blob: 001e69553e8a5c589cd918d9c0dc882dd03d9eee [file] [log] [blame]
Stefan Agnerc571d682016-10-05 15:27:09 -07001/*
2 * Copyright (C) 2016 Toradex AG
3 * Stefan Agner <stefan.agner@toradex.com>
4 *
5 * SPDX-License-Identifier: GPL-2.0+
6 */
7
8#include <common.h>
9#include <dm.h>
10#include <errno.h>
11#include <fdtdec.h>
12#include <libfdt.h>
13#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) {
28 debug("write error to device: %p register: %#x!", dev, reg);
29 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) {
41 debug("read error from device: %p register: %#x!", dev, reg);
42 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" },
56 { }
57};
58
59U_BOOT_DRIVER(pmic_rn5t567) = {
60 .name = "rn5t567 pmic",
61 .id = UCLASS_PMIC,
62 .of_match = rn5t567_ids,
63 .ops = &rn5t567_ops,
64};