diff mbox series

[V3] ASoC: amd: add logic to check dmic hardware runtime

Message ID 1593025336-21482-1-git-send-email-Vijendar.Mukunda@amd.com (mailing list archive)
State New, archived
Headers show
Series [V3] ASoC: amd: add logic to check dmic hardware runtime | expand

Commit Message

Vijendar Mukunda June 24, 2020, 7:02 p.m. UTC
Add logic to check DMIC hardware exists or not on
the platform at runtime.

Add module param for overriding DMIC hardware check
at runtime.

Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
---
v3: changed  dmic_acpi_check module param as bint
v2: changed module param usage -1 as default, 0 - skip, 1 - force
 sound/soc/amd/renoir/rn-pci-acp3x.c | 29 +++++++++++++++++++++++++++++
 sound/soc/amd/renoir/rn_acp3x.h     |  2 ++
 2 files changed, 31 insertions(+)

Comments

Jaroslav Kysela June 24, 2020, 6:55 p.m. UTC | #1
Dne 24. 06. 20 v 21:02 Vijendar Mukunda napsal(a):
> Add logic to check DMIC hardware exists or not on
> the platform at runtime.
> 
> Add module param for overriding DMIC hardware check
> at runtime.
> 
> Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>

Reviewed-by: Jaroslav Kysela <perex@perex.cz>

> ---
> v3: changed  dmic_acpi_check module param as bint
> v2: changed module param usage -1 as default, 0 - skip, 1 - force
>   sound/soc/amd/renoir/rn-pci-acp3x.c | 29 +++++++++++++++++++++++++++++
>   sound/soc/amd/renoir/rn_acp3x.h     |  2 ++
>   2 files changed, 31 insertions(+)
> 
> diff --git a/sound/soc/amd/renoir/rn-pci-acp3x.c b/sound/soc/amd/renoir/rn-pci-acp3x.c
> index 859ed67..d1faea5 100644
> --- a/sound/soc/amd/renoir/rn-pci-acp3x.c
> +++ b/sound/soc/amd/renoir/rn-pci-acp3x.c
> @@ -5,6 +5,7 @@
>   //Copyright 2020 Advanced Micro Devices, Inc.
>   
>   #include <linux/pci.h>
> +#include <linux/acpi.h>
>   #include <linux/module.h>
>   #include <linux/io.h>
>   #include <linux/delay.h>
> @@ -18,6 +19,16 @@ static int acp_power_gating;
>   module_param(acp_power_gating, int, 0644);
>   MODULE_PARM_DESC(acp_power_gating, "Enable acp power gating");
>   
> +/**
> + * dmic_acpi_check = -1 - Checks ACPI method to know DMIC hardware status runtime
> + *                 = 0 - Skips the DMIC device creation and returns probe failure
> + *                 = 1 - Assumes that platform has DMIC support and skips ACPI
> + *                       method check
> + */
> +static int dmic_acpi_check = ACP_DMIC_AUTO;
> +module_param(dmic_acpi_check, bint, 0644);
> +MODULE_PARM_DESC(dmic_acpi_check, "checks Dmic hardware runtime");
> +
>   struct acp_dev_data {
>   	void __iomem *acp_base;
>   	struct resource *res;
> @@ -157,6 +168,8 @@ static int snd_rn_acp_probe(struct pci_dev *pci,
>   {
>   	struct acp_dev_data *adata;
>   	struct platform_device_info pdevinfo[ACP_DEVS];
> +	acpi_handle handle;
> +	acpi_integer dmic_status;
>   	unsigned int irqflags;
>   	int ret, index;
>   	u32 addr;
> @@ -201,6 +214,22 @@ static int snd_rn_acp_probe(struct pci_dev *pci,
>   	if (ret)
>   		goto disable_msi;
>   
> +	if (!dmic_acpi_check) {
> +		ret = -ENODEV;
> +		goto de_init;
> +	} else if (dmic_acpi_check == ACP_DMIC_AUTO) {
> +		handle = ACPI_HANDLE(&pci->dev);
> +		ret = acpi_evaluate_integer(handle, "_WOV", NULL, &dmic_status);
> +		if (ACPI_FAILURE(ret)) {
> +			ret = -EINVAL;
> +			goto de_init;
> +		}
> +		if (!dmic_status) {
> +			ret = -ENODEV;
> +			goto de_init;
> +		}
> +	}
> +
>   	adata->res = devm_kzalloc(&pci->dev,
>   				  sizeof(struct resource) * 2,
>   				  GFP_KERNEL);
> diff --git a/sound/soc/amd/renoir/rn_acp3x.h b/sound/soc/amd/renoir/rn_acp3x.h
> index 75228e3..1462039 100644
> --- a/sound/soc/amd/renoir/rn_acp3x.h
> +++ b/sound/soc/amd/renoir/rn_acp3x.h
> @@ -55,6 +55,8 @@
>   
>   #define MAX_BUFFER (CAPTURE_MAX_PERIOD_SIZE * CAPTURE_MAX_NUM_PERIODS)
>   #define MIN_BUFFER MAX_BUFFER
> +#define	ACP_DMIC_AUTO   -1
> +
>   struct pdm_dev_data {
>   	u32 pdm_irq;
>   	void __iomem *acp_base;
>
Mark Brown June 25, 2020, 11:11 a.m. UTC | #2
On Wed, Jun 24, 2020 at 08:55:45PM +0200, Jaroslav Kysela wrote:
> Dne 24. 06. 20 v 21:02 Vijendar Mukunda napsal(a):
> > Add logic to check DMIC hardware exists or not on
> > the platform at runtime.
> > 
> > Add module param for overriding DMIC hardware check
> > at runtime.
> > 
> > Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
> 
> Reviewed-by: Jaroslav Kysela <perex@perex.cz>

As documented in submitting-patches.rst please send patches to the 
maintainers for the code you would like to change.  The normal kernel
workflow is that people apply patches from their inboxes, if they aren't
copied they are likely to not see the patch at all and it is much more
difficult to apply patches.
Vijendar Mukunda June 25, 2020, 12:02 p.m. UTC | #3
On 25/06/20 4:41 pm, Mark Brown wrote:
> On Wed, Jun 24, 2020 at 08:55:45PM +0200, Jaroslav Kysela wrote:
>> Dne 24. 06. 20 v 21:02 Vijendar Mukunda napsal(a):
>>> Add logic to check DMIC hardware exists or not on
>>> the platform at runtime.
>>>
>>> Add module param for overriding DMIC hardware check
>>> at runtime.
>>>
>>> Signed-off-by: Vijendar Mukunda <Vijendar.Mukunda@amd.com>
>>
>> Reviewed-by: Jaroslav Kysela <perex@perex.cz>
> 
> As documented in submitting-patches.rst please send patches to the
> maintainers for the code you would like to change.  The normal kernel
> workflow is that people apply patches from their inboxes, if they aren't
> copied they are likely to not see the patch at all and it is much more
> difficult to apply patches.

Next time onwards, i will make sure using maintainer list for posting 
new patch.
>
Mark Brown June 25, 2020, 1:22 p.m. UTC | #4
On Thu, Jun 25, 2020 at 05:32:33PM +0530, Mukunda,Vijendar wrote:

> Next time onwards, i will make sure using maintainer list for posting new
> patch.

Please send me this patch as well if you want me to review it.
diff mbox series

Patch

diff --git a/sound/soc/amd/renoir/rn-pci-acp3x.c b/sound/soc/amd/renoir/rn-pci-acp3x.c
index 859ed67..d1faea5 100644
--- a/sound/soc/amd/renoir/rn-pci-acp3x.c
+++ b/sound/soc/amd/renoir/rn-pci-acp3x.c
@@ -5,6 +5,7 @@ 
 //Copyright 2020 Advanced Micro Devices, Inc.
 
 #include <linux/pci.h>
+#include <linux/acpi.h>
 #include <linux/module.h>
 #include <linux/io.h>
 #include <linux/delay.h>
@@ -18,6 +19,16 @@  static int acp_power_gating;
 module_param(acp_power_gating, int, 0644);
 MODULE_PARM_DESC(acp_power_gating, "Enable acp power gating");
 
+/**
+ * dmic_acpi_check = -1 - Checks ACPI method to know DMIC hardware status runtime
+ *                 = 0 - Skips the DMIC device creation and returns probe failure
+ *                 = 1 - Assumes that platform has DMIC support and skips ACPI
+ *                       method check
+ */
+static int dmic_acpi_check = ACP_DMIC_AUTO;
+module_param(dmic_acpi_check, bint, 0644);
+MODULE_PARM_DESC(dmic_acpi_check, "checks Dmic hardware runtime");
+
 struct acp_dev_data {
 	void __iomem *acp_base;
 	struct resource *res;
@@ -157,6 +168,8 @@  static int snd_rn_acp_probe(struct pci_dev *pci,
 {
 	struct acp_dev_data *adata;
 	struct platform_device_info pdevinfo[ACP_DEVS];
+	acpi_handle handle;
+	acpi_integer dmic_status;
 	unsigned int irqflags;
 	int ret, index;
 	u32 addr;
@@ -201,6 +214,22 @@  static int snd_rn_acp_probe(struct pci_dev *pci,
 	if (ret)
 		goto disable_msi;
 
+	if (!dmic_acpi_check) {
+		ret = -ENODEV;
+		goto de_init;
+	} else if (dmic_acpi_check == ACP_DMIC_AUTO) {
+		handle = ACPI_HANDLE(&pci->dev);
+		ret = acpi_evaluate_integer(handle, "_WOV", NULL, &dmic_status);
+		if (ACPI_FAILURE(ret)) {
+			ret = -EINVAL;
+			goto de_init;
+		}
+		if (!dmic_status) {
+			ret = -ENODEV;
+			goto de_init;
+		}
+	}
+
 	adata->res = devm_kzalloc(&pci->dev,
 				  sizeof(struct resource) * 2,
 				  GFP_KERNEL);
diff --git a/sound/soc/amd/renoir/rn_acp3x.h b/sound/soc/amd/renoir/rn_acp3x.h
index 75228e3..1462039 100644
--- a/sound/soc/amd/renoir/rn_acp3x.h
+++ b/sound/soc/amd/renoir/rn_acp3x.h
@@ -55,6 +55,8 @@ 
 
 #define MAX_BUFFER (CAPTURE_MAX_PERIOD_SIZE * CAPTURE_MAX_NUM_PERIODS)
 #define MIN_BUFFER MAX_BUFFER
+#define	ACP_DMIC_AUTO   -1
+
 struct pdm_dev_data {
 	u32 pdm_irq;
 	void __iomem *acp_base;