Re: [PATCH 2/2] fixup! regmap-mmio: Add big endian support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/30/20 8:46 PM, Ahmad Fatoum wrote:
> of_regmap_init_mmio_clk was introduced as to avoid allocating new
> devices for syscon nodes, a device tree node sufficed.
> 
> We already have an existing device node though, so let's use that.
s/device node/device object/
> Through this device node, we can access the big-endian and friends
s/device node/device object/
> properties.

(I assume this will be squashed anyway, but to make it a bit clearer)

> 
> Signed-off-by: Ahmad Fatoum <ahmad@xxxxxx>
> ---
> Hello Sascha,
> 
> this is untested on the Layerscape. I just verified it now works on the
> stm32mp and that adding a big-endian there breaks it again.
> 
> Feel free to adjust.
> ---
>  drivers/base/regmap/regmap-mmio.c | 22 ----------------------
>  drivers/mfd/syscon.c              | 21 +++++++++++++++++----
>  include/regmap.h                  | 15 ---------------
>  3 files changed, 17 insertions(+), 41 deletions(-)
> 
> diff --git a/drivers/base/regmap/regmap-mmio.c b/drivers/base/regmap/regmap-mmio.c
> index 9c5a2822a4fe..7ca95d6bea79 100644
> --- a/drivers/base/regmap/regmap-mmio.c
> +++ b/drivers/base/regmap/regmap-mmio.c
> @@ -299,28 +299,6 @@ struct regmap *regmap_init_mmio_clk(struct device_d *dev,
>  	return regmap_init(dev, &regmap_mmio, ctx, config);
>  }
>  
> -struct regmap *of_regmap_init_mmio_clk(struct device_node *np,
> -				       const char *clk_id,
> -				       void __iomem *regs,
> -				       const struct regmap_config *config)
> -{
> -	struct regmap_mmio_context *ctx;
> -
> -	ctx = regmap_mmio_gen_context(NULL, regs, config);
> -	if (IS_ERR(ctx))
> -		return ERR_CAST(ctx);
> -
> -	if (clk_id) {
> -		ctx->clk = of_clk_get_by_name(np, clk_id);
> -		if (IS_ERR(ctx->clk)) {
> -			kfree(ctx);
> -			return ERR_CAST(ctx->clk);
> -		}
> -	}
> -
> -	return regmap_init(NULL, &regmap_mmio, ctx, config);
> -}
> -
>  int regmap_mmio_attach_clk(struct regmap *map, struct clk *clk)
>  {
>  	struct regmap_mmio_context *ctx = map->bus_context;
> diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
> index f1e6559d71fa..c9dfb151ee0a 100644
> --- a/drivers/mfd/syscon.c
> +++ b/drivers/mfd/syscon.c
> @@ -27,6 +27,7 @@ static LIST_HEAD(syscon_list);
>  
>  struct syscon {
>  	struct device_node *np;
> +	struct device_d *dev;
>  	void __iomem *base;
>  	struct list_head list;
>  	struct regmap *regmap;
> @@ -42,6 +43,7 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_clk)
>  {
>  	int ret;
>  	struct syscon *syscon;
> +	struct device_d *dev;
>  	struct resource res;
>  
>  	if (!of_device_is_compatible(np, "syscon"))
> @@ -55,12 +57,23 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_clk)
>  	}
>  
>  	syscon->base = IOMEM(res.start);
> -	syscon->np   = np;
> +
> +	for_each_device(dev) {
> +		if (np == dev->device_node) {
> +			syscon->dev = dev;
> +			break;
> +		}
> +	}
> +
> +	if (!syscon->dev) {
> +		ret = -ENODEV;
> +		goto err_map;
> +	}
>  
>  	list_add_tail(&syscon->list, &syscon_list);
>  
> -	syscon->regmap = of_regmap_init_mmio_clk(np, NULL, syscon->base,
> -					     &syscon_regmap_config);
> +	syscon->regmap = regmap_init_mmio_clk(syscon->dev, NULL, syscon->base,
> +					      &syscon_regmap_config);
>  
>  	if (check_clk) {
>  		struct clk *clk = of_clk_get(np, 0);
> @@ -88,7 +101,7 @@ static struct syscon *node_to_syscon(struct device_node *np)
>  	struct syscon *entry, *syscon = NULL;
>  
>  	list_for_each_entry(entry, &syscon_list, list)
> -		if (entry->np == np) {
> +		if (entry->dev->device_node == np) {
>  			syscon = entry;
>  			break;
>  		}
> diff --git a/include/regmap.h b/include/regmap.h
> index 139ac33ec3e8..4172c00bd2da 100644
> --- a/include/regmap.h
> +++ b/include/regmap.h
> @@ -61,21 +61,6 @@ struct regmap *regmap_init(struct device_d *dev,
>  
>  struct clk;
>  
> -/**
> - * of_regmap_init_mmio_clk() - Initialise register map with register clock
> - *
> - * @np: Device node that will be interacted with
> - * @clk_id: register clock consumer ID
> - * @regs: Pointer to memory-mapped IO region
> - * @config: Configuration for register map
> - *
> - * The return value will be an ERR_PTR() on error or a valid pointer to
> - * a struct regmap.
> - */
> -struct regmap *of_regmap_init_mmio_clk(struct device_node *np, const char *clk_id,
> -				       void __iomem *regs,
> -				       const struct regmap_config *config);
> -
>  /**
>   * regmap_init_mmio_clk() - Initialise register map with register clock
>   *
> 

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux