Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1699326 > unrolled thread
| Started by | codekipper@gmail.com |
|---|---|
| First post | 2017-07-29 16:20 +0200 |
| Last post | 2017-07-31 09:10 +0200 |
| Articles | 7 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH v3 00/12] ASoC: Add I2S support for Allwinner H3 SoCs codekipper@gmail.com - 2017-07-29 16:20 +0200
[PATCH v3 05/12] ASoC: sun4i-i2s: Add regmap fields for channels codekipper@gmail.com - 2017-07-29 16:20 +0200
Re: [alsa-devel] [PATCH v3 05/12] ASoC: sun4i-i2s: Add regmap fields for channels kbuild test robot <lkp@intel.com> - 2017-07-30 18:50 +0200
[PATCH] ASoC: sun4i-i2s: fix ptr_ret.cocci warnings kbuild test robot <lkp@intel.com> - 2017-07-30 18:50 +0200
[PATCH v3 03/12] ASoC: sun4i-i2s: Add regmap config to quirks codekipper@gmail.com - 2017-07-29 16:30 +0200
[PATCH v3 01/12] ASoC: sun4i-i2s: Extend quirks scope codekipper@gmail.com - 2017-07-29 16:30 +0200
Re: [linux-sunxi] [PATCH v3 00/12] ASoC: Add I2S support for Allwinner H3 SoCs Olliver Schinagl <oliver+list@schinagl.nl> - 2017-07-31 09:10 +0200
| From | codekipper@gmail.com |
|---|---|
| Date | 2017-07-29 16:20 +0200 |
| Subject | [PATCH v3 00/12] ASoC: Add I2S support for Allwinner H3 SoCs |
| Message-ID | <u8AKZ-3qk-3@gated-at.bofh.it> |
From: Marcus Cooper <codekipper@gmail.com> Hi All, please find attached a series of patches to bring i2s support to the Allwinner H3 SoC. This has been tested with the following setups: A20 Olimex EVB connected to a pcm5102 Orange Pi 2 connected to a uda1380 Orange Pi 2 hdmi audio playback Pine 64 connected to the audio DAC board To get i2s working some additional patches are required which will be delivered later. For now they have been pushed here https://github.com/codekipper/linux-sunxi/commits/sunxi-audio-h3 I don't own a A33 device which uses the i2s block for the audio codec so if someone could test against that it would be much appreciated. I'm also wondering if there is a preferred way of setting the lrclk size in the dts?..currently it is set to the sample width but for example the pcm5102a wants it to be 32 bits whatever the sample rate. Thanks in advance, CK --- v3 changes compared to v2 are: - initial changes to prepare driver for newer SoCs has been broken down into smaller patches - reduce use of regmap fields to where just needed. - clkdiv expansion will be delivered later. - defines for H3 variant segregated. - fixed regmap config issue with SUN8I_I2S_FIFO_TX_REG. v2 changes compared to v1 are: - massive refactoring to remove duplicate code making use of regmap_fields. - extending the clock divisors. - removed code that should be delivered when we support 20/24bits --- Marcus Cooper (12): ASoC: sun4i-i2s: Extend quirks scope ASoC: sun4i-i2s: Add clkdiv offsets to quirks ASoC: sun4i-i2s: Add regmap config to quirks ASoC: sun4i-i2s: Add TX FIFO offset to quirks ASoC: sun4i-i2s: Add regmap fields for channels ASoC: sun4i-i2s: Add changes for wss and sr ASoC: sun4i-i2s: bclk and lrclk polarity tidyup ASoC: sun4i-i2s: Add mclk enable regmap field ASoC: sun4i-i2s: Add regmap field to set format ASoC: sun4i-i2s: Check for slave select bit ASoC: sun4i-i2s: Update global enable with bitmask ASoC: sun4i-i2s: Add support for H3 .../devicetree/bindings/sound/sun4i-i2s.txt | 2 + sound/soc/sunxi/sun4i-i2s.c | 460 ++++++++++++++++++--- 2 files changed, 398 insertions(+), 64 deletions(-) -- 2.13.3
[toc] | [next] | [standalone]
| From | codekipper@gmail.com |
|---|---|
| Date | 2017-07-29 16:20 +0200 |
| Subject | [PATCH v3 05/12] ASoC: sun4i-i2s: Add regmap fields for channels |
| Message-ID | <u8AL0-3qk-23@gated-at.bofh.it> |
| In reply to | #1699326 |
From: Marcus Cooper <codekipper@gmail.com>
On the original i2s block the channel mapping and selection were
configured for stereo audio by default: This is not the case with
the newer SoCs and they are also located at different offsets.
To support the newer SoC then regmap fields have been added to the
quirks and these are initialised to their correct settings during
probing.
Signed-off-by: Marcus Cooper <codekipper@gmail.com>
---
sound/soc/sunxi/sun4i-i2s.c | 80 ++++++++++++++++++++++++++++++++++++++++-----
1 file changed, 72 insertions(+), 8 deletions(-)
diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index 2a25df22c2f8..120f797a38e8 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -82,7 +82,7 @@
#define SUN4I_I2S_TX_CNT_REG 0x2c
#define SUN4I_I2S_TX_CHAN_SEL_REG 0x30
-#define SUN4I_I2S_TX_CHAN_SEL(num_chan) (((num_chan) - 1) << 0)
+#define SUN4I_I2S_CHAN_SEL(num_chan) (((num_chan) - 1) << 0)
#define SUN4I_I2S_TX_CHAN_MAP_REG 0x34
#define SUN4I_I2S_TX_CHAN_MAP(chan, sample) ((sample) << (chan << 2))
@@ -98,6 +98,10 @@
* @sun4i_i2s_regmap: regmap config to use.
* @mclk_offset: Value by which mclkdiv needs to be adjusted.
* @bclk_offset: Value by which bclkdiv needs to be adjusted.
+ * @field_txchanmap: location of the tx channel mapping register.
+ * @field_rxchanmap: location of the rx channel mapping register.
+ * @field_txchansel: location of the tx channel select bit fields.
+ * @field_rxchansel: location of the rx channel select bit fields.
*/
struct sun4i_i2s_quirks {
bool has_reset;
@@ -105,6 +109,12 @@ struct sun4i_i2s_quirks {
const struct regmap_config *sun4i_i2s_regmap;
unsigned int mclk_offset;
unsigned int bclk_offset;
+
+ /* Register fields for i2s */
+ struct reg_field field_txchanmap;
+ struct reg_field field_rxchanmap;
+ struct reg_field field_txchansel;
+ struct reg_field field_rxchansel;
};
struct sun4i_i2s {
@@ -118,6 +128,12 @@ struct sun4i_i2s {
struct snd_dmaengine_dai_dma_data capture_dma_data;
struct snd_dmaengine_dai_dma_data playback_dma_data;
+ /* Register fields for i2s */
+ struct regmap_field *field_txchanmap;
+ struct regmap_field *field_rxchanmap;
+ struct regmap_field *field_txchansel;
+ struct regmap_field *field_rxchansel;
+
const struct sun4i_i2s_quirks *variant;
};
@@ -264,6 +280,18 @@ static int sun4i_i2s_hw_params(struct snd_pcm_substream *substream,
if (params_channels(params) != 2)
return -EINVAL;
+ /* Map the channels for playback and capture */
+ regmap_field_write(i2s->field_txchanmap, 0x76543210);
+ regmap_field_write(i2s->field_rxchanmap, 0x00003210);
+
+ /* Configure the channels */
+ regmap_field_write(i2s->field_txchansel,
+ SUN4I_I2S_CHAN_SEL(params_channels(params)));
+
+ regmap_field_write(i2s->field_rxchansel,
+ SUN4I_I2S_CHAN_SEL(params_channels(params)));
+
+
switch (params_physical_width(params)) {
case 16:
width = DMA_SLAVE_BUSWIDTH_2_BYTES;
@@ -486,13 +514,6 @@ static int sun4i_i2s_startup(struct snd_pcm_substream *substream,
SUN4I_I2S_CTRL_SDO_EN_MASK,
SUN4I_I2S_CTRL_SDO_EN(0));
- /* Enable the first two channels */
- regmap_write(i2s->regmap, SUN4I_I2S_TX_CHAN_SEL_REG,
- SUN4I_I2S_TX_CHAN_SEL(2));
-
- /* Map them to the two first samples coming in */
- regmap_write(i2s->regmap, SUN4I_I2S_TX_CHAN_MAP_REG,
- SUN4I_I2S_TX_CHAN_MAP(0, 0) | SUN4I_I2S_TX_CHAN_MAP(1, 1));
return clk_prepare_enable(i2s->mod_clk);
}
@@ -677,14 +698,51 @@ static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks = {
.has_reset = false,
.reg_offset_txdata = SUN4I_I2S_FIFO_TX_REG,
.sun4i_i2s_regmap = &sun4i_i2s_regmap_config,
+ .field_txchanmap = REG_FIELD(SUN4I_I2S_TX_CHAN_MAP_REG, 0, 31),
+ .field_rxchanmap = REG_FIELD(SUN4I_I2S_RX_CHAN_MAP_REG, 0, 31),
+ .field_txchansel = REG_FIELD(SUN4I_I2S_TX_CHAN_SEL_REG, 0, 2),
+ .field_rxchansel = REG_FIELD(SUN4I_I2S_RX_CHAN_SEL_REG, 0, 2),
};
static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = {
.has_reset = true,
.reg_offset_txdata = SUN4I_I2S_FIFO_TX_REG,
.sun4i_i2s_regmap = &sun4i_i2s_regmap_config,
+ .field_txchanmap = REG_FIELD(SUN4I_I2S_TX_CHAN_MAP_REG, 0, 31),
+ .field_rxchanmap = REG_FIELD(SUN4I_I2S_RX_CHAN_MAP_REG, 0, 31),
+ .field_txchansel = REG_FIELD(SUN4I_I2S_TX_CHAN_SEL_REG, 0, 2),
+ .field_rxchansel = REG_FIELD(SUN4I_I2S_RX_CHAN_SEL_REG, 0, 2),
};
+static int sun4i_i2s_init_regmap_fields(struct device *dev, struct sun4i_i2s *i2s)
+{
+ i2s->field_txchanmap =
+ devm_regmap_field_alloc(dev, i2s->regmap,
+ i2s->variant->field_txchanmap);
+ if (IS_ERR(i2s->field_txchanmap))
+ return PTR_ERR(i2s->field_txchanmap);
+
+ i2s->field_rxchanmap =
+ devm_regmap_field_alloc(dev, i2s->regmap,
+ i2s->variant->field_rxchanmap);
+ if (IS_ERR(i2s->field_rxchanmap))
+ return PTR_ERR(i2s->field_rxchanmap);
+
+ i2s->field_txchansel =
+ devm_regmap_field_alloc(dev, i2s->regmap,
+ i2s->variant->field_txchansel);
+ if (IS_ERR(i2s->field_txchansel))
+ return PTR_ERR(i2s->field_txchansel);
+
+ i2s->field_rxchansel =
+ devm_regmap_field_alloc(dev, i2s->regmap,
+ i2s->variant->field_rxchansel);
+ if (IS_ERR(i2s->field_rxchansel))
+ return PTR_ERR(i2s->field_rxchansel);
+
+ return 0;
+}
+
static int sun4i_i2s_probe(struct platform_device *pdev)
{
struct sun4i_i2s *i2s;
@@ -778,6 +836,12 @@ static int sun4i_i2s_probe(struct platform_device *pdev)
goto err_suspend;
}
+ ret = sun4i_i2s_init_regmap_fields(&pdev->dev, i2s);
+ if (ret) {
+ dev_err(&pdev->dev, "Could not initialise regmap fields\n");
+ goto err_suspend;
+ }
+
return 0;
err_suspend:
--
2.13.3
[toc] | [prev] | [next] | [standalone]
| From | kbuild test robot <lkp@intel.com> |
|---|---|
| Date | 2017-07-30 18:50 +0200 |
| Subject | Re: [alsa-devel] [PATCH v3 05/12] ASoC: sun4i-i2s: Add regmap fields for channels |
| Message-ID | <u8ZzI-2LG-11@gated-at.bofh.it> |
| In reply to | #1699327 |
Hi Marcus, [auto build test WARNING on asoc/for-next] [also build test WARNING on next-20170728] [cannot apply to v4.13-rc2] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/codekipper-gmail-com/ASoC-Add-I2S-support-for-Allwinner-H3-SoCs/20170730-220649 base: https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next coccinelle warnings: (new ones prefixed by >>) >> sound/soc/sunxi/sun4i-i2s.c:740:1-3: WARNING: PTR_ERR_OR_ZERO can be used Please review and possibly fold the followup patch. --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
[toc] | [prev] | [next] | [standalone]
| From | kbuild test robot <lkp@intel.com> |
|---|---|
| Date | 2017-07-30 18:50 +0200 |
| Subject | [PATCH] ASoC: sun4i-i2s: fix ptr_ret.cocci warnings |
| Message-ID | <u8ZzI-2LG-15@gated-at.bofh.it> |
| In reply to | #1699327 |
sound/soc/sunxi/sun4i-i2s.c:740:1-3: WARNING: PTR_ERR_OR_ZERO can be used
Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR
Generated by: scripts/coccinelle/api/ptr_ret.cocci
Fixes: 298207690de9 ("ASoC: sun4i-i2s: Add regmap fields for channels")
CC: Marcus Cooper <codekipper@gmail.com>
Signed-off-by: Fengguang Wu <fengguang.wu@intel.com>
---
sun4i-i2s.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -737,10 +737,7 @@ static int sun4i_i2s_init_regmap_fields(
i2s->field_rxchansel =
devm_regmap_field_alloc(dev, i2s->regmap,
i2s->variant->field_rxchansel);
- if (IS_ERR(i2s->field_rxchansel))
- return PTR_ERR(i2s->field_rxchansel);
-
- return 0;
+ return PTR_ERR_OR_ZERO(i2s->field_rxchansel);
}
static int sun4i_i2s_probe(struct platform_device *pdev)
[toc] | [prev] | [next] | [standalone]
| From | codekipper@gmail.com |
|---|---|
| Date | 2017-07-29 16:30 +0200 |
| Subject | [PATCH v3 03/12] ASoC: sun4i-i2s: Add regmap config to quirks |
| Message-ID | <u8AUF-3uX-1@gated-at.bofh.it> |
| In reply to | #1699326 |
From: Marcus Cooper <codekipper@gmail.com>
The newer SoCs have a larger range than the original SoC that this
driver was developed for. By adding the regmap config to the quirks
then the driver can initialise the managed register map correctly.
Signed-off-by: Marcus Cooper <codekipper@gmail.com>
---
sound/soc/sunxi/sun4i-i2s.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index 1d538de4e4d0..73e991f5a81e 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -94,11 +94,13 @@
* struct sun4i_i2s_quirks - Differences between SoC variants.
*
* @has_reset: SoC needs reset deasserted.
+ * @sun4i_i2s_regmap: regmap config to use.
* @mclk_offset: Value by which mclkdiv needs to be adjusted.
* @bclk_offset: Value by which bclkdiv needs to be adjusted.
*/
struct sun4i_i2s_quirks {
bool has_reset;
+ const struct regmap_config *sun4i_i2s_regmap;
unsigned int mclk_offset;
unsigned int bclk_offset;
};
@@ -670,11 +672,13 @@ static int sun4i_i2s_runtime_suspend(struct device *dev)
}
static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks = {
- .has_reset = false,
+ .has_reset = false,
+ .sun4i_i2s_regmap = &sun4i_i2s_regmap_config,
};
static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = {
- .has_reset = true,
+ .has_reset = true,
+ .sun4i_i2s_regmap = &sun4i_i2s_regmap_config,
};
static int sun4i_i2s_probe(struct platform_device *pdev)
@@ -713,7 +717,7 @@ static int sun4i_i2s_probe(struct platform_device *pdev)
}
i2s->regmap = devm_regmap_init_mmio(&pdev->dev, regs,
- &sun4i_i2s_regmap_config);
+ i2s->variant->sun4i_i2s_regmap);
if (IS_ERR(i2s->regmap)) {
dev_err(&pdev->dev, "Regmap initialisation failed\n");
return PTR_ERR(i2s->regmap);
--
2.13.3
[toc] | [prev] | [next] | [standalone]
| From | codekipper@gmail.com |
|---|---|
| Date | 2017-07-29 16:30 +0200 |
| Subject | [PATCH v3 01/12] ASoC: sun4i-i2s: Extend quirks scope |
| Message-ID | <u8AUG-3uX-11@gated-at.bofh.it> |
| In reply to | #1699326 |
From: Marcus Cooper <codekipper@gmail.com>
In preparation for the changes required to support newer SoCs then
quirks has been moved and also added to the device structure.
Signed-off-by: Marcus Cooper <codekipper@gmail.com>
---
sound/soc/sunxi/sun4i-i2s.c | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/sound/soc/sunxi/sun4i-i2s.c b/sound/soc/sunxi/sun4i-i2s.c
index 62b307b0c846..d7ee7a443e4e 100644
--- a/sound/soc/sunxi/sun4i-i2s.c
+++ b/sound/soc/sunxi/sun4i-i2s.c
@@ -90,6 +90,15 @@
#define SUN4I_I2S_RX_CHAN_SEL_REG 0x38
#define SUN4I_I2S_RX_CHAN_MAP_REG 0x3c
+/**
+ * struct sun4i_i2s_quirks - Differences between SoC variants.
+ *
+ * @has_reset: SoC needs reset deasserted.
+ */
+struct sun4i_i2s_quirks {
+ bool has_reset;
+};
+
struct sun4i_i2s {
struct clk *bus_clk;
struct clk *mod_clk;
@@ -100,6 +109,8 @@ struct sun4i_i2s {
struct snd_dmaengine_dai_dma_data capture_dma_data;
struct snd_dmaengine_dai_dma_data playback_dma_data;
+
+ const struct sun4i_i2s_quirks *variant;
};
struct sun4i_i2s_clk_div {
@@ -654,10 +665,6 @@ static int sun4i_i2s_runtime_suspend(struct device *dev)
return 0;
}
-struct sun4i_i2s_quirks {
- bool has_reset;
-};
-
static const struct sun4i_i2s_quirks sun4i_a10_i2s_quirks = {
.has_reset = false,
};
@@ -669,7 +676,6 @@ static const struct sun4i_i2s_quirks sun6i_a31_i2s_quirks = {
static int sun4i_i2s_probe(struct platform_device *pdev)
{
struct sun4i_i2s *i2s;
- const struct sun4i_i2s_quirks *quirks;
struct resource *res;
void __iomem *regs;
int irq, ret;
@@ -690,8 +696,8 @@ static int sun4i_i2s_probe(struct platform_device *pdev)
return irq;
}
- quirks = of_device_get_match_data(&pdev->dev);
- if (!quirks) {
+ i2s->variant = of_device_get_match_data(&pdev->dev);
+ if (!i2s->variant) {
dev_err(&pdev->dev, "Failed to determine the quirks to use\n");
return -ENODEV;
}
@@ -715,7 +721,7 @@ static int sun4i_i2s_probe(struct platform_device *pdev)
return PTR_ERR(i2s->mod_clk);
}
- if (quirks->has_reset) {
+ if (i2s->variant->has_reset) {
i2s->rst = devm_reset_control_get_exclusive(&pdev->dev, NULL);
if (IS_ERR(i2s->rst)) {
dev_err(&pdev->dev, "Failed to get reset control\n");
--
2.13.3
[toc] | [prev] | [next] | [standalone]
| From | Olliver Schinagl <oliver+list@schinagl.nl> |
|---|---|
| Date | 2017-07-31 09:10 +0200 |
| Subject | Re: [linux-sunxi] [PATCH v3 00/12] ASoC: Add I2S support for Allwinner H3 SoCs |
| Message-ID | <u9cZZ-3eT-11@gated-at.bofh.it> |
| In reply to | #1699326 |
Hey Marcus, On 29-07-17 16:17, codekipper@gmail.com wrote: > From: Marcus Cooper <codekipper@gmail.com> > > Hi All, > please find attached a series of patches to bring i2s support to the > Allwinner H3 SoC. This has been tested with the following setups: > > A20 Olimex EVB connected to a pcm5102 But that's not an H3 is it? :) > Orange Pi 2 connected to a uda1380 > Orange Pi 2 hdmi audio playback > Pine 64 connected to the audio DAC board > > To get i2s working some additional patches are required which will be > delivered later. For now they have been pushed here > > https://github.com/codekipper/linux-sunxi/commits/sunxi-audio-h3 Since I want to use i2s on the A20, i'm trying out your patches. It would be helpfull if you could point out which patches are missing (and if the subject doesn't cover it why those are needed) > > I don't own a A33 device which uses the i2s block for the audio codec > so if someone could test against that it would be much appreciated. > > I'm also wondering if there is a preferred way of setting the lrclk > size in the dts?..currently it is set to the sample width but for example > the pcm5102a wants it to be 32 bits whatever the sample rate. > > Thanks in advance, > CK > > --- > > v3 changes compared to v2 are: > - initial changes to prepare driver for newer SoCs has been broken down > into smaller patches > - reduce use of regmap fields to where just needed. > - clkdiv expansion will be delivered later. > - defines for H3 variant segregated. > - fixed regmap config issue with SUN8I_I2S_FIFO_TX_REG. > > > v2 changes compared to v1 are: > - massive refactoring to remove duplicate code making use of regmap_fields. > - extending the clock divisors. > - removed code that should be delivered when we support 20/24bits > > --- > > Marcus Cooper (12): > ASoC: sun4i-i2s: Extend quirks scope > ASoC: sun4i-i2s: Add clkdiv offsets to quirks > ASoC: sun4i-i2s: Add regmap config to quirks > ASoC: sun4i-i2s: Add TX FIFO offset to quirks > ASoC: sun4i-i2s: Add regmap fields for channels > ASoC: sun4i-i2s: Add changes for wss and sr > ASoC: sun4i-i2s: bclk and lrclk polarity tidyup > ASoC: sun4i-i2s: Add mclk enable regmap field > ASoC: sun4i-i2s: Add regmap field to set format > ASoC: sun4i-i2s: Check for slave select bit > ASoC: sun4i-i2s: Update global enable with bitmask > ASoC: sun4i-i2s: Add support for H3 > > .../devicetree/bindings/sound/sun4i-i2s.txt | 2 + > sound/soc/sunxi/sun4i-i2s.c | 460 ++++++++++++++++++--- > 2 files changed, 398 insertions(+), 64 deletions(-) >
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web