Skip to content

Commit

Permalink
ARM: 7898/1: sa1100: h3100: refactor LCD GPIO handling
Browse files Browse the repository at this point in the history
As GPIOs are going to move to platform device, there is no guarantee
that they will be available at init_machine time.

Request all GPIOs directly in lcd_power callback and not at init_machine
time.

Signed-off-by: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
  • Loading branch information
Dmitry Eremin-Solenikov authored and Russell King committed Dec 12, 2013
1 parent 22564bd commit 5f72d85
Showing 1 changed file with 27 additions and 8 deletions.
35 changes: 27 additions & 8 deletions arch/arm/mach-sa1100/h3100.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,35 @@
/*
* helper for sa1100fb
*/
static struct gpio h3100_lcd_gpio[] = {
{ H3100_GPIO_LCD_3V_ON, GPIOF_OUT_INIT_LOW, "LCD 3V" },
{ H3XXX_EGPIO_LCD_ON, GPIOF_OUT_INIT_LOW, "LCD ON" },
};

static bool h3100_lcd_request(void)
{
static bool h3100_lcd_ok;
int rc;

if (h3100_lcd_ok)
return true;

rc = gpio_request_array(h3100_lcd_gpio, ARRAY_SIZE(h3100_lcd_gpio));
if (rc)
pr_err("%s: can't request GPIOs\n", __func__);
else
h3100_lcd_ok = true;

return h3100_lcd_ok;
}

static void h3100_lcd_power(int enable)
{
if (!gpio_request(H3XXX_EGPIO_LCD_ON, "LCD ON")) {
gpio_set_value(H3100_GPIO_LCD_3V_ON, enable);
gpio_direction_output(H3XXX_EGPIO_LCD_ON, enable);
gpio_free(H3XXX_EGPIO_LCD_ON);
} else {
pr_err("%s: can't request H3XXX_EGPIO_LCD_ON\n", __func__);
}
if (!h3100_lcd_request())
return;

gpio_set_value(H3100_GPIO_LCD_3V_ON, enable);
gpio_set_value(H3XXX_EGPIO_LCD_ON, enable);
}

static struct sa1100fb_mach_info h3100_lcd_info = {
Expand Down Expand Up @@ -91,7 +111,6 @@ static struct gpio_default_state h3100_default_gpio[] = {
{ H3XXX_GPIO_COM_DCD, GPIO_MODE_IN, "COM DCD" },
{ H3XXX_GPIO_COM_CTS, GPIO_MODE_IN, "COM CTS" },
{ H3XXX_GPIO_COM_RTS, GPIO_MODE_OUT0, "COM RTS" },
{ H3100_GPIO_LCD_3V_ON, GPIO_MODE_OUT0, "LCD 3v" },
};

static void __init h3100_mach_init(void)
Expand Down

0 comments on commit 5f72d85

Please sign in to comment.