summaryrefslogtreecommitdiff
path: root/board/hammer
diff options
context:
space:
mode:
authorWei-Han Chen <stimim@google.com>2018-03-12 20:04:46 +0800
committerchrome-bot <chrome-bot@chromium.org>2018-03-26 23:33:33 -0700
commit225e6815a9dd44ebaca841262d854391a5dfa91d (patch)
tree080d641c2a07d94bf887c983d5b97d9d884fb4b6 /board/hammer
parentd8225540d9acbb26e29df6b5555090bc5b48579e (diff)
downloadchrome-ec-225e6815a9dd44ebaca841262d854391a5dfa91d.tar.gz
whiskers: enable ST touchpad
BRANCH=whiskers BUG=b:70482333 TEST=make BOARD=whiskers Signed-off-by: Wei-Han Chen <stimim@chromium.org> Change-Id: I8a5ef6796a60706da539dd80fb03a379f1aa8d38 Reviewed-on: https://chromium-review.googlesource.com/958895 Commit-Ready: Wei-Han Chen <stimim@chromium.org> Tested-by: Wei-Han Chen <stimim@chromium.org> Reviewed-by: Nicolas Boichat <drinkcat@chromium.org>
Diffstat (limited to 'board/hammer')
-rw-r--r--board/hammer/board.c39
-rw-r--r--board/hammer/board.h33
2 files changed, 61 insertions, 11 deletions
diff --git a/board/hammer/board.c b/board/hammer/board.c
index a7ccbf5e87..54c5305eb9 100644
--- a/board/hammer/board.c
+++ b/board/hammer/board.c
@@ -4,6 +4,7 @@
*/
/* Hammer board configuration */
+#include "clock.h"
#include "common.h"
#include "driver/led/lm3630a.h"
#include "ec_version.h"
@@ -22,6 +23,7 @@
#include "queue_policies.h"
#include "registers.h"
#include "rollback.h"
+#include "spi.h"
#include "system.h"
#include "task.h"
#include "touchpad.h"
@@ -33,6 +35,7 @@
#include "usb_api.h"
#include "usb_descriptor.h"
#include "usb_i2c.h"
+#include "usb_spi.h"
#include "util.h"
#include "gpio_list.h"
@@ -66,6 +69,18 @@ BUILD_ASSERT(ARRAY_SIZE(usb_strings) == USB_STR_COUNT);
*/
#ifdef SECTION_IS_RW
+#ifdef BOARD_WHISKERS
+/* SPI devices */
+const struct spi_device_t spi_devices[] = {
+ [SPI_ST_TP_DEVICE_ID] = { CONFIG_SPI_TOUCHPAD_PORT, 2, GPIO_SPI1_NSS },
+};
+const unsigned int spi_devices_used = ARRAY_SIZE(spi_devices);
+
+USB_SPI_CONFIG(usb_spi, USB_IFACE_I2C_SPI, USB_EP_I2C_SPI);
+/* SPI interface is always enabled, no need to do anything. */
+void usb_spi_board_enable(struct usb_spi_config const *config) {}
+void usb_spi_board_disable(struct usb_spi_config const *config) {}
+#endif /* !BOARD_WHISKERS */
/* I2C ports */
const struct i2c_port_t i2c_ports[] = {
@@ -177,6 +192,26 @@ static void board_init(void)
#ifdef BOARD_WHISKERS
lm3630a_poweron();
+ spi_enable(CONFIG_SPI_TOUCHPAD_PORT, 0);
+
+ /* Disable SPI passthrough when the system is locked */
+ usb_spi_enable(&usb_spi, system_is_locked());
+
+ /* Set all four SPI pins to high speed */
+ /* pins B3/5, A15 */
+ STM32_GPIO_OSPEEDR(GPIO_B) |= 0x00000cc0;
+ STM32_GPIO_OSPEEDR(GPIO_A) |= 0xc0000000;
+
+ /* Reset SPI1 */
+ STM32_RCC_APB2RSTR |= STM32_RCC_PB2_SPI1;
+ STM32_RCC_APB2RSTR &= ~STM32_RCC_PB2_SPI1;
+ /* Enable clocks to SPI1 module */
+ STM32_RCC_APB2ENR |= STM32_RCC_PB2_SPI1;
+
+ clock_wait_bus_cycles(BUS_APB, 1);
+ /* Enable SPI for touchpad */
+ gpio_config_module(MODULE_SPI_MASTER, 1);
+ spi_enable(CONFIG_SPI_TOUCHPAD_PORT, 1);
#endif /* BOARD_WHISKERS */
#endif /* SECTION_IS_RW */
}
@@ -231,9 +266,9 @@ void board_touchpad_reset(void)
{
#ifdef BOARD_WHISKERS
gpio_set_level(GPIO_EN_PP3300_TP, 0);
- msleep(10);
+ msleep(100);
gpio_set_level(GPIO_EN_PP3300_TP, 1);
- msleep(10);
+ msleep(100);
#else
gpio_set_level(GPIO_EN_PP3300_TP_ODL, 1);
msleep(10);
diff --git a/board/hammer/board.h b/board/hammer/board.h
index b299201cd0..910e951d11 100644
--- a/board/hammer/board.h
+++ b/board/hammer/board.h
@@ -114,7 +114,8 @@
#define USB_IFACE_HID_KEYBOARD 0
#define USB_IFACE_UPDATE 1
#define USB_IFACE_HID_TOUCHPAD 2
-#define USB_IFACE_I2C 3
+/* Can be either I2C or SPI passthrough, depending on the board. */
+#define USB_IFACE_I2C_SPI 3
#define USB_IFACE_COUNT 4
#else
#define USB_IFACE_UPDATE 0
@@ -127,7 +128,8 @@
#ifdef SECTION_IS_RW
#define USB_EP_HID_KEYBOARD 2
#define USB_EP_HID_TOUCHPAD 3
-#define USB_EP_I2C 4
+/* Can be either I2C or SPI passthrough, depending on the board. */
+#define USB_EP_I2C_SPI 4
#define USB_EP_COUNT 5
#else
#define USB_EP_COUNT 2
@@ -180,12 +182,11 @@
#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_Y 581 /* tenth of mm */
#define CONFIG_TOUCHPAD_VIRTUAL_SIZE (56*1024)
#elif defined(BOARD_WHISKERS)
-/* TODO(b:68934906): Add support for touchpad and replace these values. */
-#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_X 3000
-#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_Y 1500
+#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_X 2160
+#define CONFIG_USB_HID_TOUCHPAD_LOGICAL_MAX_Y 1080
#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_X 1000 /* tenth of mm */
#define CONFIG_USB_HID_TOUCHPAD_PHYSICAL_MAX_Y 500 /* tenth of mm */
-#define CONFIG_TOUCHPAD_VIRTUAL_SIZE (48*1024)
+#define CONFIG_TOUCHPAD_VIRTUAL_SIZE (128*1024)
#else
#error "No touchpad information for board."
#endif
@@ -200,8 +201,6 @@
/* Keyboard output port list */
#define KB_OUT_PORT_LIST GPIO_A, GPIO_B, GPIO_C, GPIO_F
-/* Enable control of I2C over USB */
-#define CONFIG_USB_I2C
#define CONFIG_I2C
#define CONFIG_I2C_MASTER
#define I2C_PORT_MASTER 0
@@ -215,13 +214,29 @@
#define CONFIG_LED_DRIVER_LM3630A
#define CONFIG_LID_SWITCH
#define CONFIG_USB_INHIBIT_CONNECT
-#endif
+/* Enable control of SPI over USB */
+#define CONFIG_USB_SPI
+#define CONFIG_SPI_MASTER
+#define CONFIG_SPI_HALFDUPLEX
+#define CONFIG_STM32_SPI1_MASTER
+#define CONFIG_SPI_TOUCHPAD_PORT 0
+#define SPI_ST_TP_DEVICE_ID 0
+/* Enable SPI master xfer command */
+#define CONFIG_CMD_SPI_XFER
+#define CONFIG_TOUCHPAD
+#define CONFIG_TOUCHPAD_ST
+#else /* !BOARD_WHISKERS */
+/* Enable control of I2C over USB */
+#define CONFIG_USB_I2C
+#define USB_IFACE_I2C USB_IFACE_I2C_SPI
+#define USB_EP_I2C USB_EP_I2C_SPI
/* Enable Elan touchpad driver */
#define CONFIG_TOUCHPAD
#define CONFIG_TOUCHPAD_ELAN
#define CONFIG_TOUCHPAD_I2C_PORT I2C_PORT_MASTER
#define CONFIG_TOUCHPAD_I2C_ADDR (0x15 << 1)
+#endif /* BOARD_WHISKERS */
#define CONFIG_CURVE25519