summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormartin yan <martin.yan@microchip.corp-partner.google.com>2021-04-01 03:57:18 -0400
committerCommit Bot <commit-bot@chromium.org>2021-04-05 19:21:04 +0000
commit26c5b9897f23ea07633ee3eb156b1e5928eb67b1 (patch)
treeb6fd90c565be254619d0d1f6a8d489bcac005bac
parentc580c2225e055ceda79ced0fd7a08f6447ce987f (diff)
downloadchrome-ec-26c5b9897f23ea07633ee3eb156b1e5928eb67b1.tar.gz
mchp: Add i2c_chip.h and board_i2c_p2c() in chip
Add board_i2c_p2c() which returns default I2C controller for i2c but this function can be overridden by board BRANCH=none BUG=none TEST=Build sklrvp_mchp172x. Signed-off-by: martin yan <martin.yan@microchip.corp-partner.google.com> Change-Id: I88740517f11c6afcfc1edb37a59bbf04f336f655 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/2800091 Reviewed-by: Vijay P Hiremath <vijay.p.hiremath@intel.com> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Commit-Queue: Aseda Aboagye <aaboagye@chromium.org>
-rw-r--r--chip/mchp/i2c.c12
-rw-r--r--chip/mchp/i2c_chip.h27
2 files changed, 39 insertions, 0 deletions
diff --git a/chip/mchp/i2c.c b/chip/mchp/i2c.c
index cc8eae7960..6125a893ef 100644
--- a/chip/mchp/i2c.c
+++ b/chip/mchp/i2c.c
@@ -10,6 +10,7 @@
#include "gpio.h"
#include "hooks.h"
#include "i2c.h"
+#include "i2c_chip.h"
#include "registers.h"
#include "task.h"
#include "tfdp_chip.h"
@@ -927,6 +928,17 @@ int i2c_get_line_levels(int port)
}
/*
+ * this function returns the controller for I2C
+ * return mod of MCHP_I2C_CTRL_MAX
+ */
+__overridable int board_i2c_p2c(int port)
+{
+ if (port < 0 || port >= I2C_PORT_COUNT)
+ return -1;
+ return port % MCHP_I2C_CTRL_MAX;
+}
+
+/*
* I2C port must be a zero based number.
* MCHP I2C can map any port to any of the 4 controllers.
* Call board level function as board designs may choose
diff --git a/chip/mchp/i2c_chip.h b/chip/mchp/i2c_chip.h
new file mode 100644
index 0000000000..35752fe9ca
--- /dev/null
+++ b/chip/mchp/i2c_chip.h
@@ -0,0 +1,27 @@
+/* Copyright 2021 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* MCHP-specific I2C module for Chrome EC */
+
+#ifndef _I2C_CHIP_H
+#define _I2C_CHIP_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Place any C interfaces here */
+
+/*
+ * function returns the controller for I2C
+ * if there is a special assignment, function board.c can override this.
+ */
+__override_proto int board_i2c_p2c(int port);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _I2C_CHIP_H */