xref: /openbmc/u-boot/drivers/misc/mc9sdz60.c (revision 0cb77bfa)
1 /*
2  * (C) Copyright 2010 Stefano Babic <sbabic@denx.de>
3  *
4  * See file CREDITS for list of people who contributed to this
5  * project.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License as
9  * published by the Free Software Foundation; either version 2 of
10  * the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20  * MA 02111-1307 USA
21  */
22 
23 
24 #include <config.h>
25 #include <common.h>
26 #include <asm/errno.h>
27 #include <linux/types.h>
28 #include <i2c.h>
29 #include <mc9sdz60.h>
30 
31 #ifndef CONFIG_SYS_FSL_MC9SDZ60_I2C_ADDR
32 #error "You have to configure I2C address for MC9SDZ60"
33 #endif
34 
35 
36 u8 mc9sdz60_reg_read(enum mc9sdz60_reg reg)
37 {
38 	u8 val;
39 
40 	if (i2c_read(CONFIG_SYS_FSL_MC9SDZ60_I2C_ADDR, reg, 1, &val, 1)) {
41 		puts("Error reading MC9SDZ60 register\n");
42 		return -1;
43 	}
44 
45 	return val;
46 }
47 
48 void mc9sdz60_reg_write(enum mc9sdz60_reg reg, u8 val)
49 {
50 	i2c_write(CONFIG_SYS_FSL_MC9SDZ60_I2C_ADDR, reg, 1, &val, 1);
51 }
52