summaryrefslogtreecommitdiff
path: root/board/it8380dev
diff options
context:
space:
mode:
authorVincent Palatin <vpalatin@chromium.org>2013-10-25 15:33:41 -0700
committerchrome-internal-fetch <chrome-internal-fetch@google.com>2014-01-08 02:24:23 +0000
commit4cf4fcf1cb6a4332a27dd76ae19ba8852ddbaaec (patch)
treec7c60433492976a10506ec93e8fee8f7483fa44c /board/it8380dev
parent375e75de27813e0f440fefc45892157972e300dc (diff)
downloadchrome-ec-4cf4fcf1cb6a4332a27dd76ae19ba8852ddbaaec.tar.gz
ite: Add initial support for ITE IT8380 chip
Initial support for the ITE IT8380 chip with the following peripherals : - 8250-like UART module. - HW timer (with a 128-us tick period). - GPIO with pins initialization and edge interrupt support. other functions are stubbed. - Clock : basic fixed frequency setup only. It also add the dev board configuration as a test vehicle. Signed-off-by: Alec Berg <alecaberg@chromium.org> Signed-off-by: Vincent Palatin <vpalatin@chromium.org> BRANCH=none BUG=chrome-os-partner:23575 TEST=make BOARD=it8380dev on IT8380 dev board, use the EC serial console, use gettime from console. Change-Id: Id4bf37d1beb21d1a4bee404c9a0bc500025fe787 Reviewed-on: https://chromium-review.googlesource.com/175481 Reviewed-by: Vincent Palatin <vpalatin@chromium.org> Commit-Queue: Alec Berg <alecaberg@chromium.org> Tested-by: Alec Berg <alecaberg@chromium.org>
Diffstat (limited to 'board/it8380dev')
-rw-r--r--board/it8380dev/board.c106
-rw-r--r--board/it8380dev/board.h47
-rw-r--r--board/it8380dev/build.mk11
-rw-r--r--board/it8380dev/ec.tasklist21
4 files changed, 185 insertions, 0 deletions
diff --git a/board/it8380dev/board.c b/board/it8380dev/board.c
new file mode 100644
index 0000000000..adad1d73a8
--- /dev/null
+++ b/board/it8380dev/board.c
@@ -0,0 +1,106 @@
+/* Copyright (c) 2013 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.
+ */
+/* IT8380 development board configuration */
+
+#include "common.h"
+#include "console.h"
+#include "gpio.h"
+#include "hooks.h"
+#include "registers.h"
+#include "task.h"
+#include "util.h"
+
+/* Test GPIO interrupt function that toggles one LED. */
+void test_interrupt(enum gpio_signal signal)
+{
+ static int busy_state;
+
+ /* toggle LED */
+ busy_state = !busy_state;
+ gpio_set_level(GPIO_BUSY_LED, busy_state);
+}
+
+/* GPIO signal list. Must match order from enum gpio_signal. */
+const struct gpio_info gpio_list[] = {
+ {"H_LED0", GPIO_A, (1<<0), GPIO_ODR_HIGH},
+ {"H_LED1", GPIO_A, (1<<1), GPIO_ODR_HIGH},
+ {"H_LED2", GPIO_A, (1<<2), GPIO_ODR_HIGH},
+ {"H_LED3", GPIO_A, (1<<3), GPIO_ODR_HIGH},
+ {"H_LED4", GPIO_A, (1<<4), GPIO_ODR_HIGH},
+ {"H_LED5", GPIO_A, (1<<5), GPIO_ODR_HIGH},
+ {"H_LED6", GPIO_A, (1<<6), GPIO_ODR_HIGH},
+ {"L_LED0", GPIO_I, (1<<0), GPIO_ODR_HIGH},
+ {"L_LED1", GPIO_I, (1<<1), GPIO_ODR_HIGH},
+ {"L_LED2", GPIO_I, (1<<2), GPIO_ODR_HIGH},
+ {"L_LED3", GPIO_I, (1<<3), GPIO_ODR_HIGH},
+ {"L_LED4", GPIO_I, (1<<4), GPIO_ODR_HIGH},
+ {"L_LED5", GPIO_I, (1<<5), GPIO_ODR_HIGH},
+ {"L_LED6", GPIO_I, (1<<6), GPIO_ODR_HIGH},
+ {"BUSY_LED", GPIO_J, (1<<0), GPIO_OUT_LOW},
+ {"GOOD_LED", GPIO_J, (1<<1), GPIO_OUT_HIGH},
+ {"FAIL_LED", GPIO_J, (1<<2), GPIO_OUT_LOW},
+ {"SW0", GPIO_E, (1<<0), GPIO_INPUT},
+ {"SW1", GPIO_E, (1<<1), GPIO_INPUT | GPIO_PULL_DOWN},
+ {"SW2", GPIO_E, (1<<2), GPIO_INPUT | GPIO_PULL_DOWN},
+ {"SW3", GPIO_E, (1<<3), GPIO_INPUT | GPIO_PULL_DOWN},
+ {"START_SW", GPIO_E, (1<<4), GPIO_INT_FALLING, test_interrupt},
+ /* Unimplemented signals which we need to emulate for now */
+ GPIO_SIGNAL_NOT_IMPLEMENTED("ENTERING_RW"),
+};
+BUILD_ASSERT(ARRAY_SIZE(gpio_list) == GPIO_COUNT);
+
+/* Pins with alternate functions */
+const struct gpio_alt_func gpio_alt_funcs[] = {
+ {GPIO_B, 0x03, 1, MODULE_UART, GPIO_PULL_UP}, /* UART0 */
+};
+const int gpio_alt_funcs_count = ARRAY_SIZE(gpio_alt_funcs);
+
+/* Initialize board. */
+static void board_init(void)
+{
+ gpio_enable_interrupt(GPIO_START_SW);
+}
+DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
+
+/*****************************************************************************/
+/* Console commands */
+
+void display_7seg(uint8_t val)
+{
+ int i;
+ static const uint8_t digits[16] = {
+ 0xc0, 0xf9, 0xa8, 0xb0,
+ 0x99, 0x92, 0x82, 0xf8,
+ 0x80, 0x98, 0x88, 0x83,
+ 0xc6, 0xa1, 0x86, 0x8e,
+ };
+
+ for (i = 0; i < 7; i++)
+ gpio_set_level(GPIO_H_LED0 + i, digits[val >> 4] & (1 << i));
+ for (i = 0; i < 7; i++)
+ gpio_set_level(GPIO_L_LED0 + i, digits[val & 0xf] & (1 << i));
+}
+
+static int command_7seg(int argc, char **argv)
+{
+ uint8_t val;
+ char *e;
+
+ if (argc != 2)
+ return EC_ERROR_PARAM_COUNT;
+
+ val = strtoi(argv[1], &e, 16);
+ if (*e)
+ return EC_ERROR_PARAM1;
+
+ ccprintf("display 0x%02x\n", val);
+ display_7seg(val);
+
+ return EC_SUCCESS;
+}
+DECLARE_CONSOLE_COMMAND(seg7, command_7seg,
+ "<hex>",
+ "Print 8-bit value on 7-segment display",
+ NULL);
diff --git a/board/it8380dev/board.h b/board/it8380dev/board.h
new file mode 100644
index 0000000000..dc1fe01187
--- /dev/null
+++ b/board/it8380dev/board.h
@@ -0,0 +1,47 @@
+/* Copyright (c) 2013 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.
+ */
+
+/* IT8380 development board configuration */
+
+#ifndef __BOARD_H
+#define __BOARD_H
+
+#ifndef __ASSEMBLER__
+
+/* stubbed features */
+#undef CONFIG_LID_SWITCH
+
+enum gpio_signal {
+ GPIO_H_LED0,
+ GPIO_H_LED1,
+ GPIO_H_LED2,
+ GPIO_H_LED3,
+ GPIO_H_LED4,
+ GPIO_H_LED5,
+ GPIO_H_LED6,
+ GPIO_L_LED0,
+ GPIO_L_LED1,
+ GPIO_L_LED2,
+ GPIO_L_LED3,
+ GPIO_L_LED4,
+ GPIO_L_LED5,
+ GPIO_L_LED6,
+ GPIO_BUSY_LED,
+ GPIO_GOOD_LED,
+ GPIO_FAIL_LED,
+ GPIO_SW1,
+ GPIO_SW2,
+ GPIO_SW3,
+ GPIO_SW4,
+ GPIO_START_SW,
+ /* Unimplemented GPIOs */
+ GPIO_ENTERING_RW,
+
+ /* Number of GPIOs; not an actual GPIO */
+ GPIO_COUNT
+};
+
+#endif /* !__ASSEMBLER__ */
+#endif /* __BOARD_H */
diff --git a/board/it8380dev/build.mk b/board/it8380dev/build.mk
new file mode 100644
index 0000000000..83f36b09b1
--- /dev/null
+++ b/board/it8380dev/build.mk
@@ -0,0 +1,11 @@
+# -*- makefile -*-
+# Copyright (c) 2013 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.
+#
+# Board specific files build
+
+# the IC is ITE 8380
+CHIP:=it83xx
+
+board-y=board.o
diff --git a/board/it8380dev/ec.tasklist b/board/it8380dev/ec.tasklist
new file mode 100644
index 0000000000..d3ac489b42
--- /dev/null
+++ b/board/it8380dev/ec.tasklist
@@ -0,0 +1,21 @@
+/* Copyright (c) 2013 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.
+ */
+
+/**
+ * List of enabled tasks in the priority order
+ *
+ * The first one has the lowest priority.
+ *
+ * For each task, use the macro TASK_ALWAYS(n, r, d, s) for base tasks and
+ * TASK_NOTEST(n, r, d, s) for tasks that can be excluded in test binaries,
+ * where :
+ * 'n' in the name of the task
+ * 'r' in the main routine of the task
+ * 'd' in an opaque parameter passed to the routine at startup
+ * 's' is the stack size in bytes; must be a multiple of 8
+ */
+#define CONFIG_TASK_LIST \
+ TASK_ALWAYS(HOOKS, hook_task, NULL, TASK_STACK_SIZE) \
+ TASK_ALWAYS(CONSOLE, console_task, NULL, TASK_STACK_SIZE)