From 6e8353525a1567494ebd141866a3cfa5791106e6 Mon Sep 17 00:00:00 2001 From: Russell King Date: Thu, 8 Sep 2016 17:35:29 +0100 Subject: ARM: sa1100/assabet: switch to using gpiod APIs for LCD control Switch to using gpiod APIs for controlling the LCD depth and power. Signed-off-by: Russell King --- arch/arm/mach-sa1100/assabet.c | 59 ++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 25 deletions(-) (limited to 'arch') diff --git a/arch/arm/mach-sa1100/assabet.c b/arch/arm/mach-sa1100/assabet.c index 84649207dbb9..5b4ed8cbba27 100644 --- a/arch/arm/mach-sa1100/assabet.c +++ b/arch/arm/mach-sa1100/assabet.c @@ -70,6 +70,9 @@ enum { #define machine_has_neponset() (0) #endif +/* The build phase of the hardware. This isn't detectable */ +#define assabet_phase() 4 + #define ASSABET_BCR_BASE 0xf1000000 #define ASSABET_BCR IOMEM(ASSABET_BCR_BASE) @@ -335,24 +338,20 @@ static struct mcp_plat_data assabet_mcp_data = { .codec_pdata = &assabet_ucb1x00_data, }; -static void assabet_lcd_set_visual(u32 visual) -{ - u_int is_true_color = visual == FB_VISUAL_TRUECOLOR; +static struct gpiod_lookup_table assabet_platform_gpio_table = { + .table = { + GPIO_LOOKUP("assabet", 10, "lcd-depth", GPIO_ACTIVE_HIGH), + GPIO_LOOKUP("assabet", 11, "lcd-on", GPIO_ACTIVE_HIGH), + { }, + }, +}; - if (machine_is_assabet()) { -#if 1 // phase 4 or newer Assabet's - if (is_true_color) - ASSABET_BCR_set(ASSABET_BCR_LCD_12RGB); - else - ASSABET_BCR_clear(ASSABET_BCR_LCD_12RGB); -#else - // older Assabet's - if (is_true_color) - ASSABET_BCR_clear(ASSABET_BCR_LCD_12RGB); - else - ASSABET_BCR_set(ASSABET_BCR_LCD_12RGB); -#endif - } +static struct gpio_desc *gpio_lcd_depth; +static struct gpio_desc *gpio_lcd_on; + +static void assabet_set_visual(u32 visual) +{ + gpiod_set_value(gpio_lcd_depth, visual == FB_VISUAL_TRUECOLOR); } #ifndef ASSABET_PAL_VIDEO @@ -373,10 +372,11 @@ static void assabet_lcd_power(int on) { if (on && 0) { msleep(500); - ASSABET_BCR_set(ASSABET_BCR_LCD_ON); + gpiod_set_value(gpio_lcd_on, 1); msleep(500); - } else - ASSABET_BCR_clear(ASSABET_BCR_LCD_ON); + } else { + gpiod_set_value(gpio_lcd_on, 0); + } } /* @@ -399,7 +399,7 @@ static struct sa1100fb_mach_info lq039q2ds54_info = { .backlight_power = assabet_lcd_backlight_power, .lcd_power = assabet_lcd_power, - .set_visual = assabet_lcd_set_visual, + .set_visual = assabet_set_visual, }; #else static void assabet_pal_backlight_power(int on) @@ -409,7 +409,6 @@ static void assabet_pal_backlight_power(int on) static void assabet_pal_power(int on) { - ASSABET_BCR_clear(ASSABET_BCR_LCD_ON); } static struct sa1100fb_mach_info pal_info = { @@ -425,7 +424,7 @@ static struct sa1100fb_mach_info pal_info = { .backlight_power = assabet_pal_backlight_power, .lcd_power = assabet_pal_power, - .set_visual = assabet_lcd_set_visual, + .set_visual = assabet_set_visual, }; #endif @@ -559,8 +558,13 @@ static struct gpiod_lookup_table assabet_uart3_gpio_table = { static void __init assabet_init(void) { + /* Assabets earler than Phase4 have an inverted signal */ + if (assabet_phase() < 4) + assabet_platform_gpio_table.table[0].flags = GPIO_ACTIVE_LOW; + gpiod_add_lookup_table(&assabet_uda1341_gpio_table); gpiod_add_lookup_table(&assabet_audio_gpio_table); + gpiod_add_lookup_table(&assabet_platform_gpio_table); /* * Ensure that the power supply is in "high power" mode. @@ -625,11 +629,16 @@ static void __init assabet_init(void) gpiod_add_lookup_table(&assabet_leds_gpio_table); gpio_led_register_device(-1, &assabet_leds_pdata); + gpio_lcd_depth = gpiod_get(NULL, "lcd-depth", GPIOD_OUT_HIGH); + gpio_lcd_on = gpiod_get(NULL, "lcd-on", GPIOD_OUT_LOW); + if (!IS_ERR(gpio_lcd_depth) && !IS_ERR(gpio_lcd_on)) { #ifndef ASSABET_PAL_VIDEO - sa11x0_register_lcd(&lq039q2ds54_info); + sa11x0_register_lcd(&lq039q2ds54_info); #else - sa11x0_register_lcd(&pal_video); + sa11x0_register_lcd(&pal_video); #endif + } + sa11x0_register_mtd(&assabet_flash_data, assabet_flash_resources, ARRAY_SIZE(assabet_flash_resources)); sa11x0_register_mcp(&assabet_mcp_data); -- cgit