summaryrefslogtreecommitdiffstats
path: root/src/soc/mediatek/mt8192
diff options
context:
space:
mode:
authorRex-BC Chen <rex-bc.chen@mediatek.corp-partner.google.com>2021-11-03 11:28:23 +0800
committerHung-Te Lin <hungte@chromium.org>2021-11-17 10:29:55 +0000
commit9d321588d04843621af4cddff411ddcee88fe682 (patch)
treed4b35804b227b111cd73df23479e9993a2437d9f /src/soc/mediatek/mt8192
parente2cc773f71891f26330f235421602ad4bd3695e6 (diff)
downloadcoreboot-9d321588d04843621af4cddff411ddcee88fe682.tar.gz
coreboot-9d321588d04843621af4cddff411ddcee88fe682.tar.bz2
coreboot-9d321588d04843621af4cddff411ddcee88fe682.zip
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 <rex-bc.chen@mediatek.com> Change-Id: I4a702741c763bf9261cea90d0d71c08b6e28c261 Reviewed-on: https://review.coreboot.org/c/coreboot/+/59295 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Diffstat (limited to 'src/soc/mediatek/mt8192')
-rw-r--r--src/soc/mediatek/mt8192/i2c.c9
-rw-r--r--src/soc/mediatek/mt8192/include/soc/i2c.h5
2 files changed, 9 insertions, 5 deletions
diff --git a/src/soc/mediatek/mt8192/i2c.c b/src/soc/mediatek/mt8192/i2c.c
index a76b0394c7e0..5f1e3a03f356 100644
--- a/src/soc/mediatek/mt8192/i2c.c
+++ b/src/soc/mediatek/mt8192/i2c.c
@@ -2,11 +2,9 @@
#include <assert.h>
#include <device/mmio.h>
-#include <soc/pll.h>
#include <soc/i2c.h>
#include <soc/gpio.h>
-#define I2C_CLK_HZ (UNIVPLL_HZ / 20)
#define I2C_FULL_DUTY 100
#define I2C_HALF_DUTY 50
#define I2C_ADJUSTED_DUTY 45
@@ -64,7 +62,8 @@ struct mtk_i2c mtk_i2c_bus_controller[] = {
},
};
-#define I2C_BUS_NUMBER ARRAY_SIZE(mtk_i2c_bus_controller)
+_Static_assert(ARRAY_SIZE(mtk_i2c_bus_controller) == I2C_BUS_NUMBER,
+ "Wrong size of mtk_i2c_bus_controller");
struct pad_func {
gpio_t gpio;
@@ -127,7 +126,7 @@ static void mtk_i2c_set_gpio_pinmux(uint8_t bus)
}
}
-static void mtk_i2c_speed_init(uint8_t bus)
+static void mtk_i2c_speed_init_soc(uint8_t bus)
{
uint8_t step_div;
const uint8_t clock_div = 5;
@@ -178,7 +177,7 @@ static void mtk_i2c_speed_init(uint8_t bus)
void mtk_i2c_bus_init(uint8_t bus)
{
- mtk_i2c_speed_init(bus);
+ mtk_i2c_speed_init_soc(bus);
mtk_i2c_set_gpio_pinmux(bus);
}
diff --git a/src/soc/mediatek/mt8192/include/soc/i2c.h b/src/soc/mediatek/mt8192/include/soc/i2c.h
index 72a9af10e2b1..fbf41e6c4875 100644
--- a/src/soc/mediatek/mt8192/include/soc/i2c.h
+++ b/src/soc/mediatek/mt8192/include/soc/i2c.h
@@ -4,6 +4,7 @@
#define SOC_MEDIATEK_MT8192_I2C_H
#include <soc/i2c_common.h>
+#include <soc/pll.h>
/* I2C Register */
struct mt_i2c_regs {
@@ -39,6 +40,10 @@ struct mt_i2c_regs {
uint32_t rollback;
};
+#define I2C_BUS_NUMBER 10
+#define MAX_CLOCK_DIV 32
+#define I2C_CLK_HZ (UNIVPLL_HZ / 20)
+
check_member(mt_i2c_regs, multi_dma, 0xf8c);
void mtk_i2c_bus_init(uint8_t bus);