20
20
#include <linux/mfd/samsung/s5m8767.h>
21
21
#include <linux/mod_devicetable.h>
22
22
#include <linux/module.h>
23
- #include <linux/of.h>
24
23
#include <linux/pm.h>
24
+ #include <linux/property.h>
25
25
#include <linux/regmap.h>
26
26
#include "sec-core.h"
27
27
28
+ struct sec_pmic_i2c_platform_data {
29
+ const struct regmap_config * regmap_cfg ;
30
+ unsigned long device_type ;
31
+ };
32
+
28
33
static bool s2mpa01_volatile (struct device * dev , unsigned int reg )
29
34
{
30
35
switch (reg ) {
@@ -136,52 +141,20 @@ static const struct regmap_config s5m8767_regmap_config = {
136
141
137
142
static int sec_pmic_i2c_probe (struct i2c_client * client )
138
143
{
139
- const struct regmap_config * regmap ;
140
- unsigned long device_type ;
144
+ const struct sec_pmic_i2c_platform_data * pdata ;
141
145
struct regmap * regmap_pmic ;
142
146
143
- device_type = (unsigned long )of_device_get_match_data (& client -> dev );
144
-
145
- switch (device_type ) {
146
- case S2DOS05 :
147
- regmap = & s2dos05_regmap_config ;
148
- break ;
149
- case S2MPA01 :
150
- regmap = & s2mpa01_regmap_config ;
151
- break ;
152
- case S2MPS11X :
153
- regmap = & s2mps11_regmap_config ;
154
- break ;
155
- case S2MPS13X :
156
- regmap = & s2mps13_regmap_config ;
157
- break ;
158
- case S2MPS14X :
159
- regmap = & s2mps14_regmap_config ;
160
- break ;
161
- case S2MPS15X :
162
- regmap = & s2mps15_regmap_config ;
163
- break ;
164
- case S2MPU02 :
165
- regmap = & s2mpu02_regmap_config ;
166
- break ;
167
- case S2MPU05 :
168
- regmap = & s2mpu05_regmap_config ;
169
- break ;
170
- case S5M8767X :
171
- regmap = & s5m8767_regmap_config ;
172
- break ;
173
- default :
147
+ pdata = device_get_match_data (& client -> dev );
148
+ if (!pdata )
174
149
return dev_err_probe (& client -> dev , - ENODEV ,
175
- "Unsupported device type %lu\n" ,
176
- device_type );
177
- }
150
+ "Unsupported device type\n" );
178
151
179
- regmap_pmic = devm_regmap_init_i2c (client , regmap );
152
+ regmap_pmic = devm_regmap_init_i2c (client , pdata -> regmap_cfg );
180
153
if (IS_ERR (regmap_pmic ))
181
154
return dev_err_probe (& client -> dev , PTR_ERR (regmap_pmic ),
182
155
"regmap init failed\n" );
183
156
184
- return sec_pmic_probe (& client -> dev , device_type , client -> irq ,
157
+ return sec_pmic_probe (& client -> dev , pdata -> device_type , client -> irq ,
185
158
regmap_pmic , client );
186
159
}
187
160
@@ -190,35 +163,61 @@ static void sec_pmic_i2c_shutdown(struct i2c_client *i2c)
190
163
sec_pmic_shutdown (& i2c -> dev );
191
164
}
192
165
166
+ static const struct sec_pmic_i2c_platform_data s2dos05_data = {
167
+ .regmap_cfg = & s2dos05_regmap_config ,
168
+ .device_type = S2DOS05
169
+ };
170
+
171
+ static const struct sec_pmic_i2c_platform_data s2mpa01_data = {
172
+ .regmap_cfg = & s2mpa01_regmap_config ,
173
+ .device_type = S2MPA01 ,
174
+ };
175
+
176
+ static const struct sec_pmic_i2c_platform_data s2mps11_data = {
177
+ .regmap_cfg = & s2mps11_regmap_config ,
178
+ .device_type = S2MPS11X ,
179
+ };
180
+
181
+ static const struct sec_pmic_i2c_platform_data s2mps13_data = {
182
+ .regmap_cfg = & s2mps13_regmap_config ,
183
+ .device_type = S2MPS13X ,
184
+ };
185
+
186
+ static const struct sec_pmic_i2c_platform_data s2mps14_data = {
187
+ .regmap_cfg = & s2mps14_regmap_config ,
188
+ .device_type = S2MPS14X ,
189
+ };
190
+
191
+ static const struct sec_pmic_i2c_platform_data s2mps15_data = {
192
+ .regmap_cfg = & s2mps15_regmap_config ,
193
+ .device_type = S2MPS15X ,
194
+ };
195
+
196
+ static const struct sec_pmic_i2c_platform_data s2mpu02_data = {
197
+ .regmap_cfg = & s2mpu02_regmap_config ,
198
+ .device_type = S2MPU02 ,
199
+ };
200
+
201
+ static const struct sec_pmic_i2c_platform_data s2mpu05_data = {
202
+ .regmap_cfg = & s2mpu05_regmap_config ,
203
+ .device_type = S2MPU05 ,
204
+ };
205
+
206
+ static const struct sec_pmic_i2c_platform_data s5m8767_data = {
207
+ .regmap_cfg = & s5m8767_regmap_config ,
208
+ .device_type = S5M8767X ,
209
+ };
210
+
193
211
static const struct of_device_id sec_pmic_i2c_of_match [] = {
194
- {
195
- .compatible = "samsung,s2dos05" ,
196
- .data = (void * )S2DOS05 ,
197
- }, {
198
- .compatible = "samsung,s2mpa01-pmic" ,
199
- .data = (void * )S2MPA01 ,
200
- }, {
201
- .compatible = "samsung,s2mps11-pmic" ,
202
- .data = (void * )S2MPS11X ,
203
- }, {
204
- .compatible = "samsung,s2mps13-pmic" ,
205
- .data = (void * )S2MPS13X ,
206
- }, {
207
- .compatible = "samsung,s2mps14-pmic" ,
208
- .data = (void * )S2MPS14X ,
209
- }, {
210
- .compatible = "samsung,s2mps15-pmic" ,
211
- .data = (void * )S2MPS15X ,
212
- }, {
213
- .compatible = "samsung,s2mpu02-pmic" ,
214
- .data = (void * )S2MPU02 ,
215
- }, {
216
- .compatible = "samsung,s2mpu05-pmic" ,
217
- .data = (void * )S2MPU05 ,
218
- }, {
219
- .compatible = "samsung,s5m8767-pmic" ,
220
- .data = (void * )S5M8767X ,
221
- },
212
+ { .compatible = "samsung,s2dos05" , .data = & s2dos05_data , },
213
+ { .compatible = "samsung,s2mpa01-pmic" , .data = & s2mpa01_data , },
214
+ { .compatible = "samsung,s2mps11-pmic" , .data = & s2mps11_data , },
215
+ { .compatible = "samsung,s2mps13-pmic" , .data = & s2mps13_data , },
216
+ { .compatible = "samsung,s2mps14-pmic" , .data = & s2mps14_data , },
217
+ { .compatible = "samsung,s2mps15-pmic" , .data = & s2mps15_data , },
218
+ { .compatible = "samsung,s2mpu02-pmic" , .data = & s2mpu02_data , },
219
+ { .compatible = "samsung,s2mpu05-pmic" , .data = & s2mpu05_data , },
220
+ { .compatible = "samsung,s5m8767-pmic" , .data = & s5m8767_data , },
222
221
{ },
223
222
};
224
223
MODULE_DEVICE_TABLE (of , sec_pmic_i2c_of_match );
0 commit comments