devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
To: lee.jones@linaro.org, cw00.choi@samsung.com
Cc: myungjoo.ham@samsung.com, sameo@linux.intel.com,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	patches@opensource.wolfsonmicro.com
Subject: [PATCH v2 3/5] extcon: arizona: Convert to gpiod
Date: Thu, 18 Jun 2015 15:43:49 +0100	[thread overview]
Message-ID: <1434638631-16451-4-git-send-email-ckeepax@opensource.wolfsonmicro.com> (raw)
In-Reply-To: <1434638631-16451-1-git-send-email-ckeepax@opensource.wolfsonmicro.com>

Convert to using the newer gpiod interface for the micd_pol_gpio.
Although we still carry support for the old gpio interface from pdata.

Signed-off-by: Charles Keepax <ckeepax@opensource.wolfsonmicro.com>
---
 drivers/extcon/extcon-arizona.c |   36 +++++++++++++++++++++++++++++++-----
 1 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/drivers/extcon/extcon-arizona.c b/drivers/extcon/extcon-arizona.c
index 5bf1b19..71d60ba 100644
--- a/drivers/extcon/extcon-arizona.c
+++ b/drivers/extcon/extcon-arizona.c
@@ -20,6 +20,7 @@
 #include <linux/slab.h>
 #include <linux/interrupt.h>
 #include <linux/err.h>
+#include <linux/gpio/consumer.h>
 #include <linux/gpio.h>
 #include <linux/input.h>
 #include <linux/platform_device.h>
@@ -95,6 +96,8 @@ struct arizona_extcon_info {
 	int hpdet_ip_version;
 
 	struct extcon_dev *edev;
+
+	struct gpio_desc *micd_pol_gpio;
 };
 
 static const struct arizona_micd_config micd_default_modes[] = {
@@ -205,6 +208,10 @@ static void arizona_extcon_set_mode(struct arizona_extcon_info *info, int mode)
 	if (arizona->pdata.micd_pol_gpio > 0)
 		gpio_set_value_cansleep(arizona->pdata.micd_pol_gpio,
 					info->micd_modes[mode].gpio);
+	else if (info->micd_pol_gpio)
+		gpiod_set_value_cansleep(info->micd_pol_gpio,
+					 info->micd_modes[mode].gpio);
+
 	regmap_update_bits(arizona->regmap, ARIZONA_MIC_DETECT_1,
 			   ARIZONA_MICD_BIAS_SRC_MASK,
 			   info->micd_modes[mode].bias <<
@@ -1271,6 +1278,22 @@ static int arizona_extcon_probe(struct platform_device *pdev)
 				arizona->pdata.micd_pol_gpio, ret);
 			goto err_register;
 		}
+	} else {
+		if (info->micd_modes[0].gpio)
+			mode = GPIOD_OUT_HIGH;
+		else
+			mode = GPIOD_OUT_LOW;
+
+		info->micd_pol_gpio = gpiod_get_optional(arizona->dev,
+							 "wlf,micd-pol",
+							 GPIOD_OUT_LOW);
+		if (IS_ERR(info->micd_pol_gpio)) {
+			ret = PTR_ERR(info->micd_pol_gpio);
+			dev_err(arizona->dev,
+				"Failed to get microphone polarity GPIO: %d\n",
+				ret);
+			goto err_register;
+		}
 	}
 
 	if (arizona->pdata.hpdet_id_gpio > 0) {
@@ -1281,7 +1304,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)
 		if (ret != 0) {
 			dev_err(arizona->dev, "Failed to request GPIO%d: %d\n",
 				arizona->pdata.hpdet_id_gpio, ret);
-			goto err_register;
+			goto err_gpio;
 		}
 	}
 
@@ -1325,7 +1348,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)
 				dev_err(arizona->dev,
 					"MICD ranges must be sorted\n");
 				ret = -EINVAL;
-				goto err_input;
+				goto err_gpio;
 			}
 		}
 	}
@@ -1344,7 +1367,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)
 			dev_err(arizona->dev, "Unsupported MICD level %d\n",
 				info->micd_ranges[i].max);
 			ret = -EINVAL;
-			goto err_input;
+			goto err_gpio;
 		}
 
 		dev_dbg(arizona->dev, "%d ohms for MICD threshold %d\n",
@@ -1417,7 +1440,7 @@ static int arizona_extcon_probe(struct platform_device *pdev)
 	if (ret != 0) {
 		dev_err(&pdev->dev, "Failed to get JACKDET rise IRQ: %d\n",
 			ret);
-		goto err_input;
+		goto err_gpio;
 	}
 
 	ret = arizona_set_irq_wake(arizona, jack_irq_rise, 1);
@@ -1488,7 +1511,8 @@ err_rise_wake:
 	arizona_set_irq_wake(arizona, jack_irq_rise, 0);
 err_rise:
 	arizona_free_irq(arizona, jack_irq_rise, info);
-err_input:
+err_gpio:
+	gpiod_put(info->micd_pol_gpio);
 err_register:
 	pm_runtime_disable(&pdev->dev);
 	return ret;
@@ -1500,6 +1524,8 @@ static int arizona_extcon_remove(struct platform_device *pdev)
 	struct arizona *arizona = info->arizona;
 	int jack_irq_rise, jack_irq_fall;
 
+	gpiod_put(info->micd_pol_gpio);
+
 	pm_runtime_disable(&pdev->dev);
 
 	regmap_update_bits(arizona->regmap,
-- 
1.7.2.5

  parent reply	other threads:[~2015-06-18 14:43 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-18 14:43 [PATCH v2 0/5] Add basic microphone detection bindings Charles Keepax
     [not found] ` <1434638631-16451-1-git-send-email-ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2015-06-18 14:43   ` [PATCH v2 1/5] extcon: arizona: Update to use the new device properties API Charles Keepax
     [not found]     ` <1434638631-16451-2-git-send-email-ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2015-06-19  2:14       ` Chanwoo Choi
2015-06-18 14:43   ` [PATCH v2 2/5] extcon: arizona: Add basic microphone detection DT/ACPI bindings Charles Keepax
     [not found]     ` <1434638631-16451-3-git-send-email-ckeepax-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2015-06-19  2:25       ` Chanwoo Choi
     [not found]         ` <CAGTfZH0uds0swf-x0naTJeMRvOB6DkekdmSSGWA5KpNCWVOWZw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-06-19  8:17           ` Charles Keepax
     [not found]             ` <20150619081737.GS32730-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2015-06-19  8:28               ` Chanwoo Choi
     [not found]                 ` <CAGTfZH1a6H4Virm-mZDeOD9Pt5M-Q13xo7v+bQwBguJuy1AJXg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-06-19  9:08                   ` Charles Keepax
2015-06-19 10:31                     ` Chanwoo Choi
     [not found]                       ` <CAGTfZH19cvcb2PXn69pZY-JpkaOYsCsJC1rrQWy06eNav=+VuA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-06-19 10:44                         ` Charles Keepax
2015-06-19 11:03                           ` Chanwoo Choi
     [not found]                             ` <CAGTfZH2OpzWR_VQrkCVPD+NKf4+D8e4TytsSeek+kDk2BQH_yQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-06-19 11:59                               ` Charles Keepax
2015-06-18 14:43 ` Charles Keepax [this message]
2015-06-19  2:36   ` [PATCH v2 3/5] extcon: arizona: Convert to gpiod Chanwoo Choi
     [not found]     ` <CAGTfZH0AsRwcFwevAiQeyL=VUxiCvCx+3OEFKQ4nV3DpRdsdoQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-06-19  8:14       ` Charles Keepax
     [not found]         ` <20150619081433.GR32730-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2015-06-19  8:39           ` Chanwoo Choi
2015-06-19  9:13             ` Charles Keepax
2015-06-19  9:50               ` Chanwoo Choi
     [not found]                 ` <CAGTfZH3RWaSGKM66dp1YeLivPq504mys-xnBFJ56ob_qWZ03nA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-06-19  9:54                   ` Charles Keepax
2015-06-18 14:43 ` [PATCH v2 4/5] mfd: arizona: Update DT doc for new mic detection bindings Charles Keepax
2015-06-18 14:43 ` [PATCH v2 5/5] mfd: arizona: Update several pdata members to unsigned Charles Keepax

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=1434638631-16451-4-git-send-email-ckeepax@opensource.wolfsonmicro.com \
    --to=ckeepax@opensource.wolfsonmicro.com \
    --cc=cw00.choi@samsung.com \
    --cc=devicetree@vger.kernel.org \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=myungjoo.ham@samsung.com \
    --cc=patches@opensource.wolfsonmicro.com \
    --cc=sameo@linux.intel.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).