summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFurquan Shaikh <furquan@google.com>2018-05-23 12:33:11 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-05-26 00:21:43 -0700
commitc25b78ae0263463a0a635f6336379612078b5566 (patch)
tree85f55a6d7b165136f7c9434e36b51862064eb4a6
parentb5cebbaadb4966e9d1820b0dcabd690d3e5d762e (diff)
downloadchrome-ec-c25b78ae0263463a0a635f6336379612078b5566.tar.gz
chip/it83xx: Clean-up ec2i pnpcfg settings
This change gets rid of enum ec2i_setting and reorganizes pnpcfg_settings into multiple tables each for a logical device that needs to be configured. BUG=b:79897267 BRANCH=None TEST=Verified that bip still boots up. Change-Id: If7a756640c5e72b8494294495693589aaaa8fe74 Signed-off-by: Furquan Shaikh <furquan@google.com> Reviewed-on: https://chromium-review.googlesource.com/1070486 Commit-Ready: Furquan Shaikh <furquan@chromium.org> Tested-by: Furquan Shaikh <furquan@chromium.org> Reviewed-by: Jett Rink <jettrink@chromium.org> Reviewed-by: Dino Li <dino.li@ite.corp-partner.google.com>
-rw-r--r--chip/it83xx/ec2i.c65
-rw-r--r--chip/it83xx/ec2i_chip.h47
2 files changed, 54 insertions, 58 deletions
diff --git a/chip/it83xx/ec2i.c b/chip/it83xx/ec2i.c
index 5807b3ed32..3804061407 100644
--- a/chip/it83xx/ec2i.c
+++ b/chip/it83xx/ec2i.c
@@ -6,6 +6,7 @@
/* EC2I control module for IT83xx. */
#include "common.h"
+#include "console.h"
#include "ec2i_chip.h"
#include "hooks.h"
#include "registers.h"
@@ -13,8 +14,7 @@
#include "timer.h"
#include "util.h"
-/* PNPCFG settings */
-static const struct ec2i_t pnpcfg_settings[] = {
+static const struct ec2i_t keyboard_settings[] = {
/* Select logical device 06h(keyboard) */
{HOST_INDEX_LDN, LDN_KBC_KEYBOARD},
/* Set IRQ=01h for logical device */
@@ -43,21 +43,27 @@ static const struct ec2i_t pnpcfg_settings[] = {
#endif
/* Enable logical device */
{HOST_INDEX_LDA, 0x01},
+};
+static const struct ec2i_t mouse_settings[] = {
/* Select logical device 05h(mouse) */
{HOST_INDEX_LDN, LDN_KBC_MOUSE},
/* Set IRQ=0Ch for logical device */
{HOST_INDEX_IRQNUMX, 0x0C},
/* Enable logical device */
{HOST_INDEX_LDA, 0x01},
+};
+static const struct ec2i_t pm1_settings[] = {
/* Select logical device 11h(PM1 ACPI) */
{HOST_INDEX_LDN, LDN_PMC1},
/* Set IRQ=00h for logical device */
{HOST_INDEX_IRQNUMX, 0x00},
/* Enable logical device */
{HOST_INDEX_LDA, 0x01},
+};
+static const struct ec2i_t pm2_settings[] = {
/* Select logical device 12h(PM2) */
{HOST_INDEX_LDN, LDN_PMC2},
/* I/O Port Base Address 200h/204h */
@@ -69,7 +75,9 @@ static const struct ec2i_t pnpcfg_settings[] = {
{HOST_INDEX_IRQNUMX, 0x00},
/* Enable logical device */
{HOST_INDEX_LDA, 0x01},
+};
+static const struct ec2i_t smfi_settings[] = {
/* Select logical device 0Fh(SMFI) */
{HOST_INDEX_LDN, LDN_SMFI},
/* H2RAM LPC I/O cycle Dxxx */
@@ -78,7 +86,13 @@ static const struct ec2i_t pnpcfg_settings[] = {
{HOST_INDEX_DSLDC7, 0x01},
/* Enable logical device */
{HOST_INDEX_LDA, 0x01},
+};
+/*
+ * PM3 is enabled and base address is set to 80h so that we are able to get an
+ * interrupt when host outputs data to port 80.
+ */
+static const struct ec2i_t pm3_settings[] = {
/* Select logical device 17h(PM3) */
{HOST_INDEX_LDN, LDN_PMC3},
/* I/O Port Base Address 80h */
@@ -90,6 +104,14 @@ static const struct ec2i_t pnpcfg_settings[] = {
{HOST_INDEX_IRQNUMX, 0x00},
/* Enable logical device */
{HOST_INDEX_LDA, 0x01},
+};
+
+/*
+ * This logical device is not enabled, however P80L* settings need to be
+ * performed on this logical device to ensure that port80 BRAM index is
+ * initialized correctly.
+ */
+static const struct ec2i_t rtct_settings[] = {
/* Select logical device 10h(RTCT) */
{HOST_INDEX_LDN, LDN_RTCT},
/* P80L Begin Index */
@@ -98,7 +120,10 @@ static const struct ec2i_t pnpcfg_settings[] = {
{HOST_INDEX_DSLDC5, P80L_P80LE},
/* P80L Current Index */
{HOST_INDEX_DSLDC6, P80L_P80LC},
+};
+
#ifdef CONFIG_UART_HOST
+static const struct ec2i_t uart2_settings[] = {
/* Select logical device 2h(UART2) */
{HOST_INDEX_LDN, LDN_UART2},
/*
@@ -120,9 +145,8 @@ static const struct ec2i_t pnpcfg_settings[] = {
{HOST_INDEX_IRQTP, 0x02},
/* Enable logical device */
{HOST_INDEX_LDA, 0x01},
-#endif
};
-BUILD_ASSERT(ARRAY_SIZE(pnpcfg_settings) == EC2I_SETTING_COUNT);
+#endif
/* EC2I access index/data port */
enum ec2i_access {
@@ -251,17 +275,36 @@ enum ec2i_message ec2i_write(enum host_pnpcfg_index index, uint8_t data)
return ret;
}
-static void pnpcfg_init(void)
+static void pnpcfg_configure(const struct ec2i_t *settings, size_t entries)
{
- int table;
+ size_t i;
+
+ for (i = 0; i < entries; i++) {
+ if (ec2i_write(settings[i].index_port, settings[i].data_port) ==
+ EC2I_WRITE_ERROR) {
+ ccprints("Failed to apply %d", i);
+ break;
+ }
+ }
+}
+#define PNPCFG(_s) \
+ pnpcfg_configure(_s##_settings, ARRAY_SIZE(_s##_settings))
+
+static void pnpcfg_init(void)
+{
/* Host access is disabled */
IT83XX_EC2I_LSIOHA |= 0x3;
- for (table = 0x00; table < EC2I_SETTING_COUNT; table++) {
- if (ec2i_write(pnpcfg_settings[table].index_port,
- pnpcfg_settings[table].data_port) == EC2I_WRITE_ERROR)
- break;
- }
+ PNPCFG(keyboard);
+ PNPCFG(mouse);
+ PNPCFG(pm1);
+ PNPCFG(pm2);
+ PNPCFG(smfi);
+ PNPCFG(pm3);
+ PNPCFG(rtct);
+#ifdef CONFIG_UART_HOST
+ PNPCFG(uart2);
+#endif
}
DECLARE_HOOK(HOOK_INIT, pnpcfg_init, HOOK_PRIO_DEFAULT);
diff --git a/chip/it83xx/ec2i_chip.h b/chip/it83xx/ec2i_chip.h
index 9510f75efc..29566de905 100644
--- a/chip/it83xx/ec2i_chip.h
+++ b/chip/it83xx/ec2i_chip.h
@@ -13,53 +13,6 @@
#define P80L_P80LC 0
#define P80L_BRAM_BANK1_SIZE_MASK 0x3F
-enum ec2i_setting {
- EC2I_SET_KB_LDN,
- EC2I_SET_KB_IRQ,
-#ifdef CONFIG_HOSTCMD_ESPI
- EC2I_SET_KB_IRQ_TYPE,
-#endif
- EC2I_SET_KB_ENABLE,
- EC2I_SET_MOUSE_LDN,
- EC2I_SET_MOUSE_IRQ,
- EC2I_SET_MOUSE_ENABLE,
- EC2I_SET_PMC1_LDN,
- EC2I_SET_PMC1_IRQ,
- EC2I_SET_PMC1_ENABLE,
- EC2I_SET_PMC2_LDN,
- EC2I_SET_PMC2_BASE0_MSB,
- EC2I_SET_PMC2_BASE0_LSB,
- EC2I_SET_PMC2_BASE1_MSB,
- EC2I_SET_PMC2_BASE1_LSB,
- EC2I_SET_PMC2_IRQ,
- EC2I_SET_PMC2_ENABLE,
- EC2I_SET_SMFI_LDN,
- EC2I_SET_SMFI_H2RAM_IO_BASE,
- EC2I_SET_SMFI_H2RAM_MAP_LPC_IO,
- EC2I_SET_SMFI_ENABLE,
- EC2I_SET_PMC3_LDN,
- EC2I_SET_PMC3_BASE0_MSB,
- EC2I_SET_PMC3_BASE0_LSB,
- EC2I_SET_PMC3_BASE1_MSB,
- EC2I_SET_PMC3_BASE1_LSB,
- EC2I_SET_PMC3_IRQ,
- EC2I_SET_PMC3_ENABLE,
- EC2I_SET_RTCT_LDN,
- EC2I_SET_RTCT_P80LB,
- EC2I_SET_RTCT_P80LE,
- EC2I_SET_RTCT_P80LC,
-#ifdef CONFIG_UART_HOST
- EC2I_SET_UART2_LDN,
- EC2I_SET_UART2_IO_BASE_MSB,
- EC2I_SET_UART2_IO_BASE_LSB,
- EC2I_SET_UART2_IRQ,
- EC2I_SET_UART2_IRQ_TYPE,
- EC2I_SET_UART2_ENABLE,
-#endif
- /* Number of EC2I settings */
- EC2I_SETTING_COUNT
-};
-
/* Index list of the host interface registers of PNPCFG */
enum host_pnpcfg_index {
/* Logical Device Number */