From: Andre Przywara Date: Thu, 24 Jan 2019 11:31:43 +0000 Subject: [U-Boot] [PATCH 1/2] arm: sunxi: allwinner spi driver sun6i support In-Reply-To: References: <20190105175216.7086-1-oskari@lemmela.net> <20190105175216.7086-2-oskari@lemmela.net> <5c396578-cc87-9bb2-a9c9-3641e30a7794@suse.de> <1f7a9085-9d61-a182-fef8-512d210983b7@suse.de> <215b3b07-9caf-24f2-9ef4-15b79d1576bd@suse.de> <9ed2a1e6-0a4d-a4c6-24e9-9f8d273e0339@suse.de> <20190124105703.1b5dff49@donnerap.cambridge.arm.com> <20190124110705.15c473cc@donnerap.cambridge.arm.com> Message-ID: <20190124113143.4f9c95f5@donnerap.cambridge.arm.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: u-boot@lists.denx.de On Thu, 24 Jan 2019 12:21:17 +0100 Alexander Graf wrote: > On 24.01.19 12:07, Andre Przywara wrote: > > On Thu, 24 Jan 2019 11:59:32 +0100 > > Alexander Graf wrote: > > =20 > >> On 24.01.19 11:57, Andre Przywara wrote: =20 > >>> On Thu, 24 Jan 2019 11:17:03 +0100 > >>> Alexander Graf wrote: > >>> =20 > >>>> On 22.01.19 17:37, Alexander Graf wrote: =20 > >>>>> > >>>>> > >>>>> On 22.01.19 17:28, Alexander Graf wrote: =20 > >>>>>> > >>>>>> > >>>>>> On 22.01.19 17:17, Oskari Lemmel=C3=A4 wrote: =20 > >>>>>>> Hi, > >>>>>>> > >>>>>>> On 22.1.2019 16.54, Alexander Graf wrote: =20 > >>>>>>>> > >>>>>>>> On 05.01.19 18:52, Oskari Lemmela wrote: =20 > >>>>>>>>> Minimal changes to support sun6i based Allwinner SOCs > >>>>>>>>> Changes are based to SPL driver > >>>>>>>>> arch/arm/mach-sunxi/spl_spi_sunxi.c > >>>>>>>>> > >>>>>>>>> Signed-off-by: Oskari Lemmela =20 > >>>>>>>> I just tried to see if this patch gives me "sf" access on a > >>>>>>>> SoPine system. Unfortunately, it seems as if the sun4i_spi > >>>>>>>> driver doesn't even get probed? > >>>>>>>> > >>>>>>>> How did you manage to actually make use of this driver? > >>>>>>>> > >>>>>>>> > >>>>>>>> Alex =20 > >>>>>>> > >>>>>>> You need to add spi0 alias to dts and enable needed drivers to > >>>>>>> defconfig. You can take look from Jagan's patch [1]. > >>>>>>> > >>>>>>> I didn't include those changes as Maxime already commented [2] > >>>>>>> that Kconfig depends/defaults should be modified first. =20 > >>>>>> > >>>>>> I don't see any relation between the dts change and the Kconfig > >>>>>> dependency issues? > >>>>>> > >>>>>> But thanks for the pointer, I'll give this patch a try. =20 > >>>>> > >>>>> Ok, so I now get the SPI controller initialized, but it seems to > >>>>> only returns zeros when trying to access the SPI flash device. > >>>>> > >>>>> In other words, it doesn't work for me :). But maybe I'm missing > >>>>> all the other clk patches to actually get it working? =20 > >>>> > >>>> Ok, so turns out the problem is that you can't have eMMC and SPI > >>>> both working. I don't quite know yet whether this is just a > >>>> pinmux problem (so potentially software workaroundable) or if > >>>> it's a hardware limitation (eMMC pulling a line required for > >>>> SPI). =20 > >>> > >>> The line that is shared is "DS", which is only needed for higher > >>> (e)MMC modes (HS-400). At the moment neither Linux nor U-Boot > >>> implement this mode, and probably U-Boot will never need it: it > >>> adds software complexity for a questionable performance benefit, > >>> especially if the flash chips can't keep up with the high > >>> interface speed anyway. > >>> > >>> We addressed this in the DTs (kernel commit fa59dd2ef755). > >>> > >>> I am a bit puzzled here as why this happens: I can't find where > >>> U-Boot would configure PC1 to use the MMC2 function: the > >>> hard-coded mmc_pinmux_setup() doesn't touch PC1 at all. Maybe > >>> it's the BootROM configuring this line? So we would need to reset > >>> it? > >>> > >>> As I don't have an eMMC module here at hand right now, this has to > >>> wait till tonight for further insights. =20 > >> > >> A few more data points: > >> > >> When I boot w/o eMMC module attached, SPI flash works > >> When I then plug in the eMMC module, SPI flash still works =20 > >=20 > > Plug in with power off (which you should always do)? So it goes > > through the BootROM? > > =20 > >> When I that start initializing the eMMC module, SPI flash fails =20 > >=20 > > What do you mean by that, exactly? Accessing eMMC from U-Boot? =20 >=20 > Yes, "mmc part" to be precise. >=20 > > Because that is the interesting data point, somehow this makes the > > eMMC module drive the pin. > > =20 > >> When I then unplug the eMMC module, SPI flash works again =20 > >=20 > > Again, at runtime? =20 >=20 > Yup, all of it at runtime. I felt darey and ignored the fact that you > should really only plug the eMMC module at boot time ;). >=20 > The last step definitely did not change pinmux. Hence the conclusion > that this is line drive collision, not pinmux. >=20 > So I guess you're saying that forcing the eMMC into 4-DAT mode would > make things work? Technically DS is for HS-400, which is a step beyond 8-bit bus width. So just enabling 8 bit should not affect the DS line. There is a bit in the MMC controller to enable HS-400, but I don't see that we would set it (we actually don't even define the register). You could try to force eMMC to 4 bit to check this theory, by hack-removing the MMC_MODE_8BIT line in sunxi_mmc_init() in drivers/mmc/sunxi-mmc.c (we don't use DM_MMC yet, so it's in the hacky part and ignores the DT property) Cheers, Andre.