2014-08-30 09:32:58 +00:00
|
|
|
From 469f83e0ed374250be5fd6202ac535276a752fa8 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Bjorn Andersson <bjorn@kryo.se>
|
|
|
|
Date: Tue, 4 Feb 2014 19:55:31 -0800
|
|
|
|
Subject: [PATCH 033/182] pinctrl-msm: Support output-{high,low} configuration
|
|
|
|
|
|
|
|
Add support for configuring pins as output with value as from the
|
|
|
|
pinconf-generic interface.
|
|
|
|
|
|
|
|
Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
|
|
|
|
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
|
|
|
|
---
|
|
|
|
drivers/pinctrl/pinctrl-msm.c | 27 +++++++++++++++++++++++++++
|
|
|
|
1 file changed, 27 insertions(+)
|
|
|
|
|
|
|
|
--- a/drivers/pinctrl/pinctrl-msm.c
|
|
|
|
+++ b/drivers/pinctrl/pinctrl-msm.c
|
2014-09-10 21:40:19 +00:00
|
|
|
@@ -214,6 +214,11 @@ static int msm_config_reg(struct msm_pin
|
2014-08-30 09:32:58 +00:00
|
|
|
*bit = g->drv_bit;
|
|
|
|
*mask = 7;
|
|
|
|
break;
|
|
|
|
+ case PIN_CONFIG_OUTPUT:
|
|
|
|
+ *reg = g->ctl_reg;
|
|
|
|
+ *bit = g->oe_bit;
|
|
|
|
+ *mask = 1;
|
|
|
|
+ break;
|
|
|
|
default:
|
|
|
|
dev_err(pctrl->dev, "Invalid config param %04x\n", param);
|
|
|
|
return -ENOTSUPP;
|
2014-09-10 21:40:19 +00:00
|
|
|
@@ -282,6 +287,14 @@ static int msm_config_group_get(struct p
|
2014-08-30 09:32:58 +00:00
|
|
|
case PIN_CONFIG_DRIVE_STRENGTH:
|
|
|
|
arg = msm_regval_to_drive(arg);
|
|
|
|
break;
|
|
|
|
+ case PIN_CONFIG_OUTPUT:
|
|
|
|
+ /* Pin is not output */
|
|
|
|
+ if (!arg)
|
|
|
|
+ return -EINVAL;
|
|
|
|
+
|
|
|
|
+ val = readl(pctrl->regs + g->io_reg);
|
|
|
|
+ arg = !!(val & BIT(g->in_bit));
|
|
|
|
+ break;
|
|
|
|
default:
|
|
|
|
dev_err(pctrl->dev, "Unsupported config parameter: %x\n",
|
|
|
|
param);
|
2014-09-10 21:40:19 +00:00
|
|
|
@@ -337,6 +350,20 @@ static int msm_config_group_set(struct p
|
2014-08-30 09:32:58 +00:00
|
|
|
else
|
|
|
|
arg = (arg / 2) - 1;
|
|
|
|
break;
|
|
|
|
+ case PIN_CONFIG_OUTPUT:
|
|
|
|
+ /* set output value */
|
|
|
|
+ spin_lock_irqsave(&pctrl->lock, flags);
|
|
|
|
+ val = readl(pctrl->regs + g->io_reg);
|
|
|
|
+ if (arg)
|
|
|
|
+ val |= BIT(g->out_bit);
|
|
|
|
+ else
|
|
|
|
+ val &= ~BIT(g->out_bit);
|
|
|
|
+ writel(val, pctrl->regs + g->io_reg);
|
|
|
|
+ spin_unlock_irqrestore(&pctrl->lock, flags);
|
|
|
|
+
|
|
|
|
+ /* enable output */
|
|
|
|
+ arg = 1;
|
|
|
|
+ break;
|
|
|
|
default:
|
|
|
|
dev_err(pctrl->dev, "Unsupported config parameter: %x\n",
|
|
|
|
param);
|