core: add support for U_BOOT_DRIVER_ALIAS
authorWalter Lozano <walter.lozano@collabora.com>
Thu, 25 Jun 2020 04:10:06 +0000 (01:10 -0300)
committerSimon Glass <sjg@chromium.org>
Fri, 10 Jul 2020 00:57:22 +0000 (18:57 -0600)
Currently when using OF_PLATDATA the binding between devices and drivers
is done trying to match the compatible string in the node with a driver
name. However, usually a single driver supports multiple compatible strings
which causes that only devices which its compatible string matches a
driver name get bound.

To overcome this issue, this patch adds the U_BOOT_DRIVER_ALIAS macro,
which generates no code at all, but allows an easy way to declare driver
name aliases. Thanks to this, dtoc could be improve to look for the driver
name based on its alias when it populates the U_BOOT_DEVICE entry.

Signed-off-by: Walter Lozano <walter.lozano@collabora.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
14 files changed:
drivers/clk/at91/pmc.c
drivers/gpio/mxs_gpio.c
drivers/gpio/sandbox.c
drivers/i2c/rk_i2c.c
drivers/mmc/mxsmmc.c
drivers/mmc/rockchip_dw_mmc.c
drivers/mtd/spi/sf_probe.c
drivers/pinctrl/nxp/pinctrl-mxs.c
drivers/pinctrl/pinctrl-at91.c
drivers/power/pmic/rk8xx.c
drivers/serial/ns16550.c
drivers/spi/mxs_spi.c
drivers/spi/rk_spi.c
include/dm/device.h

index f6b9367f2e0136486ae8286275ae48e9896fffc4..54ae0d281d0a4a1ab84b74724b2a618ac26c0e09 100644 (file)
@@ -31,6 +31,8 @@ U_BOOT_DRIVER(atmel_at91rm9200_pmc) = {
        .of_match = at91_pmc_match,
 };
 
+U_BOOT_DRIVER_ALIAS(atmel_at91rm9200_pmc, atmel_at91sam9260_pmc)
+
 /*---------------------------------------------------------*/
 
 int at91_pmc_core_probe(struct udevice *dev)
index bc697435d8bb5ce6033cb06ddab15e1fa0768b1c..cb797261b7f368f0f69bd02f151a970fcb9324f7 100644 (file)
@@ -311,4 +311,6 @@ U_BOOT_DRIVER(fsl_imx23_gpio) = {
        .ofdata_to_platdata = mxs_ofdata_to_platdata,
 #endif
 };
+
+U_BOOT_DRIVER_ALIAS(fsl_imx23_gpio, fsl_imx28_gpio)
 #endif /* DM_GPIO */
index 1df2d8d017af2411a590aad2bd24406d84903a18..b9a1d65acc409e3fb5c24124ec766373512ec5f1 100644 (file)
@@ -254,6 +254,8 @@ U_BOOT_DRIVER(sandbox_gpio) = {
        .ops    = &gpio_sandbox_ops,
 };
 
+U_BOOT_DRIVER_ALIAS(sandbox_gpio, sandbox_gpio_alias)
+
 /* pincontrol: used only to check GPIO pin configuration (pinmux command) */
 
 struct sb_pinctrl_priv {
index cbe959b5909d1f9664e9cee6b22bb67c24b83629..659461088b73b48d08cfad846b98fb51d406cfac 100644 (file)
@@ -494,3 +494,5 @@ U_BOOT_DRIVER(rockchip_rk3066_i2c) = {
        .priv_auto_alloc_size = sizeof(struct rk_i2c),
        .ops    = &rockchip_i2c_ops,
 };
+
+U_BOOT_DRIVER_ALIAS(rockchip_rk3066_i2c, rockchip_rk3288_i2c)
index 03a50773a055d3a8b84c5041f18aabbddb5b6e50..c6a06b9ca87dbae556b779e9ee25a6849cae8c0b 100644 (file)
@@ -727,4 +727,5 @@ U_BOOT_DRIVER(fsl_imx23_mmc) = {
        .platdata_auto_alloc_size = sizeof(struct mxsmmc_platdata),
 };
 
+U_BOOT_DRIVER_ALIAS(fsl_imx23_mmc, fsl_imx28_mmc)
 #endif /* CONFIG_DM_MMC */
index c5aeffc1c01c8a3c3e8bddfe8a03567662db78eb..e8e4da20f7b55a1696390d57cb9402bc408e26b8 100644 (file)
@@ -180,6 +180,9 @@ U_BOOT_DRIVER(rockchip_rk3288_dw_mshc) = {
        .platdata_auto_alloc_size = sizeof(struct rockchip_mmc_plat),
 };
 
+U_BOOT_DRIVER_ALIAS(rockchip_rk3288_dw_mshc, rockchip_rk3328_dw_mshc)
+U_BOOT_DRIVER_ALIAS(rockchip_rk3288_dw_mshc, rockchip_rk3368_dw_mshc)
+
 #ifdef CONFIG_PWRSEQ
 static int rockchip_dwmmc_pwrseq_set_power(struct udevice *dev, bool enable)
 {
index 3dcd57d27151d8b9f0623fca6304176255340c50..475f6c31dbd4350477f808b23cef69b584b21e0c 100644 (file)
@@ -170,4 +170,6 @@ U_BOOT_DRIVER(jedec_spi_nor) = {
        .ops            = &spi_flash_std_ops,
 };
 
+U_BOOT_DRIVER_ALIAS(jedec_spi_nor, spansion_m25p16)
+
 #endif /* CONFIG_DM_SPI_FLASH */
index 99a43a3a74c28b96f710a71b06250c9301822f62..db463fc04b96e4b5745b8f3d5c3c8bf1199f1fb3 100644 (file)
@@ -191,3 +191,5 @@ U_BOOT_DRIVER(fsl_imx23_pinctrl) = {
        .priv_auto_alloc_size = sizeof(struct mxs_pinctrl_priv),
        .ops = &mxs_pinctrl_ops,
 };
+
+U_BOOT_DRIVER_ALIAS(fsl_imx23_pinctrl, fsl_imx28_pinctrl)
index def723690d2565a98ecca50abe9d4e122953d31d..cd7b32ce346034769c6f1d2549bc3d94e009e803 100644 (file)
@@ -527,3 +527,5 @@ U_BOOT_DRIVER(atmel_sama5d3_pinctrl) = {
        .priv_auto_alloc_size = sizeof(struct at91_pinctrl_priv),
        .ops = &at91_pinctrl_ops,
 };
+
+U_BOOT_DRIVER_ALIAS(atmel_sama5d3_pinctrl, atmel_at91rm9200_pinctrl)
index 517c87ed0d72f9a33af6ebdb34f1eb0909d5d161..148ee29cca0043c5d0de93eaaf398e9844611537 100644 (file)
@@ -194,3 +194,5 @@ U_BOOT_DRIVER(rockchip_rk805) = {
        .probe = rk8xx_probe,
        .ops = &rk8xx_ops,
 };
+
+U_BOOT_DRIVER_ALIAS(rockchip_rk805, rockchip_rk808)
index cca798d7e484e45bb33038ecae36ac87f256ba1a..702109b23b6a07b3454cd19564bded5991e674cf 100644 (file)
@@ -620,6 +620,10 @@ U_BOOT_DRIVER(ns16550_serial) = {
        .flags  = DM_FLAG_PRE_RELOC,
 #endif
 };
+
+U_BOOT_DRIVER_ALIAS(ns16550_serial, rockchip_rk3328_uart)
+U_BOOT_DRIVER_ALIAS(ns16550_serial, rockchip_rk3368_uart)
+U_BOOT_DRIVER_ALIAS(ns16550_serial, ti_da830_uart)
 #endif
 #endif /* SERIAL_PRESENT */
 
index 4b8e242501a9908be5c8ed92ca24a506c09d079d..3c1af839c07f4b4a29ff99fe7e5dcc09925cba20 100644 (file)
@@ -498,3 +498,5 @@ U_BOOT_DRIVER(fsl_imx23_spi) = {
        .priv_auto_alloc_size = sizeof(struct mxs_spi_priv),
        .probe  = mxs_spi_probe,
 };
+
+U_BOOT_DRIVER_ALIAS(fsl_imx23_spi, fsl_imx28_spi)
index 5c1828aedacca3155c3f5ceb2cb63b95649d809f..add3e49c306cf341ed9a11970448323e4e8480b5 100644 (file)
@@ -563,3 +563,5 @@ U_BOOT_DRIVER(rockchip_rk3288_spi) = {
        .priv_auto_alloc_size = sizeof(struct rockchip_spi_priv),
        .probe  = rockchip_spi_probe,
 };
+
+U_BOOT_DRIVER_ALIAS(rockchip_rk3288_spi, rockchip_rk3368_spi)
index 975eec5d0e19ba02c9220706234a3a3ec12db5d4..2cfe10766ff3e1eb9262b940c3a543b33717d295 100644 (file)
@@ -282,6 +282,13 @@ struct driver {
 #define DM_GET_DRIVER(__name)                                          \
        ll_entry_get(struct driver, __name, driver)
 
+/**
+ * Declare a macro to state a alias for a driver name. This macro will
+ * produce no code but its information will be parsed by tools like
+ * dtoc
+ */
+#define U_BOOT_DRIVER_ALIAS(__name, __alias)
+
 /**
  * dev_get_platdata() - Get the platform data for a device
  *