From 9d321588d04843621af4cddff411ddcee88fe682 Mon Sep 17 00:00:00 2001 From: Rex-BC Chen Date: Wed, 3 Nov 2021 11:28:23 +0800 Subject: soc/mediatek: move i2c function to common folder Move mtk_i2c_max_step_cnt, mtk_i2c_check_ac_timing, mtk_i2c_speed_init and mtk_i2c_calculate_speed to common folder to share with MT8186. TEST=test on tomato ok TEST=emerge-asurada coreboot BUG=b:202871018 Signed-off-by: Rex-BC Chen Change-Id: I4a702741c763bf9261cea90d0d71c08b6e28c261 Reviewed-on: https://review.coreboot.org/c/coreboot/+/59295 Tested-by: build bot (Jenkins) Reviewed-by: Yu-Ping Wu --- src/soc/mediatek/mt8173/i2c.c | 6 +++--- src/soc/mediatek/mt8173/include/soc/i2c.h | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src/soc/mediatek/mt8173') diff --git a/src/soc/mediatek/mt8173/i2c.c b/src/soc/mediatek/mt8173/i2c.c index ff803c3d3b..dd4629d909 100644 --- a/src/soc/mediatek/mt8173/i2c.c +++ b/src/soc/mediatek/mt8173/i2c.c @@ -6,9 +6,6 @@ #include #include #include -#include - -#define I2C_CLK_HZ (AXI_HZ / 16) struct mtk_i2c mtk_i2c_bus_controller[7] = { /* i2c0 setting */ @@ -52,6 +49,9 @@ struct mtk_i2c mtk_i2c_bus_controller[7] = { } }; +_Static_assert(ARRAY_SIZE(mtk_i2c_bus_controller) == I2C_BUS_NUMBER, + "Wrong size of mtk_i2c_bus_controller"); + #define I2CTAG "[I2C][PL] " #if CONFIG(DEBUG_I2C) diff --git a/src/soc/mediatek/mt8173/include/soc/i2c.h b/src/soc/mediatek/mt8173/include/soc/i2c.h index e6f0140367..02a21817d9 100644 --- a/src/soc/mediatek/mt8173/include/soc/i2c.h +++ b/src/soc/mediatek/mt8173/include/soc/i2c.h @@ -4,6 +4,7 @@ #define SOC_MEDIATEK_MT8173_I2C_H #include +#include /* I2C Register */ struct mt_i2c_regs { @@ -35,6 +36,10 @@ struct mt_i2c_regs { uint32_t transfer_aux_len; }; +#define I2C_CLK_HZ (AXI_HZ / 16) +#define I2C_BUS_NUMBER 7 +#define MAX_CLOCK_DIV 32 + check_member(mt_i2c_regs, debug_stat, 0x64); void mtk_i2c_bus_init(uint8_t bus); -- cgit v1.2.3