alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [alsa-devel] [PATCH 0/2] ASoC: mt8183: fix audio playback slowly after playback during bootup
@ 2019-09-12  9:54 Jiaxin Yu
  2019-09-12  9:54 ` [alsa-devel] [PATCH 1/2] ASoC: dt-bingdings: mediatek: mt8183: add a property "medaitek, toprgu" Jiaxin Yu
  2019-09-12  9:54 ` [alsa-devel] [PATCH 2/2] ASoC: mt8183: fix audio playback slowly after playback during bootup Jiaxin Yu
  0 siblings, 2 replies; 5+ messages in thread
From: Jiaxin Yu @ 2019-09-12  9:54 UTC (permalink / raw)
  To: broonie, robh+dt
  Cc: alsa-devel, lgirdwood, jiaxin.yu, tzungbi, linux-mediatek, eason.yen

These two patches fix audio playack slowly after playbakc during bootup.
The patches are based on broonie tree "for-next" branch.

Jiaxin Yu (2):
  ASoC: dt-bingdings: mediatek: mt8183: add a property "medaitek,toprgu"
  ASoC: mt8183: fix audio playback slowly after playback during bootup

 .../bindings/sound/mt8183-afe-pcm.txt         |  2 ++
 sound/soc/mediatek/common/mtk-base-afe.h      |  1 +
 sound/soc/mediatek/mt8183/mt8183-afe-pcm.c    | 21 +++++++++++++++++++
 sound/soc/mediatek/mt8183/mt8183-reg.h        |  6 ++++++
 4 files changed, 30 insertions(+)

-- 
2.18.0

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [alsa-devel] [PATCH 1/2] ASoC: dt-bingdings: mediatek: mt8183: add a property "medaitek, toprgu"
  2019-09-12  9:54 [alsa-devel] [PATCH 0/2] ASoC: mt8183: fix audio playback slowly after playback during bootup Jiaxin Yu
@ 2019-09-12  9:54 ` Jiaxin Yu
  2019-09-12 16:52   ` Yingjoe Chen
  2019-09-12  9:54 ` [alsa-devel] [PATCH 2/2] ASoC: mt8183: fix audio playback slowly after playback during bootup Jiaxin Yu
  1 sibling, 1 reply; 5+ messages in thread
From: Jiaxin Yu @ 2019-09-12  9:54 UTC (permalink / raw)
  To: broonie, robh+dt
  Cc: alsa-devel, lgirdwood, jiaxin.yu, tzungbi, linux-mediatek, eason.yen

This patch adds a property "mediatek,toprgu" in example so that we could
use reset controller(usually we call it toprgu or watchdog) to reset audio
domain regs.

Signed-off-by: Jiaxin Yu <jiaxin.yu@mediatek.com>
---
 Documentation/devicetree/bindings/sound/mt8183-afe-pcm.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/sound/mt8183-afe-pcm.txt b/Documentation/devicetree/bindings/sound/mt8183-afe-pcm.txt
index 396ba38619f6..45ca182a4ecc 100644
--- a/Documentation/devicetree/bindings/sound/mt8183-afe-pcm.txt
+++ b/Documentation/devicetree/bindings/sound/mt8183-afe-pcm.txt
@@ -4,6 +4,7 @@ Required properties:
 - compatible = "mediatek,mt68183-audio";
 - reg: register location and size
 - interrupts: should contain AFE interrupt
+- mediatek,toprgu: A phandle to the TOPRGU which for reset controller unit
 - power-domains: should define the power domain
 - clocks: Must contain an entry for each entry in clock-names
 - clock-names: should have these clock names:
@@ -20,6 +21,7 @@ Example:
 		compatible = "mediatek,mt8183-audio";
 		reg = <0 0x11220000 0 0x1000>;
 		interrupts = <GIC_SPI 161 IRQ_TYPE_LEVEL_LOW>;
+		mediatek,toprgu = <&watchdog>;
 		power-domains = <&scpsys MT8183_POWER_DOMAIN_AUDIO>;
 		clocks = <&infrasys CLK_INFRA_AUDIO>,
 			 <&infrasys CLK_INFRA_AUDIO_26M_BCLK>,
-- 
2.18.0

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [alsa-devel] [PATCH 2/2] ASoC: mt8183: fix audio playback slowly after playback during bootup
  2019-09-12  9:54 [alsa-devel] [PATCH 0/2] ASoC: mt8183: fix audio playback slowly after playback during bootup Jiaxin Yu
  2019-09-12  9:54 ` [alsa-devel] [PATCH 1/2] ASoC: dt-bingdings: mediatek: mt8183: add a property "medaitek, toprgu" Jiaxin Yu
@ 2019-09-12  9:54 ` Jiaxin Yu
  2019-09-12 16:50   ` Yingjoe Chen
  1 sibling, 1 reply; 5+ messages in thread
From: Jiaxin Yu @ 2019-09-12  9:54 UTC (permalink / raw)
  To: broonie, robh+dt
  Cc: alsa-devel, lgirdwood, jiaxin.yu, tzungbi, linux-mediatek, eason.yen

Before regmap_reinit_cache we must reset audio reg as default value.
So we use reset controller unit(toprgu) to reset audio hw.

Signed-off-by: Jiaxin Yu <jiaxin.yu@mediatek.com>
---
 sound/soc/mediatek/common/mtk-base-afe.h   |  1 +
 sound/soc/mediatek/mt8183/mt8183-afe-pcm.c | 21 +++++++++++++++++++++
 sound/soc/mediatek/mt8183/mt8183-reg.h     |  6 ++++++
 3 files changed, 28 insertions(+)

diff --git a/sound/soc/mediatek/common/mtk-base-afe.h b/sound/soc/mediatek/common/mtk-base-afe.h
index 60cb609a9790..bccc079ee660 100644
--- a/sound/soc/mediatek/common/mtk-base-afe.h
+++ b/sound/soc/mediatek/common/mtk-base-afe.h
@@ -60,6 +60,7 @@ struct mtk_base_afe {
 	void __iomem *base_addr;
 	struct device *dev;
 	struct regmap *regmap;
+	struct regmap *toprgu_regmap;
 	struct mutex irq_alloc_lock; /* dynamic alloc irq lock */
 
 	unsigned int const *reg_back_up_list;
diff --git a/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c b/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c
index 4a31106d3471..0e5634b3a8e3 100644
--- a/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c
+++ b/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c
@@ -1089,6 +1089,7 @@ static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev)
 	struct mtk_base_afe *afe;
 	struct mt8183_afe_private *afe_priv;
 	struct device *dev;
+	unsigned int reg_value;
 	int i, irq_id, ret;
 
 	afe = devm_kzalloc(&pdev->dev, sizeof(*afe), GFP_KERNEL);
@@ -1126,6 +1127,26 @@ static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev)
 		return ret;
 	}
 
+	/* toprgu_regmap init */
+	afe->toprgu_regmap = syscon_regmap_lookup_by_phandle(dev->of_node,
+							     "mediatek,toprgu");
+	if (IS_ERR(afe->toprgu_regmap)) {
+		dev_err(dev, "could not get toprgu_regmap from dev\n");
+		return PTR_ERR(afe->toprgu_regmap);
+	}
+
+	/* read TOPRGUWDT_SWSYSRST, the high 8bits must be zero */
+	regmap_read(afe->toprgu_regmap, TOPRGUWDT_SWSYSRST, &reg_value);
+
+	/* write TOPRGUWDT_SWSYSRST, we need set high 8bits as 0x88 first */
+	reg_value |= 0x88000000;
+
+	/* reset audio domain registers */
+	reg_value |= 1 << AUDIO_RST_SFT;
+	regmap_write(afe->toprgu_regmap, TOPRGUWDT_SWSYSRST, reg_value);
+	reg_value &= ~(1 << AUDIO_RST_SFT);
+	regmap_write(afe->toprgu_regmap, TOPRGUWDT_SWSYSRST, reg_value);
+
 	/* enable clock for regcache get default value from hw */
 	afe_priv->pm_runtime_bypass_reg_ctl = true;
 	pm_runtime_get_sync(&pdev->dev);
diff --git a/sound/soc/mediatek/mt8183/mt8183-reg.h b/sound/soc/mediatek/mt8183/mt8183-reg.h
index e544a09e1913..8579ac4052ff 100644
--- a/sound/soc/mediatek/mt8183/mt8183-reg.h
+++ b/sound/soc/mediatek/mt8183/mt8183-reg.h
@@ -413,6 +413,12 @@
 #define AFE_MAX_REGISTER AFE_GENERAL2_ASRC_2CH_CON13
 #define AFE_IRQ_STATUS_BITS 0x1fff
 
+/* TOPRGUWDT_SWSYSRST */
+#define TOPRGUWDT_SWSYSRST 0x18
+#define AUDIO_RST_SFT                                17
+#define AUDIO_RST_MASK                               0x1
+#define AUDIO_RST_MASK_SFT                           (0x1 << 17)
+
 /* AUDIO_TOP_CON3 */
 #define BCK_INVERSE_SFT                              3
 #define BCK_INVERSE_MASK                             0x1
-- 
2.18.0

_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [alsa-devel] [PATCH 2/2] ASoC: mt8183: fix audio playback slowly after playback during bootup
  2019-09-12  9:54 ` [alsa-devel] [PATCH 2/2] ASoC: mt8183: fix audio playback slowly after playback during bootup Jiaxin Yu
@ 2019-09-12 16:50   ` Yingjoe Chen
  0 siblings, 0 replies; 5+ messages in thread
From: Yingjoe Chen @ 2019-09-12 16:50 UTC (permalink / raw)
  To: Jiaxin Yu
  Cc: alsa-devel, lgirdwood, robh+dt, tzungbi, broonie, linux-mediatek,
	eason.yen

On Thu, 2019-09-12 at 17:54 +0800, Jiaxin Yu wrote:
> Before regmap_reinit_cache we must reset audio reg as default value.
> So we use reset controller unit(toprgu) to reset audio hw.
> 
> Signed-off-by: Jiaxin Yu <jiaxin.yu@mediatek.com>
> ---
>  sound/soc/mediatek/common/mtk-base-afe.h   |  1 +
>  sound/soc/mediatek/mt8183/mt8183-afe-pcm.c | 21 +++++++++++++++++++++
>  sound/soc/mediatek/mt8183/mt8183-reg.h     |  6 ++++++
>  3 files changed, 28 insertions(+)
> 
> diff --git a/sound/soc/mediatek/common/mtk-base-afe.h b/sound/soc/mediatek/common/mtk-base-afe.h
> index 60cb609a9790..bccc079ee660 100644
> --- a/sound/soc/mediatek/common/mtk-base-afe.h
> +++ b/sound/soc/mediatek/common/mtk-base-afe.h
> @@ -60,6 +60,7 @@ struct mtk_base_afe {
>  	void __iomem *base_addr;
>  	struct device *dev;
>  	struct regmap *regmap;
> +	struct regmap *toprgu_regmap;
>  	struct mutex irq_alloc_lock; /* dynamic alloc irq lock */
>  
>  	unsigned int const *reg_back_up_list;
> diff --git a/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c b/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c
> index 4a31106d3471..0e5634b3a8e3 100644
> --- a/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c
> +++ b/sound/soc/mediatek/mt8183/mt8183-afe-pcm.c
> @@ -1089,6 +1089,7 @@ static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev)
>  	struct mtk_base_afe *afe;
>  	struct mt8183_afe_private *afe_priv;
>  	struct device *dev;
> +	unsigned int reg_value;
>  	int i, irq_id, ret;
>  
>  	afe = devm_kzalloc(&pdev->dev, sizeof(*afe), GFP_KERNEL);
> @@ -1126,6 +1127,26 @@ static int mt8183_afe_pcm_dev_probe(struct platform_device *pdev)
>  		return ret;
>  	}
>  
> +	/* toprgu_regmap init */
> +	afe->toprgu_regmap = syscon_regmap_lookup_by_phandle(dev->of_node,
> +							     "mediatek,toprgu");
> +	if (IS_ERR(afe->toprgu_regmap)) {
> +		dev_err(dev, "could not get toprgu_regmap from dev\n");
> +		return PTR_ERR(afe->toprgu_regmap);
> +	}
> +
> +	/* read TOPRGUWDT_SWSYSRST, the high 8bits must be zero */
> +	regmap_read(afe->toprgu_regmap, TOPRGUWDT_SWSYSRST, &reg_value);
> +
> +	/* write TOPRGUWDT_SWSYSRST, we need set high 8bits as 0x88 first */
> +	reg_value |= 0x88000000;
> +
> +	/* reset audio domain registers */
> +	reg_value |= 1 << AUDIO_RST_SFT;
> +	regmap_write(afe->toprgu_regmap, TOPRGUWDT_SWSYSRST, reg_value);
> +	reg_value &= ~(1 << AUDIO_RST_SFT);
> +	regmap_write(afe->toprgu_regmap, TOPRGUWDT_SWSYSRST, reg_value);


This register contain reset bits for many components.
If components access it directly at the same time, we might have race
condition.

Instead, watchdog driver should export this as reset controller so this
driver can access it using reset API.

Joe.C


_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [alsa-devel] [PATCH 1/2] ASoC: dt-bingdings: mediatek: mt8183: add a property "medaitek, toprgu"
  2019-09-12  9:54 ` [alsa-devel] [PATCH 1/2] ASoC: dt-bingdings: mediatek: mt8183: add a property "medaitek, toprgu" Jiaxin Yu
@ 2019-09-12 16:52   ` Yingjoe Chen
  0 siblings, 0 replies; 5+ messages in thread
From: Yingjoe Chen @ 2019-09-12 16:52 UTC (permalink / raw)
  To: Jiaxin Yu
  Cc: alsa-devel, lgirdwood, robh+dt, tzungbi, broonie, linux-mediatek,
	eason.yen

On Thu, 2019-09-12 at 17:54 +0800, Jiaxin Yu wrote:
> This patch adds a property "mediatek,toprgu" in example so that we could
> use reset controller(usually we call it toprgu or watchdog) to reset audio
> domain regs.
> 
> Signed-off-by: Jiaxin Yu <jiaxin.yu@mediatek.com>
> ---
>  Documentation/devicetree/bindings/sound/mt8183-afe-pcm.txt | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/sound/mt8183-afe-pcm.txt b/Documentation/devicetree/bindings/sound/mt8183-afe-pcm.txt
> index 396ba38619f6..45ca182a4ecc 100644
> --- a/Documentation/devicetree/bindings/sound/mt8183-afe-pcm.txt
> +++ b/Documentation/devicetree/bindings/sound/mt8183-afe-pcm.txt
> @@ -4,6 +4,7 @@ Required properties:
>  - compatible = "mediatek,mt68183-audio";
>  - reg: register location and size
>  - interrupts: should contain AFE interrupt
> +- mediatek,toprgu: A phandle to the TOPRGU which for reset controller unit
>  - power-domains: should define the power domain
>  - clocks: Must contain an entry for each entry in clock-names
>  - clock-names: should have these clock names:
> @@ -20,6 +21,7 @@ Example:
>  		compatible = "mediatek,mt8183-audio";
>  		reg = <0 0x11220000 0 0x1000>;
>  		interrupts = <GIC_SPI 161 IRQ_TYPE_LEVEL_LOW>;
> +		mediatek,toprgu = <&watchdog>;

As mentioned in the other patch, since this is reset controller,
you should use Documentation/devicetree/bindings/reset/reset.txt
instead.

Joe.C


_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-09-12 16:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-12  9:54 [alsa-devel] [PATCH 0/2] ASoC: mt8183: fix audio playback slowly after playback during bootup Jiaxin Yu
2019-09-12  9:54 ` [alsa-devel] [PATCH 1/2] ASoC: dt-bingdings: mediatek: mt8183: add a property "medaitek, toprgu" Jiaxin Yu
2019-09-12 16:52   ` Yingjoe Chen
2019-09-12  9:54 ` [alsa-devel] [PATCH 2/2] ASoC: mt8183: fix audio playback slowly after playback during bootup Jiaxin Yu
2019-09-12 16:50   ` Yingjoe Chen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).