|
19 | 19 | #include <linux/module.h>
|
20 | 20 | #include <linux/of_device.h>
|
21 | 21 | #include <linux/regmap.h>
|
22 |
| -#include <linux/syscore_ops.h> |
23 | 22 |
|
24 | 23 | struct rk808_reg_data {
|
25 | 24 | int addr;
|
@@ -509,28 +508,27 @@ static void rk818_device_shutdown(void)
|
509 | 508 | dev_err(&rk808_i2c_client->dev, "Failed to shutdown device!\n");
|
510 | 509 | }
|
511 | 510 |
|
512 |
| -static void rk8xx_syscore_shutdown(void) |
| 511 | +static void rk8xx_shutdown(struct i2c_client *client) |
513 | 512 | {
|
514 |
| - struct rk808 *rk808 = i2c_get_clientdata(rk808_i2c_client); |
| 513 | + struct rk808 *rk808 = i2c_get_clientdata(client); |
515 | 514 | int ret;
|
516 | 515 |
|
517 |
| - if (system_state == SYSTEM_POWER_OFF && |
518 |
| - (rk808->variant == RK809_ID || rk808->variant == RK817_ID)) { |
| 516 | + switch (rk808->variant) { |
| 517 | + case RK809_ID: |
| 518 | + case RK817_ID: |
519 | 519 | ret = regmap_update_bits(rk808->regmap,
|
520 | 520 | RK817_SYS_CFG(3),
|
521 | 521 | RK817_SLPPIN_FUNC_MSK,
|
522 | 522 | SLPPIN_DN_FUN);
|
523 |
| - if (ret) { |
524 |
| - dev_warn(&rk808_i2c_client->dev, |
525 |
| - "Cannot switch to power down function\n"); |
526 |
| - } |
| 523 | + break; |
| 524 | + default: |
| 525 | + return; |
527 | 526 | }
|
| 527 | + if (ret) |
| 528 | + dev_warn(&client->dev, |
| 529 | + "Cannot switch to power down function\n"); |
528 | 530 | }
|
529 | 531 |
|
530 |
| -static struct syscore_ops rk808_syscore_ops = { |
531 |
| - .shutdown = rk8xx_syscore_shutdown, |
532 |
| -}; |
533 |
| - |
534 | 532 | static const struct of_device_id rk808_of_match[] = {
|
535 | 533 | { .compatible = "rockchip,rk805" },
|
536 | 534 | { .compatible = "rockchip,rk808" },
|
@@ -623,7 +621,6 @@ static int rk808_probe(struct i2c_client *client,
|
623 | 621 | nr_pre_init_regs = ARRAY_SIZE(rk817_pre_init_reg);
|
624 | 622 | cells = rk817s;
|
625 | 623 | nr_cells = ARRAY_SIZE(rk817s);
|
626 |
| - register_syscore_ops(&rk808_syscore_ops); |
627 | 624 | break;
|
628 | 625 | default:
|
629 | 626 | dev_err(&client->dev, "Unsupported RK8XX ID %lu\n",
|
@@ -759,6 +756,7 @@ static struct i2c_driver rk808_i2c_driver = {
|
759 | 756 | },
|
760 | 757 | .probe = rk808_probe,
|
761 | 758 | .remove = rk808_remove,
|
| 759 | + .shutdown = rk8xx_shutdown, |
762 | 760 | };
|
763 | 761 |
|
764 | 762 | module_i2c_driver(rk808_i2c_driver);
|
|
0 commit comments