dm: mmc: Add driver-model support for MMC operations
Subsystems (10)
cover dm: mmc: Add driver-model support for MMC operations
At present MMC does not use driver model for its operations. It uses its own structure and passes a struct mmc instead of a struct udevice.
This series addresses this by adding driver-model operations for MMC. The conversion process is also started, with patches for rockchip, zynq and qualcomm.
The zynq patches are a starting point only and need more work.
Simon Glass (27):
dm: mmc: dwmmc: Add comments to the dwmmc setup functions
rockchip: Use 'select' instead of defaults in Kconfig
mmc: Add function declarations for mmc_bread() and mmc_switch_part()
dm: mmc: Move CONFIG_BLK code into the mmc uclass
dm: mmc: Move non-CONFIG_BLK code into mmc_legacy.c
mmc: Move MMC boot code into its own file
dm: mmc: rockchip: Support only CONFIG_BLK
mmc: Move tracing code into separate functions
rockchip: Disable CONFIG_SDHCI
dm: mmc: Add a way to use driver model for MMC operations
dm: mmc: dwmmc: Support CONFIG_DM_MMC_OPS
dm: mmc: rockchip: Enable CONFIG_DM_MMC_OPS for all boards
rockchip: Add MAINTAINER files for kylin_rk3036, evb_rk3036
dm: sandbox: Convert to use CONFIG_CMD_MMC_OPS
dm: mmc: sdhci: Refactor configuration setup to support DM
dm: mmc: sdhci: Support CONFIG_BLK and CONFIG_DM_MMC_OPS
dm: mmc: msm_sdhci: Support CONFIG_BLK and CONFIG_DM_MMC_OPS
dm: mmc: Move dragonboard410c to use CONFIG_BLK and CONFIG_DM_MMC_OPS
dm: mmc: msmsdhic: Drop old MMC code
dm: spl: mmc: Support CONFIG_BLK in SPL MMC
dm: dfu: mmc: Support CONFIG_BLK in DFU for MMC
net: phy: marvell: Add a missing errno.h header
zynq: Increase the early malloc() size
dm: zynq: usb: Convert to CONFIG_DM_USB
dm: mmc: zynq: Convert zynq to use driver model for MMC
dm: mmc: Enable DM_MMC_OPS by default with DM_MMC
dm: blk: Enable CONFIG_BLK if DM_MMC is enabled
arch/Kconfig | 1 + arch/arm/Kconfig | 18 ++ arch/arm/cpu/armv8/zynqmp/Kconfig | 4 + arch/arm/mach-rockchip/Kconfig | 27 --- arch/arm/mach-zynq/Kconfig | 3 + board/evb_rk3036/evb_rk3036/MAINTAINERS | 6 + board/kylin/kylin_rk3036/MAINTAINERS | 6 + common/spl/spl_mmc.c | 6 +- configs/dragonboard410c_defconfig | 2 + configs/sandbox_defconfig | 4 +- drivers/block/Kconfig | 1 + drivers/dfu/dfu_mmc.c | 11 +- drivers/mmc/Kconfig | 12 +- drivers/mmc/Makefile | 3 + drivers/mmc/dw_mmc.c | 33 +++ drivers/mmc/mmc-uclass.c | 146 +++++++++++++ drivers/mmc/mmc.c | 371 +++++--------------------------- drivers/mmc/mmc_boot.c | 131 +++++++++++ drivers/mmc/mmc_legacy.c | 91 ++++++++ drivers/mmc/mmc_private.h | 47 ++++ drivers/mmc/msm_sdhci.c | 38 +++- drivers/mmc/rockchip_dw_mmc.c | 14 +- drivers/mmc/sandbox_mmc.c | 17 +- drivers/mmc/sdhci.c | 147 ++++++++----- drivers/mmc/zynq_sdhci.c | 39 +++- drivers/net/phy/marvell.c | 1 + drivers/usb/host/ehci-zynq.c | 102 +++++---- include/configs/rk3036_common.h | 1 - include/configs/rk3288_common.h | 1 - include/dwmmc.h | 73 +++++++ include/mmc.h | 66 +++++- include/sdhci.h | 80 +++++++ 32 files changed, 1006 insertions(+), 496 deletions(-) create mode 100644 drivers/mmc/mmc_boot.c
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 1/27 dm: mmc: dwmmc: Add comments to the dwmmc setup functions
These comments were missed when the original code was written. Add them to help people port their drivers over.
---
include/dwmmc.h | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)
include/dwmmc.h +64 -0
@@ -224,9 +224,73 @@ static inline u8 dwmci_readb(struct dwmci_host *host, int reg) return readb(host->ioaddr + reg); } +#ifdef CONFIG_BLK +/** +* dwmci_setup_cfg() - Set up the configuration for DWMMC +* +* This is used to set up a DWMMC device when you are using CONFIG_BLK. +* +* This should be called from your MMC driver's probe() method once you have +* the information required. +* +* Generally your driver will have a platform data structure which holds both +* the configuration (struct mmc_config) and the MMC device info (struct mmc). +* For example: +* +* struct rockchip_mmc_plat { +* struct mmc_config cfg; +* struct mmc mmc; +* }; +* +* ... +* +* Inside U_BOOT_DRIVER(): +* .platdata_auto_alloc_size = sizeof(struct rockchip_mmc_plat), +* +* To access platform data: +* struct rockchip_mmc_plat *plat = dev_get_platdata(dev); +* +* See rockchip_dw_mmc.c for an example. +* +* @cfg: Configuration structure to fill in (generally &plat->mmc) +* @name: Device name (normally dev->name) +* @buswidth: Bus width (in bits, such as 4 or 8) +* @caps: Host capabilities (MMC_MODE_...) +* @max_clk: Maximum supported clock speed in HZ (e.g. 400000) +* @min_clk: Minimum supported clock speed in HZ (e.g. 150000000) +*/ void dwmci_setup_cfg (struct mmc_config *cfg,const char *name,int buswidth,uint caps,u32 max_clk,u32 min_clk); + +/** +* dwmci_bind() - Set up a new MMC block device +* +* This is used to set up a DWMMC block device when you are using CONFIG_BLK. +* It should be called from your driver's bind() method. +* +* See rockchip_dw_mmc.c for an example. +* +* @dev: Device to set up +* @mmc: Pointer to mmc structure (normally &plat->mmc) +* @cfg: Empty configuration structure (generally &plat->cfg). This is +* normally all zeroes at this point. The only purpose of passing +* this in is to set mmc->cfg to it. +* @return 0 if OK, -ve if the block device could not be created +*/ int dwmci_bind (struct udevice *dev,struct mmc *mmc,struct mmc_config *cfg); +#else +/** +* add_dwmci() - Add a new DWMMC interface +* +* This is used when you are not using CONFIG_BLK. Convert your driver over! +* +* @host: DWMMC host structure +* @max_clk: Maximum supported clock speed in HZ (e.g. 400000) +* @min_clk: Minimum supported clock speed in HZ (e.g. 150000000) +* @return 0 if OK, -ve on error +*/ int add_dwmci (struct dwmci_host *host,u32 max_clk,u32 min_clk); +#endif /* !CONFIG_BLK */ +#endif /* __DWMMC_HW_H */
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 1/27 dm: mmc: dwmmc: Add comments to the dwmmc setup functions
Hi Simon,
Quoted 41 lines · Simon Glass
These comments were missed when the original code was written. Add them to help people port their drivers over.
Signed-off-by Simon Glass <[email protected]>---
include/dwmmc.h | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)include/dwmmc.h +24
-0@@ -224,9 +224,73 @@ static inline u8 dwmci_readb(struct dwmci_host *host, int reg)return readb (host->ioaddr + reg); } +#ifdef CONFIG_BLK +/** +* dwmci_setup_cfg() - Set up the configuration for DWMMC +* +* This is used to set up a DWMMC device when you are using CONFIG_BLK. +* +* This should be called from your MMC driver's probe() method once you have +* the information required. +* +* Generally your driver will have a platform data structure which holds both +* the configuration (struct mmc_config) and the MMC device info (struct mmc). +* For example: +* +* struct rockchip_mmc_plat { +* struct mmc_config cfg; +* struct mmc mmc; +* }; +* +* ... +* +* Inside U_BOOT_DRIVER(): +* .platdata_auto_alloc_size = sizeof(struct rockchip_mmc_plat), +* +* To access platform data:
include/dwmmc.h static inline u8 dwmci_readb(struct dwmci_host *host, int reg) · line 260
Quoted 10 lines
include/dwmmc.h +10
-0+* struct rockchip_mmc_plat *plat = dev_get_platdata(dev); +* +* See rockchip_dw_mmc.c for an example. +* +* @cfg: Configuration structure to fill in (generally &plat->mmc) +* @name: Device name (normally dev->name) +* @buswidth: Bus width (in bits, such as 4 or 8) +* @caps: Host capabilities (MMC_MODE_...) +* @max_clk: Maximum supported clock speed in HZ (e.g. 400000) +* @min_clk: Minimum supported clock speed in HZ (e.g. 150000000)
e,g is need to swap max_clk <-> min_clk?
Quoted 22 lines
include/dwmmc.h +18
-0+*/ void dwmci_setup_cfg (struct mmc_config *cfg,const char *name,int buswidth,uint caps,u32 max_clk,u32 min_clk); + +/** +* dwmci_bind() - Set up a new MMC block device +* +* This is used to set up a DWMMC block device when you are using CONFIG_BLK. +* It should be called from your driver's bind() method. +* +* See rockchip_dw_mmc.c for an example. +* +* @dev: Device to set up +* @mmc: Pointer to mmc structure (normally &plat->mmc) +* @cfg: Empty configuration structure (generally &plat->cfg). This is +* normally all zeroes at this point. The only purpose of passing +* this in is to set mmc->cfg to it. +* @return 0 if OK, -ve if the block device could not be created +*/ int dwmci_bind (struct udevice *dev,struct mmc *mmc,struct mmc_config *cfg); +#else
include/dwmmc.h static inline u8 dwmci_readb(struct dwmci_host *host, int reg) · line 292
Quoted 10 lines
include/dwmmc.h +10
-0+/** +* add_dwmci() - Add a new DWMMC interface +* +* This is used when you are not using CONFIG_BLK. Convert your driver over! +* +* @host: DWMMC host structure +* @max_clk: Maximum supported clock speed in HZ (e.g. 400000) +* @min_clk: Minimum supported clock speed in HZ (e.g. 150000000) +* @return 0 if OK, -ve on error +*/
Ditto.
I'm starting to covert to DM for dwmmc exynos...
After finishing convert for dwmmc_exynos, I will check in more detail on dwmmc core side.
Sorry for checking too late.
Best Regards,
Jaehoon Chung
Quoted 5 lines
include/dwmmc.h +2
-0int add_dwmci (struct dwmci_host *host,u32 max_clk,u32 min_clk); +#endif /* !CONFIG_BLK */ +#endif /* __DWMMC_HW_H */
PATCH 1/27 dm: mmc: dwmmc: Add comments to the dwmmc setup functions
Hi Jaehoon,
Quoted 93 lines · Jaehoon Chung
Hi Simon,
Quoted 41 lines · Simon Glass
These comments were missed when the original code was written. Add them to help people port their drivers over.
Signed-off-by Simon Glass <[email protected]>---
include/dwmmc.h | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)include/dwmmc.h +24
-0@@ -224,9 +224,73 @@ static inline u8 dwmci_readb(struct dwmci_host *host, int reg)return readb (host->ioaddr + reg); } +#ifdef CONFIG_BLK +/** +* dwmci_setup_cfg() - Set up the configuration for DWMMC +* +* This is used to set up a DWMMC device when you are using CONFIG_BLK. +* +* This should be called from your MMC driver's probe() method once you have +* the information required. +* +* Generally your driver will have a platform data structure which holds both +* the configuration (struct mmc_config) and the MMC device info (struct mmc). +* For example: +* +* struct rockchip_mmc_plat { +* struct mmc_config cfg; +* struct mmc mmc; +* }; +* +* ... +* +* Inside U_BOOT_DRIVER(): +* .platdata_auto_alloc_size = sizeof(struct rockchip_mmc_plat), +* +* To access platform data: include/dwmmc.h static inline u8 dwmci_readb(struct dwmci_host *host, int reg) · line 260
Quoted 10 lines
include/dwmmc.h +10
-0+* struct rockchip_mmc_plat *plat = dev_get_platdata(dev); +* +* See rockchip_dw_mmc.c for an example. +* +* @cfg: Configuration structure to fill in (generally &plat->mmc) +* @name: Device name (normally dev->name) +* @buswidth: Bus width (in bits, such as 4 or 8) +* @caps: Host capabilities (MMC_MODE_...) +* @max_clk: Maximum supported clock speed in HZ (e.g. 400000) +* @min_clk: Minimum supported clock speed in HZ (e.g. 150000000) e,g is need to swap
max_clk<->min_clk?Quoted 22 lines
include/dwmmc.h +18
-0+*/ void dwmci_setup_cfg (struct mmc_config *cfg,const char *name,int buswidth,uint caps,u32 max_clk,u32 min_clk); + +/** +* dwmci_bind() - Set up a new MMC block device +* +* This is used to set up a DWMMC block device when you are using CONFIG_BLK. +* It should be called from your driver's bind() method. +* +* See rockchip_dw_mmc.c for an example. +* +* @dev: Device to set up +* @mmc: Pointer to mmc structure (normally &plat->mmc) +* @cfg: Empty configuration structure (generally &plat->cfg). This is +* normally all zeroes at this point. The only purpose of passing +* this in is to set mmc->cfg to it. +* @return 0 if OK, -ve if the block device could not be created +*/ int dwmci_bind (struct udevice *dev,struct mmc *mmc,struct mmc_config *cfg); +#else include/dwmmc.h static inline u8 dwmci_readb(struct dwmci_host *host, int reg) · line 292
Quoted 10 lines
include/dwmmc.h +10
-0+/** +* add_dwmci() - Add a new DWMMC interface +* +* This is used when you are not using CONFIG_BLK. Convert your driver over! +* +* @host: DWMMC host structure +* @max_clk: Maximum supported clock speed in HZ (e.g. 400000) +* @min_clk: Minimum supported clock speed in HZ (e.g. 150000000) +* @return 0 if OK, -ve on error +*/ Ditto.
Quoted 2 lines
I'm starting to covert to DM for dwmmc exynos...
After finishing convert fordwmmc_exynos, I will check in more detail on dwmmc core side.
OK I see your patches so I'll apply this as is. Your patches are assigned to Minkyu, so I'll leave them to him.
Quoted 12 lines
Sorry for checking too late.
Best Regards,
Jaehoon Chunginclude/dwmmc.h static inline u8 dwmci_readb(struct dwmci_host *host, int reg) · line 296
Quoted 5 lines
include/dwmmc.h +2
-0int add_dwmci (struct dwmci_host *host,u32 max_clk,u32 min_clk); +#endif /* !CONFIG_BLK */ +#endif /* __DWMMC_HW_H */
Regards,
Simon
PATCH 1/27 dm: mmc: dwmmc: Add comments to the dwmmc setup functions
Quoted 115 lines · Simon Glass
Hi Jaehoon,
Quoted 93 lines · Jaehoon Chung
Hi Simon,
Quoted 41 lines · Simon Glass
These comments were missed when the original code was written. Add them to help people port their drivers over.
Signed-off-by Simon Glass <[email protected]>---
include/dwmmc.h | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+)include/dwmmc.h +24
-0@@ -224,9 +224,73 @@ static inline u8 dwmci_readb(struct dwmci_host *host, int reg)return readb (host->ioaddr + reg); } +#ifdef CONFIG_BLK +/** +* dwmci_setup_cfg() - Set up the configuration for DWMMC +* +* This is used to set up a DWMMC device when you are using CONFIG_BLK. +* +* This should be called from your MMC driver's probe() method once you have +* the information required. +* +* Generally your driver will have a platform data structure which holds both +* the configuration (struct mmc_config) and the MMC device info (struct mmc). +* For example: +* +* struct rockchip_mmc_plat { +* struct mmc_config cfg; +* struct mmc mmc; +* }; +* +* ... +* +* Inside U_BOOT_DRIVER(): +* .platdata_auto_alloc_size = sizeof(struct rockchip_mmc_plat), +* +* To access platform data: include/dwmmc.h static inline u8 dwmci_readb(struct dwmci_host *host, int reg) · line 260
Quoted 10 lines
include/dwmmc.h +10
-0+* struct rockchip_mmc_plat *plat = dev_get_platdata(dev); +* +* See rockchip_dw_mmc.c for an example. +* +* @cfg: Configuration structure to fill in (generally &plat->mmc) +* @name: Device name (normally dev->name) +* @buswidth: Bus width (in bits, such as 4 or 8) +* @caps: Host capabilities (MMC_MODE_...) +* @max_clk: Maximum supported clock speed in HZ (e.g. 400000) +* @min_clk: Minimum supported clock speed in HZ (e.g. 150000000) e,g is need to swap
max_clk<->min_clk?Quoted 22 lines
include/dwmmc.h +18
-0+*/ void dwmci_setup_cfg (struct mmc_config *cfg,const char *name,int buswidth,uint caps,u32 max_clk,u32 min_clk); + +/** +* dwmci_bind() - Set up a new MMC block device +* +* This is used to set up a DWMMC block device when you are using CONFIG_BLK. +* It should be called from your driver's bind() method. +* +* See rockchip_dw_mmc.c for an example. +* +* @dev: Device to set up +* @mmc: Pointer to mmc structure (normally &plat->mmc) +* @cfg: Empty configuration structure (generally &plat->cfg). This is +* normally all zeroes at this point. The only purpose of passing +* this in is to set mmc->cfg to it. +* @return 0 if OK, -ve if the block device could not be created +*/ int dwmci_bind (struct udevice *dev,struct mmc *mmc,struct mmc_config *cfg); +#else include/dwmmc.h static inline u8 dwmci_readb(struct dwmci_host *host, int reg) · line 292
Quoted 10 lines
include/dwmmc.h +10
-0+/** +* add_dwmci() - Add a new DWMMC interface +* +* This is used when you are not using CONFIG_BLK. Convert your driver over! +* +* @host: DWMMC host structure +* @max_clk: Maximum supported clock speed in HZ (e.g. 400000) +* @min_clk: Minimum supported clock speed in HZ (e.g. 150000000) +* @return 0 if OK, -ve on error +*/ Ditto.
Quoted 2 lines
I'm starting to covert to DM for dwmmc exynos...
After finishing convert fordwmmc_exynos, I will check in more detail on dwmmc core side.OK I see your patches so I'll apply this as is. Your patches are assigned to Minkyu, so I'll leave them to him.
Quoted 12 lines
Sorry for checking too late.
Best Regards,
Jaehoon Chunginclude/dwmmc.h static inline u8 dwmci_readb(struct dwmci_host *host, int reg) · line 296
Quoted 5 lines
include/dwmmc.h +2
-0int add_dwmci (struct dwmci_host *host,u32 max_clk,u32 min_clk); +#endif /* !CONFIG_BLK */ +#endif /* __DWMMC_HW_H */
Quoted 2 lines
Regards,
Simon
Applied to u-boot-dm/next.
PATCH 2/27 rockchip: Use 'select' instead of defaults in Kconfig
In reply to Simon GlassRockchip uses driver model for all subsystems. Specify this in the arm Kconfig rather than as defaults in the Rockchip Kconfig. This means that boards cannot turn these options off, which seems correct.
---
arch/arm/Kconfig | 10 ++++++++++ arch/arm/mach-rockchip/Kconfig | 27 --------------------------- 2 files changed, 10 insertions(+), 27 deletions(-)
arch/arm/Kconfig +10 -0
@@ -823,7 +823,17 @@ config ARCH_ROCKCHIP select SPL select OF_CONTROL select CPU_V7 + select BLK select DM + select SPL_DM + select SYS_MALLOC_F + select SPL_SYS_MALLOC_SIMPLE + select DM_GPIO + select DM_I2C + select DM_MMC + select DM_SERIAL + select DM_SPI + select DM_SPI_FLASH config TARGET_THUNDERX_88XX bool "Support ThunderX 88xx"
arch/arm/mach-rockchip/Kconfig +0 -27
@@ -17,33 +17,6 @@ config ROCKCHIP_RK3036 and video codec support. Peripherals include Gigabit Ethernet, USB2 host and OTG, SDIO, I2S, UART, SPI, I2C and PWMs. -config SYS_MALLOC_F - default y - -config SPL_SYS_MALLOC_SIMPLE - default y - -config SPL_DM - default y - -config DM_SERIAL - default y - -config DM_SPI - default y - -config DM_SPI_FLASH - default y - -config DM_I2C - default y - -config DM_GPIO - default y - -config BLK - default y - source "arch/arm/mach-rockchip/rk3288/Kconfig" source "arch/arm/mach-rockchip/rk3036/Kconfig" endif
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 2/27 rockchip: Use 'select' instead of defaults in Kconfig
Quoted 10 lines · Simon Glass
Rockchip uses driver model for all subsystems. Specify this in the arm
Kconfigrather than as defaults in the RockchipKconfig. This means that boards cannot turn these options off, which seems correct.Signed-off-by Simon Glass <[email protected]>---
arch/arm/Kconfig | 10 ++++++++++ arch/arm/mach-rockchip/Kconfig | 27 --------------------------- 2 files changed, 10 insertions(+), 27 deletions(-)
Applied to u-boot-dm/next.
PATCH 3/27 mmc: Add function declarations for mmc_bread() and mmc_switch_part()
In reply to Simon GlassThese private functions are used both in the driver-model implementation and in the legacy code. Add them to the header.
---
drivers/mmc/mmc.c | 9 ++++----- drivers/mmc/mmc_private.h | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 5 deletions(-)
drivers/mmc/mmc.c +4 -5
@@ -215,11 +215,10 @@ static int mmc_read_blocks(struct mmc *mmc, void *dst, lbaint_t start, }#ifdef CONFIG_BLK -static ulong mmc_bread (struct udevice *dev,lbaint_t start,lbaint_t blkcnt, - void *dst) +ulong mmc_bread(struct udevice *dev, lbaint_t start, lbaint_t blkcnt, void *dst)#else -static ulong mmc_bread (struct blk_desc *block_dev,lbaint_t start, - lbaint_t blkcnt, void *dst) +ulong mmc_bread (struct blk_desc *block_dev,lbaint_t start,lbaint_t blkcnt, + void *dst)#endif {#ifdef CONFIG_BLK
@@ -566,7 +565,7 @@ static int mmc_set_capacity(struct mmc *mmc, int part_num)return 0 ; } -static int mmc_switch_part (struct mmc *mmc,unsigned int part_num) +int mmc_switch_part (struct mmc *mmc,unsigned int part_num) {int ret;
drivers/mmc/mmc_private.h +17 -0
@@ -20,6 +20,14 @@ extern int mmc_set_blocklen(struct mmc *mmc, int len);void mmc_adapter_card_type_ident (void );#endif +#ifdef CONFIG_BLK +ulong mmc_bread (struct udevice *dev,lbaint_t start,lbaint_t blkcnt, +void *dst); +#else +ulong mmc_bread (struct blk_desc *block_dev,lbaint_t start,lbaint_t blkcnt, +void *dst); +#endif +#ifndef CONFIG_SPL_BUILD unsigned long mmc_berase(struct blk_desc *block_dev, lbaint_t start,
@@ -89,4 +97,13 @@ void mmc_list_init(void);*/ void mmc_list_add (struct mmc *mmc); +/** +* mmc_switch_part() - Switch to a new MMC hardware partition +* +* @mmc: MMC device +* @part_num: Hardware partition number +* @return 0 if OK, -ve on error +*/ +int mmc_switch_part (struct mmc *mmc,unsigned int part_num); +#endif /* _MMC_PRIVATE_H_ */
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 3/27 mmc: Add function declarations for mmc_bread() and mmc_switch_part()
Quoted 9 lines · Simon Glass
These private functions are used both in the driver-model implementation and in the legacy code. Add them to the header.
Signed-off-by Simon Glass <[email protected]>---
drivers/mmc/mmc.c | 9 ++++----- drivers/mmc/mmc_private.h | 17 +++++++++++++++++ 2 files changed, 21 insertions(+), 5 deletions(-)
Applied to u-boot-dm/next.
PATCH 4/27 dm: mmc: Move CONFIG_BLK code into the mmc uclass
In reply to Simon GlassRather than having #ifdef in mmc.c, move this code into the uclass file.
---
drivers/mmc/mmc-uclass.c | 80 +++++++++++++++++++++++++++++++++++++++++++++ drivers/mmc/mmc.c | 85 ++---------------------------------------------- 2 files changed, 83 insertions(+), 82 deletions(-)
drivers/mmc/mmc-uclass.c +80 -0
@@ -8,8 +8,10 @@#include <common.h> #include <mmc.h> #include <dm.h> +#include <dm/device-internal.h> #include <dm/lists.h> #include <dm/root.h> +#include "mmc_private.h" struct mmc *mmc_get_mmc_dev (struct udevice *dev) {
@@ -125,6 +127,84 @@ void print_mmc_devices(char separator)#else void print_mmc_devices (char separator) { }#endif + +int mmc_bind (struct udevice *dev,struct mmc *mmc,const struct mmc_config *cfg) +{ +struct blk_desc *bdesc; +struct udevice *bdev; +int ret; + + ret =blk_create_devicef (dev,"mmc_blk" ,"blk" ,IF_TYPE_MMC ,-1 ,512 , +0 , &bdev); +if (ret) { +debug ("Cannot create block device\n" ); +return ret; + } + bdesc =dev_get_uclass_platdata (bdev); + mmc->cfg = cfg; + mmc->priv = dev; + +/* the following chunk was from mmc_register() */ + +/* Setup dsr related values */ + mmc->dsr_imp =0 ; + mmc->dsr =0xffffffff ; +/* Setup the universal parts of the block interface just once */ + bdesc->removable =1 ; + +/* setup initial part type */ + bdesc->part_type = cfg->part_type; + mmc->dev = dev; + +return 0 ; +} + +int mmc_unbind (struct udevice *dev) +{ +struct udevice *bdev; + +device_find_first_child (dev, &bdev); +if (bdev) { +device_remove (bdev); +device_unbind (bdev); + } + +return 0 ; +} + +static int mmc_select_hwpart (struct udevice *bdev,int hwpart) +{ +struct udevice *mmc_dev =dev_get_parent (bdev); +struct mmc *mmc =mmc_get_mmc_dev (mmc_dev); +struct blk_desc *desc =dev_get_uclass_platdata (bdev); +int ret; + +if (desc->hwpart == hwpart) +return 0 ; + +if (mmc->part_config ==MMCPART_NOAVAILABLE ) +return -EMEDIUMTYPE ; + + ret =mmc_switch_part (mmc, hwpart); +if (ret) +return ret; + +return 0 ; +} + +static const struct blk_ops mmc_blk_ops = { + .read = mmc_bread, +#ifndef CONFIG_SPL_BUILD + .write = mmc_bwrite, +#endif + .select_hwpart = mmc_select_hwpart, +}; + +U_BOOT_DRIVER (mmc_blk) = { + .name ="mmc_blk" , + .id =UCLASS_BLK , + .ops = &mmc_blk_ops, +};#endif /* CONFIG_BLK */ U_BOOT_DRIVER (mmc) = {
drivers/mmc/mmc.c +3 -82
110 lines not on this page · raw message
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 4/27 dm: mmc: Move CONFIG_BLK code into the mmc uclass
Quoted 8 lines · Simon Glass
Rather than having #ifdef in
mmc.c, move this code into the uclass file.Signed-off-by Simon Glass <[email protected]>---
drivers/mmc/mmc-uclass.c | 80 +++++++++++++++++++++++++++++++++++++++++++++ drivers/mmc/mmc.c | 85 ++---------------------------------------------- 2 files changed, 83 insertions(+), 82 deletions(-)
Applied to u-boot-dm/next.
PATCH 5/27 dm: mmc: Move non-CONFIG_BLK code into mmc_legacy.c
In reply to Simon GlassRather than having #ifdef in mmc.c, move this code into the legacy file.
---
drivers/mmc/mmc.c | 95 ------------------------------------------------ drivers/mmc/mmc_legacy.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 95 deletions(-)
drivers/mmc/mmc.c +0 -95
@@ -585,29 +585,6 @@ int mmc_switch_part(struct mmc *mmc, unsigned int part_num)return ret; } -#ifndef CONFIG_BLK -static int mmc_select_hwpartp (struct blk_desc *desc,int hwpart) -{ -struct mmc *mmc =find_mmc_device (desc->devnum); -int ret; - -if (!mmc) -return -ENODEV ; - -if (mmc->block_dev.hwpart == hwpart) -return 0 ; - -if (mmc->part_config ==MMCPART_NOAVAILABLE ) -return -EMEDIUMTYPE ; - - ret =mmc_switch_part (mmc, hwpart); -if (ret) -return ret; - -return 0 ; -} -#endif -int mmc_hwpart_config (struct mmc *mmc,const struct mmc_hwpart_conf *conf,enum mmc_hwpart_conf_mode mode)
@@ -1508,68 +1485,6 @@ static int mmc_send_if_cond(struct mmc *mmc)return 0 ; } -#ifndef CONFIG_BLK -struct mmc *mmc_create (const struct mmc_config *cfg,void *priv) -{ -struct blk_desc *bdesc; -struct mmc *mmc; - -/* quick validation */ -if (cfg ==NULL || cfg->ops ==NULL || cfg->ops->send_cmd ==NULL || - cfg->f_min ==0 || cfg->f_max ==0 || cfg->b_max ==0 ) -return NULL ; - - mmc =calloc (1 ,sizeof (*mmc)); -if (mmc ==NULL ) -return NULL ; - - mmc->cfg = cfg; - mmc->priv = priv; - -/* the following chunk was mmc_register() */ - -/* Setup dsr related values */ - mmc->dsr_imp =0 ; - mmc->dsr =0xffffffff ; -/* Setup the universal parts of the block interface just once */ - bdesc =mmc_get_blk_desc (mmc); - bdesc->if_type =IF_TYPE_MMC ; - bdesc->removable =1 ; - bdesc->devnum =mmc_get_next_devnum (); - bdesc->block_read = mmc_bread; - bdesc->block_write = mmc_bwrite; - bdesc->block_erase = mmc_berase; - -/* setup initial part type */ - bdesc->part_type = mmc->cfg->part_type; -mmc_list_add (mmc); - -return mmc; -} - -void mmc_destroy (struct mmc *mmc) -{ -/* only freeing memory for now */ -free (mmc); -} - -static int mmc_get_dev (int dev,struct blk_desc **descp) -{ -struct mmc *mmc =find_mmc_device (dev); -int ret; - -if (!mmc) -return -ENODEV ; - ret =mmc_init (mmc); -if (ret) -return ret; - - *descp = &mmc->block_dev; - -return 0 ; -} -#endif -/* board-specific MMC power initializations. */ __weak void board_mmc_power_init (void ) {
@@ -1891,13 +1806,3 @@ int mmc_set_rst_n_function(struct mmc *mmc, u8 enable) enable); }#endif - -#ifndef CONFIG_BLK -U_BOOT_LEGACY_BLK (mmc) = { - .if_typename ="mmc" , - .if_type =IF_TYPE_MMC , - .max_devs =-1 , - .get_dev = mmc_get_dev, - .select_hwpart = mmc_select_hwpartp, -}; -#endif
drivers/mmc/mmc_legacy.c +91 -0
101 lines not on this page · raw message
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 5/27 dm: mmc: Move non-CONFIG_BLK code into mmc_legacy.c
Quoted 8 lines · Simon Glass
Rather than having #ifdef in
mmc.c, move this code into the legacy file.Signed-off-by Simon Glass <[email protected]>---
drivers/mmc/mmc.c | 95 ------------------------------------------------ drivers/mmc/mmc_legacy.c | 91 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+), 95 deletions(-)
Applied to u-boot-dm/next.
PATCH 6/27 mmc: Move MMC boot code into its own file
In reply to Simon GlassRather than having an #ifdef in the main mmc.c file, control this feature from the Makefile by moving the code into its own file.
---
drivers/mmc/Makefile | 3 ++ drivers/mmc/mmc.c | 126 +------------------------------------------- drivers/mmc/mmc_boot.c | 131 ++++++++++++++++++++++++++++++++++++++++++++++ drivers/mmc/mmc_private.h | 11 ++++ 4 files changed, 146 insertions(+), 125 deletions(-) create mode 100644 drivers/mmc/mmc_boot.c
drivers/mmc/Makefile +3 -0
@@ -25,6 +25,9 @@ obj-$(CONFIG_FSL_ESDHC) += fsl_esdhc.o obj-$(CONFIG_FTSDC010) += ftsdc010_mci.o obj-$(CONFIG_FTSDC021) += ftsdc021_sdhci.o obj-$(CONFIG_GENERIC_MMC) += mmc.o +ifdef CONFIG_SUPPORT_EMMC_BOOT +obj-$(CONFIG_GENERIC_MMC) += mmc_boot.o +endif obj-$(CONFIG_GENERIC_ATMEL_MCI) += gen_atmel_mci.o obj-$(CONFIG_KONA_SDHCI) += kona_sdhci.o obj-$(CONFIG_MMC_SPI) += mmc_spi.o
drivers/mmc/mmc.c +1 -125
135 lines not on this page · raw message
drivers/mmc/mmc_boot.c new file +131 -0
131 lines not on this page · raw message
drivers/mmc/mmc_private.h +11 -0
@@ -106,4 +106,15 @@ void mmc_list_add(struct mmc *mmc);*/ int mmc_switch_part (struct mmc *mmc,unsigned int part_num); +/** +* mmc_switch() - Issue and MMC switch mode command +* +* @mmc: MMC device +* @set: Unused +* @index: Cmdarg index +* @value: Cmdarg value +* @return 0 if OK, -ve on error +*/ +int mmc_switch (struct mmc *mmc,u8 set,u8 index,u8 value); +#endif /* _MMC_PRIVATE_H_ */
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 6/27 mmc: Move MMC boot code into its own file
Quoted 4 lines · Simon Glass
Rather than having an #ifdef in the main
mmc.cfile, control this feature from theMakefileby moving the code into its own file.Signed-off-by Simon Glass <[email protected]>
Quoted 8 lines
---
drivers/mmc/Makefile | 3 ++ drivers/mmc/mmc.c | 126 +------------------------------------------- drivers/mmc/mmc_boot.c | 131 ++++++++++++++++++++++++++++++++++++++++++++++ drivers/mmc/mmc_private.h | 11 ++++ 4 files changed, 146 insertions(+), 125 deletions(-) create mode 100644 drivers/mmc/mmc_boot.c
Applied to u-boot-dm/next.
PATCH 7/27 dm: mmc: rockchip: Support only CONFIG_BLK
In reply to Simon GlassSince all Rockchip boards use CONFIG_BLK, we can remove this old code.
---
drivers/mmc/rockchip_dw_mmc.c | 11 ----------- 1 file changed, 11 deletions(-)
drivers/mmc/rockchip_dw_mmc.c +0 -11
@@ -67,9 +67,7 @@ static int rockchip_dwmmc_ofdata_to_platdata(struct udevice *dev)static int rockchip_dwmmc_probe (struct udevice *dev) { -#ifdef CONFIG_BLK struct rockchip_mmc_plat *plat =dev_get_platdata (dev); -#endif struct mmc_uclass_priv *upriv =dev_get_uclass_priv (dev);struct rockchip_dwmmc_priv *priv =dev_get_priv (dev);struct dwmci_host *host = &priv->host;
@@ -108,16 +106,9 @@ static int rockchip_dwmmc_probe(struct udevice *dev) return ret; }#endif -#ifdef CONFIG_BLK dwmci_setup_cfg (&plat->cfg, dev->name, host->buswidth, host->caps, minmax[1 ], minmax[0 ]); host->mmc = &plat->mmc; -#else - ret =add_dwmci (host, minmax[1 ], minmax[0 ]); -if (ret) -return ret; - -#endif host->mmc->priv = &priv->host; host->mmc->dev = dev; upriv->mmc = host->mmc;
@@ -127,14 +118,12 @@ static int rockchip_dwmmc_probe(struct udevice *dev)static int rockchip_dwmmc_bind (struct udevice *dev) { -#ifdef CONFIG_BLK struct rockchip_mmc_plat *plat =dev_get_platdata (dev);int ret; ret =dwmci_bind (dev, &plat->mmc, &plat->cfg);if (ret)return ret; -#endif return 0 ; }
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 7/27 dm: mmc: rockchip: Support only CONFIG_BLK
Quoted 7 lines · Simon Glass
Since all Rockchip boards use
CONFIG_BLK, we can remove this old code.Signed-off-by Simon Glass <[email protected]>---
drivers/mmc/rockchip_dw_mmc.c | 11 ----------- 1 file changed, 11 deletions(-)
Applied to u-boot-dm/next.
PATCH 8/27 mmc: Move tracing code into separate functions
In reply to Simon GlassMove this code into separate functions so that it can be used from the uclass also. Add static inline versions for when the option is disabled.
---
drivers/mmc/mmc.c | 41 ++++++++++++++++++++++++++--------------- drivers/mmc/mmc_private.h | 19 +++++++++++++++++++ 2 files changed, 45 insertions(+), 15 deletions(-)
drivers/mmc/mmc.c +26 -15
@@ -47,17 +47,18 @@ __weak int board_mmc_getcd(struct mmc *mmc)return -1 ; } -int mmc_send_cmd (struct mmc *mmc,struct mmc_cmd *cmd,struct mmc_data *data) +#ifdef CONFIG_MMC_TRACE +void mmmc_trace_before_send (struct mmc *mmc,struct mmc_cmd *cmd) { -int ret; +printf ("CMD_SEND:%d\n" , cmd->cmdidx); +printf ("\t\tARG\t\t\t 0x%08X\n" , cmd->cmdarg); +} -#ifdef CONFIG_MMC_TRACE +void mmmc_trace_after_send (struct mmc *mmc,struct mmc_cmd *cmd,int ret) +{int i;u8 *ptr; -printf ("CMD_SEND:%d\n" , cmd->cmdidx); -printf ("\t\tARG\t\t\t 0x%08X\n" , cmd->cmdarg); - ret = mmc->cfg->ops->send_cmd (mmc, cmd, data);if (ret) {printf ("\t\tRET\t\t\t %d\n" , ret); }else {
@@ -103,9 +104,25 @@ int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) break; } } -#else - ret = mmc->cfg->ops->send_cmd (mmc, cmd, data); +} + +void mmc_trace_state (struct mmc *mmc,struct mmc_cmd *cmd) +{ +int status; + + status = (cmd->response[0 ] &MMC_STATUS_CURR_STATE ) >>9 ; +printf ("CURR STATE:%d\n" , status); +}#endif + +int mmc_send_cmd (struct mmc *mmc,struct mmc_cmd *cmd,struct mmc_data *data) +{ +int ret; + +mmmc_trace_before_send (mmc, cmd); + ret = mmc->cfg->ops->send_cmd (mmc, cmd, data); +mmmc_trace_after_send (mmc, cmd, ret); +return ret; }
@@ -113,9 +130,6 @@ int mmc_send_status(struct mmc *mmc, int timeout) {struct mmc_cmd cmd;int err, retries =5 ; -#ifdef CONFIG_MMC_TRACE -int status; -#endif cmd.cmdidx =MMC_CMD_SEND_STATUS ; cmd.resp_type =MMC_RSP_R1 ;
@@ -145,10 +159,7 @@ int mmc_send_status(struct mmc *mmc, int timeout)udelay (1000 ); } -#ifdef CONFIG_MMC_TRACE - status = (cmd.response[0 ] &MMC_STATUS_CURR_STATE ) >>9 ; -printf ("CURR STATE:%d\n" , status); -#endif +mmc_trace_state (mmc, &cmd);if (timeout <=0 ) {#if !defined(CONFIG_SPL_BUILD ) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT )printf ("Timeout waiting card ready\n" );
drivers/mmc/mmc_private.h +19 -0
@@ -73,6 +73,25 @@ static inline ulong mmc_bwrite(struct blk_desc *block_dev, lbaint_t start,#endif /* CONFIG_SPL_BUILD */ +#ifdef CONFIG_MMC_TRACE +void mmmc_trace_before_send (struct mmc *mmc,struct mmc_cmd *cmd); +void mmmc_trace_after_send (struct mmc *mmc,struct mmc_cmd *cmd,int ret); +void mmc_trace_state (struct mmc *mmc,struct mmc_cmd *cmd); +#else +static inline void mmmc_trace_before_send (struct mmc *mmc,struct mmc_cmd *cmd) +{ +} + +static inline void mmmc_trace_after_send (struct mmc *mmc,struct mmc_cmd *cmd, +int ret) +{ +} + +static inline void mmc_trace_state (struct mmc *mmc,struct mmc_cmd *cmd) +{ +} +#endif +/** * mmc_get_next_devnum() - Get the next available MMC device number *
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 8/27 mmc: Move tracing code into separate functions
Quoted 9 lines · Simon Glass
Move this code into separate functions so that it can be used from the uclass also. Add static inline versions for when the option is disabled.
Signed-off-by Simon Glass <[email protected]>---
drivers/mmc/mmc.c | 41 ++++++++++++++++++++++++++--------------- drivers/mmc/mmc_private.h | 19 +++++++++++++++++++ 2 files changed, 45 insertions(+), 15 deletions(-)
Applied to u-boot-dm/next.
PATCH 9/27 rockchip: Disable CONFIG_SDHCI
In reply to Simon GlassThis option is not actually needed for rockchip boards. Drop it, since it will not support driver-model MMC operation support.
---
include/configs/rk3036_common.h | 1 - include/configs/rk3288_common.h | 1 - 2 files changed, 2 deletions(-)
include/configs/rk3036_common.h +0 -1
@@ -45,7 +45,6 @@/* MMC/SD IP block */ #define CONFIG_MMC #define CONFIG_GENERIC_MMC -#define CONFIG_SDHCI #define CONFIG_DWMMC #define CONFIG_BOUNCE_BUFFER
include/configs/rk3288_common.h +0 -1
@@ -51,7 +51,6 @@/* MMC/SD IP block */ #define CONFIG_MMC #define CONFIG_GENERIC_MMC -#define CONFIG_SDHCI #define CONFIG_DWMMC #define CONFIG_BOUNCE_BUFFER
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 9/27 rockchip: Disable CONFIG_SDHCI
Quoted 9 lines · Simon Glass
This option is not actually needed for rockchip boards. Drop it, since it will not support driver-model MMC operation support.
Signed-off-by Simon Glass <[email protected]>---
include/configs/rk3036_common.h | 1 - include/configs/rk3288_common.h | 1 - 2 files changed, 2 deletions(-)
Applied to u-boot-dm/next.
PATCH 10/27 dm: mmc: Add a way to use driver model for MMC operations
In reply to Simon GlassThe driver model conversion for MMC has moved in small steps. The first step was to have an MMC device (CONFIG_DM_MMC). The second was to use a child block device (CONFIG_BLK). The final one is to use driver model for MMC operations (CONFIG_DM_MMC_OP). Add support for this.
The immediate priority is to make all boards that use DM_MMC also use those other two options. This will allow them to be removed.
---
drivers/mmc/Kconfig | 9 +++++++ drivers/mmc/mmc-uclass.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++ drivers/mmc/mmc.c | 21 ++++++++++++--- include/mmc.h | 66 +++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 158 insertions(+), 4 deletions(-)
drivers/mmc/Kconfig +9 -0
@@ -16,6 +16,15 @@ config DM_MMC appear as block devices in U-Boot and can support filesystems such as EXT4 and FAT. +config DM_MMC_OPS + bool "Support MMC controller operations using Driver Model" + depends on DM_MMC + help + Driver model provides a means of supporting device operations. This + option moves MMC operations under the control of driver model. The + option will be removed as soon as all DM_MMC drivers use it, as it + will the only supported behaviour. + config MSM_SDHCI bool "Qualcomm SDHCI controller" depends on DM_MMC
drivers/mmc/mmc-uclass.c +66 -0
72 lines not on this page · raw message
drivers/mmc/mmc.c +18 -3
@@ -21,6 +21,7 @@#include <div64.h> #include "mmc_private.h" +#ifndef CONFIG_DM_MMC_OPS __weak int board_mmc_getwp (struct mmc *mmc) {return -1 ;
@@ -46,6 +47,7 @@ __weak int board_mmc_getcd(struct mmc *mmc) {return -1 ; } +#endif #ifdef CONFIG_MMC_TRACE void mmmc_trace_before_send (struct mmc *mmc,struct mmc_cmd *cmd)
@@ -115,6 +117,7 @@ void mmc_trace_state(struct mmc *mmc, struct mmc_cmd *cmd) }#endif +#ifndef CONFIG_DM_MMC_OPS int mmc_send_cmd (struct mmc *mmc,struct mmc_cmd *cmd,struct mmc_data *data) {int ret;
@@ -125,6 +128,7 @@ int mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data) return ret; } +#endif int mmc_send_status (struct mmc *mmc,int timeout) {
@@ -789,6 +793,7 @@ int mmc_hwpart_config(struct mmc *mmc,return 0 ; } +#ifndef CONFIG_DM_MMC_OPS int mmc_getcd (struct mmc *mmc) {int cd;
@@ -804,6 +809,7 @@ int mmc_getcd(struct mmc *mmc) return cd; } +#endif static int sd_switch (struct mmc *mmc,int mode,int group,u8 value,u8 *resp) {
@@ -967,11 +973,13 @@ static const u8 multipliers[] = { 80, }; +#ifndef CONFIG_DM_MMC_OPS static void mmc_set_ios (struct mmc *mmc) {if (mmc->cfg->ops->set_ios) mmc->cfg->ops->set_ios (mmc); } +#endif void mmc_set_clock (struct mmc *mmc,uint clock) {
@@ -1502,10 +1510,15 @@ __weak void board_mmc_power_init(void)int mmc_start_init (struct mmc *mmc) { +bool no_card;int err;/* we pretend there's no card when init is NULL */ -if (mmc_getcd (mmc) ==0 || mmc->cfg->ops->init ==NULL ) { + no_card =mmc_getcd (mmc) ==0 ; +#ifndef CONFIG_DM_MMC_OPS + no_card = no_card || (mmc->cfg->ops->init ==NULL ); +#endif +if (no_card) { mmc->has_init =0 ;#if !defined(CONFIG_SPL_BUILD ) || defined(CONFIG_SPL_LIBCOMMON_SUPPORT )printf ("MMC: no card present\n" );
@@ -1521,12 +1534,14 @@ int mmc_start_init(struct mmc *mmc)#endif board_mmc_power_init (); +#ifdef CONFIG_DM_MMC_OPS +/* The device has already been probed ready for use */ +#else /* made sure it's not NULL earlier */ err = mmc->cfg->ops->init (mmc); -if (err)return err; - +#endif mmc->ddr_mode =0 ;mmc_set_bus_width (mmc,1 );mmc_set_clock (mmc,1 );
include/mmc.h +65 -1
98 lines not on this page · raw message
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 10/27 dm: mmc: Add a way to use driver model for MMC operations
Quoted 8 lines · Simon Glass
The driver model conversion for MMC has moved in small steps. The first step was to have an MMC device (
CONFIG_DM_MMC). The second was to use a child block device (CONFIG_BLK). The final one is to use driver model for MMC operations (CONFIG_DM_MMC_OP). Add support for this.The immediate priority is to make all boards that use
DM_MMCalso use those other two options. This will allow them to be removed.
Quoted 8 lines
Signed-off-by Simon Glass <[email protected]>---
drivers/mmc/Kconfig | 9 +++++++ drivers/mmc/mmc-uclass.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++ drivers/mmc/mmc.c | 21 ++++++++++++--- include/mmc.h | 66 +++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 158 insertions(+), 4 deletions(-)
Applied to u-boot-dm/next.
PATCH 11/27 dm: mmc: dwmmc: Support CONFIG_DM_MMC_OPS
In reply to Simon GlassAdd support to dwmmc for using driver model for MMC operations.
---
drivers/mmc/dw_mmc.c | 33 +++++++++++++++++++++++++++++++++ include/dwmmc.h | 9 +++++++++ 2 files changed, 42 insertions(+)
drivers/mmc/dw_mmc.c +33 -0
@@ -181,9 +181,16 @@ static int dwmci_set_transfer_mode(struct dwmci_host *host,return mode; } +#ifdef CONFIG_DM_MMC_OPS +int dwmci_send_cmd (struct udevice *dev,struct mmc_cmd *cmd, +struct mmc_data *data) +{ +struct mmc *mmc =mmc_get_mmc_dev (dev); +#else static int dwmci_send_cmd (struct mmc *mmc,struct mmc_cmd *cmd,struct mmc_data *data) { +#endif struct dwmci_host *host = mmc->priv; ALLOC_CACHE_ALIGN_BUFFER(struct dwmci_idmac, cur_idmac, data ? DIV_ROUND_UP(data->blocks, 8) : 0);
@@ -373,8 +380,14 @@ static int dwmci_setup_bus(struct dwmci_host *host, u32 freq)return 0 ; } +#ifdef CONFIG_DM_MMC_OPS +int dwmci_set_ios (struct udevice *dev) +{ +struct mmc *mmc =mmc_get_mmc_dev (dev); +#else static void dwmci_set_ios (struct mmc *mmc) { +#endif struct dwmci_host *host = (struct dwmci_host *)mmc->priv;u32 ctype, regs;
@@ -405,6 +418,9 @@ static void dwmci_set_ios(struct mmc *mmc)if (host->clksel) host->clksel (host); +#ifdef CONFIG_DM_MMC_OPS +return 0 ; +#endif }static int dwmci_init (struct mmc *mmc)
@@ -448,17 +464,34 @@ static int dwmci_init(struct mmc *mmc)return 0 ; } +#ifdef CONFIG_DM_MMC_OPS +int dwmci_probe (struct udevice *dev) +{ +struct mmc *mmc =mmc_get_mmc_dev (dev); + +return dwmci_init (mmc); +} + +const struct dm_mmc_ops dm_dwmci_ops = { + .send_cmd = dwmci_send_cmd, + .set_ios = dwmci_set_ios, +}; + +#else static const struct mmc_ops dwmci_ops = { .send_cmd = dwmci_send_cmd, .set_ios = dwmci_set_ios, .init = dwmci_init, }; +#endif void dwmci_setup_cfg (struct mmc_config *cfg,const char *name,int buswidth,uint caps,u32 max_clk,u32 min_clk) { cfg->name = name; +#ifndef CONFIG_DM_MMC_OPS cfg->ops = &dwmci_ops; +#endif cfg->f_min = min_clk; cfg->f_max = max_clk;
include/dwmmc.h +9 -0
@@ -293,4 +293,13 @@ int dwmci_bind(struct udevice *dev, struct mmc *mmc, struct mmc_config *cfg);int add_dwmci (struct dwmci_host *host,u32 max_clk,u32 min_clk);#endif /* !CONFIG_BLK */ +#ifdef CONFIG_DM_MMC_OPS +/* Export the operations to drivers */ +int dwmci_send_cmd (struct udevice *dev,struct mmc_cmd *cmd, +struct mmc_data *data); +int dwmci_set_ios (struct udevice *dev); +int dwmci_probe (struct udevice *dev); +extern const struct dm_mmc_ops dm_dwmci_ops; +#endif +#endif /* __DWMMC_HW_H */
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 11/27 dm: mmc: dwmmc: Support CONFIG_DM_MMC_OPS
Quoted 8 lines · Simon Glass
Add support to dwmmc for using driver model for MMC operations.
Signed-off-by Simon Glass <[email protected]>---
drivers/mmc/dw_mmc.c | 33 +++++++++++++++++++++++++++++++++ include/dwmmc.h | 9 +++++++++ 2 files changed, 42 insertions(+)
Applied to u-boot-dm/next.
PATCH 12/27 dm: mmc: rockchip: Enable CONFIG_DM_MMC_OPS for all boards
In reply to Simon GlassEnable this option to move rockchip over to use driver model for MMC operations.
---
arch/arm/Kconfig | 1 + drivers/mmc/rockchip_dw_mmc.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-)
arch/arm/Kconfig +1 -0
@@ -831,6 +831,7 @@ config ARCH_ROCKCHIP select DM_GPIO select DM_I2C select DM_MMC + select DM_MMC_OPS select DM_SERIAL select DM_SPI select DM_SPI_FLASH
drivers/mmc/rockchip_dw_mmc.c +2 -1
@@ -113,7 +113,7 @@ static int rockchip_dwmmc_probe(struct udevice *dev) host->mmc->dev = dev; upriv->mmc = host->mmc; -return 0 ; +return dwmci_probe (dev); }static int rockchip_dwmmc_bind (struct udevice *dev)
@@ -138,6 +138,7 @@ U_BOOT_DRIVER(rockchip_dwmmc_drv) = { .id = UCLASS_MMC, .of_match = rockchip_dwmmc_ids, .ofdata_to_platdata = rockchip_dwmmc_ofdata_to_platdata, + .ops = &dm_dwmci_ops, .bind = rockchip_dwmmc_bind, .probe = rockchip_dwmmc_probe, .priv_auto_alloc_size = sizeof(struct rockchip_dwmmc_priv),
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 12/27 dm: mmc: rockchip: Enable CONFIG_DM_MMC_OPS for all boards
Quoted 9 lines · Simon Glass
Enable this option to move rockchip over to use driver model for MMC operations.
Signed-off-by Simon Glass <[email protected]>---
arch/arm/Kconfig | 1 + drivers/mmc/rockchip_dw_mmc.c | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-)
Applied to u-boot-dm/next.
PATCH 13/27 rockchip: Add MAINTAINER files for kylin_rk3036, evb_rk3036
In reply to Simon GlassThese boards should have maintainer entries. Add them.
---
board/evb_rk3036/evb_rk3036/MAINTAINERS | 6 ++++++ board/kylin/kylin_rk3036/MAINTAINERS | 6 ++++++ 2 files changed, 12 insertions(+)
board/evb_rk3036/evb_rk3036/MAINTAINERS +6 -0
@@ -0,0 +1,6 @@ +EVB-RK3036 +M: huang lin <[email protected]> +S: Maintained +F: board/evb/evb-rk3036 +F: include/configs/evb-rk3036.h +F: configs/evb-rk3036_defconfig
board/kylin/kylin_rk3036/MAINTAINERS +6 -0
@@ -0,0 +1,6 @@ +KYLIN-RK3036 +M: huang lin <[email protected]> +S: Maintained +F: board/kylin/kylin-rk3036 +F: include/configs/kylin-rk3036.h +F: configs/kylin-rk3036_defconfig
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 13/27 rockchip: Add MAINTAINER files for kylin_rk3036, evb_rk3036
Quoted 8 lines · Simon Glass
These boards should have maintainer entries. Add them.
Signed-off-by Simon Glass <[email protected]>---
board/evb_rk3036/evb_rk3036/MAINTAINERS | 6 ++++++ board/kylin/kylin_rk3036/MAINTAINERS | 6 ++++++ 2 files changed, 12 insertions(+)
Applied to u-boot-dm/next.
PATCH 14/27 dm: sandbox: Convert to use CONFIG_CMD_MMC_OPS
In reply to Simon GlassUpdate the sandbox MMC emulation to use driver model for MMC operations.
---
arch/Kconfig | 1 + configs/sandbox_defconfig | 4 ++-- drivers/mmc/sandbox_mmc.c | 17 ++++++----------- 3 files changed, 9 insertions(+), 13 deletions(-)
arch/Kconfig +1 -0
@@ -63,6 +63,7 @@ config SANDBOX select DM_I2C select DM_SPI select DM_GPIO + select DM_MMC config SH bool "SuperH architecture"
configs/sandbox_defconfig +2 -2
@@ -1,5 +1,4 @@ CONFIG_SYS_MALLOC_F_LEN=0x2000 -CONFIG_BLK=y CONFIG_MMC=y CONFIG_PCI=y CONFIG_DEFAULT_DEVICE_TREE="sandbox"
@@ -71,6 +70,7 @@ CONFIG_DEVRES=y CONFIG_DEBUG_DEVRES=y CONFIG_ADC=y CONFIG_ADC_SANDBOX=y +CONFIG_BLK=y CONFIG_CLK=y CONFIG_CPU=y CONFIG_DM_DEMO=y
@@ -101,7 +101,7 @@ CONFIG_CROS_EC_SPI=y CONFIG_PWRSEQ=y CONFIG_SPL_PWRSEQ=y CONFIG_SYSRESET=y -CONFIG_DM_MMC=y +CONFIG_DM_MMC_OPS=y CONFIG_SANDBOX_MMC=y CONFIG_SPI_FLASH_SANDBOX=y CONFIG_SPI_FLASH=y
drivers/mmc/sandbox_mmc.c +6 -11
@@ -25,7 +25,7 @@ struct sandbox_mmc_plat {* This emulate an SD card version 2. Single-block reads result in zero data. * Multiple-block reads return a test string. */ -static int sandbox_mmc_send_cmd (struct mmc *mmc,struct mmc_cmd *cmd, +static int sandbox_mmc_send_cmd (struct udevice *dev,struct mmc_cmd *cmd,struct mmc_data *data) {switch (cmd->cmdidx) {
@@ -85,25 +85,20 @@ static int sandbox_mmc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd,return 0 ; } -static void sandbox_mmc_set_ios (struct mmc *mmc) -{ -} - -static int sandbox_mmc_init (struct mmc *mmc) +static int sandbox_mmc_set_ios (struct udevice *dev) {return 0 ; } -static int sandbox_mmc_getcd (struct mmc *mmc) +static int sandbox_mmc_get_cd (struct udevice *dev) {return 1 ; } -static const struct mmc_ops sandbox_mmc_ops = { +static const struct dm_mmc_ops sandbox_mmc_ops = { .send_cmd = sandbox_mmc_send_cmd, .set_ios = sandbox_mmc_set_ios, - .init = sandbox_mmc_init, - .getcd = sandbox_mmc_getcd, + .get_cd = sandbox_mmc_get_cd, };int sandbox_mmc_probe (struct udevice *dev)
@@ -120,7 +115,6 @@ int sandbox_mmc_bind(struct udevice *dev)int ret; cfg->name = dev->name; - cfg->ops = &sandbox_mmc_ops; cfg->host_caps = MMC_MODE_HS_52MHz |MMC_MODE_HS |MMC_MODE_8BIT ; cfg->voltages =MMC_VDD_165_195 |MMC_VDD_32_33 |MMC_VDD_33_34 ; cfg->f_min =1000000 ;
@@ -150,6 +144,7 @@ U_BOOT_DRIVER(mmc_sandbox) = { .name = "mmc_sandbox", .id = UCLASS_MMC, .of_match = sandbox_mmc_ids, + .ops = &sandbox_mmc_ops, .bind = sandbox_mmc_bind, .unbind = sandbox_mmc_unbind, .probe = sandbox_mmc_probe,
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 14/27 dm: sandbox: Convert to use CONFIG_CMD_MMC_OPS
Quoted 9 lines · Simon Glass
Update the sandbox MMC emulation to use driver model for MMC operations.
Signed-off-by Simon Glass <[email protected]>---
arch/Kconfig | 1 + configs/sandbox_defconfig | 4 ++-- drivers/mmc/sandbox_mmc.c | 17 ++++++----------- 3 files changed, 9 insertions(+), 13 deletions(-)
Applied to u-boot-dm/next.
PATCH 15/27 dm: mmc: sdhci: Refactor configuration setup to support DM
In reply to Simon GlassMove the configuration setting into a separate function which can be used by the driver-model code.
---
drivers/mmc/sdhci.c | 107 +++++++++++++++++++++++++++++----------------------- 1 file changed, 59 insertions(+), 48 deletions(-)
drivers/mmc/sdhci.c +59 -48
@@ -9,6 +9,7 @@*/ #include <common.h> +#include <errno.h> #include <malloc.h> #include <mmc.h> #include <sdhci.h>
@@ -478,73 +479,83 @@ static const struct mmc_ops sdhci_ops = { .init = sdhci_init, }; -int add_sdhci (struct sdhci_host *host,u32 max_clk,u32 min_clk) +int sdhci_setup_cfg (struct mmc_config *cfg,const char *name,int buswidth, +uint caps,u32 max_clk,u32 min_clk,uint version, +uint quirks,uint host_caps) { -unsigned int caps; - - host->cfg.name = host->name; - host->cfg.ops = &sdhci_ops; - - caps =sdhci_readl (host,SDHCI_CAPABILITIES ); -#ifdef CONFIG_MMC_SDMA -if (!(caps &SDHCI_CAN_DO_SDMA )) { -printf ("%s: Your controller doesn't support SDMA!!\n" , - __func__); -return -1 ; - } + cfg->name = name; +#ifndef CONFIG_DM_MMC_OPS + cfg->ops = &sdhci_ops;#endif -if (max_clk) - host->cfg.f_max = max_clk; + cfg->f_max = max_clk;else { -if (SDHCI_GET_VERSION (host) >=SDHCI_SPEC_300 ) - host->cfg.f_max = (caps &SDHCI_CLOCK_V3_BASE_MASK ) - >>SDHCI_CLOCK_BASE_SHIFT ; +if (version >=SDHCI_SPEC_300 ) + cfg->f_max = (caps &SDHCI_CLOCK_V3_BASE_MASK ) >> +SDHCI_CLOCK_BASE_SHIFT ;else - host->cfg.f_max = (caps &SDHCI_CLOCK_BASE_MASK ) - >>SDHCI_CLOCK_BASE_SHIFT ; - host->cfg.f_max *=1000000 ; - } -if (host->cfg.f_max ==0 ) { -printf ("%s: Hardware doesn't specify base clock frequency\n" , - __func__); -return -1 ; + cfg->f_max = (caps &SDHCI_CLOCK_BASE_MASK ) >> +SDHCI_CLOCK_BASE_SHIFT ; + cfg->f_max *=1000000 ; } +if (cfg->f_max ==0 ) +return -EINVAL ;if (min_clk) - host->cfg.f_min = min_clk; + cfg->f_min = min_clk;else { -if (SDHCI_GET_VERSION (host) >=SDHCI_SPEC_300 ) - host->cfg.f_min = host->cfg.f_max / -SDHCI_MAX_DIV_SPEC_300 ; +if (version >=SDHCI_SPEC_300 ) + cfg->f_min = cfg->f_max /SDHCI_MAX_DIV_SPEC_300 ;else - host->cfg.f_min = host->cfg.f_max / -SDHCI_MAX_DIV_SPEC_200 ; + cfg->f_min = cfg->f_max /SDHCI_MAX_DIV_SPEC_200 ; } - - host->cfg.voltages =0 ; + cfg->voltages =0 ;if (caps &SDHCI_CAN_VDD_330 ) - host->cfg.voltages |=MMC_VDD_32_33 |MMC_VDD_33_34 ; + cfg->voltages |=MMC_VDD_32_33 |MMC_VDD_33_34 ;if (caps &SDHCI_CAN_VDD_300 ) - host->cfg.voltages |=MMC_VDD_29_30 |MMC_VDD_30_31 ; + cfg->voltages |=MMC_VDD_29_30 |MMC_VDD_30_31 ;if (caps &SDHCI_CAN_VDD_180 ) - host->cfg.voltages |=MMC_VDD_165_195 ; + cfg->voltages |=MMC_VDD_165_195 ; -if (host->quirks &SDHCI_QUIRK_BROKEN_VOLTAGE ) - host->cfg.voltages |= host->voltages; - - host->cfg.host_caps =MMC_MODE_HS | MMC_MODE_HS_52MHz |MMC_MODE_4BIT ; -if (SDHCI_GET_VERSION (host) >=SDHCI_SPEC_300 ) { + cfg->host_caps =MMC_MODE_HS | MMC_MODE_HS_52MHz |MMC_MODE_4BIT ; +if (version >=SDHCI_SPEC_300 ) {if (caps &SDHCI_CAN_DO_8BIT ) - host->cfg.host_caps |=MMC_MODE_8BIT ; + cfg->host_caps |=MMC_MODE_8BIT ; } -if (host->quirks &SDHCI_QUIRK_NO_HISPD_BIT ) - host->cfg.host_caps &= ~(MMC_MODE_HS | MMC_MODE_HS_52MHz); +if (quirks &SDHCI_QUIRK_NO_HISPD_BIT ) + cfg->host_caps &= ~(MMC_MODE_HS | MMC_MODE_HS_52MHz); + +if (host_caps) + cfg->host_caps |= host_caps; -if (host->host_caps) - host->cfg.host_caps |= host->host_caps; + cfg->b_max =CONFIG_SYS_MMC_MAX_BLK_COUNT ; - host->cfg.b_max =CONFIG_SYS_MMC_MAX_BLK_COUNT ; +return 0 ; +} + +int add_sdhci (struct sdhci_host *host,u32 max_clk,u32 min_clk) +{ +unsigned int caps; + + caps =sdhci_readl (host,SDHCI_CAPABILITIES ); +#ifdef CONFIG_MMC_SDMA +if (!(caps &SDHCI_CAN_DO_SDMA )) { +printf ("%s: Your controller doesn't support SDMA!!\n" , + __func__); +return -1 ; + } +#endif + +if (sdhci_setup_cfg (&host->cfg, host->name, host->bus_width, caps, + max_clk, min_clk,SDHCI_GET_VERSION (host), + host->quirks, host->host_caps)) { +printf ("%s: Hardware doesn't specify base clock frequency\n" , + __func__); +return -EINVAL ; + } + +if (host->quirks &SDHCI_QUIRK_BROKEN_VOLTAGE ) + host->cfg.voltages |= host->voltages;sdhci_reset (host,SDHCI_RESET_ALL );
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 15/27 dm: mmc: sdhci: Refactor configuration setup to support DM
Quoted 8 lines · Simon Glass
Move the configuration setting into a separate function which can be used by the driver-model code.
Signed-off-by Simon Glass <[email protected]>---
drivers/mmc/sdhci.c | 107 +++++++++++++++++++++++++++++----------------------- 1 file changed, 59 insertions(+), 48 deletions(-)
Applied to u-boot-dm/next.
PATCH 16/27 dm: mmc: sdhci: Support CONFIG_BLK and CONFIG_DM_MMC_OPS
In reply to Simon GlassAdd support for using driver model for block devices and MMC operations in this driver.
---
drivers/mmc/sdhci.c | 40 ++++++++++++++++++++++++++- include/sdhci.h | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+), 1 deletion(-)
drivers/mmc/sdhci.c +39 -1
@@ -129,9 +129,17 @@ static int sdhci_transfer_data(struct sdhci_host *host, struct mmc_data *data,#endif #define CONFIG_SDHCI_CMD_DEFAULT_TIMEOUT 100 +#ifdef CONFIG_DM_MMC_OPS +static int sdhci_send_command (struct udevice *dev,struct mmc_cmd *cmd, +struct mmc_data *data) +{ +struct mmc *mmc =mmc_get_mmc_dev (dev); + +#else static int sdhci_send_command (struct mmc *mmc,struct mmc_cmd *cmd, -struct mmc_data *data) +struct mmc_data *data) { +#endif struct sdhci_host *host = mmc->priv;unsigned int stat =0 ;int ret =0 ;
@@ -389,8 +397,14 @@ static void sdhci_set_power(struct sdhci_host *host, unsigned short power)sdhci_writeb (host, pwr,SDHCI_POWER_CONTROL ); } +#ifdef CONFIG_DM_MMC_OPS +static int sdhci_set_ios (struct udevice *dev) +{ +struct mmc *mmc =mmc_get_mmc_dev (dev); +#else static void sdhci_set_ios (struct mmc *mmc) { +#endif u32 ctrl;struct sdhci_host *host = mmc->priv;
@@ -426,6 +440,9 @@ static void sdhci_set_ios(struct mmc *mmc) ctrl &= ~SDHCI_CTRL_HISPD ;sdhci_writeb (host, ctrl,SDHCI_HOST_CONTROL ); +#ifdef CONFIG_DM_MMC_OPS +return 0 ; +#endif }static int sdhci_init (struct mmc *mmc)
@@ -472,12 +489,25 @@ static int sdhci_init(struct mmc *mmc)return 0 ; } +#ifdef CONFIG_DM_MMC_OPS +int sdhci_probe (struct udevice *dev) +{ +struct mmc *mmc =mmc_get_mmc_dev (dev); + +return sdhci_init (mmc); +} +const struct dm_mmc_ops sdhci_ops = { + .send_cmd = sdhci_send_command, + .set_ios = sdhci_set_ios, +}; +#else static const struct mmc_ops sdhci_ops = { .send_cmd = sdhci_send_command, .set_ios = sdhci_set_ios, .init = sdhci_init, }; +#endif int sdhci_setup_cfg(struct mmc_config *cfg, const char *name, int buswidth, uint caps, u32 max_clk, u32 min_clk, uint version,
@@ -528,11 +558,18 @@ int sdhci_setup_cfg(struct mmc_config *cfg, const char *name, int buswidth,if (host_caps) cfg->host_caps |= host_caps; + cfg->b_max =CONFIG_SYS_MMC_MAX_BLK_COUNT ;return 0 ; } +#ifdef CONFIG_BLK +int sdhci_bind (struct udevice *dev,struct mmc *mmc,struct mmc_config *cfg) +{ +return mmc_bind (dev, mmc, cfg); +} +#else int add_sdhci (struct sdhci_host *host,u32 max_clk,u32 min_clk) {unsigned int caps;
@@ -567,3 +604,4 @@ int add_sdhci(struct sdhci_host *host, u32 max_clk, u32 min_clk) return 0; } +#endif
include/sdhci.h +80 -0
85 lines not on this page · raw message
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 16/27 dm: mmc: sdhci: Support CONFIG_BLK and CONFIG_DM_MMC_OPS
Quoted 9 lines · Simon Glass
Add support for using driver model for block devices and MMC operations in this driver.
Signed-off-by Simon Glass <[email protected]>---
drivers/mmc/sdhci.c | 40 ++++++++++++++++++++++++++- include/sdhci.h | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 119 insertions(+), 1 deletion(-)
Applied to u-boot-dm/next.
PATCH 17/27 dm: mmc: msm_sdhci: Support CONFIG_BLK and CONFIG_DM_MMC_OPS
In reply to Simon GlassAdd support for using driver model for block devices and MMC operations in this driver.
---
drivers/mmc/msm_sdhci.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-)
drivers/mmc/msm_sdhci.c +49 -2
@@ -36,6 +36,11 @@/* Non standard (?) SDHCI register */ #define SDHCI_VENDOR_SPEC_CAPABILITIES0 0x11c +struct msm_sdhc_plat { +struct mmc_config cfg; +struct mmc mmc; +}; +struct msm_sdhc {struct sdhci_host host;void *base;
@@ -74,9 +79,14 @@ static int msm_sdc_clk_init(struct udevice *dev)static int msm_sdc_probe (struct udevice *dev) { +struct mmc_uclass_priv *upriv =dev_get_uclass_priv (dev); +#ifdef CONFIG_BLK +struct msm_sdhc_plat *plat =dev_get_platdata (dev); +#endif struct msm_sdhc *prv =dev_get_priv (dev);struct sdhci_host *host = &prv->host;u32 core_version, core_minor, core_major; +u32 caps;int ret; host->quirks =SDHCI_QUIRK_WAIT_SEND_CMD |SDHCI_QUIRK_BROKEN_R1B ;
@@ -120,7 +130,7 @@ static int msm_sdc_probe(struct udevice *dev)* controller versions and must be explicitly enabled. */ if (core_major >=1 && core_minor !=0x11 && core_minor !=0x12 ) { -u32 caps =readl (host->ioaddr +SDHCI_CAPABILITIES ); + caps =readl (host->ioaddr +SDHCI_CAPABILITIES ); caps |=SDHCI_CAN_VDD_300 |SDHCI_CAN_DO_8BIT ;writel (caps, host->ioaddr +SDHCI_VENDOR_SPEC_CAPABILITIES0 ); }
@@ -128,8 +138,26 @@ static int msm_sdc_probe(struct udevice *dev)/* Set host controller version */ host->version =sdhci_readw (host,SDHCI_HOST_VERSION ); +#ifdef CONFIG_BLK + caps =sdhci_readl (host,SDHCI_CAPABILITIES ); + ret =sdhci_setup_cfg (&plat->cfg, dev->name, host->bus_width, + caps,0 ,0 , host->version, host->quirks,0 ); + host->mmc = &plat->mmc; +#else /* automatically detect max and min speed */ -return add_sdhci (host,0 ,0 ); + ret =add_sdhci (host,0 ,0 ); +#endif +if (ret) +return ret; + host->mmc->priv = &prv->host; + host->mmc->dev = dev; + upriv->mmc = host->mmc; + +#ifdef CONFIG_DM_MMC_OPS +return sdhci_probe (dev); +#else +return 0 ; +#endif }static int msm_sdc_remove (struct udevice *dev)
@@ -164,6 +192,20 @@ static int msm_ofdata_to_platdata(struct udevice *dev)return 0 ; } +static int msm_sdc_bind (struct udevice *dev) +{ +#ifdef CONFIG_BLK +struct msm_sdhc_plat *plat =dev_get_platdata (dev); +int ret; + + ret =sdhci_bind (dev, &plat->mmc, &plat->cfg); +if (ret) +return ret; +#endif + +return 0 ; +} +static const struct udevice_id msm_mmc_ids[] = { { .compatible ="qcom,sdhci-msm-v4" }, { }
@@ -174,7 +216,12 @@ U_BOOT_DRIVER(msm_sdc_drv) = { .id = UCLASS_MMC, .of_match = msm_mmc_ids, .ofdata_to_platdata = msm_ofdata_to_platdata, +#ifdef CONFIG_DM_MMC_OPS + .ops = &sdhci_ops, +#endif + .bind = msm_sdc_bind, .probe = msm_sdc_probe, .remove = msm_sdc_remove, .priv_auto_alloc_size = sizeof(struct msm_sdhc), + .platdata_auto_alloc_size = sizeof(struct msm_sdhc_plat), };
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 17/27 dm: mmc: msm_sdhci: Support CONFIG_BLK and CONFIG_DM_MMC_OPS
Quoted 8 lines · Simon Glass
Add support for using driver model for block devices and MMC operations in this driver.
Signed-off-by Simon Glass <[email protected]>---
drivers/mmc/msm_sdhci.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 2 deletions(-)
Applied to u-boot-dm/next.
PATCH 18/27 dm: mmc: Move dragonboard410c to use CONFIG_BLK and CONFIG_DM_MMC_OPS
In reply to Simon GlassUpdate this board to use driver model for block devices and MMC operations.
---
configs/dragonboard410c_defconfig | 2 ++ 1 file changed, 2 insertions(+)
configs/dragonboard410c_defconfig +2 -0
@@ -18,6 +18,7 @@ CONFIG_CMD_EXT2=y CONFIG_CMD_EXT4=y CONFIG_CMD_FAT=y CONFIG_CMD_FS_GENERIC=y +CONFIG_BLK=y CONFIG_CLK=y CONFIG_MSM_GPIO=y CONFIG_PM8916_GPIO=y
@@ -25,6 +26,7 @@ CONFIG_LED=y CONFIG_LED_GPIO=y CONFIG_SYSRESET=y CONFIG_DM_MMC=y +CONFIG_DM_MMC_OPS=y CONFIG_MSM_SDHCI=y CONFIG_DM_PMIC=y CONFIG_PMIC_PM8916=y
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 18/27 dm: mmc: Move dragonboard410c to use CONFIG_BLK and CONFIG_DM_MMC_OPS
Quoted 7 lines · Simon Glass
Update this board to use driver model for block devices and MMC operations.
Signed-off-by Simon Glass <[email protected]>---
configs/dragonboard410c_defconfig | 2 ++ 1 file changed, 2 insertions(+)
Applied to u-boot-dm/next.
PATCH 19/27 dm: mmc: msmsdhic: Drop old MMC code
In reply to Simon GlassNow that we have fully moved to driver model, drop the old code.
---
drivers/mmc/Kconfig | 2 +- drivers/mmc/msm_sdhci.c | 15 --------------- 2 files changed, 1 insertion(+), 16 deletions(-)
drivers/mmc/Kconfig +1 -1
@@ -27,7 +27,7 @@ config DM_MMC_OPS config MSM_SDHCI bool "Qualcomm SDHCI controller" - depends on DM_MMC + depends on DM_MMC && BLK && DM_MMC_OPS help Enables support for SDHCI 2.0 controller present on some Qualcomm Snapdragon devices. This device is compatible with eMMC v4.5 and
drivers/mmc/msm_sdhci.c +0 -15
@@ -80,9 +80,7 @@ static int msm_sdc_clk_init(struct udevice *dev)static int msm_sdc_probe (struct udevice *dev) {struct mmc_uclass_priv *upriv =dev_get_uclass_priv (dev); -#ifdef CONFIG_BLK struct msm_sdhc_plat *plat =dev_get_platdata (dev); -#endif struct msm_sdhc *prv =dev_get_priv (dev);struct sdhci_host *host = &prv->host;u32 core_version, core_minor, core_major;
@@ -138,26 +136,17 @@ static int msm_sdc_probe(struct udevice *dev)/* Set host controller version */ host->version =sdhci_readw (host,SDHCI_HOST_VERSION ); -#ifdef CONFIG_BLK caps =sdhci_readl (host,SDHCI_CAPABILITIES ); ret =sdhci_setup_cfg (&plat->cfg, dev->name, host->bus_width, caps,0 ,0 , host->version, host->quirks,0 ); host->mmc = &plat->mmc; -#else -/* automatically detect max and min speed */ - ret =add_sdhci (host,0 ,0 ); -#endif if (ret)return ret; host->mmc->priv = &prv->host; host->mmc->dev = dev; upriv->mmc = host->mmc; -#ifdef CONFIG_DM_MMC_OPS return sdhci_probe (dev); -#else -return 0 ; -#endif }static int msm_sdc_remove (struct udevice *dev)
@@ -194,14 +183,12 @@ static int msm_ofdata_to_platdata(struct udevice *dev)static int msm_sdc_bind (struct udevice *dev) { -#ifdef CONFIG_BLK struct msm_sdhc_plat *plat =dev_get_platdata (dev);int ret; ret =sdhci_bind (dev, &plat->mmc, &plat->cfg);if (ret)return ret; -#endif return 0 ; }
@@ -216,9 +203,7 @@ U_BOOT_DRIVER(msm_sdc_drv) = { .id = UCLASS_MMC, .of_match = msm_mmc_ids, .ofdata_to_platdata = msm_ofdata_to_platdata, -#ifdef CONFIG_DM_MMC_OPS .ops = &sdhci_ops, -#endif .bind = msm_sdc_bind, .probe = msm_sdc_probe, .remove = msm_sdc_remove,
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 19/27 dm: mmc: msmsdhic: Drop old MMC code
Quoted 8 lines · Simon Glass
Now that we have fully moved to driver model, drop the old code.
Signed-off-by Simon Glass <[email protected]>---
drivers/mmc/Kconfig | 2 +- drivers/mmc/msm_sdhci.c | 15 --------------- 2 files changed, 1 insertion(+), 16 deletions(-)
Applied to u-boot-dm/next.
PATCH 20/27 dm: spl: mmc: Support CONFIG_BLK in SPL MMC
In reply to Simon GlassUpdate the method of accessing the block device so that it works with CONFIG_BLK enabled.
---
common/spl/spl_mmc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
common/spl/spl_mmc.c +3 -3
@@ -184,7 +184,7 @@ static int mmc_load_image_raw_os(struct mmc *mmc)unsigned long count;int ret; - count = mmc->block_dev.block_read (&mmc->block_dev, + count =blk_dread (mmc_get_blk_desc (mmc),CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTOR ,CONFIG_SYS_MMCSD_RAW_MODE_ARGS_SECTORS , (void *)CONFIG_SYS_SPL_ARGS_ADDR );
@@ -225,13 +225,13 @@ int spl_mmc_do_fs_boot(struct mmc *mmc)#ifdef CONFIG_SPL_FAT_SUPPORT if (!spl_start_uboot ()) { - err =spl_load_image_fat_os (&mmc->block_dev, + err =spl_load_image_fat_os (mmc_get_blk_desc (mmc),CONFIG_SYS_MMCSD_FS_BOOT_PARTITION );if (!err)return err; }#ifdef CONFIG_SPL_FS_LOAD_PAYLOAD_NAME - err =spl_load_image_fat (&mmc->block_dev, + err =spl_load_image_fat (mmc_get_blk_desc (mmc),CONFIG_SYS_MMCSD_FS_BOOT_PARTITION ,CONFIG_SPL_FS_LOAD_PAYLOAD_NAME );if (!err)
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 20/27 dm: spl: mmc: Support CONFIG_BLK in SPL MMC
Quoted 8 lines · Simon Glass
Update the method of accessing the block device so that it works with
CONFIG_BLKenabled.Signed-off-by Simon Glass <[email protected]>---
common/spl/spl_mmc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
Applied to u-boot-dm/next.
PATCH 21/27 dm: dfu: mmc: Support CONFIG_BLK in DFU for MMC
In reply to Simon GlassUpdate the method of accessing the block device so that it works with CONFIG_BLK enabled.
---
drivers/dfu/dfu_mmc.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
drivers/dfu/dfu_mmc.c +5 -6
@@ -49,7 +49,7 @@ static int mmc_block_op(enum dfu_op op, struct dfu_entity *dfu, }if (dfu->data.mmc.hw_partition >=0 ) { - part_num_bkp = mmc->block_dev.hwpart; + part_num_bkp =mmc_get_blk_desc (mmc)->hwpart; ret =blk_select_hwpart_devnum (IF_TYPE_MMC , dfu->data.mmc.dev_num, dfu->data.mmc.hw_partition);
@@ -62,12 +62,11 @@ static int mmc_block_op(enum dfu_op op, struct dfu_entity *dfu, dfu->data.mmc.dev_num, blk_start, blk_count, buf);switch (op) {case DFU_OP_READ : - n = mmc->block_dev.block_read (&mmc->block_dev, blk_start, - blk_count, buf); + n =blk_dread (mmc_get_blk_desc (mmc), blk_start, blk_count, buf);break ;case DFU_OP_WRITE : - n = mmc->block_dev.block_write (&mmc->block_dev, blk_start, - blk_count, buf); + n =blk_dwrite (mmc_get_blk_desc (mmc), blk_start, blk_count, + buf);break ;default :error ("Operation not supported\n" );
@@ -356,7 +355,7 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char *s) }else if (!strcmp (entity_type,"part" )) {disk_partition_t partinfo; -struct blk_desc *blk_dev = &mmc->block_dev; +struct blk_desc *blk_dev =mmc_get_blk_desc (mmc);int mmcdev = second_arg;int mmcpart = third_arg;
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 21/27 dm: dfu: mmc: Support CONFIG_BLK in DFU for MMC
Quoted 8 lines · Simon Glass
Update the method of accessing the block device so that it works with
CONFIG_BLKenabled.Signed-off-by Simon Glass <[email protected]>---
drivers/dfu/dfu_mmc.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
Applied to u-boot-dm/next.
PATCH 22/27 net: phy: marvell: Add a missing errno.h header
In reply to Simon GlassThis corrects a build error on zynqmp.
---
drivers/net/phy/marvell.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/phy/marvell.c +1 -0
@@ -8,6 +8,7 @@*/ #include <config.h> #include <common.h> +#include <errno.h> #include <phy.h> #define PHY_AUTONEGOTIATE_TIMEOUT 5000
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 22/27 net: phy: marvell: Add a missing errno.h header
Hi Simon,
Quoted 14 lines · Simon Glass
This corrects a build error on zynqmp.
Signed-off-by Simon Glass <[email protected]>Signed-off-by Simon Glass <[email protected]>---
drivers/net/phy/marvell.c | 1 + 1 file changed, 1 insertion(+)drivers/net/phy/marvell.c +0
-0
drivers/net/phy/marvell.c line 12
Quoted 5 lines
drivers/net/phy/marvell.c +1
-0@@ -8,6 +8,7 @@*/ #include <config.h> #include <common.h> +#include <errno.h> #include <phy.h>
Maybe we can go ahead and apply this:
https://patchwork.ozlabs.org/patch/605766/
Otherwise,
PATCH 22/27 net: phy: marvell: Add a missing errno.h header
Quoted 6 lines · Joe Hershberger
Hi Simon,
Quoted 3 lines · Simon Glass
This corrects a build error on zynqmp.
Signed-off-by Simon Glass <[email protected]>
Maybe fix this address too.
Thanks,
Michal
PATCH 22/27 net: phy: marvell: Add a missing errno.h header
In reply to Joe HershbergerHi Joe,
Quoted 25 lines · Joe Hershberger
Hi Simon,
Quoted 14 lines · Simon Glass
This corrects a build error on zynqmp.
Signed-off-by Simon Glass <[email protected]>Signed-off-by Simon Glass <[email protected]>---
drivers/net/phy/marvell.c | 1 + 1 file changed, 1 insertion(+)drivers/net/phy/marvell.c +0
-0drivers/net/phy/marvell.c line 12
Quoted 5 lines
drivers/net/phy/marvell.c +1
-0@@ -8,6 +8,7 @@*/ #include <config.h> #include <common.h> +#include <errno.h> #include <phy.h> Maybe we can go ahead and apply this:
Quoted 1 line
That seems reasonable to me. I like splitting headers up, but this one seems pretty fundamental.
Quoted 4 lines
Otherwise,
Acked-by Joe Hershberger <[email protected]>
Regards,
Simon
PATCH 23/27 zynq: Increase the early malloc() size
In reply to Simon GlassThis is needed to support driver-model conversion of USB and block devices.
---
arch/arm/cpu/armv8/zynqmp/Kconfig | 4 ++++ arch/arm/mach-zynq/Kconfig | 3 +++ 2 files changed, 7 insertions(+)
arch/arm/cpu/armv8/zynqmp/Kconfig +4 -0
@@ -20,4 +20,8 @@ config SYS_CONFIG_NAME config ZYNQMP_USB bool "Configure ZynqMP USB" +config SYS_MALLOC_F_LEN + default 0x600 + + endif
arch/arm/mach-zynq/Kconfig +3 -0
@@ -17,4 +17,7 @@ config SYS_CONFIG_NAME Based on this option include/configs/<CONFIG_SYS_CONFIG_NAME>.h header will be used for board configuration. +config SYS_MALLOC_F_LEN + default 0x600 + endif
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 24/27 dm: zynq: usb: Convert to CONFIG_DM_USB
In reply to Simon GlassConvert zynq USB to driver model. It does not actually work, but the error is similar.
Before:
Zynq> dm tree
Class Probed Name
----------------------------------------
root [ + ] root_driver rsa_mod_exp [ ] |-- mod_exp_sw simple_bus [ + ] `-- amba gpio [ ] |-- gpio at e000a000 serial [ + ] |-- serial at e0001000 spi [ + ] |-- spi at e000d000 spi_flash [ ] | `-- spi_flash at 0:0 eth [ + ] |-- ethernet at e000b000 mmc [ + ] |-- sdhci at e0100000 simple_bus [ ] `-- slcr at f8000000
Zynq> usb start
starting USB...
USB0: USB EHCI 1.00
scanning bus 0 for devices... 2 USB Device(s) found
USB1: usb1 wrong num MIO: 0, Index 1
lowlevel init failed
scanning usb for storage devices... 0 Storage Device(s) found
Zynq>
After:
Zynq> dm tree
Class Probed Name
----------------------------------------
root [ + ] root_driver rsa_mod_exp [ ] |-- mod_exp_sw simple_bus [ + ] `-- amba gpio [ ] |-- gpio at e000a000 serial [ + ] |-- serial at e0001000 spi [ + ] |-- spi at e000d000 spi_flash [ ] | `-- spi_flash at 0:0 eth [ + ] |-- ethernet at e000b000 mmc [ + ] |-- sdhci at e0100000 blk [ + ] | `-- sdhci at e0100000.blk simple_bus [ ] |-- slcr at f8000000 usb [ + ] `-- usb at e0002000
Zynq> usb start
starting USB...
USB0: USB EHCI 1.00
scanning bus 0 for devices... Error: Cannot find high speed parent of usb-1 device EHCI timed out on TD - token=0x80008c80
unable to get device descriptor (error=-1)
failed, error -1
Zynq>
---
arch/arm/Kconfig | 2 + drivers/usb/host/ehci-zynq.c | 102 +++++++++++++++++++++---------------------- 2 files changed, 52 insertions(+), 52 deletions(-)
arch/arm/Kconfig +2 -0
@@ -643,6 +643,7 @@ config ARCH_ZYNQ select DM_SERIAL select DM_SPI_FLASH select SPL_SEPARATE_BSS if SPL + select DM_USB config ARCH_ZYNQMP bool "Support Xilinx ZynqMP Platform"
@@ -651,6 +652,7 @@ config ARCH_ZYNQMP select OF_CONTROL select DM_SERIAL select SUPPORT_SPL + select DM_USB config TEGRA bool "NVIDIA Tegra"
drivers/usb/host/ehci-zynq.c +50 -52
133 lines not on this page · raw message
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 24/27 dm: zynq: usb: Convert to CONFIG_DM_USB
Hi Simon,
2016-06-13 7:30 GMT+02:00 Simon Glass <[email protected]>:
Quoted 4 lines
Convert zynq USB to driver model. It does not actually work, but the error is similar.
The first one is working. That low level init failed is there because there are two usb controllers and one is not wired.
If you put usb stick to zybo you will see storage device there.
That's why this patch is breaking usb support.
Thanks,
Michal
PATCH 24/27 dm: zynq: usb: Convert to CONFIG_DM_USB
In reply to Simon GlassHi Simon,
Quoted 99 lines
-----Original Message-----
From: U-Boot [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Simon Glass
Sent: Monday, June 13, 2016 11:01 AM
To: U-Boot Mailing List <[email protected]>
Cc: Marek Vasut <[email protected]>
Subject: [U-Boot] [PATCH 24/27] dm: zynq: usb: Convert toCONFIG_DM_USBConvert zynq USB to driver model. It does not actually work, but the error is similar.
Before:
Zynq> dm tree
Class Probed Name
----------------------------------------root [ + ] root_driver rsa_mod_exp [ ] |-- mod_exp_sw simple_bus [ + ] `-- amba gpio [ ] |-- gpio at e000a000 serial [ + ] |-- serial at e0001000 spi [ + ] |-- spi at e000d000 spi_flash [ ] | `-- spi_flash at 0:0 eth [ + ] |-- ethernet at e000b000 mmc [ + ] |-- sdhci at e0100000 simple_bus [ ] `-- slcr at f8000000Zynq> usb start
starting USB...
USB0: USB EHCI 1.00
scanning bus 0 for devices... 2 USB Device(s) found
USB1: usb1 wrong num MIO: 0, Index 1
lowlevel init failed
scanning usb for storage devices... 0 Storage Device(s) found
Zynq>After:
Zynq> dm tree
Class Probed Name
----------------------------------------root [ + ] root_driver rsa_mod_exp [ ] |-- mod_exp_sw simple_bus [ + ] `-- amba gpio [ ] |-- gpio at e000a000 serial [ + ] |-- serial at e0001000 spi [ + ] |-- spi at e000d000 spi_flash [ ] | `-- spi_flash at 0:0 eth [ + ] |-- ethernet at e000b000 mmc [ + ] |-- sdhci at e0100000 blk [ + ] | `-- sdhci at e0100000.blk simple_bus [ ] |-- slcr at f8000000 usb [ + ] `-- usb at e0002000Zynq> usb start
starting USB...
USB0: USB EHCI 1.00
scanning bus 0 for devices... Error: Cannot find high speed parent of usb-1 device EHCI timed out on TD - token=0x80008c80 unable to get device descriptor (error=-1) failed, error -1
Zynq>Signed-off-by Simon Glass <[email protected]>---
arch/arm/Kconfig | 2 + drivers/usb/host/ehci-zynq.c | 102 +++++++++++++++++++++---------------------- 2 files changed, 52 insertions(+), 52 deletions(-)arch/arm/Kconfig index 1af9c35..2b501eb renamed from arch/arm/Kconfig +0
-0100644
arch/arm/Kconfig +2
-0@@ -643,6 +643,7 @@ config ARCH_ZYNQ select DM_SERIAL select DM_SPI_FLASH select SPL_SEPARATE_BSS if SPL + select DM_USB config ARCH_ZYNQMP bool "Support Xilinx ZynqMP Platform"@@ -651,6 +652,7 @@ config ARCH_ZYNQMP select OF_CONTROL select DM_SERIAL select SUPPORT_SPL + select DM_USB config TEGRA bool "NVIDIA Tegra"drivers/usb/host/ehci-zynq.c index renamed from drivers/usb/host/ehci-zynq.c +0
-037a7935..b45c68d 100644
drivers/usb/host/ehci-zynq.c +2
-0@@ -7,55 +7,47 @@*/ #include <common.h> +#include <dm.h> +#include <usb.h> #include <asm/arch/hardware.h> #include <asm/arch/sys_proto.h> #include <asm/io.h>
drivers/usb/host/ehci-zynq.c line 20
Quoted 10 lines
drivers/usb/host/ehci-zynq.c +1
-4-#include <usb.h> #include <usb/ehci-ci.h> #include <usb/ulpi.h> #include "ehci.h" -#define ZYNQ_USB_USBCMD_RST 0x0000002 -#define ZYNQ_USB_USBCMD_STOP 0x0000000 -#define ZYNQ_USB_NUM_MIO 12 +struct zynq_ehci_priv {
Please add below member to this structure as per my conversation with Hans de Goede. This solves the usb issue which you stated,
Struct struct ehci_ctrl ehcictrl;
Thanks,
Siva
Quoted 125 lines
drivers/usb/host/ehci-zynq.c +46
-49+struct usb_ehci *ehci; +}; -/* -* Create the appropriate control structures to manage -* a new EHCI host controller. -*/ -int ehci_hcd_init (int index,enum usb_init_type init,struct ehci_hccr **hccr, -struct ehci_hcor **hcor) +static int ehci_zynq_ofdata_to_platdata (struct udevice *dev) { -struct usb_ehci *ehci; +struct zynq_ehci_priv *priv =dev_get_priv (dev); + + priv->ehci = (struct usb_ehci *)dev_get_addr_ptr (dev); +if (!priv->ehci) +return -EINVAL ; + +return 0 ; +} + +static int ehci_zynq_probe (struct udevice *dev) { +struct usb_platdata *plat =dev_get_platdata (dev); +struct zynq_ehci_priv *priv =dev_get_priv (dev); +struct ehci_hccr *hccr; +struct ehci_hcor *hcor;struct ulpi_viewport ulpi_vp; -int ret, mio_usb;/* Used for writing the ULPI data address */ struct ulpi_regs *ulpi = (struct ulpi_regs *)0 ; +int ret; -if (!index) { - mio_usb =zynq_slcr_get_mio_pin_status ("usb0" ); -if (mio_usb !=ZYNQ_USB_NUM_MIO ) { -printf ("usb0 wrong num MIO: %d, Index %d\n" , mio_usb, - index); -return -1 ; - } - ehci = (struct usb_ehci *)ZYNQ_USB_BASEADDR0 ; - }else { - mio_usb =zynq_slcr_get_mio_pin_status ("usb1" ); -if (mio_usb !=ZYNQ_USB_NUM_MIO ) { -printf ("usb1 wrong num MIO: %d, Index %d\n" , mio_usb, - index); -return -1 ; - } - ehci = (struct usb_ehci *)ZYNQ_USB_BASEADDR1 ; - } - - *hccr = (struct ehci_hccr *)((uint32_t )&ehci->caplength); - *hcor = (struct ehci_hcor *)((uint32_t ) *hccr + -HC_LENGTH (ehci_readl (&(*hccr)->cr_capbase))); + hccr = (struct ehci_hccr *)((uint32_t )&priv->ehci->caplength); + hcor = (struct ehci_hcor *)((uint32_t ) hccr + +HC_LENGTH (ehci_readl (&hccr->cr_capbase))); - ulpi_vp.viewport_addr = (u32)&ehci->ulpi_viewpoint; + ulpi_vp.viewport_addr = (u32)&priv->ehci->ulpi_viewpoint; ulpi_vp.port_num =0 ; ret =ulpi_init (&ulpi_vp);@@ -77,28 +69,34 @@ int ehci_hcd_init(int index, enum usb_init_type init,struct ehci_hccr **hccr, ulpi_write(&ulpi_vp, &ulpi->otg_ctrl_set, ULPI_OTG_DRVVBUS | ULPI_OTG_DRVVBUS_EXT); -return 0 ; +return ehci_register (dev, hccr, hcor,NULL ,0 , plat->init_type); } -/* -* Destroy the appropriate control structures corresponding -* the the EHCI host controller. -*/ -int ehci_hcd_stop (int index) +static int ehci_zynq_remove (struct udevice *dev) { -struct usb_ehci *ehci; - -if (!index) - ehci = (struct usb_ehci *)ZYNQ_USB_BASEADDR0 ; -else - ehci = (struct usb_ehci *)ZYNQ_USB_BASEADDR1 ; +int ret; -/* Stop controller */ -writel (ZYNQ_USB_USBCMD_STOP , &ehci->usbcmd); -udelay (1000 ); - -/* Initiate controller reset */ -writel (ZYNQ_USB_USBCMD_RST , &ehci->usbcmd); + ret =ehci_deregister (dev); +if (ret) +return ret;return 0 ; } + +static const struct udevice_id ehci_zynq_ids[] = { + { .compatible ="xlnx,zynq-usb-2.20a" }, + { } +}; + +U_BOOT_DRIVER (ehci_zynq) = { + .name ="ehci_zynq" , + .id =UCLASS_USB , + .of_match = ehci_zynq_ids, + .ofdata_to_platdata = ehci_zynq_ofdata_to_platdata, + .probe = ehci_zynq_probe, + .remove = ehci_zynq_remove, + .ops = &ehci_usb_ops, + .platdata_auto_alloc_size =sizeof (struct usb_platdata ), + .priv_auto_alloc_size =sizeof (struct zynq_ehci_priv ), + .flags =DM_FLAG_ALLOC_PRIV_DMA , +}; --2.8.0.rc3.226.g39d4020
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
PATCH 24/27 dm: zynq: usb: Convert to CONFIG_DM_USB
In reply to Simon GlassHi Simon,
Quoted 120 lines
-----Original Message-----
From: Siva Durga Prasad Paladugu
Sent: Tuesday, June 28, 2016 11:38 AM
To: 'Simon Glass' <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>
Cc: Marek Vasut <[email protected]>; 'Hans de Goede' <[email protected]>
Subject: RE: [U-Boot] [PATCH 24/27] dm: zynq: usb: Convert toCONFIG_DM_USBHi Simon,
Quoted 109 lines
-----Original Message-----
From: U-Boot [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Simon Glass
Sent: Monday, June 13, 2016 11:01 AM
To: U-Boot Mailing List <[email protected]>
Cc: Marek Vasut <[email protected]>
Subject: [U-Boot] [PATCH 24/27] dm: zynq: usb: Convert toCONFIG_DM_USBConvert zynq USB to driver model. It does not actually work, but the error is similar.
Before:
Zynq> dm tree
Class Probed Name
----------------------------------------root [ + ] root_driver rsa_mod_exp [ ] |-- mod_exp_sw simple_bus [ + ] `-- amba gpio [ ] |-- gpio at e000a000 serial [ + ] |-- serial at e0001000 spi [ + ] |-- spi at e000d000 spi_flash [ ] | `-- spi_flash at 0:0 eth [ + ] |-- ethernet at e000b000 mmc [ + ] |-- sdhci at e0100000 simple_bus [ ] `-- slcr at f8000000Zynq> usb start
starting USB...
USB0: USB EHCI 1.00
scanning bus 0 for devices... 2 USB Device(s) found
USB1: usb1 wrong num MIO: 0, Index 1
lowlevel init failed
scanning usb for storage devices... 0 Storage Device(s) found
Zynq>After:
Zynq> dm tree
Class Probed Name
----------------------------------------root [ + ] root_driver rsa_mod_exp [ ] |-- mod_exp_sw simple_bus [ + ] `-- amba gpio [ ] |-- gpio at e000a000 serial [ + ] |-- serial at e0001000 spi [ + ] |-- spi at e000d000 spi_flash [ ] | `-- spi_flash at 0:0 eth [ + ] |-- ethernet at e000b000 mmc [ + ] |-- sdhci at e0100000 blk [ + ] | `-- sdhci at e0100000.blk simple_bus [ ] |-- slcr at f8000000 usb [ + ] `-- usb at e0002000Zynq> usb start
starting USB...
USB0: USB EHCI 1.00
scanning bus 0 for devices... Error: Cannot find high speed parent of usb-1 device EHCI timed out on TD - token=0x80008c80 unable to get device descriptor (error=-1) failed, error -1
Zynq>Signed-off-by Simon Glass <[email protected]>---
arch/arm/Kconfig | 2 + drivers/usb/host/ehci-zynq.c | 102 +++++++++++++++++++++---------------------- 2 files changed, 52 insertions(+), 52 deletions(-)arch/arm/Kconfig index renamed from arch/arm/Kconfig +0
-01af9c35..2b501eb
100644arch/arm/Kconfig +2
-0@@ -643,6 +643,7 @@ config ARCH_ZYNQ select DM_SERIAL select DM_SPI_FLASH select SPL_SEPARATE_BSS if SPL + select DM_USB config ARCH_ZYNQMP bool "Support Xilinx ZynqMP Platform"@@ -651,6 +652,7 @@ config ARCH_ZYNQMP select OF_CONTROL select DM_SERIAL select SUPPORT_SPL + select DM_USB config TEGRA bool "NVIDIA Tegra"(quoted diff) +0
-0
b/drivers/usb/host/ehci-zynq.cindex 37a7935..b45c68d 100644drivers/usb/host/ehci-zynq.c +2
-1@@ -7,55 +7,47 @@*/ #include <common.h> +#include <dm.h> +#include <usb.h> #include <asm/arch/hardware.h> #include <asm/arch/sys_proto.h> #include <asm/io.h> -#include <usb.h> #include <usb/ehci-ci.h> #include <usb/ulpi.h> #include "ehci.h"
Quoted 8 lines
drivers/usb/host/ehci-zynq.c line 20
Quoted 4 lines
drivers/usb/host/ehci-zynq.c +1
-3-#define ZYNQ_USB_USBCMD_RST 0x0000002 -#define ZYNQ_USB_USBCMD_STOP 0x0000000 -#define ZYNQ_USB_NUM_MIO 12 +struct zynq_ehci_priv {Please add below member to this structure as per my conversation with Hans de Goede.
This solves the usb issue which you stated,Struct struct ehci_ctrl ehcictrl;
Can you add this element to structure (zynq_ehic_priv) as mentioned above in your patch?
Thanks,
Siva
Quoted 130 lines
Thanks,
SivaQuoted 125 lines
drivers/usb/host/ehci-zynq.c +46
-49+struct usb_ehci *ehci; +}; -/* -* Create the appropriate control structures to manage -* a new EHCI host controller. -*/ -int ehci_hcd_init (int index,enum usb_init_type init,struct ehci_hccr **hccr, -struct ehci_hcor **hcor) +static int ehci_zynq_ofdata_to_platdata (struct udevice *dev) { -struct usb_ehci *ehci; +struct zynq_ehci_priv *priv =dev_get_priv (dev); + + priv->ehci = (struct usb_ehci *)dev_get_addr_ptr (dev); +if (!priv->ehci) +return -EINVAL ; + +return 0 ; +} + +static int ehci_zynq_probe (struct udevice *dev) { +struct usb_platdata *plat =dev_get_platdata (dev); +struct zynq_ehci_priv *priv =dev_get_priv (dev); +struct ehci_hccr *hccr; +struct ehci_hcor *hcor;struct ulpi_viewport ulpi_vp; -int ret, mio_usb;/* Used for writing the ULPI data address */ struct ulpi_regs *ulpi = (struct ulpi_regs *)0 ; +int ret; -if (!index) { - mio_usb =zynq_slcr_get_mio_pin_status ("usb0" ); -if (mio_usb !=ZYNQ_USB_NUM_MIO ) { -printf ("usb0 wrong num MIO: %d, Index %d\n" , mio_usb, - index); -return -1 ; - } - ehci = (struct usb_ehci *)ZYNQ_USB_BASEADDR0 ; - }else { - mio_usb =zynq_slcr_get_mio_pin_status ("usb1" ); -if (mio_usb !=ZYNQ_USB_NUM_MIO ) { -printf ("usb1 wrong num MIO: %d, Index %d\n" , mio_usb, - index); -return -1 ; - } - ehci = (struct usb_ehci *)ZYNQ_USB_BASEADDR1 ; - } - - *hccr = (struct ehci_hccr *)((uint32_t )&ehci->caplength); - *hcor = (struct ehci_hcor *)((uint32_t ) *hccr + -HC_LENGTH (ehci_readl (&(*hccr)->cr_capbase))); + hccr = (struct ehci_hccr *)((uint32_t )&priv->ehci->caplength); + hcor = (struct ehci_hcor *)((uint32_t ) hccr + +HC_LENGTH (ehci_readl (&hccr->cr_capbase))); - ulpi_vp.viewport_addr = (u32)&ehci->ulpi_viewpoint; + ulpi_vp.viewport_addr = (u32)&priv->ehci->ulpi_viewpoint; ulpi_vp.port_num =0 ; ret =ulpi_init (&ulpi_vp);@@ -77,28 +69,34 @@ int ehci_hcd_init(int index, enum usb_init_type init, struct ehci_hccr **hccr,ulpi_write (&ulpi_vp, &ulpi->otg_ctrl_set,ULPI_OTG_DRVVBUS |ULPI_OTG_DRVVBUS_EXT ); -return 0 ; +return ehci_register (dev, hccr, hcor,NULL ,0 , plat->init_type); } -/* -* Destroy the appropriate control structures corresponding -* the the EHCI host controller. -*/ -int ehci_hcd_stop (int index) +static int ehci_zynq_remove (struct udevice *dev) { -struct usb_ehci *ehci; - -if (!index) - ehci = (struct usb_ehci *)ZYNQ_USB_BASEADDR0 ; -else - ehci = (struct usb_ehci *)ZYNQ_USB_BASEADDR1 ; +int ret; -/* Stop controller */ -writel (ZYNQ_USB_USBCMD_STOP , &ehci->usbcmd); -udelay (1000 ); - -/* Initiate controller reset */ -writel (ZYNQ_USB_USBCMD_RST , &ehci->usbcmd); + ret =ehci_deregister (dev); +if (ret) +return ret;return 0 ; } + +static const struct udevice_id ehci_zynq_ids[] = { + { .compatible ="xlnx,zynq-usb-2.20a" }, + { } +}; + +U_BOOT_DRIVER (ehci_zynq) = { + .name ="ehci_zynq" , + .id =UCLASS_USB , + .of_match = ehci_zynq_ids, + .ofdata_to_platdata = ehci_zynq_ofdata_to_platdata, + .probe = ehci_zynq_probe, + .remove = ehci_zynq_remove, + .ops = &ehci_usb_ops, + .platdata_auto_alloc_size =sizeof (struct usb_platdata ), + .priv_auto_alloc_size =sizeof (struct zynq_ehci_priv ), + .flags =DM_FLAG_ALLOC_PRIV_DMA , +}; --2.8.0.rc3.226.g39d4020
_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
PATCH 24/27 dm: zynq: usb: Convert to CONFIG_DM_USB
Hi Siva,
Quoted 131 lines · Siva Durga Prasad Paladugu
Hi Simon,
Quoted 120 lines
-----Original Message-----
From: Siva Durga Prasad Paladugu
Sent: Tuesday, June 28, 2016 11:38 AM
To: 'Simon Glass' <[email protected]>; U-Boot Mailing List <u- boot at lists.denx.de>
Cc: Marek Vasut <[email protected]>; 'Hans de Goede' <[email protected]>
Subject: RE: [U-Boot] [PATCH 24/27] dm: zynq: usb: Convert toCONFIG_DM_USBHi Simon,
Quoted 109 lines
-----Original Message-----
From: U-Boot [mailto:u-boot-bounces at lists.denx.de] On Behalf Of Simon Glass
Sent: Monday, June 13, 2016 11:01 AM
To: U-Boot Mailing List <[email protected]>
Cc: Marek Vasut <[email protected]>
Subject: [U-Boot] [PATCH 24/27] dm: zynq: usb: Convert toCONFIG_DM_USBConvert zynq USB to driver model. It does not actually work, but the error is similar.
Before:
Zynq> dm tree
Class Probed Name
----------------------------------------root [ + ] root_driver rsa_mod_exp [ ] |-- mod_exp_sw simple_bus [ + ] `-- amba gpio [ ] |-- gpio at e000a000 serial [ + ] |-- serial at e0001000 spi [ + ] |-- spi at e000d000 spi_flash [ ] | `-- spi_flash at 0:0 eth [ + ] |-- ethernet at e000b000 mmc [ + ] |-- sdhci at e0100000 simple_bus [ ] `-- slcr at f8000000Zynq> usb start
starting USB...
USB0: USB EHCI 1.00
scanning bus 0 for devices... 2 USB Device(s) found
USB1: usb1 wrong num MIO: 0, Index 1
lowlevel init failed
scanning usb for storage devices... 0 Storage Device(s) found
Zynq>After:
Zynq> dm tree
Class Probed Name
----------------------------------------root [ + ] root_driver rsa_mod_exp [ ] |-- mod_exp_sw simple_bus [ + ] `-- amba gpio [ ] |-- gpio at e000a000 serial [ + ] |-- serial at e0001000 spi [ + ] |-- spi at e000d000 spi_flash [ ] | `-- spi_flash at 0:0 eth [ + ] |-- ethernet at e000b000 mmc [ + ] |-- sdhci at e0100000 blk [ + ] | `-- sdhci at e0100000.blk simple_bus [ ] |-- slcr at f8000000 usb [ + ] `-- usb at e0002000Zynq> usb start
starting USB...
USB0: USB EHCI 1.00
scanning bus 0 for devices... Error: Cannot find high speed parent of usb-1 device EHCI timed out on TD - token=0x80008c80 unable to get device descriptor (error=-1) failed, error -1
Zynq>Signed-off-by Simon Glass <[email protected]>---
arch/arm/Kconfig | 2 + drivers/usb/host/ehci-zynq.c | 102 +++++++++++++++++++++---------------------- 2 files changed, 52 insertions(+), 52 deletions(-)arch/arm/Kconfig index renamed from arch/arm/Kconfig +0
-01af9c35..2b501eb
100644arch/arm/Kconfig +2
-0@@ -643,6 +643,7 @@ config ARCH_ZYNQ select DM_SERIAL select DM_SPI_FLASH select SPL_SEPARATE_BSS if SPL + select DM_USB config ARCH_ZYNQMP bool "Support Xilinx ZynqMP Platform"@@ -651,6 +652,7 @@ config ARCH_ZYNQMP select OF_CONTROL select DM_SERIAL select SUPPORT_SPL + select DM_USB config TEGRA bool "NVIDIA Tegra"(quoted diff) +0
-0
b/drivers/usb/host/ehci-zynq.cindex 37a7935..b45c68d 100644drivers/usb/host/ehci-zynq.c +2
-1@@ -7,55 +7,47 @@*/ #include <common.h> +#include <dm.h> +#include <usb.h> #include <asm/arch/hardware.h> #include <asm/arch/sys_proto.h> #include <asm/io.h> -#include <usb.h> #include <usb/ehci-ci.h> #include <usb/ulpi.h> #include "ehci.h" Quoted 8 lines
drivers/usb/host/ehci-zynq.c line 20
Quoted 4 lines
drivers/usb/host/ehci-zynq.c +1
-3-#define ZYNQ_USB_USBCMD_RST 0x0000002 -#define ZYNQ_USB_USBCMD_STOP 0x0000000 -#define ZYNQ_USB_NUM_MIO 12 +struct zynq_ehci_priv {Please add below member to this structure as per my conversation with Hans de Goede.
This solves the usb issue which you stated,Struct struct ehci_ctrl ehcictrl;
Quoted 1 line
Can you add this element to structure (
zynq_ehic_priv) as mentioned above in your patch?
Just to follow up - this was done and is now in mainline.
Quoted 2 lines
Thanks,
Siva
Regards,
Simon
PATCH 25/27 dm: mmc: zynq: Convert zynq to use driver model for MMC
In reply to Simon GlassMove zynq to the latest driver model support by enabling CONFIG_DM_MMC, CONFIG_DM_MMC_OPS and CONFIG_BLK.
---
arch/arm/Kconfig | 5 +++++ drivers/mmc/zynq_sdhci.c | 39 ++++++++++++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 5 deletions(-)
arch/arm/Kconfig +5 -0
@@ -639,11 +639,13 @@ config ARCH_ZYNQ select DM_GPIO select SPL_DM if SPL select DM_MMC + select DM_MMC_OPS select DM_SPI select DM_SERIAL select DM_SPI_FLASH select SPL_SEPARATE_BSS if SPL select DM_USB + select BLK config ARCH_ZYNQMP bool "Support Xilinx ZynqMP Platform"
@@ -653,6 +655,9 @@ config ARCH_ZYNQMP select DM_SERIAL select SUPPORT_SPL select DM_USB + select DM_MMC + select DM_MMC_OPS + select BLK config TEGRA bool "NVIDIA Tegra"
drivers/mmc/zynq_sdhci.c +34 -5
@@ -17,10 +17,18 @@# define CONFIG_ZYNQ_SDHCI_MIN_FREQ 0#endif +struct arasan_sdhci_plat { +struct mmc_config cfg; +struct mmc mmc; +}; +static int arasan_sdhci_probe (struct udevice *dev) { +struct arasan_sdhci_plat *plat =dev_get_platdata (dev);struct mmc_uclass_priv *upriv =dev_get_uclass_priv (dev);struct sdhci_host *host =dev_get_priv (dev); +u32 caps; +int ret; host->quirks =SDHCI_QUIRK_WAIT_SEND_CMD |SDHCI_QUIRK_BROKEN_R1B ;
@@ -31,13 +39,19 @@ static int arasan_sdhci_probe(struct udevice *dev) host->version =sdhci_readw (host,SDHCI_HOST_VERSION ); -add_sdhci (host,CONFIG_ZYNQ_SDHCI_MAX_FREQ , -CONFIG_ZYNQ_SDHCI_MIN_FREQ ); - - upriv->mmc = host->mmc; + caps =sdhci_readl (host,SDHCI_CAPABILITIES ); + ret =sdhci_setup_cfg (&plat->cfg, dev->name, host->bus_width, + caps,CONFIG_ZYNQ_SDHCI_MAX_FREQ , +CONFIG_ZYNQ_SDHCI_MIN_FREQ , host->version, + host->quirks,0 ); + host->mmc = &plat->mmc; +if (ret) +return ret; + host->mmc->priv = host; host->mmc->dev = dev; + upriv->mmc = host->mmc; -return 0 ; +return sdhci_probe (dev); }static int arasan_sdhci_ofdata_to_platdata (struct udevice *dev)
@@ -50,6 +64,18 @@ static int arasan_sdhci_ofdata_to_platdata(struct udevice *dev)return 0 ; } +static int arasan_sdhci_bind (struct udevice *dev) +{ +struct arasan_sdhci_plat *plat =dev_get_platdata (dev); +int ret; + + ret =sdhci_bind (dev, &plat->mmc, &plat->cfg); +if (ret) +return ret; + +return 0 ; +} +static const struct udevice_id arasan_sdhci_ids[] = { { .compatible ="arasan,sdhci-8.9a" }, { }
@@ -60,6 +86,9 @@ U_BOOT_DRIVER(arasan_sdhci_drv) = { .id = UCLASS_MMC, .of_match = arasan_sdhci_ids, .ofdata_to_platdata = arasan_sdhci_ofdata_to_platdata, + .ops = &sdhci_ops, + .bind = arasan_sdhci_bind, .probe = arasan_sdhci_probe, .priv_auto_alloc_size = sizeof(struct sdhci_host), + .platdata_auto_alloc_size = sizeof(struct arasan_sdhci_plat), };
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 26/27 dm: mmc: Enable DM_MMC_OPS by default with DM_MMC
In reply to Simon GlassThese two options go together and it is best to do the conversion in one step. So enable DM_MMC_OPS by default if DM_MMC is enabled.
---
drivers/mmc/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/mmc/Kconfig +1 -0
@@ -19,6 +19,7 @@ config DM_MMC config DM_MMC_OPS bool "Support MMC controller operations using Driver Model" depends on DM_MMC + default y if DM_MMC help Driver model provides a means of supporting device operations. This option moves MMC operations under the control of driver model. The
Signature · 1 line
2.8.0.rc3.226.g39d4020
PATCH 27/27 dm: blk: Enable CONFIG_BLK if DM_MMC is enabled
In reply to Simon GlassTo speed up conversion to CONFIG_BLK, enable it by default when DM_MMC is enabled.
---
drivers/block/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/block/Kconfig +1 -0
@@ -1,6 +1,7 @@ config BLK bool "Support block devices" depends on DM + default y if DM_MMC help Enable support for block devices, such as SCSI, MMC and USB flash sticks. These provide a block-level interface which permits
Signature · 1 line
2.8.0.rc3.226.g39d4020