Skip to contentSkip to conversation

dm: mmc: Add driver-model support for MMC operations

PATCH New Simon Glass 4 participants 33 messages Jul 5, 2016 – Aug 6, 2016

Subsystems (18)
Network drivers Arm (32-bit) x86 USB +14 more subsystems
lore
Share & tools
lore
#0 lore raw

v2 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.

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(-)
Signature · 1 line
2.8.0.rc3.226.g39d4020
#1 lore raw

PATCH v2 1/13 dm: core: Add a function to bind child devices

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.

---

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(+)
drivers/core/root.c +9 -0
index 95886ad..d850bd0 100644
@@ -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);
include/dm/device.h +16 -0
index f03bcd3..15c0564 100644
@@ -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);
Signature · 1 line
2.8.0.rc3.226.g39d4020
#2 lore raw

PATCH v2 1/13 dm: core: Add a function to bind child devices

Quoted 11 lines · Simon Glass

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.

Quoted 8 lines

---

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.

#3 lore raw

PATCH v2 2/13 dm: Convert users from dm_scan_fdt_node() to dm_scan_fdt_dev()

In reply to Simon Glass

This new function is more convenient for callers, and handles pre-relocation situations automatically.

---

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(-)
arch/x86/lib/lpc-uclass.c +1 -3
index c6e8f73..b8254ff 100644
@@ -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) = {
common/usb_hub.c +1 -2
index 0f39c9f..26ee13e 100644
@@ -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)
drivers/core/simple-bus.c +1 -2
index 1a9c864..5c955da 100644
@@ -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) = {
drivers/i2c/i2c-uclass.c +1 -2
index 50b99ea..9dbbe1f 100644
@@ -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)
drivers/i2c/sandbox_i2c.c +1 -3
index 2c84c41..4696a1a 100644
@@ -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;
 
drivers/misc/cros_ec.c +1 -2
index e3229ef..f50e73f 100644
@@ -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(
drivers/pch/pch-uclass.c +1 -3
index 7216660..5b2fa1f 100644
@@ -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) = {
drivers/pci/pci-uclass.c +1 -10
index 32590ce..230d181 100644
@@ -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,
drivers/pci/pci_sandbox.c +1 -2
index 6de5130..b562813 100644
@@ -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 = {
drivers/pinctrl/pinctrl_pic32.c +1 -2
index 5cf97ec..5636f8f 100644
@@ -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[] = {
drivers/pinctrl/rockchip/pinctrl_rk3036.c +1 -2
index 1f78bf8..3648678 100644
@@ -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)
drivers/pinctrl/rockchip/pinctrl_rk3288.c +1 -2
index 1fa1daa..0cfa950 100644
@@ -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
drivers/power/pmic/pm8916.c +1 -2
index d4c7d4a..6f5608e 100644
@@ -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) = {
drivers/power/regulator/Kconfig +1 -1
index 465ff3f..17f22dd 100644
@@ -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
drivers/spi/spi-uclass.c +1 -2
index 84b6786..b17ed75 100644
@@ -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)
drivers/spmi/spmi-uclass.c +1 -2
index 4ddd51b..9fa330b 100644
@@ -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) = {
drivers/usb/emul/usb-emul-uclass.c +1 -2
index ee7ea5a..da91d04 100644
@@ -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)
drivers/usb/host/usb-uclass.c +1 -3
index 69c9a50..070e271 100644
@@ -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)
include/power/regulator.h +1 -1
index 63c0814..9bcd728 100644
@@ -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:
test/dm/bus.c +1 -2
index 3b5a23b..d94dcf7 100644
@@ -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)
Signature · 1 line
2.8.0.rc3.226.g39d4020
#4 lore raw

PATCH v2 2/13 dm: Convert users from dm_scan_fdt_node() to dm_scan_fdt_dev()

Quoted 22 lines · Simon Glass

This new function is more convenient for callers, and handles pre-relocation situations automatically.

---

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 +--
Quoted 8 lines
 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.

#5 lore raw

PATCH v2 2/13 dm: Convert users from dm_scan_fdt_node() to dm_scan_fdt_dev()

Hi Simon,

2016-07-17 22:59 GMT+02:00 Simon Glass <[email protected]>:

Quoted 33 lines · Simon Glass
Quoted 1 line

This new function is more convenient for callers, and handles

pre-relocation

Quoted 21 lines

situations automatically.

---

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 +--
Quoted 8 lines
 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(-)
Quoted 2 lines

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

Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Microblaze cpu - http://www.monstr.eu/fdt/
Maintainer of Linux kernel - Xilinx Zynq ARM architecture
Microblaze U-BOOT custodian and responsible for u-boot arm zynq platform
#6 lore raw

PATCH v2 2/13 dm: Convert users from dm_scan_fdt_node() to dm_scan_fdt_dev()

Hi Michal,

Quoted 54 lines · Michal Simek

Hi Simon,

2016-07-17 22:59 GMT+02:00 Simon Glass <[email protected]>:

Quoted 34 lines · Simon Glass
Quoted 23 lines

This new function is more convenient for callers, and handles pre-relocation
situations automatically.

---

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 +--
Quoted 8 lines
 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(-)
Quoted 1 line

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,

Quoted 7 lines
                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

#7 lore raw

PATCH v2 2/13 dm: Convert users from dm_scan_fdt_node() to dm_scan_fdt_dev()

Quoted 63 lines · Simon Glass

Hi Michal,

Quoted 60 lines · Michal Simek

Hi Simon,

2016-07-17 22:59 GMT+02:00 Simon Glass <[email protected]>:

Quoted 34 lines · Simon Glass
Quoted 23 lines

This new function is more convenient for callers, and handles pre-relocation
situations automatically.

---

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 +--
Quoted 8 lines
 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(-)
Quoted 1 line

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.

Quoted 5 lines
Quoted 1 line

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

#8 lore raw

PATCH v2 3/13 dm: Use dm_scan_fdt_dev() directly where possible

In reply to Simon Glass

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.

---

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(-)
arch/x86/lib/lpc-uclass.c +1 -12
index b8254ff..eb033e6 100644
@@ -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,
 };
common/usb_hub.c +1 -7
index 26ee13e..ff9cd50 100644
@@ -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),
drivers/i2c/i2c-uclass.c +1 -6
index 9dbbe1f..26d8524 100644
@@ -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),
drivers/misc/cros_ec.c +1 -7
index f50e73f..aea8d61 100644
@@ -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,
 };
drivers/pch/pch-uclass.c +1 -12
index 5b2fa1f..af794eb 100644
@@ -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,
 };
drivers/pci/pci-uclass.c +1 -14
index 230d181..342b78c 100644
@@ -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,
drivers/pci/pci_sandbox.c +3 -7
index b562813..6a84ee3 100644
@@ -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),
 };
drivers/pinctrl/pinctrl_pic32.c +1 -7
index 5636f8f..9acac29 100644
@@ -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),
 };
drivers/pinctrl/rockchip/pinctrl_rk3036.c +1 -7
index 3648678..6aea856 100644
@@ -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,
 };
drivers/pinctrl/rockchip/pinctrl_rk3288.c +1 -7
index 0cfa950..4e29c21 100644
@@ -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,
 };
drivers/power/pmic/pm8916.c +1 -7
index 6f5608e..2b65c69 100644
@@ -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),
drivers/spi/spi-uclass.c +1 -7
index b17ed75..7b94fdd 100644
@@ -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),
drivers/spmi/spmi-uclass.c +1 -6
index 9fa330b..6edece2 100644
@@ -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,
 };
drivers/usb/emul/usb-emul-uclass.c +1 -7
index da91d04..6e03c1e 100644
@@ -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),
 };
drivers/usb/host/usb-uclass.c +1 -6
index 070e271..be114fc 100644
@@ -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),
test/dm/i2c.c +2 -2
index 23d612e..e2688bf 100644
@@ -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));
test/dm/spi.c +2 -2
index 2e27da7..5733096 100644
@@ -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));
Signature · 1 line
2.8.0.rc3.226.g39d4020
#9 lore raw

PATCH v2 3/13 dm: Use dm_scan_fdt_dev() directly where possible

Quoted 19 lines · Simon Glass

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.

---

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 +-------
Quoted 8 lines
 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.

#10 lore raw

PATCH v2 4/13 arm: Show early-malloc() usage in bdinfo

In reply to Simon Glass

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).

---

Changes in v2:
- Add new patch to show early-malloc() usage in bdinfo

 cmd/bdinfo.c | 5 +++++
 1 file changed, 5 insertions(+)
cmd/bdinfo.c +5 -0
index 1c4bed9..2b106c7 100644
@@ -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;
 }
 
Signature · 1 line
2.8.0.rc3.226.g39d4020
#11 lore raw

PATCH v2 4/13 arm: Show early-malloc() usage in bdinfo

Quoted 9 lines · Simon Glass

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).

Quoted 8 lines

---

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.

#12 lore raw

PATCH v2 5/13 net: phy: marvell: Add a missing errno.h header

In reply to Simon Glass

This corrects a build error on zynqmp.

---

Changes in v2:
- Fix sign-off tag

 drivers/net/phy/marvell.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/phy/marvell.c +1 -0
index 58d287b..4eeb0f6 100644
@@ -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
#13 lore raw

PATCH v2 5/13 net: phy: marvell: Add a missing errno.h header

Quoted 10 lines · Simon Glass

This corrects a build error on zynqmp.

---

Changes in v2:
- Fix sign-off tag

 drivers/net/phy/marvell.c | 1 +
 1 file changed, 1 insertion(+)

Applied to u-boot-dm.

#14 lore raw

PATCH v2 6/13 zynq: Increase the early malloc() size

In reply to Simon Glass

This is needed to support driver-model conversion of USB and block devices.

---

Changes in v2: None

 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
index 6c71d78..ed3305d 100644
@@ -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
index db3c579..a982320 100644
@@ -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
#15 lore raw

PATCH v2 6/13 zynq: Increase the early malloc() size

Quoted 10 lines · Simon Glass

This is needed to support driver-model conversion of USB and block devices.

---

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.

#16 lore raw

PATCH v2 7/13 dm: zynq: usb: Convert to CONFIG_DM_USB

In reply to Simon Glass

Convert zynq USB to driver model. Note this is tested on zynq-zybo only.

---

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(-)
arch/arm/Kconfig +2 -0
index 585b408..9d6cdc7 100644
@@ -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"
drivers/usb/host/ehci-zynq.c +51 -52

134 lines not on this page · raw message

Signature · 1 line
2.8.0.rc3.226.g39d4020
#17 lore raw

PATCH v2 7/13 dm: zynq: usb: Convert to CONFIG_DM_USB

Quoted 11 lines · Simon Glass

Convert zynq USB to driver model. Note this is tested on zynq-zybo only.

---

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.

#18 lore raw

PATCH v2 8/13 dm: mmc: zynq: Convert zynq to use driver model for MMC

In reply to Simon Glass

Move zynq to the latest driver model support by enabling CONFIG_DM_MMC, CONFIG_DM_MMC_OPS and CONFIG_BLK.

---

Changes in v2: None

 arch/arm/Kconfig         |  5 +++++
 drivers/mmc/zynq_sdhci.c | 39 ++++++++++++++++++++++++++++++++++-----
 2 files changed, 39 insertions(+), 5 deletions(-)
arch/arm/Kconfig +5 -0
index 9d6cdc7..f45fd37 100644
@@ -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"
drivers/mmc/zynq_sdhci.c +34 -5
index d405929..bcd154a 100644
@@ -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
#19 lore raw

PATCH v2 8/13 dm: mmc: zynq: Convert zynq to use driver model for MMC

Hi Simon,

Quoted 17 lines · Simon Glass

Move zynq to the latest driver model support by enabling CONFIG_DM_MMC, CONFIG_DM_MMC_OPS and CONFIG_BLK.

---

Changes in v2: None

 arch/arm/Kconfig         |  5 +++++
 drivers/mmc/zynq_sdhci.c | 39 ++++++++++++++++++++++++++++++++++-----
 2 files changed, 39 insertions(+), 5 deletions(-)
arch/arm/Kconfig +0 -0
index 9d6cdc7..f45fd37 100644

arch/arm/Kconfig config ARCH_ZYNQ · line 666

Quoted 10 lines
arch/arm/Kconfig +2 -0
@@ -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?

arch/arm/Kconfig config ARCH_ZYNQMP · line 678

Quoted 10 lines
arch/arm/Kconfig +3 -0
 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.

Quoted 8 lines
arch/arm/Kconfig +0 -0
 config TEGRA
 	bool "NVIDIA Tegra"
drivers/mmc/zynq_sdhci.c +0 -0
index d405929..bcd154a 100644

drivers/mmc/zynq_sdhci.c line 23

Quoted 7 lines
drivers/mmc/zynq_sdhci.c +4 -0
@@ -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

Quoted 66 lines
drivers/mmc/zynq_sdhci.c +30 -5
+
 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),
 };
#20 lore raw

PATCH v2 8/13 dm: mmc: zynq: Convert zynq to use driver model for MMC

Hi Jaehoon,

Quoted 35 lines · Jaehoon Chung

Hi Simon,

Quoted 17 lines · Simon Glass

Move zynq to the latest driver model support by enabling CONFIG_DM_MMC, CONFIG_DM_MMC_OPS and CONFIG_BLK.

---

Changes in v2: None

 arch/arm/Kconfig         |  5 +++++
 drivers/mmc/zynq_sdhci.c | 39 ++++++++++++++++++++++++++++++++++-----
 2 files changed, 39 insertions(+), 5 deletions(-)
arch/arm/Kconfig +0 -0
index 9d6cdc7..f45fd37 100644

arch/arm/Kconfig config ARCH_ZYNQ · line 666

Quoted 10 lines
arch/arm/Kconfig +2 -0
@@ -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?

Quoted 1 line
Quoted 11 lines

arch/arm/Kconfig config ARCH_ZYNQMP · line 678

Quoted 9 lines

config ARCH_ZYNQMP
bool "Support Xilinx ZynqMP Platform"

arch/arm/Kconfig +3 -0
@@ -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.

?

Quoted 21 lines
Quoted 9 lines
arch/arm/Kconfig +0 -0
 config TEGRA
      bool "NVIDIA Tegra"
drivers/mmc/zynq_sdhci.c +0 -0
index d405929..bcd154a 100644

drivers/mmc/zynq_sdhci.c line 23

Quoted 7 lines
drivers/mmc/zynq_sdhci.c +4 -0
@@ -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

Quoted 4 lines
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.

Quoted 4 lines

Then we can remove the all other similar plat structures. if you are ok, I will clean everything.
how about?

Yes, please.

Regards,
Simon

#21 lore raw

PATCH v2 9/13 dm: socfpga: mmc: Support CONFIG_BLK

In reply to Simon Glass

Update the driver to support using driver model for block devices.

---

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(-)
drivers/mmc/socfpga_dw_mmc.c +31 -1
index 6a0e971..8a96302 100644
@@ -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),
 };
Signature · 1 line
2.8.0.rc3.226.g39d4020
#22 lore raw

PATCH v2 9/13 dm: socfpga: mmc: Support CONFIG_BLK

Quoted 10 lines · Simon Glass

Update the driver to support using driver model for block devices.

---

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.

#23 lore raw

PATCH v2 10/13 dm: usb: Use blk_dread/write() instead of direct calls

In reply to Simon Glass

Update the USB mass storage code to allow it to work with driver model.

---

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(-)
cmd/usb_mass_storage.c +2 -2
index b05913a..86398fc 100644
@@ -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;
Signature · 1 line
2.8.0.rc3.226.g39d4020
#24 lore raw

PATCH v2 10/13 dm: usb: Use blk_dread/write() instead of direct calls

Quoted 10 lines · Simon Glass

Update the USB mass storage code to allow it to work with driver model.

---

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.

#25 lore raw

PATCH v2 11/13 dm: spl: mmc: Support raw partitions with CONFIG_BLK

In reply to Simon Glass

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.

---

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(-)
common/spl/spl_mmc.c +1 -1
index 6b3e9e4..7c7f329 100644
@@ -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");
Signature · 1 line
2.8.0.rc3.226.g39d4020
#26 lore raw

PATCH v2 11/13 dm: spl: mmc: Support raw partitions with CONFIG_BLK

Quoted 4 lines · Simon Glass

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.

Quoted 8 lines

---

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.

#27 lore raw

PATCH v2 12/13 dm: mmc: Enable DM_MMC_OPS by default with DM_MMC

In reply to Simon Glass

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.

---

Changes in v2: None

 drivers/mmc/Kconfig | 1 +
 1 file changed, 1 insertion(+)
drivers/mmc/Kconfig +1 -0
index 79cf18f..b11725e 100644
@@ -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
#28 lore raw

PATCH v2 12/13 dm: mmc: Enable DM_MMC_OPS by default with DM_MMC

Quoted 10 lines · Simon Glass

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.

---

Changes in v2: None

 drivers/mmc/Kconfig | 1 +
 1 file changed, 1 insertion(+)

Applied to u-boot-dm.

#29 lore raw

PATCH v2 12/13 dm: mmc: Enable DM_MMC_OPS by default with DM_MMC

Hi,

Quoted 7 lines · Simon Glass
Quoted 6 lines · Simon Glass

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.

---

Quoted 6 lines
Quoted 4 lines

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

#30 lore raw

PATCH v2 13/13 dm: blk: Enable CONFIG_BLK if DM_MMC is enabled

In reply to Simon Glass

To speed up conversion to CONFIG_BLK, enable it by default when DM_MMC is enabled.

---

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(+)
drivers/block/Kconfig +1 -0
index 80eea84..fe5aa07 100644
@@ -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
#31 lore raw

PATCH v2 13/13 dm: blk: Enable CONFIG_BLK if DM_MMC is enabled

Quoted 26 lines · Simon Glass

To speed up conversion to CONFIG_BLK, enable it by default when DM_MMC is enabled.

---

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(+)
drivers/block/Kconfig +1 -1
index 80eea84..fe5aa07 100644
@@ -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
--
Quoted 2 lines

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

#32 lore raw

PATCH v2 13/13 dm: blk: Enable CONFIG_BLK if DM_MMC is enabled

Quoted 32 lines · Simon Glass
Quoted 26 lines · Simon Glass

To speed up conversion to CONFIG_BLK, enable it by default when DM_MMC is enabled.

---

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(+)
drivers/block/Kconfig +1 -1
index 80eea84..fe5aa07 100644
@@ -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
--
Quoted 2 lines

2.8.0.rc3.226.g39d4020

Applied to u-boot-dm.

Quoted 7 lines

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