[PATCH v4 03/11] core: remap: convert regmap_init_mem_plat() input to phys_addr_t

Kever Yang kever.yang at rock-chips.com
Wed Feb 22 08:59:54 CET 2023


On 2023/2/18 23:27, Johan Jonker 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 convert regmap_init_mem_plat() input to phys_addr_t in files
> that use this function. Also correct struct syscon_base_plat
> depending on CONFIG_PHYS_64BIT setting and fix ARRAY_SIZE
> divider.
>
> Signed-off-by: Johan Jonker <jbx6244 at gmail.com>
Reviewed-by: Kever Yang <kever.yang at rock-chips.com>

Thanks,
- Kever
> ---
>
> Changed V4:
>    Fix cast and divider in syscon-uclass.c
> ---
>   drivers/core/regmap.c               |  2 +-
>   drivers/core/syscon-uclass.c        |  4 ++--
>   drivers/ram/rockchip/sdram_rk3066.c |  2 +-
>   drivers/ram/rockchip/sdram_rk3188.c |  2 +-
>   drivers/ram/rockchip/sdram_rk322x.c |  2 +-
>   drivers/ram/rockchip/sdram_rk3288.c |  2 +-
>   drivers/ram/rockchip/sdram_rk3328.c |  2 +-
>   drivers/ram/rockchip/sdram_rk3399.c |  2 +-
>   include/regmap.h                    |  2 +-
>   include/syscon.h                    | 13 +++++++------
>   10 files changed, 17 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/core/regmap.c b/drivers/core/regmap.c
> index e33bb9d7..37da64b2 100644
> --- a/drivers/core/regmap.c
> +++ b/drivers/core/regmap.c
> @@ -79,7 +79,7 @@ static struct regmap *regmap_alloc(int count)
>   }
>
>   #if CONFIG_IS_ENABLED(OF_PLATDATA)
> -int regmap_init_mem_plat(struct udevice *dev, fdt_val_t *reg, int count,
> +int regmap_init_mem_plat(struct udevice *dev, phys_addr_t *reg, int count,
>   			 struct regmap **mapp)
>   {
>   	struct regmap_range *range;
> diff --git a/drivers/core/syscon-uclass.c b/drivers/core/syscon-uclass.c
> index 25fdb66e..b557a24f 100644
> --- a/drivers/core/syscon-uclass.c
> +++ b/drivers/core/syscon-uclass.c
> @@ -58,8 +58,8 @@ static int syscon_pre_probe(struct udevice *dev)
>   #if CONFIG_IS_ENABLED(OF_PLATDATA)
>   	struct syscon_base_plat *plat = dev_get_plat(dev);
>
> -	return regmap_init_mem_plat(dev, plat->reg, ARRAY_SIZE(plat->reg),
> -					&priv->regmap);
> +	return regmap_init_mem_plat(dev, (phys_addr_t *)plat->reg,
> +				    ARRAY_SIZE(plat->reg) / 2, &priv->regmap);
>   #else
>   	return regmap_init_mem(dev_ofnode(dev), &priv->regmap);
>   #endif
> diff --git a/drivers/ram/rockchip/sdram_rk3066.c b/drivers/ram/rockchip/sdram_rk3066.c
> index a2425f22..9bb26b64 100644
> --- a/drivers/ram/rockchip/sdram_rk3066.c
> +++ b/drivers/ram/rockchip/sdram_rk3066.c
> @@ -801,7 +801,7 @@ static int rk3066_dmc_conv_of_plat(struct udevice *dev)
>   	memcpy(&plat->base, of_plat->rockchip_sdram_params, sizeof(plat->base));
>   	/* RK3066 supports dual-channel, set default channel num to 2. */
>   	plat->num_channels = 1;
> -	ret = regmap_init_mem_plat(dev, of_plat->reg,
> +	ret = regmap_init_mem_plat(dev, (phys_addr_t *)of_plat->reg,
>   				   ARRAY_SIZE(of_plat->reg) / 2, &plat->map);
>   	if (ret)
>   		return ret;
> diff --git a/drivers/ram/rockchip/sdram_rk3188.c b/drivers/ram/rockchip/sdram_rk3188.c
> index 272b1b2d..1838985c 100644
> --- a/drivers/ram/rockchip/sdram_rk3188.c
> +++ b/drivers/ram/rockchip/sdram_rk3188.c
> @@ -867,7 +867,7 @@ static int conv_of_plat(struct udevice *dev)
>   	memcpy(&plat->base, of_plat->rockchip_sdram_params, sizeof(plat->base));
>   	/* rk3188 supports dual-channel, set default channel num to 2 */
>   	plat->num_channels = 1;
> -	ret = regmap_init_mem_plat(dev, of_plat->reg,
> +	ret = regmap_init_mem_plat(dev, (phys_addr_t *)of_plat->reg,
>   				   ARRAY_SIZE(of_plat->reg) / 2, &plat->map);
>   	if (ret)
>   		return ret;
> diff --git a/drivers/ram/rockchip/sdram_rk322x.c b/drivers/ram/rockchip/sdram_rk322x.c
> index 1b204fb5..33599dc5 100644
> --- a/drivers/ram/rockchip/sdram_rk322x.c
> +++ b/drivers/ram/rockchip/sdram_rk322x.c
> @@ -769,7 +769,7 @@ static int conv_of_plat(struct udevice *dev)
>   	memcpy(&plat->base, of_plat->rockchip_sdram_params, sizeof(plat->base));
>
>   	plat->num_channels = 1;
> -	ret = regmap_init_mem_plat(dev, of_plat->reg,
> +	ret = regmap_init_mem_plat(dev, (phys_addr_t *)of_plat->reg,
>   				   ARRAY_SIZE(of_plat->reg) / 2, &plat->map);
>   	if (ret)
>   		return ret;
> diff --git a/drivers/ram/rockchip/sdram_rk3288.c b/drivers/ram/rockchip/sdram_rk3288.c
> index 83778ad1..1a548da5 100644
> --- a/drivers/ram/rockchip/sdram_rk3288.c
> +++ b/drivers/ram/rockchip/sdram_rk3288.c
> @@ -1029,7 +1029,7 @@ static int conv_of_plat(struct udevice *dev)
>   	memcpy(&plat->base, of_plat->rockchip_sdram_params, sizeof(plat->base));
>   	/* Rk3288 supports dual-channel, set default channel num to 2 */
>   	plat->num_channels = 2;
> -	ret = regmap_init_mem_plat(dev, of_plat->reg,
> +	ret = regmap_init_mem_plat(dev, (phys_addr_t *)of_plat->reg,
>   				   ARRAY_SIZE(of_plat->reg) / 2, &plat->map);
>   	if (ret)
>   		return ret;
> diff --git a/drivers/ram/rockchip/sdram_rk3328.c b/drivers/ram/rockchip/sdram_rk3328.c
> index b511c6bf..2427efe0 100644
> --- a/drivers/ram/rockchip/sdram_rk3328.c
> +++ b/drivers/ram/rockchip/sdram_rk3328.c
> @@ -54,7 +54,7 @@ static int conv_of_plat(struct udevice *dev)
>   	struct dtd_rockchip_rk3328_dmc *dtplat = &plat->dtplat;
>   	int ret;
>
> -	ret = regmap_init_mem_plat(dev, dtplat->reg,
> +	ret = regmap_init_mem_plat(dev, (phys_addr_t *)dtplat->reg,
>   				   ARRAY_SIZE(dtplat->reg) / 2, &plat->map);
>   	if (ret)
>   		return ret;
> diff --git a/drivers/ram/rockchip/sdram_rk3399.c b/drivers/ram/rockchip/sdram_rk3399.c
> index 136e4ede..c88fdbb3 100644
> --- a/drivers/ram/rockchip/sdram_rk3399.c
> +++ b/drivers/ram/rockchip/sdram_rk3399.c
> @@ -3049,7 +3049,7 @@ static int conv_of_plat(struct udevice *dev)
>   	struct dtd_rockchip_rk3399_dmc *dtplat = &plat->dtplat;
>   	int ret;
>
> -	ret = regmap_init_mem_plat(dev, dtplat->reg,
> +	ret = regmap_init_mem_plat(dev, (phys_addr_t *)dtplat->reg,
>   				   ARRAY_SIZE(dtplat->reg) / 2, &plat->map);
>   	if (ret)
>   		return ret;
> diff --git a/include/regmap.h b/include/regmap.h
> index e81a3602..a274fb27 100644
> --- a/include/regmap.h
> +++ b/include/regmap.h
> @@ -388,7 +388,7 @@ int regmap_init_mem(ofnode node, struct regmap **mapp);
>    * Use regmap_uninit() to free it.
>    *
>    */
> -int regmap_init_mem_plat(struct udevice *dev, fdt_val_t *reg, int count,
> +int regmap_init_mem_plat(struct udevice *dev, phys_addr_t *reg, int count,
>   			 struct regmap **mapp);
>
>   int regmap_init_mem_index(ofnode node, struct regmap **mapp, int index);
> diff --git a/include/syscon.h b/include/syscon.h
> index f5e6cc1a..836ae07c 100644
> --- a/include/syscon.h
> +++ b/include/syscon.h
> @@ -27,14 +27,15 @@ struct syscon_ops {
>
>   #if CONFIG_IS_ENABLED(OF_PLATDATA)
>   /*
> - * We don't support 64-bit machines. If they are so resource-contrained that
> - * they need to use OF_PLATDATA, something is horribly wrong with the
> - * education of our hardware engineers.
> - *
> - * Update: 64-bit is now supported and we have an education crisis.
> + * Support for 64bit or 32bit fdt addresses
> + * depending on the physical SoC properties.
>    */
>   struct syscon_base_plat {
> -	fdt_val_t reg[2];
> +#ifdef CONFIG_PHYS_64BIT
> +	fdt64_t reg[2];
> +#else
> +	fdt32_t reg[2];
> +#endif
>   };
>   #endif
>
> --
> 2.20.1
>


More information about the U-Boot mailing list