diff options
-rw-r--r-- | board/cr50/board.c | 40 | ||||
-rw-r--r-- | board/cr50/gpio.inc | 44 |
2 files changed, 4 insertions, 80 deletions
diff --git a/board/cr50/board.c b/board/cr50/board.c index 6fe7aa06b2..7770474904 100644 --- a/board/cr50/board.c +++ b/board/cr50/board.c @@ -28,46 +28,6 @@ BUILD_ASSERT((flags & GPIO_INT_BOTH) != GPIO_INT_BOTH); #include "gpio.wrap" -#ifdef CONFIG_USB_HID -static void send_hid_event(void) -{ - uint64_t rpt = 0; - uint8_t *key_ptr = (void *)&rpt + 2; - /* Convert SW_N/SW_S/SW_W/SW_E to A,B,C,D keys */ - if (gpio_get_level(GPIO_SW_N)) - *key_ptr++ = 0x04; /* A keycode */ - if (gpio_get_level(GPIO_SW_S)) - *key_ptr++ = 0x05; /* B keycode */ - if (gpio_get_level(GPIO_SW_W)) - *key_ptr++ = 0x06; /* C keycode */ - if (gpio_get_level(GPIO_SW_E)) - *key_ptr++ = 0x07; /* D keycode */ - /* send the keyboard state over USB HID */ - set_keyboard_report(rpt); - /* check release in the future */ - hook_call_deferred(send_hid_event, 40); -} -DECLARE_DEFERRED(send_hid_event); -#endif - -/* Interrupt handler for button pushes */ -void button_event(enum gpio_signal signal) -{ - int v; - - /* We have two GPIOs on the same input (one rising edge, one falling - * edge), so de-alias them */ - if (signal >= GPIO_SW_N_) - signal -= (GPIO_SW_N_ - GPIO_SW_N); - - v = gpio_get_level(signal); -#ifdef CONFIG_USB_HID - send_hid_event(); -#endif - ccprintf("Button %d = %d\n", signal, v); - gpio_set_level(signal - GPIO_SW_N + GPIO_LED_4, v); -} - static void init_pmu(void) { /* This boot sequence may be a result of previous soft reset, diff --git a/board/cr50/gpio.inc b/board/cr50/gpio.inc index 57c52446e5..88f0ae1418 100644 --- a/board/cr50/gpio.inc +++ b/board/cr50/gpio.inc @@ -4,30 +4,12 @@ * found in the LICENSE file. */ +/* Declare symbolic names for all the GPIOs that we care about */ /* Inputs with interrupt handlers are first for efficiency */ -/* User Push buttons */ -GPIO_INT(SW_N, PIN(0, 0), GPIO_INT_RISING, button_event) -GPIO_INT(SW_S, PIN(0, 1), GPIO_INT_RISING, button_event) -GPIO_INT(SW_W, PIN(0, 2), GPIO_INT_RISING, button_event) -GPIO_INT(SW_E, PIN(0, 3), GPIO_INT_RISING, button_event) - -/* We can't trigger on both rising and falling edge, so attach each button - * to two input GPIOs. */ -GPIO_INT(SW_N_, PIN(1, 0), GPIO_INT_FALLING, button_event) -GPIO_INT(SW_S_, PIN(1, 1), GPIO_INT_FALLING, button_event) -GPIO_INT(SW_W_, PIN(1, 2), GPIO_INT_FALLING, button_event) -GPIO_INT(SW_E_, PIN(1, 3), GPIO_INT_FALLING, button_event) - -/* User GPIO LEDs */ -GPIO(LED_2, PIN(0, 4), GPIO_OUT_LOW) -GPIO(LED_3, PIN(0, 5), GPIO_OUT_LOW) -GPIO(LED_4, PIN(0, 6), GPIO_OUT_LOW) -GPIO(LED_5, PIN(0, 7), GPIO_OUT_LOW) -GPIO(LED_6, PIN(0, 8), GPIO_OUT_LOW) -GPIO(LED_7, PIN(0, 9), GPIO_OUT_LOW) /* Unimplemented signals which we need to emulate for now */ +/* TODO(wfrichar): Half the boards don't use this signal. Take it out. */ UNIMPLEMENTED(ENTERING_RW) /* @@ -40,25 +22,7 @@ UNIMPLEMENTED(ENTERING_RW) #endif /* The serial port is one of the SoC peripheral functions */ -PINMUX(FUNC(UART0_TX), A0, DIO_OUTPUT) -PINMUX(FUNC(UART0_RX), A1, DIO_INPUT) - -/* Inputs */ -PINMUX(GPIO(SW_N), M0, 0) -PINMUX(GPIO(SW_S), M1, 0) -PINMUX(GPIO(SW_W), M2, 0) -PINMUX(GPIO(SW_E), M3, 0) - -/* Aliased Inputs, connected to the same pins */ -PINMUX(GPIO(SW_N_), M0, 0) -PINMUX(GPIO(SW_S_), M1, 0) -PINMUX(GPIO(SW_W_), M2, 0) -PINMUX(GPIO(SW_E_), M3, 0) - -/* Outputs - also mark as inputs so we can read back from the driven pin */ -PINMUX(GPIO(LED_2), A9, DIO_INPUT) -PINMUX(GPIO(LED_4), A11, DIO_INPUT) -PINMUX(GPIO(LED_6), A13, DIO_INPUT) -PINMUX(GPIO(LED_7), A14, DIO_INPUT) +PINMUX(FUNC(UART0_TX), A0, DIO_OUTPUT) /* bootrom sets this already */ +PINMUX(FUNC(UART0_RX), A1, DIO_INPUT) /* we need to set this */ #undef PINMUX |