aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/da9063-i2c.c
diff options
context:
space:
mode:
authorOpensource [Steve Twiss] <stwiss.opensource@diasemi.com>2014-07-21 06:39:33 -0400
committerLee Jones <lee.jones@linaro.org>2014-07-28 03:09:25 -0400
commit9cb42e2a8ed06e91ce9d2c59fbae8d1185ebe2f7 (patch)
tree67ab0d78b34c742ea7c1c0dde0343d851ac28659 /drivers/mfd/da9063-i2c.c
parent5fc6c39653f1c34de3f2357d50ba5baff6b6e482 (diff)
mfd: da9063: Add support for AD silicon variant
Add register definitions for DA9063 AD (0x3) silicon variant ID the ability to choose the silicon variant at run-time using regmap configuration. This patch also adds RTC support for the AD silicon changes. It adds both BB and AD support as regmap ranges and then makes the distinction between the two tables at run-time. This allows both AD and BB silicon variants to be supported at the same time. Suggested-by: Philipp Zabel <p.zabel@pengutronix.de> Signed-off-by: Opensource [Steve Twiss] <stwiss.opensource@diasemi.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'drivers/mfd/da9063-i2c.c')
-rw-r--r--drivers/mfd/da9063-i2c.c134
1 files changed, 109 insertions, 25 deletions
diff --git a/drivers/mfd/da9063-i2c.c b/drivers/mfd/da9063-i2c.c
index 8db5c805c64f..21fd8d9a217b 100644
--- a/drivers/mfd/da9063-i2c.c
+++ b/drivers/mfd/da9063-i2c.c
@@ -25,10 +25,10 @@
25#include <linux/mfd/da9063/pdata.h> 25#include <linux/mfd/da9063/pdata.h>
26#include <linux/mfd/da9063/registers.h> 26#include <linux/mfd/da9063/registers.h>
27 27
28static const struct regmap_range da9063_readable_ranges[] = { 28static const struct regmap_range da9063_ad_readable_ranges[] = {
29 { 29 {
30 .range_min = DA9063_REG_PAGE_CON, 30 .range_min = DA9063_REG_PAGE_CON,
31 .range_max = DA9063_REG_SECOND_D, 31 .range_max = DA9063_AD_REG_SECOND_D,
32 }, { 32 }, {
33 .range_min = DA9063_REG_SEQ, 33 .range_min = DA9063_REG_SEQ,
34 .range_max = DA9063_REG_ID_32_31, 34 .range_max = DA9063_REG_ID_32_31,
@@ -37,14 +37,14 @@ static const struct regmap_range da9063_readable_ranges[] = {
37 .range_max = DA9063_REG_AUTO3_LOW, 37 .range_max = DA9063_REG_AUTO3_LOW,
38 }, { 38 }, {
39 .range_min = DA9063_REG_T_OFFSET, 39 .range_min = DA9063_REG_T_OFFSET,
40 .range_max = DA9063_REG_GP_ID_19, 40 .range_max = DA9063_AD_REG_GP_ID_19,
41 }, { 41 }, {
42 .range_min = DA9063_REG_CHIP_ID, 42 .range_min = DA9063_REG_CHIP_ID,
43 .range_max = DA9063_REG_CHIP_VARIANT, 43 .range_max = DA9063_REG_CHIP_VARIANT,
44 }, 44 },
45}; 45};
46 46
47static const struct regmap_range da9063_writeable_ranges[] = { 47static const struct regmap_range da9063_ad_writeable_ranges[] = {
48 { 48 {
49 .range_min = DA9063_REG_PAGE_CON, 49 .range_min = DA9063_REG_PAGE_CON,
50 .range_max = DA9063_REG_PAGE_CON, 50 .range_max = DA9063_REG_PAGE_CON,
@@ -53,7 +53,7 @@ static const struct regmap_range da9063_writeable_ranges[] = {
53 .range_max = DA9063_REG_VSYS_MON, 53 .range_max = DA9063_REG_VSYS_MON,
54 }, { 54 }, {
55 .range_min = DA9063_REG_COUNT_S, 55 .range_min = DA9063_REG_COUNT_S,
56 .range_max = DA9063_REG_ALARM_Y, 56 .range_max = DA9063_AD_REG_ALARM_Y,
57 }, { 57 }, {
58 .range_min = DA9063_REG_SEQ, 58 .range_min = DA9063_REG_SEQ,
59 .range_max = DA9063_REG_ID_32_31, 59 .range_max = DA9063_REG_ID_32_31,
@@ -62,14 +62,14 @@ static const struct regmap_range da9063_writeable_ranges[] = {
62 .range_max = DA9063_REG_AUTO3_LOW, 62 .range_max = DA9063_REG_AUTO3_LOW,
63 }, { 63 }, {
64 .range_min = DA9063_REG_CONFIG_I, 64 .range_min = DA9063_REG_CONFIG_I,
65 .range_max = DA9063_REG_MON_REG_4, 65 .range_max = DA9063_AD_REG_MON_REG_4,
66 }, { 66 }, {
67 .range_min = DA9063_REG_GP_ID_0, 67 .range_min = DA9063_AD_REG_GP_ID_0,
68 .range_max = DA9063_REG_GP_ID_19, 68 .range_max = DA9063_AD_REG_GP_ID_19,
69 }, 69 },
70}; 70};
71 71
72static const struct regmap_range da9063_volatile_ranges[] = { 72static const struct regmap_range da9063_ad_volatile_ranges[] = {
73 { 73 {
74 .range_min = DA9063_REG_STATUS_A, 74 .range_min = DA9063_REG_STATUS_A,
75 .range_max = DA9063_REG_EVENT_D, 75 .range_max = DA9063_REG_EVENT_D,
@@ -81,26 +81,104 @@ static const struct regmap_range da9063_volatile_ranges[] = {
81 .range_max = DA9063_REG_ADC_MAN, 81 .range_max = DA9063_REG_ADC_MAN,
82 }, { 82 }, {
83 .range_min = DA9063_REG_ADC_RES_L, 83 .range_min = DA9063_REG_ADC_RES_L,
84 .range_max = DA9063_REG_SECOND_D, 84 .range_max = DA9063_AD_REG_SECOND_D,
85 }, { 85 }, {
86 .range_min = DA9063_REG_MON_REG_5, 86 .range_min = DA9063_AD_REG_MON_REG_5,
87 .range_max = DA9063_REG_MON_REG_6, 87 .range_max = DA9063_AD_REG_MON_REG_6,
88 }, 88 },
89}; 89};
90 90
91static const struct regmap_access_table da9063_readable_table = { 91static const struct regmap_access_table da9063_ad_readable_table = {
92 .yes_ranges = da9063_readable_ranges, 92 .yes_ranges = da9063_ad_readable_ranges,
93 .n_yes_ranges = ARRAY_SIZE(da9063_readable_ranges), 93 .n_yes_ranges = ARRAY_SIZE(da9063_ad_readable_ranges),
94}; 94};
95 95
96static const struct regmap_access_table da9063_writeable_table = { 96static const struct regmap_access_table da9063_ad_writeable_table = {
97 .yes_ranges = da9063_writeable_ranges, 97 .yes_ranges = da9063_ad_writeable_ranges,
98 .n_yes_ranges = ARRAY_SIZE(da9063_writeable_ranges), 98 .n_yes_ranges = ARRAY_SIZE(da9063_ad_writeable_ranges),
99}; 99};
100 100
101static const struct regmap_access_table da9063_volatile_table = { 101static const struct regmap_access_table da9063_ad_volatile_table = {
102 .yes_ranges = da9063_volatile_ranges, 102 .yes_ranges = da9063_ad_volatile_ranges,
103 .n_yes_ranges = ARRAY_SIZE(da9063_volatile_ranges), 103 .n_yes_ranges = ARRAY_SIZE(da9063_ad_volatile_ranges),
104};
105
106static const struct regmap_range da9063_bb_readable_ranges[] = {
107 {
108 .range_min = DA9063_REG_PAGE_CON,
109 .range_max = DA9063_BB_REG_SECOND_D,
110 }, {
111 .range_min = DA9063_REG_SEQ,
112 .range_max = DA9063_REG_ID_32_31,
113 }, {
114 .range_min = DA9063_REG_SEQ_A,
115 .range_max = DA9063_REG_AUTO3_LOW,
116 }, {
117 .range_min = DA9063_REG_T_OFFSET,
118 .range_max = DA9063_BB_REG_GP_ID_19,
119 }, {
120 .range_min = DA9063_REG_CHIP_ID,
121 .range_max = DA9063_REG_CHIP_VARIANT,
122 },
123};
124
125static const struct regmap_range da9063_bb_writeable_ranges[] = {
126 {
127 .range_min = DA9063_REG_PAGE_CON,
128 .range_max = DA9063_REG_PAGE_CON,
129 }, {
130 .range_min = DA9063_REG_FAULT_LOG,
131 .range_max = DA9063_REG_VSYS_MON,
132 }, {
133 .range_min = DA9063_REG_COUNT_S,
134 .range_max = DA9063_BB_REG_ALARM_Y,
135 }, {
136 .range_min = DA9063_REG_SEQ,
137 .range_max = DA9063_REG_ID_32_31,
138 }, {
139 .range_min = DA9063_REG_SEQ_A,
140 .range_max = DA9063_REG_AUTO3_LOW,
141 }, {
142 .range_min = DA9063_REG_CONFIG_I,
143 .range_max = DA9063_BB_REG_MON_REG_4,
144 }, {
145 .range_min = DA9063_BB_REG_GP_ID_0,
146 .range_max = DA9063_BB_REG_GP_ID_19,
147 },
148};
149
150static const struct regmap_range da9063_bb_volatile_ranges[] = {
151 {
152 .range_min = DA9063_REG_STATUS_A,
153 .range_max = DA9063_REG_EVENT_D,
154 }, {
155 .range_min = DA9063_REG_CONTROL_F,
156 .range_max = DA9063_REG_CONTROL_F,
157 }, {
158 .range_min = DA9063_REG_ADC_MAN,
159 .range_max = DA9063_REG_ADC_MAN,
160 }, {
161 .range_min = DA9063_REG_ADC_RES_L,
162 .range_max = DA9063_BB_REG_SECOND_D,
163 }, {
164 .range_min = DA9063_BB_REG_MON_REG_5,
165 .range_max = DA9063_BB_REG_MON_REG_6,
166 },
167};
168
169static const struct regmap_access_table da9063_bb_readable_table = {
170 .yes_ranges = da9063_bb_readable_ranges,
171 .n_yes_ranges = ARRAY_SIZE(da9063_bb_readable_ranges),
172};
173
174static const struct regmap_access_table da9063_bb_writeable_table = {
175 .yes_ranges = da9063_bb_writeable_ranges,
176 .n_yes_ranges = ARRAY_SIZE(da9063_bb_writeable_ranges),
177};
178
179static const struct regmap_access_table da9063_bb_volatile_table = {
180 .yes_ranges = da9063_bb_volatile_ranges,
181 .n_yes_ranges = ARRAY_SIZE(da9063_bb_volatile_ranges),
104}; 182};
105 183
106static const struct regmap_range_cfg da9063_range_cfg[] = { 184static const struct regmap_range_cfg da9063_range_cfg[] = {
@@ -123,10 +201,6 @@ static struct regmap_config da9063_regmap_config = {
123 .max_register = DA9063_REG_CHIP_VARIANT, 201 .max_register = DA9063_REG_CHIP_VARIANT,
124 202
125 .cache_type = REGCACHE_RBTREE, 203 .cache_type = REGCACHE_RBTREE,
126
127 .rd_table = &da9063_readable_table,
128 .wr_table = &da9063_writeable_table,
129 .volatile_table = &da9063_volatile_table,
130}; 204};
131 205
132static int da9063_i2c_probe(struct i2c_client *i2c, 206static int da9063_i2c_probe(struct i2c_client *i2c,
@@ -143,6 +217,16 @@ static int da9063_i2c_probe(struct i2c_client *i2c,
143 da9063->dev = &i2c->dev; 217 da9063->dev = &i2c->dev;
144 da9063->chip_irq = i2c->irq; 218 da9063->chip_irq = i2c->irq;
145 219
220 if (da9063->variant_code == PMIC_DA9063_AD) {
221 da9063_regmap_config.rd_table = &da9063_ad_readable_table;
222 da9063_regmap_config.wr_table = &da9063_ad_writeable_table;
223 da9063_regmap_config.volatile_table = &da9063_ad_volatile_table;
224 } else {
225 da9063_regmap_config.rd_table = &da9063_bb_readable_table;
226 da9063_regmap_config.wr_table = &da9063_bb_writeable_table;
227 da9063_regmap_config.volatile_table = &da9063_bb_volatile_table;
228 }
229
146 da9063->regmap = devm_regmap_init_i2c(i2c, &da9063_regmap_config); 230 da9063->regmap = devm_regmap_init_i2c(i2c, &da9063_regmap_config);
147 if (IS_ERR(da9063->regmap)) { 231 if (IS_ERR(da9063->regmap)) {
148 ret = PTR_ERR(da9063->regmap); 232 ret = PTR_ERR(da9063->regmap);