2 * Copyright (C) 2011 Samsung Electronics
3 * Lukasz Majewski <l.majewski@samsung.com>
6 * Stefano Babic, DENX Software Engineering, sbabic@denx.de
8 * (C) Copyright 2008-2009 Freescale Semiconductor, Inc.
10 * See file CREDITS for list of people who contributed to this
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License as
15 * published by the Free Software Foundation; either version 2 of
16 * the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
30 #include <linux/types.h>
34 int pmic_reg_write(struct pmic *p, u32 reg, u32 val)
36 unsigned char buf[4] = { 0 };
41 switch (pmic_i2c_tx_num) {
43 buf[0] = (val >> 16) & 0xff;
44 buf[1] = (val >> 8) & 0xff;
52 if (i2c_write(pmic_i2c_addr, reg, 1, buf, pmic_i2c_tx_num))
58 int pmic_reg_read(struct pmic *p, u32 reg, u32 *val)
60 unsigned char buf[4] = { 0 };
66 if (i2c_read(pmic_i2c_addr, reg, 1, buf, pmic_i2c_tx_num))
69 switch (pmic_i2c_tx_num) {
71 ret_val = buf[0] << 16 | buf[1] << 8 | buf[2];
77 memcpy(val, &ret_val, sizeof(ret_val));
82 int pmic_probe(struct pmic *p)
84 i2c_set_bus_num(p->bus);
85 debug("PMIC:%s probed!\n", p->name);
86 if (i2c_probe(pmic_i2c_addr)) {
87 printf("Can't find PMIC:%s\n", p->name);