From patchwork Fri Jan 13 10:35:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jyri Sarha X-Patchwork-Id: 9515007 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 83D70601E5 for ; Fri, 13 Jan 2017 10:36:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7B598285E5 for ; Fri, 13 Jan 2017 10:36:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7033728607; Fri, 13 Jan 2017 10:36:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 14AB7285E5 for ; Fri, 13 Jan 2017 10:36:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751413AbdAMKgI (ORCPT ); Fri, 13 Jan 2017 05:36:08 -0500 Received: from lelnx194.ext.ti.com ([198.47.27.80]:32982 "EHLO lelnx194.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751356AbdAMKgH (ORCPT ); Fri, 13 Jan 2017 05:36:07 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id v0DAa0xm017045; Fri, 13 Jan 2017 04:36:00 -0600 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id v0DAa0L5026283; Fri, 13 Jan 2017 04:36:00 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.294.0; Fri, 13 Jan 2017 04:35:59 -0600 Received: from jadmar.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id v0DAZpd3004480; Fri, 13 Jan 2017 04:35:58 -0600 From: Jyri Sarha To: , , CC: , , , , Jyri Sarha Subject: [PATCH v2 3/5] fbdev: ssd1307fb: Make reset gpio devicetree property optional Date: Fri, 13 Jan 2017 12:35:47 +0200 Message-ID: <5745ec4b4e5156ae7c7684fce4c7086f91e67c1f.1484303628.git.jsarha@ti.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: MIME-Version: 1.0 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 Make reset gpio devicetree property optional. Depending on the board designing there may not be a dedicated gpio for resetting the display. Without a proper reset there may be some junk in the display memory at probe time, so in such a case the display memory is cleared before turning it on. The devicetree binding document is also updated. Signed-off-by: Jyri Sarha --- .../devicetree/bindings/display/ssd1307fb.txt | 4 ++-- drivers/video/fbdev/ssd1307fb.c | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Documentation/devicetree/bindings/display/ssd1307fb.txt b/Documentation/devicetree/bindings/display/ssd1307fb.txt index 4aee67f..6617df6 100644 --- a/Documentation/devicetree/bindings/display/ssd1307fb.txt +++ b/Documentation/devicetree/bindings/display/ssd1307fb.txt @@ -8,14 +8,14 @@ Required properties: 0x3c or 0x3d - pwm: Should contain the pwm to use according to the OF device tree PWM specification [0]. Only required for the ssd1307. - - reset-gpios: Should contain the GPIO used to reset the OLED display. See - Documentation/devicetree/bindings/gpio/gpio.txt for details. - solomon,height: Height in pixel of the screen driven by the controller - solomon,width: Width in pixel of the screen driven by the controller - solomon,page-offset: Offset of pages (band of 8 pixels) that the screen is mapped to. Optional properties: + - reset-gpios: The GPIO used to reset the OLED display, if available. See + Documentation/devicetree/bindings/gpio/gpio.txt for details. - solomon,segment-no-remap: Display needs normal (non-inverted) data column to segment mapping - solomon,com-seq: Display uses sequential COM pin configuration diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c index 8ffaaee..89372af 100644 --- a/drivers/video/fbdev/ssd1307fb.c +++ b/drivers/video/fbdev/ssd1307fb.c @@ -439,6 +439,10 @@ static int ssd1307fb_init(struct ssd1307fb_par *par) if (ret < 0) return ret; + /* Clear the screen if we could not give reset at probe time */ + if (!par->reset) + ssd1307fb_update_display(par); + /* Turn on the display */ ret = ssd1307fb_write_cmd(par->client, SSD1307FB_DISPLAY_ON); if (ret < 0) @@ -561,7 +565,8 @@ static int ssd1307fb_probe(struct i2c_client *client, par->device_info = of_device_get_match_data(&client->dev); - par->reset = devm_gpiod_get(&client->dev, "reset", GPIOD_OUT_LOW); + par->reset = devm_gpiod_get_optional(&client->dev, "reset", + GPIOD_OUT_LOW); if (IS_ERR(par->reset)) { dev_err(&client->dev, "failed to get reset gpio: %ld\n", PTR_ERR(par->reset)); @@ -645,11 +650,13 @@ static int ssd1307fb_probe(struct i2c_client *client, i2c_set_clientdata(client, info); - /* Reset the screen */ - gpiod_set_value(par->reset, 0); - udelay(4); - gpiod_set_value(par->reset, 1); - udelay(4); + if (par->reset) { + /* Reset the screen */ + gpiod_set_value(par->reset, 0); + udelay(4); + gpiod_set_value(par->reset, 1); + udelay(4); + } ret = ssd1307fb_init(par); if (ret)