Re: [PATCH v2 4/4] ASoC: rsnd: use regmap instead of original register mapping method
On Tue, Sep 17, 2013 at 10:23:58PM +0900, Kuninori Morimoto wrote: > For example, SSI device have many ports (0-8), > but ADG is only 1 device. > On this driver, all devices are using rsnd_write/read() to > access register. OK, this sounds like the module should have this information - ie check something in the module structure rather than asking regmap. signature.asc Description: Digital signature
Re: [PATCH v2 4/4] ASoC: rsnd: use regmap instead of original register mapping method
Dear Mark > > +void rsnd_write(struct rsnd_priv *priv, > > + struct rsnd_mod *mod, > > + enum rsnd_reg reg, u32 data) > > +{ > > + struct rsnd_gen *gen = rsnd_priv_to_gen(priv); > > + > > + if (regmap_fields_enable(gen->regs[reg])) > > + regmap_fields_write(gen->regs[reg], rsnd_mod_id(mod), data); > > + else > > + regmap_field_write(gen->regs[reg], data); > > +} > > Ah, sorry - I see you are actually using fields_enable(). I must've > searched for the wrong thing. However looking at this I'm not sure that > this is a good use anyway, it seems like the caller should know if the > register it is writing to is in one of the repeated blocks. Can you > provide a bit more detail as to what's going on here? Hmm... rsnd_write/read() care about it (block/non-block), and caller don't care it, is nice point of this function... For example, SSI device have many ports (0-8), but ADG is only 1 device. On this driver, all devices are using rsnd_write/read() to access register. I can re-check it, but it will be next week Thank you Best regards -- Kuninori Morimoto -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 4/4] ASoC: rsnd: use regmap instead of original register mapping method
On Sun, Sep 01, 2013 at 08:32:45PM -0700, Kuninori Morimoto wrote: > +void rsnd_write(struct rsnd_priv *priv, > + struct rsnd_mod *mod, > + enum rsnd_reg reg, u32 data) > +{ > + struct rsnd_gen *gen = rsnd_priv_to_gen(priv); > + > + if (regmap_fields_enable(gen->regs[reg])) > + regmap_fields_write(gen->regs[reg], rsnd_mod_id(mod), data); > + else > + regmap_field_write(gen->regs[reg], data); > +} Ah, sorry - I see you are actually using fields_enable(). I must've searched for the wrong thing. However looking at this I'm not sure that this is a good use anyway, it seems like the caller should know if the register it is writing to is in one of the repeated blocks. Can you provide a bit more detail as to what's going on here? signature.asc Description: Digital signature
Re: [PATCH v2 4/4] ASoC: rsnd: use regmap instead of original register mapping method
On Sun, Sep 01, 2013 at 08:32:45PM -0700, Kuninori Morimoto wrote: +void rsnd_write(struct rsnd_priv *priv, + struct rsnd_mod *mod, + enum rsnd_reg reg, u32 data) +{ + struct rsnd_gen *gen = rsnd_priv_to_gen(priv); + + if (regmap_fields_enable(gen-regs[reg])) + regmap_fields_write(gen-regs[reg], rsnd_mod_id(mod), data); + else + regmap_field_write(gen-regs[reg], data); +} Ah, sorry - I see you are actually using fields_enable(). I must've searched for the wrong thing. However looking at this I'm not sure that this is a good use anyway, it seems like the caller should know if the register it is writing to is in one of the repeated blocks. Can you provide a bit more detail as to what's going on here? signature.asc Description: Digital signature
Re: [PATCH v2 4/4] ASoC: rsnd: use regmap instead of original register mapping method
Dear Mark +void rsnd_write(struct rsnd_priv *priv, + struct rsnd_mod *mod, + enum rsnd_reg reg, u32 data) +{ + struct rsnd_gen *gen = rsnd_priv_to_gen(priv); + + if (regmap_fields_enable(gen-regs[reg])) + regmap_fields_write(gen-regs[reg], rsnd_mod_id(mod), data); + else + regmap_field_write(gen-regs[reg], data); +} Ah, sorry - I see you are actually using fields_enable(). I must've searched for the wrong thing. However looking at this I'm not sure that this is a good use anyway, it seems like the caller should know if the register it is writing to is in one of the repeated blocks. Can you provide a bit more detail as to what's going on here? Hmm... rsnd_write/read() care about it (block/non-block), and caller don't care it, is nice point of this function... For example, SSI device have many ports (0-8), but ADG is only 1 device. On this driver, all devices are using rsnd_write/read() to access register. I can re-check it, but it will be next week Thank you Best regards -- Kuninori Morimoto -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 4/4] ASoC: rsnd: use regmap instead of original register mapping method
On Tue, Sep 17, 2013 at 10:23:58PM +0900, Kuninori Morimoto wrote: For example, SSI device have many ports (0-8), but ADG is only 1 device. On this driver, all devices are using rsnd_write/read() to access register. OK, this sounds like the module should have this information - ie check something in the module structure rather than asking regmap. signature.asc Description: Digital signature
[PATCH v2 4/4] ASoC: rsnd: use regmap instead of original register mapping method
Current Linux kernel is supporting regmap/regmap_field, and, it is good match for Renesas Sound Gen1/Gen2 register mapping. This patch uses regmap instead of original method for register access Signed-off-by: Kuninori Morimoto --- v1 -> v2 - exchange macro naming (RSND_GEN1_S_REG/RSND_GEN1_M_REG) sound/soc/sh/rcar/core.c | 45 - sound/soc/sh/rcar/gen.c | 231 ++ 2 files changed, 150 insertions(+), 126 deletions(-) diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index a357060..fc83f0f 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -106,51 +106,6 @@ (!(priv->info->func) ? -ENODEV :\ priv->info->func(param)) - -/* - * basic function - */ -u32 rsnd_read(struct rsnd_priv *priv, - struct rsnd_mod *mod, enum rsnd_reg reg) -{ - void __iomem *base = rsnd_gen_reg_get(priv, mod, reg); - - BUG_ON(!base); - - return ioread32(base); -} - -void rsnd_write(struct rsnd_priv *priv, - struct rsnd_mod *mod, - enum rsnd_reg reg, u32 data) -{ - void __iomem *base = rsnd_gen_reg_get(priv, mod, reg); - struct device *dev = rsnd_priv_to_dev(priv); - - BUG_ON(!base); - - dev_dbg(dev, "w %p : %08x\n", base, data); - - iowrite32(data, base); -} - -void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod, - enum rsnd_reg reg, u32 mask, u32 data) -{ - void __iomem *base = rsnd_gen_reg_get(priv, mod, reg); - struct device *dev = rsnd_priv_to_dev(priv); - u32 val; - - BUG_ON(!base); - - val = ioread32(base); - val &= ~mask; - val |= data & mask; - iowrite32(val, base); - - dev_dbg(dev, "s %p : %08x\n", base, val); -} - /* * rsnd_mod functions */ diff --git a/sound/soc/sh/rcar/gen.c b/sound/soc/sh/rcar/gen.c index 331fc55..9a55fdf 100644 --- a/sound/soc/sh/rcar/gen.c +++ b/sound/soc/sh/rcar/gen.c @@ -24,21 +24,106 @@ struct rsnd_gen_ops { struct rsnd_dai_stream *io); }; -struct rsnd_gen_reg_map { - int index; /* -1 : not supported */ - u32 offset_id; /* offset of ssi0, ssi1, ssi2... */ - u32 offset_adr; /* offset of SSICR, SSISR, ... */ -}; - struct rsnd_gen { void __iomem *base[RSND_BASE_MAX]; - struct rsnd_gen_reg_map reg_map[RSND_REG_MAX]; struct rsnd_gen_ops *ops; + + struct regmap *regmap; + struct regmap_field *regs[RSND_REG_MAX]; }; #define rsnd_priv_to_gen(p)((struct rsnd_gen *)(p)->gen) +#define RSND_REG_SET(gen, id, reg_id, offset, _id_offset, _id_size)\ + [id] = {\ + .reg = (unsigned int)gen->base[reg_id] + offset,\ + .lsb = 0, \ + .msb = 31, \ + .id_size = _id_size,\ + .id_offset = _id_offset,\ + } + +/* + * basic function + */ +static int rsnd_regmap_write32(void *context, const void *_data, size_t count) +{ + struct rsnd_priv *priv = context; + struct device *dev = rsnd_priv_to_dev(priv); + u32 *data = (u32 *)_data; + u32 val = data[1]; + void __iomem *reg = (void *)data[0]; + + iowrite32(val, reg); + + dev_dbg(dev, "w %p : %08x\n", reg, val); + + return 0; +} + +static int rsnd_regmap_read32(void *context, + const void *_data, size_t reg_size, + void *_val, size_t val_size) +{ + struct rsnd_priv *priv = context; + struct device *dev = rsnd_priv_to_dev(priv); + u32 *data = (u32 *)_data; + u32 *val = (u32 *)_val; + void __iomem *reg = (void *)data[0]; + + *val = ioread32(reg); + + dev_dbg(dev, "r %p : %08x\n", reg, *val); + + return 0; +} + +static struct regmap_bus rsnd_regmap_bus = { + .write = rsnd_regmap_write32, + .read = rsnd_regmap_read32, + .reg_format_endian_default = REGMAP_ENDIAN_NATIVE, + .val_format_endian_default = REGMAP_ENDIAN_NATIVE, +}; + +u32 rsnd_read(struct rsnd_priv *priv, + struct rsnd_mod *mod, enum rsnd_reg reg) +{ + struct rsnd_gen *gen = rsnd_priv_to_gen(priv); + u32 val; + + if (regmap_fields_enable(gen->regs[reg])) + regmap_fields_read(gen->regs[reg], rsnd_mod_id(mod), ); + else + regmap_field_read(gen->regs[reg], ); + + return val; +} + +void rsnd_write(struct rsnd_priv *priv, + struct rsnd_mod *mod, + enum rsnd_reg reg, u32 data) +{ + struct rsnd_gen *gen = rsnd_priv_to_gen(priv); + + if (regmap_fields_enable(gen->regs[reg])) +
[PATCH v2 4/4] ASoC: rsnd: use regmap instead of original register mapping method
Current Linux kernel is supporting regmap/regmap_field, and, it is good match for Renesas Sound Gen1/Gen2 register mapping. This patch uses regmap instead of original method for register access Signed-off-by: Kuninori Morimoto kuninori.morimoto...@renesas.com --- v1 - v2 - exchange macro naming (RSND_GEN1_S_REG/RSND_GEN1_M_REG) sound/soc/sh/rcar/core.c | 45 - sound/soc/sh/rcar/gen.c | 231 ++ 2 files changed, 150 insertions(+), 126 deletions(-) diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index a357060..fc83f0f 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -106,51 +106,6 @@ (!(priv-info-func) ? -ENODEV :\ priv-info-func(param)) - -/* - * basic function - */ -u32 rsnd_read(struct rsnd_priv *priv, - struct rsnd_mod *mod, enum rsnd_reg reg) -{ - void __iomem *base = rsnd_gen_reg_get(priv, mod, reg); - - BUG_ON(!base); - - return ioread32(base); -} - -void rsnd_write(struct rsnd_priv *priv, - struct rsnd_mod *mod, - enum rsnd_reg reg, u32 data) -{ - void __iomem *base = rsnd_gen_reg_get(priv, mod, reg); - struct device *dev = rsnd_priv_to_dev(priv); - - BUG_ON(!base); - - dev_dbg(dev, w %p : %08x\n, base, data); - - iowrite32(data, base); -} - -void rsnd_bset(struct rsnd_priv *priv, struct rsnd_mod *mod, - enum rsnd_reg reg, u32 mask, u32 data) -{ - void __iomem *base = rsnd_gen_reg_get(priv, mod, reg); - struct device *dev = rsnd_priv_to_dev(priv); - u32 val; - - BUG_ON(!base); - - val = ioread32(base); - val = ~mask; - val |= data mask; - iowrite32(val, base); - - dev_dbg(dev, s %p : %08x\n, base, val); -} - /* * rsnd_mod functions */ diff --git a/sound/soc/sh/rcar/gen.c b/sound/soc/sh/rcar/gen.c index 331fc55..9a55fdf 100644 --- a/sound/soc/sh/rcar/gen.c +++ b/sound/soc/sh/rcar/gen.c @@ -24,21 +24,106 @@ struct rsnd_gen_ops { struct rsnd_dai_stream *io); }; -struct rsnd_gen_reg_map { - int index; /* -1 : not supported */ - u32 offset_id; /* offset of ssi0, ssi1, ssi2... */ - u32 offset_adr; /* offset of SSICR, SSISR, ... */ -}; - struct rsnd_gen { void __iomem *base[RSND_BASE_MAX]; - struct rsnd_gen_reg_map reg_map[RSND_REG_MAX]; struct rsnd_gen_ops *ops; + + struct regmap *regmap; + struct regmap_field *regs[RSND_REG_MAX]; }; #define rsnd_priv_to_gen(p)((struct rsnd_gen *)(p)-gen) +#define RSND_REG_SET(gen, id, reg_id, offset, _id_offset, _id_size)\ + [id] = {\ + .reg = (unsigned int)gen-base[reg_id] + offset,\ + .lsb = 0, \ + .msb = 31, \ + .id_size = _id_size,\ + .id_offset = _id_offset,\ + } + +/* + * basic function + */ +static int rsnd_regmap_write32(void *context, const void *_data, size_t count) +{ + struct rsnd_priv *priv = context; + struct device *dev = rsnd_priv_to_dev(priv); + u32 *data = (u32 *)_data; + u32 val = data[1]; + void __iomem *reg = (void *)data[0]; + + iowrite32(val, reg); + + dev_dbg(dev, w %p : %08x\n, reg, val); + + return 0; +} + +static int rsnd_regmap_read32(void *context, + const void *_data, size_t reg_size, + void *_val, size_t val_size) +{ + struct rsnd_priv *priv = context; + struct device *dev = rsnd_priv_to_dev(priv); + u32 *data = (u32 *)_data; + u32 *val = (u32 *)_val; + void __iomem *reg = (void *)data[0]; + + *val = ioread32(reg); + + dev_dbg(dev, r %p : %08x\n, reg, *val); + + return 0; +} + +static struct regmap_bus rsnd_regmap_bus = { + .write = rsnd_regmap_write32, + .read = rsnd_regmap_read32, + .reg_format_endian_default = REGMAP_ENDIAN_NATIVE, + .val_format_endian_default = REGMAP_ENDIAN_NATIVE, +}; + +u32 rsnd_read(struct rsnd_priv *priv, + struct rsnd_mod *mod, enum rsnd_reg reg) +{ + struct rsnd_gen *gen = rsnd_priv_to_gen(priv); + u32 val; + + if (regmap_fields_enable(gen-regs[reg])) + regmap_fields_read(gen-regs[reg], rsnd_mod_id(mod), val); + else + regmap_field_read(gen-regs[reg], val); + + return val; +} + +void rsnd_write(struct rsnd_priv *priv, + struct rsnd_mod *mod, + enum rsnd_reg reg, u32 data) +{ + struct rsnd_gen *gen = rsnd_priv_to_gen(priv); + + if