From b221c77b6293ad03e2610b940e2d39de6d40c4db Mon Sep 17 00:00:00 2001 From: Vincent Palatin Date: Thu, 16 Feb 2012 02:46:56 +0000 Subject: [PATCH] stm32l: add support for ADV board Compared to Daisy, it has the EC console on USART2 (pins PA2 and PA3) and regulator enable GPIOS EN_PP1350 and EN_PP5000 are on PA9/PA10. Signed-off-by: Vincent Palatin BUG=None TEST=make BOARD=adv && make BOARD=daisy && make BOARD=discovery Change-Id: I545f7c9b05480e58db913ea562c77a1a1cd2b11c --- board/adv/board.c | 44 +++++++++++++++++++++++++++++++++++++++++++ board/adv/board.h | 43 ++++++++++++++++++++++++++++++++++++++++++ board/adv/build.mk | 10 ++++++++++ board/adv/ec.tasklist | 19 +++++++++++++++++++ chip/stm32l/config.h | 6 +++++- 5 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 board/adv/board.c create mode 100644 board/adv/board.h create mode 100644 board/adv/build.mk create mode 100644 board/adv/ec.tasklist diff --git a/board/adv/board.c b/board/adv/board.c new file mode 100644 index 0000000000..b4321f2d4c --- /dev/null +++ b/board/adv/board.c @@ -0,0 +1,44 @@ +/* Copyright (c) 2012 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. + */ +/* ADV board-specific configuration */ + +#include "board.h" +#include "common.h" +#include "gpio.h" +#include "registers.h" +#include "util.h" + +/* GPIO interrupt handlers prototypes */ +void gaia_power_event(enum gpio_signal signal); + +/* GPIO signal list. Must match order from enum gpio_signal. */ +const struct gpio_info gpio_list[GPIO_COUNT] = { + /* Inputs with interrupt handlers are first for efficiency */ + {"EC_PWRON", GPIO_A, (1<<0), GPIO_INT_BOTH, gaia_power_event}, + {"PP1800_LDO2", GPIO_A, (1<<1), GPIO_INT_BOTH, gaia_power_event}, + {"XPSHOLD", GPIO_A, (1<<11), GPIO_INT_RISING, gaia_power_event}, + {"CHARGER_INT", GPIO_B, (1<<0), GPIO_INT_RISING, NULL}, + {"LID_OPEN", GPIO_C, (1<<13), GPIO_INT_BOTH, NULL}, + /* Other inputs */ + /* Outputs */ + {"EN_PP1350", GPIO_A, (1<<9), GPIO_OUT_LOW, NULL}, + {"EN_PP5000", GPIO_A, (1<<10), GPIO_OUT_LOW, NULL}, + {"EN_PP3300", GPIO_A, (1<<8), GPIO_OUT_LOW, NULL}, + {"PMIC_ACOK", GPIO_A, (1<<12), GPIO_OUT_LOW, NULL}, + {"ENTERING_RW", GPIO_B, (1<<1), GPIO_OUT_LOW, NULL}, + {"CHARGER_EN", GPIO_B, (1<<2), GPIO_OUT_LOW, NULL}, + {"EC_INT", GPIO_B, (1<<9), GPIO_OUT_LOW, NULL}, +}; + +void configure_board(void) +{ + /* Enable all GPIOs clocks + * TODO: more fine-grained enabling for power saving + */ + STM32L_RCC_AHBENR |= 0x3f; + + /* Select Alternate function for USART2 on pins PA2/PA3 */ + gpio_set_alternate_function(GPIO_A, (1<<2) | (1<<3), GPIO_ALT_USART); +} diff --git a/board/adv/board.h b/board/adv/board.h new file mode 100644 index 0000000000..a3793d281d --- /dev/null +++ b/board/adv/board.h @@ -0,0 +1,43 @@ +/* Copyright (c) 2012 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. + */ + +/* ADV board configuration */ + +#ifndef __BOARD_H +#define __BOARD_H + +/* 16 MHz SYSCLK clock frequency */ +#define CPU_CLOCK 16000000 + +/* Use USART2 as console serial port */ +#define CONFIG_CONSOLE_UART 2 + +#define USB_CHARGE_PORT_COUNT 0 + +/* GPIO signal list */ +enum gpio_signal { + /* Inputs with interrupt handlers are first for efficiency */ + GPIO_EC_PWRON = 0, /* Power button */ + GPIO_PP1800_LDO2, /* LDO2 is ON (end of PMIC sequence) */ + GPIO_SOC1V8_XPSHOLD, /* App Processor ON */ + GPIO_CHARGER_INT, + GPIO_LID_OPEN, /* LID switch detection */ + /* Other inputs */ + /* Outputs */ + GPIO_EN_PP1350, /* DDR 1.35v rail enable */ + GPIO_EN_PP5000, /* 5.0v rail enable */ + GPIO_EN_PP3300, /* 3.3v rail enable */ + GPIO_PMIC_ACOK, /* 5v rail ready */ + GPIO_EC_ENTERING_RW, /* EC is R/W mode for the kbc mux */ + GPIO_CHARGER_EN, + GPIO_EC_INT, + + /* Number of GPIOs; not an actual GPIO */ + GPIO_COUNT +}; + +void configure_board(void); + +#endif /* __BOARD_H */ diff --git a/board/adv/build.mk b/board/adv/build.mk new file mode 100644 index 0000000000..2f0ebe32af --- /dev/null +++ b/board/adv/build.mk @@ -0,0 +1,10 @@ +# Copyright (c) 2012 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 STmicro STM32L151R8H6 +CHIP:=stm32l + +board-y=board.o diff --git a/board/adv/ec.tasklist b/board/adv/ec.tasklist new file mode 100644 index 0000000000..6c7049edae --- /dev/null +++ b/board/adv/ec.tasklist @@ -0,0 +1,19 @@ +/* Copyright (c) 2012 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(n, r, d) 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 + */ +#define CONFIG_TASK_LIST \ + TASK(WATCHDOG, watchdog_task, NULL) \ + TASK(GAIAPOWER, gaia_power_task, NULL) \ + TASK(CONSOLE, console_task, NULL) diff --git a/chip/stm32l/config.h b/chip/stm32l/config.h index 9309fc54b5..ef4dd75b27 100644 --- a/chip/stm32l/config.h +++ b/chip/stm32l/config.h @@ -20,7 +20,11 @@ #define CONFIG_IRQ_COUNT 45 /* Debug UART parameters for panic message */ -#define CONFIG_UART_ADDRESS 0x40013800 +#ifdef BOARD_adv +#define CONFIG_UART_ADDRESS 0x40004400 /* USART2 */ +#else +#define CONFIG_UART_ADDRESS 0x40013800 /* USART1 */ +#endif #define CONFIG_UART_DR_OFFSET 0x04 #define CONFIG_UART_SR_OFFSET 0x00 #define CONFIG_UART_SR_TXEMPTY 0x80