aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxime Ripard <maxime.ripard@free-electrons.com>2013-08-01 04:40:36 -0400
committerTomi Valkeinen <tomi.valkeinen@ti.com>2013-08-02 06:15:07 -0400
commitccf9901ffec4b41a3a5c22580c4a7d358d88ca9f (patch)
tree785c49ec8697824c8d9a644699f170ee06b5b756
parentdbb5ff4c2300474ac0b5993d98181b0437e73f9c (diff)
video: hx8357: Make IM pins optional
The IM pins of the HX8357 controller are used to define the interface used to feed pixel stream to the LCD panel. Most of the time, these pins are directly routed to either the ground or the VCC to set their values. Remove the need to assign GPIOs to these pins when we are in such a case. Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> Acked-by: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
-rw-r--r--drivers/video/backlight/hx8357.c52
1 files changed, 31 insertions, 21 deletions
diff --git a/drivers/video/backlight/hx8357.c b/drivers/video/backlight/hx8357.c
index a0482b567bfe..47237fa73b0c 100644
--- a/drivers/video/backlight/hx8357.c
+++ b/drivers/video/backlight/hx8357.c
@@ -76,6 +76,7 @@ struct hx8357_data {
76 unsigned reset; 76 unsigned reset;
77 struct spi_device *spi; 77 struct spi_device *spi;
78 int state; 78 int state;
79 bool use_im_pins;
79}; 80};
80 81
81static u8 hx8357_seq_power[] = { 82static u8 hx8357_seq_power[] = {
@@ -250,9 +251,11 @@ static int hx8357_lcd_init(struct lcd_device *lcdev)
250 * Set the interface selection pins to SPI mode, with three 251 * Set the interface selection pins to SPI mode, with three
251 * wires 252 * wires
252 */ 253 */
253 gpio_set_value_cansleep(lcd->im_pins[0], 1); 254 if (lcd->use_im_pins) {
254 gpio_set_value_cansleep(lcd->im_pins[1], 0); 255 gpio_set_value_cansleep(lcd->im_pins[0], 1);
255 gpio_set_value_cansleep(lcd->im_pins[2], 1); 256 gpio_set_value_cansleep(lcd->im_pins[1], 0);
257 gpio_set_value_cansleep(lcd->im_pins[2], 1);
258 }
256 259
257 /* Reset the screen */ 260 /* Reset the screen */
258 gpio_set_value(lcd->reset, 1); 261 gpio_set_value(lcd->reset, 1);
@@ -424,25 +427,32 @@ static int hx8357_probe(struct spi_device *spi)
424 return -EINVAL; 427 return -EINVAL;
425 } 428 }
426 429
427 for (i = 0; i < HX8357_NUM_IM_PINS; i++) { 430 if (of_find_property(spi->dev.of_node, "im-gpios", NULL)) {
428 lcd->im_pins[i] = of_get_named_gpio(spi->dev.of_node, 431 lcd->use_im_pins = 1;
429 "im-gpios", i); 432
430 if (lcd->im_pins[i] == -EPROBE_DEFER) { 433 for (i = 0; i < HX8357_NUM_IM_PINS; i++) {
431 dev_info(&spi->dev, "GPIO requested is not here yet, deferring the probe\n"); 434 lcd->im_pins[i] = of_get_named_gpio(spi->dev.of_node,
432 return -EPROBE_DEFER; 435 "im-gpios", i);
433 } 436 if (lcd->im_pins[i] == -EPROBE_DEFER) {
434 if (!gpio_is_valid(lcd->im_pins[i])) { 437 dev_info(&spi->dev, "GPIO requested is not here yet, deferring the probe\n");
435 dev_err(&spi->dev, "Missing dt property: im-gpios\n"); 438 return -EPROBE_DEFER;
436 return -EINVAL; 439 }
437 } 440 if (!gpio_is_valid(lcd->im_pins[i])) {
438 441 dev_err(&spi->dev, "Missing dt property: im-gpios\n");
439 ret = devm_gpio_request_one(&spi->dev, lcd->im_pins[i], 442 return -EINVAL;
440 GPIOF_OUT_INIT_LOW, "im_pins"); 443 }
441 if (ret) { 444
442 dev_err(&spi->dev, "failed to request gpio %d: %d\n", 445 ret = devm_gpio_request_one(&spi->dev, lcd->im_pins[i],
443 lcd->im_pins[i], ret); 446 GPIOF_OUT_INIT_LOW,
444 return -EINVAL; 447 "im_pins");
448 if (ret) {
449 dev_err(&spi->dev, "failed to request gpio %d: %d\n",
450 lcd->im_pins[i], ret);
451 return -EINVAL;
452 }
445 } 453 }
454 } else {
455 lcd->use_im_pins = 0;
446 } 456 }
447 457
448 lcdev = lcd_device_register("mxsfb", &spi->dev, lcd, &hx8357_ops); 458 lcdev = lcd_device_register("mxsfb", &spi->dev, lcd, &hx8357_ops);