blob: 44ebcc4d8f018dcc826cefb3fa55f15b069c0fdf [file] [log] [blame]
Thomas Gleixner16216332019-05-19 15:51:31 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Venu Byravarasu3c33be062012-03-16 11:10:19 +05302/*
3 * Core driver interface for TI TPS65090 PMIC family
4 *
5 * Copyright (C) 2012 NVIDIA Corporation
Venu Byravarasu3c33be062012-03-16 11:10:19 +05306 */
7
8#ifndef __LINUX_MFD_TPS65090_H
9#define __LINUX_MFD_TPS65090_H
10
Axel Lin06c49982012-04-17 17:08:56 +080011#include <linux/irq.h>
Laxman Dewanganb9c79322012-11-20 08:44:48 +053012#include <linux/regmap.h>
Axel Lin06c49982012-04-17 17:08:56 +080013
Laxman Dewangan759f2592012-11-20 08:44:49 +053014/* TPS65090 IRQs */
15enum {
Rhyland Klein751391c2013-03-12 18:08:06 -040016 TPS65090_IRQ_INTERRUPT,
Laxman Dewangan759f2592012-11-20 08:44:49 +053017 TPS65090_IRQ_VAC_STATUS_CHANGE,
18 TPS65090_IRQ_VSYS_STATUS_CHANGE,
19 TPS65090_IRQ_BAT_STATUS_CHANGE,
20 TPS65090_IRQ_CHARGING_STATUS_CHANGE,
21 TPS65090_IRQ_CHARGING_COMPLETE,
22 TPS65090_IRQ_OVERLOAD_DCDC1,
23 TPS65090_IRQ_OVERLOAD_DCDC2,
24 TPS65090_IRQ_OVERLOAD_DCDC3,
25 TPS65090_IRQ_OVERLOAD_FET1,
26 TPS65090_IRQ_OVERLOAD_FET2,
27 TPS65090_IRQ_OVERLOAD_FET3,
28 TPS65090_IRQ_OVERLOAD_FET4,
29 TPS65090_IRQ_OVERLOAD_FET5,
30 TPS65090_IRQ_OVERLOAD_FET6,
31 TPS65090_IRQ_OVERLOAD_FET7,
32};
Axel Lin06c49982012-04-17 17:08:56 +080033
Laxman Dewangan24282a12012-10-09 15:18:59 +053034/* TPS65090 Regulator ID */
35enum {
Laxman Dewangan8620ca92012-10-09 15:19:00 +053036 TPS65090_REGULATOR_DCDC1,
37 TPS65090_REGULATOR_DCDC2,
38 TPS65090_REGULATOR_DCDC3,
39 TPS65090_REGULATOR_FET1,
40 TPS65090_REGULATOR_FET2,
41 TPS65090_REGULATOR_FET3,
42 TPS65090_REGULATOR_FET4,
43 TPS65090_REGULATOR_FET5,
44 TPS65090_REGULATOR_FET6,
45 TPS65090_REGULATOR_FET7,
Laxman Dewangan3a81ef82012-10-09 15:19:01 +053046 TPS65090_REGULATOR_LDO1,
47 TPS65090_REGULATOR_LDO2,
Laxman Dewangan24282a12012-10-09 15:18:59 +053048
49 /* Last entry for maximum ID */
Laxman Dewangan8620ca92012-10-09 15:19:00 +053050 TPS65090_REGULATOR_MAX,
Laxman Dewangan24282a12012-10-09 15:18:59 +053051};
52
Doug Andersonc42ba722014-04-16 16:12:27 -070053/* Register addresses */
54#define TPS65090_REG_INTR_STS 0x00
55#define TPS65090_REG_INTR_STS2 0x01
56#define TPS65090_REG_INTR_MASK 0x02
57#define TPS65090_REG_INTR_MASK2 0x03
58#define TPS65090_REG_CG_CTRL0 0x04
59#define TPS65090_REG_CG_CTRL1 0x05
60#define TPS65090_REG_CG_CTRL2 0x06
61#define TPS65090_REG_CG_CTRL3 0x07
62#define TPS65090_REG_CG_CTRL4 0x08
63#define TPS65090_REG_CG_CTRL5 0x09
64#define TPS65090_REG_CG_STATUS1 0x0a
65#define TPS65090_REG_CG_STATUS2 0x0b
Maciej S. Szmigiero5c148892016-01-31 23:00:06 +010066#define TPS65090_REG_AD_OUT1 0x17
67#define TPS65090_REG_AD_OUT2 0x18
68
69#define TPS65090_MAX_REG TPS65090_REG_AD_OUT2
70#define TPS65090_NUM_REGS (TPS65090_MAX_REG + 1)
Doug Andersonc42ba722014-04-16 16:12:27 -070071
Linus Walleij3012e812018-05-14 10:06:33 +020072struct gpio_desc;
73
Axel Lin06c49982012-04-17 17:08:56 +080074struct tps65090 {
Axel Lin06c49982012-04-17 17:08:56 +080075 struct device *dev;
Axel Lin06c49982012-04-17 17:08:56 +080076 struct regmap *rmap;
Laxman Dewangan759f2592012-11-20 08:44:49 +053077 struct regmap_irq_chip_data *irq_data;
Venu Byravarasu3c33be062012-03-16 11:10:19 +053078};
79
Laxman Dewangan24282a12012-10-09 15:18:59 +053080/*
81 * struct tps65090_regulator_plat_data
82 *
83 * @reg_init_data: The regulator init data.
Laxman Dewanganf329b172012-10-09 15:19:02 +053084 * @enable_ext_control: Enable extrenal control or not. Only available for
85 * DCDC1, DCDC2 and DCDC3.
Linus Walleij3012e812018-05-14 10:06:33 +020086 * @gpiod: Gpio descriptor if external control is enabled and controlled through
87 * gpio
Doug Anderson29041442014-04-16 16:12:28 -070088 * @overcurrent_wait_valid: True if the overcurrent_wait should be applied.
89 * @overcurrent_wait: Value to set as the overcurrent wait time. This is the
90 * actual bitfield value, not a time in ms (valid value are 0 - 3).
Laxman Dewangan24282a12012-10-09 15:18:59 +053091 */
Laxman Dewangan24282a12012-10-09 15:18:59 +053092struct tps65090_regulator_plat_data {
93 struct regulator_init_data *reg_init_data;
Laxman Dewanganf329b172012-10-09 15:19:02 +053094 bool enable_ext_control;
Linus Walleij3012e812018-05-14 10:06:33 +020095 struct gpio_desc *gpiod;
Doug Anderson29041442014-04-16 16:12:28 -070096 bool overcurrent_wait_valid;
97 int overcurrent_wait;
Laxman Dewangan24282a12012-10-09 15:18:59 +053098};
99
Venu Byravarasu3c33be062012-03-16 11:10:19 +0530100struct tps65090_platform_data {
101 int irq_base;
Rhyland Klein6f8da5d2013-03-12 18:08:09 -0400102
103 char **supplied_to;
104 size_t num_supplicants;
105 int enable_low_current_chrg;
106
Laxman Dewangan8620ca92012-10-09 15:19:00 +0530107 struct tps65090_regulator_plat_data *reg_pdata[TPS65090_REGULATOR_MAX];
Venu Byravarasu3c33be062012-03-16 11:10:19 +0530108};
109
110/*
111 * NOTE: the functions below are not intended for use outside
112 * of the TPS65090 sub-device drivers
113 */
Laxman Dewanganb9c79322012-11-20 08:44:48 +0530114static inline int tps65090_write(struct device *dev, int reg, uint8_t val)
115{
116 struct tps65090 *tps = dev_get_drvdata(dev);
117
118 return regmap_write(tps->rmap, reg, val);
119}
120
121static inline int tps65090_read(struct device *dev, int reg, uint8_t *val)
122{
123 struct tps65090 *tps = dev_get_drvdata(dev);
124 unsigned int temp_val;
125 int ret;
126
127 ret = regmap_read(tps->rmap, reg, &temp_val);
128 if (!ret)
129 *val = temp_val;
130 return ret;
131}
132
133static inline int tps65090_set_bits(struct device *dev, int reg,
134 uint8_t bit_num)
135{
136 struct tps65090 *tps = dev_get_drvdata(dev);
137
138 return regmap_update_bits(tps->rmap, reg, BIT(bit_num), ~0u);
139}
140
141static inline int tps65090_clr_bits(struct device *dev, int reg,
142 uint8_t bit_num)
143{
144 struct tps65090 *tps = dev_get_drvdata(dev);
145
146 return regmap_update_bits(tps->rmap, reg, BIT(bit_num), 0u);
147}
Venu Byravarasu3c33be062012-03-16 11:10:19 +0530148
149#endif /*__LINUX_MFD_TPS65090_H */