max77888.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600
  1. /*
  2. * max77888.c - mfd core driver for the Maxim 77888
  3. *
  4. * Copyright (C) 2011 Samsung Electronics
  5. * SangYoung Son <hello.son@smasung.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. *
  21. * This driver is based on max8997.c
  22. */
  23. #include <linux/slab.h>
  24. #include <linux/i2c.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/mutex.h>
  27. #include <linux/module.h>
  28. #include <linux/mfd/core.h>
  29. #include <linux/mfd/max77888.h>
  30. #include <linux/mfd/max77888-private.h>
  31. #include <linux/regulator/machine.h>
  32. #include <linux/delay.h>
  33. #if defined (CONFIG_OF)
  34. #include <linux/of_device.h>
  35. #include <linux/of_gpio.h>
  36. #endif
  37. #define I2C_ADDR_PMIC (0xCC >> 1) /* Charger, Flash LED */
  38. #define I2C_ADDR_MUIC (0x4A >> 1)
  39. #define I2C_ADDR_HAPTIC (0x90 >> 1)
  40. #define I2C_ADDR_TEST (0xCE >> 1) /* TEST register */
  41. #ifdef CONFIG_MUIC_RESET_PIN_ENABLE
  42. int muic_reset_pin = 0;
  43. EXPORT_SYMBOL_GPL(muic_reset_pin);
  44. #endif
  45. static struct mfd_cell max77888_devs[] = {
  46. { .name = "max77888-charger", },
  47. { .name = "max77888-led", },
  48. { .name = "max77888-muic", },
  49. { .name = "max77888-safeout", },
  50. { .name = "max77888-haptic", },
  51. };
  52. int max77888_read_reg(struct i2c_client *i2c, u8 reg, u8 *dest)
  53. {
  54. struct max77888_dev *max77888 = i2c_get_clientdata(i2c);
  55. int ret;
  56. mutex_lock(&max77888->iolock);
  57. ret = i2c_smbus_read_byte_data(i2c, reg);
  58. mutex_unlock(&max77888->iolock);
  59. if (ret < 0)
  60. return ret;
  61. ret &= 0xff;
  62. *dest = ret;
  63. return 0;
  64. }
  65. EXPORT_SYMBOL_GPL(max77888_read_reg);
  66. int max77888_bulk_read(struct i2c_client *i2c, u8 reg, int count, u8 *buf)
  67. {
  68. struct max77888_dev *max77888 = i2c_get_clientdata(i2c);
  69. int ret;
  70. mutex_lock(&max77888->iolock);
  71. ret = i2c_smbus_read_i2c_block_data(i2c, reg, count, buf);
  72. mutex_unlock(&max77888->iolock);
  73. if (ret < 0)
  74. return ret;
  75. return 0;
  76. }
  77. EXPORT_SYMBOL_GPL(max77888_bulk_read);
  78. int max77888_write_reg(struct i2c_client *i2c, u8 reg, u8 value)
  79. {
  80. struct max77888_dev *max77888 = i2c_get_clientdata(i2c);
  81. int ret;
  82. mutex_lock(&max77888->iolock);
  83. ret = i2c_smbus_write_byte_data(i2c, reg, value);
  84. mutex_unlock(&max77888->iolock);
  85. return ret;
  86. }
  87. EXPORT_SYMBOL_GPL(max77888_write_reg);
  88. int max77888_bulk_write(struct i2c_client *i2c, u8 reg, int count, u8 *buf)
  89. {
  90. struct max77888_dev *max77888 = i2c_get_clientdata(i2c);
  91. int ret;
  92. mutex_lock(&max77888->iolock);
  93. ret = i2c_smbus_write_i2c_block_data(i2c, reg, count, buf);
  94. mutex_unlock(&max77888->iolock);
  95. if (ret < 0)
  96. return ret;
  97. return 0;
  98. }
  99. EXPORT_SYMBOL_GPL(max77888_bulk_write);
  100. static int max77888_read_word(struct i2c_client *i2c, u8 reg)
  101. {
  102. struct max77888_dev *max77888 = i2c_get_clientdata(i2c);
  103. int ret;
  104. mutex_lock(&max77888->iolock);
  105. ret = i2c_smbus_read_word_data(i2c, reg);
  106. mutex_unlock(&max77888->iolock);
  107. return ret;
  108. }
  109. int max77888_update_reg(struct i2c_client *i2c, u8 reg, u8 val, u8 mask)
  110. {
  111. struct max77888_dev *max77888 = i2c_get_clientdata(i2c);
  112. int ret;
  113. mutex_lock(&max77888->iolock);
  114. ret = i2c_smbus_read_byte_data(i2c, reg);
  115. if (ret >= 0) {
  116. u8 old_val = ret & 0xff;
  117. u8 new_val = (val & mask) | (old_val & (~mask));
  118. ret = i2c_smbus_write_byte_data(i2c, reg, new_val);
  119. }
  120. mutex_unlock(&max77888->iolock);
  121. return ret;
  122. }
  123. EXPORT_SYMBOL_GPL(max77888_update_reg);
  124. static int of_max77888_dt(struct device *dev, struct max77888_platform_data *pdata)
  125. {
  126. struct device_node *np = dev->of_node;
  127. int retval = 0;
  128. #ifdef CONFIG_SS_VIBRATOR
  129. struct max77888_haptic_platform_data *haptic_data;
  130. haptic_data = kzalloc(sizeof(struct max77888_haptic_platform_data), GFP_KERNEL);
  131. if (haptic_data == NULL)
  132. return -ENOMEM;
  133. #endif
  134. if(!np) {
  135. #ifdef CONFIG_SS_VIBRATOR
  136. kfree(haptic_data);
  137. #endif
  138. return -EINVAL;
  139. }
  140. pdata->irq_gpio = of_get_named_gpio(np, "max77888,irq-gpio", 0);
  141. if (pdata->irq_gpio < 0) {
  142. pr_err("%s: failed get max77888 irq-gpio : %d\n",
  143. __func__, pdata->irq_gpio);
  144. pdata->irq_gpio = 0;
  145. }
  146. #ifdef CONFIG_MUIC_RESET_PIN_ENABLE
  147. pdata->irq_reset_gpio = of_get_named_gpio(np, "max77888,irq-reset-gpio", 0);
  148. if (pdata->irq_reset_gpio < 0) {
  149. pr_err("%s: failed get max77888 irq-reset-gpio : %d\n",
  150. __func__, pdata->irq_gpio);
  151. pdata->irq_reset_gpio = -1;
  152. muic_reset_pin = 0;
  153. }
  154. else
  155. muic_reset_pin = 1;
  156. #endif
  157. retval = of_property_read_u32(np, "max77888,irq-base", &pdata->irq_base);
  158. pdata->wakeup = of_property_read_bool(np, "max77888,wakeup");
  159. pr_info("%s: irq-gpio: %u \n", __func__, pdata->irq_gpio);
  160. #ifdef CONFIG_MUIC_RESET_PIN_ENABLE
  161. pr_info("%s: irq-reset-gpio: %u \n", __func__, pdata->irq_reset_gpio);
  162. #endif
  163. pr_info("%s: irq-gpio_flags: %u \n", __func__, pdata->irq_gpio_flags);
  164. pr_info("%s: irq-base: %u \n", __func__, pdata->irq_base);
  165. #ifdef CONFIG_SS_VIBRATOR
  166. of_property_read_u32(np, "haptic,max_timeout", &haptic_data->max_timeout);
  167. of_property_read_u32(np, "haptic,duty", &haptic_data->duty);
  168. of_property_read_u32(np, "haptic,period", &haptic_data->period);
  169. of_property_read_u32(np, "haptic,pwm_id", &haptic_data->pwm_id);
  170. pr_info("%s: timeout: %u \n", __func__, haptic_data->max_timeout);
  171. pr_info("%s: duty: %u \n", __func__, haptic_data->duty);
  172. pr_info("%s: period: %u \n", __func__, haptic_data->period);
  173. pr_info("%s: pwm_id: %u \n", __func__, haptic_data->pwm_id);
  174. pdata->haptic_data = haptic_data;
  175. #endif
  176. return 0;
  177. }
  178. static int max77888_i2c_probe(struct i2c_client *i2c,
  179. const struct i2c_device_id *id)
  180. {
  181. struct max77888_dev *max77888;
  182. struct max77888_platform_data *pdata;
  183. u8 reg_data;
  184. u16 reg_data16;
  185. u8 str_data[10] = {0,};
  186. int i;
  187. int ret = 0;
  188. msleep(500);
  189. max77888 = kzalloc(sizeof(struct max77888_dev), GFP_KERNEL);
  190. if (max77888 == NULL)
  191. return -ENOMEM;
  192. if (i2c->dev.of_node) {
  193. pdata = devm_kzalloc(&i2c->dev,
  194. sizeof(struct max77888_platform_data),
  195. GFP_KERNEL);
  196. if (!pdata) {
  197. dev_err(&i2c->dev, "Failed to allocate memory \n");
  198. ret = -ENOMEM;
  199. goto err;
  200. }
  201. ret = of_max77888_dt(&i2c->dev, pdata);
  202. if (ret < 0){
  203. dev_err(&i2c->dev, "Failed to get device of_node \n");
  204. return ret;
  205. }
  206. /*Filling the platform data*/
  207. pdata->muic = &max77888_muic;
  208. #if defined(CONFIG_REGULATOR_MAX77888)
  209. pdata->num_regulators = MAX77888_REG_MAX;
  210. pdata->regulators = max77888_regulators,
  211. #endif
  212. #ifdef CONFIG_LEDS_MAX77888
  213. pdata->led_data = &max77888_led_pdata;
  214. #endif
  215. /*pdata update to other modules*/
  216. i2c->dev.platform_data = pdata;
  217. } else {
  218. pdata = i2c->dev.platform_data;
  219. }
  220. i2c_set_clientdata(i2c, max77888);
  221. max77888->dev = &i2c->dev;
  222. max77888->i2c = i2c;
  223. max77888->irq = i2c->irq;
  224. if (pdata) {
  225. max77888->irq_base = pdata->irq_base;
  226. max77888->irq_gpio = pdata->irq_gpio;
  227. #ifdef CONFIG_MUIC_RESET_PIN_ENABLE
  228. if (muic_reset_pin)
  229. {
  230. max77888->irq_reset_gpio = pdata->irq_reset_gpio;
  231. gpio_tlmm_config(GPIO_CFG(max77888->irq_reset_gpio, 0, GPIO_CFG_INPUT,
  232. GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_DISABLE);
  233. }
  234. #endif
  235. max77888->wakeup = pdata->wakeup;
  236. gpio_tlmm_config(GPIO_CFG(max77888->irq_gpio, 0, GPIO_CFG_INPUT,
  237. GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_DISABLE);
  238. } else {
  239. goto err;
  240. }
  241. mutex_init(&max77888->iolock);
  242. if (max77888_read_reg(i2c, MAX77888_PMIC_REG_PMIC_ID2, &reg_data) < 0) {
  243. dev_err(max77888->dev,
  244. "device not found on this channel (this is not an error)\n");
  245. ret = -ENODEV;
  246. goto err;
  247. } else {
  248. /* print rev */
  249. max77888->pmic_rev = (reg_data & 0x7);
  250. max77888->pmic_ver = ((reg_data & 0xF8) >> 0x3);
  251. pr_info("%s: device found: rev.0x%x, ver.0x%x\n", __func__,
  252. max77888->pmic_rev, max77888->pmic_ver);
  253. }
  254. /* No active discharge on safeout ldo 1,2 */
  255. max77888_update_reg(i2c, MAX77888_CHG_REG_SAFEOUT_CTRL, 0x00, 0x30);
  256. pr_info("%s: i2c->name=%s irq=%d !!!\n",__func__, i2c->name, i2c->irq);
  257. max77888->muic = i2c_new_dummy(i2c->adapter, I2C_ADDR_MUIC);
  258. i2c_set_clientdata(max77888->muic, max77888);
  259. max77888->haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC);
  260. i2c_set_clientdata(max77888->haptic, max77888);
  261. // Set TEST Reigster Slave address
  262. max77888->test = i2c_new_dummy(i2c->adapter, I2C_ADDR_TEST);
  263. i2c_set_clientdata(max77888->test, max77888);
  264. // Start Over-write wrong-Trimmed bit //
  265. // 1. Test Register Access Enabled
  266. max77888_write_reg(max77888->i2c, 0xFE, 0xC5);
  267. // 2. Enable TST_KEY
  268. max77888_write_reg(max77888->test, 0xB3, 0x0C);
  269. // 3. Read 0x2E with word unit.
  270. reg_data16 = max77888_read_word(max77888->test, 0x2E);
  271. // 4. Check Bit5 of First bit(Bit13)
  272. if ((reg_data16 & 0x2000) == 0) {
  273. // Wrong Trimmed
  274. // 5. Read and Store
  275. // 5-1. Read and Store from 0x21 to 0x2A
  276. for (i = 0x21; i <= 0x2A; i++) {
  277. if (i == 0x25) {
  278. continue;
  279. }
  280. reg_data16 = max77888_read_word(max77888->test, i);
  281. str_data[i-0x21] = (reg_data16 >> 8);
  282. }
  283. // 5-2. Read and Store 0x2E
  284. reg_data16 = max77888_read_word(max77888->test, i);
  285. reg_data = (reg_data16 >> 8);
  286. // 6. Write Stored data from 0x21 to 0x2A.
  287. for (i = 0x21; i <= 0x2A; i++) {
  288. if ( i == 0x25) {
  289. continue;
  290. }
  291. max77888_write_reg(max77888->test, i, str_data[i-0x21]);
  292. }
  293. // 7. Write 0x2E
  294. max77888_write_reg(max77888->test, 0x2E, (reg_data | 0x20));
  295. // 8. Write 0x20 to 0x40.
  296. max77888_write_reg(max77888->test, 0x20, 0x40);
  297. }
  298. // 9. Disable TST_KEY, Write 0xB3 to 0x00
  299. max77888_write_reg(max77888->test, 0xB3, 0x00);
  300. // 10. Test Register Access Disabled, Write 0xFE to 0x00
  301. max77888_write_reg(max77888->i2c, 0xFE, 0x00);
  302. ret = max77888_irq_init(max77888);
  303. if (ret < 0)
  304. goto err_irq_init;
  305. ret = mfd_add_devices(max77888->dev, -1, max77888_devs,
  306. ARRAY_SIZE(max77888_devs), NULL, 0);
  307. if (ret < 0)
  308. goto err_mfd;
  309. device_init_wakeup(max77888->dev, pdata->wakeup);
  310. pr_info("%s:%d:", __func__, __LINE__ );
  311. return ret;
  312. err_mfd:
  313. mfd_remove_devices(max77888->dev);
  314. max77888_irq_exit(max77888);
  315. err_irq_init:
  316. i2c_unregister_device(max77888->muic);
  317. i2c_unregister_device(max77888->haptic);
  318. err:
  319. pr_info("%s:%d:", __func__, __LINE__ );
  320. kfree(max77888);
  321. return ret;
  322. }
  323. static int max77888_i2c_remove(struct i2c_client *i2c)
  324. {
  325. struct max77888_dev *max77888 = i2c_get_clientdata(i2c);
  326. mfd_remove_devices(max77888->dev);
  327. i2c_unregister_device(max77888->muic);
  328. i2c_unregister_device(max77888->haptic);
  329. kfree(max77888);
  330. return 0;
  331. }
  332. static const struct i2c_device_id max77888_i2c_id[] = {
  333. { "max77888", TYPE_MAX77888 },
  334. { }
  335. };
  336. MODULE_DEVICE_TABLE(i2c, max77888_i2c_id);
  337. static struct of_device_id max77888_i2c_match_table[] = {
  338. { .compatible = "max77888,i2c", },
  339. { },
  340. };
  341. MODULE_DEVICE_TABLE(of, max77888_i2c_match_table);
  342. #ifdef CONFIG_PM
  343. static int max77888_suspend(struct device *dev)
  344. {
  345. struct i2c_client *i2c = container_of(dev, struct i2c_client, dev);
  346. struct max77888_dev *max77888 = i2c_get_clientdata(i2c);
  347. if (device_may_wakeup(dev))
  348. enable_irq_wake(max77888->irq);
  349. return 0;
  350. }
  351. static int max77888_resume(struct device *dev)
  352. {
  353. struct i2c_client *i2c = container_of(dev, struct i2c_client, dev);
  354. struct max77888_dev *max77888 = i2c_get_clientdata(i2c);
  355. if (device_may_wakeup(dev))
  356. disable_irq_wake(max77888->irq);
  357. return max77888_irq_resume(max77888);
  358. }
  359. #else
  360. #define max77888_suspend NULL
  361. #define max77888_resume NULL
  362. #endif /* CONFIG_PM */
  363. #ifdef CONFIG_HIBERNATION
  364. u8 max77888_dumpaddr_pmic[] = {
  365. #ifdef CONFIG_MFD_MAX77888
  366. MAX77888_LED_REG_IFLASH,
  367. #else
  368. MAX77888_LED_REG_IFLASH1,
  369. MAX77888_LED_REG_IFLASH2,
  370. #endif
  371. MAX77888_LED_REG_ITORCH,
  372. MAX77888_LED_REG_ITORCHTORCHTIMER,
  373. MAX77888_LED_REG_FLASH_TIMER,
  374. MAX77888_LED_REG_FLASH_EN,
  375. MAX77888_LED_REG_MAX_FLASH1,
  376. MAX77888_LED_REG_MAX_FLASH2,
  377. MAX77888_LED_REG_VOUT_CNTL,
  378. #ifdef CONFIG_MFD_MAX77888
  379. MAX77888_LED_REG_VOUT_FLASH,
  380. #else
  381. MAX77888_LED_REG_VOUT_FLASH1,
  382. #endif
  383. MAX77888_LED_REG_FLASH_INT_STATUS,
  384. MAX77888_PMIC_REG_TOPSYS_INT_MASK,
  385. MAX77888_PMIC_REG_MAINCTRL1,
  386. MAX77888_PMIC_REG_LSCNFG,
  387. MAX77888_CHG_REG_CHG_INT_MASK,
  388. MAX77888_CHG_REG_CHG_CNFG_00,
  389. MAX77888_CHG_REG_CHG_CNFG_01,
  390. MAX77888_CHG_REG_CHG_CNFG_02,
  391. MAX77888_CHG_REG_CHG_CNFG_03,
  392. MAX77888_CHG_REG_CHG_CNFG_04,
  393. MAX77888_CHG_REG_CHG_CNFG_05,
  394. MAX77888_CHG_REG_CHG_CNFG_06,
  395. MAX77888_CHG_REG_CHG_CNFG_07,
  396. MAX77888_CHG_REG_CHG_CNFG_08,
  397. MAX77888_CHG_REG_CHG_CNFG_09,
  398. MAX77888_CHG_REG_CHG_CNFG_10,
  399. MAX77888_CHG_REG_CHG_CNFG_11,
  400. MAX77888_CHG_REG_CHG_CNFG_12,
  401. MAX77888_CHG_REG_CHG_CNFG_13,
  402. MAX77888_CHG_REG_CHG_CNFG_14,
  403. MAX77888_CHG_REG_SAFEOUT_CTRL,
  404. };
  405. u8 max77888_dumpaddr_muic[] = {
  406. MAX77888_MUIC_REG_INTMASK1,
  407. MAX77888_MUIC_REG_INTMASK2,
  408. MAX77888_MUIC_REG_INTMASK3,
  409. MAX77888_MUIC_REG_CDETCTRL1,
  410. MAX77888_MUIC_REG_CDETCTRL2,
  411. MAX77888_MUIC_REG_CTRL1,
  412. MAX77888_MUIC_REG_CTRL2,
  413. MAX77888_MUIC_REG_CTRL3,
  414. };
  415. u8 max77888_dumpaddr_haptic[] = {
  416. MAX77888_HAPTIC_REG_CONFIG1,
  417. MAX77888_HAPTIC_REG_CONFIG2,
  418. MAX77888_HAPTIC_REG_CONFIG_CHNL,
  419. MAX77888_HAPTIC_REG_CONFG_CYC1,
  420. MAX77888_HAPTIC_REG_CONFG_CYC2,
  421. MAX77888_HAPTIC_REG_CONFIG_PER1,
  422. MAX77888_HAPTIC_REG_CONFIG_PER2,
  423. MAX77888_HAPTIC_REG_CONFIG_PER3,
  424. MAX77888_HAPTIC_REG_CONFIG_PER4,
  425. MAX77888_HAPTIC_REG_CONFIG_DUTY1,
  426. MAX77888_HAPTIC_REG_CONFIG_DUTY2,
  427. MAX77888_HAPTIC_REG_CONFIG_PWM1,
  428. MAX77888_HAPTIC_REG_CONFIG_PWM2,
  429. MAX77888_HAPTIC_REG_CONFIG_PWM3,
  430. MAX77888_HAPTIC_REG_CONFIG_PWM4,
  431. };
  432. static int max77888_freeze(struct device *dev)
  433. {
  434. struct i2c_client *i2c = container_of(dev, struct i2c_client, dev);
  435. struct max77888_dev *max77888 = i2c_get_clientdata(i2c);
  436. int i;
  437. for (i = 0; i < ARRAY_SIZE(max77888_dumpaddr_pmic); i++)
  438. max77888_read_reg(i2c, max77888_dumpaddr_pmic[i],
  439. &max77888->reg_pmic_dump[i]);
  440. for (i = 0; i < ARRAY_SIZE(max77888_dumpaddr_muic); i++)
  441. max77888_read_reg(i2c, max77888_dumpaddr_muic[i],
  442. &max77888->reg_muic_dump[i]);
  443. for (i = 0; i < ARRAY_SIZE(max77888_dumpaddr_haptic); i++)
  444. max77888_read_reg(i2c, max77888_dumpaddr_haptic[i],
  445. &max77888->reg_haptic_dump[i]);
  446. disable_irq(max77888->irq);
  447. #ifdef CONFIG_MUIC_RESET_PIN_ENABLE
  448. if (muic_reset_pin)
  449. disable_irq(max77888->irq_reset);
  450. #endif
  451. return 0;
  452. }
  453. static int max77888_restore(struct device *dev)
  454. {
  455. struct i2c_client *i2c = container_of(dev, struct i2c_client, dev);
  456. struct max77888_dev *max77888 = i2c_get_clientdata(i2c);
  457. int i;
  458. enable_irq(max77888->irq);
  459. #ifdef CONFIG_MUIC_RESET_PIN_ENABLE
  460. if (muic_reset_pin)
  461. enable_irq(max77888->irq_reset);
  462. #endif
  463. for (i = 0; i < ARRAY_SIZE(max77888_dumpaddr_pmic); i++)
  464. max77888_write_reg(i2c, max77888_dumpaddr_pmic[i],
  465. max77888->reg_pmic_dump[i]);
  466. for (i = 0; i < ARRAY_SIZE(max77888_dumpaddr_muic); i++)
  467. max77888_write_reg(i2c, max77888_dumpaddr_muic[i],
  468. max77888->reg_muic_dump[i]);
  469. for (i = 0; i < ARRAY_SIZE(max77888_dumpaddr_haptic); i++)
  470. max77888_write_reg(i2c, max77888_dumpaddr_haptic[i],
  471. max77888->reg_haptic_dump[i]);
  472. return 0;
  473. }
  474. #endif
  475. const struct dev_pm_ops max77888_pm = {
  476. .suspend = max77888_suspend,
  477. .resume = max77888_resume,
  478. #ifdef CONFIG_HIBERNATION
  479. .freeze = max77888_freeze,
  480. .thaw = max77888_restore,
  481. .restore = max77888_restore,
  482. #endif
  483. };
  484. static struct i2c_driver max77888_i2c_driver = {
  485. .driver = {
  486. .name = "max77888",
  487. .owner = THIS_MODULE,
  488. .pm = &max77888_pm,
  489. .of_match_table = max77888_i2c_match_table,
  490. },
  491. .probe = max77888_i2c_probe,
  492. .remove = max77888_i2c_remove,
  493. .id_table = max77888_i2c_id,
  494. };
  495. static int __init max77888_i2c_init(void)
  496. {
  497. pr_info("%s: START\n", __func__);
  498. return i2c_add_driver(&max77888_i2c_driver);
  499. }
  500. /* init early so consumer devices can complete system boot */
  501. //subsys_initcall(max77888_i2c_init);
  502. module_init(max77888_i2c_init);
  503. static void __exit max77888_i2c_exit(void)
  504. {
  505. i2c_del_driver(&max77888_i2c_driver);
  506. }
  507. module_exit(max77888_i2c_exit);
  508. MODULE_DESCRIPTION("MAXIM 77888 multi-function core driver");
  509. MODULE_AUTHOR("SangYoung, Son <hello.son@samsung.com>");
  510. MODULE_LICENSE("GPL");