diff options
| author | Laxman Dewangan <ldewangan@nvidia.com> | 2012-11-14 10:39:28 -0500 |
|---|---|---|
| committer | Samuel Ortiz <sameo@linux.intel.com> | 2012-11-21 10:07:47 -0500 |
| commit | edd7eabc85e2f8d76a933b9639bebfe7f98861e4 (patch) | |
| tree | aedbc16b600b10177948bbca30cbe692e4a61146 | |
| parent | dbc4849db33307c72951e4bd4935fbb8d1fc7b8d (diff) | |
mfd: Add TI TPS80031 mfd core driver
TPS80031/ TPS80032 Fully Integrated Power Management with Power
Path and Battery Charger. The device provides five configurable
step-down converters, 11 general purpose LDOs, USB OTG Module,
ADC, RTC, 2 PWM, System Voltage Regulator/Battery Charger with
Power Path from USB, 32K clock generator.
Add the mfd core driver for TPS80031/TPS80032.
Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviwed-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
| -rw-r--r-- | drivers/mfd/Kconfig | 14 | ||||
| -rw-r--r-- | drivers/mfd/Makefile | 1 | ||||
| -rw-r--r-- | drivers/mfd/tps80031.c | 573 | ||||
| -rw-r--r-- | include/linux/mfd/tps80031.h | 637 |
4 files changed, 1225 insertions, 0 deletions
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 59359a7a2493..ca633df7c330 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig | |||
| @@ -265,6 +265,20 @@ config MFD_TPS65912_SPI | |||
| 265 | If you say yes here you get support for the TPS65912 series of | 265 | If you say yes here you get support for the TPS65912 series of |
| 266 | PM chips with SPI interface. | 266 | PM chips with SPI interface. |
| 267 | 267 | ||
| 268 | config MFD_TPS80031 | ||
| 269 | bool "TI TPS80031/TPS80032 Power Management chips" | ||
| 270 | depends on I2C=y && GENERIC_HARDIRQS | ||
| 271 | select MFD_CORE | ||
| 272 | select REGMAP_I2C | ||
| 273 | select IRQ_DOMAIN | ||
| 274 | help | ||
| 275 | If you say yes here you get support for the Texas Instruments | ||
| 276 | TPS80031/ TPS80032 Fully Integrated Power Management with Power | ||
| 277 | Path and Battery Charger. The device provides five configurable | ||
| 278 | step-down converters, 11 general purpose LDOs, USB OTG Module, | ||
| 279 | ADC, RTC, 2 PWM, System Voltage Regulator/Battery Charger with | ||
| 280 | Power Path from USB, 32K clock generator. | ||
| 281 | |||
| 268 | config MENELAUS | 282 | config MENELAUS |
| 269 | bool "Texas Instruments TWL92330/Menelaus PM chip" | 283 | bool "Texas Instruments TWL92330/Menelaus PM chip" |
| 270 | depends on I2C=y && ARCH_OMAP2 | 284 | depends on I2C=y && ARCH_OMAP2 |
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 1c3ee7c76906..8072460e99d2 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile | |||
| @@ -61,6 +61,7 @@ tps65912-objs := tps65912-core.o tps65912-irq.o | |||
| 61 | obj-$(CONFIG_MFD_TPS65912) += tps65912.o | 61 | obj-$(CONFIG_MFD_TPS65912) += tps65912.o |
| 62 | obj-$(CONFIG_MFD_TPS65912_I2C) += tps65912-i2c.o | 62 | obj-$(CONFIG_MFD_TPS65912_I2C) += tps65912-i2c.o |
| 63 | obj-$(CONFIG_MFD_TPS65912_SPI) += tps65912-spi.o | 63 | obj-$(CONFIG_MFD_TPS65912_SPI) += tps65912-spi.o |
| 64 | obj-$(CONFIG_MFD_TPS80031) += tps80031.o | ||
| 64 | obj-$(CONFIG_MENELAUS) += menelaus.o | 65 | obj-$(CONFIG_MENELAUS) += menelaus.o |
| 65 | 66 | ||
| 66 | obj-$(CONFIG_TWL4030_CORE) += twl-core.o twl4030-irq.o twl6030-irq.o | 67 | obj-$(CONFIG_TWL4030_CORE) += twl-core.o twl4030-irq.o twl6030-irq.o |
diff --git a/drivers/mfd/tps80031.c b/drivers/mfd/tps80031.c new file mode 100644 index 000000000000..f64005efa6fa --- /dev/null +++ b/drivers/mfd/tps80031.c | |||
| @@ -0,0 +1,573 @@ | |||
| 1 | /* | ||
| 2 | * tps80031.c -- TI TPS80031/TPS80032 mfd core driver. | ||
| 3 | * | ||
| 4 | * MFD core driver for TI TPS80031/TPS80032 Fully Integrated | ||
| 5 | * Power Management with Power Path and Battery Charger | ||
| 6 | * | ||
| 7 | * Copyright (c) 2012, NVIDIA Corporation. | ||
| 8 | * | ||
| 9 | * Author: Laxman Dewangan <ldewangan@nvidia.com> | ||
| 10 | * | ||
| 11 | * This program is free software; you can redistribute it and/or | ||
| 12 | * modify it under the terms of the GNU General Public License as | ||
| 13 | * published by the Free Software Foundation version 2. | ||
| 14 | * | ||
| 15 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind, | ||
| 16 | * whether express or implied; without even the implied warranty of | ||
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
| 18 | * General Public License for more details. | ||
| 19 | * | ||
| 20 | * You should have received a copy of the GNU General Public License | ||
| 21 | * along with this program; if not, write to the Free Software | ||
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA | ||
| 23 | * 02111-1307, USA | ||
| 24 | */ | ||
| 25 | |||
| 26 | #include <linux/err.h> | ||
| 27 | #include <linux/i2c.h> | ||
| 28 | #include <linux/init.h> | ||
| 29 | #include <linux/interrupt.h> | ||
| 30 | #include <linux/irq.h> | ||
| 31 | #include <linux/mfd/core.h> | ||
| 32 | #include <linux/mfd/tps80031.h> | ||
| 33 | #include <linux/module.h> | ||
| 34 | #include <linux/pm.h> | ||
| 35 | #include <linux/regmap.h> | ||
| 36 | #include <linux/slab.h> | ||
| 37 | |||
| 38 | static struct resource tps80031_rtc_resources[] = { | ||
| 39 | { | ||
| 40 | .start = TPS80031_INT_RTC_ALARM, | ||
| 41 | .end = TPS80031_INT_RTC_ALARM, | ||
| 42 | .flags = IORESOURCE_IRQ, | ||
| 43 | }, | ||
| 44 | }; | ||
| 45 | |||
| 46 | /* TPS80031 sub mfd devices */ | ||
| 47 | static struct mfd_cell tps80031_cell[] = { | ||
| 48 | { | ||
| 49 | .name = "tps80031-pmic", | ||
| 50 | }, | ||
| 51 | { | ||
| 52 | .name = "tps80031-clock", | ||
| 53 | }, | ||
| 54 | { | ||
| 55 | .name = "tps80031-rtc", | ||
| 56 | .num_resources = ARRAY_SIZE(tps80031_rtc_resources), | ||
| 57 | .resources = tps80031_rtc_resources, | ||
| 58 | }, | ||
| 59 | { | ||
| 60 | .name = "tps80031-gpadc", | ||
| 61 | }, | ||
| 62 | { | ||
| 63 | .name = "tps80031-fuel-gauge", | ||
| 64 | }, | ||
| 65 | { | ||
| 66 | .name = "tps80031-charger", | ||
| 67 | }, | ||
| 68 | }; | ||
| 69 | |||
| 70 | static int tps80031_slave_address[TPS80031_NUM_SLAVES] = { | ||
| 71 | TPS80031_I2C_ID0_ADDR, | ||
| 72 | TPS80031_I2C_ID1_ADDR, | ||
| 73 | TPS80031_I2C_ID2_ADDR, | ||
| 74 | TPS80031_I2C_ID3_ADDR, | ||
| 75 | }; | ||
| 76 | |||
| 77 | struct tps80031_pupd_data { | ||
| 78 | u8 reg; | ||
| 79 | u8 pullup_bit; | ||
| 80 | u8 pulldown_bit; | ||
| 81 | }; | ||
| 82 | |||
| 83 | #define TPS80031_IRQ(_reg, _mask) \ | ||
| 84 | { \ | ||
| 85 | .reg_offset = (TPS80031_INT_MSK_LINE_##_reg) - \ | ||
| 86 | TPS80031_INT_MSK_LINE_A, \ | ||
| 87 | .mask = BIT(_mask), \ | ||
| 88 | } | ||
| 89 | |||
| 90 | static const struct regmap_irq tps80031_main_irqs[] = { | ||
| 91 | [TPS80031_INT_PWRON] = TPS80031_IRQ(A, 0), | ||
| 92 | [TPS80031_INT_RPWRON] = TPS80031_IRQ(A, 1), | ||
| 93 | [TPS80031_INT_SYS_VLOW] = TPS80031_IRQ(A, 2), | ||
| 94 | [TPS80031_INT_RTC_ALARM] = TPS80031_IRQ(A, 3), | ||
| 95 | [TPS80031_INT_RTC_PERIOD] = TPS80031_IRQ(A, 4), | ||
| 96 | [TPS80031_INT_HOT_DIE] = TPS80031_IRQ(A, 5), | ||
| 97 | [TPS80031_INT_VXX_SHORT] = TPS80031_IRQ(A, 6), | ||
| 98 | [TPS80031_INT_SPDURATION] = TPS80031_IRQ(A, 7), | ||
| 99 | [TPS80031_INT_WATCHDOG] = TPS80031_IRQ(B, 0), | ||
| 100 | [TPS80031_INT_BAT] = TPS80031_IRQ(B, 1), | ||
| 101 | [TPS80031_INT_SIM] = TPS80031_IRQ(B, 2), | ||
| 102 | [TPS80031_INT_MMC] = TPS80031_IRQ(B, 3), | ||
| 103 | [TPS80031_INT_RES] = TPS80031_IRQ(B, 4), | ||
| 104 | [TPS80031_INT_GPADC_RT] = TPS80031_IRQ(B, 5), | ||
| 105 | [TPS80031_INT_GPADC_SW2_EOC] = TPS80031_IRQ(B, 6), | ||
| 106 | [TPS80031_INT_CC_AUTOCAL] = TPS80031_IRQ(B, 7), | ||
| 107 | [TPS80031_INT_ID_WKUP] = TPS80031_IRQ(C, 0), | ||
| 108 | [TPS80031_INT_VBUSS_WKUP] = TPS80031_IRQ(C, 1), | ||
| 109 | [TPS80031_INT_ID] = TPS80031_IRQ(C, 2), | ||
| 110 | [TPS80031_INT_VBUS] = TPS80031_IRQ(C, 3), | ||
| 111 | [TPS80031_INT_CHRG_CTRL] = TPS80031_IRQ(C, 4), | ||
| 112 | [TPS80031_INT_EXT_CHRG] = TPS80031_IRQ(C, 5), | ||
| 113 | [TPS80031_INT_INT_CHRG] = TPS80031_IRQ(C, 6), | ||
| 114 | [TPS80031_INT_RES2] = TPS80031_IRQ(C, 7), | ||
| 115 | }; | ||
| 116 | |||
| 117 | static struct regmap_irq_chip tps80031_irq_chip = { | ||
| 118 | .name = "tps80031", | ||
| 119 | .irqs = tps80031_main_irqs, | ||
| 120 | .num_irqs = ARRAY_SIZE(tps80031_main_irqs), | ||
| 121 | .num_regs = 3, | ||
| 122 | .status_base = TPS80031_INT_STS_A, | ||
| 123 | .mask_base = TPS80031_INT_MSK_LINE_A, | ||
| 124 | }; | ||
| 125 | |||
| 126 | #define PUPD_DATA(_reg, _pulldown_bit, _pullup_bit) \ | ||
| 127 | { \ | ||
| 128 | .reg = TPS80031_CFG_INPUT_PUPD##_reg, \ | ||
| 129 | .pulldown_bit = _pulldown_bit, \ | ||
| 130 | .pullup_bit = _pullup_bit, \ | ||
| 131 | } | ||
| 132 | |||
| 133 | static const struct tps80031_pupd_data tps80031_pupds[] = { | ||
| 134 | [TPS80031_PREQ1] = PUPD_DATA(1, BIT(0), BIT(1)), | ||
| 135 | [TPS80031_PREQ2A] = PUPD_DATA(1, BIT(2), BIT(3)), | ||
| 136 | [TPS80031_PREQ2B] = PUPD_DATA(1, BIT(4), BIT(5)), | ||
| 137 | [TPS80031_PREQ2C] = PUPD_DATA(1, BIT(6), BIT(7)), | ||
| 138 | [TPS80031_PREQ3] = PUPD_DATA(2, BIT(0), BIT(1)), | ||
| 139 | [TPS80031_NRES_WARM] = PUPD_DATA(2, 0, BIT(2)), | ||
| 140 | [TPS80031_PWM_FORCE] = PUPD_DATA(2, BIT(5), 0), | ||
| 141 | [TPS80031_CHRG_EXT_CHRG_STATZ] = PUPD_DATA(2, 0, BIT(6)), | ||
| 142 | [TPS80031_SIM] = PUPD_DATA(3, BIT(0), BIT(1)), | ||
| 143 | [TPS80031_MMC] = PUPD_DATA(3, BIT(2), BIT(3)), | ||
| 144 | [TPS80031_GPADC_START] = PUPD_DATA(3, BIT(4), 0), | ||
| 145 | [TPS80031_DVSI2C_SCL] = PUPD_DATA(4, 0, BIT(0)), | ||
| 146 | [TPS80031_DVSI2C_SDA] = PUPD_DATA(4, 0, BIT(1)), | ||
| 147 | [TPS80031_CTLI2C_SCL] = PUPD_DATA(4, 0, BIT(2)), | ||
| 148 | [TPS80031_CTLI2C_SDA] = PUPD_DATA(4, 0, BIT(3)), | ||
| 149 | }; | ||
| 150 | static struct tps80031 *tps80031_power_off_dev; | ||
| 151 | |||
| 152 | int tps80031_ext_power_req_config(struct device *dev, | ||
| 153 | unsigned long ext_ctrl_flag, int preq_bit, | ||
| 154 | int state_reg_add, int trans_reg_add) | ||
| 155 | { | ||
| 156 | u8 res_ass_reg = 0; | ||
| 157 | int preq_mask_bit = 0; | ||
| 158 | int ret; | ||
| 159 | |||
| 160 | if (!(ext_ctrl_flag & TPS80031_EXT_PWR_REQ)) | ||
| 161 | return 0; | ||
| 162 | |||
| 163 | if (ext_ctrl_flag & TPS80031_PWR_REQ_INPUT_PREQ1) { | ||
| 164 | res_ass_reg = TPS80031_PREQ1_RES_ASS_A + (preq_bit >> 3); | ||
| 165 | preq_mask_bit = 5; | ||
| 166 | } else if (ext_ctrl_flag & TPS80031_PWR_REQ_INPUT_PREQ2) { | ||
