* [PATCH 1/2] fixup! regmap-mmio: Add big endian support @ 2020-03-30 18:46 Ahmad Fatoum 2020-03-30 18:46 ` [PATCH 2/2] " Ahmad Fatoum 0 siblings, 1 reply; 3+ messages in thread From: Ahmad Fatoum @ 2020-03-30 18:46 UTC (permalink / raw) To: barebox The Linux default for the regmap MMIO bus used for syscon is little endian, not big endian like for a general regmap bus. This fixes network breakage on the STM32MP, which uses a syscon in link mode configuration. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> --- drivers/base/regmap/regmap-mmio.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/base/regmap/regmap-mmio.c b/drivers/base/regmap/regmap-mmio.c index 492dd16ff52a..9c5a2822a4fe 100644 --- a/drivers/base/regmap/regmap-mmio.c +++ b/drivers/base/regmap/regmap-mmio.c @@ -182,6 +182,7 @@ static int regmap_mmio_read(void *context, unsigned int reg, unsigned int *val) static const struct regmap_bus regmap_mmio = { .reg_write = regmap_mmio_write, .reg_read = regmap_mmio_read, + .val_format_endian_default = REGMAP_ENDIAN_LITTLE, }; static struct regmap_mmio_context *regmap_mmio_gen_context(struct device_d *dev, -- 2.20.1 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/2] fixup! regmap-mmio: Add big endian support 2020-03-30 18:46 [PATCH 1/2] fixup! regmap-mmio: Add big endian support Ahmad Fatoum @ 2020-03-30 18:46 ` Ahmad Fatoum 2020-03-31 7:24 ` Ahmad Fatoum 0 siblings, 1 reply; 3+ messages in thread From: Ahmad Fatoum @ 2020-03-30 18:46 UTC (permalink / raw) To: barebox 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. Through this device node, we can access the big-endian and friends properties. Signed-off-by: Ahmad Fatoum <ahmad@a3f.at> --- 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, ®map_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, ®map_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 * -- 2.20.1 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 2/2] fixup! regmap-mmio: Add big endian support 2020-03-30 18:46 ` [PATCH 2/2] " Ahmad Fatoum @ 2020-03-31 7:24 ` Ahmad Fatoum 0 siblings, 0 replies; 3+ messages in thread From: Ahmad Fatoum @ 2020-03-31 7:24 UTC (permalink / raw) To: Ahmad Fatoum, barebox 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@a3f.at> > --- > 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, ®map_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, ®map_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@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-03-31 7:24 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-03-30 18:46 [PATCH 1/2] fixup! regmap-mmio: Add big endian support Ahmad Fatoum 2020-03-30 18:46 ` [PATCH 2/2] " Ahmad Fatoum 2020-03-31 7:24 ` Ahmad Fatoum
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox