Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Stefano Babic | 01bb24b | 2011-01-19 22:46:29 +0000 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2010 Stefano Babic <sbabic@denx.de> |
Stefano Babic | 01bb24b | 2011-01-19 22:46:29 +0000 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | |
| 7 | #include <config.h> |
| 8 | #include <common.h> |
Masahiro Yamada | 1221ce4 | 2016-09-21 11:28:55 +0900 | [diff] [blame] | 9 | #include <linux/errno.h> |
Stefano Babic | 01bb24b | 2011-01-19 22:46:29 +0000 | [diff] [blame] | 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 | } |