blob: 9d103dd840578bcf549be799a5024f3b3f33c684 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Stefan Agnerb084ddd2016-10-05 15:27:09 -07002/*
3 * Copyright (C) 2016 Toradex AG
4 * Stefan Agner <stefan.agner@toradex.com>
Stefan Agnerb084ddd2016-10-05 15:27:09 -07005 */
6
7#include <common.h>
8#include <dm.h>
9#include <errno.h>
10#include <fdtdec.h>
Simon Glass0f2af882020-05-10 11:40:05 -060011#include <log.h>
Masahiro Yamada75f82d02018-03-05 01:20:11 +090012#include <linux/libfdt.h>
Stefan Agnerb084ddd2016-10-05 15:27:09 -070013#include <power/rn5t567_pmic.h>
14#include <power/pmic.h>
15
16static int rn5t567_reg_count(struct udevice *dev)
17{
18 return RN5T567_NUM_OF_REGS;
19}
20
21static int rn5t567_write(struct udevice *dev, uint reg, const uint8_t *buff,
22 int len)
23{
24 int ret;
25
26 ret = dm_i2c_write(dev, reg, buff, len);
27 if (ret) {
Simon Glass73126ac2018-11-18 08:14:28 -070028 debug("write error to device: %p register: %#x!\n", dev, reg);
Stefan Agnerb084ddd2016-10-05 15:27:09 -070029 return ret;
30 }
31
32 return 0;
33}
34
35static int rn5t567_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
36{
37 int ret;
38
39 ret = dm_i2c_read(dev, reg, buff, len);
40 if (ret) {
Simon Glass73126ac2018-11-18 08:14:28 -070041 debug("read error from device: %p register: %#x!\n", dev, reg);
Stefan Agnerb084ddd2016-10-05 15:27:09 -070042 return ret;
43 }
44
45 return 0;
46}
47
48static struct dm_pmic_ops rn5t567_ops = {
49 .reg_count = rn5t567_reg_count,
50 .read = rn5t567_read,
51 .write = rn5t567_write,
52};
53
54static const struct udevice_id rn5t567_ids[] = {
55 { .compatible = "ricoh,rn5t567" },
Martyn Welche32d0362022-10-25 10:55:00 +010056 { .compatible = "ricoh,rn5t568" },
Stefan Agnerb084ddd2016-10-05 15:27:09 -070057 { }
58};
59
60U_BOOT_DRIVER(pmic_rn5t567) = {
61 .name = "rn5t567 pmic",
62 .id = UCLASS_PMIC,
63 .of_match = rn5t567_ids,
64 .ops = &rn5t567_ops,
65};