From: Lars Poeschel
This driver allows to use a lcd2s 20x4 character display from Modtronix
engineering as an auxdisplay charlcd device.
Signed-off-by: Lars Poeschel
---
Changes in v4:
- modtronix -> Modtronix
- Kconfig: remove "default n"
---
drivers/auxdisplay/Kconfig | 10 +
drivers/auxdisplay/Makefile | 1 +
drivers/auxdisplay/lcd2s.c | 409
3 files changed, 420 insertions(+)
create mode 100644 drivers/auxdisplay/lcd2s.c
diff --git a/drivers/auxdisplay/Kconfig b/drivers/auxdisplay/Kconfig
index a56171d1a1ba..96c8cdfce48d 100644
--- a/drivers/auxdisplay/Kconfig
+++ b/drivers/auxdisplay/Kconfig
@@ -173,6 +173,16 @@ config HT16K33
Say yes here to add support for Holtek HT16K33, RAM mapping 16*8
LED controller driver with keyscan.
+config LCD2S
+ tristate "lcd2s 20x4 character display over I2C console"
+ depends on I2C
+ select CHARLCD
+ help
+ This is a driver that lets you use the lcd2s 20x4 character display
+ from Modtronix engineering as a console output device. The display
+ is a simple single color character display. You have to connect it
+ to an I2C bus.
+
config ARM_CHARLCD
bool "ARM Ltd. Character LCD Driver"
depends on PLAT_VERSATILE
diff --git a/drivers/auxdisplay/Makefile b/drivers/auxdisplay/Makefile
index 7e8a8c3eb3c3..307771027c89 100644
--- a/drivers/auxdisplay/Makefile
+++ b/drivers/auxdisplay/Makefile
@@ -12,3 +12,4 @@ obj-$(CONFIG_IMG_ASCII_LCD) += img-ascii-lcd.o
obj-$(CONFIG_HD44780) += hd44780.o
obj-$(CONFIG_HT16K33) += ht16k33.o
obj-$(CONFIG_PARPORT_PANEL)+= panel.o
+obj-$(CONFIG_LCD2S)+= lcd2s.o
diff --git a/drivers/auxdisplay/lcd2s.c b/drivers/auxdisplay/lcd2s.c
new file mode 100644
index ..4b8c597a26fa
--- /dev/null
+++ b/drivers/auxdisplay/lcd2s.c
@@ -0,0 +1,409 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * console driver for LCD2S 4x20 character displays connected through i2c.
+ * The display also has a spi interface, but the driver does not support
+ * this yet.
+ *
+ * This is a driver allowing you to use a LCD2S 4x20 from modtronix
+ * engineering as auxdisplay character device.
+ *
+ * (C) 2019 by Lemonage Software GmbH
+ * Author: Lars Pöschel
+ * All rights reserved.
+ */
+#include
+#include
+#include
+#include
+#include
+
+#include "charlcd.h"
+
+#define LCD2S_CMD_CUR_MOVES_FWD0x09
+#define LCD2S_CMD_CUR_BLINK_OFF0x10
+#define LCD2S_CMD_CUR_UL_OFF 0x11
+#define LCD2S_CMD_DISPLAY_OFF 0x12
+#define LCD2S_CMD_CUR_BLINK_ON 0x18
+#define LCD2S_CMD_CUR_UL_ON0x19
+#define LCD2S_CMD_DISPLAY_ON 0x1a
+#define LCD2S_CMD_BACKLIGHT_OFF0x20
+#define LCD2S_CMD_BACKLIGHT_ON 0x28
+#define LCD2S_CMD_WRITE0x80
+#define LCD2S_CMD_MOV_CUR_RIGHT0x83
+#define LCD2S_CMD_MOV_CUR_LEFT 0x84
+#define LCD2S_CMD_SHIFT_RIGHT 0x85
+#define LCD2S_CMD_SHIFT_LEFT 0x86
+#define LCD2S_CMD_SHIFT_UP 0x87
+#define LCD2S_CMD_SHIFT_DOWN 0x88
+#define LCD2S_CMD_CUR_ADDR 0x89
+#define LCD2S_CMD_CUR_POS 0x8a
+#define LCD2S_CMD_CUR_RESET0x8b
+#define LCD2S_CMD_CLEAR0x8c
+#define LCD2S_CMD_DEF_CUSTOM_CHAR 0x92
+#define LCD2S_CMD_READ_STATUS 0xd0
+
+#define LCD2S_CHARACTER_SIZE 8
+
+#define LCD2S_STATUS_BUF_MASK 0x7f
+
+struct lcd2s_data {
+ struct i2c_client *i2c;
+ struct charlcd *charlcd;
+};
+
+static s32 lcd2s_wait_buf_free(const struct i2c_client *client, int count)
+{
+ s32 status;
+
+ status = i2c_smbus_read_byte_data(client, LCD2S_CMD_READ_STATUS);
+ if (status < 0)
+ return status;
+
+ while ((status & LCD2S_STATUS_BUF_MASK) < count) {
+ mdelay(1);
+ status = i2c_smbus_read_byte_data(client,
+ LCD2S_CMD_READ_STATUS);
+ if (status < 0)
+ return status;
+ }
+ return 0;
+}
+
+static int lcd2s_i2c_master_send(const struct i2c_client *client,
+const char *buf, int count)
+{
+ s32 status;
+
+ status = lcd2s_wait_buf_free(client, count);
+ if (status < 0)
+ return status;
+
+ return i2c_master_send(client, buf, count);
+}
+
+static int lcd2s_i2c_smbus_write_byte(const struct i2c_client *client, u8
value)
+{
+ s32 status;
+
+ status = lcd2s_wait_buf_free(client, 1);
+ if (status < 0)
+ return status;
+
+ return i2c_smbus_write_byte(client, value);
+}
+
+static int lcd2s_print(struct charlcd *lcd, int c)
+{
+ struct lcd2s_data *lcd2s = lcd->drvdata;
+ u8 buf[2] = { LCD2S_CMD_WRITE, c };
+
+ lcd2s_i2c_master_send(lcd2s->i2c, buf, s