4
4
#include <linux/hwspinlock.h>
5
5
#include <linux/module.h>
6
6
#include <linux/of.h>
7
+ #include <linux/of_device.h>
7
8
#include <linux/platform_device.h>
8
9
#include <linux/regmap.h>
9
10
#include <linux/nvmem-provider.h>
10
11
11
12
/* PMIC global registers definition */
12
13
#define SC27XX_MODULE_EN 0xc08
14
+ #define SC2730_MODULE_EN 0x1808
13
15
#define SC27XX_EFUSE_EN BIT(6)
14
16
15
17
/* Efuse controller registers definition */
49
51
#define SC27XX_EFUSE_POLL_TIMEOUT 3000000
50
52
#define SC27XX_EFUSE_POLL_DELAY_US 10000
51
53
54
+ /*
55
+ * Since different PMICs of SC27xx series can have different
56
+ * address , we should save address in the device data structure.
57
+ */
58
+ struct sc27xx_efuse_variant_data {
59
+ u32 module_en ;
60
+ };
61
+
52
62
struct sc27xx_efuse {
53
63
struct device * dev ;
54
64
struct regmap * regmap ;
55
65
struct hwspinlock * hwlock ;
56
66
struct mutex mutex ;
57
67
u32 base ;
68
+ const struct sc27xx_efuse_variant_data * var_data ;
69
+ };
70
+
71
+ static const struct sc27xx_efuse_variant_data sc2731_edata = {
72
+ .module_en = SC27XX_MODULE_EN ,
73
+ };
74
+
75
+ static const struct sc27xx_efuse_variant_data sc2730_edata = {
76
+ .module_en = SC2730_MODULE_EN ,
58
77
};
59
78
60
79
/*
@@ -119,7 +138,7 @@ static int sc27xx_efuse_read(void *context, u32 offset, void *val, size_t bytes)
119
138
return ret ;
120
139
121
140
/* Enable the efuse controller. */
122
- ret = regmap_update_bits (efuse -> regmap , SC27XX_MODULE_EN ,
141
+ ret = regmap_update_bits (efuse -> regmap , efuse -> var_data -> module_en ,
123
142
SC27XX_EFUSE_EN , SC27XX_EFUSE_EN );
124
143
if (ret )
125
144
goto unlock_efuse ;
@@ -169,7 +188,7 @@ static int sc27xx_efuse_read(void *context, u32 offset, void *val, size_t bytes)
169
188
170
189
disable_efuse :
171
190
/* Disable the efuse controller after reading. */
172
- regmap_update_bits (efuse -> regmap , SC27XX_MODULE_EN , SC27XX_EFUSE_EN , 0 );
191
+ regmap_update_bits (efuse -> regmap , efuse -> var_data -> module_en , SC27XX_EFUSE_EN , 0 );
173
192
unlock_efuse :
174
193
sc27xx_efuse_unlock (efuse );
175
194
@@ -219,6 +238,7 @@ static int sc27xx_efuse_probe(struct platform_device *pdev)
219
238
220
239
mutex_init (& efuse -> mutex );
221
240
efuse -> dev = & pdev -> dev ;
241
+ efuse -> var_data = of_device_get_match_data (& pdev -> dev );
222
242
223
243
econfig .stride = 1 ;
224
244
econfig .word_size = 1 ;
@@ -238,7 +258,8 @@ static int sc27xx_efuse_probe(struct platform_device *pdev)
238
258
}
239
259
240
260
static const struct of_device_id sc27xx_efuse_of_match [] = {
241
- { .compatible = "sprd,sc2731-efuse" },
261
+ { .compatible = "sprd,sc2731-efuse" , .data = & sc2731_edata },
262
+ { .compatible = "sprd,sc2730-efuse" , .data = & sc2730_edata },
242
263
{ }
243
264
};
244
265
0 commit comments