/*
* pinctrl-palmas.c -- TI PALMAS series pin control driver.
*
* Copyright (c) 2013, NVIDIA Corporation.
*
* Author: Laxman Dewangan <ldewangan@nvidia.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation version 2.
*
* This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
* whether express or implied; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
* 02111-1307, USA
*/
#include <linux/delay.h>
#include <linux/module.h>
#include <linux/mfd/palmas.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/pinctrl/machine.h>
#include <linux/pinctrl/pinctrl.h>
#include <linux/pinctrl/pinconf-generic.h>
#include <linux/pinctrl/pinconf.h>
#include <linux/pinctrl/pinmux.h>
#include <linux/pm.h>
#include <linux/slab.h>
#include "core.h"
#include "pinconf.h"
#include "pinctrl-utils.h"
#define PALMAS_PIN_GPIO0_ID 0
#define PALMAS_PIN_GPIO1_VBUS_LED1_PWM1 1
#define PALMAS_PIN_GPIO2_REGEN_LED2_PWM2 2
#define PALMAS_PIN_GPIO3_CHRG_DET 3
#define PALMAS_PIN_GPIO4_SYSEN1 4
#define PALMAS_PIN_GPIO5_CLK32KGAUDIO_USB_PSEL 5
#define PALMAS_PIN_GPIO6_SYSEN2 6
#define PALMAS_PIN_GPIO7_MSECURE_PWRHOLD 7
#define PALMAS_PIN_GPIO8_SIM1RSTI 8
#define PALMAS_PIN_GPIO9_LOW_VBAT 9
#define PALMAS_PIN_GPIO10_WIRELESS_CHRG1 10
#define PALMAS_PIN_GPIO11_RCM 11
#define PALMAS_PIN_GPIO12_SIM2RSTO 12
#define PALMAS_PIN_GPIO13 13
#define PALMAS_PIN_GPIO14 14
#define PALMAS_PIN_GPIO15_SIM2RSTI 15
#define PALMAS_PIN_VAC 16
#define PALMAS_PIN_POWERGOOD_USB_PSEL 17
#define PALMAS_PIN_NRESWARM 18
#define PALMAS_PIN_PWRDOWN 19
#define PALMAS_PIN_GPADC_START 20
#define PALMAS_PIN_RESET_IN 21
#define PALMAS_PIN_NSLEEP 22
#define PALMAS_PIN_ENABLE1 23
#define PALMAS_PIN_ENABLE2 24
#define PALMAS_PIN_INT 25
#define PALMAS_PIN_NUM (PALMAS_PIN_INT + 1)
struct palmas_pin_function {
const char *name;
const char * const *groups;
unsigned ngroups;
};
struct palmas_pctrl_chip_info {
struct device *dev;
struct pinctrl_dev *pctl;
struct palmas *palmas;
int pins_current_opt[PALMAS_PIN_NUM];
const struct palmas_pin_function *functions;
unsigned num_functions;
const struct palmas_pingroup *pin_groups;
int num_pin_groups;
const struct pinctrl_pin_desc *pins;
unsigned num_pins;
};
static const struct pinctrl_pin_desc palmas_pins_desc[] = {
PINCTRL_PIN(PALMAS_PIN_GPIO0_ID, "gpio0"),
PINCTRL_PIN(PALMAS_PIN_GPIO1_VBUS_LED1_PWM1, "gpio1"),
PINCTRL_PIN(PALMAS_PIN_GPIO2_REGEN_LED2_PWM2, "gpio2"),
PINCTRL_PIN(PALMAS_PIN_GPIO3_CHRG_DET, "gpio3"),
PINCTRL_PIN(PALMAS_PIN_GPIO4_SYSEN1, "gpio4"),
PINCTRL_PIN(PALMAS_PIN_GPIO5_CLK32KGAUDIO_USB_PSEL, "gpio5"),
PINCTRL_PIN(PALMAS_PIN_GPIO6_SYSEN2, "gpio6"),
PINCTRL_PIN(PALMAS_PIN_GPIO7_MSECURE_PWRHOLD, "gpio7"),
PINCTRL_PIN(PALMAS_PIN_GPIO8_SIM1RSTI, "gpio8"),
PINCTRL_PIN(PALMAS_PIN_GPIO9_LOW_VBAT, "gpio9"),
PINCTRL_PIN(PALMAS_PIN_GPIO10_WIRELESS_CHRG1, "gpio10"),
PINCTRL_PIN(PALMAS_PIN_GPIO11_RCM, "gpio11"),
PINCTRL_PIN(PALMAS_PIN_GPIO12_SIM2RSTO, "gpio12"),
PINCTRL_PIN(PALMAS_PIN_GPIO13, "gpio13"),
PINCTRL_PIN(PALMAS_PIN_GPIO14, "gpio14"),
PINCTRL_PIN(PALMAS_PIN_GPIO15_SIM2RSTI, "gpio15"),
PINCTRL_PIN(PALMAS_PIN_VAC, "vac"),
PINCTRL_PIN(PALMAS_PIN_POWERGOOD_USB_PSEL, "powergood"),
PINCTRL_PIN(PALMAS_PIN_NRESWARM, "nreswarm"),
PINCTRL_PIN(PALMAS_PIN_PWRDOWN, "pwrdown"),
PINCTRL_PIN(PALMAS_PIN_GPADC_START, "gpadc_start"),
PINCTRL_PIN(PALMAS_PIN_RESET_IN, "reset_in"),
PINCTRL_PIN(PALMAS_PIN_NSLEEP, "nsleep"),
PINCTRL_PIN(PALMAS_PIN_ENABLE1, "enable1"),
PINCTRL_PIN(PALMAS_PIN_ENABLE2, "enable2"),
PINCTRL_PIN(PALMAS_PIN_INT, "int"),
};
static const char * const opt0_groups[] = {
"gpio0",
"gpio1",
"gpio2",
"gpio3",
"gpio4",
"gpio5",
"gpio6",
"gpio7",
"gpio8",
"gpio9",
"gpio10",
"gpio11",
"gpio12",
"gpio13",
"gpio14",
"gpio15",
"vac",
"powergood",
"nreswarm",
"pwrdown",
"gpadc_start",
"reset_in",
"nsleep",
"enable1",
"enable2",
"int",
};
static const char * const opt1_groups[] = {
"gpio0",
"gpio1",
"gpio2",
"gpio3",
"gpio4",
"gpio5",
"gpio6",
"gpio7",
"gpio8",
"gpio9",
"gpio10",
"gpio11",
"gpio12",
"gpio15",
"vac",
"powergood",
};
static const char * const opt2_groups[] = {
"gpio1",
"gpio2",
"gpio5",
"gpio7",
};
static const