2 * Copyright (C) 2014 Lothar Waßmann <LW@KARO-electronics.de>
4 * See file CREDITS for list of people who contributed to this
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * version 2 as published by the Free Software Foundation.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
21 #include "../common/karo.h"
24 static int rn5t567_setup_regs(uchar slave_addr, struct pmic_regs *r,
30 for (i = 0; i < count; i++, r++) {
34 ret = i2c_read(slave_addr, r->addr, 1, &value, 1);
36 printf("%s: failed to read PMIC register %02x: %d\n",
37 __func__, r->addr, ret);
40 if ((value & ~r->mask) != r->val) {
41 printf("Changing PMIC reg %02x from %02x to %02x\n",
42 r->addr, value, r->val);
45 ret = i2c_write(slave_addr, r->addr, 1, &r->val, 1);
47 printf("%s: failed to write PMIC register %02x: %d\n",
48 __func__, r->addr, ret);
52 ret = i2c_read(slave_addr, r->addr, 1, &value, 1);
54 printf("%s: failed to read PMIC register %02x: %d\n",
55 __func__, r->addr, ret);
58 if (value != r->val) {
59 printf("Failed to set PMIC reg %02x to %02x; actual value: %02x\n",
60 r->addr, r->val, value);
67 int rn5t567_pmic_setup(uchar slave_addr, struct pmic_regs *regs,
73 ret = i2c_read(slave_addr, 0x11, 1, &value, 1);
75 printf("%s: i2c_read error: %d\n", __func__, ret);
79 ret = rn5t567_setup_regs(slave_addr, regs, count);
83 ret = i2c_read(slave_addr, RN5T567_DC1DAC, 1, &value, 1);
85 printf("VDDCORE set to %umV\n", rn5t_regval_to_mV(value));
87 printf("Failed to read VDDCORE register setting\n");
89 #ifndef CONFIG_SOC_MX6UL
90 ret = i2c_read(slave_addr, RN5T567_DC2DAC, 1, &value, 1);
92 printf("VDDSOC set to %umV\n", rn5t_regval_to_mV(value));
94 printf("Failed to read VDDSOC register setting\n");