0185-ASoC-mediatek-modify-MT2701-AFE-driver-to-adapt-mfd-.patch 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. From 310ca2954c7cce10d716001ff869bc255494e3df Mon Sep 17 00:00:00 2001
  2. From: Ryder Lee <[email protected]>
  3. Date: Thu, 4 Jan 2018 15:44:08 +0800
  4. Subject: [PATCH 185/224] ASoC: mediatek: modify MT2701 AFE driver to adapt mfd
  5. device
  6. As the new MFD parent is in place, modify MT2701 AFE driver to adapt it.
  7. Signed-off-by: Ryder Lee <[email protected]>
  8. Signed-off-by: Mark Brown <[email protected]>
  9. ---
  10. sound/soc/mediatek/mt2701/mt2701-afe-pcm.c | 45 +++++++++++++-----------------
  11. sound/soc/mediatek/mt2701/mt2701-reg.h | 1 -
  12. 2 files changed, 20 insertions(+), 26 deletions(-)
  13. diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
  14. index 0edadca12a5e..f0cd08fa5c5d 100644
  15. --- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
  16. +++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c
  17. @@ -17,6 +17,7 @@
  18. #include <linux/delay.h>
  19. #include <linux/module.h>
  20. +#include <linux/mfd/syscon.h>
  21. #include <linux/of.h>
  22. #include <linux/of_address.h>
  23. #include <linux/pm_runtime.h>
  24. @@ -1368,14 +1369,6 @@ static const struct mt2701_i2s_data mt2701_i2s_data[MT2701_I2S_NUM][2] = {
  25. },
  26. };
  27. -static const struct regmap_config mt2701_afe_regmap_config = {
  28. - .reg_bits = 32,
  29. - .reg_stride = 4,
  30. - .val_bits = 32,
  31. - .max_register = AFE_END_ADDR,
  32. - .cache_type = REGCACHE_NONE,
  33. -};
  34. -
  35. static irqreturn_t mt2701_asys_isr(int irq_id, void *dev)
  36. {
  37. int id;
  38. @@ -1414,9 +1407,9 @@ static int mt2701_afe_runtime_resume(struct device *dev)
  39. static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
  40. {
  41. + struct snd_soc_component *component;
  42. struct mtk_base_afe *afe;
  43. struct mt2701_afe_private *afe_priv;
  44. - struct resource *res;
  45. struct device *dev;
  46. int i, irq_id, ret;
  47. @@ -1446,17 +1439,11 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
  48. return ret;
  49. }
  50. - res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
  51. -
  52. - afe->base_addr = devm_ioremap_resource(&pdev->dev, res);
  53. -
  54. - if (IS_ERR(afe->base_addr))
  55. - return PTR_ERR(afe->base_addr);
  56. -
  57. - afe->regmap = devm_regmap_init_mmio(&pdev->dev, afe->base_addr,
  58. - &mt2701_afe_regmap_config);
  59. - if (IS_ERR(afe->regmap))
  60. - return PTR_ERR(afe->regmap);
  61. + afe->regmap = syscon_node_to_regmap(dev->parent->of_node);
  62. + if (!afe->regmap) {
  63. + dev_err(dev, "could not get regmap from parent\n");
  64. + return -ENODEV;
  65. + }
  66. mutex_init(&afe->irq_alloc_lock);
  67. @@ -1490,6 +1477,12 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
  68. = &mt2701_i2s_data[i][I2S_IN];
  69. }
  70. + component = kzalloc(sizeof(*component), GFP_KERNEL);
  71. + if (!component)
  72. + return -ENOMEM;
  73. +
  74. + component->regmap = afe->regmap;
  75. +
  76. afe->mtk_afe_hardware = &mt2701_afe_hardware;
  77. afe->memif_fs = mt2701_memif_fs;
  78. afe->irq_fs = mt2701_irq_fs;
  79. @@ -1502,7 +1495,7 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
  80. ret = mt2701_init_clock(afe);
  81. if (ret) {
  82. dev_err(dev, "init clock error\n");
  83. - return ret;
  84. + goto err_init_clock;
  85. }
  86. platform_set_drvdata(pdev, afe);
  87. @@ -1521,10 +1514,10 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
  88. goto err_platform;
  89. }
  90. - ret = snd_soc_register_component(&pdev->dev,
  91. - &mt2701_afe_pcm_dai_component,
  92. - mt2701_afe_pcm_dais,
  93. - ARRAY_SIZE(mt2701_afe_pcm_dais));
  94. + ret = snd_soc_add_component(dev, component,
  95. + &mt2701_afe_pcm_dai_component,
  96. + mt2701_afe_pcm_dais,
  97. + ARRAY_SIZE(mt2701_afe_pcm_dais));
  98. if (ret) {
  99. dev_warn(dev, "err_dai_component\n");
  100. goto err_dai_component;
  101. @@ -1538,6 +1531,8 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev)
  102. pm_runtime_put_sync(dev);
  103. err_pm_disable:
  104. pm_runtime_disable(dev);
  105. +err_init_clock:
  106. + kfree(component);
  107. return ret;
  108. }
  109. diff --git a/sound/soc/mediatek/mt2701/mt2701-reg.h b/sound/soc/mediatek/mt2701/mt2701-reg.h
  110. index f17c76f37b5f..18e676974f22 100644
  111. --- a/sound/soc/mediatek/mt2701/mt2701-reg.h
  112. +++ b/sound/soc/mediatek/mt2701/mt2701-reg.h
  113. @@ -145,5 +145,4 @@
  114. #define ASYS_I2S_CON_WIDE_MODE_SET(x) ((x) << 1)
  115. #define ASYS_I2S_IN_PHASE_FIX (0x1 << 31)
  116. -#define AFE_END_ADDR 0x15e0
  117. #endif
  118. --
  119. 2.11.0