1 // SPDX-License-Identifier: GPL-2.0-only
3 * MFD core driver for Rockchip RK808/RK818
5 * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
7 * Author: Chris Zhong <zyw@rock-chips.com>
8 * Author: Zhang Qing <zhangqing@rock-chips.com>
10 * Copyright (C) 2016 PHYTEC Messtechnik GmbH
12 * Author: Wadim Egorov <w.egorov@phytec.de>
15 #include <linux/i2c.h>
16 #include <linux/interrupt.h>
17 #include <linux/mfd/rk808.h>
18 #include <linux/mfd/core.h>
19 #include <linux/module.h>
20 #include <linux/of_device.h>
21 #include <linux/regmap.h>
22 #include <linux/syscore_ops.h>
24 struct rk808_reg_data
{
30 static bool rk808_is_volatile_reg(struct device
*dev
, unsigned int reg
)
34 * - Technically the ROUND_30s bit makes RTC_CTRL_REG volatile, but
35 * we don't use that feature. It's better to cache.
36 * - It's unlikely we care that RK808_DEVCTRL_REG is volatile since
37 * bits are cleared in case when we shutoff anyway, but better safe.
41 case RK808_SECONDS_REG
... RK808_WEEKS_REG
:
42 case RK808_RTC_STATUS_REG
:
43 case RK808_VB_MON_REG
:
44 case RK808_THERMAL_REG
:
45 case RK808_DCDC_UV_STS_REG
:
46 case RK808_LDO_UV_STS_REG
:
47 case RK808_DCDC_PG_REG
:
48 case RK808_LDO_PG_REG
:
49 case RK808_DEVCTRL_REG
:
50 case RK808_INT_STS_REG1
:
51 case RK808_INT_STS_REG2
:
58 static bool rk817_is_volatile_reg(struct device
*dev
, unsigned int reg
)
62 * - Technically the ROUND_30s bit makes RTC_CTRL_REG volatile, but
63 * we don't use that feature. It's better to cache.
67 case RK817_SECONDS_REG
... RK817_WEEKS_REG
:
68 case RK817_RTC_STATUS_REG
:
69 case RK817_INT_STS_REG0
:
70 case RK817_INT_STS_REG1
:
71 case RK817_INT_STS_REG2
:
79 static const struct regmap_config rk818_regmap_config
= {
82 .max_register
= RK818_USB_CTRL_REG
,
83 .cache_type
= REGCACHE_RBTREE
,
84 .volatile_reg
= rk808_is_volatile_reg
,
87 static const struct regmap_config rk805_regmap_config
= {
90 .max_register
= RK805_OFF_SOURCE_REG
,
91 .cache_type
= REGCACHE_RBTREE
,
92 .volatile_reg
= rk808_is_volatile_reg
,
95 static const struct regmap_config rk808_regmap_config
= {
98 .max_register
= RK808_IO_POL_REG
,
99 .cache_type
= REGCACHE_RBTREE
,
100 .volatile_reg
= rk808_is_volatile_reg
,
103 static const struct regmap_config rk817_regmap_config
= {
106 .max_register
= RK817_GPIO_INT_CFG
,
107 .cache_type
= REGCACHE_NONE
,
108 .volatile_reg
= rk817_is_volatile_reg
,
111 static struct resource rtc_resources
[] = {
112 DEFINE_RES_IRQ(RK808_IRQ_RTC_ALARM
),
115 static struct resource rk817_rtc_resources
[] = {
116 DEFINE_RES_IRQ(RK817_IRQ_RTC_ALARM
),
119 static struct resource rk805_key_resources
[] = {
120 DEFINE_RES_IRQ(RK805_IRQ_PWRON_RISE
),
121 DEFINE_RES_IRQ(RK805_IRQ_PWRON_FALL
),
124 static struct resource rk817_pwrkey_resources
[] = {
125 DEFINE_RES_IRQ(RK817_IRQ_PWRON_RISE
),
126 DEFINE_RES_IRQ(RK817_IRQ_PWRON_FALL
),
129 static const struct mfd_cell rk805s
[] = {
130 { .name
= "rk808-clkout", },
131 { .name
= "rk808-regulator", },
132 { .name
= "rk805-pinctrl", },
135 .num_resources
= ARRAY_SIZE(rtc_resources
),
136 .resources
= &rtc_resources
[0],
138 { .name
= "rk805-pwrkey",
139 .num_resources
= ARRAY_SIZE(rk805_key_resources
),
140 .resources
= &rk805_key_resources
[0],
144 static const struct mfd_cell rk808s
[] = {
145 { .name
= "rk808-clkout", },
146 { .name
= "rk808-regulator", },
149 .num_resources
= ARRAY_SIZE(rtc_resources
),
150 .resources
= rtc_resources
,
154 static const struct mfd_cell rk817s
[] = {
155 { .name
= "rk808-clkout",},
156 { .name
= "rk808-regulator",},
158 .name
= "rk805-pwrkey",
159 .num_resources
= ARRAY_SIZE(rk817_pwrkey_resources
),
160 .resources
= &rk817_pwrkey_resources
[0],
164 .num_resources
= ARRAY_SIZE(rk817_rtc_resources
),
165 .resources
= &rk817_rtc_resources
[0],
169 static const struct mfd_cell rk818s
[] = {
170 { .name
= "rk808-clkout", },
171 { .name
= "rk808-regulator", },
174 .num_resources
= ARRAY_SIZE(rtc_resources
),
175 .resources
= rtc_resources
,
179 static const struct rk808_reg_data rk805_pre_init_reg
[] = {
180 {RK805_BUCK1_CONFIG_REG
, RK805_BUCK1_2_ILMAX_MASK
,
181 RK805_BUCK1_2_ILMAX_4000MA
},
182 {RK805_BUCK2_CONFIG_REG
, RK805_BUCK1_2_ILMAX_MASK
,
183 RK805_BUCK1_2_ILMAX_4000MA
},
184 {RK805_BUCK3_CONFIG_REG
, RK805_BUCK3_4_ILMAX_MASK
,
185 RK805_BUCK3_ILMAX_3000MA
},
186 {RK805_BUCK4_CONFIG_REG
, RK805_BUCK3_4_ILMAX_MASK
,
187 RK805_BUCK4_ILMAX_3500MA
},
188 {RK805_BUCK4_CONFIG_REG
, BUCK_ILMIN_MASK
, BUCK_ILMIN_400MA
},
189 {RK805_GPIO_IO_POL_REG
, SLP_SD_MSK
, SLEEP_FUN
},
190 {RK805_THERMAL_REG
, TEMP_HOTDIE_MSK
, TEMP115C
},
193 static const struct rk808_reg_data rk808_pre_init_reg
[] = {
194 { RK808_BUCK3_CONFIG_REG
, BUCK_ILMIN_MASK
, BUCK_ILMIN_150MA
},
195 { RK808_BUCK4_CONFIG_REG
, BUCK_ILMIN_MASK
, BUCK_ILMIN_200MA
},
196 { RK808_BOOST_CONFIG_REG
, BOOST_ILMIN_MASK
, BOOST_ILMIN_100MA
},
197 { RK808_BUCK1_CONFIG_REG
, BUCK1_RATE_MASK
, BUCK_ILMIN_200MA
},
198 { RK808_BUCK2_CONFIG_REG
, BUCK2_RATE_MASK
, BUCK_ILMIN_200MA
},
199 { RK808_DCDC_UV_ACT_REG
, BUCK_UV_ACT_MASK
, BUCK_UV_ACT_DISABLE
},
200 { RK808_VB_MON_REG
, MASK_ALL
, VB_LO_ACT
|
204 static const struct rk808_reg_data rk817_pre_init_reg
[] = {
205 {RK817_RTC_CTRL_REG
, RTC_STOP
, RTC_STOP
},
206 {RK817_GPIO_INT_CFG
, RK817_INT_POL_MSK
, RK817_INT_POL_L
},
207 {RK817_SYS_CFG(1), RK817_HOTDIE_TEMP_MSK
| RK817_TSD_TEMP_MSK
,
208 RK817_HOTDIE_105
| RK817_TSD_140
},
211 static const struct rk808_reg_data rk818_pre_init_reg
[] = {
212 /* improve efficiency */
213 { RK818_BUCK2_CONFIG_REG
, BUCK2_RATE_MASK
, BUCK_ILMIN_250MA
},
214 { RK818_BUCK4_CONFIG_REG
, BUCK_ILMIN_MASK
, BUCK_ILMIN_250MA
},
215 { RK818_BOOST_CONFIG_REG
, BOOST_ILMIN_MASK
, BOOST_ILMIN_100MA
},
216 { RK818_USB_CTRL_REG
, RK818_USB_ILIM_SEL_MASK
,
217 RK818_USB_ILMIN_2000MA
},
218 /* close charger when usb lower then 3.4V */
219 { RK818_USB_CTRL_REG
, RK818_USB_CHG_SD_VSEL_MASK
,
221 /* no action when vref */
222 { RK818_H5V_EN_REG
, BIT(1), RK818_REF_RDY_CTRL
},
224 { RK818_H5V_EN_REG
, BIT(0), RK818_H5V_EN
},
225 { RK808_VB_MON_REG
, MASK_ALL
, VB_LO_ACT
|
229 static const struct regmap_irq rk805_irqs
[] = {
230 [RK805_IRQ_PWRON_RISE
] = {
231 .mask
= RK805_IRQ_PWRON_RISE_MSK
,
234 [RK805_IRQ_VB_LOW
] = {
235 .mask
= RK805_IRQ_VB_LOW_MSK
,
238 [RK805_IRQ_PWRON
] = {
239 .mask
= RK805_IRQ_PWRON_MSK
,
242 [RK805_IRQ_PWRON_LP
] = {
243 .mask
= RK805_IRQ_PWRON_LP_MSK
,
246 [RK805_IRQ_HOTDIE
] = {
247 .mask
= RK805_IRQ_HOTDIE_MSK
,
250 [RK805_IRQ_RTC_ALARM
] = {
251 .mask
= RK805_IRQ_RTC_ALARM_MSK
,
254 [RK805_IRQ_RTC_PERIOD
] = {
255 .mask
= RK805_IRQ_RTC_PERIOD_MSK
,
258 [RK805_IRQ_PWRON_FALL
] = {
259 .mask
= RK805_IRQ_PWRON_FALL_MSK
,
264 static const struct regmap_irq rk808_irqs
[] = {
266 [RK808_IRQ_VOUT_LO
] = {
267 .mask
= RK808_IRQ_VOUT_LO_MSK
,
270 [RK808_IRQ_VB_LO
] = {
271 .mask
= RK808_IRQ_VB_LO_MSK
,
274 [RK808_IRQ_PWRON
] = {
275 .mask
= RK808_IRQ_PWRON_MSK
,
278 [RK808_IRQ_PWRON_LP
] = {
279 .mask
= RK808_IRQ_PWRON_LP_MSK
,
282 [RK808_IRQ_HOTDIE
] = {
283 .mask
= RK808_IRQ_HOTDIE_MSK
,
286 [RK808_IRQ_RTC_ALARM
] = {
287 .mask
= RK808_IRQ_RTC_ALARM_MSK
,
290 [RK808_IRQ_RTC_PERIOD
] = {
291 .mask
= RK808_IRQ_RTC_PERIOD_MSK
,
296 [RK808_IRQ_PLUG_IN_INT
] = {
297 .mask
= RK808_IRQ_PLUG_IN_INT_MSK
,
300 [RK808_IRQ_PLUG_OUT_INT
] = {
301 .mask
= RK808_IRQ_PLUG_OUT_INT_MSK
,
306 static const struct regmap_irq rk818_irqs
[] = {
308 [RK818_IRQ_VOUT_LO
] = {
309 .mask
= RK818_IRQ_VOUT_LO_MSK
,
312 [RK818_IRQ_VB_LO
] = {
313 .mask
= RK818_IRQ_VB_LO_MSK
,
316 [RK818_IRQ_PWRON
] = {
317 .mask
= RK818_IRQ_PWRON_MSK
,
320 [RK818_IRQ_PWRON_LP
] = {
321 .mask
= RK818_IRQ_PWRON_LP_MSK
,
324 [RK818_IRQ_HOTDIE
] = {
325 .mask
= RK818_IRQ_HOTDIE_MSK
,
328 [RK818_IRQ_RTC_ALARM
] = {
329 .mask
= RK818_IRQ_RTC_ALARM_MSK
,
332 [RK818_IRQ_RTC_PERIOD
] = {
333 .mask
= RK818_IRQ_RTC_PERIOD_MSK
,
336 [RK818_IRQ_USB_OV
] = {
337 .mask
= RK818_IRQ_USB_OV_MSK
,
342 [RK818_IRQ_PLUG_IN
] = {
343 .mask
= RK818_IRQ_PLUG_IN_MSK
,
346 [RK818_IRQ_PLUG_OUT
] = {
347 .mask
= RK818_IRQ_PLUG_OUT_MSK
,
350 [RK818_IRQ_CHG_OK
] = {
351 .mask
= RK818_IRQ_CHG_OK_MSK
,
354 [RK818_IRQ_CHG_TE
] = {
355 .mask
= RK818_IRQ_CHG_TE_MSK
,
358 [RK818_IRQ_CHG_TS1
] = {
359 .mask
= RK818_IRQ_CHG_TS1_MSK
,
363 .mask
= RK818_IRQ_TS2_MSK
,
366 [RK818_IRQ_CHG_CVTLIM
] = {
367 .mask
= RK818_IRQ_CHG_CVTLIM_MSK
,
370 [RK818_IRQ_DISCHG_ILIM
] = {
371 .mask
= RK818_IRQ_DISCHG_ILIM_MSK
,
376 static const struct regmap_irq rk817_irqs
[RK817_IRQ_END
] = {
377 REGMAP_IRQ_REG_LINE(0, 8),
378 REGMAP_IRQ_REG_LINE(1, 8),
379 REGMAP_IRQ_REG_LINE(2, 8),
380 REGMAP_IRQ_REG_LINE(3, 8),
381 REGMAP_IRQ_REG_LINE(4, 8),
382 REGMAP_IRQ_REG_LINE(5, 8),
383 REGMAP_IRQ_REG_LINE(6, 8),
384 REGMAP_IRQ_REG_LINE(7, 8),
385 REGMAP_IRQ_REG_LINE(8, 8),
386 REGMAP_IRQ_REG_LINE(9, 8),
387 REGMAP_IRQ_REG_LINE(10, 8),
388 REGMAP_IRQ_REG_LINE(11, 8),
389 REGMAP_IRQ_REG_LINE(12, 8),
390 REGMAP_IRQ_REG_LINE(13, 8),
391 REGMAP_IRQ_REG_LINE(14, 8),
392 REGMAP_IRQ_REG_LINE(15, 8),
393 REGMAP_IRQ_REG_LINE(16, 8),
394 REGMAP_IRQ_REG_LINE(17, 8),
395 REGMAP_IRQ_REG_LINE(18, 8),
396 REGMAP_IRQ_REG_LINE(19, 8),
397 REGMAP_IRQ_REG_LINE(20, 8),
398 REGMAP_IRQ_REG_LINE(21, 8),
399 REGMAP_IRQ_REG_LINE(22, 8),
400 REGMAP_IRQ_REG_LINE(23, 8)
403 static struct regmap_irq_chip rk805_irq_chip
= {
406 .num_irqs
= ARRAY_SIZE(rk805_irqs
),
408 .status_base
= RK805_INT_STS_REG
,
409 .mask_base
= RK805_INT_STS_MSK_REG
,
410 .ack_base
= RK805_INT_STS_REG
,
411 .init_ack_masked
= true,
414 static const struct regmap_irq_chip rk808_irq_chip
= {
417 .num_irqs
= ARRAY_SIZE(rk808_irqs
),
420 .status_base
= RK808_INT_STS_REG1
,
421 .mask_base
= RK808_INT_STS_MSK_REG1
,
422 .ack_base
= RK808_INT_STS_REG1
,
423 .init_ack_masked
= true,
426 static struct regmap_irq_chip rk817_irq_chip
= {
429 .num_irqs
= ARRAY_SIZE(rk817_irqs
),
432 .status_base
= RK817_INT_STS_REG0
,
433 .mask_base
= RK817_INT_STS_MSK_REG0
,
434 .ack_base
= RK817_INT_STS_REG0
,
435 .init_ack_masked
= true,
438 static const struct regmap_irq_chip rk818_irq_chip
= {
441 .num_irqs
= ARRAY_SIZE(rk818_irqs
),
444 .status_base
= RK818_INT_STS_REG1
,
445 .mask_base
= RK818_INT_STS_MSK_REG1
,
446 .ack_base
= RK818_INT_STS_REG1
,
447 .init_ack_masked
= true,
450 static struct i2c_client
*rk808_i2c_client
;
452 static void rk805_device_shutdown(void)
455 struct rk808
*rk808
= i2c_get_clientdata(rk808_i2c_client
);
460 ret
= regmap_update_bits(rk808
->regmap
,
464 dev_err(&rk808_i2c_client
->dev
, "Failed to shutdown device!\n");
467 static void rk805_device_shutdown_prepare(void)
470 struct rk808
*rk808
= i2c_get_clientdata(rk808_i2c_client
);
475 ret
= regmap_update_bits(rk808
->regmap
,
476 RK805_GPIO_IO_POL_REG
,
477 SLP_SD_MSK
, SHUTDOWN_FUN
);
479 dev_err(&rk808_i2c_client
->dev
, "Failed to shutdown device!\n");
482 static void rk808_device_shutdown(void)
485 struct rk808
*rk808
= i2c_get_clientdata(rk808_i2c_client
);
490 ret
= regmap_update_bits(rk808
->regmap
,
492 DEV_OFF_RST
, DEV_OFF_RST
);
494 dev_err(&rk808_i2c_client
->dev
, "Failed to shutdown device!\n");
497 static void rk818_device_shutdown(void)
500 struct rk808
*rk808
= i2c_get_clientdata(rk808_i2c_client
);
505 ret
= regmap_update_bits(rk808
->regmap
,
509 dev_err(&rk808_i2c_client
->dev
, "Failed to shutdown device!\n");
512 static void rk8xx_syscore_shutdown(void)
514 struct rk808
*rk808
= i2c_get_clientdata(rk808_i2c_client
);
517 if (system_state
== SYSTEM_POWER_OFF
&&
518 (rk808
->variant
== RK809_ID
|| rk808
->variant
== RK817_ID
)) {
519 ret
= regmap_update_bits(rk808
->regmap
,
521 RK817_SLPPIN_FUNC_MSK
,
524 dev_warn(&rk808_i2c_client
->dev
,
525 "Cannot switch to power down function\n");
530 static struct syscore_ops rk808_syscore_ops
= {
531 .shutdown
= rk8xx_syscore_shutdown
,
534 static const struct of_device_id rk808_of_match
[] = {
535 { .compatible
= "rockchip,rk805" },
536 { .compatible
= "rockchip,rk808" },
537 { .compatible
= "rockchip,rk809" },
538 { .compatible
= "rockchip,rk817" },
539 { .compatible
= "rockchip,rk818" },
542 MODULE_DEVICE_TABLE(of
, rk808_of_match
);
544 static int rk808_probe(struct i2c_client
*client
,
545 const struct i2c_device_id
*id
)
547 struct device_node
*np
= client
->dev
.of_node
;
549 const struct rk808_reg_data
*pre_init_reg
;
550 const struct mfd_cell
*cells
;
551 int nr_pre_init_regs
;
553 int pm_off
= 0, msb
, lsb
;
554 unsigned char pmic_id_msb
, pmic_id_lsb
;
558 rk808
= devm_kzalloc(&client
->dev
, sizeof(*rk808
), GFP_KERNEL
);
562 if (of_device_is_compatible(np
, "rockchip,rk817") ||
563 of_device_is_compatible(np
, "rockchip,rk809")) {
564 pmic_id_msb
= RK817_ID_MSB
;
565 pmic_id_lsb
= RK817_ID_LSB
;
567 pmic_id_msb
= RK808_ID_MSB
;
568 pmic_id_lsb
= RK808_ID_LSB
;
571 /* Read chip variant */
572 msb
= i2c_smbus_read_byte_data(client
, pmic_id_msb
);
574 dev_err(&client
->dev
, "failed to read the chip id at 0x%x\n",
579 lsb
= i2c_smbus_read_byte_data(client
, pmic_id_lsb
);
581 dev_err(&client
->dev
, "failed to read the chip id at 0x%x\n",
586 rk808
->variant
= ((msb
<< 8) | lsb
) & RK8XX_ID_MSK
;
587 dev_info(&client
->dev
, "chip id: 0x%x\n", (unsigned int)rk808
->variant
);
589 switch (rk808
->variant
) {
591 rk808
->regmap_cfg
= &rk805_regmap_config
;
592 rk808
->regmap_irq_chip
= &rk805_irq_chip
;
593 pre_init_reg
= rk805_pre_init_reg
;
594 nr_pre_init_regs
= ARRAY_SIZE(rk805_pre_init_reg
);
596 nr_cells
= ARRAY_SIZE(rk805s
);
597 rk808
->pm_pwroff_fn
= rk805_device_shutdown
;
598 rk808
->pm_pwroff_prep_fn
= rk805_device_shutdown_prepare
;
601 rk808
->regmap_cfg
= &rk808_regmap_config
;
602 rk808
->regmap_irq_chip
= &rk808_irq_chip
;
603 pre_init_reg
= rk808_pre_init_reg
;
604 nr_pre_init_regs
= ARRAY_SIZE(rk808_pre_init_reg
);
606 nr_cells
= ARRAY_SIZE(rk808s
);
607 rk808
->pm_pwroff_fn
= rk808_device_shutdown
;
610 rk808
->regmap_cfg
= &rk818_regmap_config
;
611 rk808
->regmap_irq_chip
= &rk818_irq_chip
;
612 pre_init_reg
= rk818_pre_init_reg
;
613 nr_pre_init_regs
= ARRAY_SIZE(rk818_pre_init_reg
);
615 nr_cells
= ARRAY_SIZE(rk818s
);
616 rk808
->pm_pwroff_fn
= rk818_device_shutdown
;
620 rk808
->regmap_cfg
= &rk817_regmap_config
;
621 rk808
->regmap_irq_chip
= &rk817_irq_chip
;
622 pre_init_reg
= rk817_pre_init_reg
;
623 nr_pre_init_regs
= ARRAY_SIZE(rk817_pre_init_reg
);
625 nr_cells
= ARRAY_SIZE(rk817s
);
626 register_syscore_ops(&rk808_syscore_ops
);
629 dev_err(&client
->dev
, "Unsupported RK8XX ID %lu\n",
635 i2c_set_clientdata(client
, rk808
);
637 rk808
->regmap
= devm_regmap_init_i2c(client
, rk808
->regmap_cfg
);
638 if (IS_ERR(rk808
->regmap
)) {
639 dev_err(&client
->dev
, "regmap initialization failed\n");
640 return PTR_ERR(rk808
->regmap
);
644 dev_err(&client
->dev
, "No interrupt support, no core IRQ\n");
648 ret
= regmap_add_irq_chip(rk808
->regmap
, client
->irq
,
650 rk808
->regmap_irq_chip
, &rk808
->irq_data
);
652 dev_err(&client
->dev
, "Failed to add irq_chip %d\n", ret
);
656 for (i
= 0; i
< nr_pre_init_regs
; i
++) {
657 ret
= regmap_update_bits(rk808
->regmap
,
658 pre_init_reg
[i
].addr
,
659 pre_init_reg
[i
].mask
,
660 pre_init_reg
[i
].value
);
662 dev_err(&client
->dev
,
664 pre_init_reg
[i
].addr
);
669 ret
= devm_mfd_add_devices(&client
->dev
, PLATFORM_DEVID_NONE
,
670 cells
, nr_cells
, NULL
, 0,
671 regmap_irq_get_domain(rk808
->irq_data
));
673 dev_err(&client
->dev
, "failed to add MFD devices %d\n", ret
);
677 pm_off
= of_property_read_bool(np
,
678 "rockchip,system-power-controller");
679 if (pm_off
&& !pm_power_off
) {
680 rk808_i2c_client
= client
;
681 pm_power_off
= rk808
->pm_pwroff_fn
;
684 if (pm_off
&& !pm_power_off_prepare
) {
685 if (!rk808_i2c_client
)
686 rk808_i2c_client
= client
;
687 pm_power_off_prepare
= rk808
->pm_pwroff_prep_fn
;
693 regmap_del_irq_chip(client
->irq
, rk808
->irq_data
);
697 static int rk808_remove(struct i2c_client
*client
)
699 struct rk808
*rk808
= i2c_get_clientdata(client
);
701 regmap_del_irq_chip(client
->irq
, rk808
->irq_data
);
704 * pm_power_off may points to a function from another module.
705 * Check if the pointer is set by us and only then overwrite it.
707 if (rk808
->pm_pwroff_fn
&& pm_power_off
== rk808
->pm_pwroff_fn
)
711 * As above, check if the pointer is set by us before overwrite.
713 if (rk808
->pm_pwroff_prep_fn
&&
714 pm_power_off_prepare
== rk808
->pm_pwroff_prep_fn
)
715 pm_power_off_prepare
= NULL
;
720 static int __maybe_unused
rk8xx_suspend(struct device
*dev
)
722 struct rk808
*rk808
= i2c_get_clientdata(rk808_i2c_client
);
725 switch (rk808
->variant
) {
728 ret
= regmap_update_bits(rk808
->regmap
,
730 RK817_SLPPIN_FUNC_MSK
,
740 static int __maybe_unused
rk8xx_resume(struct device
*dev
)
742 struct rk808
*rk808
= i2c_get_clientdata(rk808_i2c_client
);
745 switch (rk808
->variant
) {
748 ret
= regmap_update_bits(rk808
->regmap
,
750 RK817_SLPPIN_FUNC_MSK
,
759 static SIMPLE_DEV_PM_OPS(rk8xx_pm_ops
, rk8xx_suspend
, rk8xx_resume
);
761 static struct i2c_driver rk808_i2c_driver
= {
764 .of_match_table
= rk808_of_match
,
767 .probe
= rk808_probe
,
768 .remove
= rk808_remove
,
771 module_i2c_driver(rk808_i2c_driver
);
773 MODULE_LICENSE("GPL");
774 MODULE_AUTHOR("Chris Zhong <zyw@rock-chips.com>");
775 MODULE_AUTHOR("Zhang Qing <zhangqing@rock-chips.com>");
776 MODULE_AUTHOR("Wadim Egorov <w.egorov@phytec.de>");
777 MODULE_DESCRIPTION("RK808/RK818 PMIC driver");