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 newval = (value & r->mask) | r->val;
42 if (value != newval) {
43 printf("Changing PMIC reg %02x from %02x to %02x\n",
44 r->addr, value, newval);
47 ret = i2c_write(slave_addr, r->addr, 1, &newval, 1);
49 printf("%s: failed to write PMIC register %02x: %d\n",
50 __func__, r->addr, ret);
54 ret = i2c_read(slave_addr, r->addr, 1, &value, 1);
56 printf("%s: failed to read PMIC register %02x: %d\n",
57 __func__, r->addr, ret);
60 if (value != newval) {
61 printf("Failed to set PMIC reg %02x to %02x; actual value: %02x\n",
62 r->addr, newval, value);
69 int rn5t567_pmic_setup(uchar slave_addr, struct pmic_regs *regs,
75 ret = i2c_read(slave_addr, 0x11, 1, &value, 1);
77 printf("%s: i2c_read error: %d\n", __func__, ret);
81 ret = rn5t567_setup_regs(slave_addr, regs, count);
85 ret = i2c_read(slave_addr, RN5T567_DC1DAC, 1, &value, 1);
87 printf("VDDCORE set to %umV\n", rn5t_regval_to_mV(value));
89 printf("Failed to read VDDCORE register setting\n");
91 #ifndef CONFIG_SOC_MX6UL
92 ret = i2c_read(slave_addr, RN5T567_DC2DAC, 1, &value, 1);
94 printf("VDDSOC set to %umV\n", rn5t_regval_to_mV(value));
96 printf("Failed to read VDDSOC register setting\n");