summaryrefslogtreecommitdiff
path: root/board/polyberry/board.c
diff options
context:
space:
mode:
authorNick Sanders <nsanders@chromium.org>2016-10-14 21:12:14 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-10-18 22:15:52 -0700
commit6e03484c018310539196ee3cfceeeae806592670 (patch)
treecafbc1c55964548192e6a573fa95421c01db4162 /board/polyberry/board.c
parent35e580b7a9d0dedbb2664dbfd694ab5bd3a87226 (diff)
downloadchrome-ec-6e03484c018310539196ee3cfceeeae806592670.tar.gz
polyberry: add initial board build
This supports gpio initialization only. BUG=None TEST=Successfully checked console and available GPIO on sweetberry BRANCH=None Change-Id: Id50f66652b05c25a8c79ce2938fa161a944d93b8 Signed-off-by: Nick Sanders <nsanders@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/399643 Reviewed-by: Aseda Aboagye <aaboagye@chromium.org>
Diffstat (limited to 'board/polyberry/board.c')
-rw-r--r--board/polyberry/board.c106
1 files changed, 106 insertions, 0 deletions
diff --git a/board/polyberry/board.c b/board/polyberry/board.c
new file mode 100644
index 0000000000..d270498809
--- /dev/null
+++ b/board/polyberry/board.c
@@ -0,0 +1,106 @@
+/* Copyright 2016 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.
+ */
+/* Polyberry board configuration */
+
+#include "common.h"
+#include "dma.h"
+#include "ec_version.h"
+#include "gpio.h"
+#include "gpio_list.h"
+#include "hooks.h"
+#include "registers.h"
+#include "stm32-dma.h"
+#include "task.h"
+#include "update_fw.h"
+#include "usb_descriptor.h"
+#include "util.h"
+#include "usb_dwc_hw.h"
+#include "usb_dwc_console.h"
+#include "usb_dwc_update.h"
+
+/******************************************************************************
+ * Define the strings used in our USB descriptors.
+ */
+const void *const usb_strings[] = {
+ [USB_STR_DESC] = usb_string_desc,
+ [USB_STR_VENDOR] = USB_STRING_DESC("Google Inc."),
+ [USB_STR_PRODUCT] = USB_STRING_DESC("Polyberry"),
+ [USB_STR_SERIALNO] = USB_STRING_DESC("1234-a"),
+ [USB_STR_VERSION] = USB_STRING_DESC(CROS_EC_VERSION32),
+ [USB_STR_CONSOLE_NAME] = USB_STRING_DESC("Polyberry EC Shell"),
+ [USB_STR_UPDATE_NAME] = USB_STRING_DESC("Firmware update"),
+};
+
+BUILD_ASSERT(ARRAY_SIZE(usb_strings) == USB_STR_COUNT);
+
+struct dwc_usb usb_ctl = {
+ .ep = {
+ &ep0_ctl,
+ &ep_console_ctl,
+ &usb_update_ep_ctl,
+ },
+ .speed = USB_SPEED_FS,
+ .phy_type = USB_PHY_ULPI,
+ .dma_en = 1,
+ .irq = STM32_IRQ_OTG_HS,
+};
+
+/******************************************************************************
+ * Support firmware upgrade over USB. We can update whichever section is not
+ * the current section.
+ */
+
+/*
+ * This array defines possible sections available for the firmware update.
+ * The section which does not map the current executing code is picked as the
+ * valid update area. The values are offsets into the flash space.
+ */
+const struct section_descriptor board_rw_sections[] = {
+ {CONFIG_RO_MEM_OFF,
+ CONFIG_RO_MEM_OFF + CONFIG_RO_SIZE},
+ {CONFIG_RW_MEM_OFF,
+ CONFIG_RW_MEM_OFF + CONFIG_RW_SIZE},
+};
+const struct section_descriptor * const rw_sections = board_rw_sections;
+const int num_rw_sections = ARRAY_SIZE(board_rw_sections);
+
+#define GPIO_SET_HS(bank, number) \
+ (STM32_GPIO_OSPEEDR(GPIO_##bank) |= (0x3 << ((number) * 2)))
+
+void board_config_post_gpio_init(void)
+{
+ /* We use MCO2 clock passthrough to provide a clock to USB HS */
+ gpio_config_module(MODULE_MCO, 1);
+ /* GPIO PC9 to high speed */
+ GPIO_SET_HS(C, 9);
+
+ if (usb_ctl.phy_type == USB_PHY_ULPI)
+ gpio_set_level(GPIO_USB_MUX_SEL, 0);
+ else
+ gpio_set_level(GPIO_USB_MUX_SEL, 1);
+
+ /* Set USB GPIO to high speed */
+ GPIO_SET_HS(A, 11);
+ GPIO_SET_HS(A, 12);
+
+ GPIO_SET_HS(C, 3);
+ GPIO_SET_HS(C, 2);
+ GPIO_SET_HS(C, 0);
+ GPIO_SET_HS(A, 5);
+
+ GPIO_SET_HS(B, 5);
+ GPIO_SET_HS(B, 13);
+ GPIO_SET_HS(B, 12);
+ GPIO_SET_HS(B, 2);
+ GPIO_SET_HS(B, 10);
+ GPIO_SET_HS(B, 1);
+ GPIO_SET_HS(B, 0);
+ GPIO_SET_HS(A, 3);
+}
+
+static void board_init(void)
+{
+}
+DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);