Re: [PATCH v2 08/14] dtoc: extend dtoc to use struct driver_info when linking nodes

2020-06-23 Thread Walter Lozano

Hi Simon,

On 23/6/20 09:28, Simon Glass wrote:

On Fri, 19 Jun 2020 at 08:56, Walter Lozano  wrote:

In the current implementation, when dtoc parses a dtb to generate a struct
platdata it converts the information related to linked nodes as pointers
to struct platdata of destination nodes. By doing this, it makes
difficult to get pointer to udevices created based on these
information.

This patch extends dtoc to use struct driver_info when populating
information about linked nodes, which makes it easier to later get
the devices created. In this context, reimplement functions like
clk_get_by_index_platdata() which made use of the previous approach.

Signed-off-by: Walter Lozano 
---
  drivers/clk/clk-uclass.c| 11 +--
  drivers/misc/irq-uclass.c   | 10 --
  drivers/mmc/ftsdc010_mci.c  |  2 +-
  drivers/mmc/rockchip_dw_mmc.c   |  2 +-
  drivers/mmc/rockchip_sdhci.c|  2 +-
  drivers/ram/rockchip/sdram_rk3399.c |  2 +-
  drivers/spi/rk_spi.c|  2 +-
  include/clk.h   |  4 ++--
  tools/dtoc/dtb_platdata.py  | 24 +---
  9 files changed, 37 insertions(+), 22 deletions(-)

Reviewed-by: Simon Glass 

But I think you need to squash something else in here, or make another
changes, as 'make qcheck' fails on this commit.



You are right, I will squash the patch which updates the tests.

Regards,

Walter



Re: [PATCH v2 08/14] dtoc: extend dtoc to use struct driver_info when linking nodes

2020-06-23 Thread Simon Glass
On Fri, 19 Jun 2020 at 08:56, Walter Lozano  wrote:
>
> In the current implementation, when dtoc parses a dtb to generate a struct
> platdata it converts the information related to linked nodes as pointers
> to struct platdata of destination nodes. By doing this, it makes
> difficult to get pointer to udevices created based on these
> information.
>
> This patch extends dtoc to use struct driver_info when populating
> information about linked nodes, which makes it easier to later get
> the devices created. In this context, reimplement functions like
> clk_get_by_index_platdata() which made use of the previous approach.
>
> Signed-off-by: Walter Lozano 
> ---
>  drivers/clk/clk-uclass.c| 11 +--
>  drivers/misc/irq-uclass.c   | 10 --
>  drivers/mmc/ftsdc010_mci.c  |  2 +-
>  drivers/mmc/rockchip_dw_mmc.c   |  2 +-
>  drivers/mmc/rockchip_sdhci.c|  2 +-
>  drivers/ram/rockchip/sdram_rk3399.c |  2 +-
>  drivers/spi/rk_spi.c|  2 +-
>  include/clk.h   |  4 ++--
>  tools/dtoc/dtb_platdata.py  | 24 +---
>  9 files changed, 37 insertions(+), 22 deletions(-)

Reviewed-by: Simon Glass 

But I think you need to squash something else in here, or make another
changes, as 'make qcheck' fails on this commit.


[PATCH v2 08/14] dtoc: extend dtoc to use struct driver_info when linking nodes

2020-06-19 Thread Walter Lozano
In the current implementation, when dtoc parses a dtb to generate a struct
platdata it converts the information related to linked nodes as pointers
to struct platdata of destination nodes. By doing this, it makes
difficult to get pointer to udevices created based on these
information.

This patch extends dtoc to use struct driver_info when populating
information about linked nodes, which makes it easier to later get
the devices created. In this context, reimplement functions like
clk_get_by_index_platdata() which made use of the previous approach.

Signed-off-by: Walter Lozano 
---
 drivers/clk/clk-uclass.c| 11 +--
 drivers/misc/irq-uclass.c   | 10 --
 drivers/mmc/ftsdc010_mci.c  |  2 +-
 drivers/mmc/rockchip_dw_mmc.c   |  2 +-
 drivers/mmc/rockchip_sdhci.c|  2 +-
 drivers/ram/rockchip/sdram_rk3399.c |  2 +-
 drivers/spi/rk_spi.c|  2 +-
 include/clk.h   |  4 ++--
 tools/dtoc/dtb_platdata.py  | 24 +---
 9 files changed, 37 insertions(+), 22 deletions(-)

diff --git a/drivers/clk/clk-uclass.c b/drivers/clk/clk-uclass.c
index 71878474eb..412f26cd29 100644
--- a/drivers/clk/clk-uclass.c
+++ b/drivers/clk/clk-uclass.c
@@ -25,17 +25,16 @@ static inline const struct clk_ops *clk_dev_ops(struct 
udevice *dev)
 
 #if CONFIG_IS_ENABLED(OF_CONTROL)
 # if CONFIG_IS_ENABLED(OF_PLATDATA)
-int clk_get_by_index_platdata(struct udevice *dev, int index,
- struct phandle_1_arg *cells, struct clk *clk)
+int clk_get_by_driver_info(struct udevice *dev, struct phandle_1_arg *cells,
+  struct clk *clk)
 {
int ret;
 
-   if (index != 0)
-   return -ENOSYS;
-   ret = uclass_get_device(UCLASS_CLK, 0, >dev);
+   ret = device_get_by_driver_info((struct driver_info *)cells->node,
+   >dev);
if (ret)
return ret;
-   clk->id = cells[0].arg[0];
+   clk->id = cells->arg[0];
 
return 0;
 }
diff --git a/drivers/misc/irq-uclass.c b/drivers/misc/irq-uclass.c
index 61aa10e465..3c38681108 100644
--- a/drivers/misc/irq-uclass.c
+++ b/drivers/misc/irq-uclass.c
@@ -63,17 +63,15 @@ int irq_read_and_clear(struct irq *irq)
 }
 
 #if CONFIG_IS_ENABLED(OF_PLATDATA)
-int irq_get_by_index_platdata(struct udevice *dev, int index,
- struct phandle_1_arg *cells, struct irq *irq)
+int irq_get_by_driver_info(struct udevice *dev,
+  struct phandle_1_arg *cells, struct irq *irq)
 {
int ret;
 
-   if (index != 0)
-   return -ENOSYS;
-   ret = uclass_get_device(UCLASS_IRQ, 0, >dev);
+   ret = device_get_by_driver_info(cells->node, >dev);
if (ret)
return ret;
-   irq->id = cells[0].arg[0];
+   irq->id = cells->arg[0];
 
return 0;
 }
diff --git a/drivers/mmc/ftsdc010_mci.c b/drivers/mmc/ftsdc010_mci.c
index 9c15eb36d6..efa92d48be 100644
--- a/drivers/mmc/ftsdc010_mci.c
+++ b/drivers/mmc/ftsdc010_mci.c
@@ -437,7 +437,7 @@ static int ftsdc010_mmc_probe(struct udevice *dev)
chip->priv = dev;
chip->dev_index = 1;
memcpy(priv->minmax, dtplat->clock_freq_min_max, sizeof(priv->minmax));
-   ret = clk_get_by_index_platdata(dev, 0, dtplat->clocks, >clk);
+   ret = clk_get_by_driver_info(dev, dtplat->clocks, >clk);
if (ret < 0)
return ret;
 #endif
diff --git a/drivers/mmc/rockchip_dw_mmc.c b/drivers/mmc/rockchip_dw_mmc.c
index ac710324c8..80432ddbbc 100644
--- a/drivers/mmc/rockchip_dw_mmc.c
+++ b/drivers/mmc/rockchip_dw_mmc.c
@@ -120,7 +120,7 @@ static int rockchip_dwmmc_probe(struct udevice *dev)
priv->minmax[0] = 40;  /*  400 kHz */
priv->minmax[1] = dtplat->max_frequency;
 
-   ret = clk_get_by_index_platdata(dev, 0, dtplat->clocks, >clk);
+   ret = clk_get_by_driver_info(dev, dtplat->clocks, >clk);
if (ret < 0)
return ret;
 #else
diff --git a/drivers/mmc/rockchip_sdhci.c b/drivers/mmc/rockchip_sdhci.c
index b440996b26..b073f1a08d 100644
--- a/drivers/mmc/rockchip_sdhci.c
+++ b/drivers/mmc/rockchip_sdhci.c
@@ -46,7 +46,7 @@ static int arasan_sdhci_probe(struct udevice *dev)
host->name = dev->name;
host->ioaddr = map_sysmem(dtplat->reg[0], dtplat->reg[1]);
max_frequency = dtplat->max_frequency;
-   ret = clk_get_by_index_platdata(dev, 0, dtplat->clocks, );
+   ret = clk_get_by_driver_info(dev, dtplat->clocks, );
 #else
max_frequency = dev_read_u32_default(dev, "max-frequency", 0);
ret = clk_get_by_index(dev, 0, );
diff --git a/drivers/ram/rockchip/sdram_rk3399.c 
b/drivers/ram/rockchip/sdram_rk3399.c
index d69ef01d08..87ec25f893 100644
--- a/drivers/ram/rockchip/sdram_rk3399.c
+++ b/drivers/ram/rockchip/sdram_rk3399.c
@@ -3125,7 +3125,7 @@ static int rk3399_dmc_init(struct udevice *dev)
  priv->cic,