Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6638104ybc; Thu, 28 Nov 2019 02:57:42 -0800 (PST) X-Google-Smtp-Source: APXvYqwcjIn6tu0PYyPS6NguSg8ruCRT1pdtZkgo5zE37hGonbL6AXN6Y0eTuEs6sKXDeY69KA9h X-Received: by 2002:a17:906:9417:: with SMTP id q23mr54826915ejx.37.1574938662445; Thu, 28 Nov 2019 02:57:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574938662; cv=none; d=google.com; s=arc-20160816; b=dR3nW811lADSoZc6YZ5ITp+MVj+Zrq7KnkMOAPQacU7W72TCXMReyL2MXGsTj1DG0v C+f3loR4xg7MXdVclezGTJ16KbITlfmtC+lNWouKOfWtOlmWj1gL0qknK6UHPGaBIFeT 5i7iiiHnChVeG+/uLeMqJ1TOHdP8bSfSRMM69bdq1unAJ09xP+xent6EFteS3PoV0FGL RLs6ig7JM/6gNr+90B2Z4mcfeIca72dNI6nbGLIrpijXSRSI26c7zuSLFkFYWYC3ntmj tRsCnw2r2flyDOlIJOjILOgDBVVG2hPgxC7fR5HEoRFR8R2xeeR3ftENVM3SoQb6PK79 b8TQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1unqpUWHwx1IvEo3kX+J6A2gi0WGBW3A7wOvFx9/P0E=; b=wAVHNYKuFVnNSj10uMBgMOxaCxdiPe+pWAZETZggs8+qk0/gbLHWjOoPt1qOMmbaYO tIvSDz+xHHyHvU4M9J+ucLbAHxOZVOKT3CaNYIix/OLa7tyDplyCwJiy1eu1Z6AOfyjd B2nWfM/Ni0aX5MQQ4KWp3yKGtX3ybwUEI7D7SY2Dca4S4m4n+7v/xi5ikybPoobEvD72 WVbah+C9BZjxRiJ/0xf/2ttCCEFoGDUcUk9lYhDmB6V90UKT+YFR/HWuaoNEdj8fplFs 7YeP/iQsRSpK6FsFRTK6R+ibf5L9dUGdc/J2ulyYlTJhDm/9MxkV04lW0eJzFI4YlAbe J1SQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eCG+x0QC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ot30si230301ejb.155.2019.11.28.02.57.18; Thu, 28 Nov 2019 02:57:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=eCG+x0QC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726858AbfK1KzX (ORCPT + 99 others); Thu, 28 Nov 2019 05:55:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:34814 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726730AbfK1KzU (ORCPT ); Thu, 28 Nov 2019 05:55:20 -0500 Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2FB9F21787; Thu, 28 Nov 2019 10:55:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574938519; bh=lLJJ20+1Kf0z7RwaP9GF+SreDiq2IVYE6EiZ/qH42vk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eCG+x0QCcmY4hxoE5yZNhO9eZXUNLTq+yA4kI5gERhl590TU8MowUDCxaBhqzAJMy olzsEDlu7aa1K94vqqv6Ar7Bgv3A5MsOhbsa4yv+5m5CMgqKSp4LxAb+Wp14BZkV+Q C8MIVxlQxt9s43fQjCL8r65OB0g9gb8vHpROfZis= From: kbingham@kernel.org To: linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Rob Herring , Miguel Ojeda Sandonis , Simon Goda Cc: Kieran Bingham Subject: [PATCH 3/3] drivers: auxdisplay: Add JHD1313 I2C interface driver Date: Thu, 28 Nov 2019 10:55:08 +0000 Message-Id: <20191128105508.3916-4-kbingham@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191128105508.3916-1-kbingham@kernel.org> References: <20191128105508.3916-1-kbingham@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kieran Bingham Provide an auxdisplay driver for the JHD1313 as used by the Grove-LCD RGB Backlight module [0]. A datasheet for the JHD1214 is provided by seeed [1], which assumes that they are similar parts. The backlight for the Grove-LCD is already controllable with the PCA963x driver. [0] http://wiki.seeedstudio.com/Grove-LCD_RGB_Backlight/ [1] https://seeeddoc.github.io/Grove-LCD_RGB_Backlight/res/JHD1214Y_YG_1.0.pdf Signed-off-by: Simon Goda Signed-off-by: Kieran Bingham --- MAINTAINERS | 4 ++ drivers/auxdisplay/Kconfig | 12 ++++ drivers/auxdisplay/Makefile | 1 + drivers/auxdisplay/jhd1313.c | 111 +++++++++++++++++++++++++++++++++++ 4 files changed, 128 insertions(+) create mode 100644 drivers/auxdisplay/jhd1313.c diff --git a/MAINTAINERS b/MAINTAINERS index 8f075b866aaf..640f099ff7fb 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -8837,6 +8837,10 @@ S: Maintained F: Documentation/admin-guide/jfs.rst F: fs/jfs/ +JHD1313 LCD Dispaly driver +M: Kieran Bingham +F: drivers/auxdisplay/jhd1313.c + JME NETWORK DRIVER M: Guo-Fu Tseng L: netdev@vger.kernel.org diff --git a/drivers/auxdisplay/Kconfig b/drivers/auxdisplay/Kconfig index b8313a04422d..cfc61c1abdee 100644 --- a/drivers/auxdisplay/Kconfig +++ b/drivers/auxdisplay/Kconfig @@ -27,6 +27,18 @@ config HD44780 kernel and started at boot. If you don't understand what all this is about, say N. +config JHD1313 + tristate "JHD1313 Character LCD support" + depends on I2C + select CHARLCD + ---help--- + Enable support for Character LCDs using a JHD1313 controller on I2C. + The LCD is accessible through the /dev/lcd char device (10, 156). + This code can either be compiled as a module, or linked into the + kernel and started at boot. + This supports the LCD panel on the Grove 16x2 LCD series. + If you don't understand what all this is about, say N. + config KS0108 tristate "KS0108 LCD Controller" depends on PARPORT_PC diff --git a/drivers/auxdisplay/Makefile b/drivers/auxdisplay/Makefile index cf54b5efb07e..6e1405a61925 100644 --- a/drivers/auxdisplay/Makefile +++ b/drivers/auxdisplay/Makefile @@ -9,5 +9,6 @@ obj-$(CONFIG_KS0108) += ks0108.o obj-$(CONFIG_CFAG12864B) += cfag12864b.o cfag12864bfb.o obj-$(CONFIG_IMG_ASCII_LCD) += img-ascii-lcd.o obj-$(CONFIG_HD44780) += hd44780.o +obj-$(CONFIG_JHD1313) += jhd1313.o obj-$(CONFIG_HT16K33) += ht16k33.o obj-$(CONFIG_PARPORT_PANEL) += panel.o diff --git a/drivers/auxdisplay/jhd1313.c b/drivers/auxdisplay/jhd1313.c new file mode 100644 index 000000000000..abf270e128ac --- /dev/null +++ b/drivers/auxdisplay/jhd1313.c @@ -0,0 +1,111 @@ +// SPDX-License-Identifier: GPL-2.0+ + +/* + * JHD1313 I2C Character LCD driver for Linux. + * + * Kieran Bingham + */ + +#include +#include + +#include + +#include "charlcd.h" + +struct jhd1313 { + struct i2c_client *client; +}; + +static void jhd1313_write_cmd(struct charlcd *lcd, int cmd) +{ + struct jhd1313 *jhd = lcd->drvdata; + struct i2c_client *client = jhd->client; + + i2c_smbus_write_byte_data(client, 0x00, cmd); +} + +static void jhd1313_write_data(struct charlcd *lcd, int data) +{ + struct jhd1313 *jhd = lcd->drvdata; + struct i2c_client *client = jhd->client; + + i2c_smbus_write_byte_data(client, 0x40, data); +} + +static const struct charlcd_ops jhd1313_ops = { + .write_cmd = jhd1313_write_cmd, + .write_data = jhd1313_write_data, +}; + +static int jhd1313_probe(struct i2c_client *client) +{ + struct charlcd *lcd; + struct jhd1313 *jhd; + int ret; + + if (!i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) { + dev_err(&client->dev, "i2c_check_functionality error\n"); + return -EIO; + } + + lcd = charlcd_alloc(sizeof(struct jhd1313)); + if (!lcd) + return -ENOMEM; + + jhd = lcd->drvdata; + i2c_set_clientdata(client, lcd); + jhd->client = client; + + lcd->width = 16; + lcd->height = 2; + lcd->ifwidth = 8; + lcd->ops = &jhd1313_ops; + + ret = charlcd_register(lcd); + if (ret) { + charlcd_free(lcd); + dev_err(&client->dev, "Failed to register JHD1313"); + } + + return ret; +} + +static int jhd1313_remove(struct i2c_client *client) +{ + struct charlcd *lcd = i2c_get_clientdata(client); + + charlcd_unregister(lcd); + charlcd_free(lcd); + + return 0; +} + +static const struct i2c_device_id jhd1313_id[] = { + { "jhd1313", 0 }, + { }, +}; +MODULE_DEVICE_TABLE(i2c, jhd1313_id); + +static const struct of_device_id jhd1313_of_table[] = { + { .compatible = "jhd,jhd1313" }, + { /* sentinel */ } +}; +MODULE_DEVICE_TABLE(of, jhd1313_of_table); + +static struct i2c_driver jhd1313_driver = { + .driver = { + .name = "jhd1313", + .of_match_table = jhd1313_of_table, + }, + .probe_new = jhd1313_probe, + .remove = jhd1313_remove, + .id_table = jhd1313_id, +}; + +module_i2c_driver(jhd1313_driver); + +MODULE_DESCRIPTION("JHD1313 I2C Character LCD driver"); +MODULE_AUTHOR("Kieran Bingham "); +MODULE_LICENSE("GPL"); -- 2.20.1