ASoC: mediatek: Set i2s clock sharing from machine drivers
Subsystems (4)
cover ASoC: mediatek: Set i2s clock sharing from machine drivers
The i2s ports on MediaTek SoCs only support a single data lane. In order to achieve full-duplex operation thus two i2s ports, one for input and one for output, need to be used together and sharing a single clock from one of the ports.
This clock sharing setting was previously read by the sound platform driver from the devicetree, but given that the input/output pairing is closely related to which codecs are connected to which ports, the machine sound driver can infer and set it, so that no DT property is required.
At this point only mt8183-kukui was using the DT property, but given that this property was never documented, and that the API introduced in this series makes it obsolete, the undocumented DT property can safely be removed.
This series adds a function to allow setting the i2s shared clocks, makes use of it in the machine drivers as required, and removes the no longer required DT properties and support for them in the drivers, for all of mt8192, mt8183 and mt8186.
Nícolas F. R. A. Prado (10):
ASoC: mediatek: mt8192: Allow setting shared clocks from machine
driver
ASoC: mediatek: mt8192-mt6359: Make i2s9 share the clock from i2s8
ASoC: mediatek: mt8192: Remove clock share parsing from DT
ASoC: mediatek: mt8183: Allow setting shared clocks from machine
driver
ASoC: mediatek: mt8183: Configure shared clocks
ASoC: mediatek: mt8183: Remove clock share parsing from DT
arm64: dts: mediatek: kukui: Remove i2s-share properties
ASoC: mediatek: mt8186: Allow setting shared clocks from machine
driver
ASoC: mediatek: mt8186: Configure shared clocks
ASoC: mediatek: mt8186: Remove clock share parsing from DT
.../arm64/boot/dts/mediatek/mt8183-kukui.dtsi | 5 -- sound/soc/mediatek/mt8183/mt8183-afe-common.h | 3 ++ .../mediatek/mt8183/mt8183-da7219-max98357.c | 33 +++++++++++++ sound/soc/mediatek/mt8183/mt8183-dai-i2s.c | 45 ++++++++--------- .../mt8183/mt8183-mt6358-ts3a227-max98357.c | 33 +++++++++++++ sound/soc/mediatek/mt8186/mt8186-afe-common.h | 3 ++ sound/soc/mediatek/mt8186/mt8186-dai-i2s.c | 44 ++++++++--------- .../mt8186/mt8186-mt6366-da7219-max98357.c | 18 +++++++ .../mt8186/mt8186-mt6366-rt1019-rt5682s.c | 18 +++++++ sound/soc/mediatek/mt8192/mt8192-afe-common.h | 3 ++ sound/soc/mediatek/mt8192/mt8192-dai-i2s.c | 49 ++++++++----------- .../mt8192/mt8192-mt6359-rt1015-rt5682.c | 9 ++++ 12 files changed, 180 insertions(+), 83 deletions(-)
Signature · 1 line
2.37.3
PATCH 1/10 ASoC: mediatek: mt8192: Allow setting shared clocks from machine driver
Add a new function to configure the shared clock between two i2s ports, and export it. This will allow the clock sharing to be set from the machine driver instead of the devicetree.
---
sound/soc/mediatek/mt8192/mt8192-afe-common.h | 3 +++ sound/soc/mediatek/mt8192/mt8192-dai-i2s.c | 26 +++++++++++++++++++ 2 files changed, 29 insertions(+)
sound/soc/mediatek/mt8192/mt8192-afe-common.h +3 -0
@@ -159,6 +159,9 @@ int mt8192_dai_src_register(struct mtk_base_afe *afe);int mt8192_dai_pcm_register (struct mtk_base_afe *afe);int mt8192_dai_tdm_register (struct mtk_base_afe *afe); +int mt8192_dai_i2s_set_share (struct mtk_base_afe *afe,const char *main_i2s_name, +const char *secondary_i2s_name); +unsigned int mt8192_general_rate_transform (struct device *dev,unsigned int rate); unsigned int mt8192_rate_transform(struct device *dev,
sound/soc/mediatek/mt8192/mt8192-dai-i2s.c +26 -0
@@ -2057,6 +2057,32 @@ static int mt8192_dai_i2s_get_share(struct mtk_base_afe *afe)return 0 ; } +/** +* mt8192_dai_i2s_set_share() - Set up I2S ports to share a single clock. +* @afe: Pointer to &struct mtk_base_afe +* @main_i2s_name: The name of the I2S port that will provide the clock +* @secondary_i2s_name: The name of the I2S port that will use this clock +*/ +int mt8192_dai_i2s_set_share (struct mtk_base_afe *afe,const char *main_i2s_name, +const char *secondary_i2s_name) +{ +struct mtk_afe_i2s_priv *secondary_i2s_priv; +int main_i2s_id; + + secondary_i2s_priv =get_i2s_priv_by_name (afe, secondary_i2s_name); +if (!secondary_i2s_priv) +return -EINVAL ; + + main_i2s_id =get_i2s_id_by_name (afe, main_i2s_name); +if (main_i2s_id <0 ) +return main_i2s_id; + + secondary_i2s_priv->share_i2s_id = main_i2s_id; + +return 0 ; +} +EXPORT_SYMBOL_GPL (mt8192_dai_i2s_set_share); +static int mt8192_dai_i2s_set_priv (struct mtk_base_afe *afe) {int i;
Signature · 1 line
2.37.3
Re: [PATCH 01/10] ASoC: mediatek: mt8192: Allow setting shared clocks from machine driver
Il 08/09/22 18:11, Nícolas F. R. A. Prado ha scritto:
Quoted 5 lines
Add a new function to configure the shared clock between two i2s ports, and export it. This will allow the clock sharing to be set from the machine driver instead of the devicetree.
Signed-off-by Nícolas F. R. A. Prado <[email protected]>
PATCH 2/10 ASoC: mediatek: mt8192-mt6359: Make i2s9 share the clock from i2s8
In reply to Nícolas F. R. A. PradoBoth i2s8 and i2s9 are connected to the rt5682 codec and should share the same clock to work in a full-duplex manner. Set the clock sharing during the initialization for rt5682.
---
sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c | 9 +++++++++ 1 file changed, 9 insertions(+)
sound/soc/mediatek/mt8192/mt8192-mt6359-rt1015-rt5682.c +9 -0
@@ -311,12 +311,21 @@ static int mt8192_mt6359_init(struct snd_soc_pcm_runtime *rtd)static int mt8192_rt5682_init (struct snd_soc_pcm_runtime *rtd) { +struct snd_soc_component *cmpnt_afe = +snd_soc_rtdcom_lookup (rtd,AFE_PCM_NAME ); +struct mtk_base_afe *afe =snd_soc_component_get_drvdata (cmpnt_afe);struct snd_soc_component *cmpnt_codec =asoc_rtd_to_codec (rtd,0 )->component;struct mt8192_mt6359_priv *priv =snd_soc_card_get_drvdata (rtd->card);struct snd_soc_jack *jack = &priv->headset_jack;int ret; + ret =mt8192_dai_i2s_set_share (afe,"I2S8" ,"I2S9" ); +if (ret) { +dev_err (rtd->dev,"Failed to set up shared clocks\n" ); +return ret; + } + ret = snd_soc_card_jack_new(rtd->card, "Headset Jack", SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2 |
Signature · 1 line
2.37.3
Re: [PATCH 02/10] ASoC: mediatek: mt8192-mt6359: Make i2s9 share the clock from i2s8
Il 08/09/22 18:11, Nícolas F. R. A. Prado ha scritto:
Quoted 5 lines
Both i2s8 and i2s9 are connected to the rt5682 codec and should share the same clock to work in a full-duplex manner. Set the clock sharing during the initialization for rt5682.
Signed-off-by Nícolas F. R. A. Prado <[email protected]>
PATCH 3/10 ASoC: mediatek: mt8192: Remove clock share parsing from DT
In reply to Nícolas F. R. A. PradoNow that the clock sharing for i2s ports can be configured from the sound machine driver, remove the logic that was used to parse the properties from the devicetree.
---
sound/soc/mediatek/mt8192/mt8192-dai-i2s.c | 35 ---------------------- 1 file changed, 35 deletions(-)
sound/soc/mediatek/mt8192/mt8192-dai-i2s.c +0 -35
@@ -45,7 +45,6 @@ struct mtk_afe_i2s_priv {int rate;/* for determine which apll to use */ int low_jitter_en; -const char *share_property_name;int share_i2s_id;int mclk_id;
@@ -1984,79 +1983,50 @@ static const struct mtk_afe_i2s_priv mt8192_i2s_priv[DAI_I2S_NUM] = { [DAI_I2S0 ] = { .id =MT8192_DAI_I2S_0 , .mclk_id =MT8192_I2S0_MCK , - .share_property_name ="i2s0-share" , .share_i2s_id =-1 , }, [DAI_I2S1 ] = { .id =MT8192_DAI_I2S_1 , .mclk_id =MT8192_I2S1_MCK , - .share_property_name ="i2s1-share" , .share_i2s_id =-1 , }, [DAI_I2S2 ] = { .id =MT8192_DAI_I2S_2 , .mclk_id =MT8192_I2S2_MCK , - .share_property_name ="i2s2-share" , .share_i2s_id =-1 , }, [DAI_I2S3 ] = { .id =MT8192_DAI_I2S_3 , .mclk_id =MT8192_I2S3_MCK , - .share_property_name ="i2s3-share" , .share_i2s_id =-1 , }, [DAI_I2S5 ] = { .id =MT8192_DAI_I2S_5 , .mclk_id =MT8192_I2S5_MCK , - .share_property_name ="i2s5-share" , .share_i2s_id =-1 , }, [DAI_I2S6 ] = { .id =MT8192_DAI_I2S_6 , .mclk_id =MT8192_I2S6_MCK , - .share_property_name ="i2s6-share" , .share_i2s_id =-1 , }, [DAI_I2S7 ] = { .id =MT8192_DAI_I2S_7 , .mclk_id =MT8192_I2S7_MCK , - .share_property_name ="i2s7-share" , .share_i2s_id =-1 , }, [DAI_I2S8 ] = { .id =MT8192_DAI_I2S_8 , .mclk_id =MT8192_I2S8_MCK , - .share_property_name ="i2s8-share" , .share_i2s_id =-1 , }, [DAI_I2S9 ] = { .id =MT8192_DAI_I2S_9 , .mclk_id =MT8192_I2S9_MCK , - .share_property_name ="i2s9-share" , .share_i2s_id =-1 , }, }; -static int mt8192_dai_i2s_get_share (struct mtk_base_afe *afe) -{ -struct mt8192_afe_private *afe_priv = afe->platform_priv; -const struct device_node *of_node = afe->dev->of_node; -const char *of_str; -const char *property_name; -struct mtk_afe_i2s_priv *i2s_priv; -int i; - -for (i =0 ; i <DAI_I2S_NUM ; i++) { - i2s_priv = afe_priv->dai_priv[mt8192_i2s_priv[i].id]; - property_name = mt8192_i2s_priv[i].share_property_name; -if (of_property_read_string (of_node, property_name, &of_str)) -continue ; - i2s_priv->share_i2s_id =get_i2s_id_by_name (afe, of_str); - } - -return 0 ; -} -/** * mt8192_dai_i2s_set_share() - Set up I2S ports to share a single clock. * @afe: Pointer to &struct mtk_base_afe
@@ -2127,10 +2097,5 @@ int mt8192_dai_i2s_register(struct mtk_base_afe *afe)if (ret)return ret; -/* parse share i2s */ - ret =mt8192_dai_i2s_get_share (afe); -if (ret) -return ret; -return 0 ; }
Signature · 1 line
2.37.3
Re: [PATCH 03/10] ASoC: mediatek: mt8192: Remove clock share parsing from DT
Il 08/09/22 18:11, Nícolas F. R. A. Prado ha scritto:
Quoted 5 lines
Now that the clock sharing for i2s ports can be configured from the sound machine driver, remove the logic that was used to parse the properties from the devicetree.
Signed-off-by Nícolas F. R. A. Prado <[email protected]>
PATCH 4/10 ASoC: mediatek: mt8183: Allow setting shared clocks from machine driver
In reply to Nícolas F. R. A. PradoAdd a new function to configure the shared clock between two i2s ports, and export it. This will allow the clock sharing to be set from the machine driver instead of the devicetree.
---
sound/soc/mediatek/mt8183/mt8183-afe-common.h | 3 +++ sound/soc/mediatek/mt8183/mt8183-dai-i2s.c | 26 +++++++++++++++++++ 2 files changed, 29 insertions(+)
sound/soc/mediatek/mt8183/mt8183-afe-common.h +3 -0
@@ -99,6 +99,9 @@ unsigned int mt8183_general_rate_transform(struct device *dev,unsigned int mt8183_rate_transform (struct device *dev,unsigned int rate,int aud_blk); +int mt8183_dai_i2s_set_share (struct mtk_base_afe *afe,const char *main_i2s_name, +const char *secondary_i2s_name); +/* dai register */ int mt8183_dai_adda_register (struct mtk_base_afe *afe);int mt8183_dai_pcm_register (struct mtk_base_afe *afe);
sound/soc/mediatek/mt8183/mt8183-dai-i2s.c +26 -0
@@ -1026,6 +1026,32 @@ static int mt8183_dai_i2s_get_share(struct mtk_base_afe *afe)return 0 ; } +/** +* mt8183_dai_i2s_set_share() - Set up I2S ports to share a single clock. +* @afe: Pointer to &struct mtk_base_afe +* @main_i2s_name: The name of the I2S port that will provide the clock +* @secondary_i2s_name: The name of the I2S port that will use this clock +*/ +int mt8183_dai_i2s_set_share (struct mtk_base_afe *afe,const char *main_i2s_name, +const char *secondary_i2s_name) +{ +struct mtk_afe_i2s_priv *secondary_i2s_priv; +int main_i2s_id; + + secondary_i2s_priv =get_i2s_priv_by_name (afe, secondary_i2s_name); +if (!secondary_i2s_priv) +return -EINVAL ; + + main_i2s_id =get_i2s_id_by_name (afe, main_i2s_name); +if (main_i2s_id <0 ) +return main_i2s_id; + + secondary_i2s_priv->share_i2s_id = main_i2s_id; + +return 0 ; +} +EXPORT_SYMBOL_GPL (mt8183_dai_i2s_set_share); +static int mt8183_dai_i2s_set_priv (struct mtk_base_afe *afe) {struct mt8183_afe_private *afe_priv = afe->platform_priv;
Signature · 1 line
2.37.3
Re: [PATCH 04/10] ASoC: mediatek: mt8183: Allow setting shared clocks from machine driver
Il 08/09/22 18:11, Nícolas F. R. A. Prado ha scritto:
Quoted 5 lines
Add a new function to configure the shared clock between two i2s ports, and export it. This will allow the clock sharing to be set from the machine driver instead of the devicetree.
Signed-off-by Nícolas F. R. A. Prado <[email protected]>
PATCH 5/10 ASoC: mediatek: mt8183: Configure shared clocks
In reply to Nícolas F. R. A. Pradoi2s0 and i2s5 are paired input/output connected to the same codec and should share the same clock. Likewise for i2s2 and i2s3. Set the clock sharing for each pair during the DAI initialization.
---
.../mediatek/mt8183/mt8183-da7219-max98357.c | 33 +++++++++++++++++++ .../mt8183/mt8183-mt6358-ts3a227-max98357.c | 33 +++++++++++++++++++ 2 files changed, 66 insertions(+)
sound/soc/mediatek/mt8183/mt8183-da7219-max98357.c +33 -0
@@ -17,6 +17,7 @@#include "../../codecs/da7219-aad.h" #include "../../codecs/da7219.h" #include "../../codecs/rt1015.h" +#include "../common/mtk-afe-platform-driver.h" #include "mt8183-afe-common.h" #define DA7219_CODEC_DAI "da7219-hifi"
@@ -372,6 +373,36 @@ static int mt8183_da7219_max98357_hdmi_init(struct snd_soc_pcm_runtime *rtd) &priv->hdmi_jack, NULL); } +static int mt8183_bt_init (struct snd_soc_pcm_runtime *rtd) +{ +struct snd_soc_component *cmpnt_afe = +snd_soc_rtdcom_lookup (rtd,AFE_PCM_NAME ); +struct mtk_base_afe *afe =snd_soc_component_get_drvdata (cmpnt_afe); +int ret; + + ret =mt8183_dai_i2s_set_share (afe,"I2S5" ,"I2S0" ); +if (ret) { +dev_err (rtd->dev,"Failed to set up shared clocks\n" ); +return ret; + } +return 0 ; +} + +static int mt8183_da7219_init (struct snd_soc_pcm_runtime *rtd) +{ +struct snd_soc_component *cmpnt_afe = +snd_soc_rtdcom_lookup (rtd,AFE_PCM_NAME ); +struct mtk_base_afe *afe =snd_soc_component_get_drvdata (cmpnt_afe); +int ret; + + ret =mt8183_dai_i2s_set_share (afe,"I2S2" ,"I2S3" ); +if (ret) { +dev_err (rtd->dev,"Failed to set up shared clocks\n" ); +return ret; + } +return 0 ; +} +static struct snd_soc_dai_link mt8183_da7219_dai_links[] = {/* FE */ {
@@ -500,6 +531,7 @@ static struct snd_soc_dai_link mt8183_da7219_dai_links[] = { .ignore_suspend = 1, .be_hw_params_fixup = mt8183_i2s_hw_params_fixup, .ops = &mt8183_da7219_i2s_ops, + .init = &mt8183_da7219_init, SND_SOC_DAILINK_REG(i2s2), }, {
@@ -515,6 +547,7 @@ static struct snd_soc_dai_link mt8183_da7219_dai_links[] = { .ignore_suspend = 1, .be_hw_params_fixup = mt8183_i2s_hw_params_fixup, .ops = &mt8183_mt6358_i2s_ops, + .init = &mt8183_bt_init, SND_SOC_DAILINK_REG(i2s5), }, {
sound/soc/mediatek/mt8183/mt8183-mt6358-ts3a227-max98357.c +33 -0
@@ -15,6 +15,7 @@#include "../../codecs/rt1015.h" #include "../../codecs/ts3a227e.h" +#include "../common/mtk-afe-platform-driver.h" #include "mt8183-afe-common.h" #define RT1015_CODEC_DAI "rt1015-aif"
@@ -391,6 +392,36 @@ mt8183_mt6358_ts3a227_max98357_hdmi_init(struct snd_soc_pcm_runtime *rtd) &priv->hdmi_jack, NULL); } +static int mt8183_bt_init (struct snd_soc_pcm_runtime *rtd) +{ +struct snd_soc_component *cmpnt_afe = +snd_soc_rtdcom_lookup (rtd,AFE_PCM_NAME ); +struct mtk_base_afe *afe =snd_soc_component_get_drvdata (cmpnt_afe); +int ret; + + ret =mt8183_dai_i2s_set_share (afe,"I2S5" ,"I2S0" ); +if (ret) { +dev_err (rtd->dev,"Failed to set up shared clocks\n" ); +return ret; + } +return 0 ; +} + +static int mt8183_i2s2_init (struct snd_soc_pcm_runtime *rtd) +{ +struct snd_soc_component *cmpnt_afe = +snd_soc_rtdcom_lookup (rtd,AFE_PCM_NAME ); +struct mtk_base_afe *afe =snd_soc_component_get_drvdata (cmpnt_afe); +int ret; + + ret =mt8183_dai_i2s_set_share (afe,"I2S2" ,"I2S3" ); +if (ret) { +dev_err (rtd->dev,"Failed to set up shared clocks\n" ); +return ret; + } +return 0 ; +} +static struct snd_soc_dai_link mt8183_mt6358_ts3a227_dai_links[] = {/* FE */ {
@@ -527,6 +558,7 @@ static struct snd_soc_dai_link mt8183_mt6358_ts3a227_dai_links[] = { .ignore_suspend = 1, .be_hw_params_fixup = mt8183_i2s_hw_params_fixup, .ops = &mt8183_mt6358_i2s_ops, + .init = &mt8183_i2s2_init, SND_SOC_DAILINK_REG(i2s2), }, {
@@ -541,6 +573,7 @@ static struct snd_soc_dai_link mt8183_mt6358_ts3a227_dai_links[] = { .dpcm_playback = 1, .ignore_suspend = 1, .ops = &mt8183_mt6358_i2s_ops, + .init = &mt8183_bt_init, SND_SOC_DAILINK_REG(i2s5), }, {
Signature · 1 line
2.37.3
Re: [PATCH 05/10] ASoC: mediatek: mt8183: Configure shared clocks
Il 08/09/22 18:11, Nícolas F. R. A. Prado ha scritto:
Quoted 5 lines
i2s0 and i2s5 are paired input/output connected to the same codec and should share the same clock. Likewise for i2s2 and i2s3. Set the clock sharing for each pair during the DAI initialization.
Signed-off-by Nícolas F. R. A. Prado <[email protected]>
PATCH 6/10 ASoC: mediatek: mt8183: Remove clock share parsing from DT
In reply to Nícolas F. R. A. PradoNow that the clock sharing for i2s ports can be configured from the sound machine driver, remove the logic that was used to parse the properties from the devicetree.
---
sound/soc/mediatek/mt8183/mt8183-dai-i2s.c | 31 ---------------------- 1 file changed, 31 deletions(-)
sound/soc/mediatek/mt8183/mt8183-dai-i2s.c +0 -31
@@ -43,7 +43,6 @@ struct mtk_afe_i2s_priv {int rate;/* for determine which apll to use */ int low_jitter_en; -const char *share_property_name;int share_i2s_id;int mclk_id;
@@ -977,55 +976,30 @@ static const struct mtk_afe_i2s_priv mt8183_i2s_priv[DAI_I2S_NUM] = { [DAI_I2S0 ] = { .id =MT8183_DAI_I2S_0 , .mclk_id =MT8183_I2S0_MCK , - .share_property_name ="i2s0-share" , .share_i2s_id =-1 , }, [DAI_I2S1 ] = { .id =MT8183_DAI_I2S_1 , .mclk_id =MT8183_I2S1_MCK , - .share_property_name ="i2s1-share" , .share_i2s_id =-1 , }, [DAI_I2S2 ] = { .id =MT8183_DAI_I2S_2 , .mclk_id =MT8183_I2S2_MCK , - .share_property_name ="i2s2-share" , .share_i2s_id =-1 , }, [DAI_I2S3 ] = { .id =MT8183_DAI_I2S_3 , .mclk_id =MT8183_I2S3_MCK , - .share_property_name ="i2s3-share" , .share_i2s_id =-1 , }, [DAI_I2S5 ] = { .id =MT8183_DAI_I2S_5 , .mclk_id =MT8183_I2S5_MCK , - .share_property_name ="i2s5-share" , .share_i2s_id =-1 , }, }; -static int mt8183_dai_i2s_get_share (struct mtk_base_afe *afe) -{ -struct mt8183_afe_private *afe_priv = afe->platform_priv; -const struct device_node *of_node = afe->dev->of_node; -const char *of_str; -const char *property_name; -struct mtk_afe_i2s_priv *i2s_priv; -int i; - -for (i =0 ; i <DAI_I2S_NUM ; i++) { - i2s_priv = afe_priv->dai_priv[mt8183_i2s_priv[i].id]; - property_name = mt8183_i2s_priv[i].share_property_name; -if (of_property_read_string (of_node, property_name, &of_str)) -continue ; - i2s_priv->share_i2s_id =get_i2s_id_by_name (afe, of_str); - } - -return 0 ; -} -/** * mt8183_dai_i2s_set_share() - Set up I2S ports to share a single clock. * @afe: Pointer to &struct mtk_base_afe
@@ -1100,10 +1074,5 @@ int mt8183_dai_i2s_register(struct mtk_base_afe *afe)if (ret)return ret; -/* parse share i2s */ - ret =mt8183_dai_i2s_get_share (afe); -if (ret) -return ret; -return 0 ; }
Signature · 1 line
2.37.3
Re: [PATCH 06/10] ASoC: mediatek: mt8183: Remove clock share parsing from DT
Il 08/09/22 18:11, Nícolas F. R. A. Prado ha scritto:
Quoted 5 lines
Now that the clock sharing for i2s ports can be configured from the sound machine driver, remove the logic that was used to parse the properties from the devicetree.
Signed-off-by Nícolas F. R. A. Prado <[email protected]>
PATCH 7/10 arm64: dts: mediatek: kukui: Remove i2s-share properties
In reply to Nícolas F. R. A. PradoThe i2sN-share properties were never documented in the dt-binding and thus shouldn't be used. Now that the ASoC machine drivers are setting the I2S clock sharing internally, these properties are no longer needed, so remove them.
---
arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi | 5 ----- 1 file changed, 5 deletions(-)
arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi +0 -5
@@ -221,11 +221,6 @@ tboard_thermistor2: thermal-sensor2 { }; }; -&afe { - i2s3-share = "I2S2"; - i2s0-share = "I2S5"; -}; - &auxadc { status = "okay"; };
Signature · 1 line
2.37.3
Re: [PATCH 07/10] arm64: dts: mediatek: kukui: Remove i2s-share properties
Il 08/09/22 18:11, Nícolas F. R. A. Prado ha scritto:
Quoted 6 lines
The i2sN-share properties were never documented in the dt-binding and thus shouldn't be used. Now that the ASoC machine drivers are setting the I2S clock sharing internally, these properties are no longer needed, so remove them.
Signed-off-by Nícolas F. R. A. Prado <[email protected]>
Re: [PATCH 07/10] arm64: dts: mediatek: kukui: Remove i2s-share properties
In reply to Nícolas F. R. A. PradoQuoted 6 lines · Nícolas F. R. A. Prado
The i2sN-share properties were never documented in the dt-binding and thus shouldn't be used. Now that the ASoC machine drivers are setting the I2S clock sharing internally, these properties are no longer needed, so remove them.
Signed-off-by Nícolas F. R. A. Prado <[email protected]>
Applied, thanks!
Quoted 21 lines
---
arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi | 5 ----- 1 file changed, 5 deletions(-)arch/arm64/boot/dts/mediatek/mt8183-kukui.dtsi +0
-5@@ -221,11 +221,6 @@ tboard_thermistor2: thermal-sensor2 { }; }; -&afe { - i2s3-share = "I2S2"; - i2s0-share = "I2S5"; -}; - &auxadc { status = "okay"; };
PATCH 8/10 ASoC: mediatek: mt8186: Allow setting shared clocks from machine driver
In reply to Nícolas F. R. A. PradoAdd a new function to configure the shared clock between two i2s ports, and export it. This will allow the clock sharing to be set from the machine driver instead of the devicetree.
---
sound/soc/mediatek/mt8186/mt8186-afe-common.h | 3 +++ sound/soc/mediatek/mt8186/mt8186-dai-i2s.c | 26 +++++++++++++++++++ 2 files changed, 29 insertions(+)
sound/soc/mediatek/mt8186/mt8186-afe-common.h +3 -0
@@ -189,6 +189,9 @@ unsigned int mt8186_rate_transform(struct device *dev,unsigned int mt8186_tdm_relatch_rate_transform (struct device *dev,unsigned int rate); +int mt8186_dai_i2s_set_share (struct mtk_base_afe *afe,const char *main_i2s_name, +const char *secondary_i2s_name); +int mt8186_dai_set_priv (struct mtk_base_afe *afe,int id,int priv_size,const void *priv_data);
sound/soc/mediatek/mt8186/mt8186-dai-i2s.c +26 -0
@@ -1184,6 +1184,32 @@ static int mt8186_dai_i2s_get_share(struct mtk_base_afe *afe)return 0 ; } +/** +* mt8186_dai_i2s_set_share() - Set up I2S ports to share a single clock. +* @afe: Pointer to &struct mtk_base_afe +* @main_i2s_name: The name of the I2S port that will provide the clock +* @secondary_i2s_name: The name of the I2S port that will use this clock +*/ +int mt8186_dai_i2s_set_share (struct mtk_base_afe *afe,const char *main_i2s_name, +const char *secondary_i2s_name) +{ +struct mtk_afe_i2s_priv *secondary_i2s_priv; +int main_i2s_id; + + secondary_i2s_priv =get_i2s_priv_by_name (afe, secondary_i2s_name); +if (!secondary_i2s_priv) +return -EINVAL ; + + main_i2s_id =get_i2s_id_by_name (afe, main_i2s_name); +if (main_i2s_id <0 ) +return main_i2s_id; + + secondary_i2s_priv->share_i2s_id = main_i2s_id; + +return 0 ; +} +EXPORT_SYMBOL_GPL (mt8186_dai_i2s_set_share); +static int mt8186_dai_i2s_set_priv (struct mtk_base_afe *afe) {int i;
Signature · 1 line
2.37.3
Re: [PATCH 08/10] ASoC: mediatek: mt8186: Allow setting shared clocks from machine driver
Il 08/09/22 18:11, Nícolas F. R. A. Prado ha scritto:
Quoted 5 lines
Add a new function to configure the shared clock between two i2s ports, and export it. This will allow the clock sharing to be set from the machine driver instead of the devicetree.
Signed-off-by Nícolas F. R. A. Prado <[email protected]>
PATCH 9/10 ASoC: mediatek: mt8186: Configure shared clocks
In reply to Nícolas F. R. A. Pradoi2s0 and i2s1 are paired input/output connected to the same codec and should share the same clock. Likewise for i2s2 and i2s3. Set the clock sharing for each pair during the codec's initialization.
---
.../mt8186/mt8186-mt6366-da7219-max98357.c | 18 ++++++++++++++++++ .../mt8186/mt8186-mt6366-rt1019-rt5682s.c | 18 ++++++++++++++++++ 2 files changed, 36 insertions(+)
sound/soc/mediatek/mt8186/mt8186-mt6366-da7219-max98357.c +18 -0
@@ -54,6 +54,9 @@ static struct snd_soc_codec_conf mt8186_mt6366_da7219_max98357_codec_conf[] = {static int mt8186_da7219_init (struct snd_soc_pcm_runtime *rtd) { +struct snd_soc_component *cmpnt_afe = +snd_soc_rtdcom_lookup (rtd,AFE_PCM_NAME ); +struct mtk_base_afe *afe =snd_soc_component_get_drvdata (cmpnt_afe);struct mtk_soc_card_data *soc_card_data =snd_soc_card_get_drvdata (rtd->card);struct mt8186_mt6366_da7219_max98357_priv *priv = soc_card_data->mach_priv;
@@ -62,6 +65,12 @@ static int mt8186_da7219_init(struct snd_soc_pcm_runtime *rtd)asoc_rtd_to_codec (rtd,0 )->component;int ret; + ret =mt8186_dai_i2s_set_share (afe,"I2S1" ,"I2S0" ); +if (ret) { +dev_err (rtd->dev,"Failed to set up shared clocks\n" ); +return ret; + } +/* Enable Headset and 4 Buttons Jack detection */ ret = snd_soc_card_jack_new(rtd->card, "Headset Jack", SND_JACK_HEADSET | SND_JACK_BTN_0 |
@@ -160,6 +169,9 @@ static const struct snd_soc_ops mt8186_da7219_i2s_ops = {static int mt8186_mt6366_da7219_max98357_hdmi_init (struct snd_soc_pcm_runtime *rtd) { +struct snd_soc_component *cmpnt_afe = +snd_soc_rtdcom_lookup (rtd,AFE_PCM_NAME ); +struct mtk_base_afe *afe =snd_soc_component_get_drvdata (cmpnt_afe);struct snd_soc_component *cmpnt_codec =asoc_rtd_to_codec (rtd,0 )->component; struct mtk_soc_card_data *soc_card_data =
@@ -167,6 +179,12 @@ static int mt8186_mt6366_da7219_max98357_hdmi_init(struct snd_soc_pcm_runtime *rstruct mt8186_mt6366_da7219_max98357_priv *priv = soc_card_data->mach_priv;int ret; + ret =mt8186_dai_i2s_set_share (afe,"I2S3" ,"I2S2" ); +if (ret) { +dev_err (rtd->dev,"Failed to set up shared clocks\n" ); +return ret; + } + ret =snd_soc_card_jack_new (rtd->card,"HDMI Jack" ,SND_JACK_LINEOUT , &priv->hdmi_jack);if (ret) {dev_err (rtd->dev,"HDMI Jack creation failed: %d\n" , ret);
sound/soc/mediatek/mt8186/mt8186-mt6366-rt1019-rt5682s.c +18 -0
@@ -58,6 +58,9 @@ static struct snd_soc_codec_conf mt8186_mt6366_rt1019_rt5682s_codec_conf[] = {static int mt8186_rt5682s_init (struct snd_soc_pcm_runtime *rtd) { +struct snd_soc_component *cmpnt_afe = +snd_soc_rtdcom_lookup (rtd,AFE_PCM_NAME ); +struct mtk_base_afe *afe =snd_soc_component_get_drvdata (cmpnt_afe);struct mtk_soc_card_data *soc_card_data =snd_soc_card_get_drvdata (rtd->card);struct mt8186_mt6366_rt1019_rt5682s_priv *priv = soc_card_data->mach_priv;
@@ -66,6 +69,12 @@ static int mt8186_rt5682s_init(struct snd_soc_pcm_runtime *rtd)asoc_rtd_to_codec (rtd,0 )->component;int ret; + ret =mt8186_dai_i2s_set_share (afe,"I2S1" ,"I2S0" ); +if (ret) { +dev_err (rtd->dev,"Failed to set up shared clocks\n" ); +return ret; + } + ret = snd_soc_card_jack_new(rtd->card, "Headset Jack", SND_JACK_HEADSET | SND_JACK_BTN_0 | SND_JACK_BTN_1 | SND_JACK_BTN_2 |
@@ -136,6 +145,9 @@ static const struct snd_soc_ops mt8186_rt5682s_i2s_ops = {static int mt8186_mt6366_rt1019_rt5682s_hdmi_init (struct snd_soc_pcm_runtime *rtd) { +struct snd_soc_component *cmpnt_afe = +snd_soc_rtdcom_lookup (rtd,AFE_PCM_NAME ); +struct mtk_base_afe *afe =snd_soc_component_get_drvdata (cmpnt_afe);struct snd_soc_component *cmpnt_codec =asoc_rtd_to_codec (rtd,0 )->component; struct mtk_soc_card_data *soc_card_data =
@@ -143,6 +155,12 @@ static int mt8186_mt6366_rt1019_rt5682s_hdmi_init(struct snd_soc_pcm_runtime *rtstruct mt8186_mt6366_rt1019_rt5682s_priv *priv = soc_card_data->mach_priv;int ret; + ret =mt8186_dai_i2s_set_share (afe,"I2S3" ,"I2S2" ); +if (ret) { +dev_err (rtd->dev,"Failed to set up shared clocks\n" ); +return ret; + } + ret =snd_soc_card_jack_new (rtd->card,"HDMI Jack" ,SND_JACK_LINEOUT , &priv->hdmi_jack);if (ret) {dev_err (rtd->dev,"HDMI Jack creation failed: %d\n" , ret);
Signature · 1 line
2.37.3
Re: [PATCH 09/10] ASoC: mediatek: mt8186: Configure shared clocks
Il 08/09/22 18:11, Nícolas F. R. A. Prado ha scritto:
Quoted 5 lines
i2s0 and i2s1 are paired input/output connected to the same codec and should share the same clock. Likewise for i2s2 and i2s3. Set the clock sharing for each pair during the codec's initialization.
Signed-off-by Nícolas F. R. A. Prado <[email protected]>
PATCH 10/10 ASoC: mediatek: mt8186: Remove clock share parsing from DT
In reply to Nícolas F. R. A. PradoNow that the clock sharing for i2s ports can be configured from the sound machine driver, remove the logic that was used to parse the properties from the devicetree.
---
sound/soc/mediatek/mt8186/mt8186-dai-i2s.c | 30 ---------------------- 1 file changed, 30 deletions(-)
sound/soc/mediatek/mt8186/mt8186-dai-i2s.c +0 -30
@@ -44,7 +44,6 @@ struct mtk_afe_i2s_priv {int low_jitter_en;int master;/* only i2s0 has slave mode*/ -const char *share_property_name;int share_i2s_id;int mclk_id;
@@ -1140,50 +1139,26 @@ static const struct mtk_afe_i2s_priv mt8186_i2s_priv[DAI_I2S_NUM] = { [DAI_I2S0 ] = { .id =MT8186_DAI_I2S_0 , .mclk_id =MT8186_I2S0_MCK , - .share_property_name ="i2s0-share" , .share_i2s_id =-1 , }, [DAI_I2S1 ] = { .id =MT8186_DAI_I2S_1 , .mclk_id =MT8186_I2S1_MCK , - .share_property_name ="i2s1-share" , .share_i2s_id =-1 , }, [DAI_I2S2 ] = { .id =MT8186_DAI_I2S_2 , .mclk_id =MT8186_I2S2_MCK , - .share_property_name ="i2s2-share" , .share_i2s_id =-1 , }, [DAI_I2S3 ] = { .id =MT8186_DAI_I2S_3 ,/* clock gate naming is hf_faud_i2s4_m_ck*/ .mclk_id =MT8186_I2S4_MCK , - .share_property_name ="i2s3-share" , .share_i2s_id =-1 , } }; -static int mt8186_dai_i2s_get_share (struct mtk_base_afe *afe) -{ -struct mt8186_afe_private *afe_priv = afe->platform_priv; -const struct device_node *of_node = afe->dev->of_node; -const char *of_str; -const char *property_name; -struct mtk_afe_i2s_priv *i2s_priv; -int i; - -for (i =0 ; i <DAI_I2S_NUM ; i++) { - i2s_priv = afe_priv->dai_priv[mt8186_i2s_priv[i].id]; - property_name = mt8186_i2s_priv[i].share_property_name; -if (of_property_read_string (of_node, property_name, &of_str)) -continue ; - i2s_priv->share_i2s_id =get_i2s_id_by_name (afe, of_str); - } - -return 0 ; -} -/** * mt8186_dai_i2s_set_share() - Set up I2S ports to share a single clock. * @afe: Pointer to &struct mtk_base_afe
@@ -1252,10 +1227,5 @@ int mt8186_dai_i2s_register(struct mtk_base_afe *afe)if (ret)return ret; -/* parse share i2s */ - ret =mt8186_dai_i2s_get_share (afe); -if (ret) -return ret; -return 0 ; }
Signature · 1 line
2.37.3
Re: [PATCH 10/10] ASoC: mediatek: mt8186: Remove clock share parsing from DT
Il 08/09/22 18:11, Nícolas F. R. A. Prado ha scritto:
Quoted 5 lines
Now that the clock sharing for i2s ports can be configured from the sound machine driver, remove the logic that was used to parse the properties from the devicetree.
Signed-off-by Nícolas F. R. A. Prado <[email protected]>
Mark Brown
maintainerQuoted 5 lines · Nícolas F. R. A. Prado
The i2s ports on MediaTek SoCs only support a single data lane. In order to achieve full-duplex operation thus two i2s ports, one for input and one for output, need to be used together and sharing a single clock from one of the ports.
Quoted 7 lines
This clock sharing setting was previously read by the sound platform driver from the devicetree, but given that the input/output pairing is closely related to which codecs are connected to which ports, the machine sound driver can infer and set it, so that no DT property is required.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[01/10] ASoC: mediatek: mt8192: Allow setting shared clocks from machine driver
commit: 8ae4fcfd5b11b5c33154732fcad99ad0f5843ce2
[02/10] ASoC: mediatek: mt8192-mt6359: Make i2s9 share the clock from i2s8
commit: 3ffb9fa3963964a730c34f48e502ac0625efc145
[03/10] ASoC: mediatek: mt8192: Remove clock share parsing from DT
commit: 9ccd51ce396a46d9d4d0c87aa6a82dd26a2f281a
[04/10] ASoC: mediatek: mt8183: Allow setting shared clocks from machine driver
commit: fea84890e5c1fb65ae8e25b2f9b86363af1f45f2
[05/10] ASoC: mediatek: mt8183: Configure shared clocks
commit: 4583392a135cc30409f5a6ceebb8374e550b03e0
[06/10] ASoC: mediatek: mt8183: Remove clock share parsing from DT
commit: cbebe67859a0e8d51e578fdd9f927f8ef2504ba4
[07/10] arm64: dts: mediatek: kukui: Remove i2s-share properties
commit: b3821f7839c2ec322926d16557aff29f4be1f4dc
[08/10] ASoC: mediatek: mt8186: Allow setting shared clocks from machine driver
commit: 4132a778e806f77c2bd01a9a34b07edc9dd99d76
[09/10] ASoC: mediatek: mt8186: Configure shared clocks
commit: 9986bdaee4776c5d595933cace9d54c6bc084e91
[10/10] ASoC: mediatek: mt8186: Remove clock share parsing from DT
commit: 62da80c6a124dd68b12c4d2197ecc74b79823571All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Matthias Brugger
maintainerQuoted 21 lines · Mark Brown
Quoted 5 lines · Nícolas F. R. A. Prado
The i2s ports on MediaTek SoCs only support a single data lane. In order to achieve full-duplex operation thus two i2s ports, one for input and one for output, need to be used together and sharing a single clock from one of the ports.
Quoted 7 lines
This clock sharing setting was previously read by the sound platform driver from the devicetree, but given that the input/output pairing is closely related to which codecs are connected to which ports, the machine sound driver can infer and set it, so that no DT property is required.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[01/10] ASoC: mediatek: mt8192: Allow setting shared clocks from machine driver
Quoted 13 lines
commit: 8ae4fcfd5b11b5c33154732fcad99ad0f5843ce2
[02/10] ASoC: mediatek: mt8192-mt6359: Make i2s9 share the clock from i2s8
commit: 3ffb9fa3963964a730c34f48e502ac0625efc145
[03/10] ASoC: mediatek: mt8192: Remove clock share parsing from DT
commit: 9ccd51ce396a46d9d4d0c87aa6a82dd26a2f281a
[04/10] ASoC: mediatek: mt8183: Allow setting shared clocks from machine driver
commit: fea84890e5c1fb65ae8e25b2f9b86363af1f45f2
[05/10] ASoC: mediatek: mt8183: Configure shared clocks
commit: 4583392a135cc30409f5a6ceebb8374e550b03e0
[06/10] ASoC: mediatek: mt8183: Remove clock share parsing from DT
commit: cbebe67859a0e8d51e578fdd9f927f8ef2504ba4
[07/10] arm64: dts: mediatek: kukui: Remove i2s-share properties
commit: b3821f7839c2ec322926d16557aff29f4be1f4dcDTS should go through my branch. We can see if there are any merge conflicts in linux-next and fix them somehow or you drop the patch and I take it through my tree. As you like.
Regards,
Matthias
Quoted 25 lines
[08/10] ASoC: mediatek: mt8186: Allow setting shared clocks from machine driver
commit: 4132a778e806f77c2bd01a9a34b07edc9dd99d76 [09/10] ASoC: mediatek: mt8186: Configure shared clocks commit: 9986bdaee4776c5d595933cace9d54c6bc084e91 [10/10] ASoC: mediatek: mt8186: Remove clock share parsing from DT commit: 62da80c6a124dd68b12c4d2197ecc74b79823571All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark
Mark Brown
maintainerQuoted 3 lines · Matthias Brugger
DTS should go through my branch. We can see if there are any merge conflicts in linux-next and fix them somehow or you drop the patch and I take it through my tree. As you like.
Sorry, dropped now.
Mark Brown
maintainerQuoted 5 lines · Nícolas F. R. A. Prado
The i2s ports on MediaTek SoCs only support a single data lane. In order to achieve full-duplex operation thus two i2s ports, one for input and one for output, need to be used together and sharing a single clock from one of the ports.
Quoted 7 lines
This clock sharing setting was previously read by the sound platform driver from the devicetree, but given that the input/output pairing is closely related to which codecs are connected to which ports, the machine sound driver can infer and set it, so that no DT property is required.
[...]
Applied to
broonie/sound.git for-next
Thanks!
[01/10] ASoC: mediatek: mt8192: Allow setting shared clocks from machine driver
commit: 8ae4fcfd5b11b5c33154732fcad99ad0f5843ce2
[02/10] ASoC: mediatek: mt8192-mt6359: Make i2s9 share the clock from i2s8
commit: 3ffb9fa3963964a730c34f48e502ac0625efc145
[03/10] ASoC: mediatek: mt8192: Remove clock share parsing from DT
commit: 9ccd51ce396a46d9d4d0c87aa6a82dd26a2f281a
[04/10] ASoC: mediatek: mt8183: Allow setting shared clocks from machine driver
commit: fea84890e5c1fb65ae8e25b2f9b86363af1f45f2
[05/10] ASoC: mediatek: mt8183: Configure shared clocks
commit: 4583392a135cc30409f5a6ceebb8374e550b03e0
[06/10] ASoC: mediatek: mt8183: Remove clock share parsing from DT
commit: cbebe67859a0e8d51e578fdd9f927f8ef2504ba4
[07/10] arm64: dts: mediatek: kukui: Remove i2s-share properties
commit: b3821f7839c2ec322926d16557aff29f4be1f4dc
[08/10] ASoC: mediatek: mt8186: Allow setting shared clocks from machine driver
commit: 4132a778e806f77c2bd01a9a34b07edc9dd99d76
[09/10] ASoC: mediatek: mt8186: Configure shared clocks
commit: 9986bdaee4776c5d595933cace9d54c6bc084e91
[10/10] ASoC: mediatek: mt8186: Remove clock share parsing from DT
commit: 62da80c6a124dd68b12c4d2197ecc74b79823571All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark