From patchwork Fri Jun 21 18:27:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Belloni X-Patchwork-Id: 2763901 Return-Path: X-Original-To: patchwork-linux-fbdev@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id C82A0C0AB1 for ; Fri, 21 Jun 2013 18:27:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AB8CD20215 for ; Fri, 21 Jun 2013 18:27:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4F8062020F for ; Fri, 21 Jun 2013 18:27:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423508Ab3FUS14 (ORCPT ); Fri, 21 Jun 2013 14:27:56 -0400 Received: from mail.free-electrons.com ([94.23.35.102]:56854 "EHLO mail.free-electrons.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423383Ab3FUS14 (ORCPT ); Fri, 21 Jun 2013 14:27:56 -0400 Received: by mail.free-electrons.com (Postfix, from userid 106) id 9FC4A7CC; Fri, 21 Jun 2013 20:27:53 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-8.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from localhost (128-79-216-144.hfc.dyn.abo.bbox.fr [128.79.216.144]) by mail.free-electrons.com (Postfix) with ESMTPSA id 581BF76F; Fri, 21 Jun 2013 20:27:53 +0200 (CEST) From: Alexandre Belloni To: linux-fbdev@vger.kernel.org, Jean-Christophe PLAGNIOL-VILLARD Cc: jimwall@q.com, brian@crystalfontz.com, Maxime Ripard , linux-kernel@vger.kernel.org, Richard Purdie , Florian Tobias Schandinat , Alexandre Belloni Subject: [PATCH 1/2] fb: backlight: HX8357: Make IM pins optionnal Date: Fri, 21 Jun 2013 20:27:38 +0200 Message-Id: <1371839259-543-1-git-send-email-alexandre.belloni@free-electrons.com> X-Mailer: git-send-email 1.8.1.2 Sender: linux-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Maxime Ripard Signed-off-by: Alexandre Belloni Signed-off-by: Maxime Ripard --- drivers/video/backlight/hx8357.c | 53 +++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 22 deletions(-) diff --git a/drivers/video/backlight/hx8357.c b/drivers/video/backlight/hx8357.c index a0482b5..69f5672 100644 --- a/drivers/video/backlight/hx8357.c +++ b/drivers/video/backlight/hx8357.c @@ -76,6 +76,7 @@ struct hx8357_data { unsigned reset; struct spi_device *spi; int state; + u8 use_im_pins; }; static u8 hx8357_seq_power[] = { @@ -250,9 +251,11 @@ static int hx8357_lcd_init(struct lcd_device *lcdev) * Set the interface selection pins to SPI mode, with three * wires */ - gpio_set_value_cansleep(lcd->im_pins[0], 1); - gpio_set_value_cansleep(lcd->im_pins[1], 0); - gpio_set_value_cansleep(lcd->im_pins[2], 1); + if (lcd->use_im_pins) { + gpio_set_value_cansleep(lcd->im_pins[0], 1); + gpio_set_value_cansleep(lcd->im_pins[1], 0); + gpio_set_value_cansleep(lcd->im_pins[2], 1); + } /* Reset the screen */ gpio_set_value(lcd->reset, 1); @@ -424,26 +427,32 @@ static int hx8357_probe(struct spi_device *spi) return -EINVAL; } - for (i = 0; i < HX8357_NUM_IM_PINS; i++) { - lcd->im_pins[i] = of_get_named_gpio(spi->dev.of_node, - "im-gpios", i); - if (lcd->im_pins[i] == -EPROBE_DEFER) { - dev_info(&spi->dev, "GPIO requested is not here yet, deferring the probe\n"); - return -EPROBE_DEFER; - } - if (!gpio_is_valid(lcd->im_pins[i])) { - dev_err(&spi->dev, "Missing dt property: im-gpios\n"); - return -EINVAL; + if (of_find_property(spi->dev.of_node, "im-gpios", NULL)) { + lcd->use_im_pins = 1; + + for (i = 0; i < HX8357_NUM_IM_PINS; i++) { + lcd->im_pins[i] = of_get_named_gpio(spi->dev.of_node, + "im-gpios", i); + if (lcd->im_pins[i] == -EPROBE_DEFER) { + dev_info(&spi->dev, "GPIO requested is not here yet, deferring the probe\n"); + return -EPROBE_DEFER; + } + if (!gpio_is_valid(lcd->im_pins[i])) { + dev_err(&spi->dev, "Missing dt property: im-gpios\n"); + return -EINVAL; + } + + ret = devm_gpio_request_one(&spi->dev, lcd->im_pins[i], + GPIOF_OUT_INIT_LOW, + "im_pins"); + if (ret) { + dev_err(&spi->dev, "failed to request gpio %d: %d\n", + lcd->im_pins[i], ret); + return -EINVAL; + } } - - ret = devm_gpio_request_one(&spi->dev, lcd->im_pins[i], - GPIOF_OUT_INIT_LOW, "im_pins"); - if (ret) { - dev_err(&spi->dev, "failed to request gpio %d: %d\n", - lcd->im_pins[i], ret); - return -EINVAL; - } - } + } else + lcd->use_im_pins = 0; lcdev = lcd_device_register("mxsfb", &spi->dev, lcd, &hx8357_ops); if (IS_ERR(lcdev)) {