diff options
author | Nick Sanders <nsanders@chromium.org> | 2016-08-11 16:28:03 -0700 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2016-08-21 04:11:10 -0700 |
commit | cc68693cda0d520229971b73c116d434c48bdd65 (patch) | |
tree | 29978c73b634ae6ebd505a361c96de9c697db083 /board/sweetberry | |
parent | 153c2cf49c6c225508e09a942eb90611c9d3cef9 (diff) | |
download | chrome-ec-cc68693cda0d520229971b73c116d434c48bdd65.tar.gz |
sweetberry: add i2c support
stm32f446 has two types of i2c blocks, the traditional
stm i2c, and "fast mode plus" i2c, which need different drivers.
This commit adds both, muxed in i2c-stm32f4, as the ec
codebase doesn't really support multiple types of the same interface.
BUG=chromium:608039
TEST=i2c works on all 4 channels
BRANCH=None
Change-Id: I6a9ac632f44142bd809ffee5782a192ae47af1f0
Signed-off-by: Nick Sanders <nsanders@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/368358
Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'board/sweetberry')
-rw-r--r-- | board/sweetberry/board.c | 21 | ||||
-rw-r--r-- | board/sweetberry/board.h | 7 |
2 files changed, 28 insertions, 0 deletions
diff --git a/board/sweetberry/board.c b/board/sweetberry/board.c index 902917001a..21c595826f 100644 --- a/board/sweetberry/board.c +++ b/board/sweetberry/board.c @@ -16,6 +16,18 @@ #include "task.h" #include "util.h" +/* I2C ports */ +const struct i2c_port_t i2c_ports[] = { + {"i2c1", I2C_PORT_0, 800, + GPIO_I2C1_SCL, GPIO_I2C1_SDA}, + {"i2c2", I2C_PORT_1, 800, + GPIO_I2C2_SCL, GPIO_I2C2_SDA}, + {"i2c3", I2C_PORT_2, 800, + GPIO_I2C3_SCL, GPIO_I2C3_SDA}, + {"fmpi2c4", FMPI2C_PORT_3, 800, + GPIO_FMPI2C_SCL, GPIO_FMPI2C_SDA}, +}; +const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports); #define GPIO_SET_HS(bank, number) \ (STM32_GPIO_OSPEEDR(GPIO_##bank) |= (0x3 << ((number) * 2))) @@ -55,3 +67,12 @@ void board_config_post_gpio_init(void) GPIO_SET_HS(C, 6); GPIO_SET_HS(C, 7); } + +static void board_init(void) +{ + uint8_t tmp; + + /* i2c 0 has a tendancy to get wedged. TODO(nsanders): why? */ + i2c_xfer(0, 0, NULL, 0, &tmp, 1, I2C_XFER_SINGLE); +} +DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT); diff --git a/board/sweetberry/board.h b/board/sweetberry/board.h index 1b0eddb263..407d30e442 100644 --- a/board/sweetberry/board.h +++ b/board/sweetberry/board.h @@ -29,6 +29,13 @@ #define CONFIG_UART_TX_REQ_CH 4 #define CONFIG_UART_RX_REQ_CH 4 +#define CONFIG_I2C +#define CONFIG_I2C_MASTER +#define I2C_PORT_0 0 +#define I2C_PORT_1 1 +#define I2C_PORT_2 2 +#define FMPI2C_PORT_3 3 + /* This is not actually a Chromium EC so disable some features. */ #undef CONFIG_WATCHDOG_HELP #undef CONFIG_LID_SWITCH |