alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Bard Liao <bardliao@realtek.com>,
	Oder Chiou <oder_chiou@realtek.com>,
	Liam Girdwood <lgirdwood@gmail.com>,
	Mark Brown <broonie@kernel.org>,
	alsa-devel@alsa-project.org, John Keeping <john@metanate.com>
Subject: Re: [PATCH v1 2/3] ASoC: rt5677: Move platform code to board file
Date: Sat, 10 Jun 2017 14:31:14 +0300	[thread overview]
Message-ID: <1497094274.22624.89.camel@linux.intel.com> (raw)
In-Reply-To: <20170609204954.40310-2-andriy.shevchenko@linux.intel.com>

On Fri, 2017-06-09 at 23:49 +0300, Andy Shevchenko wrote:
> 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.

> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  sound/soc/codecs/rt5677.c           | 26 --------------------------
>  sound/soc/intel/boards/bdw-rt5677.c | 27 +++++++++++++++++++++++++++
>  2 files changed, 27 insertions(+), 26 deletions(-)
> 
> diff --git a/sound/soc/codecs/rt5677.c b/sound/soc/codecs/rt5677.c
> index 64cf6cc41ad1..36e530a36c82 100644
> --- a/sound/soc/codecs/rt5677.c
> +++ b/sound/soc/codecs/rt5677.c
> @@ -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;
>  
> diff --git a/sound/soc/intel/boards/bdw-rt5677.c
> b/sound/soc/intel/boards/bdw-rt5677.c
> index 14d9693c1641..e3aa32c2546b 100644
> --- a/sound/soc/intel/boards/bdw-rt5677.c
> +++ b/sound/soc/intel/boards/bdw-rt5677.c
> @@ -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);

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

  reply	other threads:[~2017-06-10 11:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-09 20:49 [PATCH v1 1/3] ASoC: rt5677: Introduce proper table for ACPI enumeration Andy Shevchenko
2017-06-09 20:49 ` [PATCH v1 2/3] ASoC: rt5677: Move platform code to board file Andy Shevchenko
2017-06-10 11:31   ` Andy Shevchenko [this message]
2017-06-09 20:49 ` [PATCH v1 3/3] ASoC: Intel: bdw-rt5677: Switch to devm_acpi_dev_add_driver_gpios() Andy Shevchenko
2017-06-16 16:53 ` Applied "ASoC: rt5677: Introduce proper table for ACPI enumeration" to the asoc tree Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1497094274.22624.89.camel@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=bardliao@realtek.com \
    --cc=broonie@kernel.org \
    --cc=john@metanate.com \
    --cc=lgirdwood@gmail.com \
    --cc=oder_chiou@realtek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).