First drop of ryu sensor hub file

For building a basic image for the Ryu Sensor Hub.

BUG=chrome-os-partner:30801
TEST=uart work, i2c master finds device, pin with EC works.
BRANCH=ToT
Change-Id: I6f8c6fa550da91eabf8b21452684d2de410611b9
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/210755
Reviewed-by: Vic Yang <victoryang@chromium.org>
Reviewed-by: Alec Berg <alecaberg@chromium.org>
This commit is contained in:
Gwendal Grignou
2014-08-21 10:03:33 -07:00
committed by chrome-internal-fetch
parent 866af4f6f2
commit f5b9f2d641
5 changed files with 161 additions and 0 deletions

32
board/ryu_sh/board.c Normal file
View File

@@ -0,0 +1,32 @@
/* Copyright (c) 2014 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.
*/
/* ryu sensor hub configuration */
#include "common.h"
#include "console.h"
#include "gpio.h"
#include "hooks.h"
#include "i2c.h"
#include "registers.h"
#include "task.h"
#include "util.h"
#include "gpio_list.h"
/* Initialize board. */
static void board_init(void)
{
}
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
/* I2C ports */
const struct i2c_port_t i2c_ports[] = {
{"master", I2C_PORT_MASTER, 100,
GPIO_MASTER_I2C_SCL, GPIO_MASTER_I2C_SDA},
{"slave", I2C_PORT_SLAVE, 100,
GPIO_SLAVE_I2C_SCL, GPIO_SLAVE_I2C_SDA},
};
const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);

50
board/ryu_sh/board.h Normal file
View File

@@ -0,0 +1,50 @@
/* Copyright (c) 2014 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.
*/
/* ryu sensor board configuration */
#ifndef __BOARD_H
#define __BOARD_H
/* 48 MHz SYSCLK clock frequency */
#define CPU_CLOCK 48000000
/* the UART console is on USART2 (PA2/PA3) */
#undef CONFIG_UART_CONSOLE
#define CONFIG_UART_CONSOLE 2
/* By default, enable all console messages */
#define CC_DEFAULT CC_ALL
/* Optional features */
#define CONFIG_STM_HWTIMER32
#define CONFIG_I2C
#undef CONFIG_LID_SWITCH
#define CONFIG_VBOOT_HASH
#undef CONFIG_WATCHDOG_HELP
/* I2C ports configuration */
#define I2C_PORT_MASTER 1
#define I2C_PORT_SLAVE 0
#define I2C_PORT_EC I2C_PORT_SLAVE
#define I2C_PORT_ACCEL I2C_PORT_MASTER
#define I2C_PORT_COMPASS I2C_PORT_MASTER
/* slave address for host commands */
#ifdef HAS_TASK_HOSTCMD
#define CONFIG_HOSTCMD_I2C_SLAVE_ADDR 0x3e
#endif
#ifndef __ASSEMBLER__
/* Timer selection */
#define TIM_CLOCK32 2
#define TIM_ADC 3
#include "gpio_signal.h"
#endif /* !__ASSEMBLER__ */
#endif /* __BOARD_H */

12
board/ryu_sh/build.mk Normal file
View File

@@ -0,0 +1,12 @@
# Copyright (c) 2014 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 STM32F072VBH6
CHIP:=stm32
CHIP_FAMILY:=stm32f0
CHIP_VARIANT:=stm32f07x
board-y=board.o

22
board/ryu_sh/ec.tasklist Normal file
View File

@@ -0,0 +1,22 @@
/* Copyright (c) 2014 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, LARGER_TASK_STACK_SIZE) \
TASK_NOTEST(HOSTCMD, host_command_task, NULL, TASK_STACK_SIZE) \
TASK_ALWAYS(CONSOLE, console_task, NULL, TASK_STACK_SIZE)

45
board/ryu_sh/gpio.inc Normal file
View File

@@ -0,0 +1,45 @@
/* -*- mode:c -*-
*
* Copyright (c) 2014 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.
*/
/* Interrupts */
/*
* TODO(gwendal): Follow Rambus work.
* Combined accelerometer input. This will become an interrupt, once we have
* support for it.
*/
GPIO(ACC_IRQ, B, 12, GPIO_INPUT, NULL)
/* Outputs */
GPIO(SH_EC_SIGNAL, A, 7, GPIO_OUT_LOW, NULL)
GPIO(SH_IRQ_L, A, 11, GPIO_OUT_LOW, NULL)
/* Inputs */
GPIO(COMPASS_DRDY, B, 11, GPIO_INPUT, NULL)
GPIO(AP_IN_SUSPEND, B, 15, GPIO_INPUT, NULL)
#if 0
/* Alternate functions */
GPIO(UART_TX, A, 2, GPIO_OUT_LOW, NULL)
GPIO(UART_RX, A, 3, GPIO_OUT_LOW, NULL)
#endif
/* Needed to bypass flash write protection */
UNIMPLEMENTED(ENTERING_RW)
UNIMPLEMENTED(WP_L)
/*
* I2C pins should be configured as inputs until I2C module is
* initialized. This will avoid driving the lines unintentionally.
*/
GPIO(SLAVE_I2C_SCL, B, 6, GPIO_INPUT, NULL)
GPIO(SLAVE_I2C_SDA, B, 7, GPIO_INPUT, NULL)
GPIO(MASTER_I2C_SCL, B, 13, GPIO_INPUT, NULL)
GPIO(MASTER_I2C_SDA, B, 14, GPIO_INPUT, NULL)
ALTERNATE(A, 0x000C, 1, MODULE_UART, 0) /* USART2: PA2/PA3 */
ALTERNATE(B, 0x00C0, 1, MODULE_I2C, 0) /* I2C SLAVE:PB6/7 */
ALTERNATE(B, 0x6000, 5, MODULE_I2C, 0) /* I2C MASTER:PB13/14 */