mirror of
https://github.com/followmsi/android_kernel_google_msm.git
synced 2024-11-06 23:17:41 +00:00
msm: qpnp: Add gpiolib support for PMIC GPIOs
Add a gpio_chip driver to support the Qualcomm SPMI PMIC architecture called QPNP. The driver supports Device Tree and allows a device_node to be registered as a gpio-controller. The driver also specifies APIs to allow a non-Device Tree user the ability to configure the PMIC GPIOs. This driver does not handle interrupts for GPIOs directly. Instead, that work is handled by the existing qpnp-int driver. This is feasible since the interrupt register map for all QPNP peripherals is the same. Change-Id: I04eb39d9855b0957f0647010fcb203ec2fc83c7c Signed-off-by: Michael Bohan <mbohan@codeaurora.org>
This commit is contained in:
parent
a4d4710dd2
commit
94f44896e2
5 changed files with 1368 additions and 0 deletions
143
Documentation/devicetree/bindings/gpio/qpnp-gpio.txt
Normal file
143
Documentation/devicetree/bindings/gpio/qpnp-gpio.txt
Normal file
|
@ -0,0 +1,143 @@
|
|||
* msm-qpnp-gpio
|
||||
|
||||
msm-qpnp-gpio is a GPIO chip driver for the MSM SPMI implementation.
|
||||
It creates a spmi_device for every spmi-dev-container block of device_nodes.
|
||||
These device_nodes contained within specify the PMIC GPIO number associated
|
||||
with each GPIO chip. The driver will map these to Linux GPIO numbers.
|
||||
|
||||
[PMIC GPIO Device Declarations]
|
||||
|
||||
-Root Node-
|
||||
|
||||
Required properties :
|
||||
- spmi-dev-container : Used to specify the following child nodes as part of the
|
||||
same SPMI device.
|
||||
- gpio-controller : Specify as gpio-contoller. All child nodes will belong to this
|
||||
gpio_chip.
|
||||
- #gpio-cells: We encode a PMIC GPIO number and a 32-bit flag field to
|
||||
specify the gpio configuration. This must be set to '2'.
|
||||
- #address-cells: Specify one address field. This must be set to '1'.
|
||||
- #size-cells: Specify one size-cell. This must be set to '1'.
|
||||
- compatible = "qcom,qpnp-gpio" : Specify driver matching for this driver.
|
||||
|
||||
-Child Nodes-
|
||||
|
||||
Required properties :
|
||||
- reg : Specify the spmi offset and size for this gpio device.
|
||||
- qcom,gpio-num : Specify the PMIC GPIO number for this gpio device.
|
||||
|
||||
Optional configuration properties :
|
||||
- qcom,direction: indicates whether the gpio should be input, output, or
|
||||
both.
|
||||
QPNP_GPIO_DIR_IN = 0,
|
||||
QPNP_GPIO_DIR_OUT = 1,
|
||||
QPNP_GPIO_DIR_BOTH = 2
|
||||
|
||||
- qcom,output-type: indicates gpio should be configured as CMOS or open
|
||||
drain.
|
||||
QPNP_GPIO_OUT_BUF_CMOS = 0
|
||||
QPNP_GPIO_OUT_BUF_OPEN_DRAIN_NMOS = 1,
|
||||
QPNP_GPIO_OUT_BUF_OPEN_DRAIN_PMOS = 2,
|
||||
|
||||
- qcom,invert: Invert the signal of the gpio line -
|
||||
QPNP_GPIO_INVERT_DISABLE = 0
|
||||
QPNP_GPIO_INVERT_ENABLE = 1
|
||||
|
||||
- qcom,pull: Indicates whether a pull up or pull down should be
|
||||
applied. If a pullup is required the current strength
|
||||
needs to be specified. Current values of 30uA, 1.5uA,
|
||||
31.5uA, 1.5uA with 30uA boost are supported.
|
||||
QPNP_GPIO_PULL_UP_30 = 0,
|
||||
QPNP_GPIO_PULL_UP_1P5 = 1,
|
||||
QPNP_GPIO_PULL_UP_31P5 = 2,
|
||||
QPNP_GPIO_PULL_UP_1P5_30 = 3,
|
||||
QPNP_GPIO_PULL_DN = 4,
|
||||
QPNP_GPIO_PULL_NO = 5
|
||||
|
||||
- qcom,vin-sel: specifies the voltage level when the output is set to 1.
|
||||
For an input gpio specifies the voltage level at which
|
||||
the input is interpreted as a logical 1.
|
||||
QPNP_GPIO_VIN0 = 0,
|
||||
QPNP_GPIO_VIN1 = 1,
|
||||
QPNP_GPIO_VIN2 = 2,
|
||||
QPNP_GPIO_VIN3 = 3,
|
||||
QPNP_GPIO_VIN4 = 4,
|
||||
QPNP_GPIO_VIN5 = 5,
|
||||
QPNP_GPIO_VIN6 = 6,
|
||||
QPNP_GPIO_VIN7 = 7
|
||||
|
||||
- qcom,out-strength: the amount of current supplied for an output gpio.
|
||||
QPNP_GPIO_OUT_STRENGTH_LOW = 1
|
||||
QPNP_GPIO_OUT_STRENGTH_MED = 2,
|
||||
QPNP_GPIO_OUT_STRENGTH_HIGH = 3,
|
||||
|
||||
- qcom,source-sel: choose alternate function for the gpio. Certain gpios
|
||||
can be paired (shorted) with each other. Some gpio pin
|
||||
can act as alternate functions.
|
||||
QPNP_GPIO_FUNC_NORMAL = 0,
|
||||
QPNP_GPIO_FUNC_PAIRED = 1
|
||||
QPNP_GPIO_FUNC_1 = 2,
|
||||
QPNP_GPIO_FUNC_2 = 3,
|
||||
QPNP_GPIO_DTEST1 = 4,
|
||||
QPNP_GPIO_DTEST2 = 5,
|
||||
QPNP_GPIO_DTEST3 = 6,
|
||||
QPNP_GPIO_DTEST4 = 7
|
||||
|
||||
- qcom,master-en: 1 = Enable features within the
|
||||
GPIO block based on configurations.
|
||||
0 = Completely disable the GPIO
|
||||
block and let the pin float with high impedance
|
||||
regardless of other settings.
|
||||
|
||||
*Note: If any of the configuration properties are not specified, then the
|
||||
qpnp-gpio driver will not modify that respective configuration in
|
||||
hardware.
|
||||
|
||||
[PMIC GPIO clients]
|
||||
|
||||
Required properties :
|
||||
- gpios : Contains 3 fields of the form <&gpio_controller pmic_gpio_num flags>
|
||||
|
||||
[Example]
|
||||
|
||||
qpnp: qcom,spmi@fc4c0000 {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <0>;
|
||||
interrupt-controller;
|
||||
#interrupt-cells = <3>;
|
||||
|
||||
qcom,pm8941@0 {
|
||||
spmi-slave-container;
|
||||
reg = <0x0>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
pm8941_gpios: gpios {
|
||||
spmi-dev-container;
|
||||
compatible = "qcom,qpnp-gpio";
|
||||
gpio-controller;
|
||||
#gpio-cells = <2>;
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
gpio@c000 {
|
||||
reg = <0xc000 0x100>;
|
||||
qcom,gpio-num = <62>;
|
||||
};
|
||||
|
||||
gpio@c100 {
|
||||
reg = <0xc100 0x100>;
|
||||
qcom,gpio-num = <20>;
|
||||
qcom,source_sel = <2>;
|
||||
qcom,pull = <5>;
|
||||
};
|
||||
};
|
||||
|
||||
qcom,testgpio@1000 {
|
||||
compatible = "qcom,qpnp-testgpio";
|
||||
reg = <0x1000 0x1000>;
|
||||
gpios = <&pm8941_gpios 62 0x0 &pm8941_gpios 20 0x1>;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
|
@ -555,4 +555,20 @@ config GPIO_PM8XXX_RPC
|
|||
This option enables support for on-chip GPIO found on Qualcomm PM8xxx
|
||||
PMICs through RPC.
|
||||
|
||||
config GPIO_QPNP
|
||||
depends on ARCH_MSMCOPPER
|
||||
depends on OF_SPMI
|
||||
depends on MSM_QPNP_INT
|
||||
tristate "Qualcomm QPNP GPIO support"
|
||||
help
|
||||
Say 'y' here to include support for the Qualcomm QPNP gpio
|
||||
support. QPNP is a SPMI based PMIC implementation.
|
||||
|
||||
config GPIO_QPNP_DEBUG
|
||||
depends on GPIO_QPNP
|
||||
depends on DEBUG_FS
|
||||
bool "Qualcomm QPNP GPIO debug support"
|
||||
help
|
||||
Say 'y' here to include debug support for the Qualcomm
|
||||
QPNP gpio support
|
||||
endif
|
||||
|
|
|
@ -48,6 +48,7 @@ obj-$(CONFIG_GPIO_PM8XXX) += pm8xxx-gpio.o
|
|||
obj-$(CONFIG_GPIO_PM8XXX_MPP) += pm8xxx-mpp.o
|
||||
obj-$(CONFIG_GPIO_PM8XXX_RPC) += gpio-pm8xxx-rpc.o
|
||||
obj-$(CONFIG_GPIO_PXA) += gpio-pxa.o
|
||||
obj-$(CONFIG_GPIO_QPNP) += qpnp-gpio.o
|
||||
obj-$(CONFIG_GPIO_RDC321X) += gpio-rdc321x.o
|
||||
obj-$(CONFIG_PLAT_SAMSUNG) += gpio-samsung.o
|
||||
obj-$(CONFIG_ARCH_SA1100) += gpio-sa1100.o
|
||||
|
|
1090
drivers/gpio/qpnp-gpio.c
Normal file
1090
drivers/gpio/qpnp-gpio.c
Normal file
File diff suppressed because it is too large
Load diff
118
include/linux/qpnp/gpio.h
Normal file
118
include/linux/qpnp/gpio.h
Normal file
|
@ -0,0 +1,118 @@
|
|||
/* Copyright (c) 2012, Code Aurora Forum. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
* only version 2 as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include <mach/qpnp.h>
|
||||
|
||||
#define QPNP_GPIO_DIR_IN 0
|
||||
#define QPNP_GPIO_DIR_OUT 1
|
||||
#define QPNP_GPIO_DIR_BOTH 2
|
||||
|
||||
#define QPNP_GPIO_INVERT_DISABLE 0
|
||||
#define QPNP_GPIO_INVERT_ENABLE 1
|
||||
|
||||
#define QPNP_GPIO_OUT_BUF_CMOS 0
|
||||
#define QPNP_GPIO_OUT_BUF_OPEN_DRAIN_NMOS 1
|
||||
#define QPNP_GPIO_OUT_BUF_OPEN_DRAIN_PMOS 2
|
||||
|
||||
#define QPNP_GPIO_VIN0 0
|
||||
#define QPNP_GPIO_VIN1 1
|
||||
#define QPNP_GPIO_VIN2 2
|
||||
#define QPNP_GPIO_VIN3 3
|
||||
#define QPNP_GPIO_VIN4 4
|
||||
#define QPNP_GPIO_VIN5 5
|
||||
#define QPNP_GPIO_VIN6 6
|
||||
#define QPNP_GPIO_VIN7 7
|
||||
|
||||
#define QPNP_GPIO_PULL_UP_30 0
|
||||
#define QPNP_GPIO_PULL_UP_1P5 1
|
||||
#define QPNP_GPIO_PULL_UP_31P5 2
|
||||
#define QPNP_GPIO_PULL_UP_1P5_30 3
|
||||
#define QPNP_GPIO_PULL_DN 4
|
||||
#define QPNP_GPIO_PULL_NO 5
|
||||
|
||||
#define QPNP_GPIO_OUT_STRENGTH_LOW 1
|
||||
#define QPNP_GPIO_OUT_STRENGTH_MED 2
|
||||
#define QPNP_GPIO_OUT_STRENGTH_HIGH 3
|
||||
|
||||
#define QPNP_GPIO_SRC_FUNC_NORMAL 0
|
||||
#define QPNP_GPIO_SRC_FUNC_PAIRED 1
|
||||
#define QPNP_GPIO_SRC_FUNC_1 2
|
||||
#define QPNP_GPIO_SRC_FUNC_2 3
|
||||
#define QPNP_GPIO_SRC_DTEST1 4
|
||||
#define QPNP_GPIO_SRC_DTEST2 5
|
||||
#define QPNP_GPIO_SRC_DTEST3 6
|
||||
#define QPNP_GPIO_SRC_DTEST4 7
|
||||
|
||||
#define QPNP_GPIO_MASTER_DISABLE 0
|
||||
#define QPNP_GPIO_MASTER_ENABLE 1
|
||||
|
||||
/**
|
||||
* struct qpnp_gpio_cfg - structure to specify gpio configurtion values
|
||||
* @direction: indicates whether the gpio should be input, output, or
|
||||
* both. Should be of the type QPNP_GPIO_DIR_*
|
||||
* @output_type: indicates gpio should be configured as CMOS or open
|
||||
* drain. Should be of the type QPNP_GPIO_OUT_BUF_*
|
||||
* @invert: Invert the signal of the gpio line -
|
||||
* QPNP_GPIO_INVERT_DISABLE or QPNP_GPIO_INVERT_ENABLE
|
||||
* @pull: Indicates whether a pull up or pull down should be
|
||||
* applied. If a pullup is required the current strength
|
||||
* needs to be specified. Current values of 30uA, 1.5uA,
|
||||
* 31.5uA, 1.5uA with 30uA boost are supported. This value
|
||||
* should be one of the QPNP_GPIO_PULL_*
|
||||
* @vin_sel: specifies the voltage level when the output is set to 1.
|
||||
* For an input gpio specifies the voltage level at which
|
||||
* the input is interpreted as a logical 1.
|
||||
* @out_strength: the amount of current supplied for an output gpio,
|
||||
* should be of the type QPNP_GPIO_STRENGTH_*
|
||||
* @source_sel: choose alternate function for the gpio. Certain gpios
|
||||
* can be paired (shorted) with each other. Some gpio pin
|
||||
* can act as alternate functions. This parameter should
|
||||
* be of type QPNP_GPIO_SRC_*.
|
||||
* @master_en: QPNP_GPIO_MASTER_ENABLE = Enable features within the
|
||||
* GPIO block based on configurations.
|
||||
* QPNP_GPIO_MASTER_DISABLE = Completely disable the GPIO
|
||||
* block and let the pin float with high impedance
|
||||
* regardless of other settings.
|
||||
*/
|
||||
struct qpnp_gpio_cfg {
|
||||
unsigned int direction;
|
||||
unsigned int output_type;
|
||||
unsigned int invert;
|
||||
unsigned int pull;
|
||||
unsigned int vin_sel;
|
||||
unsigned int out_strength;
|
||||
unsigned int src_select;
|
||||
unsigned int master_en;
|
||||
};
|
||||
|
||||
/**
|
||||
* qpnp_gpio_config - Apply gpio configuration for Linux gpio
|
||||
* @gpio: Linux gpio number to configure.
|
||||
* @param: parameters to configure.
|
||||
*
|
||||
* This routine takes a Linux gpio number that corresponds with a
|
||||
* PMIC gpio and applies the configuration specified in 'param'.
|
||||
* This gpio number can be ascertained by of_get_gpio_flags() or
|
||||
* the qpnp_gpio_map_gpio() API.
|
||||
*/
|
||||
int qpnp_gpio_config(int gpio, struct qpnp_gpio_cfg *param);
|
||||
|
||||
/**
|
||||
* qpnp_gpio_map_gpio - Obtain Linux GPIO number from device spec
|
||||
* @slave_id: slave_id of the spmi_device for the gpio in question.
|
||||
* @pmic_gpio: PMIC gpio number to lookup.
|
||||
*
|
||||
* This routine is used in legacy configurations that do not support
|
||||
* Device Tree. If you are using Device Tree, you should not use this.
|
||||
* For such cases, use of_get_gpio() instead.
|
||||
*/
|
||||
int qpnp_gpio_map_gpio(uint16_t slave_id, uint32_t pmic_gpio);
|
Loading…
Reference in a new issue