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 --- .../mips/ingenic_x1000/fiiom3k/lcd-fiiom3k.c | 25 ++++++++++++++-------- 1 file changed, 16 insertions(+), 9 deletions(-) (limited to 'firmware/target/mips/ingenic_x1000/fiiom3k/lcd-fiiom3k.c') diff --git a/firmware/target/mips/ingenic_x1000/fiiom3k/lcd-fiiom3k.c b/firmware/target/mips/ingenic_x1000/fiiom3k/lcd-fiiom3k.c index 96f794d7df..29e72286ff 100644 --- a/firmware/target/mips/ingenic_x1000/fiiom3k/lcd-fiiom3k.c +++ b/firmware/target/mips/ingenic_x1000/fiiom3k/lcd-fiiom3k.c @@ -25,9 +25,6 @@ #include "gpio-x1000.h" #include "system.h" -#define CS_PIN (1 << 18) -#define RD_PIN (1 << 16) - static const uint32_t fiio_lcd_cmd_enable[] = { /* Software reset */ LCD_INSTR_CMD, 0x01, @@ -169,17 +166,27 @@ const struct lcd_tgt_config lcd_tgt_config = { void lcd_tgt_enable(bool enable) { if(enable) { - gpio_config(GPIO_A, 0xffff, GPIO_DEVICE(1)); - gpio_config(GPIO_B, 0x1f << 16, GPIO_DEVICE(1)); - gpio_config(GPIO_B, CS_PIN|RD_PIN, GPIO_OUTPUT(1)); + /* reset controller, probably */ + gpio_set_level(GPIO_LCD_CE, 1); + gpio_set_level(GPIO_LCD_RD, 1); mdelay(5); - gpio_out_level(GPIO_B, CS_PIN, 0); + gpio_set_level(GPIO_LCD_CE, 0); + + /* set the clock whatever it is... */ lcd_set_clock(X1000_CLK_SCLK_A, 30000000); + + /* program the initial configuration */ lcd_exec_commands(&fiio_lcd_cmd_enable[0]); } else { + /* go to sleep mode first */ lcd_exec_commands(&fiio_lcd_cmd_sleep[0]); - mdelay(115); /* ensure we wait a total of 120ms before power off */ - gpio_config(GPIO_B, CS_PIN|RD_PIN, 0); + + /* ensure we wait a total of 120ms before power off */ + mdelay(115); + + /* this is intended to power off the panel but I'm not sure it does */ + gpio_set_level(GPIO_LCD_CE, 0); + gpio_set_level(GPIO_LCD_RD, 0); } } -- cgit v1.2.3