ASoC: qcom: lpass: Use regmap_field for i2sctl and dmactl registers
Hello Srini,
Quoted 78 lines · Rohit Kumar
Thanks Srini for reviewing the change.
Quoted 25 lines · Srinivas Kandagatla
Quoted 12 lines · Ajit Pandey
I2SCTL and DMACTL registers has different bits alignment for newer LPASS variants of SC7180 soc. Instead of adding extra overhead for calculating masks and shifts for newer variants registers layout we changed the approach to use
regmap_field_write()API to update bit. Such API's will internally do the required bit shift and mask based onreg_fieldstruct defined for bit fields. We'll defineREG_FIELD()macros with bit layout for both lpass variants and use such macros to initialize register fields in variant specific driver callbacks. Also added new bitfieds values for I2SCTL and DMACTL registers and removed shifts and mask macros for such registers from header file.Signed-off-by Ajit Pandey <[email protected]>Quoted 9 lines
---
sound/soc/qcom/lpass-apq8016.c | 61 ++++++++++++ sound/soc/qcom/lpass-cpu.c | 114 +++++++++++++---------sound/soc/qcom/lpass-lpaif-reg.h| 203
++++++++++++++++++++++++---------------
sound/soc/qcom/lpass-platform.c | 86 +++++++++++------ sound/soc/qcom/lpass.h | 30 ++++++5 files changed, 340 insertions(+), 154 deletions(-)Quoted 3 lines
Thanks for moving this to regmap fields, looks clean!
However this patch just removed support tolpass-ipq806x.cvariant, which should to be taken care of while doing patches that apply to all variants.Right. I will make the change as part of next patchset.
Quoted 36 lines
Quoted 15 lines
sound/soc/qcom/lpass-apq8016.c +6
-0@@ -124,6 +124,32 @@ }, }; +static int apq8016_init_dmactl_bitfields(struct lpaif_dmactl *dmactl, + struct regmap *map, + unsigned int reg) +{ + struct reg_field bursten = DMACTL_BURSTEN_FLD(reg); + struct reg_field wpscnt = DMACTL_WPSCNT_FLD(reg); + struct reg_field fifowm = DMACTL_FIFOWM_FLD(reg);sound/soc/qcom/lpass-apq8016.c line 142
Quoted 10 lines
sound/soc/qcom/lpass-apq8016.c +10
-0+ struct reg_field intf = DMACTL_AUDINTF_FLD(reg); + struct reg_field enable = DMACTL_ENABLE_FLD(reg); + struct reg_field dyncclk = DMACTL_DYNCLK_FLD(reg); + + dmactl->bursten = regmap_field_alloc(map, bursten); + dmactl->wpscnt = regmap_field_alloc(map, wpscnt); + dmactl->fifowm = regmap_field_alloc(map, fifowm); + dmactl->intf = regmap_field_alloc(map, intf); + dmactl->enable = regmap_field_alloc(map, enable); + dmactl->dyncclk = regmap_field_alloc(map, dyncclk);My idea was to move this all regmap fields to variant structure and common code will do the
regmap_filed_allocrather than each variant duplicating the same code for each variant, also am guessing some of the members in thelpass_variantstructure tp become redundant due to regmap field which can be removed as well.ex :
struct
lpass_variant{
...
structreg_fieldbursten
...
};Quoted 9 lines
in
lpass-apq8016.cwe do
static structlpass_variantapq8016_data= {.bursten =
REG_FIELD(reg, 11, 11),
...
}
Quoted 7 lines
We can keep
reg_fieldinlpass_variant, but assignment in the struct will be a problem asreg is variable here. So, we need to expose an API in
lpass_variantto assignreg_field.
regmap_fieldwill still be in dmactl/i2sctl structs as it differs for different dma channel/i2s portrespectively. Please share your thoughts.
While making changes, I felt like there is no significance of keeping reg_field variables inside
lpass_variant struct. Below are the reasons:
* We anyway have to expose an API to fill the regfields as reg is variable in REG_FIELD(reg, 11, 11)
* In case of sc7180, RD_DMA and WR_DMA control register has different field mask. So, values
different for playback and capture. I was thinking of exposing an API which will just fill the reg_field
in the struct passed something like this:
static void apq8016_init_dmactl_regfields(struct lpaif_dmactl_regfields *dmactl, unsigned int reg, int dir)
{
struct reg_field bursten = DMACTL_BURSTEN_FLD(reg);
struct reg_field wpscnt = DMACTL_WPSCNT_FLD(reg);
struct reg_field fifowm = DMACTL_FIFOWM_FLD(reg);
struct reg_field intf = DMACTL_AUDINTF_FLD(reg);
struct reg_field enable = DMACTL_ENABLE_FLD(reg);
struct reg_field dyncclk = DMACTL_DYNCLK_FLD(reg);
dmactl->bursten = bursten;
dmactl->wpscnt = wpscnt;
dmactl->fifowm = fifowm;
dmactl->intf = intf;
dmactl->enable = enable;
dmactl->dyncclk = dyncclk;
}
This will be called by lpass-platform.c where we can do regmap_field_alloc.
So, we will have common function for regmap_field_alloc. Please share your inputs.
Quoted 33 lines
Quoted 4 lines
in
lpass-cpu.cwe can do the realregmap_field_allocasoc_qcom_lpass_cpu_platform_probeYes, I will move
regmap_field_alloctolpass_cpu.cin next patchset.Quoted 23 lines
Quoted 15 lines
sound/soc/qcom/lpass-apq8016.c +9
-0+ + if (IS_ERR(dmactl->bursten) || IS_ERR(dmactl->wpscnt) || + IS_ERR(dmactl->fifowm) || IS_ERR(dmactl->intf) || + IS_ERR(dmactl->enable) || IS_ERR(dmactl->dyncclk)) + return -EINVAL; + + return 0; +} + static int apq8016_lpass_alloc_dma_channel(struct lpass_data *drvdata, int direction) {sound/soc/qcom/lpass-apq8016.c static int · line 189
Quoted 6 lines
sound/soc/qcom/lpass-apq8016.c +2
-0@@ -158,6 +184,39 @@ static int apq8016_lpass_free_dma_channel(struct lpass_data *drvdata, int chan) return 0; } +static int sc7180_init_i2sctl_bitfields(struct lpaif_i2sctl *i2sctl, + struct regmap *map, unsigned int reg) +{Should this be
apq8016_init_i2sctl_bitfieldsQuoted 2 lines
Please make sure that you compile the code before sending it out!
Will take care in next patchset.
Quoted 1 line
Quoted 7 lines
Quoted 3 lines
--srini
Quoted 1 line
Thanks,
Rohit
Thanks,
Rohit
Signature · 2 lines
Qualcomm INDIA, on behalf of Qualcomm Innovation Center, Inc.is a member of the Code Aurora Forum, hosted by the Linux Foundation.