xref: /openbmc/u-boot/drivers/misc/mc9sdz60.c (revision f77d4410)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * (C) Copyright 2010 Stefano Babic <sbabic@denx.de>
4  */
5 
6 
7 #include <config.h>
8 #include <common.h>
9 #include <linux/errno.h>
10 #include <linux/types.h>
11 #include <i2c.h>
12 #include <mc9sdz60.h>
13 
14 #ifndef CONFIG_SYS_FSL_MC9SDZ60_I2C_ADDR
15 #error "You have to configure I2C address for MC9SDZ60"
16 #endif
17 
18 
19 u8 mc9sdz60_reg_read(enum mc9sdz60_reg reg)
20 {
21 	u8 val;
22 
23 	if (i2c_read(CONFIG_SYS_FSL_MC9SDZ60_I2C_ADDR, reg, 1, &val, 1)) {
24 		puts("Error reading MC9SDZ60 register\n");
25 		return -1;
26 	}
27 
28 	return val;
29 }
30 
31 void mc9sdz60_reg_write(enum mc9sdz60_reg reg, u8 val)
32 {
33 	i2c_write(CONFIG_SYS_FSL_MC9SDZ60_I2C_ADDR, reg, 1, &val, 1);
34 }
35