]> git.kernelconcepts.de Git - karo-tx-linux.git/blob - include/linux/mfd/samsung/core.h
mfd/rtc: s5m: fix register updating by adding regmap for RTC
[karo-tx-linux.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         S2MPS11X,
22 };
23
24 /**
25  * struct sec_pmic_dev - s5m87xx master device for sub-drivers
26  * @dev: master device of the chip (can be used to access platform data)
27  * @pdata: pointer to private data used to pass platform data to child
28  * @i2c: i2c client private data for regulator
29  * @rtc: i2c client private data for rtc
30  * @iolock: mutex for serializing io access
31  * @irqlock: mutex for buslock
32  * @irq_base: base IRQ number for sec-pmic, required for IRQs
33  * @irq: generic IRQ number for s5m87xx
34  * @ono: power onoff IRQ number for s5m87xx
35  * @irq_masks_cur: currently active value
36  * @irq_masks_cache: cached hardware value
37  * @type: indicate which s5m87xx "variant" is used
38  */
39 struct sec_pmic_dev {
40         struct device *dev;
41         struct sec_platform_data *pdata;
42         struct regmap *regmap_pmic;
43         struct regmap *regmap_rtc;
44         struct i2c_client *i2c;
45         struct i2c_client *rtc;
46
47         int device_type;
48         int irq_base;
49         int irq;
50         struct regmap_irq_chip_data *irq_data;
51
52         int ono;
53         int type;
54         bool wakeup;
55         bool wtsr_smpl;
56 };
57
58 int sec_irq_init(struct sec_pmic_dev *sec_pmic);
59 void sec_irq_exit(struct sec_pmic_dev *sec_pmic);
60 int sec_irq_resume(struct sec_pmic_dev *sec_pmic);
61
62 extern int sec_reg_read(struct sec_pmic_dev *sec_pmic, u8 reg, void *dest);
63 extern int sec_bulk_read(struct sec_pmic_dev *sec_pmic, u8 reg, int count, u8 *buf);
64 extern int sec_reg_write(struct sec_pmic_dev *sec_pmic, u8 reg, u8 value);
65 extern int sec_bulk_write(struct sec_pmic_dev *sec_pmic, u8 reg, int count, u8 *buf);
66 extern int sec_reg_update(struct sec_pmic_dev *sec_pmic, u8 reg, u8 val, u8 mask);
67
68 struct sec_platform_data {
69         struct sec_regulator_data       *regulators;
70         struct sec_opmode_data          *opmode;
71         int                             device_type;
72         int                             num_regulators;
73
74         int                             irq_base;
75         int                             (*cfg_pmic_irq)(void);
76
77         int                             ono;
78         bool                            wakeup;
79         bool                            buck_voltage_lock;
80
81         int                             buck_gpios[3];
82         int                             buck_ds[3];
83         unsigned int                    buck2_voltage[8];
84         bool                            buck2_gpiodvs;
85         unsigned int                    buck3_voltage[8];
86         bool                            buck3_gpiodvs;
87         unsigned int                    buck4_voltage[8];
88         bool                            buck4_gpiodvs;
89
90         int                             buck_set1;
91         int                             buck_set2;
92         int                             buck_set3;
93         int                             buck2_enable;
94         int                             buck3_enable;
95         int                             buck4_enable;
96         int                             buck_default_idx;
97         int                             buck2_default_idx;
98         int                             buck3_default_idx;
99         int                             buck4_default_idx;
100
101         int                             buck_ramp_delay;
102
103         int                             buck2_ramp_delay;
104         int                             buck34_ramp_delay;
105         int                             buck5_ramp_delay;
106         int                             buck16_ramp_delay;
107         int                             buck7810_ramp_delay;
108         int                             buck9_ramp_delay;
109
110         bool                            buck2_ramp_enable;
111         bool                            buck3_ramp_enable;
112         bool                            buck4_ramp_enable;
113         bool                            buck6_ramp_enable;
114
115         int                             buck2_init;
116         int                             buck3_init;
117         int                             buck4_init;
118 };
119
120 /**
121  * sec_regulator_data - regulator data
122  * @id: regulator id
123  * @initdata: regulator init data (contraints, supplies, ...)
124  */
125 struct sec_regulator_data {
126         int                             id;
127         struct regulator_init_data      *initdata;
128         struct device_node *reg_node;
129 };
130
131 /*
132  * sec_opmode_data - regulator operation mode data
133  * @id: regulator id
134  * @mode: regulator operation mode
135  */
136 struct sec_opmode_data {
137         int id;
138         unsigned int mode;
139 };
140
141 /*
142  * samsung regulator operation mode
143  * SEC_OPMODE_OFF       Regulator always OFF
144  * SEC_OPMODE_ON        Regulator always ON
145  * SEC_OPMODE_LOWPOWER  Regulator is on in low-power mode
146  * SEC_OPMODE_SUSPEND   Regulator is changed by PWREN pin
147  *                      If PWREN is high, regulator is on
148  *                      If PWREN is low, regulator is off
149  */
150
151 enum sec_opmode {
152         SEC_OPMODE_OFF,
153         SEC_OPMODE_ON,
154         SEC_OPMODE_LOWPOWER,
155         SEC_OPMODE_SUSPEND,
156 };
157
158 #endif /*  __LINUX_MFD_SEC_CORE_H */