diff mbox series

[v2,2/2] spi: spi-aspeed-smc: use devfdt_get_addr_index_ptr

Message ID 37692c20-a1ec-7620-159d-1c6399f8954b@gmail.com
State Accepted
Delegated to: Tom Rini
Headers show
Series [v2,1/2] core: fdtaddr: add devfdt_get_addr_size_index_ptr function | expand

Commit Message

Johan Jonker Feb. 25, 2023, 11:44 a.m. UTC
The fdt_addr_t and phys_addr_t size have been decoupled.
A 32bit CPU can expect 64-bit data from the device tree parser,
so use devfdt_get_addr_index_ptr and devfdt_get_addr_size_index_ptr
function in the spi-aspeed-smc.c file. Also fix dev_dbg to be able
to handle both sizes.

Signed-off-by: Johan Jonker <jbx6244@gmail.com>
---

Note:

This is needed for a Rockchip patch serie to pass the test and
must be merged before by Rockchip maintainers:

[PATCH v4 00/11] Fixes for Rockchip NFC driver part 1
https://lore.kernel.org/u-boot/f3dba231-4a55-0a94-dfab-5cab1419d132@gmail.com/

Changed V2:
  Use devfdt_get_addr_index_ptr and devfdt_get_addr_size_index_ptr
---
 drivers/spi/spi-aspeed-smc.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

--
2.20.1

Comments

Michael Nazzareno Trimarchi Feb. 25, 2023, 11:47 a.m. UTC | #1
Hi

On Sat, Feb 25, 2023 at 12:44 PM Johan Jonker <jbx6244@gmail.com> wrote:
>
> The fdt_addr_t and phys_addr_t size have been decoupled.
> A 32bit CPU can expect 64-bit data from the device tree parser,
> so use devfdt_get_addr_index_ptr and devfdt_get_addr_size_index_ptr
> function in the spi-aspeed-smc.c file. Also fix dev_dbg to be able
> to handle both sizes.
>
> Signed-off-by: Johan Jonker <jbx6244@gmail.com>
> ---
>
> Note:
>
> This is needed for a Rockchip patch serie to pass the test and
> must be merged before by Rockchip maintainers:
>
> [PATCH v4 00/11] Fixes for Rockchip NFC driver part 1
> https://lore.kernel.org/u-boot/f3dba231-4a55-0a94-dfab-5cab1419d132@gmail.com/
>
> Changed V2:
>   Use devfdt_get_addr_index_ptr and devfdt_get_addr_size_index_ptr
> ---
>  drivers/spi/spi-aspeed-smc.c | 13 ++++++-------
>  1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
> index a3c96333..fedcaad6 100644
> --- a/drivers/spi/spi-aspeed-smc.c
> +++ b/drivers/spi/spi-aspeed-smc.c
> @@ -1125,15 +1125,14 @@ static int apseed_spi_of_to_plat(struct udevice *bus)
>         int ret;
>         struct clk hclk;
>
> -       priv->regs = (void __iomem *)devfdt_get_addr_index(bus, 0);
> -       if ((u32)priv->regs == FDT_ADDR_T_NONE) {
> +       priv->regs = devfdt_get_addr_index_ptr(bus, 0);
> +       if (!priv->regs) {
>                 dev_err(bus, "wrong ctrl base\n");
>                 return -ENODEV;
>         }
>
> -       plat->ahb_base =
> -               (void __iomem *)devfdt_get_addr_size_index(bus, 1, &plat->ahb_sz);
> -       if ((u32)plat->ahb_base == FDT_ADDR_T_NONE) {
> +       plat->ahb_base = devfdt_get_addr_size_index_ptr(bus, 1, &plat->ahb_sz);
> +       if (!plat->ahb_base) {
>                 dev_err(bus, "wrong AHB base\n");
>                 return -ENODEV;
>         }
> @@ -1151,8 +1150,8 @@ static int apseed_spi_of_to_plat(struct udevice *bus)
>         plat->hclk_rate = clk_get_rate(&hclk);
>         clk_free(&hclk);
>
> -       dev_dbg(bus, "ctrl_base = 0x%x, ahb_base = 0x%p, size = 0x%lx\n",
> -               (u32)priv->regs, plat->ahb_base, plat->ahb_sz);
> +       dev_dbg(bus, "ctrl_base = 0x%x, ahb_base = 0x%p, size = 0x%llx\n",
> +               (u32)priv->regs, plat->ahb_base, (fdt64_t)plat->ahb_sz);
>         dev_dbg(bus, "hclk = %dMHz, max_cs = %d\n",
>                 plat->hclk_rate / 1000000, plat->max_cs);
>
> --
> 2.20.1
>
Reviewed-By: Michael Trimarchi <michael@amarulasolutions.com>
diff mbox series

Patch

diff --git a/drivers/spi/spi-aspeed-smc.c b/drivers/spi/spi-aspeed-smc.c
index a3c96333..fedcaad6 100644
--- a/drivers/spi/spi-aspeed-smc.c
+++ b/drivers/spi/spi-aspeed-smc.c
@@ -1125,15 +1125,14 @@  static int apseed_spi_of_to_plat(struct udevice *bus)
 	int ret;
 	struct clk hclk;

-	priv->regs = (void __iomem *)devfdt_get_addr_index(bus, 0);
-	if ((u32)priv->regs == FDT_ADDR_T_NONE) {
+	priv->regs = devfdt_get_addr_index_ptr(bus, 0);
+	if (!priv->regs) {
 		dev_err(bus, "wrong ctrl base\n");
 		return -ENODEV;
 	}

-	plat->ahb_base =
-		(void __iomem *)devfdt_get_addr_size_index(bus, 1, &plat->ahb_sz);
-	if ((u32)plat->ahb_base == FDT_ADDR_T_NONE) {
+	plat->ahb_base = devfdt_get_addr_size_index_ptr(bus, 1, &plat->ahb_sz);
+	if (!plat->ahb_base) {
 		dev_err(bus, "wrong AHB base\n");
 		return -ENODEV;
 	}
@@ -1151,8 +1150,8 @@  static int apseed_spi_of_to_plat(struct udevice *bus)
 	plat->hclk_rate = clk_get_rate(&hclk);
 	clk_free(&hclk);

-	dev_dbg(bus, "ctrl_base = 0x%x, ahb_base = 0x%p, size = 0x%lx\n",
-		(u32)priv->regs, plat->ahb_base, plat->ahb_sz);
+	dev_dbg(bus, "ctrl_base = 0x%x, ahb_base = 0x%p, size = 0x%llx\n",
+		(u32)priv->regs, plat->ahb_base, (fdt64_t)plat->ahb_sz);
 	dev_dbg(bus, "hclk = %dMHz, max_cs = %d\n",
 		plat->hclk_rate / 1000000, plat->max_cs);