[U-Boot] [PATCH] km/spi: port SPI flash of KM Kirkwood boards to driver model

Stefan Roese sr at denx.de
Thu Jun 13 06:46:23 UTC 2019


On 04.06.19 14:23, pascal.linder at edu.hefr.ch wrote:
> From: Pascal Linder <pascal.linder at edu.hefr.ch>
> 
> The required configurations were activated in the default configuration
> files of the board series and the SPI interface setting is added to
> the common device tree file.
> 
> Some adaptions were necessary in the driver (kirkwood_spi.c) in order to
> support the driver model on the shared SPI bus. Weak functions were added
> to the claim and release operation (release was not yet implemented) and
> can be overwritten in the board specific file. For KM boards these
> functionality is needed to change the MPP configuration when claiming
> or releasing the bus as the pins are shared between the NAND and SPI NOR
> device.
> 
> Finally, the deprecated code in the driver could be deleted as only KM
> boards were overwriting these weak functions. Every occurrence of the
> now unused preprocessor definition CONFIG_SYS_KW_SPI_MPP and its
> associated defines were removed as well.
> 
> Signed-off-by: Pascal Linder <pascal.linder at edu.hefr.ch>
> Signed-off-by: Holger Brunck <holger.brunck at ch.abb.com>
> ---
>   arch/arm/dts/kirkwood-km_kirkwood.dts | 22 +++++++++
>   arch/arm/include/asm/arch-mvebu/spi.h | 11 -----
>   board/keymile/km_arm/km_arm.c         | 23 ++++++++-
>   configs/km_kirkwood_128m16_defconfig  |  4 ++
>   configs/km_kirkwood_defconfig         |  4 ++
>   configs/km_kirkwood_pci_defconfig     |  4 ++
>   configs/kmcoge5un_defconfig           |  4 ++
>   configs/kmnusa_defconfig              |  4 ++
>   configs/kmsugp1_defconfig             |  4 ++
>   configs/kmsuv31_defconfig             |  4 ++
>   configs/mgcoge3un_defconfig           |  4 ++
>   configs/portl2_defconfig              |  7 ++-
>   drivers/spi/kirkwood_spi.c            | 71 ++++++---------------------
>   include/configs/km/km_arm.h           |  2 -
>   scripts/config_whitelist.txt          |  1 -
>   15 files changed, 97 insertions(+), 72 deletions(-)

It would be better (easier to review) to split this patch into multiple
separate patches. Perhaps something like this (just a rough idea):

patch 1/5: Add board specific MPP handling to kirkwood-spi (DM version)
patch 2/5: Add SPI nodes and properties to Keymile DT files
patch 3/5: Enable DM_SPI in defconfigs
patch 4/5: Add board specific DM SPI MPP stuff to Keymile boards
patch 5/5: Remove now unused MPP stuff (non-DM driver and header)

Please find some further comments below.

> 
> diff --git a/arch/arm/dts/kirkwood-km_kirkwood.dts b/arch/arm/dts/kirkwood-km_kirkwood.dts
> index f035eff1c11..b2c0209f5db 100644
> --- a/arch/arm/dts/kirkwood-km_kirkwood.dts
> +++ b/arch/arm/dts/kirkwood-km_kirkwood.dts
> @@ -13,6 +13,10 @@
>   		device_type = "memory";
>   		reg = <0x00000000 0x08000000>;
>   	};
> +
> +	aliases {
> +		spi0 = &spi0;
> +	};
>   };
>   
>   &mdio {
> @@ -29,3 +33,21 @@
>   		phy-handle = <&ethphy0>;
>   	};
>   };
> +
> +&spi0 {
> +	status = "okay";
> +
> +	flash at 0 {
> +		#address-cells = <1>;
> +		#size-cells = <1>;
> +		compatible = "st,m25p80", "jedec,spi-nor", "spi-flash";
> +		reg = <0>;
> +		spi-max-frequency = <33000000>;
> +		mode = <3>;
> +
> +		partition at uboot {
> +			reg = <0x000000 0x0c0000>;
> +			label = "uboot";
> +		};
> +	};
> +};
> diff --git a/arch/arm/include/asm/arch-mvebu/spi.h b/arch/arm/include/asm/arch-mvebu/spi.h
> index d6f6d1ac574..58b6c32c4d8 100644
> --- a/arch/arm/include/asm/arch-mvebu/spi.h
> +++ b/arch/arm/include/asm/arch-mvebu/spi.h
> @@ -23,17 +23,6 @@ struct kwspi_registers {
>   	u32 dw_cfg;	/* 0x10620 - Direct Write Configuration */
>   };
>   
> -/* They are used to define CONFIG_SYS_KW_SPI_MPP
> - * each of the below #defines selects which mpp is
> - * configured for each SPI signal in spi_claim_bus
> - * bit 0: selects pin for MOSI (MPP1 if 0, MPP6 if 1)
> - * bit 1: selects pin for SCK (MPP2 if 0, MPP10 if 1)
> - * bit 2: selects pin for MISO (MPP3 if 0, MPP11 if 1)
> - */
> -#define MOSI_MPP6	(1 << 0)
> -#define SCK_MPP10	(1 << 1)
> -#define MISO_MPP11	(1 << 2)
> -
>   /* Control Register */
>   #define KWSPI_CSN_ACT		(1 << 0) /* Activates serial memory interface */
>   #define KWSPI_SMEMRDY		(1 << 1) /* SerMem Data xfer ready */
> diff --git a/board/keymile/km_arm/km_arm.c b/board/keymile/km_arm/km_arm.c
> index ea03be9eb37..3db80615ef6 100644
> --- a/board/keymile/km_arm/km_arm.c
> +++ b/board/keymile/km_arm/km_arm.c
> @@ -310,16 +310,35 @@ int board_late_init(void)
>   	return 0;
>   }
>   
> -int board_spi_claim_bus(struct spi_slave *slave)
> +static const u32 spi_mpp_config[] = {
> +	MPP1_SPI_MOSI,
> +	MPP2_SPI_SCK,
> +	MPP3_SPI_MISO,
> +	0
> +};
> +
> +static u32 spi_mpp_backup[4];
> +
> +int mvebu_board_spi_claim_bus(struct udevice *dev)
>   {
> +	spi_mpp_backup[3] = 0;
> +
> +	/* set new spi mpp config and save current one */
> +	kirkwood_mpp_conf(spi_mpp_config, spi_mpp_backup);
> +
>   	kw_gpio_set_value(KM_FLASH_GPIO_PIN, 0);
>   
>   	return 0;
>   }
>   
> -void board_spi_release_bus(struct spi_slave *slave)
> +int mvebu_board_spi_release_bus(struct udevice *dev)
>   {
> +	/* restore saved mpp config */
> +	kirkwood_mpp_conf(spi_mpp_backup, NULL);
> +
>   	kw_gpio_set_value(KM_FLASH_GPIO_PIN, 1);
> +
> +	return 0;
>   }
>   
>   #if (defined(CONFIG_KM_PIGGY4_88E6061))
> diff --git a/configs/km_kirkwood_128m16_defconfig b/configs/km_kirkwood_128m16_defconfig
> index 92fb2481112..707aace2759 100644
> --- a/configs/km_kirkwood_128m16_defconfig
> +++ b/configs/km_kirkwood_128m16_defconfig
> @@ -3,6 +3,7 @@ CONFIG_KIRKWOOD=y
>   CONFIG_SYS_TEXT_BASE=0x07d00000
>   CONFIG_TARGET_KM_KIRKWOOD=y
>   CONFIG_IDENT_STRING="\nKeymile Kirkwood 128M16"
> +# CONFIG_SYS_MALLOC_F is not set
>   CONFIG_SYS_EXTRA_OPTIONS="KM_KIRKWOOD_128M16"
>   CONFIG_MISC_INIT_R=y
>   CONFIG_VERSION_VARIABLE=y
> @@ -30,10 +31,12 @@ CONFIG_CMD_UBI=y
>   CONFIG_OF_CONTROL=y
>   CONFIG_DEFAULT_DEVICE_TREE="kirkwood-km_kirkwood"
>   CONFIG_ENV_IS_IN_EEPROM=y
> +CONFIG_DM=y
>   CONFIG_BOOTCOUNT_LIMIT=y
>   CONFIG_BOOTCOUNT_RAM=y
>   CONFIG_BOOTCOUNT_BOOTLIMIT=3
>   # CONFIG_MMC is not set
> +CONFIG_DM_SPI_FLASH=y
>   CONFIG_SPI_FLASH=y
>   CONFIG_SF_DEFAULT_SPEED=8100000
>   CONFIG_SPI_FLASH_STMICRO=y
> @@ -41,5 +44,6 @@ CONFIG_MVGBE=y
>   CONFIG_MII=y
>   CONFIG_SYS_NS16550=y
>   CONFIG_SPI=y
> +CONFIG_DM_SPI=y
>   CONFIG_KIRKWOOD_SPI=y
>   CONFIG_BCH=y
> diff --git a/configs/km_kirkwood_defconfig b/configs/km_kirkwood_defconfig
> index b1a95cb381e..30e548a9f14 100644
> --- a/configs/km_kirkwood_defconfig
> +++ b/configs/km_kirkwood_defconfig
> @@ -3,6 +3,7 @@ CONFIG_KIRKWOOD=y
>   CONFIG_SYS_TEXT_BASE=0x07d00000
>   CONFIG_TARGET_KM_KIRKWOOD=y
>   CONFIG_IDENT_STRING="\nKeymile Kirkwood"
> +# CONFIG_SYS_MALLOC_F is not set
>   CONFIG_SYS_EXTRA_OPTIONS="KM_KIRKWOOD"
>   CONFIG_MISC_INIT_R=y
>   CONFIG_VERSION_VARIABLE=y
> @@ -30,10 +31,12 @@ CONFIG_CMD_UBI=y
>   CONFIG_OF_CONTROL=y
>   CONFIG_DEFAULT_DEVICE_TREE="kirkwood-km_kirkwood"
>   CONFIG_ENV_IS_IN_EEPROM=y
> +CONFIG_DM=y
>   CONFIG_BOOTCOUNT_LIMIT=y
>   CONFIG_BOOTCOUNT_RAM=y
>   CONFIG_BOOTCOUNT_BOOTLIMIT=3
>   # CONFIG_MMC is not set
> +CONFIG_DM_SPI_FLASH=y
>   CONFIG_SPI_FLASH=y
>   CONFIG_SF_DEFAULT_SPEED=8100000
>   CONFIG_SPI_FLASH_STMICRO=y
> @@ -41,5 +44,6 @@ CONFIG_MVGBE=y
>   CONFIG_MII=y
>   CONFIG_SYS_NS16550=y
>   CONFIG_SPI=y
> +CONFIG_DM_SPI=y
>   CONFIG_KIRKWOOD_SPI=y
>   CONFIG_BCH=y
> diff --git a/configs/km_kirkwood_pci_defconfig b/configs/km_kirkwood_pci_defconfig
> index 443399daf2b..bbc359bd835 100644
> --- a/configs/km_kirkwood_pci_defconfig
> +++ b/configs/km_kirkwood_pci_defconfig
> @@ -3,6 +3,7 @@ CONFIG_KIRKWOOD=y
>   CONFIG_SYS_TEXT_BASE=0x07d00000
>   CONFIG_TARGET_KM_KIRKWOOD=y
>   CONFIG_IDENT_STRING="\nKeymile Kirkwood PCI"
> +# CONFIG_SYS_MALLOC_F is not set
>   CONFIG_SYS_EXTRA_OPTIONS="KM_KIRKWOOD_PCI"
>   CONFIG_MISC_INIT_R=y
>   CONFIG_VERSION_VARIABLE=y
> @@ -30,10 +31,12 @@ CONFIG_CMD_UBI=y
>   CONFIG_OF_CONTROL=y
>   CONFIG_DEFAULT_DEVICE_TREE="kirkwood-km_kirkwood"
>   CONFIG_ENV_IS_IN_EEPROM=y
> +CONFIG_DM=y
>   CONFIG_BOOTCOUNT_LIMIT=y
>   CONFIG_BOOTCOUNT_RAM=y
>   CONFIG_BOOTCOUNT_BOOTLIMIT=3
>   # CONFIG_MMC is not set
> +CONFIG_DM_SPI_FLASH=y
>   CONFIG_SPI_FLASH=y
>   CONFIG_SF_DEFAULT_SPEED=8100000
>   CONFIG_SPI_FLASH_STMICRO=y
> @@ -41,5 +44,6 @@ CONFIG_MVGBE=y
>   CONFIG_MII=y
>   CONFIG_SYS_NS16550=y
>   CONFIG_SPI=y
> +CONFIG_DM_SPI=y
>   CONFIG_KIRKWOOD_SPI=y
>   CONFIG_BCH=y
> diff --git a/configs/kmcoge5un_defconfig b/configs/kmcoge5un_defconfig
> index 7ec728149d8..25de085ca68 100644
> --- a/configs/kmcoge5un_defconfig
> +++ b/configs/kmcoge5un_defconfig
> @@ -3,6 +3,7 @@ CONFIG_KIRKWOOD=y
>   CONFIG_SYS_TEXT_BASE=0x07d00000
>   CONFIG_TARGET_KM_KIRKWOOD=y
>   CONFIG_IDENT_STRING="\nKeymile COGE5UN"
> +# CONFIG_SYS_MALLOC_F is not set
>   CONFIG_SYS_EXTRA_OPTIONS="KM_COGE5UN"
>   CONFIG_MISC_INIT_R=y
>   CONFIG_VERSION_VARIABLE=y
> @@ -30,10 +31,12 @@ CONFIG_CMD_UBI=y
>   CONFIG_OF_CONTROL=y
>   CONFIG_DEFAULT_DEVICE_TREE="kirkwood-km_kirkwood"
>   CONFIG_ENV_IS_IN_SPI_FLASH=y
> +CONFIG_DM=y
>   CONFIG_BOOTCOUNT_LIMIT=y
>   CONFIG_BOOTCOUNT_RAM=y
>   CONFIG_BOOTCOUNT_BOOTLIMIT=3
>   # CONFIG_MMC is not set
> +CONFIG_DM_SPI_FLASH=y
>   CONFIG_SPI_FLASH=y
>   CONFIG_SF_DEFAULT_SPEED=8100000
>   CONFIG_SPI_FLASH_STMICRO=y
> @@ -41,5 +44,6 @@ CONFIG_MVGBE=y
>   CONFIG_MII=y
>   CONFIG_SYS_NS16550=y
>   CONFIG_SPI=y
> +CONFIG_DM_SPI=y
>   CONFIG_KIRKWOOD_SPI=y
>   CONFIG_BCH=y
> diff --git a/configs/kmnusa_defconfig b/configs/kmnusa_defconfig
> index 34ece1888a3..4827b64e903 100644
> --- a/configs/kmnusa_defconfig
> +++ b/configs/kmnusa_defconfig
> @@ -3,6 +3,7 @@ CONFIG_KIRKWOOD=y
>   CONFIG_SYS_TEXT_BASE=0x07d00000
>   CONFIG_TARGET_KM_KIRKWOOD=y
>   CONFIG_IDENT_STRING="\nKeymile NUSA"
> +# CONFIG_SYS_MALLOC_F is not set
>   CONFIG_SYS_EXTRA_OPTIONS="KM_NUSA"
>   CONFIG_MISC_INIT_R=y
>   CONFIG_VERSION_VARIABLE=y
> @@ -30,10 +31,12 @@ CONFIG_CMD_UBI=y
>   CONFIG_OF_CONTROL=y
>   CONFIG_DEFAULT_DEVICE_TREE="kirkwood-km_kirkwood"
>   CONFIG_ENV_IS_IN_SPI_FLASH=y
> +CONFIG_DM=y
>   CONFIG_BOOTCOUNT_LIMIT=y
>   CONFIG_BOOTCOUNT_RAM=y
>   CONFIG_BOOTCOUNT_BOOTLIMIT=3
>   # CONFIG_MMC is not set
> +CONFIG_DM_SPI_FLASH=y
>   CONFIG_SPI_FLASH=y
>   CONFIG_SF_DEFAULT_SPEED=8100000
>   CONFIG_SPI_FLASH_STMICRO=y
> @@ -41,5 +44,6 @@ CONFIG_MVGBE=y
>   CONFIG_MII=y
>   CONFIG_SYS_NS16550=y
>   CONFIG_SPI=y
> +CONFIG_DM_SPI=y
>   CONFIG_KIRKWOOD_SPI=y
>   CONFIG_BCH=y
> diff --git a/configs/kmsugp1_defconfig b/configs/kmsugp1_defconfig
> index 63c5925fdc6..258c249eab3 100644
> --- a/configs/kmsugp1_defconfig
> +++ b/configs/kmsugp1_defconfig
> @@ -3,6 +3,7 @@ CONFIG_KIRKWOOD=y
>   CONFIG_SYS_TEXT_BASE=0x07d00000
>   CONFIG_TARGET_KM_KIRKWOOD=y
>   CONFIG_IDENT_STRING="\nKeymile SUGP1"
> +# CONFIG_SYS_MALLOC_F is not set
>   CONFIG_SYS_EXTRA_OPTIONS="KM_SUGP1"
>   CONFIG_MISC_INIT_R=y
>   CONFIG_VERSION_VARIABLE=y
> @@ -30,10 +31,12 @@ CONFIG_CMD_UBI=y
>   CONFIG_OF_CONTROL=y
>   CONFIG_DEFAULT_DEVICE_TREE="kirkwood-km_kirkwood"
>   CONFIG_ENV_IS_IN_SPI_FLASH=y
> +CONFIG_DM=y
>   CONFIG_BOOTCOUNT_LIMIT=y
>   CONFIG_BOOTCOUNT_RAM=y
>   CONFIG_BOOTCOUNT_BOOTLIMIT=3
>   # CONFIG_MMC is not set
> +CONFIG_DM_SPI_FLASH=y
>   CONFIG_SPI_FLASH=y
>   CONFIG_SF_DEFAULT_SPEED=8100000
>   CONFIG_SPI_FLASH_STMICRO=y
> @@ -41,5 +44,6 @@ CONFIG_MVGBE=y
>   CONFIG_MII=y
>   CONFIG_SYS_NS16550=y
>   CONFIG_SPI=y
> +CONFIG_DM_SPI=y
>   CONFIG_KIRKWOOD_SPI=y
>   CONFIG_BCH=y
> diff --git a/configs/kmsuv31_defconfig b/configs/kmsuv31_defconfig
> index b2d62320a4c..6ddc533c2b2 100644
> --- a/configs/kmsuv31_defconfig
> +++ b/configs/kmsuv31_defconfig
> @@ -3,6 +3,7 @@ CONFIG_KIRKWOOD=y
>   CONFIG_SYS_TEXT_BASE=0x07d00000
>   CONFIG_TARGET_KM_KIRKWOOD=y
>   CONFIG_IDENT_STRING="\nKeymile SUV31"
> +# CONFIG_SYS_MALLOC_F is not set
>   CONFIG_SYS_EXTRA_OPTIONS="KM_SUV31"
>   CONFIG_MISC_INIT_R=y
>   CONFIG_VERSION_VARIABLE=y
> @@ -30,10 +31,12 @@ CONFIG_CMD_UBI=y
>   CONFIG_OF_CONTROL=y
>   CONFIG_DEFAULT_DEVICE_TREE="kirkwood-km_kirkwood"
>   CONFIG_ENV_IS_IN_SPI_FLASH=y
> +CONFIG_DM=y
>   CONFIG_BOOTCOUNT_LIMIT=y
>   CONFIG_BOOTCOUNT_RAM=y
>   CONFIG_BOOTCOUNT_BOOTLIMIT=3
>   # CONFIG_MMC is not set
> +CONFIG_DM_SPI_FLASH=y
>   CONFIG_SPI_FLASH=y
>   CONFIG_SF_DEFAULT_SPEED=8100000
>   CONFIG_SPI_FLASH_STMICRO=y
> @@ -41,5 +44,6 @@ CONFIG_MVGBE=y
>   CONFIG_MII=y
>   CONFIG_SYS_NS16550=y
>   CONFIG_SPI=y
> +CONFIG_DM_SPI=y
>   CONFIG_KIRKWOOD_SPI=y
>   CONFIG_BCH=y
> diff --git a/configs/mgcoge3un_defconfig b/configs/mgcoge3un_defconfig
> index d85a216ddba..4f956c3417a 100644
> --- a/configs/mgcoge3un_defconfig
> +++ b/configs/mgcoge3un_defconfig
> @@ -3,6 +3,7 @@ CONFIG_KIRKWOOD=y
>   CONFIG_SYS_TEXT_BASE=0x07d00000
>   CONFIG_TARGET_KM_KIRKWOOD=y
>   CONFIG_IDENT_STRING="\nKeymile COGE3UN"
> +# CONFIG_SYS_MALLOC_F is not set
>   CONFIG_SYS_EXTRA_OPTIONS="KM_MGCOGE3UN"
>   CONFIG_MISC_INIT_R=y
>   CONFIG_VERSION_VARIABLE=y
> @@ -30,10 +31,12 @@ CONFIG_CMD_UBI=y
>   CONFIG_OF_CONTROL=y
>   CONFIG_DEFAULT_DEVICE_TREE="kirkwood-km_kirkwood"
>   CONFIG_ENV_IS_IN_EEPROM=y
> +CONFIG_DM=y
>   CONFIG_BOOTCOUNT_LIMIT=y
>   CONFIG_BOOTCOUNT_RAM=y
>   CONFIG_BOOTCOUNT_BOOTLIMIT=3
>   # CONFIG_MMC is not set
> +CONFIG_DM_SPI_FLASH=y
>   CONFIG_SPI_FLASH=y
>   CONFIG_SF_DEFAULT_SPEED=8100000
>   CONFIG_SPI_FLASH_STMICRO=y
> @@ -41,5 +44,6 @@ CONFIG_MVGBE=y
>   CONFIG_MII=y
>   CONFIG_SYS_NS16550=y
>   CONFIG_SPI=y
> +CONFIG_DM_SPI=y
>   CONFIG_KIRKWOOD_SPI=y
>   CONFIG_BCH=y
> diff --git a/configs/portl2_defconfig b/configs/portl2_defconfig
> index 7e0abaa8371..201a1b1920a 100644
> --- a/configs/portl2_defconfig
> +++ b/configs/portl2_defconfig
> @@ -3,6 +3,7 @@ CONFIG_KIRKWOOD=y
>   CONFIG_SYS_TEXT_BASE=0x07d00000
>   CONFIG_TARGET_KM_KIRKWOOD=y
>   CONFIG_IDENT_STRING="\nKeymile Port-L2"
> +# CONFIG_SYS_MALLOC_F is not set
>   CONFIG_SYS_EXTRA_OPTIONS="KM_PORTL2"
>   CONFIG_MISC_INIT_R=y
>   CONFIG_VERSION_VARIABLE=y
> @@ -27,11 +28,15 @@ CONFIG_MTDIDS_DEFAULT="nand0=orion_nand"
>   CONFIG_MTDPARTS_DEFAULT="mtdparts=orion_nand:-(ubi0);"
>   CONFIG_CMD_UBI=y
>   # CONFIG_CMD_UBIFS is not set
> +CONFIG_OF_CONTROL=y
> +CONFIG_DEFAULT_DEVICE_TREE="kirkwood-km_kirkwood"
>   CONFIG_ENV_IS_IN_EEPROM=y
> +CONFIG_DM=y
>   CONFIG_BOOTCOUNT_LIMIT=y
>   CONFIG_BOOTCOUNT_RAM=y
>   CONFIG_BOOTCOUNT_BOOTLIMIT=3
>   # CONFIG_MMC is not set
> +CONFIG_DM_SPI_FLASH=y
>   CONFIG_SPI_FLASH=y
>   CONFIG_SF_DEFAULT_SPEED=8100000
>   CONFIG_SPI_FLASH_STMICRO=y
> @@ -39,6 +44,6 @@ CONFIG_MVGBE=y
>   CONFIG_MII=y
>   CONFIG_SYS_NS16550=y
>   CONFIG_SPI=y
> +CONFIG_DM_SPI=y
>   CONFIG_KIRKWOOD_SPI=y
>   CONFIG_BCH=y
> -CONFIG_OF_LIBFDT=y
> diff --git a/drivers/spi/kirkwood_spi.c b/drivers/spi/kirkwood_spi.c
> index 5dd1ad67cfc..b0126b05613 100644
> --- a/drivers/spi/kirkwood_spi.c
> +++ b/drivers/spi/kirkwood_spi.c
> @@ -151,61 +151,6 @@ void spi_free_slave(struct spi_slave *slave)
>   	free(slave);
>   }
>   
> -#if defined(CONFIG_SYS_KW_SPI_MPP)
> -u32 spi_mpp_backup[4];
> -#endif
> -
> -__attribute__((weak)) int board_spi_claim_bus(struct spi_slave *slave)
> -{
> -	return 0;
> -}
> -
> -int spi_claim_bus(struct spi_slave *slave)
> -{
> -#if defined(CONFIG_SYS_KW_SPI_MPP)
> -	u32 config;
> -	u32 spi_mpp_config[4];
> -
> -	config = CONFIG_SYS_KW_SPI_MPP;
> -
> -	if (config & MOSI_MPP6)
> -		spi_mpp_config[0] = MPP6_SPI_MOSI;
> -	else
> -		spi_mpp_config[0] = MPP1_SPI_MOSI;
> -
> -	if (config & SCK_MPP10)
> -		spi_mpp_config[1] = MPP10_SPI_SCK;
> -	else
> -		spi_mpp_config[1] = MPP2_SPI_SCK;
> -
> -	if (config & MISO_MPP11)
> -		spi_mpp_config[2] = MPP11_SPI_MISO;
> -	else
> -		spi_mpp_config[2] = MPP3_SPI_MISO;
> -
> -	spi_mpp_config[3] = 0;
> -	spi_mpp_backup[3] = 0;
> -
> -	/* set new spi mpp and save current mpp config */
> -	kirkwood_mpp_conf(spi_mpp_config, spi_mpp_backup);
> -#endif
> -
> -	return board_spi_claim_bus(slave);
> -}
> -
> -__attribute__((weak)) void board_spi_release_bus(struct spi_slave *slave)
> -{
> -}
> -
> -void spi_release_bus(struct spi_slave *slave)
> -{
> -#if defined(CONFIG_SYS_KW_SPI_MPP)
> -	kirkwood_mpp_conf(spi_mpp_backup, NULL);
> -#endif
> -
> -	board_spi_release_bus(slave);
> -}
> -
>   #ifndef CONFIG_SPI_CS_IS_VALID
>   /*
>    * you can define this function board specific
> @@ -338,6 +283,11 @@ static int mvebu_spi_xfer(struct udevice *dev, unsigned int bitlen,
>   	return _spi_xfer(plat->spireg, bitlen, dout, din, flags);
>   }
>   
> +__attribute__((weak)) int mvebu_board_spi_claim_bus(struct udevice *dev)
> +{
> +	return 0;
> +}
> +

I don't really like this weak function in this common code. But frankly,
I don't have a better idea on how to easily implement a board specific
claim / release function. So let's give it a try, if nobody else comes
up with a better version.

>   static int mvebu_spi_claim_bus(struct udevice *dev)
>   {
>   	struct udevice *bus = dev->parent;
> @@ -348,9 +298,19 @@ static int mvebu_spi_claim_bus(struct udevice *dev)
>   			KWSPI_CS_MASK << KWSPI_CS_SHIFT,
>   			spi_chip_select(dev) << KWSPI_CS_SHIFT);
>   
> +	return mvebu_board_spi_claim_bus(dev);
> +}
> +
> +__attribute__((weak)) int mvebu_board_spi_release_bus(struct udevice *dev)
> +{
>   	return 0;
>   }
>   
> +static int mvebu_spi_release_bus(struct udevice *dev)
> +{
> +	return mvebu_board_spi_release_bus(dev);
> +}
> +
>   static int mvebu_spi_probe(struct udevice *bus)
>   {
>   	struct mvebu_spi_platdata *plat = dev_get_platdata(bus);
> @@ -377,6 +337,7 @@ static int mvebu_spi_ofdata_to_platdata(struct udevice *bus)
>   
>   static const struct dm_spi_ops mvebu_spi_ops = {
>   	.claim_bus	= mvebu_spi_claim_bus,
> +	.release_bus = mvebu_spi_release_bus,

Indention not correct.

>   	.xfer		= mvebu_spi_xfer,
>   	.set_speed	= mvebu_spi_set_speed,
>   	.set_mode	= mvebu_spi_set_mode,
> diff --git a/include/configs/km/km_arm.h b/include/configs/km/km_arm.h
> index 8a00ac015ac..e0a6fabbeab 100644
> --- a/include/configs/km/km_arm.h
> +++ b/include/configs/km/km_arm.h
> @@ -203,8 +203,6 @@ int get_scl(void);
>   
>   
>   /* SPI bus claim MPP configuration */
> -#define CONFIG_SYS_KW_SPI_MPP	0x0
> -
>   #define FLASH_GPIO_PIN			0x00010000
>   #define KM_FLASH_GPIO_PIN	16
>   
> diff --git a/scripts/config_whitelist.txt b/scripts/config_whitelist.txt
> index b16bc6ae34c..ca47944f95e 100644
> --- a/scripts/config_whitelist.txt
> +++ b/scripts/config_whitelist.txt
> @@ -3186,7 +3186,6 @@ CONFIG_SYS_JFFS2_SORT_FRAGMENTS
>   CONFIG_SYS_KMBEC_FPGA_BASE
>   CONFIG_SYS_KMBEC_FPGA_SIZE
>   CONFIG_SYS_KWD_CONFIG
> -CONFIG_SYS_KW_SPI_MPP
>   CONFIG_SYS_L2
>   CONFIG_SYS_L2_PL310
>   CONFIG_SYS_L2_SIZE

This patch break compilation for other Kirkwood based boards (perhaps
even MVEBU, I didn't check). E.g.:

d2net_v2:
drivers/mtd/spi/built-in.o: In function `spi_flash_probe_slave':
/home/stefan/git/u-boot/u-boot-marvell/drivers/mtd/spi/sf_probe.c:37: undefined reference to `spi_claim_bus'
/home/stefan/git/u-boot/u-boot-marvell/drivers/mtd/spi/sf_probe.c:52: undefined reference to `spi_release_bus'
drivers/spi/built-in.o: In function `spi_mem_exec_op':
/home/stefan/git/u-boot/u-boot-marvell/drivers/spi/spi-mem-nodm.c:31: undefined reference to `spi_claim_bus'
/home/stefan/git/u-boot/u-boot-marvell/drivers/spi/spi-mem-nodm.c:66: undefined reference to `spi_release_bus'
/opt/linaro/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ld.bfd: BFD (Linaro_Binutils-2019.02) 2.28.2.20170706 assertion fail /home/tcwg-buildslave/workspace/tcwg-make-release_0/snapshots/binutils-gdb.git~users~linaro~binutils-2_28-branch/bfd/elf32-arm.c:9514
/opt/linaro/gcc-linaro-7.4.1-2019.02-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ld.bfd: BFD (Linaro_Binutils-2019.02) 2.28.2.20170706 assertion fail /home/tcwg-buildslave/workspace/tcwg-make-release_0/snapshots/binutils-gdb.git~users~linaro~binutils-2_28-branch/bfd/elf32-arm.c:9514
make: *** [Makefile:1570: u-boot] Error 1

Please make sure that no breakage occurs. buildman is quite handy here.

Thanks,
Stefan


More information about the U-Boot mailing list