From e85bc74b307365e9a7b4adab51d646638db12fbd Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Sat, 5 Jun 2021 00:12:01 +0100 Subject: x1000: GPIO refactor The GPIO API was pretty clunky and pin settings were decentralized, making it hard to see what was happening and making GPIO stuff look like a mess, frankly. Instead of passing clunky (port, pin) pairs everywhere, GPIOs are now identified with a single int. The extra overhead should be minimal as GPIO configuration is generally not on a performance-critical path. Pin assignments are now mostly consolidated in gpio-target.h and put in various tables so gpio_init() can assign most pins at boot time. Most drivers no longer need to touch GPIOs and basic pin I/O stuff can happen without config since pins are put into the right state. IRQ pins still need to be configured manually before use. Change-Id: Ic5326284b0b2a2f613e9e76a41cb50e24af3aa47 --- .../target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) (limited to 'firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c') diff --git a/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c b/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c index efc652c84f..47b5e3d6dc 100644 --- a/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c +++ b/firmware/target/mips/ingenic_x1000/fiiom3k/button-fiiom3k.c @@ -35,8 +35,6 @@ # include "font.h" #endif -#define FT_RST_PIN (1 << 15) -#define FT_INT_PIN (1 << 12) #define ft_interrupt GPIOB12 /* Touch event types */ @@ -389,11 +387,13 @@ static void ft_init(void) i2c_x1000_set_freq(FT6x06_BUS, I2C_FREQ_400K); /* Reset chip */ - gpio_config(GPIO_B, FT_RST_PIN|FT_INT_PIN, GPIO_OUTPUT(0)); + gpio_set_level(GPIO_FT6x06_RESET, 0); mdelay(5); - gpio_out_level(GPIO_B, FT_RST_PIN, 1); - gpio_config(GPIO_B, FT_INT_PIN, GPIO_IRQ_EDGE(0)); - gpio_enable_irq(GPIO_B, FT_INT_PIN); + gpio_set_level(GPIO_FT6x06_RESET, 1); + + /* Configure the interrupt pin */ + gpio_set_function(GPIO_FT6x06_INTERRUPT, GPIOF_IRQ_EDGE(0)); + gpio_enable_irq(GPIO_FT6x06_INTERRUPT); } void touchpad_set_sensitivity(int level) @@ -454,10 +454,6 @@ static void hp_detect_init(void) /* Rockbox interface */ void button_init_device(void) { - /* Configure physical button GPIOs */ - gpio_config(GPIO_A, (1 << 17) | (1 << 19), GPIO_INPUT); - gpio_config(GPIO_B, (1 << 28) | (1 << 31), GPIO_INPUT); - /* Initialize touchpad */ ft_init(); -- cgit v1.2.3