diff mbox series

[1/4] ASoC: rt5645: Introduce mapping for ACPI-defined GPIO

Message ID 20210107090625.107078-2-chiu@endlessos.org (mailing list archive)
State Superseded
Headers show
Series ASoC: rt5645: Enable internal mic and headset on ECS EF20 | expand

Commit Message

Chris Chiu Jan. 7, 2021, 9:06 a.m. UTC
On at least one laptop (ECS EF20EA) the 'hp-detect' GPIO is defined in
the DSDT table by the ACPI GpioIo resources in _CRS. The GPIO related
information should be mapped to the rt5645 driver to enable the jack
detection also on non-DT platforms.

Signed-off-by: Chris Chiu <chiu@endlessos.org>
---
 sound/soc/codecs/rt5645.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Mark Brown Jan. 7, 2021, 2:27 p.m. UTC | #1
On Thu, Jan 07, 2021 at 05:06:22PM +0800, Chris Chiu wrote:

> +static const struct acpi_gpio_mapping *cht_rt5645_gpios;
> +

You're adding a read only static variable with no way to set it.  This
doesn't actually do anything?

> @@ -3780,7 +3782,6 @@ static const struct dmi_system_id dmi_platform_data[] = {
>  		},
>  		.driver_data = (void *)&intel_braswell_platform_data,
>  	},
> -	{ }
>  };
>  

This is an unrelated change which removes the terminator on the array
which will cause issues.
Chris Chiu Jan. 8, 2021, 3:30 a.m. UTC | #2
On Thu, Jan 7, 2021 at 10:28 PM Mark Brown <broonie@kernel.org> wrote:
>
> On Thu, Jan 07, 2021 at 05:06:22PM +0800, Chris Chiu wrote:
>
> > +static const struct acpi_gpio_mapping *cht_rt5645_gpios;
> > +
>
> You're adding a read only static variable with no way to set it.  This
> doesn't actually do anything?
>
This is a pointer to a 'const 'struct acpi_gpio_mapping', and I will
need it to point to
the 'static const struct acpi_gpio_mapping cht_rt5645_ef20_gpios[]' in
my consequent
patch '[PATCH 2/4] ASoC: rt5645: Add ACPI-defined GPIO for ECS EF20 series'.

I take the same idea from 'sound/soc/intel/boards/bytcr_rt5651.c' line 90.
And it did work as expected on my ECS EF20EA

> > @@ -3780,7 +3782,6 @@ static const struct dmi_system_id dmi_platform_data[] = {
> >               },
> >               .driver_data = (void *)&intel_braswell_platform_data,
> >       },
> > -     { }
> >  };
> >
>
> This is an unrelated change which removes the terminator on the array
> which will cause issues.

Thanks for pointing that out. It's not my intention. I accidentally
removed it. I'll fix this in v3.

Chris
diff mbox series

Patch

diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c
index 420003d062c7..78f0ab0a008e 100644
--- a/sound/soc/codecs/rt5645.c
+++ b/sound/soc/codecs/rt5645.c
@@ -42,6 +42,8 @@  static unsigned int quirk = -1;
 module_param(quirk, uint, 0444);
 MODULE_PARM_DESC(quirk, "RT5645 pdata quirk override");
 
+static const struct acpi_gpio_mapping *cht_rt5645_gpios;
+
 #define RT5645_DEVICE_ID 0x6308
 #define RT5650_DEVICE_ID 0x6419
 
@@ -3780,7 +3782,6 @@  static const struct dmi_system_id dmi_platform_data[] = {
 		},
 		.driver_data = (void *)&intel_braswell_platform_data,
 	},
-	{ }
 };
 
 static bool rt5645_check_dp(struct device *dev)
@@ -3848,6 +3849,10 @@  static int rt5645_i2c_probe(struct i2c_client *i2c,
 		rt5645->pdata.dmic2_data_pin = QUIRK_DMIC2_DATA_PIN(quirk);
 	}
 
+	if (cht_rt5645_gpios && has_acpi_companion(&i2c->dev))
+		if (devm_acpi_dev_add_driver_gpios(&i2c->dev, cht_rt5645_gpios))
+			dev_dbg(&i2c->dev, "Failed to add driver gpios\n");
+
 	rt5645->gpiod_hp_det = devm_gpiod_get_optional(&i2c->dev, "hp-detect",
 						       GPIOD_IN);