Skip to content

Commit 2eef018

Browse files
Freeman Liugregkh
authored andcommitted
nvmem: sc27xx: add sc2730 efuse support
Add support to the new efuse IP which is integrated in the SC2730 which includes multiple blocks in a single chip. Signed-off-by: Freeman Liu <[email protected]> Signed-off-by: Chunyan Zhang <[email protected]> Reviewed-by: Baolin Wang <[email protected]> Signed-off-by: Srinivas Kandagatla <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 8356671 commit 2eef018

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

drivers/nvmem/sc27xx-efuse.c

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
#include <linux/hwspinlock.h>
55
#include <linux/module.h>
66
#include <linux/of.h>
7+
#include <linux/of_device.h>
78
#include <linux/platform_device.h>
89
#include <linux/regmap.h>
910
#include <linux/nvmem-provider.h>
1011

1112
/* PMIC global registers definition */
1213
#define SC27XX_MODULE_EN 0xc08
14+
#define SC2730_MODULE_EN 0x1808
1315
#define SC27XX_EFUSE_EN BIT(6)
1416

1517
/* Efuse controller registers definition */
@@ -49,12 +51,29 @@
4951
#define SC27XX_EFUSE_POLL_TIMEOUT 3000000
5052
#define SC27XX_EFUSE_POLL_DELAY_US 10000
5153

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+
5262
struct sc27xx_efuse {
5363
struct device *dev;
5464
struct regmap *regmap;
5565
struct hwspinlock *hwlock;
5666
struct mutex mutex;
5767
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,
5877
};
5978

6079
/*
@@ -119,7 +138,7 @@ static int sc27xx_efuse_read(void *context, u32 offset, void *val, size_t bytes)
119138
return ret;
120139

121140
/* 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,
123142
SC27XX_EFUSE_EN, SC27XX_EFUSE_EN);
124143
if (ret)
125144
goto unlock_efuse;
@@ -169,7 +188,7 @@ static int sc27xx_efuse_read(void *context, u32 offset, void *val, size_t bytes)
169188

170189
disable_efuse:
171190
/* 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);
173192
unlock_efuse:
174193
sc27xx_efuse_unlock(efuse);
175194

@@ -219,6 +238,7 @@ static int sc27xx_efuse_probe(struct platform_device *pdev)
219238

220239
mutex_init(&efuse->mutex);
221240
efuse->dev = &pdev->dev;
241+
efuse->var_data = of_device_get_match_data(&pdev->dev);
222242

223243
econfig.stride = 1;
224244
econfig.word_size = 1;
@@ -238,7 +258,8 @@ static int sc27xx_efuse_probe(struct platform_device *pdev)
238258
}
239259

240260
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},
242263
{ }
243264
};
244265

0 commit comments

Comments
 (0)