Paul Barker | da981cc | 2024-02-27 20:40:31 +0000 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright (C) 2023 Renesas Electronics Corporation |
| 4 | */ |
| 5 | |
| 6 | #include <dm.h> |
| 7 | #include <dm/device-internal.h> |
| 8 | #include <dm/lists.h> |
| 9 | #include <i2c.h> |
| 10 | #include <power/pmic.h> |
| 11 | |
| 12 | #define RAA215300_REG_COUNT 0x80 |
| 13 | |
| 14 | static int raa215300_reg_count(struct udevice *dev) |
| 15 | { |
| 16 | return RAA215300_REG_COUNT; |
| 17 | } |
| 18 | |
| 19 | static struct dm_pmic_ops raa215300_ops = { |
| 20 | .reg_count = raa215300_reg_count, |
| 21 | .read = dm_i2c_read, |
| 22 | .write = dm_i2c_write, |
| 23 | }; |
| 24 | |
| 25 | static const struct udevice_id raa215300_ids[] = { |
| 26 | { .compatible = "renesas,raa215300" }, |
| 27 | { /* sentinel */ } |
| 28 | }; |
| 29 | |
| 30 | static int raa215300_bind(struct udevice *dev) |
| 31 | { |
Paul Barker | 64703279 | 2024-02-27 20:40:34 +0000 | [diff] [blame] | 32 | if (IS_ENABLED(CONFIG_SYSRESET_RAA215300)) { |
| 33 | struct driver *drv = lists_driver_lookup_name("raa215300_sysreset"); |
| 34 | if (!drv) |
| 35 | return -ENOENT; |
| 36 | |
| 37 | return device_bind(dev, drv, dev->name, NULL, dev_ofnode(dev), |
| 38 | NULL); |
| 39 | } |
| 40 | |
Paul Barker | da981cc | 2024-02-27 20:40:31 +0000 | [diff] [blame] | 41 | return 0; |
| 42 | } |
| 43 | |
| 44 | U_BOOT_DRIVER(raa215300_pmic) = { |
| 45 | .name = "raa215300_pmic", |
| 46 | .id = UCLASS_PMIC, |
| 47 | .of_match = raa215300_ids, |
| 48 | .bind = raa215300_bind, |
| 49 | .ops = &raa215300_ops, |
| 50 | }; |