mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-12-27 18:25:05 +00:00
cr50: Switch from ALTERNATE to PINMUX macros
Previously the g chip and cr50 board abused the ALTERNATE macro to encode the pinmux configuration. This switches them over to using a PINMUX macro that is designed for this purpose. Signed-off-by: Anton Staaf <robotboy@chromium.org> BRANCH=None BUG=None TEST=make buildall -j Change-Id: I5c1f70b7aa92d87cc105e672aa66aee7f267c9a2 Reviewed-on: https://chromium-review.googlesource.com/328823 Commit-Ready: Anton Staaf <robotboy@chromium.org> Tested-by: Anton Staaf <robotboy@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org>
This commit is contained in:
@@ -30,34 +30,35 @@ GPIO(LED_7, PIN(0, 9), GPIO_OUT_LOW)
|
||||
/* Unimplemented signals which we need to emulate for now */
|
||||
UNIMPLEMENTED(ENTERING_RW)
|
||||
|
||||
/* The Cr50 ARM core has no alternate functions, so we repurpose that
|
||||
* macro to describe the PINMUX setup. The args are
|
||||
*
|
||||
* 1. The ARM core GPIO or SoC peripheral function to connect
|
||||
* 2. The pinmux DIO pad to connect to
|
||||
* 3. <ignored>
|
||||
* 4. MODULE_GPIO, to prevent being called by gpio_config_module()
|
||||
* 5. flags to specify the direction if the GPIO isn't enough
|
||||
/*
|
||||
* If we are included by generic GPIO code that doesn't know about the PINMUX
|
||||
* macro we need to provide an empty definition so that the invocations don't
|
||||
* interfere with other GPIO processing.
|
||||
*/
|
||||
#ifndef PINMUX
|
||||
#define PINMUX(...)
|
||||
#endif
|
||||
|
||||
/* The serial port is one of the SoC peripheral functions */
|
||||
ALTERNATE(PIN_MASK(FUNC(UART0_TX), DIO(A0)), 0, MODULE_GPIO, DIO_OUTPUT)
|
||||
ALTERNATE(PIN_MASK(FUNC(UART0_RX), DIO(A1)), 0, MODULE_GPIO, DIO_INPUT)
|
||||
PINMUX(FUNC(UART0_TX), A0, DIO_OUTPUT)
|
||||
PINMUX(FUNC(UART0_RX), A1, DIO_INPUT)
|
||||
|
||||
/* Inputs */
|
||||
ALTERNATE(PIN_MASK(SW_N, DIO(M0)), 0, MODULE_GPIO, 0)
|
||||
ALTERNATE(PIN_MASK(SW_S, DIO(M1)), 0, MODULE_GPIO, 0)
|
||||
ALTERNATE(PIN_MASK(SW_W, DIO(M2)), 0, MODULE_GPIO, 0)
|
||||
ALTERNATE(PIN_MASK(SW_E, DIO(M3)), 0, MODULE_GPIO, 0)
|
||||
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 */
|
||||
ALTERNATE(PIN_MASK(SW_N_, DIO(M0)), 0, MODULE_GPIO, 0)
|
||||
ALTERNATE(PIN_MASK(SW_S_, DIO(M1)), 0, MODULE_GPIO, 0)
|
||||
ALTERNATE(PIN_MASK(SW_W_, DIO(M2)), 0, MODULE_GPIO, 0)
|
||||
ALTERNATE(PIN_MASK(SW_E_, DIO(M3)), 0, MODULE_GPIO, 0)
|
||||
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 */
|
||||
ALTERNATE(PIN_MASK(LED_2, DIO(A9)), 0, MODULE_GPIO, DIO_INPUT)
|
||||
ALTERNATE(PIN_MASK(LED_4, DIO(A11)), 0, MODULE_GPIO, DIO_INPUT)
|
||||
ALTERNATE(PIN_MASK(LED_6, DIO(A13)), 0, MODULE_GPIO, DIO_INPUT)
|
||||
ALTERNATE(PIN_MASK(LED_7, DIO(A14)), 0, MODULE_GPIO, DIO_INPUT)
|
||||
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)
|
||||
|
||||
#undef PINMUX
|
||||
|
||||
@@ -84,9 +84,25 @@ void gpio_set_alternate_function(uint32_t port, uint32_t mask, int func)
|
||||
/* This HW feature is not present in the Cr50 ARM core */
|
||||
}
|
||||
|
||||
struct pinmux {
|
||||
uint32_t signal;
|
||||
uint32_t dio;
|
||||
uint16_t flags;
|
||||
};
|
||||
|
||||
static void connect_pinmux(uint32_t signal, uint32_t dio, uint16_t flags)
|
||||
#define GPIO_GPIO(name) GPIO_##name
|
||||
#define PINMUX(signal, dio, flags) {GPIO_##signal, DIO(dio), flags},
|
||||
|
||||
static const struct pinmux pinmux_list[] = {
|
||||
#include "gpio.wrap"
|
||||
};
|
||||
|
||||
static void connect_pinmux(struct pinmux const *p)
|
||||
{
|
||||
uint32_t signal = p->signal;
|
||||
uint32_t dio = p->dio;
|
||||
uint16_t flags = p->flags;
|
||||
|
||||
if (flags & DIO_ENABLE_DIRECT_INPUT) {
|
||||
/* enable digital input for direct wired peripheral */
|
||||
REG_WRITE_MLV(DIO_CTL_REG(dio), DIO_CTL_IE_MASK,
|
||||
@@ -142,7 +158,6 @@ int gpio_disable_interrupt(enum gpio_signal signal)
|
||||
void gpio_pre_init(void)
|
||||
{
|
||||
const struct gpio_info *g = gpio_list;
|
||||
const struct gpio_alt_func *af = gpio_alt_funcs;
|
||||
|
||||
int i;
|
||||
|
||||
@@ -155,8 +170,8 @@ void gpio_pre_init(void)
|
||||
GC_PMU_PERICLKSET0_DGPIO1_CLK_LSB, 1);
|
||||
|
||||
/* Set up the pinmux */
|
||||
for (i = 0; i < gpio_alt_funcs_count; i++, af++)
|
||||
connect_pinmux(af->port, af->mask, af->flags);
|
||||
for (i = 0; i < ARRAY_SIZE(pinmux_list); i++)
|
||||
connect_pinmux(pinmux_list + i);
|
||||
|
||||
/* Set up ARM core GPIOs */
|
||||
for (i = 0; i < GPIO_COUNT; i++, g++)
|
||||
|
||||
Reference in New Issue
Block a user