[U-Boot] [PATCH v2 00/13] 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.
While testing the v1 series a problem was found where simple-bus would bind all child devices prior to relocation, even those not marked for pre-relocation use. This caused Zynq boards to run out of memory with DM_USB enabled.
This is caused by the 'false' value passed to dm_scan_fdt_node() by simple-bus. To fix this a new dm_scan_fdt_dev() function is created which passes the correct flag value. Existing users of dm_scan_fdt_node() are converted.
Changes in v2: - Add missing struct ehci_ctrl to struct zynq_ehci_priv - Add new dm_scan_fdt_dev() function and convert the code - Add new patch to bring in dm_scan_fdt_dev() - Add new patch to make use of dm_scan_fdt_dev() - Add new patch to show early-malloc() usage in bdinfo - Add new patch to support CONFIG_BLK with socfpga - Add new patch to support raw partitions with CONFIG_BLK - Add new patch to use blk_dread/write() instead of direct calls - Add new patch to use dm_scan_fdt_dev() directly where possible - Drop patches previously applied to u-boot-dm/next - Fix sign-off tag
Simon Glass (13): dm: core: Add a function to bind child devices dm: Convert users from dm_scan_fdt_node() to dm_scan_fdt_dev() dm: Use dm_scan_fdt_dev() directly where possible arm: Show early-malloc() usage in bdinfo 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: socfpga: mmc: Support CONFIG_BLK dm: usb: Use blk_dread/write() instead of direct calls dm: spl: mmc: Support raw partitions with CONFIG_BLK dm: mmc: Enable DM_MMC_OPS by default with DM_MMC dm: blk: Enable CONFIG_BLK if DM_MMC is enabled
arch/arm/Kconfig | 7 ++ arch/arm/cpu/armv8/zynqmp/Kconfig | 4 ++ arch/arm/mach-zynq/Kconfig | 3 + arch/x86/lib/lpc-uclass.c | 15 +---- cmd/bdinfo.c | 5 ++ cmd/usb_mass_storage.c | 4 +- common/spl/spl_mmc.c | 2 +- common/usb_hub.c | 9 +-- drivers/block/Kconfig | 1 + drivers/core/root.c | 9 +++ drivers/core/simple-bus.c | 3 +- drivers/i2c/i2c-uclass.c | 8 +-- drivers/i2c/sandbox_i2c.c | 4 +- drivers/misc/cros_ec.c | 9 +-- drivers/mmc/Kconfig | 1 + drivers/mmc/socfpga_dw_mmc.c | 32 +++++++++- drivers/mmc/zynq_sdhci.c | 39 +++++++++-- drivers/net/phy/marvell.c | 1 + drivers/pch/pch-uclass.c | 15 +---- drivers/pci/pci-uclass.c | 24 +------ drivers/pci/pci_sandbox.c | 11 +--- drivers/pinctrl/pinctrl_pic32.c | 9 +-- drivers/pinctrl/rockchip/pinctrl_rk3036.c | 9 +-- drivers/pinctrl/rockchip/pinctrl_rk3288.c | 9 +-- drivers/power/pmic/pm8916.c | 9 +-- drivers/power/regulator/Kconfig | 2 +- drivers/spi/spi-uclass.c | 9 +-- drivers/spmi/spmi-uclass.c | 8 +-- drivers/usb/emul/usb-emul-uclass.c | 9 +-- drivers/usb/host/ehci-zynq.c | 103 +++++++++++++++--------------- drivers/usb/host/usb-uclass.c | 9 +-- include/dm/device.h | 16 +++++ include/power/regulator.h | 2 +- test/dm/bus.c | 3 +- test/dm/i2c.c | 4 +- test/dm/spi.c | 4 +- 36 files changed, 192 insertions(+), 219 deletions(-)

We currently use dm_scan_fdt_node() to bind devices. It is an internal function and it requires the caller to know whether we are pre- or post- relocation.
This requirement has become quite common in drivers, so the current function is not ideal.
Add a new function with fewer arguments, that does not require internal headers. This can be used directly as a post_bind() method if needed.
Signed-off-by: Simon Glass sjg@chromium.org ---
Changes in v2: - Add new patch to bring in dm_scan_fdt_dev()
drivers/core/root.c | 9 +++++++++ include/dm/device.h | 16 ++++++++++++++++ 2 files changed, 25 insertions(+)
diff --git a/drivers/core/root.c b/drivers/core/root.c index 95886ad..d850bd0 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -218,6 +218,15 @@ int dm_scan_fdt_node(struct udevice *parent, const void *blob, int offset, return ret; }
+int dm_scan_fdt_dev(struct udevice *dev) +{ + if (dev->of_offset == -1) + return 0; + + return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, + gd->flags & GD_FLG_RELOC ? false : true); +} + int dm_scan_fdt(const void *blob, bool pre_reloc_only) { return dm_scan_fdt_node(gd->dm_root, blob, 0, pre_reloc_only); diff --git a/include/dm/device.h b/include/dm/device.h index f03bcd3..15c0564 100644 --- a/include/dm/device.h +++ b/include/dm/device.h @@ -593,6 +593,22 @@ static inline bool device_is_on_pci_bus(struct udevice *dev) #define device_foreach_child_safe(pos, next, parent) \ list_for_each_entry_safe(pos, next, &parent->child_head, sibling_node)
+/** + * dm_scan_fdt_dev() - Bind child device in a the device tree + * + * This handles device which have sub-nodes in the device tree. It scans all + * sub-nodes and binds drivers for each node where a driver can be found. + * + * If this is called prior to relocation, only pre-relocation devices will be + * bound (those marked with u-boot,dm-pre-reloc in the device tree, or where + * the driver has the DM_FLAG_PRE_RELOC flag set). Otherwise, all devices will + * be bound. + * + * @dev: Device to scan + * @return 0 if OK, -ve on error + */ +int dm_scan_fdt_dev(struct udevice *dev); + /* device resource management */ typedef void (*dr_release_t)(struct udevice *dev, void *res); typedef int (*dr_match_t)(struct udevice *dev, void *res, void *match_data);

On 5 July 2016 at 17:10, Simon Glass sjg@chromium.org wrote:
We currently use dm_scan_fdt_node() to bind devices. It is an internal function and it requires the caller to know whether we are pre- or post- relocation.
This requirement has become quite common in drivers, so the current function is not ideal.
Add a new function with fewer arguments, that does not require internal headers. This can be used directly as a post_bind() method if needed.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v2:
- Add new patch to bring in dm_scan_fdt_dev()
drivers/core/root.c | 9 +++++++++ include/dm/device.h | 16 ++++++++++++++++ 2 files changed, 25 insertions(+)
Applied to u-boot-dm.

This new function is more convenient for callers, and handles pre-relocation situations automatically.
Signed-off-by: Simon Glass sjg@chromium.org ---
Changes in v2: - Add new patch to make use of dm_scan_fdt_dev()
arch/x86/lib/lpc-uclass.c | 4 +--- common/usb_hub.c | 3 +-- drivers/core/simple-bus.c | 3 +-- drivers/i2c/i2c-uclass.c | 3 +-- drivers/i2c/sandbox_i2c.c | 4 +--- drivers/misc/cros_ec.c | 3 +-- drivers/pch/pch-uclass.c | 4 +--- drivers/pci/pci-uclass.c | 11 +---------- drivers/pci/pci_sandbox.c | 3 +-- drivers/pinctrl/pinctrl_pic32.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3036.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3288.c | 3 +-- drivers/power/pmic/pm8916.c | 3 +-- drivers/power/regulator/Kconfig | 2 +- drivers/spi/spi-uclass.c | 3 +-- drivers/spmi/spmi-uclass.c | 3 +-- drivers/usb/emul/usb-emul-uclass.c | 3 +-- drivers/usb/host/usb-uclass.c | 4 +--- include/power/regulator.h | 2 +- test/dm/bus.c | 3 +-- 20 files changed, 20 insertions(+), 50 deletions(-)
diff --git a/arch/x86/lib/lpc-uclass.c b/arch/x86/lib/lpc-uclass.c index c6e8f73..b8254ff 100644 --- a/arch/x86/lib/lpc-uclass.c +++ b/arch/x86/lib/lpc-uclass.c @@ -7,7 +7,6 @@
#include <common.h> #include <dm.h> -#include <dm/root.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -19,8 +18,7 @@ static int lpc_uclass_post_bind(struct udevice *bus) * Before relocation, only bind devices marked for pre-relocation * use. */ - return dm_scan_fdt_node(bus, gd->fdt_blob, bus->of_offset, - gd->flags & GD_FLG_RELOC ? false : true); + return dm_scan_fdt_dev(bus); }
UCLASS_DRIVER(lpc) = { diff --git a/common/usb_hub.c b/common/usb_hub.c index 0f39c9f..26ee13e 100644 --- a/common/usb_hub.c +++ b/common/usb_hub.c @@ -36,7 +36,6 @@ #include <asm/state.h> #endif #include <asm/unaligned.h> -#include <dm/root.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -758,7 +757,7 @@ int usb_hub_scan(struct udevice *hub) static int usb_hub_post_bind(struct udevice *dev) { /* Scan the bus for devices */ - return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false); + return dm_scan_fdt_dev(dev); }
static int usb_hub_post_probe(struct udevice *dev) diff --git a/drivers/core/simple-bus.c b/drivers/core/simple-bus.c index 1a9c864..5c955da 100644 --- a/drivers/core/simple-bus.c +++ b/drivers/core/simple-bus.c @@ -6,7 +6,6 @@
#include <common.h> #include <dm.h> -#include <dm/root.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -41,7 +40,7 @@ static int simple_bus_post_bind(struct udevice *dev) plat->size = cell[2]; }
- return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false); + return dm_scan_fdt_dev(dev); }
UCLASS_DRIVER(simple_bus) = { diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c index 50b99ea..9dbbe1f 100644 --- a/drivers/i2c/i2c-uclass.c +++ b/drivers/i2c/i2c-uclass.c @@ -12,7 +12,6 @@ #include <malloc.h> #include <dm/device-internal.h> #include <dm/lists.h> -#include <dm/root.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -496,7 +495,7 @@ static int i2c_post_probe(struct udevice *dev) static int i2c_post_bind(struct udevice *dev) { /* Scan the bus for devices */ - return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false); + return dm_scan_fdt_dev(dev); }
static int i2c_child_post_bind(struct udevice *dev) diff --git a/drivers/i2c/sandbox_i2c.c b/drivers/i2c/sandbox_i2c.c index 2c84c41..4696a1a 100644 --- a/drivers/i2c/sandbox_i2c.c +++ b/drivers/i2c/sandbox_i2c.c @@ -14,7 +14,6 @@ #include <asm/test.h> #include <dm/lists.h> #include <dm/device-internal.h> -#include <dm/root.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -33,8 +32,7 @@ static int get_emul(struct udevice *dev, struct udevice **devp, *opsp = NULL; plat = dev_get_parent_platdata(dev); if (!plat->emul) { - ret = dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, - false); + ret = dm_scan_fdt_dev(dev); if (ret) return ret;
diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c index e3229ef..f50e73f 100644 --- a/drivers/misc/cros_ec.c +++ b/drivers/misc/cros_ec.c @@ -26,7 +26,6 @@ #include <asm/io.h> #include <asm-generic/gpio.h> #include <dm/device-internal.h> -#include <dm/root.h> #include <dm/uclass-internal.h>
#ifdef DEBUG_TRACE @@ -1453,7 +1452,7 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) int cros_ec_post_bind(struct udevice *dev) { /* Scan for available EC devices (e.g. I2C tunnel) */ - return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false); + return dm_scan_fdt_dev(dev); }
U_BOOT_CMD( diff --git a/drivers/pch/pch-uclass.c b/drivers/pch/pch-uclass.c index 7216660..5b2fa1f 100644 --- a/drivers/pch/pch-uclass.c +++ b/drivers/pch/pch-uclass.c @@ -8,7 +8,6 @@ #include <common.h> #include <dm.h> #include <pch.h> -#include <dm/root.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -63,8 +62,7 @@ static int pch_uclass_post_bind(struct udevice *bus) * Before relocation, only bind devices marked for pre-relocation * use. */ - return dm_scan_fdt_node(bus, gd->fdt_blob, bus->of_offset, - gd->flags & GD_FLG_RELOC ? false : true); + return dm_scan_fdt_dev(bus); }
UCLASS_DRIVER(pch) = { diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index 32590ce..230d181 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -13,7 +13,6 @@ #include <pci.h> #include <asm/io.h> #include <dm/lists.h> -#include <dm/root.h> #include <dm/device-internal.h> #if defined(CONFIG_X86) && defined(CONFIG_HAVE_FSP) #include <asm/fsp/fsp_support.h> @@ -756,13 +755,6 @@ error: static int pci_uclass_post_bind(struct udevice *bus) { /* - * If there is no pci device listed in the device tree, - * don't bother scanning the device tree. - */ - if (bus->of_offset == -1) - return 0; - - /* * Scan the device tree for devices. This does not probe the PCI bus, * as this is not permitted while binding. It just finds devices * mentioned in the device tree. @@ -770,8 +762,7 @@ static int pci_uclass_post_bind(struct udevice *bus) * Before relocation, only bind devices marked for pre-relocation * use. */ - return dm_scan_fdt_node(bus, gd->fdt_blob, bus->of_offset, - gd->flags & GD_FLG_RELOC ? false : true); + return dm_scan_fdt_dev(bus); }
static int decode_regions(struct pci_controller *hose, const void *blob, diff --git a/drivers/pci/pci_sandbox.c b/drivers/pci/pci_sandbox.c index 6de5130..b562813 100644 --- a/drivers/pci/pci_sandbox.c +++ b/drivers/pci/pci_sandbox.c @@ -10,7 +10,6 @@ #include <fdtdec.h> #include <inttypes.h> #include <pci.h> -#include <dm/root.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -55,7 +54,7 @@ static int sandbox_pci_read_config(struct udevice *bus, pci_dev_t devfn, static int sandbox_pci_child_post_bind(struct udevice *dev) { /* Attach an emulator if we can */ - return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false); + return dm_scan_fdt_dev(dev); }
static const struct dm_pci_ops sandbox_pci_ops = { diff --git a/drivers/pinctrl/pinctrl_pic32.c b/drivers/pinctrl/pinctrl_pic32.c index 5cf97ec..5636f8f 100644 --- a/drivers/pinctrl/pinctrl_pic32.c +++ b/drivers/pinctrl/pinctrl_pic32.c @@ -10,7 +10,6 @@ #include <errno.h> #include <asm/io.h> #include <dm/pinctrl.h> -#include <dm/root.h> #include <mach/pic32.h>
DECLARE_GLOBAL_DATA_PTR; @@ -344,7 +343,7 @@ static int pic32_pinctrl_probe(struct udevice *dev) static int pic32_pinctrl_bind(struct udevice *dev) { /* scan child GPIO banks */ - return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false); + return dm_scan_fdt_dev(dev); }
static const struct udevice_id pic32_pinctrl_ids[] = { diff --git a/drivers/pinctrl/rockchip/pinctrl_rk3036.c b/drivers/pinctrl/rockchip/pinctrl_rk3036.c index 1f78bf8..3648678 100644 --- a/drivers/pinctrl/rockchip/pinctrl_rk3036.c +++ b/drivers/pinctrl/rockchip/pinctrl_rk3036.c @@ -15,7 +15,6 @@ #include <asm/arch/hardware.h> #include <asm/arch/periph.h> #include <dm/pinctrl.h> -#include <dm/root.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -256,7 +255,7 @@ static struct pinctrl_ops rk3036_pinctrl_ops = { static int rk3036_pinctrl_bind(struct udevice *dev) { /* scan child GPIO banks */ - return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false); + return dm_scan_fdt_dev(dev); }
static int rk3036_pinctrl_probe(struct udevice *dev) diff --git a/drivers/pinctrl/rockchip/pinctrl_rk3288.c b/drivers/pinctrl/rockchip/pinctrl_rk3288.c index 1fa1daa..0cfa950 100644 --- a/drivers/pinctrl/rockchip/pinctrl_rk3288.c +++ b/drivers/pinctrl/rockchip/pinctrl_rk3288.c @@ -17,7 +17,6 @@ #include <asm/arch/periph.h> #include <asm/arch/pmu_rk3288.h> #include <dm/pinctrl.h> -#include <dm/root.h>
DECLARE_GLOBAL_DATA_PTR;
@@ -665,7 +664,7 @@ static struct pinctrl_ops rk3288_pinctrl_ops = { static int rk3288_pinctrl_bind(struct udevice *dev) { /* scan child GPIO banks */ - return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false); + return dm_scan_fdt_dev(dev); }
#ifndef CONFIG_SPL_BUILD diff --git a/drivers/power/pmic/pm8916.c b/drivers/power/pmic/pm8916.c index d4c7d4a..6f5608e 100644 --- a/drivers/power/pmic/pm8916.c +++ b/drivers/power/pmic/pm8916.c @@ -7,7 +7,6 @@ */ #include <common.h> #include <dm.h> -#include <dm/root.h> #include <power/pmic.h> #include <spmi/spmi.h>
@@ -82,7 +81,7 @@ static int pm8916_probe(struct udevice *dev)
static int pm8916_bind(struct udevice *dev) { - return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false); + return dm_scan_fdt_dev(dev); }
U_BOOT_DRIVER(pmic_pm8916) = { diff --git a/drivers/power/regulator/Kconfig b/drivers/power/regulator/Kconfig index 465ff3f..17f22dd 100644 --- a/drivers/power/regulator/Kconfig +++ b/drivers/power/regulator/Kconfig @@ -13,7 +13,7 @@ config DM_REGULATOR - 'drivers/power/pmic/regulator-uclass.c' It's important to call the device_bind() with the proper node offset, when binding the regulator devices. The pmic_bind_childs() can be used - for this purpose if PMIC I/O driver is implemented or dm_scan_fdt_node() + for this purpose if PMIC I/O driver is implemented or dm_scan_fdt_dev() otherwise. Detailed information can be found in the header file.
config SPL_DM_REGULATOR diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c index 84b6786..b17ed75 100644 --- a/drivers/spi/spi-uclass.c +++ b/drivers/spi/spi-uclass.c @@ -12,7 +12,6 @@ #include <spi.h> #include <dm/device-internal.h> #include <dm/uclass-internal.h> -#include <dm/root.h> #include <dm/lists.h> #include <dm/util.h>
@@ -112,7 +111,7 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, static int spi_post_bind(struct udevice *dev) { /* Scan the bus for devices */ - return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false); + return dm_scan_fdt_dev(dev); }
static int spi_child_post_bind(struct udevice *dev) diff --git a/drivers/spmi/spmi-uclass.c b/drivers/spmi/spmi-uclass.c index 4ddd51b..9fa330b 100644 --- a/drivers/spmi/spmi-uclass.c +++ b/drivers/spmi/spmi-uclass.c @@ -9,7 +9,6 @@ #include <common.h> #include <dm.h> #include <errno.h> -#include <dm/root.h> #include <spmi/spmi.h> #include <linux/ctype.h>
@@ -38,7 +37,7 @@ int spmi_reg_write(struct udevice *dev, int usid, int pid, int reg,
static int spmi_post_bind(struct udevice *dev) { - return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false); + return dm_scan_fdt_dev(dev); }
UCLASS_DRIVER(spmi) = { diff --git a/drivers/usb/emul/usb-emul-uclass.c b/drivers/usb/emul/usb-emul-uclass.c index ee7ea5a..da91d04 100644 --- a/drivers/usb/emul/usb-emul-uclass.c +++ b/drivers/usb/emul/usb-emul-uclass.c @@ -8,7 +8,6 @@ #include <common.h> #include <dm.h> #include <usb.h> -#include <dm/root.h> #include <dm/device-internal.h>
DECLARE_GLOBAL_DATA_PTR; @@ -268,7 +267,7 @@ int usb_emul_setup_device(struct udevice *dev, int maxpacketsize, int usb_emul_post_bind(struct udevice *dev) { /* Scan the bus for devices */ - return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false); + return dm_scan_fdt_dev(dev); }
void usb_emul_reset(struct udevice *dev) diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c index 69c9a50..070e271 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -14,7 +14,6 @@ #include <usb.h> #include <dm/device-internal.h> #include <dm/lists.h> -#include <dm/root.h> #include <dm/uclass-internal.h>
DECLARE_GLOBAL_DATA_PTR; @@ -351,8 +350,7 @@ struct usb_device *usb_get_dev_index(struct udevice *bus, int index)
int usb_post_bind(struct udevice *dev) { - /* Scan the bus for devices */ - return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false); + return dm_scan_fdt_dev(dev); }
int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp) diff --git a/include/power/regulator.h b/include/power/regulator.h index 63c0814..9bcd728 100644 --- a/include/power/regulator.h +++ b/include/power/regulator.h @@ -54,7 +54,7 @@ * which does the scan on the device node, for the 'regulator-name' constraint. * If the parent is not a PMIC device, and the child is not bind by function: * 'pmic_bind_childs()', then it's recommended to bind the device by call to - * dm_scan_fdt_node() - this is usually done automatically for bus devices, + * dm_scan_fdt_dev() - this is usually done automatically for bus devices, * as a post bind method. * * Regulator get: diff --git a/test/dm/bus.c b/test/dm/bus.c index 3b5a23b..d94dcf7 100644 --- a/test/dm/bus.c +++ b/test/dm/bus.c @@ -7,7 +7,6 @@ #include <common.h> #include <dm.h> #include <dm/device-internal.h> -#include <dm/root.h> #include <dm/test.h> #include <dm/uclass-internal.h> #include <dm/util.h> @@ -30,7 +29,7 @@ static struct dm_test_state *test_state;
static int testbus_drv_probe(struct udevice *dev) { - return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false); + return dm_scan_fdt_dev(dev); }
static int testbus_child_post_bind(struct udevice *dev)

On 5 July 2016 at 17:10, Simon Glass sjg@chromium.org wrote:
This new function is more convenient for callers, and handles pre-relocation situations automatically.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v2:
- Add new patch to make use of dm_scan_fdt_dev()
arch/x86/lib/lpc-uclass.c | 4 +--- common/usb_hub.c | 3 +-- drivers/core/simple-bus.c | 3 +-- drivers/i2c/i2c-uclass.c | 3 +-- drivers/i2c/sandbox_i2c.c | 4 +--- drivers/misc/cros_ec.c | 3 +-- drivers/pch/pch-uclass.c | 4 +--- drivers/pci/pci-uclass.c | 11 +---------- drivers/pci/pci_sandbox.c | 3 +-- drivers/pinctrl/pinctrl_pic32.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3036.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3288.c | 3 +-- drivers/power/pmic/pm8916.c | 3 +-- drivers/power/regulator/Kconfig | 2 +- drivers/spi/spi-uclass.c | 3 +-- drivers/spmi/spmi-uclass.c | 3 +-- drivers/usb/emul/usb-emul-uclass.c | 3 +-- drivers/usb/host/usb-uclass.c | 4 +--- include/power/regulator.h | 2 +- test/dm/bus.c | 3 +-- 20 files changed, 20 insertions(+), 50 deletions(-)
Applied to u-boot-dm.

Hi Simon,
2016-07-17 22:59 GMT+02:00 Simon Glass sjg@chromium.org:
On 5 July 2016 at 17:10, Simon Glass sjg@chromium.org wrote:
This new function is more convenient for callers, and handles
pre-relocation
situations automatically.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v2:
- Add new patch to make use of dm_scan_fdt_dev()
arch/x86/lib/lpc-uclass.c | 4 +--- common/usb_hub.c | 3 +-- drivers/core/simple-bus.c | 3 +-- drivers/i2c/i2c-uclass.c | 3 +-- drivers/i2c/sandbox_i2c.c | 4 +--- drivers/misc/cros_ec.c | 3 +-- drivers/pch/pch-uclass.c | 4 +--- drivers/pci/pci-uclass.c | 11 +---------- drivers/pci/pci_sandbox.c | 3 +-- drivers/pinctrl/pinctrl_pic32.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3036.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3288.c | 3 +-- drivers/power/pmic/pm8916.c | 3 +-- drivers/power/regulator/Kconfig | 2 +- drivers/spi/spi-uclass.c | 3 +-- drivers/spmi/spmi-uclass.c | 3 +-- drivers/usb/emul/usb-emul-uclass.c | 3 +-- drivers/usb/host/usb-uclass.c | 4 +--- include/power/regulator.h | 2 +- test/dm/bus.c | 3 +-- 20 files changed, 20 insertions(+), 50 deletions(-)
Applied to u-boot-dm.
This is breaking zynqmp support - to be specific serial driver which gets information about clock from DT. On zcu102 with early debug this is an output. failed to get clock failed to get clock failed to get clock No serial driver found resetting ...
I looked at it and the reason for that is that there is different handling for pre_reloc_only. dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, gd->flags & GD_FLG_RELOC ? false : true);
Called from simple-bus.c. The reason for it is that my clk node has no u-boot,dm-pre-reloc; property. I expect that this is the right fix to add u-boot,dm-pre-reloc; property.
I will send a patch to fix this but I wanted to let you know.
Thanks, Michal

Hi Michal,
On 29 July 2016 at 05:29, Michal Simek monstr@monstr.eu wrote:
Hi Simon,
2016-07-17 22:59 GMT+02:00 Simon Glass sjg@chromium.org:
On 5 July 2016 at 17:10, Simon Glass sjg@chromium.org wrote:
This new function is more convenient for callers, and handles pre-relocation situations automatically.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v2:
- Add new patch to make use of dm_scan_fdt_dev()
arch/x86/lib/lpc-uclass.c | 4 +--- common/usb_hub.c | 3 +-- drivers/core/simple-bus.c | 3 +-- drivers/i2c/i2c-uclass.c | 3 +-- drivers/i2c/sandbox_i2c.c | 4 +--- drivers/misc/cros_ec.c | 3 +-- drivers/pch/pch-uclass.c | 4 +--- drivers/pci/pci-uclass.c | 11 +---------- drivers/pci/pci_sandbox.c | 3 +-- drivers/pinctrl/pinctrl_pic32.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3036.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3288.c | 3 +-- drivers/power/pmic/pm8916.c | 3 +-- drivers/power/regulator/Kconfig | 2 +- drivers/spi/spi-uclass.c | 3 +-- drivers/spmi/spmi-uclass.c | 3 +-- drivers/usb/emul/usb-emul-uclass.c | 3 +-- drivers/usb/host/usb-uclass.c | 4 +--- include/power/regulator.h | 2 +- test/dm/bus.c | 3 +-- 20 files changed, 20 insertions(+), 50 deletions(-)
Applied to u-boot-dm.
This is breaking zynqmp support - to be specific serial driver which gets information about clock from DT. On zcu102 with early debug this is an output. failed to get clock failed to get clock failed to get clock No serial driver found resetting ...
I looked at it and the reason for that is that there is different handling for pre_reloc_only. dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, gd->flags & GD_FLG_RELOC ? false : true);
Called from simple-bus.c. The reason for it is that my clk node has no u-boot,dm-pre-reloc; property. I expect that this is the right fix to add u-boot,dm-pre-reloc; property.
I will send a patch to fix this but I wanted to let you know.
Sorry about the breakage, that's one reason I wanted to get it in early. But yes, the fix is to add that property. The old behaviour was wrong and chewed up a lot of pre-reloc memory on one platform.
Regards, Simon

On 1.8.2016 03:03, Simon Glass wrote:
Hi Michal,
On 29 July 2016 at 05:29, Michal Simek monstr@monstr.eu wrote:
Hi Simon,
2016-07-17 22:59 GMT+02:00 Simon Glass sjg@chromium.org:
On 5 July 2016 at 17:10, Simon Glass sjg@chromium.org wrote:
This new function is more convenient for callers, and handles pre-relocation situations automatically.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v2:
- Add new patch to make use of dm_scan_fdt_dev()
arch/x86/lib/lpc-uclass.c | 4 +--- common/usb_hub.c | 3 +-- drivers/core/simple-bus.c | 3 +-- drivers/i2c/i2c-uclass.c | 3 +-- drivers/i2c/sandbox_i2c.c | 4 +--- drivers/misc/cros_ec.c | 3 +-- drivers/pch/pch-uclass.c | 4 +--- drivers/pci/pci-uclass.c | 11 +---------- drivers/pci/pci_sandbox.c | 3 +-- drivers/pinctrl/pinctrl_pic32.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3036.c | 3 +-- drivers/pinctrl/rockchip/pinctrl_rk3288.c | 3 +-- drivers/power/pmic/pm8916.c | 3 +-- drivers/power/regulator/Kconfig | 2 +- drivers/spi/spi-uclass.c | 3 +-- drivers/spmi/spmi-uclass.c | 3 +-- drivers/usb/emul/usb-emul-uclass.c | 3 +-- drivers/usb/host/usb-uclass.c | 4 +--- include/power/regulator.h | 2 +- test/dm/bus.c | 3 +-- 20 files changed, 20 insertions(+), 50 deletions(-)
Applied to u-boot-dm.
This is breaking zynqmp support - to be specific serial driver which gets information about clock from DT. On zcu102 with early debug this is an output. failed to get clock failed to get clock failed to get clock No serial driver found resetting ...
I looked at it and the reason for that is that there is different handling for pre_reloc_only. dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, gd->flags & GD_FLG_RELOC ? false : true);
Called from simple-bus.c. The reason for it is that my clk node has no u-boot,dm-pre-reloc; property. I expect that this is the right fix to add u-boot,dm-pre-reloc; property.
I will send a patch to fix this but I wanted to let you know.
Sorry about the breakage, that's one reason I wanted to get it in early. But yes, the fix is to add that property. The old behaviour was wrong and chewed up a lot of pre-reloc memory on one platform.
NP. Good that we catch it early.
Thanks, Michal

Quite a few places have a bind() method which just calls dm_scan_fdt_dev(). We may as well call dm_scan_fdt_dev() directly. Update the code to do this.
Signed-off-by: Simon Glass sjg@chromium.org ---
Changes in v2: - Add new patch to use dm_scan_fdt_dev() directly where possible
arch/x86/lib/lpc-uclass.c | 13 +------------ common/usb_hub.c | 8 +------- drivers/i2c/i2c-uclass.c | 7 +------ drivers/misc/cros_ec.c | 8 +------- drivers/pch/pch-uclass.c | 13 +------------ drivers/pci/pci-uclass.c | 15 +-------------- drivers/pci/pci_sandbox.c | 10 +++------- drivers/pinctrl/pinctrl_pic32.c | 8 +------- drivers/pinctrl/rockchip/pinctrl_rk3036.c | 8 +------- drivers/pinctrl/rockchip/pinctrl_rk3288.c | 8 +------- drivers/power/pmic/pm8916.c | 8 +------- drivers/spi/spi-uclass.c | 8 +------- drivers/spmi/spmi-uclass.c | 7 +------ drivers/usb/emul/usb-emul-uclass.c | 8 +------- drivers/usb/host/usb-uclass.c | 7 +------ test/dm/i2c.c | 4 ++-- test/dm/spi.c | 4 ++-- 17 files changed, 21 insertions(+), 123 deletions(-)
diff --git a/arch/x86/lib/lpc-uclass.c b/arch/x86/lib/lpc-uclass.c index b8254ff..eb033e6 100644 --- a/arch/x86/lib/lpc-uclass.c +++ b/arch/x86/lib/lpc-uclass.c @@ -10,19 +10,8 @@
DECLARE_GLOBAL_DATA_PTR;
-static int lpc_uclass_post_bind(struct udevice *bus) -{ - /* - * Scan the device tree for devices - * - * Before relocation, only bind devices marked for pre-relocation - * use. - */ - return dm_scan_fdt_dev(bus); -} - UCLASS_DRIVER(lpc) = { .id = UCLASS_LPC, .name = "lpc", - .post_bind = lpc_uclass_post_bind, + .post_bind = dm_scan_fdt_dev, }; diff --git a/common/usb_hub.c b/common/usb_hub.c index 26ee13e..ff9cd50 100644 --- a/common/usb_hub.c +++ b/common/usb_hub.c @@ -754,12 +754,6 @@ int usb_hub_scan(struct udevice *hub) return usb_hub_configure(udev); }
-static int usb_hub_post_bind(struct udevice *dev) -{ - /* Scan the bus for devices */ - return dm_scan_fdt_dev(dev); -} - static int usb_hub_post_probe(struct udevice *dev) { debug("%s\n", __func__); @@ -781,7 +775,7 @@ U_BOOT_DRIVER(usb_generic_hub) = { UCLASS_DRIVER(usb_hub) = { .id = UCLASS_USB_HUB, .name = "usb_hub", - .post_bind = usb_hub_post_bind, + .post_bind = dm_scan_fdt_dev, .post_probe = usb_hub_post_probe, .child_pre_probe = usb_child_pre_probe, .per_child_auto_alloc_size = sizeof(struct usb_device), diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c index 9dbbe1f..26d8524 100644 --- a/drivers/i2c/i2c-uclass.c +++ b/drivers/i2c/i2c-uclass.c @@ -492,11 +492,6 @@ static int i2c_post_probe(struct udevice *dev) return dm_i2c_set_bus_speed(dev, i2c->speed_hz); }
-static int i2c_post_bind(struct udevice *dev) -{ - /* Scan the bus for devices */ - return dm_scan_fdt_dev(dev); -}
static int i2c_child_post_bind(struct udevice *dev) { @@ -512,7 +507,7 @@ UCLASS_DRIVER(i2c) = { .id = UCLASS_I2C, .name = "i2c", .flags = DM_UC_FLAG_SEQ_ALIAS, - .post_bind = i2c_post_bind, + .post_bind = dm_scan_fdt_dev, .post_probe = i2c_post_probe, .per_device_auto_alloc_size = sizeof(struct dm_i2c_bus), .per_child_platdata_auto_alloc_size = sizeof(struct dm_i2c_chip), diff --git a/drivers/misc/cros_ec.c b/drivers/misc/cros_ec.c index f50e73f..aea8d61 100644 --- a/drivers/misc/cros_ec.c +++ b/drivers/misc/cros_ec.c @@ -1449,12 +1449,6 @@ static int do_cros_ec(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) return ret; }
-int cros_ec_post_bind(struct udevice *dev) -{ - /* Scan for available EC devices (e.g. I2C tunnel) */ - return dm_scan_fdt_dev(dev); -} - U_BOOT_CMD( crosec, 6, 1, do_cros_ec, "CROS-EC utility command", @@ -1481,5 +1475,5 @@ UCLASS_DRIVER(cros_ec) = { .id = UCLASS_CROS_EC, .name = "cros_ec", .per_device_auto_alloc_size = sizeof(struct cros_ec_dev), - .post_bind = cros_ec_post_bind, + .post_bind = dm_scan_fdt_dev, }; diff --git a/drivers/pch/pch-uclass.c b/drivers/pch/pch-uclass.c index 5b2fa1f..af794eb 100644 --- a/drivers/pch/pch-uclass.c +++ b/drivers/pch/pch-uclass.c @@ -54,19 +54,8 @@ int pch_get_io_base(struct udevice *dev, u32 *iobasep) return ops->get_io_base(dev, iobasep); }
-static int pch_uclass_post_bind(struct udevice *bus) -{ - /* - * Scan the device tree for devices - * - * Before relocation, only bind devices marked for pre-relocation - * use. - */ - return dm_scan_fdt_dev(bus); -} - UCLASS_DRIVER(pch) = { .id = UCLASS_PCH, .name = "pch", - .post_bind = pch_uclass_post_bind, + .post_bind = dm_scan_fdt_dev, }; diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c index 230d181..342b78c 100644 --- a/drivers/pci/pci-uclass.c +++ b/drivers/pci/pci-uclass.c @@ -752,19 +752,6 @@ error: return ret; }
-static int pci_uclass_post_bind(struct udevice *bus) -{ - /* - * Scan the device tree for devices. This does not probe the PCI bus, - * as this is not permitted while binding. It just finds devices - * mentioned in the device tree. - * - * Before relocation, only bind devices marked for pre-relocation - * use. - */ - return dm_scan_fdt_dev(bus); -} - static int decode_regions(struct pci_controller *hose, const void *blob, int parent_node, int node) { @@ -1245,7 +1232,7 @@ UCLASS_DRIVER(pci) = { .id = UCLASS_PCI, .name = "pci", .flags = DM_UC_FLAG_SEQ_ALIAS, - .post_bind = pci_uclass_post_bind, + .post_bind = dm_scan_fdt_dev, .pre_probe = pci_uclass_pre_probe, .post_probe = pci_uclass_post_probe, .child_post_bind = pci_uclass_child_post_bind, diff --git a/drivers/pci/pci_sandbox.c b/drivers/pci/pci_sandbox.c index b562813..6a84ee3 100644 --- a/drivers/pci/pci_sandbox.c +++ b/drivers/pci/pci_sandbox.c @@ -51,12 +51,6 @@ static int sandbox_pci_read_config(struct udevice *bus, pci_dev_t devfn, return ops->read_config(emul, offset, valuep, size); }
-static int sandbox_pci_child_post_bind(struct udevice *dev) -{ - /* Attach an emulator if we can */ - return dm_scan_fdt_dev(dev); -} - static const struct dm_pci_ops sandbox_pci_ops = { .read_config = sandbox_pci_read_config, .write_config = sandbox_pci_write_config, @@ -72,7 +66,9 @@ U_BOOT_DRIVER(pci_sandbox) = { .id = UCLASS_PCI, .of_match = sandbox_pci_ids, .ops = &sandbox_pci_ops, - .child_post_bind = sandbox_pci_child_post_bind, + + /* Attach an emulator if we can */ + .child_post_bind = dm_scan_fdt_dev, .per_child_platdata_auto_alloc_size = sizeof(struct pci_child_platdata), }; diff --git a/drivers/pinctrl/pinctrl_pic32.c b/drivers/pinctrl/pinctrl_pic32.c index 5636f8f..9acac29 100644 --- a/drivers/pinctrl/pinctrl_pic32.c +++ b/drivers/pinctrl/pinctrl_pic32.c @@ -340,12 +340,6 @@ static int pic32_pinctrl_probe(struct udevice *dev) return 0; }
-static int pic32_pinctrl_bind(struct udevice *dev) -{ - /* scan child GPIO banks */ - return dm_scan_fdt_dev(dev); -} - static const struct udevice_id pic32_pinctrl_ids[] = { { .compatible = "microchip,pic32mzda-pinctrl" }, { } @@ -357,6 +351,6 @@ U_BOOT_DRIVER(pinctrl_pic32) = { .of_match = pic32_pinctrl_ids, .ops = &pic32_pinctrl_ops, .probe = pic32_pinctrl_probe, - .bind = pic32_pinctrl_bind, + .bind = dm_scan_fdt_dev, .priv_auto_alloc_size = sizeof(struct pic32_pinctrl_priv), }; diff --git a/drivers/pinctrl/rockchip/pinctrl_rk3036.c b/drivers/pinctrl/rockchip/pinctrl_rk3036.c index 3648678..6aea856 100644 --- a/drivers/pinctrl/rockchip/pinctrl_rk3036.c +++ b/drivers/pinctrl/rockchip/pinctrl_rk3036.c @@ -252,12 +252,6 @@ static struct pinctrl_ops rk3036_pinctrl_ops = { .get_periph_id = rk3036_pinctrl_get_periph_id, };
-static int rk3036_pinctrl_bind(struct udevice *dev) -{ - /* scan child GPIO banks */ - return dm_scan_fdt_dev(dev); -} - static int rk3036_pinctrl_probe(struct udevice *dev) { struct rk3036_pinctrl_priv *priv = dev_get_priv(dev); @@ -278,6 +272,6 @@ U_BOOT_DRIVER(pinctrl_rk3036) = { .of_match = rk3036_pinctrl_ids, .priv_auto_alloc_size = sizeof(struct rk3036_pinctrl_priv), .ops = &rk3036_pinctrl_ops, - .bind = rk3036_pinctrl_bind, + .bind = dm_scan_fdt_dev, .probe = rk3036_pinctrl_probe, }; diff --git a/drivers/pinctrl/rockchip/pinctrl_rk3288.c b/drivers/pinctrl/rockchip/pinctrl_rk3288.c index 0cfa950..4e29c21 100644 --- a/drivers/pinctrl/rockchip/pinctrl_rk3288.c +++ b/drivers/pinctrl/rockchip/pinctrl_rk3288.c @@ -661,12 +661,6 @@ static struct pinctrl_ops rk3288_pinctrl_ops = { .get_periph_id = rk3288_pinctrl_get_periph_id, };
-static int rk3288_pinctrl_bind(struct udevice *dev) -{ - /* scan child GPIO banks */ - return dm_scan_fdt_dev(dev); -} - #ifndef CONFIG_SPL_BUILD static int rk3288_pinctrl_parse_tables(struct rk3288_pinctrl_priv *priv, struct rockchip_pin_bank *banks, @@ -723,6 +717,6 @@ U_BOOT_DRIVER(pinctrl_rk3288) = { .of_match = rk3288_pinctrl_ids, .priv_auto_alloc_size = sizeof(struct rk3288_pinctrl_priv), .ops = &rk3288_pinctrl_ops, - .bind = rk3288_pinctrl_bind, + .bind = dm_scan_fdt_dev, .probe = rk3288_pinctrl_probe, }; diff --git a/drivers/power/pmic/pm8916.c b/drivers/power/pmic/pm8916.c index 6f5608e..2b65c69 100644 --- a/drivers/power/pmic/pm8916.c +++ b/drivers/power/pmic/pm8916.c @@ -78,17 +78,11 @@ static int pm8916_probe(struct udevice *dev) return 0; }
- -static int pm8916_bind(struct udevice *dev) -{ - return dm_scan_fdt_dev(dev); -} - U_BOOT_DRIVER(pmic_pm8916) = { .name = "pmic_pm8916", .id = UCLASS_PMIC, .of_match = pm8916_ids, - .bind = pm8916_bind, + .bind = dm_scan_fdt_dev, .probe = pm8916_probe, .ops = &pm8916_ops, .priv_auto_alloc_size = sizeof(struct pm8916_priv), diff --git a/drivers/spi/spi-uclass.c b/drivers/spi/spi-uclass.c index b17ed75..7b94fdd 100644 --- a/drivers/spi/spi-uclass.c +++ b/drivers/spi/spi-uclass.c @@ -108,12 +108,6 @@ int spi_xfer(struct spi_slave *slave, unsigned int bitlen, return dm_spi_xfer(slave->dev, bitlen, dout, din, flags); }
-static int spi_post_bind(struct udevice *dev) -{ - /* Scan the bus for devices */ - return dm_scan_fdt_dev(dev); -} - static int spi_child_post_bind(struct udevice *dev) { struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev); @@ -441,7 +435,7 @@ UCLASS_DRIVER(spi) = { .id = UCLASS_SPI, .name = "spi", .flags = DM_UC_FLAG_SEQ_ALIAS, - .post_bind = spi_post_bind, + .post_bind = dm_scan_fdt_dev, .post_probe = spi_post_probe, .child_pre_probe = spi_child_pre_probe, .per_device_auto_alloc_size = sizeof(struct dm_spi_bus), diff --git a/drivers/spmi/spmi-uclass.c b/drivers/spmi/spmi-uclass.c index 9fa330b..6edece2 100644 --- a/drivers/spmi/spmi-uclass.c +++ b/drivers/spmi/spmi-uclass.c @@ -35,13 +35,8 @@ int spmi_reg_write(struct udevice *dev, int usid, int pid, int reg, return ops->write(dev, usid, pid, reg, value); }
-static int spmi_post_bind(struct udevice *dev) -{ - return dm_scan_fdt_dev(dev); -} - UCLASS_DRIVER(spmi) = { .id = UCLASS_SPMI, .name = "spmi", - .post_bind = spmi_post_bind, + .post_bind = dm_scan_fdt_dev, }; diff --git a/drivers/usb/emul/usb-emul-uclass.c b/drivers/usb/emul/usb-emul-uclass.c index da91d04..6e03c1e 100644 --- a/drivers/usb/emul/usb-emul-uclass.c +++ b/drivers/usb/emul/usb-emul-uclass.c @@ -264,12 +264,6 @@ int usb_emul_setup_device(struct udevice *dev, int maxpacketsize, return 0; }
-int usb_emul_post_bind(struct udevice *dev) -{ - /* Scan the bus for devices */ - return dm_scan_fdt_dev(dev); -} - void usb_emul_reset(struct udevice *dev) { struct usb_dev_platdata *plat = dev_get_parent_platdata(dev); @@ -281,7 +275,7 @@ void usb_emul_reset(struct udevice *dev) UCLASS_DRIVER(usb_emul) = { .id = UCLASS_USB_EMUL, .name = "usb_emul", - .post_bind = usb_emul_post_bind, + .post_bind = dm_scan_fdt_dev, .per_child_auto_alloc_size = sizeof(struct usb_device), .per_child_platdata_auto_alloc_size = sizeof(struct usb_dev_platdata), }; diff --git a/drivers/usb/host/usb-uclass.c b/drivers/usb/host/usb-uclass.c index 070e271..be114fc 100644 --- a/drivers/usb/host/usb-uclass.c +++ b/drivers/usb/host/usb-uclass.c @@ -348,11 +348,6 @@ struct usb_device *usb_get_dev_index(struct udevice *bus, int index) } #endif
-int usb_post_bind(struct udevice *dev) -{ - return dm_scan_fdt_dev(dev); -} - int usb_setup_ehci_gadget(struct ehci_ctrl **ctlrp) { struct usb_platdata *plat; @@ -766,7 +761,7 @@ UCLASS_DRIVER(usb) = { .id = UCLASS_USB, .name = "usb", .flags = DM_UC_FLAG_SEQ_ALIAS, - .post_bind = usb_post_bind, + .post_bind = dm_scan_fdt_dev, .priv_auto_alloc_size = sizeof(struct usb_uclass_priv), .per_child_auto_alloc_size = sizeof(struct usb_device), .per_device_auto_alloc_size = sizeof(struct usb_bus_priv), diff --git a/test/dm/i2c.c b/test/dm/i2c.c index 23d612e..e2688bf 100644 --- a/test/dm/i2c.c +++ b/test/dm/i2c.c @@ -31,8 +31,8 @@ static int dm_test_i2c_find(struct unit_test_state *uts) false, &bus));
/* - * i2c_post_bind() will bind devices to chip selects. Check this then - * remove the emulation and the slave device. + * The post_bind() method will bind devices to chip selects. Check + * this then remove the emulation and the slave device. */ ut_assertok(uclass_get_device_by_seq(UCLASS_I2C, busnum, &bus)); ut_assertok(dm_i2c_probe(bus, chip, 0, &dev)); diff --git a/test/dm/spi.c b/test/dm/spi.c index 2e27da7..5733096 100644 --- a/test/dm/spi.c +++ b/test/dm/spi.c @@ -30,8 +30,8 @@ static int dm_test_spi_find(struct unit_test_state *uts) false, &bus));
/* - * spi_post_bind() will bind devices to chip selects. Check this then - * remove the emulation and the slave device. + * The post_bind() method will bind devices to chip selects. Check + * this then remove the emulation and the slave device. */ ut_asserteq(0, uclass_get_device_by_seq(UCLASS_SPI, busnum, &bus)); ut_assertok(spi_cs_info(bus, cs, &info));

On 5 July 2016 at 17:10, Simon Glass sjg@chromium.org wrote:
Quite a few places have a bind() method which just calls dm_scan_fdt_dev(). We may as well call dm_scan_fdt_dev() directly. Update the code to do this.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v2:
- Add new patch to use dm_scan_fdt_dev() directly where possible
arch/x86/lib/lpc-uclass.c | 13 +------------ common/usb_hub.c | 8 +------- drivers/i2c/i2c-uclass.c | 7 +------ drivers/misc/cros_ec.c | 8 +------- drivers/pch/pch-uclass.c | 13 +------------ drivers/pci/pci-uclass.c | 15 +-------------- drivers/pci/pci_sandbox.c | 10 +++------- drivers/pinctrl/pinctrl_pic32.c | 8 +------- drivers/pinctrl/rockchip/pinctrl_rk3036.c | 8 +------- drivers/pinctrl/rockchip/pinctrl_rk3288.c | 8 +------- drivers/power/pmic/pm8916.c | 8 +------- drivers/spi/spi-uclass.c | 8 +------- drivers/spmi/spmi-uclass.c | 7 +------ drivers/usb/emul/usb-emul-uclass.c | 8 +------- drivers/usb/host/usb-uclass.c | 7 +------ test/dm/i2c.c | 4 ++-- test/dm/spi.c | 4 ++-- 17 files changed, 21 insertions(+), 123 deletions(-)
Applied to u-boot-dm.

This is useful information to show how close we are to the limit. At present it is only available by enabling DEBUG in board_r.c.
Make it available with the 'bdinfo' command also.
Note that this affects ARM only. The bdinfo command is different for each architecture. Rather than duplicating the code it would be better to refactor it (as was done with global_data).
Signed-off-by: Simon Glass sjg@chromium.org ---
Changes in v2: - Add new patch to show early-malloc() usage in bdinfo
cmd/bdinfo.c | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c index 1c4bed9..2b106c7 100644 --- a/cmd/bdinfo.c +++ b/cmd/bdinfo.c @@ -416,6 +416,11 @@ static int do_bdinfo(cmd_tbl_t *cmdtp, int flag, int argc, #ifdef CONFIG_BOARD_TYPES printf("Board Type = %ld\n", gd->board_type); #endif +#ifdef CONFIG_SYS_MALLOC_F + printf("Early malloc usage: %lx / %x\n", gd->malloc_ptr, + CONFIG_SYS_MALLOC_F_LEN); +#endif + return 0; }

On 5 July 2016 at 17:10, Simon Glass sjg@chromium.org wrote:
This is useful information to show how close we are to the limit. At present it is only available by enabling DEBUG in board_r.c.
Make it available with the 'bdinfo' command also.
Note that this affects ARM only. The bdinfo command is different for each architecture. Rather than duplicating the code it would be better to refactor it (as was done with global_data).
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v2:
- Add new patch to show early-malloc() usage in bdinfo
cmd/bdinfo.c | 5 +++++ 1 file changed, 5 insertions(+)
Applied to u-boot-dm.

This corrects a build error on zynqmp.
Signed-off-by: Simon Glass sjg@chromium.org ---
Changes in v2: - Fix sign-off tag
drivers/net/phy/marvell.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index 58d287b..4eeb0f6 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -8,6 +8,7 @@ */ #include <config.h> #include <common.h> +#include <errno.h> #include <phy.h>
#define PHY_AUTONEGOTIATE_TIMEOUT 5000

On 5 July 2016 at 17:10, Simon Glass sjg@chromium.org wrote:
This corrects a build error on zynqmp.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v2:
- Fix sign-off tag
drivers/net/phy/marvell.c | 1 + 1 file changed, 1 insertion(+)
Applied to u-boot-dm.

This is needed to support driver-model conversion of USB and block devices.
Signed-off-by: Simon Glass sjg@chromium.org ---
Changes in v2: None
arch/arm/cpu/armv8/zynqmp/Kconfig | 4 ++++ arch/arm/mach-zynq/Kconfig | 3 +++ 2 files changed, 7 insertions(+)
diff --git a/arch/arm/cpu/armv8/zynqmp/Kconfig b/arch/arm/cpu/armv8/zynqmp/Kconfig index 6c71d78..ed3305d 100644 --- a/arch/arm/cpu/armv8/zynqmp/Kconfig +++ b/arch/arm/cpu/armv8/zynqmp/Kconfig @@ -20,4 +20,8 @@ config SYS_CONFIG_NAME config ZYNQMP_USB bool "Configure ZynqMP USB"
+config SYS_MALLOC_F_LEN + default 0x600 + + endif diff --git a/arch/arm/mach-zynq/Kconfig b/arch/arm/mach-zynq/Kconfig index db3c579..a982320 100644 --- a/arch/arm/mach-zynq/Kconfig +++ b/arch/arm/mach-zynq/Kconfig @@ -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

On 5 July 2016 at 17:10, Simon Glass sjg@chromium.org wrote:
This is needed to support driver-model conversion of USB and block devices.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v2: None
arch/arm/cpu/armv8/zynqmp/Kconfig | 4 ++++ arch/arm/mach-zynq/Kconfig | 3 +++ 2 files changed, 7 insertions(+)
Applied to u-boot-dm.

Convert zynq USB to driver model. Note this is tested on zynq-zybo only.
Signed-off-by: Simon Glass sjg@chromium.org ---
Changes in v2: - Add missing struct ehci_ctrl to struct zynq_ehci_priv
arch/arm/Kconfig | 2 + drivers/usb/host/ehci-zynq.c | 103 +++++++++++++++++++++---------------------- 2 files changed, 53 insertions(+), 52 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 585b408..9d6cdc7 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -661,6 +661,7 @@ config ARCH_ZYNQ select DM_SERIAL select DM_SPI_FLASH select SPL_SEPARATE_BSS if SPL + select DM_USB if USB
config ARCH_ZYNQMP bool "Support Xilinx ZynqMP Platform" @@ -669,6 +670,7 @@ config ARCH_ZYNQMP select OF_CONTROL select DM_SERIAL select SUPPORT_SPL + select DM_USB if USB
config TEGRA bool "NVIDIA Tegra" diff --git a/drivers/usb/host/ehci-zynq.c b/drivers/usb/host/ehci-zynq.c index 37a7935..76642cd 100644 --- a/drivers/usb/host/ehci-zynq.c +++ b/drivers/usb/host/ehci-zynq.c @@ -7,55 +7,48 @@ */
#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"
-#define ZYNQ_USB_USBCMD_RST 0x0000002 -#define ZYNQ_USB_USBCMD_STOP 0x0000000 -#define ZYNQ_USB_NUM_MIO 12 +struct zynq_ehci_priv { + struct ehci_ctrl ehcictrl; + 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 +70,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, +};

On 5 July 2016 at 17:10, Simon Glass sjg@chromium.org wrote:
Convert zynq USB to driver model. Note this is tested on zynq-zybo only.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v2:
- Add missing struct ehci_ctrl to struct zynq_ehci_priv
arch/arm/Kconfig | 2 + drivers/usb/host/ehci-zynq.c | 103 +++++++++++++++++++++---------------------- 2 files changed, 53 insertions(+), 52 deletions(-)
Applied to u-boot-dm.

Move zynq to the latest driver model support by enabling CONFIG_DM_MMC, CONFIG_DM_MMC_OPS and CONFIG_BLK.
Signed-off-by: Simon Glass sjg@chromium.org ---
Changes in v2: None
arch/arm/Kconfig | 5 +++++ drivers/mmc/zynq_sdhci.c | 39 ++++++++++++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 9d6cdc7..f45fd37 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -657,11 +657,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 if USB + select BLK
config ARCH_ZYNQMP bool "Support Xilinx ZynqMP Platform" @@ -671,6 +673,9 @@ config ARCH_ZYNQMP select DM_SERIAL select SUPPORT_SPL select DM_USB if USB + select DM_MMC + select DM_MMC_OPS + select BLK
config TEGRA bool "NVIDIA Tegra" diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c index d405929..bcd154a 100644 --- a/drivers/mmc/zynq_sdhci.c +++ b/drivers/mmc/zynq_sdhci.c @@ -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), };

Hi Simon,
On 07/06/2016 08:10 AM, Simon Glass wrote:
Move zynq to the latest driver model support by enabling CONFIG_DM_MMC, CONFIG_DM_MMC_OPS and CONFIG_BLK.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v2: None
arch/arm/Kconfig | 5 +++++ drivers/mmc/zynq_sdhci.c | 39 ++++++++++++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 9d6cdc7..f45fd37 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -657,11 +657,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 if USB
- select BLK
If my understanding is right, your patch[12~13/13] are enabled with CONFIG_DM_MMC. Does it need to select at here?
config ARCH_ZYNQMP bool "Support Xilinx ZynqMP Platform" @@ -671,6 +673,9 @@ config ARCH_ZYNQMP select DM_SERIAL select SUPPORT_SPL select DM_USB if USB
- select DM_MMC
- select DM_MMC_OPS
- select BLK
Ditto.
config TEGRA bool "NVIDIA Tegra" diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c index d405929..bcd154a 100644 --- a/drivers/mmc/zynq_sdhci.c +++ b/drivers/mmc/zynq_sdhci.c @@ -17,10 +17,18 @@ # define CONFIG_ZYNQ_SDHCI_MIN_FREQ 0 #endif
+struct arasan_sdhci_plat {
- struct mmc_config cfg;
- struct mmc mmc;
+};
Almost all drivers are using the similar *_plat structure. Then it can be used the one structure instead of *_plat.. So i think it should be located "struct mmc_plat" into mmc.h
struct mmc_plat { struct mmc_config cfg; struct mmc mmc; };
Then we can remove the all other similar plat structures. if you are ok, I will clean everything. how about?
Best Regards, Jaehoon Chung
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),
};

Hi Jaehoon,
On 6 July 2016 at 00:53, Jaehoon Chung jh80.chung@samsung.com wrote:
Hi Simon,
On 07/06/2016 08:10 AM, Simon Glass wrote:
Move zynq to the latest driver model support by enabling CONFIG_DM_MMC, CONFIG_DM_MMC_OPS and CONFIG_BLK.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v2: None
arch/arm/Kconfig | 5 +++++ drivers/mmc/zynq_sdhci.c | 39 ++++++++++++++++++++++++++++++++++----- 2 files changed, 39 insertions(+), 5 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 9d6cdc7..f45fd37 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -657,11 +657,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 if USB
select BLK
If my understanding is right, your patch[12~13/13] are enabled with CONFIG_DM_MMC. Does it need to select at here?
config ARCH_ZYNQMP bool "Support Xilinx ZynqMP Platform" @@ -671,6 +673,9 @@ config ARCH_ZYNQMP select DM_SERIAL select SUPPORT_SPL select DM_USB if USB
select DM_MMC
select DM_MMC_OPS
select BLK
Ditto.
?
config TEGRA bool "NVIDIA Tegra" diff --git a/drivers/mmc/zynq_sdhci.c b/drivers/mmc/zynq_sdhci.c index d405929..bcd154a 100644 --- a/drivers/mmc/zynq_sdhci.c +++ b/drivers/mmc/zynq_sdhci.c @@ -17,10 +17,18 @@ # define CONFIG_ZYNQ_SDHCI_MIN_FREQ 0 #endif
+struct arasan_sdhci_plat {
struct mmc_config cfg;
struct mmc mmc;
+};
Almost all drivers are using the similar *_plat structure. Then it can be used the one structure instead of *_plat.. So i think it should be located "struct mmc_plat" into mmc.h
struct mmc_plat { struct mmc_config cfg; struct mmc mmc; };
Seems reasonable, but of course some might want to override it. Still, the more common code the better.
Then we can remove the all other similar plat structures. if you are ok, I will clean everything. how about?
Yes, please.
Regards, Simon

Update the driver to support using driver model for block devices.
Signed-off-by: Simon Glass sjg@chromium.org ---
Changes in v2: - Add new patch to support CONFIG_BLK with socfpga
drivers/mmc/socfpga_dw_mmc.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-)
diff --git a/drivers/mmc/socfpga_dw_mmc.c b/drivers/mmc/socfpga_dw_mmc.c index 6a0e971..8a96302 100644 --- a/drivers/mmc/socfpga_dw_mmc.c +++ b/drivers/mmc/socfpga_dw_mmc.c @@ -22,6 +22,11 @@ static const struct socfpga_clock_manager *clock_manager_base = static const struct socfpga_system_manager *system_manager_base = (void *)SOCFPGA_SYSMGR_ADDRESS;
+struct socfpga_dwmci_plat { + struct mmc_config cfg; + struct mmc mmc; +}; + /* socfpga implmentation specific driver private data */ struct dwmci_socfpga_priv_data { struct dwmci_host host; @@ -98,21 +103,45 @@ static int socfpga_dwmmc_ofdata_to_platdata(struct udevice *dev)
static int socfpga_dwmmc_probe(struct udevice *dev) { +#ifdef CONFIG_BLK + struct socfpga_dwmci_plat *plat = dev_get_platdata(dev); +#endif struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); struct dwmci_socfpga_priv_data *priv = dev_get_priv(dev); struct dwmci_host *host = &priv->host; + +#ifdef CONFIG_BLK + dwmci_setup_cfg(&plat->cfg, dev->name, host->buswidth, host->caps, + host->bus_hz, 400000); + host->mmc = &plat->mmc; +#else int ret;
ret = add_dwmci(host, host->bus_hz, 400000); if (ret) return ret; - +#endif + host->mmc->priv = &priv->host; upriv->mmc = host->mmc; host->mmc->dev = dev;
return 0; }
+static int socfpga_dwmmc_bind(struct udevice *dev) +{ +#ifdef CONFIG_BLK + struct socfpga_dwmci_plat *plat = dev_get_platdata(dev); + int ret; + + ret = dwmci_bind(dev, &plat->mmc, &plat->cfg); + if (ret) + return ret; +#endif + + return 0; +} + static const struct udevice_id socfpga_dwmmc_ids[] = { { .compatible = "altr,socfpga-dw-mshc" }, { } @@ -123,6 +152,7 @@ U_BOOT_DRIVER(socfpga_dwmmc_drv) = { .id = UCLASS_MMC, .of_match = socfpga_dwmmc_ids, .ofdata_to_platdata = socfpga_dwmmc_ofdata_to_platdata, + .bind = socfpga_dwmmc_bind, .probe = socfpga_dwmmc_probe, .priv_auto_alloc_size = sizeof(struct dwmci_socfpga_priv_data), };

On 5 July 2016 at 17:10, Simon Glass sjg@chromium.org wrote:
Update the driver to support using driver model for block devices.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v2:
- Add new patch to support CONFIG_BLK with socfpga
drivers/mmc/socfpga_dw_mmc.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-)
Applied to u-boot-dm.

Update the USB mass storage code to allow it to work with driver model.
Signed-off-by: Simon Glass sjg@chromium.org ---
Changes in v2: - Add new patch to use blk_dread/write() instead of direct calls
cmd/usb_mass_storage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/cmd/usb_mass_storage.c b/cmd/usb_mass_storage.c index b05913a..86398fc 100644 --- a/cmd/usb_mass_storage.c +++ b/cmd/usb_mass_storage.c @@ -22,7 +22,7 @@ static int ums_read_sector(struct ums *ums_dev, struct blk_desc *block_dev = &ums_dev->block_dev; lbaint_t blkstart = start + ums_dev->start_sector;
- return block_dev->block_read(block_dev, blkstart, blkcnt, buf); + return blk_dread(block_dev, blkstart, blkcnt, buf); }
static int ums_write_sector(struct ums *ums_dev, @@ -31,7 +31,7 @@ static int ums_write_sector(struct ums *ums_dev, struct blk_desc *block_dev = &ums_dev->block_dev; lbaint_t blkstart = start + ums_dev->start_sector;
- return block_dev->block_write(block_dev, blkstart, blkcnt, buf); + return blk_dwrite(block_dev, blkstart, blkcnt, buf); }
static struct ums *ums;

On 5 July 2016 at 17:10, Simon Glass sjg@chromium.org wrote:
Update the USB mass storage code to allow it to work with driver model.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v2:
- Add new patch to use blk_dread/write() instead of direct calls
cmd/usb_mass_storage.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
Applied to u-boot-dm.

Fix up the call in mmc_load_image_raw_partition() to use the correct function to obtain the MMC device, so that this code can support driver model.
Signed-off-by: Simon Glass sjg@chromium.org ---
Changes in v2: - Add new patch to support raw partitions with CONFIG_BLK
common/spl/spl_mmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index 6b3e9e4..7c7f329 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -155,7 +155,7 @@ static int mmc_load_image_raw_partition(struct mmc *mmc, int partition) disk_partition_t info; int err;
- err = part_get_info(&mmc->block_dev, partition, &info); + err = part_get_info(mmc_get_blk_desc(mmc), partition, &info); if (err) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT puts("spl: partition error\n");

On 5 July 2016 at 17:10, Simon Glass sjg@chromium.org wrote:
Fix up the call in mmc_load_image_raw_partition() to use the correct function to obtain the MMC device, so that this code can support driver model.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v2:
- Add new patch to support raw partitions with CONFIG_BLK
common/spl/spl_mmc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Applied to u-boot-dm.

These 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.
Signed-off-by: Simon Glass sjg@chromium.org ---
Changes in v2: None
drivers/mmc/Kconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig index 79cf18f..b11725e 100644 --- a/drivers/mmc/Kconfig +++ b/drivers/mmc/Kconfig @@ -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

On 5 July 2016 at 17:10, Simon Glass sjg@chromium.org wrote:
These 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.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v2: None
drivers/mmc/Kconfig | 1 + 1 file changed, 1 insertion(+)
Applied to u-boot-dm.

Hi,
On 17 July 2016 at 15:00, Simon Glass sjg@chromium.org wrote:
On 5 July 2016 at 17:10, Simon Glass sjg@chromium.org wrote:
These 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.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v2: None
drivers/mmc/Kconfig | 1 + 1 file changed, 1 insertion(+)
Applied to u-boot-dm.
I had to drop that due to a build error. Re-applied.
- Simon

To speed up conversion to CONFIG_BLK, enable it by default when DM_MMC is enabled.
Signed-off-by: Simon Glass sjg@chromium.org ---
Changes in v2: - Add new dm_scan_fdt_dev() function and convert the code - Drop patches previously applied to u-boot-dm/next
drivers/block/Kconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index 80eea84..fe5aa07 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig @@ -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

On 5 July 2016 at 17:10, Simon Glass sjg@chromium.org wrote:
To speed up conversion to CONFIG_BLK, enable it by default when DM_MMC is enabled.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v2:
- Add new dm_scan_fdt_dev() function and convert the code
- Drop patches previously applied to u-boot-dm/next
drivers/block/Kconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index 80eea84..fe5aa07 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig @@ -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
-- 2.8.0.rc3.226.g39d4020
Applied to u-boot-dm.
I'm concerned that this patch might break some boards, but have had not comments. I'm pretty sure we should get a build error if it is wrong, and I have build-tested it. Hopefully it will get more testing once applied.
Regards, Simon

On 17 July 2016 at 15:00, Simon Glass sjg@chromium.org wrote:
On 5 July 2016 at 17:10, Simon Glass sjg@chromium.org wrote:
To speed up conversion to CONFIG_BLK, enable it by default when DM_MMC is enabled.
Signed-off-by: Simon Glass sjg@chromium.org
Changes in v2:
- Add new dm_scan_fdt_dev() function and convert the code
- Drop patches previously applied to u-boot-dm/next
drivers/block/Kconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/drivers/block/Kconfig b/drivers/block/Kconfig index 80eea84..fe5aa07 100644 --- a/drivers/block/Kconfig +++ b/drivers/block/Kconfig @@ -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
-- 2.8.0.rc3.226.g39d4020
Applied to u-boot-dm.
I'm concerned that this patch might break some boards, but have had not comments. I'm pretty sure we should get a build error if it is wrong, and I have build-tested it. Hopefully it will get more testing once applied.
Regards, Simon
I had to drop this due to a build error. Now that the MMC stuff is in I've applied it again.
- Simon
participants (4)
-
Jaehoon Chung
-
Michal Simek
-
Michal Simek
-
Simon Glass