24 #include <linux/slab.h>
25 #include <linux/i2c.h>
28 #include <linux/module.h>
34 #define I2C_ADDR_PMIC (0xCC >> 1)
35 #define I2C_ADDR_MUIC (0x4A >> 1)
36 #define I2C_ADDR_BATTERY (0x6C >> 1)
37 #define I2C_ADDR_RTC (0x0C >> 1)
38 #define I2C_ADDR_HAPTIC (0x90 >> 1)
40 static struct mfd_cell max8997_devs[] = {
41 { .name =
"max8997-pmic", },
42 { .name =
"max8997-rtc", },
43 { .name =
"max8997-battery", },
44 { .name =
"max8997-haptic", },
45 { .name =
"max8997-muic", },
46 { .name =
"max8997-led", .id = 1 },
47 { .name =
"max8997-led", .id = 2 },
52 struct max8997_dev *max8997 = i2c_get_clientdata(i2c);
69 struct max8997_dev *max8997 = i2c_get_clientdata(i2c);
84 struct max8997_dev *max8997 = i2c_get_clientdata(i2c);
96 struct max8997_dev *max8997 = i2c_get_clientdata(i2c);
111 struct max8997_dev *max8997 = i2c_get_clientdata(i2c);
117 u8 old_val = ret & 0xff;
118 u8 new_val = (val &
mask) | (old_val & (~mask));
137 i2c_set_clientdata(i2c, max8997);
140 max8997->
type =
id->driver_data;
146 max8997->
ono = pdata->
ono;
151 i2c_set_clientdata(max8997->
rtc, max8997);
153 i2c_set_clientdata(max8997->
haptic, max8997);
155 i2c_set_clientdata(max8997->
muic, max8997);
157 pm_runtime_set_active(max8997->
dev);
188 static int max8997_i2c_remove(
struct i2c_client *i2c)
190 struct max8997_dev *max8997 = i2c_get_clientdata(i2c);
208 static u8 max8997_dumpaddr_pmic[] = {
333 static u8 max8997_dumpaddr_muic[] = {
343 static u8 max8997_dumpaddr_haptic[] = {
361 static int max8997_freeze(
struct device *
dev)
364 struct max8997_dev *max8997 = i2c_get_clientdata(i2c);
367 for (i = 0; i <
ARRAY_SIZE(max8997_dumpaddr_pmic); i++)
371 for (i = 0; i <
ARRAY_SIZE(max8997_dumpaddr_muic); i++)
375 for (i = 0; i <
ARRAY_SIZE(max8997_dumpaddr_haptic); i++)
383 static int max8997_restore(
struct device *dev)
386 struct max8997_dev *max8997 = i2c_get_clientdata(i2c);
389 for (i = 0; i <
ARRAY_SIZE(max8997_dumpaddr_pmic); i++)
393 for (i = 0; i <
ARRAY_SIZE(max8997_dumpaddr_muic); i++)
397 for (i = 0; i <
ARRAY_SIZE(max8997_dumpaddr_haptic); i++)
405 static int max8997_suspend(
struct device *dev)
408 struct max8997_dev *max8997 = i2c_get_clientdata(i2c);
410 if (device_may_wakeup(dev))
415 static int max8997_resume(
struct device *dev)
418 struct max8997_dev *max8997 = i2c_get_clientdata(i2c);
420 if (device_may_wakeup(dev))
426 .suspend = max8997_suspend,
427 .resume = max8997_resume,
428 .freeze = max8997_freeze,
429 .restore = max8997_restore,
432 static struct i2c_driver max8997_i2c_driver = {
438 .probe = max8997_i2c_probe,
439 .remove = max8997_i2c_remove,
440 .id_table = max8997_i2c_id,
443 static int __init max8997_i2c_init(
void)
445 return i2c_add_driver(&max8997_i2c_driver);
450 static void __exit max8997_i2c_exit(
void)