summaryrefslogtreecommitdiff
path: root/chip/npcx/i2c.c
diff options
context:
space:
mode:
authorWealian Liao <whliao@nuvoton.corp-partner.google.com>2020-02-13 13:57:22 +0800
committerCommit Bot <commit-bot@chromium.org>2020-02-13 12:30:23 +0000
commit1f9574abf03baf048407c1f7ddb3c7392ecb8db9 (patch)
tree37488a17d086fcda040fc9fc18b325183cf3cfa3 /chip/npcx/i2c.c
parentbd8c51b9295d9d09531a8efca702658ca9d61124 (diff)
downloadchrome-ec-1f9574abf03baf048407c1f7ddb3c7392ecb8db9.tar.gz
npcx7: SMB: Fix the incorrect selection of clock source
The SMB driver currently uses the APB2 as the clock source for SMB4-SMB7, which is not correct. Luckily, the incorrect setting won't cause any real issue until now because the APB2 and APB3 are set to the same value. This CL fixes it by changing the clock source to the correct one (i.e. APB3.) BUG=b:149359617 BRANCH=none TEST=No error for "make buildall" TEST=Test all SMB ports on npcx7 EVB with the SMB slave device. Change-Id: I10aa0554b1c84d85e355bdefa0a0643b59aa1b25 Signed-off-by: Wealian <whliao@nuvoton.corp-partner.google.com> Signed-off-by: CHLin <CHLIN56@nuvoton.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2053865 Reviewed-by: CH Lin <chlin56@nuvoton.com> Reviewed-by: caveh jalali <caveh@chromium.org>
Diffstat (limited to 'chip/npcx/i2c.c')
-rw-r--r--chip/npcx/i2c.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/chip/npcx/i2c.c b/chip/npcx/i2c.c
index bae14aa101..17b183bc71 100644
--- a/chip/npcx/i2c.c
+++ b/chip/npcx/i2c.c
@@ -1009,17 +1009,20 @@ static void i2c_freq_changed(void)
int ctrl = i2c_port_to_controller(i2c_ports[i].port);
int scl_freq;
- if (ctrl < 2)
-#if defined(CHIP_FAMILY_NPCX7)
- /* SMB0/1 use APB3 clock */
- freq = clock_get_apb3_freq();
-#else
- /* SMB0/1 use core clock */
- freq = clock_get_freq();
+#ifdef CHIP_FAMILY_NPCX7
+ /*
+ * SMB0/1/4/5/6/7 use APB3 clock
+ * SMB2/3 use APB2 clock
+ */
+ freq = (ctrl < 2 || ctrl > 3) ?
+ clock_get_apb3_freq() : clock_get_apb2_freq();
+#else /* CHIP_FAMILY_NPCX5 */
+ /*
+ * SMB0/1 use core clock
+ * SMB2/3 use APB2 clock
+ */
+ freq = (ctrl < 2) ? clock_get_freq() : clock_get_apb2_freq();
#endif
- else
- /* Other SMB controller use APB2 clock */
- freq = clock_get_apb2_freq();
/*
* Set SCL frequency by formula: