So I have tried a build with Yocto from code aurora (latest build) and modified for our card and we have the same issue.
I have also, with our previous builds, now tried all combinations of Linux kernel 4.9, 4.14, 4.19 and 5.0 using ext3 and ext4 for the root file system and the problem persists.
Having discussed this with our electronics engineers they are doing a redesign of the board. They are going to length tune the SD lines, even though the lines are less than 3inches so technically shouldn't need length tuning. They are also moving the SD card to a different position on our board as it was quite close to a large oscillator.
If it isn't hardware/layout then could there be something we've missed when porting the device tree?
In u-boot in our ported board.c file (adapted from the sabre SD code) we have the same pad control as on the SabreSD, which we think should work with our microSD slot:
#define USDHC_PAD_CTRL (PAD_CTL_PUS_47K_UP | \
PAD_CTL_SPEED_LOW | PAD_CTL_DSE_80ohm | \
PAD_CTL_SRE_FAST | PAD_CTL_HYS)
The I/O mux is set as follows:
static iomux_v3_cfg_t const usdhc4_pads[] = {
IOMUX_PADS(PAD_SD4_CLK__SD4_CLK | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
IOMUX_PADS(PAD_SD4_CMD__SD4_CMD | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
IOMUX_PADS(PAD_SD4_DAT0__SD4_DATA0 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
IOMUX_PADS(PAD_SD4_DAT1__SD4_DATA1 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
IOMUX_PADS(PAD_SD4_DAT2__SD4_DATA2 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
IOMUX_PADS(PAD_SD4_DAT3__SD4_DATA3 | MUX_PAD_CTRL(USDHC_PAD_CTRL)),
};
In the kernel device tree we have the following (adapted from the sabre SD tree):
pinctrl_usdhc4: usdhc4grp {
fsl,pins = <
MX6QDL_PAD_SD4_CMD__SD4_CMD 0x17059
MX6QDL_PAD_SD4_CLK__SD4_CLK 0x10059
MX6QDL_PAD_SD4_DAT0__SD4_DATA0 0x17059
MX6QDL_PAD_SD4_DAT1__SD4_DATA1 0x17059
MX6QDL_PAD_SD4_DAT2__SD4_DATA2 0x17059
MX6QDL_PAD_SD4_DAT3__SD4_DATA3 0x17059
>;
};
&usdhc4{
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_usdhc4>;
bus-width = <4>;
non-removable;
disable-wp;
status = "okay";
};
One thing we have noticed is that in the pinctrl in the DTSI snippet 0x17059 when decoded shows this represents:
<bit 16> to <bit 0>
1 - schmitt triggered
01 - 47kOhm pullup
1 - pullup
1 - pullup enabled
0 - CMOS output
000 - ?
01 - medium (100- 150MHz)
011 - 50Ohm (80 Ohm if DDR)
00 - ?
1 - fast slew rate
This seems to set the speed to medium (100-150MHz) but in u-boot it is set as PAD_CTL_SPEED_LOW (equivalent to 50MHz). We would have expected the setting to be 50MHz in the device tree also. Why is the SabreSD setup like this (with a difference between its u-boot and kernel settings)?
We have tried changing the device tree values to use low speed but it made no difference. We also have hardware pull-ups of 10 kOhm in parallel with the software pull-ups (those set in u-boot/device tree) so we have also tried removing these from our board but this also didn't help.