* [PATCH 0/8] Qualcomm PMIC pinctrl additions
@ 2015-06-18 6:47 Bjorn Andersson
2015-06-18 6:47 ` [PATCH 4/8] pinctrl: qcom: spmi-mpp: Implement support for sink mode Bjorn Andersson
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Bjorn Andersson @ 2015-06-18 6:47 UTC (permalink / raw)
To: Ivan T. Ivanov, Andy Gross, Ian Campbell, Kumar Gala, Lee Jones,
Linus Walleij, Mark Rutland, Pawel Moll, Rob Herring,
Samuel Ortiz
Cc: devicetree, linux-arm-msm, linux-gpio, linux-kernel, linux-soc,
marc.zyngier
This series starts out by fixing various issues found in the pm8941 mpp driver.
While doing this work, and trying to use the mpp driver from device tree it, it
became obvious that the current binding is not fit for neither the driver
implementation nor the dts implementation.
The main reason for this is that we "inherited" the functions from the gpio
driver, where there is a notion of functions. But in the MPP the logical
mapping of digital, analog and current sink makes much more sense to map as
"functions". The features previously exposed as functions are replaced by two
properties (qcom,paired and qcom,dtest).
The end result is a more natural device tree definition.
With this in place the series introduces the gpio and mpp drivers for the ssbi
based pmics; found in 8660, 8960 and 8064.
Bjorn Andersson (8):
pinctrl: qcom: spmi-mpp: Transition to generic dt binding parser
pinctrl: qcom: spmi-mpp: Fixes related to enable handling
pinctrl: qcom: spmi-mpp: Introduce defines for MODE_CTL
pinctrl: qcom: spmi-mpp: Implement support for sink mode
pinctrl: qcom: spmi-mpp: Add support for setting analog output level
pinctrl: qcom: spmi-mpp: Transpose pinmux function
mfd: pm8921: Implement irq_get_irqchip_state
pinctrl: qcom: ssbi: Family A gpio & mpp drivers
.../devicetree/bindings/pinctrl/qcom,pmic-mpp.txt | 36 +-
drivers/mfd/pm8921-core.c | 43 +
drivers/pinctrl/qcom/Kconfig | 12 +
drivers/pinctrl/qcom/Makefile | 2 +
drivers/pinctrl/qcom/pinctrl-spmi-mpp.c | 374 +++++----
drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c | 795 ++++++++++++++++++
drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c | 886 +++++++++++++++++++++
include/dt-bindings/pinctrl/qcom,pmic-mpp.h | 51 ++
8 files changed, 1993 insertions(+), 206 deletions(-)
create mode 100644 drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c
create mode 100644 drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c
--
1.8.2.2
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 4/8] pinctrl: qcom: spmi-mpp: Implement support for sink mode
2015-06-18 6:47 [PATCH 0/8] Qualcomm PMIC pinctrl additions Bjorn Andersson
@ 2015-06-18 6:47 ` Bjorn Andersson
2015-07-14 11:01 ` Linus Walleij
2015-06-18 6:47 ` [PATCH 5/8] pinctrl: qcom: spmi-mpp: Add support for setting analog output level Bjorn Andersson
` (2 subsequent siblings)
3 siblings, 1 reply; 11+ messages in thread
From: Bjorn Andersson @ 2015-06-18 6:47 UTC (permalink / raw)
To: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
Linus Walleij, Ivan T. Ivanov
Cc: devicetree, linux-gpio, linux-kernel, linux-arm-msm
The MPP supports three modes; digital, analog and sink mode. This patch
implements support for the latter.
Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
---
.../devicetree/bindings/pinctrl/qcom,pmic-mpp.txt | 5 +
drivers/pinctrl/qcom/pinctrl-spmi-mpp.c | 115 +++++++++++++--------
2 files changed, 76 insertions(+), 44 deletions(-)
diff --git a/Documentation/devicetree/bindings/pinctrl/qcom,pmic-mpp.txt b/Documentation/devicetree/bindings/pinctrl/qcom,pmic-mpp.txt
index ed19991aad35..d29fb96a57d3 100644
--- a/Documentation/devicetree/bindings/pinctrl/qcom,pmic-mpp.txt
+++ b/Documentation/devicetree/bindings/pinctrl/qcom,pmic-mpp.txt
@@ -134,6 +134,11 @@ to specify in a pin configuration subnode:
and/or output-high, output-low MPP could operate as
Bidirectional Logic, Analog Input, Analog Output.
+- qcom,sink-mode:
+ Usage: optional
+ Value type: <u32> or <none>
+ Definition: Selects sink mode of operation
+
- qcom,amux-route:
Usage: optional
Value type: <u32>
diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c
index 745c37dea7d0..9dde023640ba 100644
--- a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c
+++ b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c
@@ -62,6 +62,7 @@
#define PMIC_MPP_REG_DIG_IN_CTL 0x43
#define PMIC_MPP_REG_EN_CTL 0x46
#define PMIC_MPP_REG_AIN_CTL 0x4a
+#define PMIC_MPP_REG_SINK_CTL 0x4c
/* PMIC_MPP_REG_MODE_CTL */
#define PMIC_MPP_REG_MODE_VALUE_MASK 0x1
@@ -98,6 +99,7 @@
/* Qualcomm specific pin configurations */
#define PMIC_MPP_CONF_AMUX_ROUTE (PIN_CONFIG_END + 1)
#define PMIC_MPP_CONF_ANALOG_MODE (PIN_CONFIG_END + 2)
+#define PMIC_MPP_CONF_SINK_MODE (PIN_CONFIG_END + 3)
/**
* struct pmic_mpp_pad - keep current MPP settings
@@ -109,11 +111,13 @@
* @input_enabled: Set to true if MPP input buffer logic is enabled.
* @analog_mode: Set to true when MPP should operate in Analog Input, Analog
* Output or Bidirectional Analog mode.
+ * @sink_mode: Boolean indicating if ink mode is slected
* @num_sources: Number of power-sources supported by this MPP.
* @power_source: Current power-source used.
* @amux_input: Set the source for analog input.
* @pullup: Pullup resistor value. Valid in Bidirectional mode only.
* @function: See pmic_mpp_functions[].
+ * @drive_strength: Amount of current in sink mode
*/
struct pmic_mpp_pad {
u16 base;
@@ -123,11 +127,13 @@ struct pmic_mpp_pad {
bool output_enabled;
bool input_enabled;
bool analog_mode;
+ bool sink_mode;
unsigned int num_sources;
unsigned int power_source;
unsigned int amux_input;
unsigned int pullup;
unsigned int function;
+ unsigned int drive_strength;
};
struct pmic_mpp_state {
@@ -140,12 +146,14 @@ struct pmic_mpp_state {
static const struct pinconf_generic_params pmic_mpp_bindings[] = {
{"qcom,amux-route", PMIC_MPP_CONF_AMUX_ROUTE, 0},
{"qcom,analog-mode", PMIC_MPP_CONF_ANALOG_MODE, 0},
+ {"qcom,sink-mode", PMIC_MPP_CONF_SINK_MODE, 0},
};
#ifdef CONFIG_DEBUG_FS
static const struct pin_config_item pmic_conf_items[] = {
PCONFDUMP(PMIC_MPP_CONF_AMUX_ROUTE, "analog mux", NULL, true),
PCONFDUMP(PMIC_MPP_CONF_ANALOG_MODE, "analog output", NULL, false),
+ PCONFDUMP(PMIC_MPP_CONF_SINK_MODE, "sink mode", NULL, false),
};
#endif
@@ -243,33 +251,28 @@ static int pmic_mpp_get_function_groups(struct pinctrl_dev *pctldev,
return 0;
}
-static int pmic_mpp_set_mux(struct pinctrl_dev *pctldev, unsigned function,
- unsigned pin)
+static int pmic_mpp_write_mode_ctl(struct pmic_mpp_state *state,
+ struct pmic_mpp_pad *pad)
{
- struct pmic_mpp_state *state = pinctrl_dev_get_drvdata(pctldev);
- struct pmic_mpp_pad *pad;
unsigned int val;
- int ret;
-
- pad = pctldev->desc->pins[pin].drv_data;
-
- pad->function = function;
- if (!pad->analog_mode) {
- val = PMIC_MPP_MODE_DIGITAL_INPUT;
+ if (pad->analog_mode) {
+ val = PMIC_MPP_MODE_ANALOG_INPUT;
if (pad->output_enabled) {
if (pad->input_enabled)
- val = PMIC_MPP_MODE_DIGITAL_BIDIR;
+ val = PMIC_MPP_MODE_ANALOG_BIDIR;
else
- val = PMIC_MPP_MODE_DIGITAL_OUTPUT;
+ val = PMIC_MPP_MODE_ANALOG_OUTPUT;
}
+ } else if (pad->sink_mode) {
+ val = PMIC_MPP_MODE_CURRENT_SINK;
} else {
- val = PMIC_MPP_MODE_ANALOG_INPUT;
+ val = PMIC_MPP_MODE_DIGITAL_INPUT;
if (pad->output_enabled) {
if (pad->input_enabled)
- val = PMIC_MPP_MODE_ANALOG_BIDIR;
+ val = PMIC_MPP_MODE_DIGITAL_BIDIR;
else
- val = PMIC_MPP_MODE_ANALOG_OUTPUT;
+ val = PMIC_MPP_MODE_DIGITAL_OUTPUT;
}
}
@@ -277,9 +280,22 @@ static int pmic_mpp_set_mux(struct pinctrl_dev *pctldev, unsigned function,
val |= pad->function << PMIC_MPP_REG_MODE_FUNCTION_SHIFT;
val |= pad->out_value & PMIC_MPP_REG_MODE_VALUE_MASK;
- ret = pmic_mpp_write(state, pad, PMIC_MPP_REG_MODE_CTL, val);
- if (ret < 0)
- return ret;
+ return pmic_mpp_write(state, pad, PMIC_MPP_REG_MODE_CTL, val);
+}
+
+static int pmic_mpp_set_mux(struct pinctrl_dev *pctldev, unsigned function,
+ unsigned pin)
+{
+ struct pmic_mpp_state *state = pinctrl_dev_get_drvdata(pctldev);
+ struct pmic_mpp_pad *pad;
+ unsigned int val;
+ int ret;
+
+ pad = pctldev->desc->pins[pin].drv_data;
+
+ pad->function = function;
+
+ ret = pmic_mpp_write_mode_ctl(state, pad);
val = pad->is_enabled << PMIC_MPP_REG_MASTER_EN_SHIFT;
@@ -339,9 +355,15 @@ static int pmic_mpp_config_get(struct pinctrl_dev *pctldev,
case PMIC_MPP_CONF_AMUX_ROUTE:
arg = pad->amux_input;
break;
+ case PIN_CONFIG_DRIVE_STRENGTH:
+ arg = pad->drive_strength;
+ break;
case PMIC_MPP_CONF_ANALOG_MODE:
arg = pad->analog_mode;
break;
+ case PMIC_MPP_CONF_SINK_MODE:
+ arg = pad->sink_mode;
+ break;
default:
return -EINVAL;
}
@@ -403,13 +425,19 @@ static int pmic_mpp_config_set(struct pinctrl_dev *pctldev, unsigned int pin,
pad->output_enabled = true;
pad->out_value = arg;
break;
+ case PIN_CONFIG_DRIVE_STRENGTH:
+ arg = pad->drive_strength;
+ break;
case PMIC_MPP_CONF_AMUX_ROUTE:
if (arg >= PMIC_MPP_AMUX_ROUTE_ABUS4)
return -EINVAL;
pad->amux_input = arg;
break;
case PMIC_MPP_CONF_ANALOG_MODE:
- pad->analog_mode = true;
+ pad->analog_mode = !!arg;
+ break;
+ case PMIC_MPP_CONF_SINK_MODE:
+ pad->sink_mode = !!arg;
break;
default:
return -EINVAL;
@@ -434,29 +462,7 @@ static int pmic_mpp_config_set(struct pinctrl_dev *pctldev, unsigned int pin,
if (ret < 0)
return ret;
- if (!pad->analog_mode) {
- val = 0; /* just digital input */
- if (pad->output_enabled) {
- if (pad->input_enabled)
- val = 2; /* digital input and output */
- else
- val = 1; /* just digital output */
- }
- } else {
- val = 4; /* just analog input */
- if (pad->output_enabled) {
- if (pad->input_enabled)
- val = 3; /* analog input and output */
- else
- val = 5; /* just analog output */
- }
- }
-
- val = val << PMIC_MPP_REG_MODE_DIR_SHIFT;
- val |= pad->function << PMIC_MPP_REG_MODE_FUNCTION_SHIFT;
- val |= pad->out_value & PMIC_MPP_REG_MODE_VALUE_MASK;
-
- ret = pmic_mpp_write(state, pad, PMIC_MPP_REG_MODE_CTL, val);
+ ret = pmic_mpp_write_mode_ctl(state, pad);
if (ret < 0)
return ret;
@@ -476,6 +482,9 @@ static void pmic_mpp_config_dbg_show(struct pinctrl_dev *pctldev,
"0.6kOhm", "10kOhm", "30kOhm", "Disabled"
};
+ static const char *const modes[] = {
+ "digital", "analog", "sink"
+ };
pad = pctldev->desc->pins[pin].drv_data;
@@ -495,7 +504,7 @@ static void pmic_mpp_config_dbg_show(struct pinctrl_dev *pctldev,
}
seq_printf(s, " %-4s", pad->output_enabled ? "out" : "in");
- seq_printf(s, " %-4s", pad->analog_mode ? "ana" : "dig");
+ seq_printf(s, " %-7s", modes[pad->analog_mode ? 1 : (pad->sink_mode ? 2 : 0)]);
seq_printf(s, " %-7s", pmic_mpp_functions[pad->function]);
seq_printf(s, " vin-%d", pad->power_source);
seq_printf(s, " %-8s", biases[pad->pullup]);
@@ -666,31 +675,43 @@ static int pmic_mpp_populate(struct pmic_mpp_state *state,
pad->input_enabled = true;
pad->output_enabled = false;
pad->analog_mode = false;
+ pad->sink_mode = false;
break;
case PMIC_MPP_MODE_DIGITAL_OUTPUT:
pad->input_enabled = false;
pad->output_enabled = true;
pad->analog_mode = false;
+ pad->sink_mode = false;
break;
case PMIC_MPP_MODE_DIGITAL_BIDIR:
pad->input_enabled = true;
pad->output_enabled = true;
pad->analog_mode = false;
+ pad->sink_mode = false;
break;
case PMIC_MPP_MODE_ANALOG_BIDIR:
pad->input_enabled = true;
pad->output_enabled = true;
pad->analog_mode = true;
+ pad->sink_mode = false;
break;
case PMIC_MPP_MODE_ANALOG_INPUT:
pad->input_enabled = true;
pad->output_enabled = false;
pad->analog_mode = true;
+ pad->sink_mode = false;
break;
case PMIC_MPP_MODE_ANALOG_OUTPUT:
pad->input_enabled = false;
pad->output_enabled = true;
pad->analog_mode = true;
+ pad->sink_mode = false;
+ break;
+ case PMIC_MPP_MODE_CURRENT_SINK:
+ pad->input_enabled = false;
+ pad->output_enabled = true;
+ pad->analog_mode = false;
+ pad->sink_mode = true;
break;
default:
dev_err(state->dev, "unknown MPP direction\n");
@@ -721,6 +742,12 @@ static int pmic_mpp_populate(struct pmic_mpp_state *state,
pad->amux_input = val >> PMIC_MPP_REG_AIN_ROUTE_SHIFT;
pad->amux_input &= PMIC_MPP_REG_AIN_ROUTE_MASK;
+ val = pmic_mpp_read(state, pad, PMIC_MPP_REG_SINK_CTL);
+ if (val < 0)
+ return val;
+
+ pad->drive_strength = val;
+
val = pmic_mpp_read(state, pad, PMIC_MPP_REG_EN_CTL);
if (val < 0)
return val;
--
1.8.2.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 5/8] pinctrl: qcom: spmi-mpp: Add support for setting analog output level
2015-06-18 6:47 [PATCH 0/8] Qualcomm PMIC pinctrl additions Bjorn Andersson
2015-06-18 6:47 ` [PATCH 4/8] pinctrl: qcom: spmi-mpp: Implement support for sink mode Bjorn Andersson
@ 2015-06-18 6:47 ` Bjorn Andersson
2015-06-24 8:17 ` Ivan T. Ivanov
` (2 more replies)
[not found] ` <1434610052-602-1-git-send-email-bjorn.andersson-/MT0OVThwyLZJqsBc5GL+g@public.gmane.org>
2015-06-24 8:29 ` [PATCH 0/8] Qualcomm PMIC pinctrl additions Ivan T. Ivanov
3 siblings, 3 replies; 11+ messages in thread
From: Bjorn Andersson @ 2015-06-18 6:47 UTC (permalink / raw)
To: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
Linus Walleij, Ivan T. Ivanov
Cc: devicetree, linux-gpio, linux-kernel, linux-arm-msm
When the MPP is configured for analog output the output level is selected by
the AOUT_CTL register, this patch makes it possible to control this.
Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
---
.../devicetree/bindings/pinctrl/qcom,pmic-mpp.txt | 7 +++++++
drivers/pinctrl/qcom/pinctrl-spmi-mpp.c | 21 +++++++++++++++++++++
2 files changed, 28 insertions(+)
diff --git a/Documentation/devicetree/bindings/pinctrl/qcom,pmic-mpp.txt b/Documentation/devicetree/bindings/pinctrl/qcom,pmic-mpp.txt
index d29fb96a57d3..0e4d4e62e220 100644
--- a/Documentation/devicetree/bindings/pinctrl/qcom,pmic-mpp.txt
+++ b/Documentation/devicetree/bindings/pinctrl/qcom,pmic-mpp.txt
@@ -127,6 +127,13 @@ to specify in a pin configuration subnode:
Definition: Selects the power source for the specified pins. Valid power
sources are defined in <dt-bindings/pinctrl/qcom,pmic-mpp.h>
+- qcom,analog-level:
+ Usage: optional
+ Value type: <u32>
+ Definition: Selects the source for analog output. Valued values are
+ defined in <dt-binding/pinctrl/qcom,pmic-mpp.h>
+ PMIC_MPP_AOUT_LVL_*
+
- qcom,analog-mode:
Usage: optional
Value type: <none>
diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c
index 9dde023640ba..24f471eee341 100644
--- a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c
+++ b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c
@@ -61,6 +61,7 @@
#define PMIC_MPP_REG_DIG_PULL_CTL 0x42
#define PMIC_MPP_REG_DIG_IN_CTL 0x43
#define PMIC_MPP_REG_EN_CTL 0x46
+#define PMIC_MPP_REG_AOUT_CTL 0x48
#define PMIC_MPP_REG_AIN_CTL 0x4a
#define PMIC_MPP_REG_SINK_CTL 0x4c
@@ -100,6 +101,7 @@
#define PMIC_MPP_CONF_AMUX_ROUTE (PIN_CONFIG_END + 1)
#define PMIC_MPP_CONF_ANALOG_MODE (PIN_CONFIG_END + 2)
#define PMIC_MPP_CONF_SINK_MODE (PIN_CONFIG_END + 3)
+#define PMIC_MPP_CONF_ANALOG_LEVEL (PIN_CONFIG_END + 4)
/**
* struct pmic_mpp_pad - keep current MPP settings
@@ -115,6 +117,7 @@
* @num_sources: Number of power-sources supported by this MPP.
* @power_source: Current power-source used.
* @amux_input: Set the source for analog input.
+ * @aout_level: Analog output level
* @pullup: Pullup resistor value. Valid in Bidirectional mode only.
* @function: See pmic_mpp_functions[].
* @drive_strength: Amount of current in sink mode
@@ -131,6 +134,7 @@ struct pmic_mpp_pad {
unsigned int num_sources;
unsigned int power_source;
unsigned int amux_input;
+ unsigned int aout_level;
unsigned int pullup;
unsigned int function;
unsigned int drive_strength;
@@ -145,6 +149,7 @@ struct pmic_mpp_state {
static const struct pinconf_generic_params pmic_mpp_bindings[] = {
{"qcom,amux-route", PMIC_MPP_CONF_AMUX_ROUTE, 0},
+ {"qcom,analog-level", PMIC_MPP_CONF_ANALOG_LEVEL, 0},
{"qcom,analog-mode", PMIC_MPP_CONF_ANALOG_MODE, 0},
{"qcom,sink-mode", PMIC_MPP_CONF_SINK_MODE, 0},
};
@@ -152,6 +157,7 @@ static const struct pinconf_generic_params pmic_mpp_bindings[] = {
#ifdef CONFIG_DEBUG_FS
static const struct pin_config_item pmic_conf_items[] = {
PCONFDUMP(PMIC_MPP_CONF_AMUX_ROUTE, "analog mux", NULL, true),
+ PCONFDUMP(PMIC_MPP_CONF_ANALOG_LEVEL, "analog level", NULL, true),
PCONFDUMP(PMIC_MPP_CONF_ANALOG_MODE, "analog output", NULL, false),
PCONFDUMP(PMIC_MPP_CONF_SINK_MODE, "sink mode", NULL, false),
};
@@ -358,6 +364,9 @@ static int pmic_mpp_config_get(struct pinctrl_dev *pctldev,
case PIN_CONFIG_DRIVE_STRENGTH:
arg = pad->drive_strength;
break;
+ case PMIC_MPP_CONF_ANALOG_LEVEL:
+ arg = pad->aout_level;
+ break;
case PMIC_MPP_CONF_ANALOG_MODE:
arg = pad->analog_mode;
break;
@@ -433,6 +442,9 @@ static int pmic_mpp_config_set(struct pinctrl_dev *pctldev, unsigned int pin,
return -EINVAL;
pad->amux_input = arg;
break;
+ case PMIC_MPP_CONF_ANALOG_LEVEL:
+ pad->aout_level = arg;
+ break;
case PMIC_MPP_CONF_ANALOG_MODE:
pad->analog_mode = !!arg;
break;
@@ -462,6 +474,10 @@ static int pmic_mpp_config_set(struct pinctrl_dev *pctldev, unsigned int pin,
if (ret < 0)
return ret;
+ ret = pmic_mpp_write(state, pad, PMIC_MPP_REG_AOUT_CTL, pad->aout_level);
+ if (ret < 0)
+ return ret;
+
ret = pmic_mpp_write_mode_ctl(state, pad);
if (ret < 0)
return ret;
@@ -507,6 +523,7 @@ static void pmic_mpp_config_dbg_show(struct pinctrl_dev *pctldev,
seq_printf(s, " %-7s", modes[pad->analog_mode ? 1 : (pad->sink_mode ? 2 : 0)]);
seq_printf(s, " %-7s", pmic_mpp_functions[pad->function]);
seq_printf(s, " vin-%d", pad->power_source);
+ seq_printf(s, " %d", pad->aout_level);
seq_printf(s, " %-8s", biases[pad->pullup]);
seq_printf(s, " %-4s", pad->out_value ? "high" : "low");
}
@@ -748,6 +765,10 @@ static int pmic_mpp_populate(struct pmic_mpp_state *state,
pad->drive_strength = val;
+ val = pmic_mpp_read(state, pad, PMIC_MPP_REG_AOUT_CTL);
+ if (val < 0)
+ return val;
+
val = pmic_mpp_read(state, pad, PMIC_MPP_REG_EN_CTL);
if (val < 0)
return val;
--
1.8.2.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 6/8] pinctrl: qcom: spmi-mpp: Transpose pinmux function
[not found] ` <1434610052-602-1-git-send-email-bjorn.andersson-/MT0OVThwyLZJqsBc5GL+g@public.gmane.org>
@ 2015-06-18 6:47 ` Bjorn Andersson
2015-07-17 12:31 ` Linus Walleij
0 siblings, 1 reply; 11+ messages in thread
From: Bjorn Andersson @ 2015-06-18 6:47 UTC (permalink / raw)
To: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
Linus Walleij, Ivan T. Ivanov
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-gpio-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA,
linux-arm-msm-u79uwXL29TY76Z2rM5mHXA
The "function" of the MPP driver was inherited from the GPIO driver, but the
differences between the two hardware blocks makes both the driver and the
device tree binding to be awkward.
Instead of overloading the "normal" function with various modes this patch
transposes the pinmux function to represent the three operating modes of the
MPP (digital, analog and current sink). The properties of pin pairing and DTEST
routing is moved to separate properties.
Signed-off-by: Bjorn Andersson <bjorn.andersson-/MT0OVThwyLZJqsBc5GL+g@public.gmane.org>
---
.../devicetree/bindings/pinctrl/qcom,pmic-mpp.txt | 29 ++--
drivers/pinctrl/qcom/pinctrl-spmi-mpp.c | 157 ++++++++++++---------
2 files changed, 99 insertions(+), 87 deletions(-)
diff --git a/Documentation/devicetree/bindings/pinctrl/qcom,pmic-mpp.txt b/Documentation/devicetree/bindings/pinctrl/qcom,pmic-mpp.txt
index 0e4d4e62e220..b096d8351b8f 100644
--- a/Documentation/devicetree/bindings/pinctrl/qcom,pmic-mpp.txt
+++ b/Documentation/devicetree/bindings/pinctrl/qcom,pmic-mpp.txt
@@ -77,12 +77,9 @@ to specify in a pin configuration subnode:
Value type: <string>
Definition: Specify the alternative function to be configured for the
specified pins. Valid values are:
- "normal",
- "paired",
- "dtest1",
- "dtest2",
- "dtest3",
- "dtest4"
+ "digital",
+ "analog",
+ "sink"
- bias-disable:
Usage: optional
@@ -134,17 +131,11 @@ to specify in a pin configuration subnode:
defined in <dt-binding/pinctrl/qcom,pmic-mpp.h>
PMIC_MPP_AOUT_LVL_*
-- qcom,analog-mode:
+- qcom,dtest:
Usage: optional
- Value type: <none>
- Definition: Selects Analog mode of operation: combined with input-enable
- and/or output-high, output-low MPP could operate as
- Bidirectional Logic, Analog Input, Analog Output.
-
-- qcom,sink-mode:
- Usage: optional
- Value type: <u32> or <none>
- Definition: Selects sink mode of operation
+ Value type: <u32>
+ Definition: Selects which dtest rail to be routed in the various functions.
+ Valid values are 1-4
- qcom,amux-route:
Usage: optional
@@ -152,6 +143,10 @@ to specify in a pin configuration subnode:
Definition: Selects the source for analog input. Valid values are
defined in <dt-bindings/pinctrl/qcom,pmic-mpp.h>
PMIC_MPP_AMUX_ROUTE_CH5, PMIC_MPP_AMUX_ROUTE_CH6...
+- qcom,paired:
+ Usage: optional
+ Value type: <none>
+ Definition: Indicates that the pin should be operating in paired mode.
Example:
@@ -168,7 +163,7 @@ Example:
pm8841_default: default {
gpio {
pins = "mpp1", "mpp2", "mpp3", "mpp4";
- function = "normal";
+ function = "digital";
input-enable;
power-source = <PM8841_MPP_S3>;
};
diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c
index 24f471eee341..8a280ef6304e 100644
--- a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c
+++ b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c
@@ -95,13 +95,17 @@
#define PMIC_MPP_MODE_ANALOG_OUTPUT 5
#define PMIC_MPP_MODE_CURRENT_SINK 6
+#define PMIC_MPP_SELECTOR_NORMAL 0
+#define PMIC_MPP_SELECTOR_PAIRED 1
+#define PMIC_MPP_SELECTOR_DTEST_FIRST 4
+
#define PMIC_MPP_PHYSICAL_OFFSET 1
/* Qualcomm specific pin configurations */
#define PMIC_MPP_CONF_AMUX_ROUTE (PIN_CONFIG_END + 1)
-#define PMIC_MPP_CONF_ANALOG_MODE (PIN_CONFIG_END + 2)
-#define PMIC_MPP_CONF_SINK_MODE (PIN_CONFIG_END + 3)
-#define PMIC_MPP_CONF_ANALOG_LEVEL (PIN_CONFIG_END + 4)
+#define PMIC_MPP_CONF_ANALOG_LEVEL (PIN_CONFIG_END + 2)
+#define PMIC_MPP_CONF_DTEST_SELECTOR (PIN_CONFIG_END + 3)
+#define PMIC_MPP_CONF_PAIRED (PIN_CONFIG_END + 4)
/**
* struct pmic_mpp_pad - keep current MPP settings
@@ -111,9 +115,7 @@
* @out_value: Cached pin output value.
* @output_enabled: Set to true if MPP output logic is enabled.
* @input_enabled: Set to true if MPP input buffer logic is enabled.
- * @analog_mode: Set to true when MPP should operate in Analog Input, Analog
- * Output or Bidirectional Analog mode.
- * @sink_mode: Boolean indicating if ink mode is slected
+ * @paired: Pin operates in paired mode
* @num_sources: Number of power-sources supported by this MPP.
* @power_source: Current power-source used.
* @amux_input: Set the source for analog input.
@@ -121,6 +123,7 @@
* @pullup: Pullup resistor value. Valid in Bidirectional mode only.
* @function: See pmic_mpp_functions[].
* @drive_strength: Amount of current in sink mode
+ * @dtest: DTEST route selector
*/
struct pmic_mpp_pad {
u16 base;
@@ -129,8 +132,7 @@ struct pmic_mpp_pad {
bool out_value;
bool output_enabled;
bool input_enabled;
- bool analog_mode;
- bool sink_mode;
+ bool paired;
unsigned int num_sources;
unsigned int power_source;
unsigned int amux_input;
@@ -138,6 +140,7 @@ struct pmic_mpp_pad {
unsigned int pullup;
unsigned int function;
unsigned int drive_strength;
+ unsigned int dtest;
};
struct pmic_mpp_state {
@@ -150,16 +153,16 @@ struct pmic_mpp_state {
static const struct pinconf_generic_params pmic_mpp_bindings[] = {
{"qcom,amux-route", PMIC_MPP_CONF_AMUX_ROUTE, 0},
{"qcom,analog-level", PMIC_MPP_CONF_ANALOG_LEVEL, 0},
- {"qcom,analog-mode", PMIC_MPP_CONF_ANALOG_MODE, 0},
- {"qcom,sink-mode", PMIC_MPP_CONF_SINK_MODE, 0},
+ {"qcom,dtest", PMIC_MPP_CONF_DTEST_SELECTOR, 0},
+ {"qcom,paired", PMIC_MPP_CONF_PAIRED, 0},
};
#ifdef CONFIG_DEBUG_FS
static const struct pin_config_item pmic_conf_items[] = {
PCONFDUMP(PMIC_MPP_CONF_AMUX_ROUTE, "analog mux", NULL, true),
PCONFDUMP(PMIC_MPP_CONF_ANALOG_LEVEL, "analog level", NULL, true),
- PCONFDUMP(PMIC_MPP_CONF_ANALOG_MODE, "analog output", NULL, false),
- PCONFDUMP(PMIC_MPP_CONF_SINK_MODE, "sink mode", NULL, false),
+ PCONFDUMP(PMIC_MPP_CONF_DTEST_SELECTOR, "dtest", NULL, true),
+ PCONFDUMP(PMIC_MPP_CONF_PAIRED, "paired", NULL, false),
};
#endif
@@ -167,11 +170,12 @@ static const char *const pmic_mpp_groups[] = {
"mpp1", "mpp2", "mpp3", "mpp4", "mpp5", "mpp6", "mpp7", "mpp8",
};
+#define PMIC_MPP_DIGITAL 0
+#define PMIC_MPP_ANALOG 1
+#define PMIC_MPP_SINK 2
+
static const char *const pmic_mpp_functions[] = {
- PMIC_MPP_FUNC_NORMAL, PMIC_MPP_FUNC_PAIRED,
- "reserved1", "reserved2",
- PMIC_MPP_FUNC_DTEST1, PMIC_MPP_FUNC_DTEST2,
- PMIC_MPP_FUNC_DTEST3, PMIC_MPP_FUNC_DTEST4,
+ "digital", "analog", "sink"
};
static inline struct pmic_mpp_state *to_mpp_state(struct gpio_chip *chip)
@@ -260,31 +264,46 @@ static int pmic_mpp_get_function_groups(struct pinctrl_dev *pctldev,
static int pmic_mpp_write_mode_ctl(struct pmic_mpp_state *state,
struct pmic_mpp_pad *pad)
{
+ unsigned int mode;
+ unsigned int sel;
unsigned int val;
-
- if (pad->analog_mode) {
- val = PMIC_MPP_MODE_ANALOG_INPUT;
- if (pad->output_enabled) {
- if (pad->input_enabled)
- val = PMIC_MPP_MODE_ANALOG_BIDIR;
- else
- val = PMIC_MPP_MODE_ANALOG_OUTPUT;
- }
- } else if (pad->sink_mode) {
- val = PMIC_MPP_MODE_CURRENT_SINK;
- } else {
- val = PMIC_MPP_MODE_DIGITAL_INPUT;
- if (pad->output_enabled) {
- if (pad->input_enabled)
- val = PMIC_MPP_MODE_DIGITAL_BIDIR;
- else
- val = PMIC_MPP_MODE_DIGITAL_OUTPUT;
- }
+ unsigned int en;
+
+ switch (pad->function) {
+ case PMIC_MPP_ANALOG:
+ if (pad->input_enabled && pad->output_enabled)
+ mode = PMIC_MPP_MODE_ANALOG_BIDIR;
+ else if (pad->input_enabled)
+ mode = PMIC_MPP_MODE_ANALOG_INPUT;
+ else
+ mode = PMIC_MPP_MODE_ANALOG_OUTPUT;
+ break;
+ case PMIC_MPP_DIGITAL:
+ if (pad->input_enabled && pad->output_enabled)
+ mode = PMIC_MPP_MODE_DIGITAL_BIDIR;
+ else if (pad->input_enabled)
+ mode = PMIC_MPP_MODE_DIGITAL_INPUT;
+ else
+ mode = PMIC_MPP_MODE_DIGITAL_OUTPUT;
+ break;
+ case PMIC_MPP_SINK:
+ default:
+ mode = PMIC_MPP_MODE_CURRENT_SINK;
+ break;
}
- val = val << PMIC_MPP_REG_MODE_DIR_SHIFT;
- val |= pad->function << PMIC_MPP_REG_MODE_FUNCTION_SHIFT;
- val |= pad->out_value & PMIC_MPP_REG_MODE_VALUE_MASK;
+ if (pad->dtest)
+ sel = PMIC_MPP_SELECTOR_DTEST_FIRST + pad->dtest - 1;
+ else if (pad->paired)
+ sel = PMIC_MPP_SELECTOR_PAIRED;
+ else
+ sel = PMIC_MPP_SELECTOR_NORMAL;
+
+ en = !!pad->out_value;
+
+ val = mode << PMIC_MPP_REG_MODE_DIR_SHIFT |
+ sel << PMIC_MPP_REG_MODE_FUNCTION_SHIFT |
+ en;
return pmic_mpp_write(state, pad, PMIC_MPP_REG_MODE_CTL, val);
}
@@ -358,21 +377,21 @@ static int pmic_mpp_config_get(struct pinctrl_dev *pctldev,
case PIN_CONFIG_OUTPUT:
arg = pad->out_value;
break;
+ case PMIC_MPP_CONF_DTEST_SELECTOR:
+ arg = pad->dtest;
+ break;
case PMIC_MPP_CONF_AMUX_ROUTE:
arg = pad->amux_input;
break;
+ case PMIC_MPP_CONF_PAIRED:
+ arg = pad->paired;
+ break;
case PIN_CONFIG_DRIVE_STRENGTH:
arg = pad->drive_strength;
break;
case PMIC_MPP_CONF_ANALOG_LEVEL:
arg = pad->aout_level;
break;
- case PMIC_MPP_CONF_ANALOG_MODE:
- arg = pad->analog_mode;
- break;
- case PMIC_MPP_CONF_SINK_MODE:
- arg = pad->sink_mode;
- break;
default:
return -EINVAL;
}
@@ -434,6 +453,9 @@ static int pmic_mpp_config_set(struct pinctrl_dev *pctldev, unsigned int pin,
pad->output_enabled = true;
pad->out_value = arg;
break;
+ case PMIC_MPP_CONF_DTEST_SELECTOR:
+ pad->dtest = arg;
+ break;
case PIN_CONFIG_DRIVE_STRENGTH:
arg = pad->drive_strength;
break;
@@ -445,11 +467,8 @@ static int pmic_mpp_config_set(struct pinctrl_dev *pctldev, unsigned int pin,
case PMIC_MPP_CONF_ANALOG_LEVEL:
pad->aout_level = arg;
break;
- case PMIC_MPP_CONF_ANALOG_MODE:
- pad->analog_mode = !!arg;
- break;
- case PMIC_MPP_CONF_SINK_MODE:
- pad->sink_mode = !!arg;
+ case PMIC_MPP_CONF_PAIRED:
+ pad->paired = !!arg;
break;
default:
return -EINVAL;
@@ -498,10 +517,6 @@ static void pmic_mpp_config_dbg_show(struct pinctrl_dev *pctldev,
"0.6kOhm", "10kOhm", "30kOhm", "Disabled"
};
- static const char *const modes[] = {
- "digital", "analog", "sink"
- };
-
pad = pctldev->desc->pins[pin].drv_data;
seq_printf(s, " mpp%-2d:", pin + PMIC_MPP_PHYSICAL_OFFSET);
@@ -520,12 +535,15 @@ static void pmic_mpp_config_dbg_show(struct pinctrl_dev *pctldev,
}
seq_printf(s, " %-4s", pad->output_enabled ? "out" : "in");
- seq_printf(s, " %-7s", modes[pad->analog_mode ? 1 : (pad->sink_mode ? 2 : 0)]);
seq_printf(s, " %-7s", pmic_mpp_functions[pad->function]);
seq_printf(s, " vin-%d", pad->power_source);
seq_printf(s, " %d", pad->aout_level);
seq_printf(s, " %-8s", biases[pad->pullup]);
seq_printf(s, " %-4s", pad->out_value ? "high" : "low");
+ if (pad->dtest)
+ seq_printf(s, " dtest%d", pad->dtest);
+ if (pad->paired)
+ seq_puts(s, " paired");
}
}
@@ -646,6 +664,7 @@ static int pmic_mpp_populate(struct pmic_mpp_state *state,
struct pmic_mpp_pad *pad)
{
int type, subtype, val, dir;
+ unsigned int sel;
type = pmic_mpp_read(state, pad, PMIC_MPP_REG_TYPE);
if (type < 0)
@@ -691,52 +710,50 @@ static int pmic_mpp_populate(struct pmic_mpp_state *state,
case PMIC_MPP_MODE_DIGITAL_INPUT:
pad->input_enabled = true;
pad->output_enabled = false;
- pad->analog_mode = false;
- pad->sink_mode = false;
+ pad->function = PMIC_MPP_DIGITAL;
break;
case PMIC_MPP_MODE_DIGITAL_OUTPUT:
pad->input_enabled = false;
pad->output_enabled = true;
- pad->analog_mode = false;
- pad->sink_mode = false;
+ pad->function = PMIC_MPP_DIGITAL;
break;
case PMIC_MPP_MODE_DIGITAL_BIDIR:
pad->input_enabled = true;
pad->output_enabled = true;
- pad->analog_mode = false;
- pad->sink_mode = false;
+ pad->function = PMIC_MPP_DIGITAL;
break;
case PMIC_MPP_MODE_ANALOG_BIDIR:
pad->input_enabled = true;
pad->output_enabled = true;
- pad->analog_mode = true;
- pad->sink_mode = false;
+ pad->function = PMIC_MPP_ANALOG;
break;
case PMIC_MPP_MODE_ANALOG_INPUT:
pad->input_enabled = true;
pad->output_enabled = false;
- pad->analog_mode = true;
- pad->sink_mode = false;
+ pad->function = PMIC_MPP_ANALOG;
break;
case PMIC_MPP_MODE_ANALOG_OUTPUT:
pad->input_enabled = false;
pad->output_enabled = true;
- pad->analog_mode = true;
- pad->sink_mode = false;
+ pad->function = PMIC_MPP_ANALOG;
break;
case PMIC_MPP_MODE_CURRENT_SINK:
pad->input_enabled = false;
pad->output_enabled = true;
- pad->analog_mode = false;
- pad->sink_mode = true;
+ pad->function = PMIC_MPP_SINK;
break;
default:
dev_err(state->dev, "unknown MPP direction\n");
return -ENODEV;
}
- pad->function = val >> PMIC_MPP_REG_MODE_FUNCTION_SHIFT;
- pad->function &= PMIC_MPP_REG_MODE_FUNCTION_MASK;
+ sel = val >> PMIC_MPP_REG_MODE_FUNCTION_SHIFT;
+ sel &= PMIC_MPP_REG_MODE_FUNCTION_MASK;
+
+ if (sel >= PMIC_MPP_SELECTOR_DTEST_FIRST)
+ pad->dtest = sel + 1;
+ else if (sel == PMIC_MPP_SELECTOR_PAIRED)
+ pad->paired = true;
val = pmic_mpp_read(state, pad, PMIC_MPP_REG_DIG_VIN_CTL);
if (val < 0)
--
1.8.2.2
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 5/8] pinctrl: qcom: spmi-mpp: Add support for setting analog output level
2015-06-18 6:47 ` [PATCH 5/8] pinctrl: qcom: spmi-mpp: Add support for setting analog output level Bjorn Andersson
@ 2015-06-24 8:17 ` Ivan T. Ivanov
2015-07-14 11:04 ` Linus Walleij
2015-07-15 6:40 ` [PATCH v2 " Bjorn Andersson
2 siblings, 0 replies; 11+ messages in thread
From: Ivan T. Ivanov @ 2015-06-24 8:17 UTC (permalink / raw)
To: Bjorn Andersson
Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
Linus Walleij, devicetree, linux-gpio, linux-kernel,
linux-arm-msm
Hi Bjorn,
On Wed, 2015-06-17 at 23:47 -0700, Bjorn Andersson wrote:
> When the MPP is configured for analog output the output level is selected by
> the AOUT_CTL register, this patch makes it possible to control this.
>
<snip>
> }
> @@ -748,6 +765,10 @@ static int pmic_mpp_populate(struct pmic_mpp_state *state,
>
> pad->drive_strength = val;
>
> + val = pmic_mpp_read(state, pad, PMIC_MPP_REG_AOUT_CTL);
> + if (val < 0)
> + return val;
> +
Missing
pad->aout_level = val;
> val = pmic_mpp_read(state, pad, PMIC_MPP_REG_EN_CTL);
> if (val < 0)
> return val;
>
Regards,
Ivan
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 0/8] Qualcomm PMIC pinctrl additions
2015-06-18 6:47 [PATCH 0/8] Qualcomm PMIC pinctrl additions Bjorn Andersson
` (2 preceding siblings ...)
[not found] ` <1434610052-602-1-git-send-email-bjorn.andersson-/MT0OVThwyLZJqsBc5GL+g@public.gmane.org>
@ 2015-06-24 8:29 ` Ivan T. Ivanov
3 siblings, 0 replies; 11+ messages in thread
From: Ivan T. Ivanov @ 2015-06-24 8:29 UTC (permalink / raw)
To: Bjorn Andersson
Cc: Andy Gross, Ian Campbell, Kumar Gala, Lee Jones, Linus Walleij,
Mark Rutland, Pawel Moll, Rob Herring, Samuel Ortiz, devicetree,
linux-arm-msm, linux-gpio, linux-kernel, linux-soc, marc.zyngier
On Wed, 2015-06-17 at 23:47 -0700, Bjorn Andersson wrote:
> This series starts out by fixing various issues found in the pm8941 mpp driver.
> While doing this work, and trying to use the mpp driver from device tree it, it
> became obvious that the current binding is not fit for neither the driver
> implementation nor the dts implementation.
>
> The main reason for this is that we "inherited" the functions from the gpio
> driver, where there is a notion of functions. But in the MPP the logical
> mapping of digital, analog and current sink makes much more sense to map as
> "functions". The features previously exposed as functions are replaced by two
> properties (qcom,paired and qcom,dtest).
>
> The end result is a more natural device tree definition.
>
> With this in place the series introduces the gpio and mpp drivers for the ssbi
> based pmics; found in 8660, 8960 and 8064.
>
> Bjorn Andersson (8):
> pinctrl: qcom: spmi-mpp: Transition to generic dt binding parser
> pinctrl: qcom: spmi-mpp: Fixes related to enable handling
> pinctrl: qcom: spmi-mpp: Introduce defines for MODE_CTL
> pinctrl: qcom: spmi-mpp: Implement support for sink mode
> pinctrl: qcom: spmi-mpp: Add support for setting analog output level
> pinctrl: qcom: spmi-mpp: Transpose pinmux function
> mfd: pm8921: Implement irq_get_irqchip_state
> pinctrl: qcom: ssbi: Family A gpio & mpp drivers
Thank you Bjorn.
Now MPP drivers have its full functionality.
With two small comments on patch 5 and 8,
Reviewed-by: Ivan T. Ivanov <iivanov@mm-sol.com>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 4/8] pinctrl: qcom: spmi-mpp: Implement support for sink mode
2015-06-18 6:47 ` [PATCH 4/8] pinctrl: qcom: spmi-mpp: Implement support for sink mode Bjorn Andersson
@ 2015-07-14 11:01 ` Linus Walleij
0 siblings, 0 replies; 11+ messages in thread
From: Linus Walleij @ 2015-07-14 11:01 UTC (permalink / raw)
To: Bjorn Andersson
Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
Ivan T. Ivanov, devicetree@vger.kernel.org,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-msm@vger.kernel.org
On Thu, Jun 18, 2015 at 8:47 AM, Bjorn Andersson
<bjorn.andersson@sonymobile.com> wrote:
> The MPP supports three modes; digital, analog and sink mode. This patch
> implements support for the latter.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
(...)
> +- qcom,sink-mode:
> + Usage: optional
> + Value type: <u32> or <none>
> + Definition: Selects sink mode of operation
Do we have some idea of what this actually means?
Just thinking whether it should be something generic "sink-mode" or
not.
Do we know?
Patch tentatively applied, anyways.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 5/8] pinctrl: qcom: spmi-mpp: Add support for setting analog output level
2015-06-18 6:47 ` [PATCH 5/8] pinctrl: qcom: spmi-mpp: Add support for setting analog output level Bjorn Andersson
2015-06-24 8:17 ` Ivan T. Ivanov
@ 2015-07-14 11:04 ` Linus Walleij
2015-07-15 6:40 ` [PATCH v2 " Bjorn Andersson
2 siblings, 0 replies; 11+ messages in thread
From: Linus Walleij @ 2015-07-14 11:04 UTC (permalink / raw)
To: Bjorn Andersson
Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
Ivan T. Ivanov, devicetree@vger.kernel.org,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-msm@vger.kernel.org
On Thu, Jun 18, 2015 at 8:47 AM, Bjorn Andersson
<bjorn.andersson@sonymobile.com> wrote:
> When the MPP is configured for analog output the output level is selected by
> the AOUT_CTL register, this patch makes it possible to control this.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
Holding the application of patches here until Ivan's
comment is addressed, its OK to resend just the patches that need
alterations, just preserve the 5/8 please so I don't get too confused...
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2 5/8] pinctrl: qcom: spmi-mpp: Add support for setting analog output level
2015-06-18 6:47 ` [PATCH 5/8] pinctrl: qcom: spmi-mpp: Add support for setting analog output level Bjorn Andersson
2015-06-24 8:17 ` Ivan T. Ivanov
2015-07-14 11:04 ` Linus Walleij
@ 2015-07-15 6:40 ` Bjorn Andersson
2015-07-17 12:30 ` Linus Walleij
2 siblings, 1 reply; 11+ messages in thread
From: Bjorn Andersson @ 2015-07-15 6:40 UTC (permalink / raw)
To: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
Linus Walleij, Ivan T. Ivanov
Cc: devicetree, linux-gpio, linux-kernel, linux-arm-msm
When the MPP is configured for analog output the output level is selected by
the AOUT_CTL register, this patch makes it possible to control this.
Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
---
Changes since v1:
- Assign aout_level in pmic_mpp_populate()
.../devicetree/bindings/pinctrl/qcom,pmic-mpp.txt | 7 +++++++
drivers/pinctrl/qcom/pinctrl-spmi-mpp.c | 23 ++++++++++++++++++++++
2 files changed, 30 insertions(+)
diff --git a/Documentation/devicetree/bindings/pinctrl/qcom,pmic-mpp.txt b/Documentation/devicetree/bindings/pinctrl/qcom,pmic-mpp.txt
index d29fb96a57d3..0e4d4e62e220 100644
--- a/Documentation/devicetree/bindings/pinctrl/qcom,pmic-mpp.txt
+++ b/Documentation/devicetree/bindings/pinctrl/qcom,pmic-mpp.txt
@@ -127,6 +127,13 @@ to specify in a pin configuration subnode:
Definition: Selects the power source for the specified pins. Valid power
sources are defined in <dt-bindings/pinctrl/qcom,pmic-mpp.h>
+- qcom,analog-level:
+ Usage: optional
+ Value type: <u32>
+ Definition: Selects the source for analog output. Valued values are
+ defined in <dt-binding/pinctrl/qcom,pmic-mpp.h>
+ PMIC_MPP_AOUT_LVL_*
+
- qcom,analog-mode:
Usage: optional
Value type: <none>
diff --git a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c
index 9dde023640ba..e52a72348a67 100644
--- a/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c
+++ b/drivers/pinctrl/qcom/pinctrl-spmi-mpp.c
@@ -61,6 +61,7 @@
#define PMIC_MPP_REG_DIG_PULL_CTL 0x42
#define PMIC_MPP_REG_DIG_IN_CTL 0x43
#define PMIC_MPP_REG_EN_CTL 0x46
+#define PMIC_MPP_REG_AOUT_CTL 0x48
#define PMIC_MPP_REG_AIN_CTL 0x4a
#define PMIC_MPP_REG_SINK_CTL 0x4c
@@ -100,6 +101,7 @@
#define PMIC_MPP_CONF_AMUX_ROUTE (PIN_CONFIG_END + 1)
#define PMIC_MPP_CONF_ANALOG_MODE (PIN_CONFIG_END + 2)
#define PMIC_MPP_CONF_SINK_MODE (PIN_CONFIG_END + 3)
+#define PMIC_MPP_CONF_ANALOG_LEVEL (PIN_CONFIG_END + 4)
/**
* struct pmic_mpp_pad - keep current MPP settings
@@ -115,6 +117,7 @@
* @num_sources: Number of power-sources supported by this MPP.
* @power_source: Current power-source used.
* @amux_input: Set the source for analog input.
+ * @aout_level: Analog output level
* @pullup: Pullup resistor value. Valid in Bidirectional mode only.
* @function: See pmic_mpp_functions[].
* @drive_strength: Amount of current in sink mode
@@ -131,6 +134,7 @@ struct pmic_mpp_pad {
unsigned int num_sources;
unsigned int power_source;
unsigned int amux_input;
+ unsigned int aout_level;
unsigned int pullup;
unsigned int function;
unsigned int drive_strength;
@@ -145,6 +149,7 @@ struct pmic_mpp_state {
static const struct pinconf_generic_params pmic_mpp_bindings[] = {
{"qcom,amux-route", PMIC_MPP_CONF_AMUX_ROUTE, 0},
+ {"qcom,analog-level", PMIC_MPP_CONF_ANALOG_LEVEL, 0},
{"qcom,analog-mode", PMIC_MPP_CONF_ANALOG_MODE, 0},
{"qcom,sink-mode", PMIC_MPP_CONF_SINK_MODE, 0},
};
@@ -152,6 +157,7 @@ static const struct pinconf_generic_params pmic_mpp_bindings[] = {
#ifdef CONFIG_DEBUG_FS
static const struct pin_config_item pmic_conf_items[] = {
PCONFDUMP(PMIC_MPP_CONF_AMUX_ROUTE, "analog mux", NULL, true),
+ PCONFDUMP(PMIC_MPP_CONF_ANALOG_LEVEL, "analog level", NULL, true),
PCONFDUMP(PMIC_MPP_CONF_ANALOG_MODE, "analog output", NULL, false),
PCONFDUMP(PMIC_MPP_CONF_SINK_MODE, "sink mode", NULL, false),
};
@@ -358,6 +364,9 @@ static int pmic_mpp_config_get(struct pinctrl_dev *pctldev,
case PIN_CONFIG_DRIVE_STRENGTH:
arg = pad->drive_strength;
break;
+ case PMIC_MPP_CONF_ANALOG_LEVEL:
+ arg = pad->aout_level;
+ break;
case PMIC_MPP_CONF_ANALOG_MODE:
arg = pad->analog_mode;
break;
@@ -433,6 +442,9 @@ static int pmic_mpp_config_set(struct pinctrl_dev *pctldev, unsigned int pin,
return -EINVAL;
pad->amux_input = arg;
break;
+ case PMIC_MPP_CONF_ANALOG_LEVEL:
+ pad->aout_level = arg;
+ break;
case PMIC_MPP_CONF_ANALOG_MODE:
pad->analog_mode = !!arg;
break;
@@ -462,6 +474,10 @@ static int pmic_mpp_config_set(struct pinctrl_dev *pctldev, unsigned int pin,
if (ret < 0)
return ret;
+ ret = pmic_mpp_write(state, pad, PMIC_MPP_REG_AOUT_CTL, pad->aout_level);
+ if (ret < 0)
+ return ret;
+
ret = pmic_mpp_write_mode_ctl(state, pad);
if (ret < 0)
return ret;
@@ -507,6 +523,7 @@ static void pmic_mpp_config_dbg_show(struct pinctrl_dev *pctldev,
seq_printf(s, " %-7s", modes[pad->analog_mode ? 1 : (pad->sink_mode ? 2 : 0)]);
seq_printf(s, " %-7s", pmic_mpp_functions[pad->function]);
seq_printf(s, " vin-%d", pad->power_source);
+ seq_printf(s, " %d", pad->aout_level);
seq_printf(s, " %-8s", biases[pad->pullup]);
seq_printf(s, " %-4s", pad->out_value ? "high" : "low");
}
@@ -748,6 +765,12 @@ static int pmic_mpp_populate(struct pmic_mpp_state *state,
pad->drive_strength = val;
+ val = pmic_mpp_read(state, pad, PMIC_MPP_REG_AOUT_CTL);
+ if (val < 0)
+ return val;
+
+ pad->aout_level = val;
+
val = pmic_mpp_read(state, pad, PMIC_MPP_REG_EN_CTL);
if (val < 0)
return val;
--
1.8.2.2
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2 5/8] pinctrl: qcom: spmi-mpp: Add support for setting analog output level
2015-07-15 6:40 ` [PATCH v2 " Bjorn Andersson
@ 2015-07-17 12:30 ` Linus Walleij
0 siblings, 0 replies; 11+ messages in thread
From: Linus Walleij @ 2015-07-17 12:30 UTC (permalink / raw)
To: Bjorn Andersson
Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
Ivan T. Ivanov, devicetree@vger.kernel.org,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-msm@vger.kernel.org
On Wed, Jul 15, 2015 at 8:40 AM, Bjorn Andersson
<bjorn.andersson@sonymobile.com> wrote:
> When the MPP is configured for analog output the output level is selected by
> the AOUT_CTL register, this patch makes it possible to control this.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
> ---
>
> Changes since v1:
> - Assign aout_level in pmic_mpp_populate()
Applied this v2 version for v4.3 unless someone protests.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 6/8] pinctrl: qcom: spmi-mpp: Transpose pinmux function
2015-06-18 6:47 ` [PATCH 6/8] pinctrl: qcom: spmi-mpp: Transpose pinmux function Bjorn Andersson
@ 2015-07-17 12:31 ` Linus Walleij
0 siblings, 0 replies; 11+ messages in thread
From: Linus Walleij @ 2015-07-17 12:31 UTC (permalink / raw)
To: Bjorn Andersson
Cc: Rob Herring, Pawel Moll, Mark Rutland, Ian Campbell, Kumar Gala,
Ivan T. Ivanov, devicetree@vger.kernel.org,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-msm@vger.kernel.org
On Thu, Jun 18, 2015 at 8:47 AM, Bjorn Andersson
<bjorn.andersson@sonymobile.com> wrote:
> The "function" of the MPP driver was inherited from the GPIO driver, but the
> differences between the two hardware blocks makes both the driver and the
> device tree binding to be awkward.
>
> Instead of overloading the "normal" function with various modes this patch
> transposes the pinmux function to represent the three operating modes of the
> MPP (digital, analog and current sink). The properties of pin pairing and DTEST
> routing is moved to separate properties.
>
> Signed-off-by: Bjorn Andersson <bjorn.andersson@sonymobile.com>
Patch applied.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2015-07-17 12:31 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-18 6:47 [PATCH 0/8] Qualcomm PMIC pinctrl additions Bjorn Andersson
2015-06-18 6:47 ` [PATCH 4/8] pinctrl: qcom: spmi-mpp: Implement support for sink mode Bjorn Andersson
2015-07-14 11:01 ` Linus Walleij
2015-06-18 6:47 ` [PATCH 5/8] pinctrl: qcom: spmi-mpp: Add support for setting analog output level Bjorn Andersson
2015-06-24 8:17 ` Ivan T. Ivanov
2015-07-14 11:04 ` Linus Walleij
2015-07-15 6:40 ` [PATCH v2 " Bjorn Andersson
2015-07-17 12:30 ` Linus Walleij
[not found] ` <1434610052-602-1-git-send-email-bjorn.andersson-/MT0OVThwyLZJqsBc5GL+g@public.gmane.org>
2015-06-18 6:47 ` [PATCH 6/8] pinctrl: qcom: spmi-mpp: Transpose pinmux function Bjorn Andersson
2015-07-17 12:31 ` Linus Walleij
2015-06-24 8:29 ` [PATCH 0/8] Qualcomm PMIC pinctrl additions Ivan T. Ivanov
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).