xref: /linux/include/linux/mfd/samsung/core.h (revision e9ef810dfee7a2227da9d423aecb0ced35faddbe)
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright (c) 2011 Samsung Electronics Co., Ltd
4  *              http://www.samsung.com
5  */
6 
7 #ifndef __LINUX_MFD_SEC_CORE_H
8 #define __LINUX_MFD_SEC_CORE_H
9 
10 /* Macros to represent minimum voltages for LDO/BUCK */
11 #define MIN_3000_MV		3000000
12 #define MIN_2500_MV		2500000
13 #define MIN_2000_MV		2000000
14 #define MIN_1800_MV		1800000
15 #define MIN_1500_MV		1500000
16 #define MIN_1400_MV		1400000
17 #define MIN_1000_MV		1000000
18 
19 #define MIN_900_MV		900000
20 #define MIN_850_MV		850000
21 #define MIN_800_MV		800000
22 #define MIN_750_MV		750000
23 #define MIN_650_MV		650000
24 #define MIN_600_MV		600000
25 #define MIN_500_MV		500000
26 
27 /* Ramp delay in uV/us */
28 #define RAMP_DELAY_12_MVUS	12000
29 
30 /* Macros to represent steps for LDO/BUCK */
31 #define STEP_50_MV		50000
32 #define STEP_25_MV		25000
33 #define STEP_12_5_MV		12500
34 #define STEP_6_25_MV		6250
35 
36 struct gpio_desc;
37 
38 enum sec_device_type {
39 	S5M8767X,
40 	S2DOS05,
41 	S2MPA01,
42 	S2MPG10,
43 	S2MPS11X,
44 	S2MPS13X,
45 	S2MPS14X,
46 	S2MPS15X,
47 	S2MPU02,
48 	S2MPU05,
49 };
50 
51 /**
52  * struct sec_pmic_dev - s2m/s5m master device for sub-drivers
53  * @dev:		Master device of the chip
54  * @pdata:		Platform data populated with data from DTS
55  *			or board files
56  * @regmap_pmic:	Regmap associated with PMIC's I2C address
57  * @i2c:		I2C client of the main driver
58  * @device_type:	Type of device, matches enum sec_device_type
59  * @irq_base:		Base IRQ number for device, required for IRQs
60  * @irq:		Generic IRQ number for device
61  * @irq_data:		Runtime data structure for IRQ controller
62  * @wakeup:		Whether or not this is a wakeup device
63  */
64 struct sec_pmic_dev {
65 	struct device *dev;
66 	struct sec_platform_data *pdata;
67 	struct regmap *regmap_pmic;
68 	struct i2c_client *i2c;
69 
70 	int device_type;
71 	int irq;
72 	struct regmap_irq_chip_data *irq_data;
73 };
74 
75 struct sec_platform_data {
76 	struct sec_regulator_data	*regulators;
77 	struct sec_opmode_data		*opmode;
78 	int				num_regulators;
79 
80 	int				buck_gpios[3];
81 	int				buck_ds[3];
82 	unsigned int			buck2_voltage[8];
83 	bool				buck2_gpiodvs;
84 	unsigned int			buck3_voltage[8];
85 	bool				buck3_gpiodvs;
86 	unsigned int			buck4_voltage[8];
87 	bool				buck4_gpiodvs;
88 
89 	int				buck_default_idx;
90 	int				buck_ramp_delay;
91 
92 	bool				buck2_ramp_enable;
93 	bool				buck3_ramp_enable;
94 	bool				buck4_ramp_enable;
95 
96 	int				buck2_init;
97 	int				buck3_init;
98 	int				buck4_init;
99 	/* Whether or not manually set PWRHOLD to low during shutdown. */
100 	bool				manual_poweroff;
101 	/* Disable the WRSTBI (buck voltage warm reset) when probing? */
102 	bool				disable_wrstbi;
103 };
104 
105 /**
106  * sec_regulator_data - regulator data
107  * @id: regulator id
108  * @initdata: regulator init data (contraints, supplies, ...)
109  */
110 struct sec_regulator_data {
111 	int				id;
112 	struct regulator_init_data	*initdata;
113 	struct device_node		*reg_node;
114 	struct gpio_desc		*ext_control_gpiod;
115 };
116 
117 /*
118  * sec_opmode_data - regulator operation mode data
119  * @id: regulator id
120  * @mode: regulator operation mode
121  */
122 struct sec_opmode_data {
123 	int id;
124 	unsigned int mode;
125 };
126 
127 /*
128  * samsung regulator operation mode
129  * SEC_OPMODE_OFF	Regulator always OFF
130  * SEC_OPMODE_ON	Regulator always ON
131  * SEC_OPMODE_LOWPOWER  Regulator is on in low-power mode
132  * SEC_OPMODE_SUSPEND   Regulator is changed by PWREN pin
133  *			If PWREN is high, regulator is on
134  *			If PWREN is low, regulator is off
135  */
136 
137 enum sec_opmode {
138 	SEC_OPMODE_OFF,
139 	SEC_OPMODE_ON,
140 	SEC_OPMODE_LOWPOWER,
141 	SEC_OPMODE_SUSPEND,
142 };
143 
144 #endif /*  __LINUX_MFD_SEC_CORE_H */
145