ASoC: rt5677: Introduce proper table for ACPI enumeration
Subsystems (4)
PATCH 1/3 ASoC: rt5677: Introduce proper table for ACPI enumeration
I2C devices are enumerated by IDs, and not by instances. Make it clear by using proper module device table for ACPI case.
--- sound/soc/codecs/rt5677.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
sound/soc/codecs/rt5677.c +9 -1
@@ -5030,7 +5030,6 @@ static const struct regmap_config rt5677_regmap = {static const struct i2c_device_id rt5677_i2c_id[] = { {"rt5677" ,RT5677 }, {"rt5676" ,RT5676 }, - {"RT5677CE:00" ,RT5677 }, { } };MODULE_DEVICE_TABLE (i2c, rt5677_i2c_id);
@@ -5041,6 +5040,14 @@ static const struct of_device_id rt5677_of_match[] = { };MODULE_DEVICE_TABLE (of, rt5677_of_match); +#ifdef CONFIG_ACPI +static const struct acpi_device_id rt5677_acpi_match[] = { + {"RT5677CE" ,RT5677 }, + { } +}; +MODULE_DEVICE_TABLE (acpi, rt5677_acpi_match); +#endif +static const struct acpi_gpio_params plug_det_gpio = {RT5677_GPIO_PLUG_DET ,0 , false };static const struct acpi_gpio_params mic_present_gpio = {RT5677_GPIO_MIC_PRESENT_L ,0 , false };static const struct acpi_gpio_params headphone_enable_gpio = {RT5677_GPIO_HP_AMP_SHDN_L ,0 , false };
@@ -5301,6 +5308,7 @@ static struct i2c_driver rt5677_i2c_driver = { .driver = { .name = "rt5677", .of_match_table = rt5677_of_match, + .acpi_match_table = ACPI_PTR(rt5677_acpi_match), }, .probe = rt5677_i2c_probe, .remove = rt5677_i2c_remove,
Signature · 1 line
2.11.0
PATCH 2/3 ASoC: rt5677: Move platform code to board file
GPIO ACPI mapping table is defined on platform basis. Codec driver shouldn't have known what platform is using it.
Make codec driver more generic by moving platform code to where it belongs.
--- sound/soc/codecs/rt5677.c | 26 -------------------------- sound/soc/intel/boards/bdw-rt5677.c | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 26 deletions(-)
sound/soc/codecs/rt5677.c +0 -26
@@ -41,15 +41,6 @@#define RT5677_PR_BASE (RT5677_PR_RANGE_BASE + (0 * RT5677_PR_SPACING)) -/* GPIO indexes defined by ACPI */ -enum { -RT5677_GPIO_PLUG_DET =0 , -RT5677_GPIO_MIC_PRESENT_L =1 , -RT5677_GPIO_HOTWORD_DET_L =2 , -RT5677_GPIO_DSP_INT =3 , -RT5677_GPIO_HP_AMP_SHDN_L =4 , -}; -static const struct regmap_range_cfg rt5677_ranges[] = { { .name ="PR" ,
@@ -5048,28 +5039,11 @@ static const struct acpi_device_id rt5677_acpi_match[] = {MODULE_DEVICE_TABLE (acpi, rt5677_acpi_match);#endif -static const struct acpi_gpio_params plug_det_gpio = {RT5677_GPIO_PLUG_DET ,0 , false }; -static const struct acpi_gpio_params mic_present_gpio = {RT5677_GPIO_MIC_PRESENT_L ,0 , false }; -static const struct acpi_gpio_params headphone_enable_gpio = {RT5677_GPIO_HP_AMP_SHDN_L ,0 , false }; - -static const struct acpi_gpio_mapping bdw_rt5677_gpios[] = { - {"plug-det-gpios" , &plug_det_gpio,1 }, - {"mic-present-gpios" , &mic_present_gpio,1 }, - {"headphone-enable-gpios" , &headphone_enable_gpio,1 }, - {NULL }, -}; -static void rt5677_read_acpi_properties (struct rt5677_priv *rt5677,struct device *dev) { -int ret;u32 val; - ret =acpi_dev_add_driver_gpios (ACPI_COMPANION (dev), - bdw_rt5677_gpios); -if (ret) -dev_warn (dev,"Failed to add driver gpios\n" ); -if (!device_property_read_u32 (dev,"DCLK" , &val)) rt5677->pdata.dmic2_clk_pin = val;
sound/soc/intel/boards/bdw-rt5677.c +27 -0
@@ -16,6 +16,7 @@* along with this program. If not, see <http://www.gnu.org/licenses/>. */ +#include <linux/acpi.h> #include <linux/module.h> #include <linux/platform_device.h> #include <linux/gpio/consumer.h>
@@ -120,6 +121,26 @@ static struct snd_soc_jack_gpio mic_jack_gpio = { .invert = 1, }; +/* GPIO indexes defined by ACPI */ +enum { +RT5677_GPIO_PLUG_DET =0 , +RT5677_GPIO_MIC_PRESENT_L =1 , +RT5677_GPIO_HOTWORD_DET_L =2 , +RT5677_GPIO_DSP_INT =3 , +RT5677_GPIO_HP_AMP_SHDN_L =4 , +}; + +static const struct acpi_gpio_params plug_det_gpio = {RT5677_GPIO_PLUG_DET ,0 , false }; +static const struct acpi_gpio_params mic_present_gpio = {RT5677_GPIO_MIC_PRESENT_L ,0 , false }; +static const struct acpi_gpio_params headphone_enable_gpio = {RT5677_GPIO_HP_AMP_SHDN_L ,0 , false }; + +static const struct acpi_gpio_mapping bdw_rt5677_gpios[] = { + {"plug-det-gpios" , &plug_det_gpio,1 }, + {"mic-present-gpios" , &mic_present_gpio,1 }, + {"headphone-enable-gpios" , &headphone_enable_gpio,1 }, + {NULL }, +}; +static int broadwell_ssp0_fixup (struct snd_soc_pcm_runtime *rtd,struct snd_pcm_hw_params *params) {
@@ -314,6 +335,7 @@ static struct snd_soc_card bdw_rt5677_card = {static int bdw_rt5677_probe (struct platform_device *pdev) {struct bdw_rt5677_priv *bdw_rt5677; +int ret; bdw_rt5677_card.dev = &pdev->dev;
@@ -325,6 +347,11 @@ static int bdw_rt5677_probe(struct platform_device *pdev)return -ENOMEM ; } + ret =acpi_dev_add_driver_gpios (ACPI_COMPANION (&pdev->dev), + bdw_rt5677_gpios); +if (ret) +dev_warn (&pdev->dev,"Failed to add driver gpios\n" ); +snd_soc_card_set_drvdata (&bdw_rt5677_card, bdw_rt5677);return devm_snd_soc_register_card (&pdev->dev, &bdw_rt5677_card);
Signature · 1 line
2.11.0
Re: [PATCH v1 2/3] ASoC: rt5677: Move platform code to board file
Quoted 6 lines · Andy Shevchenko
GPIO ACPI mapping table is defined on platform basis. Codec driver shouldn't have known what platform is using it.
Make codec driver more generic by moving platform code to where it belongs.
It will not work like this. We need to take care about actual device to which GPIOs belongs to.
I will fix it in v2.
Quoted 126 lines
Signed-off-by Andy Shevchenko <[email protected]>---
sound/soc/codecs/rt5677.c | 26 --------------------------sound/soc/intel/boards/bdw-rt5677.c| 27 +++++++++++++++++++++++++++2 files changed, 27 insertions(+), 26 deletions(-)sound/soc/codecs/rt5677.c +0
-0@@ -41,15 +41,6 @@
#defineRT5677_PR_BASE(RT5677_PR_RANGE_BASE+ (0 *RT5677_PR_SPACING))sound/soc/codecs/rt5677.c +0
-9-/* GPIO indexes defined by ACPI */ -enum { -RT5677_GPIO_PLUG_DET =0 , -RT5677_GPIO_MIC_PRESENT_L =1 , -RT5677_GPIO_HOTWORD_DET_L =2 , -RT5677_GPIO_DSP_INT =3 , -RT5677_GPIO_HP_AMP_SHDN_L =4 , -}; -static const struct
regmap_range_cfgrt5677_ranges[] = { {
.name = "PR",sound/soc/codecs/rt5677.c +0
-0@@ -5048,28 +5039,11 @@ static const struct acpi_device_id rt5677_acpi_match[] = { MODULE_DEVICE_TABLE(acpi, rt5677_acpi_match); #endif
-static const structacpi_gpio_paramsplug_det_gpio= {RT5677_GPIO_PLUG_DET, 0, false };
-static const structacpi_gpio_paramsmic_present_gpio= {RT5677_GPIO_MIC_PRESENT_L, 0, false };
-static const structacpi_gpio_paramsheadphone_enable_gpio= {RT5677_GPIO_HP_AMP_SHDN_L, 0, false };sound/soc/codecs/rt5677.c +0
-8- -static const struct acpi_gpio_mapping bdw_rt5677_gpios[] = { - {"plug-det-gpios" , &plug_det_gpio,1 }, - {"mic-present-gpios" , &mic_present_gpio,1 }, - {"headphone-enable-gpios" , &headphone_enable_gpio,1 }, - {NULL }, -}; -static void
rt5677_read_acpi_properties(struct rt5677_priv *rt5677, struct device *dev)
{sound/soc/codecs/rt5677.c +0
-1-int ret;u32 val;
sound/soc/codecs/rt5677.c +0
-5- ret =acpi_dev_add_driver_gpios (ACPI_COMPANION (dev), - bdw_rt5677_gpios); -if (ret) -dev_warn (dev,"Failed to add driver gpios\n" ); -if (!device_property_read_u32(dev, "DCLK", &val))
rt5677->pdata.dmic2_clk_pin= val;sound/soc/intel/boards/bdw-rt5677.c +0
-0@@ -16,6 +16,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include <linux/acpi.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/gpio/consumer.h>sound/soc/intel/boards/bdw-rt5677.c +0
-0@@ -120,6 +121,26 @@ static struct snd_soc_jack_gpio mic_jack_gpio = { .invert = 1, };sound/soc/intel/boards/bdw-rt5677.c +10
-0+/* GPIO indexes defined by ACPI */ +enum { +RT5677_GPIO_PLUG_DET =0 , +RT5677_GPIO_MIC_PRESENT_L =1 , +RT5677_GPIO_HOTWORD_DET_L =2 , +RT5677_GPIO_DSP_INT =3 , +RT5677_GPIO_HP_AMP_SHDN_L =4 , +}; + +static const struct acpi_gpio_params plug_det_gpio = {
RT5677_GPIO_PLUG_DET, 0, false };
+static const structacpi_gpio_paramsmic_present_gpio= {RT5677_GPIO_MIC_PRESENT_L, 0, false };
+static const structacpi_gpio_paramsheadphone_enable_gpio= {RT5677_GPIO_HP_AMP_SHDN_L, 0, false };sound/soc/intel/boards/bdw-rt5677.c +8
-0+ +static const struct acpi_gpio_mapping bdw_rt5677_gpios[] = { + {"plug-det-gpios" , &plug_det_gpio,1 }, + {"mic-present-gpios" , &mic_present_gpio,1 }, + {"headphone-enable-gpios" , &headphone_enable_gpio,1 }, + {NULL }, +}; +static int
broadwell_ssp0_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_params *params){sound/soc/intel/boards/bdw-rt5677.c +1
-0@@ -314,6 +335,7 @@ static struct snd_soc_card bdw_rt5677_card = { static int bdw_rt5677_probe(struct platform_device *pdev) { struct bdw_rt5677_priv *bdw_rt5677; +int ret;
bdw_rt5677_card.dev =&pdev->dev;sound/soc/intel/boards/bdw-rt5677.c +0
-0@@ -325,6 +347,11 @@ static int bdw_rt5677_probe(struct platform_device *pdev) return -ENOMEM; }sound/soc/intel/boards/bdw-rt5677.c +5
-0+ ret =acpi_dev_add_driver_gpios (ACPI_COMPANION (&pdev->dev), + bdw_rt5677_gpios); +if (ret) +dev_warn (&pdev->dev,"Failed to add driver gpios\n" ); +
snd_soc_card_set_drvdata(&bdw_rt5677_card, bdw_rt5677);
returndevm_snd_soc_register_card(&pdev->dev, &bdw_rt5677_card);
Signature · 6 lines
Andy Shevchenko <[email protected]> Intel Finland Oy _______________________________________________ Alsa-devel mailing list [email protected] http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
PATCH 3/3 ASoC: Intel: bdw-rt5677: Switch to devm_acpi_dev_add_driver_gpios()
In reply to Andy ShevchenkoSwitch to use managed variant of acpi_dev_add_driver_gpios() to simplify error path and fix potentially wrong assingment if ->probe() fails.
--- sound/soc/intel/boards/bdw-rt5677.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/intel/boards/bdw-rt5677.c +1 -2
@@ -347,8 +347,7 @@ static int bdw_rt5677_probe(struct platform_device *pdev)return -ENOMEM ; } - ret =acpi_dev_add_driver_gpios (ACPI_COMPANION (&pdev->dev), - bdw_rt5677_gpios); + ret =devm_acpi_dev_add_driver_gpios (&pdev->dev, bdw_rt5677_gpios);if (ret)dev_warn (&pdev->dev,"Failed to add driver gpios\n" );
Signature · 1 line
2.11.0
Mark Brown
maintainerApplied "ASoC: rt5677: Introduce proper table for ACPI enumeration" to the asoc tree
In reply to Andy ShevchenkoThe patch
ASoC: rt5677: Introduce proper table for ACPI enumeration
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All 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
Quoted 1 line
From
a36afb0ab6488eaa2c9672d6c20a966a7c08ef65Mon Sep 17 00:00:00 2001
From: Andy Shevchenko <[email protected]>
Date: Thu, 15 Jun 2017 15:46:36 +0300
Subject: [PATCH] ASoC: rt5677: Introduce proper table for ACPI enumeration
I2C devices are enumerated by IDs, and not by instances. Make it clear by using proper module device table for ACPI case.
--- sound/soc/codecs/rt5677.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
sound/soc/codecs/rt5677.c +9 -1
@@ -5030,7 +5030,6 @@ static const struct regmap_config rt5677_regmap = {static const struct i2c_device_id rt5677_i2c_id[] = { {"rt5677" ,RT5677 }, {"rt5676" ,RT5676 }, - {"RT5677CE:00" ,RT5677 }, { } };MODULE_DEVICE_TABLE (i2c, rt5677_i2c_id);
@@ -5041,6 +5040,14 @@ static const struct of_device_id rt5677_of_match[] = { };MODULE_DEVICE_TABLE (of, rt5677_of_match); +#ifdef CONFIG_ACPI +static const struct acpi_device_id rt5677_acpi_match[] = { + {"RT5677CE" ,RT5677 }, + { } +}; +MODULE_DEVICE_TABLE (acpi, rt5677_acpi_match); +#endif +static const struct acpi_gpio_params plug_det_gpio = {RT5677_GPIO_PLUG_DET ,0 , false };static const struct acpi_gpio_params mic_present_gpio = {RT5677_GPIO_MIC_PRESENT_L ,0 , false };static const struct acpi_gpio_params headphone_enable_gpio = {RT5677_GPIO_HP_AMP_SHDN_L ,0 , false };
@@ -5301,6 +5308,7 @@ static struct i2c_driver rt5677_i2c_driver = { .driver = { .name = "rt5677", .of_match_table = rt5677_of_match, + .acpi_match_table = ACPI_PTR(rt5677_acpi_match), }, .probe = rt5677_i2c_probe, .remove = rt5677_i2c_remove,
Signature · 1 line
2.11.0