aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIcenowy Zheng <icenowy@aosc.xyz>2017-06-05 09:27:22 -0400
committerMark Brown <broonie@kernel.org>2017-06-06 14:30:00 -0400
commit8b2840b6daca728cecfa925b50bf638189e2fbca (patch)
tree55e531df1ea02090531166d5bc5c9f54caeb3a77
parent2cfeaec0ec896bc0b8aad2de28a3de4572c7e4a1 (diff)
ASoC: sun4i-codec: Add support for V3s codec
The codec in the V3s is similar to the one found on the A31. One key difference is the analog path controls are routed through the PRCM block. This is supported by the sun8i-codec-analog driver, and tied into this codec driver with the audio card's aux_dev. In addition, the V3s does not have LINEIN, LINEOUT, MBIAS and MIC2, MIC3, and the FIFO related registers are like H3. Signed-off-by: Icenowy Zheng <icenowy@aosc.xyz> Reviewed-by: Chen-Yu Tsai <wens@csie.org> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Mark Brown <broonie@kernel.org>
-rw-r--r--Documentation/devicetree/bindings/sound/sun4i-codec.txt11
-rw-r--r--sound/soc/sunxi/sun4i-codec.c63
2 files changed, 70 insertions, 4 deletions
diff --git a/Documentation/devicetree/bindings/sound/sun4i-codec.txt b/Documentation/devicetree/bindings/sound/sun4i-codec.txt
index 3863531d1e6d..2d4e10deb6f4 100644
--- a/Documentation/devicetree/bindings/sound/sun4i-codec.txt
+++ b/Documentation/devicetree/bindings/sound/sun4i-codec.txt
@@ -7,6 +7,7 @@ Required properties:
7 - "allwinner,sun7i-a20-codec" 7 - "allwinner,sun7i-a20-codec"
8 - "allwinner,sun8i-a23-codec" 8 - "allwinner,sun8i-a23-codec"
9 - "allwinner,sun8i-h3-codec" 9 - "allwinner,sun8i-h3-codec"
10 - "allwinner,sun8i-v3s-codec"
10- reg: must contain the registers location and length 11- reg: must contain the registers location and length
11- interrupts: must contain the codec interrupt 12- interrupts: must contain the codec interrupt
12- dmas: DMA channels for tx and rx dma. See the DMA client binding, 13- dmas: DMA channels for tx and rx dma. See the DMA client binding,
@@ -25,6 +26,7 @@ Required properties for the following compatibles:
25 - "allwinner,sun6i-a31-codec" 26 - "allwinner,sun6i-a31-codec"
26 - "allwinner,sun8i-a23-codec" 27 - "allwinner,sun8i-a23-codec"
27 - "allwinner,sun8i-h3-codec" 28 - "allwinner,sun8i-h3-codec"
29 - "allwinner,sun8i-v3s-codec"
28- resets: phandle to the reset control for this device 30- resets: phandle to the reset control for this device
29- allwinner,audio-routing: A list of the connections between audio components. 31- allwinner,audio-routing: A list of the connections between audio components.
30 Each entry is a pair of strings, the first being the 32 Each entry is a pair of strings, the first being the
@@ -34,15 +36,15 @@ Required properties for the following compatibles:
34 Audio pins on the SoC: 36 Audio pins on the SoC:
35 "HP" 37 "HP"
36 "HPCOM" 38 "HPCOM"
37 "LINEIN" 39 "LINEIN" (not on sun8i-v3s)
38 "LINEOUT" (not on sun8i-a23) 40 "LINEOUT" (not on sun8i-a23 or sun8i-v3s)
39 "MIC1" 41 "MIC1"
40 "MIC2" 42 "MIC2" (not on sun8i-v3s)
41 "MIC3" (sun6i-a31 only) 43 "MIC3" (sun6i-a31 only)
42 44
43 Microphone biases from the SoC: 45 Microphone biases from the SoC:
44 "HBIAS" 46 "HBIAS"
45 "MBIAS" 47 "MBIAS" (not on sun8i-v3s)
46 48
47 Board connectors: 49 Board connectors:
48 "Headphone" 50 "Headphone"
@@ -55,6 +57,7 @@ Required properties for the following compatibles:
55Required properties for the following compatibles: 57Required properties for the following compatibles:
56 - "allwinner,sun8i-a23-codec" 58 - "allwinner,sun8i-a23-codec"
57 - "allwinner,sun8i-h3-codec" 59 - "allwinner,sun8i-h3-codec"
60 - "allwinner,sun8i-v3s-codec"
58- allwinner,codec-analog-controls: A phandle to the codec analog controls 61- allwinner,codec-analog-controls: A phandle to the codec analog controls
59 block in the PRCM. 62 block in the PRCM.
60 63
diff --git a/sound/soc/sunxi/sun4i-codec.c b/sound/soc/sunxi/sun4i-codec.c
index c3aab10fa085..150069987c0c 100644
--- a/sound/soc/sunxi/sun4i-codec.c
+++ b/sound/soc/sunxi/sun4i-codec.c
@@ -1339,6 +1339,44 @@ static struct snd_soc_card *sun8i_h3_codec_create_card(struct device *dev)
1339 return card; 1339 return card;
1340}; 1340};
1341 1341
1342static struct snd_soc_card *sun8i_v3s_codec_create_card(struct device *dev)
1343{
1344 struct snd_soc_card *card;
1345 int ret;
1346
1347 card = devm_kzalloc(dev, sizeof(*card), GFP_KERNEL);
1348 if (!card)
1349 return ERR_PTR(-ENOMEM);
1350
1351 aux_dev.codec_of_node = of_parse_phandle(dev->of_node,
1352 "allwinner,codec-analog-controls",
1353 0);
1354 if (!aux_dev.codec_of_node) {
1355 dev_err(dev, "Can't find analog controls for codec.\n");
1356 return ERR_PTR(-EINVAL);
1357 };
1358
1359 card->dai_link = sun4i_codec_create_link(dev, &card->num_links);
1360 if (!card->dai_link)
1361 return ERR_PTR(-ENOMEM);
1362
1363 card->dev = dev;
1364 card->name = "V3s Audio Codec";
1365 card->dapm_widgets = sun6i_codec_card_dapm_widgets;
1366 card->num_dapm_widgets = ARRAY_SIZE(sun6i_codec_card_dapm_widgets);
1367 card->dapm_routes = sun8i_codec_card_routes;
1368 card->num_dapm_routes = ARRAY_SIZE(sun8i_codec_card_routes);
1369 card->aux_dev = &aux_dev;
1370 card->num_aux_devs = 1;
1371 card->fully_routed = true;
1372
1373 ret = snd_soc_of_parse_audio_routing(card, "allwinner,audio-routing");
1374 if (ret)
1375 dev_warn(dev, "failed to parse audio-routing: %d\n", ret);
1376
1377 return card;
1378};
1379
1342static const struct regmap_config sun4i_codec_regmap_config = { 1380static const struct regmap_config sun4i_codec_regmap_config = {
1343 .reg_bits = 32, 1381 .reg_bits = 32,
1344 .reg_stride = 4, 1382 .reg_stride = 4,
@@ -1374,6 +1412,13 @@ static const struct regmap_config sun8i_h3_codec_regmap_config = {
1374 .max_register = SUN8I_H3_CODEC_ADC_DBG, 1412 .max_register = SUN8I_H3_CODEC_ADC_DBG,
1375}; 1413};
1376 1414
1415static const struct regmap_config sun8i_v3s_codec_regmap_config = {
1416 .reg_bits = 32,
1417 .reg_stride = 4,
1418 .val_bits = 32,
1419 .max_register = SUN8I_H3_CODEC_ADC_DBG,
1420};
1421
1377struct sun4i_codec_quirks { 1422struct sun4i_codec_quirks {
1378 const struct regmap_config *regmap_config; 1423 const struct regmap_config *regmap_config;
1379 const struct snd_soc_codec_driver *codec; 1424 const struct snd_soc_codec_driver *codec;
@@ -1437,6 +1482,20 @@ static const struct sun4i_codec_quirks sun8i_h3_codec_quirks = {
1437 .has_reset = true, 1482 .has_reset = true,
1438}; 1483};
1439 1484
1485static const struct sun4i_codec_quirks sun8i_v3s_codec_quirks = {
1486 .regmap_config = &sun8i_v3s_codec_regmap_config,
1487 /*
1488 * TODO The codec structure should be split out, like
1489 * H3, when adding digital audio processing support.
1490 */
1491 .codec = &sun8i_a23_codec_codec,
1492 .create_card = sun8i_v3s_codec_create_card,
1493 .reg_adc_fifoc = REG_FIELD(SUN6I_CODEC_ADC_FIFOC, 0, 31),
1494 .reg_dac_txdata = SUN8I_H3_CODEC_DAC_TXDATA,
1495 .reg_adc_rxdata = SUN6I_CODEC_ADC_RXDATA,
1496 .has_reset = true,
1497};
1498
1440static const struct of_device_id sun4i_codec_of_match[] = { 1499static const struct of_device_id sun4i_codec_of_match[] = {
1441 { 1500 {
1442 .compatible = "allwinner,sun4i-a10-codec", 1501 .compatible = "allwinner,sun4i-a10-codec",
@@ -1458,6 +1517,10 @@ static const struct of_device_id sun4i_codec_of_match[] = {
1458 .compatible = "allwinner,sun8i-h3-codec", 1517 .compatible = "allwinner,sun8i-h3-codec",
1459 .data = &sun8i_h3_codec_quirks, 1518 .data = &sun8i_h3_codec_quirks,
1460 }, 1519 },
1520 {
1521 .compatible = "allwinner,sun8i-v3s-codec",
1522 .data = &sun8i_v3s_codec_quirks,
1523 },
1461 {} 1524 {}
1462}; 1525};
1463MODULE_DEVICE_TABLE(of, sun4i_codec_of_match); 1526MODULE_DEVICE_TABLE(of, sun4i_codec_of_match);