blob: e68a056a559d1f5f9277f0e908d3a8fa2f0d4f69 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Stefano Babic01bb24b2011-01-19 22:46:29 +00002/*
3 * (C) Copyright 2010 Stefano Babic <sbabic@denx.de>
Stefano Babic01bb24b2011-01-19 22:46:29 +00004 */
5
6
7#include <config.h>
8#include <common.h>
Masahiro Yamada1221ce42016-09-21 11:28:55 +09009#include <linux/errno.h>
Stefano Babic01bb24b2011-01-19 22:46:29 +000010#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
19u8 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
31void mc9sdz60_reg_write(enum mc9sdz60_reg reg, u8 val)
32{
33 i2c_write(CONFIG_SYS_FSL_MC9SDZ60_I2C_ADDR, reg, 1, &val, 1);
34}