/*
* TI Palmas
*
* Copyright 2011-2013 Texas Instruments Inc.
*
* Author: Graeme Gregory <gg@slimlogic.co.uk>
* Author: Ian Lartey <ian@slimlogic.co.uk>
*
* 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; either version 2 of the License, or (at your
* option) any later version.
*
*/
#ifndef __LINUX_MFD_PALMAS_H
#define __LINUX_MFD_PALMAS_H
#include <linux/usb/otg.h>
#include <linux/leds.h>
#include <linux/regmap.h>
#include <linux/regulator/driver.h>
#include <linux/extcon.h>
#include <linux/usb/phy_companion.h>
#define PALMAS_NUM_CLIENTS 3
/* The ID_REVISION NUMBERS */
#define PALMAS_CHIP_OLD_ID 0x0000
#define PALMAS_CHIP_ID 0xC035
#define PALMAS_CHIP_CHARGER_ID 0xC036
#define TPS65917_RESERVED -1
#define is_palmas(a) (((a) == PALMAS_CHIP_OLD_ID) || \
((a) == PALMAS_CHIP_ID))
#define is_palmas_charger(a) ((a) == PALMAS_CHIP_CHARGER_ID)
/**
* Palmas PMIC feature types
*
* PALMAS_PMIC_FEATURE_SMPS10_BOOST - used when the PMIC provides SMPS10_BOOST
* regulator.
*
* PALMAS_PMIC_HAS(b, f) - macro to check if a bandgap device is capable of a
* specific feature (above) or not. Return non-zero, if yes.
*/
#define PALMAS_PMIC_FEATURE_SMPS10_BOOST BIT(0)
#define PALMAS_PMIC_HAS(b, f) \
((b)->features & PALMAS_PMIC_FEATURE_ ## f)
struct palmas_pmic;
struct palmas_gpadc;
struct palmas_resource;
struct palmas_usb;
struct palmas_pmic_driver_data;
struct palmas_pmic_platform_data;
enum palmas_usb_state {
PALMAS_USB_STATE_DISCONNECT,
PALMAS_USB_STATE_VBUS,
PALMAS_USB_STATE_ID,
};
struct palmas {
struct device *dev;
struct i2c_client *i2c_clients[PALMAS_NUM_CLIENTS];
struct regmap *regmap[PALMAS_NUM_CLIENTS];
/* Stored chip id */
int id;
unsigned int features;
/* IRQ Data */
int irq;
u32 irq_mask;
struct mutex irq_lock;
struct regmap_irq_chip_data *irq_data;
struct palmas_pmic_driver_data *pmic_ddata;
/* Child Devices */
struct palmas_pmic *pmic;
struct palmas_gpadc *gpadc;
struct palmas_resource *resource;
struct palmas_usb *usb;
/* GPIO MUXing */
u8 gpio_muxed;
u8 led_muxed;
u8 pwm_muxed;
};
#define PALMAS_EXT_REQ (PALMAS_EXT_CONTROL_ENABLE1 | \
PALMAS_EXT_CONTROL_ENABLE2 | \
PALMAS_EXT_CONTROL_NSLEEP)
struct palmas_sleep_requestor_info {
int id;
int reg_offset;
int bit_pos;
};
struct palmas_regs_info {
char *name;
char *sname;
u8 vsel_addr;
u8 ctrl_addr;
u8 tstep_addr;
int sleep_id;
};
struct palmas_pmic_driver_data {
int smps_start;
int smps_end;
int ldo_begin;
int ldo_end;
int max_reg;
bool has_regen3;
struct palmas_regs_info *palmas_regs_info;
struct of_regulator_match *palmas_matches;
struct palmas_sleep_requestor_info *sleep_req_info;
int (*smps_register)(struct palmas_pmic *pmic,
struct palmas_pmic_driver_data *ddata,
struct palmas_pmic_platform_data *pdata,
const char *pdev_name,
struct regulator_config config);
int (*ldo_register)(struct palmas_pmic *pmic,
struct palmas_pmic_driver_data *ddata,
struct palmas_pmic_platform_data *pdata,
const char *pdev_name,
struct regulator_config config);
};
struct palmas_gpadc_platform_data {
/* Channel 3 current source is only enabled during conversion */
int ch3_current;
/* Channel 0 current source can be used for battery detection.
* If used for battery detection this will cause a permanent current
* consumption depending on current level set here.
*/
int ch0_current;
/* default BAT_REMOVAL_DAT setting on device probe */
int bat_removal;
/* Sets the START_POLARITY bit in the RT_CTRL register */
int start_polarity;
};
struct palmas_reg_init {
/* warm_rest controls the voltage levels after a warm reset
*
* 0: reload default values from OTP on warm reset
* 1: maintain voltage from VSEL on warm reset
*/
int warm_reset;
/* roof_floor controls whether the regulator uses the i2c style
* of DVS or uses the method where a GPIO or other control method is
* attached to the NSLEEP/ENABLE1/ENABLE2 pins
*
* For SMPS
*
* 0: i2c selection of voltage
* 1: pin selection of voltage.
*
* For LDO unused
*/
int roof_floor;
/* sleep_mode is the mode loaded to MODE_SLEEP bits as defined in
* the data sheet.
*
* For SMPS
*
* 0: Off
* 1: AUTO
* 2: ECO
* 3: Forced PWM
*
* For LDO
*
* 0: Off
* 1: On
*/
int mode_sleep;
/* voltage_sel is the bitfield loaded onto the SMPSX_VOLTAGE
* register. Set this is the default voltage set in OTP needs
* to be overridden.
*/
u8 vsel;
};
enum palmas_regulators {
/* SMPS regulators */
PALMAS_REG_SMPS12,
PALMAS_REG_SMPS123,
PALMAS_REG_SMPS3,
PALMAS_REG_SMPS45,
PALMAS_REG_SMPS457,
PALMAS_REG_SMPS6,
PALMAS_REG_SMPS7,
PALMAS_REG_SMPS8,
PALMAS_REG_SMPS9,
PALMAS_REG_SMPS10_OUT2,
PALMAS_REG_SMPS10_OUT1,
/* LDO regulators */
PALMAS_REG_LDO1,
PALMAS_REG_LDO2,
PALMAS_REG_LDO3,
PALMAS_REG_LDO4,
PALMAS_REG_LDO5,
PALMAS_REG_LDO6,
PALMAS_REG_LDO7,
PALMAS_REG_LDO8,
PALMAS_REG_LDO9,
PALMAS_REG_LDOLN,
PALMAS_REG_LDOUSB,
/* External regulators */
PALMAS_REG_REGEN1,
PALMAS_REG_REGEN2,
PALMAS_REG_REGEN3,
PALMAS_REG_SYSEN1,
PALMAS_REG_SYSEN2,
/* Total number of regulators */
PALMAS_NUM_REGS,
};
enum tps65917_regulators {
/* SMPS regulators */
TPS65917_REG_SMPS1,
TPS65917_REG_SMPS2,
TPS65917_REG_SMPS3,
TPS65917_REG_SMPS4,
TPS65917_REG_SMPS5,
/* LDO regulators */
TPS65917_REG_LDO1,
TPS65917_REG_LDO2,
TPS65917_REG_LDO3,
TPS65917_REG_LDO4,
TPS65917_REG_LDO5,
TPS65917_REG_REGEN1,
TPS65917_REG_REGEN2,
TPS65917_REG_REGEN3,
/* Total number of regulators */
TPS65917_NUM_REGS,
};
/* External controll signal name */
enum {
PALMAS_EXT_CONTROL_ENABLE1 = 0x1,
PALMAS_EXT_CONTROL_ENABLE2 = 0x2,
PALMAS_EXT_CONTROL_NSLEEP = 0x4,
};
/*
* Palmas device resources can be controlled externally for
* enabling/disabling it rather than register write through i2c.
* Add the external controlled requestor ID for different resources.
*/
enum palmas_external_requestor_id {
PALMAS_EXTERNAL_REQSTR_ID_REGEN1,
PALMAS_EXTERNAL_REQSTR_ID_REGEN2,
PALMAS_EXTERNAL_REQSTR_ID_SYSEN1,
PALMAS_EXTERNAL_REQSTR_ID_SYSEN2,
PALMAS_EXTERNAL_REQSTR_ID_CLK32KG,
PALMAS_EXTERNAL_REQSTR_ID_CLK32KGAUDIO,
PALMAS_EXTERNAL_REQSTR_ID_REGEN3,
PALMAS_EXTERNAL_REQSTR_ID_SMPS12,
PALMAS_EXTERNAL_REQSTR_ID_SMPS3,
PALMAS_EXTERNAL_REQSTR_ID_SMPS45,
PALMAS_EXTERNAL_REQSTR_ID_SMPS6,
PALMAS_EXTERNAL_REQSTR_ID_SMPS7,
PALMAS_EXTERNAL_REQSTR_ID_SMPS8,
PALMAS_EXTERNAL_REQSTR_ID_SMPS9,
PALMAS_EXTERNAL_REQSTR_ID_SMPS10,
PALMAS_EXTERNAL_REQSTR_ID_LDO1,
PALMAS_EXTERNAL_REQSTR_ID_LDO2,
PALMAS_EXTERNAL_REQSTR_ID_LDO3,
PALMAS_EXTERNAL_REQSTR_ID_LDO4,
PALMAS_EXTERNAL_REQSTR_ID_LDO5,
PALMAS_EXTERNAL_REQSTR_ID_LDO6,
PALMAS_EXTERNAL_REQSTR_ID_LDO7,
PALMAS_EXTERNAL_REQSTR_ID_LDO8,
PALMAS_EXTERNAL_REQSTR_ID_LDO9,
PALMAS_EXTERNAL_REQSTR_ID_LDOLN,
PALMAS_EXTERNAL_REQSTR_ID_LDOUSB,
/* Last entry */
PALMAS_EXTERNAL_REQSTR_ID_MAX,
};
enum tps65917_external_requestor_id {
TPS65917_EXTERNAL_REQSTR_ID_REGEN1,
TPS65917_EXTERNAL_REQSTR_ID_REGEN2,
TPS65917_EXTERNAL_REQSTR_ID_REGEN3,
TPS65917_EXTERNAL_REQSTR_ID_SMPS1,
TPS65917_EXTERNAL_REQSTR_ID_SMPS2,
TPS65917_EXTERNAL_REQSTR_ID_SMPS3,
TPS65917_EXTERNAL_REQSTR_ID_SMPS4,
TPS65917_EXTERNAL_REQSTR_ID_SMPS5,
TPS65917_EXTERNAL_REQSTR_ID_LDO1,
TPS65917_EXTERNAL_REQSTR_ID_LDO2,
TPS65917_EXTERNAL_REQSTR_ID_LDO3,
TPS65917_EXTERNAL_REQSTR_ID_LDO4,
TPS65917_EXTERNAL_REQSTR_ID_LDO5,
/* Last entry */
TPS65917_EXTERNAL_REQSTR_ID_MAX,
};
struct palmas_pmic_platform_data {
/* An array of pointers to regulator init data indexed by regulator
* ID
*/
struct regulator_init_data *reg_data[PALMAS_NUM_REGS];
/* An array of pointers to structures containing sleep mode and DVS
* configuration for regulators indexed by ID
*/
struct palmas_reg_init *reg_init[PALMAS_NUM_REGS];
/* use LDO6