Merge remote-tracking branches 'regulator/topic/s5m8767', 'regulator/topic/st-pwm...
[linux-2.6-microblaze.git] / include / linux / mfd / samsung / core.h
1 /*
2  * core.h
3  *
4  * copyright (c) 2011 Samsung Electronics Co., Ltd
5  *              http://www.samsung.com
6  *
7  *  This program is free software; you can redistribute  it and/or modify it
8  *  under  the terms of  the GNU General  Public License as published by the
9  *  Free Software Foundation;  either version 2 of the  License, or (at your
10  *  option) any later version.
11  *
12  */
13
14 #ifndef __LINUX_MFD_SEC_CORE_H
15 #define __LINUX_MFD_SEC_CORE_H
16
17 enum sec_device_type {
18         S5M8751X,
19         S5M8763X,
20         S5M8767X,
21         S2MPA01,
22         S2MPS11X,
23         S2MPS14X,
24 };
25
26 /**
27  * struct sec_pmic_dev - s5m87xx master device for sub-drivers
28  * @dev: master device of the chip (can be used to access platform data)
29  * @pdata: pointer to private data used to pass platform data to child
30  * @i2c: i2c client private data for regulator
31  * @rtc: i2c client private data for rtc
32  * @iolock: mutex for serializing io access
33  * @irqlock: mutex for buslock
34  * @irq_base: base IRQ number for sec-pmic, required for IRQs
35  * @irq: generic IRQ number for s5m87xx
36  * @ono: power onoff IRQ number for s5m87xx
37  * @irq_masks_cur: currently active value
38  * @irq_masks_cache: cached hardware value
39  * @type: indicate which s5m87xx "variant" is used
40  */
41 struct sec_pmic_dev {
42         struct device *dev;
43         struct sec_platform_data *pdata;
44         struct regmap *regmap_pmic;
45         struct regmap *regmap_rtc;
46         struct i2c_client *i2c;
47         struct i2c_client *rtc;
48
49         int device_type;
50         int irq_base;
51         int irq;
52         struct regmap_irq_chip_data *irq_data;
53
54         int ono;
55         unsigned long type;
56         bool wakeup;
57         bool wtsr_smpl;
58 };
59
60 int sec_irq_init(struct sec_pmic_dev *sec_pmic);
61 void sec_irq_exit(struct sec_pmic_dev *sec_pmic);
62 int sec_irq_resume(struct sec_pmic_dev *sec_pmic);
63
64 struct sec_platform_data {
65         struct sec_regulator_data       *regulators;
66         struct sec_opmode_data          *opmode;
67         int                             device_type;
68         int                             num_regulators;
69
70         int                             irq_base;
71         int                             (*cfg_pmic_irq)(void);
72
73         int                             ono;
74         bool                            wakeup;
75         bool                            buck_voltage_lock;
76
77         int                             buck_gpios[3];
78         int                             buck_ds[3];
79         unsigned int                    buck2_voltage[8];
80         bool                            buck2_gpiodvs;
81         unsigned int                    buck3_voltage[8];
82         bool                            buck3_gpiodvs;
83         unsigned int                    buck4_voltage[8];
84         bool                            buck4_gpiodvs;
85
86         int                             buck_set1;
87         int                             buck_set2;
88         int                             buck_set3;
89         int                             buck2_enable;
90         int                             buck3_enable;
91         int                             buck4_enable;
92         int                             buck_default_idx;
93         int                             buck2_default_idx;
94         int                             buck3_default_idx;
95         int                             buck4_default_idx;
96
97         int                             buck_ramp_delay;
98
99         int                             buck2_ramp_delay;
100         int                             buck34_ramp_delay;
101         int                             buck5_ramp_delay;
102         int                             buck16_ramp_delay;
103         int                             buck7810_ramp_delay;
104         int                             buck9_ramp_delay;
105         int                             buck24_ramp_delay;
106         int                             buck3_ramp_delay;
107         int                             buck7_ramp_delay;
108         int                             buck8910_ramp_delay;
109
110         bool                            buck1_ramp_enable;
111         bool                            buck2_ramp_enable;
112         bool                            buck3_ramp_enable;
113         bool                            buck4_ramp_enable;
114         bool                            buck6_ramp_enable;
115
116         int                             buck2_init;
117         int                             buck3_init;
118         int                             buck4_init;
119 };
120
121 /**
122  * sec_regulator_data - regulator data
123  * @id: regulator id
124  * @initdata: regulator init data (contraints, supplies, ...)
125  */
126 struct sec_regulator_data {
127         int                             id;
128         struct regulator_init_data      *initdata;
129         struct device_node              *reg_node;
130         int                             ext_control_gpio;
131 };
132
133 /*
134  * sec_opmode_data - regulator operation mode data
135  * @id: regulator id
136  * @mode: regulator operation mode
137  */
138 struct sec_opmode_data {
139         int id;
140         unsigned int mode;
141 };
142
143 /*
144  * samsung regulator operation mode
145  * SEC_OPMODE_OFF       Regulator always OFF
146  * SEC_OPMODE_ON        Regulator always ON
147  * SEC_OPMODE_LOWPOWER  Regulator is on in low-power mode
148  * SEC_OPMODE_SUSPEND   Regulator is changed by PWREN pin
149  *                      If PWREN is high, regulator is on
150  *                      If PWREN is low, regulator is off
151  */
152
153 enum sec_opmode {
154         SEC_OPMODE_OFF,
155         SEC_OPMODE_ON,
156         SEC_OPMODE_LOWPOWER,
157         SEC_OPMODE_SUSPEND,
158 };
159
160 #endif /*  __LINUX_MFD_SEC_CORE_H */