]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
arm: mvebu: turris_mox: Fix unstable board topology reading
authorMarek Behún <marek.behun@nic.cz>
Fri, 26 Nov 2021 13:57:14 +0000 (14:57 +0100)
committerStefan Roese <sr@denx.de>
Sun, 19 Dec 2021 08:50:47 +0000 (09:50 +0100)
The pre-relocation board topology reading in board_fix_fdt() is
unstable: sometimes wrong data are read from the SPI bus.

This is due to wrong order of SPI bus configuration instructions: we
first need to set the pins to SPI mode, and only after that configure
the bus.

Also add a 1ms delay before enabling chip-select, so that the clock pin
is high for some time before reading the bus.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Stefan Roese <sr@denx.de>
board/CZ.NIC/turris_mox/turris_mox.c

index 502f6fc0109e758d2e6b2fdd124438ef6bc61dc3..809ce82d2014e9bedf6d3881bfcae156d4b27379 100644 (file)
@@ -56,9 +56,11 @@ int board_fix_fdt(void *blob)
         * to read SPI by reading/writing SPI registers directly
         */
 
-       writel(0x10df, ARMADA_37XX_SPI_CFG);
        /* put pin from GPIO to SPI mode */
        clrbits_le32(ARMADA_37XX_NB_GPIO_SEL, BIT(12));
+       /* configure cpol, cpha, prescale */
+       writel(0x10df, ARMADA_37XX_SPI_CFG);
+       mdelay(1);
        /* enable SPI CS1 */
        setbits_le32(ARMADA_37XX_SPI_CTRL, BIT(17));