Stefano Babic | 6379513 | 2011-01-19 22:46:29 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2010 Stefano Babic <sbabic@denx.de> |
| 3 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
Stefano Babic | 6379513 | 2011-01-19 22:46:29 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | |
| 8 | #include <config.h> |
| 9 | #include <common.h> |
| 10 | #include <asm/errno.h> |
| 11 | #include <linux/types.h> |
| 12 | #include <i2c.h> |
| 13 | #include <mc9sdz60.h> |
| 14 | |
| 15 | #ifndef CONFIG_SYS_FSL_MC9SDZ60_I2C_ADDR |
| 16 | #error "You have to configure I2C address for MC9SDZ60" |
| 17 | #endif |
| 18 | |
| 19 | |
| 20 | u8 mc9sdz60_reg_read(enum mc9sdz60_reg reg) |
| 21 | { |
| 22 | u8 val; |
| 23 | |
| 24 | if (i2c_read(CONFIG_SYS_FSL_MC9SDZ60_I2C_ADDR, reg, 1, &val, 1)) { |
| 25 | puts("Error reading MC9SDZ60 register\n"); |
| 26 | return -1; |
| 27 | } |
| 28 | |
| 29 | return val; |
| 30 | } |
| 31 | |
| 32 | void mc9sdz60_reg_write(enum mc9sdz60_reg reg, u8 val) |
| 33 | { |
| 34 | i2c_write(CONFIG_SYS_FSL_MC9SDZ60_I2C_ADDR, reg, 1, &val, 1); |
| 35 | } |