blob: f238396d368301365b0646e8dfae2faeb2060f79 [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>
Masahiro Yamada75f82d02018-03-05 01:20:11 +090011#include <linux/libfdt.h>
Stefan Agnerb084ddd2016-10-05 15:27:09 -070012#include <power/rn5t567_pmic.h>
13#include <power/pmic.h>
14
15static int rn5t567_reg_count(struct udevice *dev)
16{
17 return RN5T567_NUM_OF_REGS;
18}
19
20static int rn5t567_write(struct udevice *dev, uint reg, const uint8_t *buff,
21 int len)
22{
23 int ret;
24
25 ret = dm_i2c_write(dev, reg, buff, len);
26 if (ret) {
Simon Glass73126ac2018-11-18 08:14:28 -070027 debug("write error to device: %p register: %#x!\n", dev, reg);
Stefan Agnerb084ddd2016-10-05 15:27:09 -070028 return ret;
29 }
30
31 return 0;
32}
33
34static int rn5t567_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
35{
36 int ret;
37
38 ret = dm_i2c_read(dev, reg, buff, len);
39 if (ret) {
Simon Glass73126ac2018-11-18 08:14:28 -070040 debug("read error from device: %p register: %#x!\n", dev, reg);
Stefan Agnerb084ddd2016-10-05 15:27:09 -070041 return ret;
42 }
43
44 return 0;
45}
46
47static struct dm_pmic_ops rn5t567_ops = {
48 .reg_count = rn5t567_reg_count,
49 .read = rn5t567_read,
50 .write = rn5t567_write,
51};
52
53static const struct udevice_id rn5t567_ids[] = {
54 { .compatible = "ricoh,rn5t567" },
55 { }
56};
57
58U_BOOT_DRIVER(pmic_rn5t567) = {
59 .name = "rn5t567 pmic",
60 .id = UCLASS_PMIC,
61 .of_match = rn5t567_ids,
62 .ops = &rn5t567_ops,
63};