Advertisement
Guest User

rt5651_cherryview-4.7rc1.patch

a guest
Jun 2nd, 2016
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.73 KB | None | 0 0
  1. diff -Naur linux-4.7-rc1/sound/soc/intel/atom/sst/sst_acpi.c linux-4.7-rc1-cherrytrail/sound/soc/intel/atom/sst/sst_acpi.c
  2. --- linux-4.7-rc1/sound/soc/intel/atom/sst/sst_acpi.c   2016-05-16 00:43:13.000000000 +0200
  3. +++ linux-4.7-rc1-cherrytrail/sound/soc/intel/atom/sst/sst_acpi.c   2016-06-02 10:47:50.030742190 +0200
  4. @@ -342,10 +342,11 @@
  5.                         &chv_platform_data },
  6.     {"193C9890", "cht-bsw-max98090", "intel/fw_sst_22a8.bin", "cht-bsw", NULL,
  7.                         &chv_platform_data },
  8. -   /* some CHT-T platforms rely on RT5640, use Baytrail machine driver */
  9. +   /* some CHT-T platforms rely on RT5640 and RT5651, use Baytrail machine driver */
  10.     {"10EC5640", "bytcr_rt5640", "intel/fw_sst_22a8.bin", "bytcr_rt5640", NULL,
  11.                         &chv_platform_data },
  12. -
  13. +   {"10EC5651", "bytcr_rt5651", "intel/fw_sst_22a8.bin", "bytcr_rt5651", NULL,
  14. +                       &chv_platform_data },
  15.     {},
  16.  };
  17.  
  18. diff -Naur linux-4.7-rc1/sound/soc/intel/boards/bytcr_rt5651.c linux-4.7-rc1-cherrytrail/sound/soc/intel/boards/bytcr_rt5651.c
  19. --- linux-4.7-rc1/sound/soc/intel/boards/bytcr_rt5651.c 2016-06-02 10:13:21.000000000 +0200
  20. +++ linux-4.7-rc1-cherrytrail/sound/soc/intel/boards/bytcr_rt5651.c 2016-06-02 10:46:26.887640425 +0200
  21. @@ -31,11 +31,76 @@
  22.  #include "../../codecs/rt5651.h"
  23.  #include "../atom/sst-atom-controls.h"
  24.  
  25. +#define CHT_PLAT_CLK_3_HZ       19200000
  26. +#define CHT_CODEC_DAI_5651   "rt5651-aif1"
  27. +
  28. +struct cht_acpi_card {
  29. +        char *codec_id;
  30. +        int codec_type;
  31. +        struct snd_soc_card *soc_card;
  32. +};
  33. +
  34. +struct cht_mc_private {
  35. +        struct snd_soc_jack jack;
  36. +        struct cht_acpi_card *acpi_card;
  37. +};
  38. +
  39. +
  40. +static inline struct snd_soc_dai *cht_get_codec_dai(struct snd_soc_card *card)
  41. +{
  42. +        struct snd_soc_pcm_runtime *rtd;
  43. +
  44. +        list_for_each_entry(rtd, &card->rtd_list, list) {
  45. +                if (!strncmp(rtd->codec_dai->name, CHT_CODEC_DAI_5651,
  46. +                             strlen(CHT_CODEC_DAI_5651)))
  47. +                        return rtd->codec_dai;
  48. +        }
  49. +        return NULL;
  50. +}
  51. +
  52. +static int platform_clock_control(struct snd_soc_dapm_widget *w,
  53. +                struct snd_kcontrol *k, int  event)
  54. +{
  55. +        struct snd_soc_dapm_context *dapm = w->dapm;
  56. +        struct snd_soc_card *card = dapm->card;
  57. +        struct snd_soc_dai *codec_dai;
  58. +        int ret;
  59. +
  60. +        codec_dai = cht_get_codec_dai(card);
  61. +        if (!codec_dai) {
  62. +                dev_err(card->dev, "Codec dai not found; Unable to set platform clock\n");
  63. +                return -EIO;
  64. +        }
  65. +
  66. +        if (!SND_SOC_DAPM_EVENT_OFF(event))
  67. +                return 0;
  68. +
  69. +        /* Set codec sysclk source to its internal clock because codec PLL will
  70. +         * be off when idle and MCLK will also be off by ACPI when codec is
  71. +         * runtime suspended. Codec needs clock for jack detection and button
  72. +         * press.
  73. +         */
  74. +        ret = snd_soc_dai_set_sysclk(codec_dai, RT5651_SCLK_S_RCCLK,
  75. +                        0, SND_SOC_CLOCK_IN);
  76. +        if (ret < 0) {
  77. +                dev_err(card->dev, "can't set codec sysclk: %d\n", ret);
  78. +                return ret;
  79. +        }
  80. +
  81. +        return 0;
  82. +}
  83. +
  84. +
  85. +
  86. +
  87.  static const struct snd_soc_dapm_widget byt_rt5651_widgets[] = {
  88.     SND_SOC_DAPM_HP("Headphone", NULL),
  89.     SND_SOC_DAPM_MIC("Headset Mic", NULL),
  90.     SND_SOC_DAPM_MIC("Internal Mic", NULL),
  91.     SND_SOC_DAPM_SPK("Speaker", NULL),
  92. +        SND_SOC_DAPM_SUPPLY("Platform Clock", SND_SOC_NOPM, 0, 0,
  93. +                        platform_clock_control, SND_SOC_DAPM_POST_PMD),
  94. +
  95.  };
  96.  
  97.  static const struct snd_soc_dapm_route byt_rt5651_audio_map[] = {
  98. @@ -52,6 +117,9 @@
  99.     {"Headphone", NULL, "HPOR"},
  100.     {"Speaker", NULL, "LOUTL"},
  101.     {"Speaker", NULL, "LOUTR"},
  102. +        {"Headphone", NULL, "Platform Clock"},
  103. +   {"Speaker", NULL, "Platform Clock"},
  104. +
  105.  };
  106.  
  107.  static const struct snd_soc_dapm_route byt_rt5651_intmic_dmic1_map[] = {
  108. @@ -93,7 +161,13 @@
  109.     struct snd_soc_dai *codec_dai = rtd->codec_dai;
  110.     int ret;
  111.  
  112. -   snd_soc_dai_set_bclk_ratio(codec_dai, 50);
  113. +        /* set codec PLL source to the 19.2MHz platform clock (MCLK) */
  114. +        ret = snd_soc_dai_set_pll(codec_dai, 0, RT5651_PLL1_S_MCLK,
  115. +                                  CHT_PLAT_CLK_3_HZ, params_rate(params) * 512);
  116. +        if (ret < 0) {
  117. +                dev_err(rtd->dev, "can't set codec pll: %d\n", ret);
  118. +                return ret;
  119. +        }
  120.  
  121.     ret = snd_soc_dai_set_sysclk(codec_dai, RT5651_SCLK_S_PLL1,
  122.                      params_rate(params) * 512,
  123. @@ -103,14 +177,6 @@
  124.         return ret;
  125.     }
  126.  
  127. -   ret = snd_soc_dai_set_pll(codec_dai, 0, RT5651_PLL1_S_BCLK1,
  128. -                 params_rate(params) * 50,
  129. -                 params_rate(params) * 512);
  130. -   if (ret < 0) {
  131. -       dev_err(rtd->dev, "can't set codec pll: %d\n", ret);
  132. -       return ret;
  133. -   }
  134. -
  135.     return 0;
  136.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement