25 #include <linux/kernel.h>
26 #include <linux/module.h>
29 #include <linux/slab.h>
30 #include <linux/i2c.h>
35 #define RICOH_ONOFFSEL_REG 0x10
36 #define RICOH_SWCTL_REG 0x5E
43 #define DEEPSLEEP_INIT(_id, _reg, _pos) \
45 .reg_add = RC5T583_##_reg, \
75 (RC5T583_EXT_PWRREQ1_CONTROL | RC5T583_EXT_PWRREQ2_CONTROL)
77 static struct mfd_cell rc5t583_subdevs[] = {
78 {.name =
"rc5t583-gpio",},
79 {.name =
"rc5t583-regulator",},
80 {.name =
"rc5t583-rtc", },
81 {.name =
"rc5t583-key", }
84 static int __rc5t583_set_ext_pwrreq1_control(
struct device *
dev,
85 int id,
int ext_pwr,
int slots)
90 unsigned int slot_bit;
93 dev_err(dev,
"PWRREQ1 is invalid control for rail %d\n",
id);
98 slot_bit = en_bit + 1;
99 ret = rc5t583_read(dev, deepsleep_data[
id].reg_add, &sleepseq_val);
101 dev_err(dev,
"Error in reading reg 0x%x\n",
102 deepsleep_data[
id].reg_add);
106 sleepseq_val &= ~(0xF << en_bit);
107 sleepseq_val |=
BIT(en_bit);
108 sleepseq_val |= ((slots & 0x7) << slot_bit);
111 dev_err(dev,
"Error in updating the 0x%02x register\n",
116 ret = rc5t583_write(dev, deepsleep_data[
id].reg_add, sleepseq_val);
118 dev_err(dev,
"Error in writing reg 0x%x\n",
119 deepsleep_data[
id].reg_add);
126 dev_err(dev,
"Error in writing reg 0x%x\n",
132 static int __rc5t583_set_ext_pwrreq2_control(
struct device *dev,
138 dev_err(dev,
"PWRREQ2 is invalid control for rail %d\n",
id);
144 dev_err(dev,
"Error in updating the ONOFFSEL 0x10 register\n");
149 int ext_pwr_req,
int deepsleep_slot_nr)
155 return __rc5t583_set_ext_pwrreq1_control(dev, ds_id,
156 ext_pwr_req, deepsleep_slot_nr);
159 return __rc5t583_set_ext_pwrreq2_control(dev,
178 dev_warn(rc5t583->
dev,
"Error in writing reg %d error: %d\n",
183 dev_warn(rc5t583->
dev,
"Error in writing reg %d error: %d\n",
188 ret = rc5t583_write(rc5t583->
dev, i, 0x0);
191 "Error in writing reg 0x%02x error: %d\n",
197 static bool volatile_reg(
struct device *dev,
unsigned int reg)
240 static const struct regmap_config rc5t583_regmap_config = {
243 .volatile_reg = volatile_reg,
252 struct rc5t583 *rc5t583;
255 bool irq_init_success =
false;
258 dev_err(&i2c->
dev,
"Err: Platform data not found\n");
264 dev_err(&i2c->
dev,
"Memory allocation failed\n");
269 i2c_set_clientdata(i2c, rc5t583);
272 if (IS_ERR(rc5t583->
regmap)) {
273 ret = PTR_ERR(rc5t583->
regmap);
274 dev_err(&i2c->
dev,
"regmap initialization failed: %d\n", ret);
278 ret = rc5t583_clear_ext_power_req(rc5t583, pdata);
288 irq_init_success =
true;
294 dev_err(&i2c->
dev,
"add mfd devices failed: %d\n", ret);
301 if (irq_init_success)
308 struct rc5t583 *rc5t583 = i2c_get_clientdata(i2c);
316 {.name =
"rc5t583", .driver_data = 0},
322 static struct i2c_driver rc5t583_i2c_driver = {
327 .probe = rc5t583_i2c_probe,
329 .id_table = rc5t583_i2c_id,
332 static int __init rc5t583_i2c_init(
void)
334 return i2c_add_driver(&rc5t583_i2c_driver);
338 static void __exit rc5t583_i2c_exit(
void)