mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2026-01-08 16:41:55 +00:00
board: ryu: Enable SPI access to Accel
Enable 3rd SPI port and use it to accel the accelerometer. BRANCH=smaug BUG=chrome-os-partner:42304 TEST=Check accel on SPI enabled Ryu board. Change-Id: If17eff36e2a3ea0fe59d6677aa41ba5f802e33b6 Signed-off-by: Gwendal Grignou <gwendal@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/288516
This commit is contained in:
committed by
ChromeOS Commit Bot
parent
feccc86686
commit
5abd6087d4
@@ -234,6 +234,25 @@ static void board_init(void)
|
||||
|
||||
/* Enable interrupts from BMI160 sensor. */
|
||||
gpio_enable_interrupt(GPIO_ACC_IRQ1);
|
||||
|
||||
/* Enable SPI for BMI160 */
|
||||
gpio_config_module(MODULE_SPI_MASTER, 1);
|
||||
|
||||
/* Set all four SPI3 pins to high speed */
|
||||
/* pins C10/C11/C12 */
|
||||
STM32_GPIO_OSPEEDR(GPIO_C) |= 0x03f00000;
|
||||
|
||||
/* pin A4 */
|
||||
STM32_GPIO_OSPEEDR(GPIO_A) |= 0x00000300;
|
||||
|
||||
/* Enable clocks to SPI3 module */
|
||||
STM32_RCC_APB1ENR |= STM32_RCC_PB1_SPI3;
|
||||
|
||||
/* Reset SPI3 */
|
||||
STM32_RCC_APB1RSTR |= STM32_RCC_PB1_SPI3;
|
||||
STM32_RCC_APB1RSTR &= ~STM32_RCC_PB1_SPI3;
|
||||
|
||||
spi_enable(CONFIG_SPI_ACCEL_PORT, 1);
|
||||
}
|
||||
DECLARE_HOOK(HOOK_INIT, board_init, HOOK_PRIO_DEFAULT);
|
||||
|
||||
@@ -292,6 +311,7 @@ const unsigned int i2c_ports_used = ARRAY_SIZE(i2c_ports);
|
||||
/* SPI devices */
|
||||
const struct spi_device_t spi_devices[] = {
|
||||
{ CONFIG_SPI_FLASH_PORT, 0, GPIO_SPI_FLASH_NSS},
|
||||
{ CONFIG_SPI_ACCEL_PORT, 1, GPIO_SPI3_NSS }
|
||||
};
|
||||
const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices);
|
||||
|
||||
@@ -327,7 +347,7 @@ struct motion_sensor_t motion_sensors[] = {
|
||||
.drv = &bmi160_drv,
|
||||
.mutex = &g_mutex,
|
||||
.drv_data = &g_bmi160_data,
|
||||
.addr = BMI160_ADDR0,
|
||||
.addr = 1,
|
||||
.rot_standard_ref = &accelgyro_standard_ref,
|
||||
.default_config = {
|
||||
.odr = 100000,
|
||||
@@ -344,7 +364,7 @@ struct motion_sensor_t motion_sensors[] = {
|
||||
.drv = &bmi160_drv,
|
||||
.mutex = &g_mutex,
|
||||
.drv_data = &g_bmi160_data,
|
||||
.addr = BMI160_ADDR0,
|
||||
.addr = 1,
|
||||
.rot_standard_ref = &accelgyro_standard_ref,
|
||||
.default_config = {
|
||||
.odr = 0,
|
||||
@@ -361,7 +381,7 @@ struct motion_sensor_t motion_sensors[] = {
|
||||
.drv = &bmi160_drv,
|
||||
.mutex = &g_mutex,
|
||||
.drv_data = &g_bmi160_data,
|
||||
.addr = BMI160_ADDR0,
|
||||
.addr = 1,
|
||||
.rot_standard_ref = &mag_standard_ref,
|
||||
.default_config = {
|
||||
.odr = 0,
|
||||
@@ -493,6 +513,7 @@ void usb_spi_board_enable(struct usb_spi_config const *config)
|
||||
gpio_set_flags(SPI_FLASH_DEVICE->gpio_cs, GPIO_OUT_HIGH);
|
||||
|
||||
/* Set all four SPI pins to high speed */
|
||||
/* pins B10/B14/B15 and B9 */
|
||||
STM32_GPIO_OSPEEDR(GPIO_B) |= 0xf03c0000;
|
||||
|
||||
/* Enable clocks to SPI2 module */
|
||||
|
||||
@@ -95,8 +95,8 @@
|
||||
#define I2C_PORT_CHARGER I2C_PORT_MASTER
|
||||
#define I2C_PORT_BATTERY I2C_PORT_MASTER
|
||||
#define I2C_PORT_LIGHTBAR I2C_PORT_MASTER
|
||||
#define I2C_PORT_ACCEL I2C_PORT_MASTER
|
||||
#define I2C_PORT_PERICOM I2C_PORT_MASTER
|
||||
|
||||
#define BMM150_I2C_ADDRESS BMM150_ADDR0
|
||||
|
||||
/* slave address for host commands */
|
||||
@@ -139,10 +139,13 @@
|
||||
/* Enable control of SPI over USB */
|
||||
#define CONFIG_SPI_FLASH_PORT 0 /* First SPI master port */
|
||||
#define CONFIG_USB_SPI
|
||||
|
||||
/* Enable Case Closed Debugging */
|
||||
#define CONFIG_CASE_CLOSED_DEBUG
|
||||
|
||||
/* Enable Accel over SPI */
|
||||
#define CONFIG_SPI_ACCEL_PORT 1 /* Second SPI master port */
|
||||
#define SPI_ACCEL_PORT_ID 1 /* stored at spi_ports[1] */
|
||||
|
||||
/* Sensor support */
|
||||
#define CONFIG_ACCELGYRO_BMI160
|
||||
#define CONFIG_MAG_BMI160_BMM150
|
||||
|
||||
@@ -31,10 +31,11 @@ GPIO(BTN_VOLU_L, PIN(A, 2), GPIO_INPUT | GPIO_PULL_UP)
|
||||
/* PD RX/TX */
|
||||
GPIO(USBC_CC1_PD, PIN(A, 1), GPIO_ANALOG)
|
||||
GPIO(USBC_CC2_PD, PIN(A, 3), GPIO_ANALOG)
|
||||
GPIO(USBC_CC_EN, PIN(A, 4), GPIO_OUT_LOW)
|
||||
GPIO(USBC_CC_EN, PIN(E, 7), GPIO_OUT_LOW)
|
||||
GPIO(USBC_CC_TX_DATA, PIN(A, 6), GPIO_OUT_LOW)
|
||||
GPIO(USBC_CC_TX_EN, PIN(D, 7), GPIO_OUT_LOW)
|
||||
|
||||
GPIO(SPI3_NSS, PIN(A, 4), GPIO_OUT_HIGH)
|
||||
#if 0
|
||||
/* Alternate functions */
|
||||
GPIO(USBC_TX_CLKOUT, PIN(B, 1), GPIO_OUT_LOW)
|
||||
@@ -109,7 +110,7 @@ GPIO(PERICOM_CLK_EN, PIN(C, 15), GPIO_OUT_HIGH)
|
||||
GPIO(USB_PU_EN_L, PIN(C, 2), GPIO_OUT_HIGH)
|
||||
GPIO(PD_DISABLE_DEBUG, PIN(C, 6), GPIO_OUT_LOW)
|
||||
GPIO(SPI_FLASH_NSS, PIN(B, 9), GPIO_INPUT)
|
||||
GPIO(VDDSPI_EN, PIN(C, 12), GPIO_OUT_LOW)
|
||||
GPIO(VDDSPI_EN, PIN(C, 15), GPIO_OUT_LOW)
|
||||
GPIO(SH_RESET, PIN(C, 4), GPIO_ODR_HIGH)
|
||||
GPIO(SH_BOOT, PIN(C, 9), GPIO_ODR_HIGH)
|
||||
GPIO(EC_INT_L, PIN(F, 2), GPIO_ODR_HIGH)
|
||||
@@ -120,21 +121,17 @@ GPIO(EC_BOOT_SPI_EN, PIN(F, 4), GPIO_ODR_HIGH)
|
||||
|
||||
#if 0
|
||||
/* Alternate functions */
|
||||
GPIO(SH_UART_TX, PIN(C, 11), GPIO_OUT_LOW)
|
||||
GPIO(SH_UART_RX, PIN(C, 10), GPIO_INPUT)
|
||||
GPIO(AP_UART_TX, PIN(B, 6), GPIO_OUT_LOW)
|
||||
GPIO(AP_UART_RX, PIN(B, 7), GPIO_INPUT)
|
||||
#endif
|
||||
|
||||
UNIMPLEMENTED(AP_RESET_L)
|
||||
|
||||
#define GPIO_ODR_UP GPIO_OPEN_DRAIN | GPIO_PULL_UP
|
||||
|
||||
ALTERNATE(PIN_MASK(C, 0x1C00), 6, MODULE_SPI_MASTER, 0) /* SPI3: PC10/PC11/PC12 */
|
||||
ALTERNATE(PIN_MASK(B, 0xC400), 5, MODULE_SPI_FLASH, 0) /* SPI2: PB10/14/15 */
|
||||
ALTERNATE(PIN_MASK(B, 0x0008), 5, MODULE_USB_PD, 0) /* SPI1: SCK(PB3) */
|
||||
ALTERNATE(PIN_MASK(B, 0x0002), 2, MODULE_USB_PD, 0) /* TIM3_CH4: PB1 */
|
||||
ALTERNATE(PIN_MASK(B, 0x00C0), 7, MODULE_USART, 0) /* USART1: PB6/PB7 */
|
||||
ALTERNATE(PIN_MASK(D, 0x0060), 7, MODULE_UART, GPIO_PULL_UP) /* USART2: PD4/PD5 */
|
||||
ALTERNATE(PIN_MASK(C, 0x0C00), 7, MODULE_USART, GPIO_ODR_UP) /* USART3: PC10/PC11 */
|
||||
ALTERNATE(PIN_MASK(A, 0xC600), 4, MODULE_I2C, 0) /* I2C SLAVE:PA9/10 MASTER:PA14/15 */
|
||||
ALTERNATE(PIN_MASK(A, 0x1800),14, MODULE_USB, 0) /* USB: PA11/12 */
|
||||
|
||||
Reference in New Issue
Block a user