xref: /linux/drivers/auxdisplay/arm-charlcd.c (revision 351f683b9823a3d1bffb6e2e3f381601aa0b2671)
1*351f683bSMiguel Ojeda // SPDX-License-Identifier: GPL-2.0
200846a44SAndy Shevchenko /*
300846a44SAndy Shevchenko  * Driver for the on-board character LCD found on some ARM reference boards
400846a44SAndy Shevchenko  * This is basically an Hitachi HD44780 LCD with a custom IP block to drive it
500846a44SAndy Shevchenko  * http://en.wikipedia.org/wiki/HD44780_Character_LCD
600846a44SAndy Shevchenko  * Currently it will just display the text "ARM Linux" and the linux version
700846a44SAndy Shevchenko  *
800846a44SAndy Shevchenko  * Author: Linus Walleij <triad@df.lth.se>
900846a44SAndy Shevchenko  */
1000846a44SAndy Shevchenko #include <linux/init.h>
1100846a44SAndy Shevchenko #include <linux/interrupt.h>
1200846a44SAndy Shevchenko #include <linux/platform_device.h>
1300846a44SAndy Shevchenko #include <linux/of.h>
1400846a44SAndy Shevchenko #include <linux/completion.h>
1500846a44SAndy Shevchenko #include <linux/delay.h>
1600846a44SAndy Shevchenko #include <linux/io.h>
1700846a44SAndy Shevchenko #include <linux/slab.h>
1800846a44SAndy Shevchenko #include <linux/workqueue.h>
1900846a44SAndy Shevchenko #include <generated/utsrelease.h>
2000846a44SAndy Shevchenko 
2100846a44SAndy Shevchenko #define DRIVERNAME "arm-charlcd"
2200846a44SAndy Shevchenko #define CHARLCD_TIMEOUT (msecs_to_jiffies(1000))
2300846a44SAndy Shevchenko 
2400846a44SAndy Shevchenko /* Offsets to registers */
2500846a44SAndy Shevchenko #define CHAR_COM	0x00U
2600846a44SAndy Shevchenko #define CHAR_DAT	0x04U
2700846a44SAndy Shevchenko #define CHAR_RD		0x08U
2800846a44SAndy Shevchenko #define CHAR_RAW	0x0CU
2900846a44SAndy Shevchenko #define CHAR_MASK	0x10U
3000846a44SAndy Shevchenko #define CHAR_STAT	0x14U
3100846a44SAndy Shevchenko 
3200846a44SAndy Shevchenko #define CHAR_RAW_CLEAR	0x00000000U
3300846a44SAndy Shevchenko #define CHAR_RAW_VALID	0x00000100U
3400846a44SAndy Shevchenko 
3500846a44SAndy Shevchenko /* Hitachi HD44780 display commands */
3600846a44SAndy Shevchenko #define HD_CLEAR			0x01U
3700846a44SAndy Shevchenko #define HD_HOME				0x02U
3800846a44SAndy Shevchenko #define HD_ENTRYMODE			0x04U
3900846a44SAndy Shevchenko #define HD_ENTRYMODE_INCREMENT		0x02U
4000846a44SAndy Shevchenko #define HD_ENTRYMODE_SHIFT		0x01U
4100846a44SAndy Shevchenko #define HD_DISPCTRL			0x08U
4200846a44SAndy Shevchenko #define HD_DISPCTRL_ON			0x04U
4300846a44SAndy Shevchenko #define HD_DISPCTRL_CURSOR_ON		0x02U
4400846a44SAndy Shevchenko #define HD_DISPCTRL_CURSOR_BLINK	0x01U
4500846a44SAndy Shevchenko #define HD_CRSR_SHIFT			0x10U
4600846a44SAndy Shevchenko #define HD_CRSR_SHIFT_DISPLAY		0x08U
4700846a44SAndy Shevchenko #define HD_CRSR_SHIFT_DISPLAY_RIGHT	0x04U
4800846a44SAndy Shevchenko #define HD_FUNCSET			0x20U
4900846a44SAndy Shevchenko #define HD_FUNCSET_8BIT			0x10U
5000846a44SAndy Shevchenko #define HD_FUNCSET_2_LINES		0x08U
5100846a44SAndy Shevchenko #define HD_FUNCSET_FONT_5X10		0x04U
5200846a44SAndy Shevchenko #define HD_SET_CGRAM			0x40U
5300846a44SAndy Shevchenko #define HD_SET_DDRAM			0x80U
5400846a44SAndy Shevchenko #define HD_BUSY_FLAG			0x80U
5500846a44SAndy Shevchenko 
5600846a44SAndy Shevchenko /**
57b1bf6119SMiguel Ojeda  * struct charlcd - Private data structure
5800846a44SAndy Shevchenko  * @dev: a pointer back to containing device
5900846a44SAndy Shevchenko  * @phybase: the offset to the controller in physical memory
6000846a44SAndy Shevchenko  * @physize: the size of the physical page
6100846a44SAndy Shevchenko  * @virtbase: the offset to the controller in virtual memory
6200846a44SAndy Shevchenko  * @irq: reserved interrupt number
6300846a44SAndy Shevchenko  * @complete: completion structure for the last LCD command
64b1bf6119SMiguel Ojeda  * @init_work: delayed work structure to initialize the display on boot
6500846a44SAndy Shevchenko  */
6600846a44SAndy Shevchenko struct charlcd {
6700846a44SAndy Shevchenko 	struct device *dev;
6800846a44SAndy Shevchenko 	u32 phybase;
6900846a44SAndy Shevchenko 	u32 physize;
7000846a44SAndy Shevchenko 	void __iomem *virtbase;
7100846a44SAndy Shevchenko 	int irq;
7200846a44SAndy Shevchenko 	struct completion complete;
7300846a44SAndy Shevchenko 	struct delayed_work init_work;
7400846a44SAndy Shevchenko };
7500846a44SAndy Shevchenko 
7600846a44SAndy Shevchenko static irqreturn_t charlcd_interrupt(int irq, void *data)
7700846a44SAndy Shevchenko {
7800846a44SAndy Shevchenko 	struct charlcd *lcd = data;
7900846a44SAndy Shevchenko 	u8 status;
8000846a44SAndy Shevchenko 
8100846a44SAndy Shevchenko 	status = readl(lcd->virtbase + CHAR_STAT) & 0x01;
8200846a44SAndy Shevchenko 	/* Clear IRQ */
8300846a44SAndy Shevchenko 	writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW);
8400846a44SAndy Shevchenko 	if (status)
8500846a44SAndy Shevchenko 		complete(&lcd->complete);
8600846a44SAndy Shevchenko 	else
8700846a44SAndy Shevchenko 		dev_info(lcd->dev, "Spurious IRQ (%02x)\n", status);
8800846a44SAndy Shevchenko 	return IRQ_HANDLED;
8900846a44SAndy Shevchenko }
9000846a44SAndy Shevchenko 
9100846a44SAndy Shevchenko 
9200846a44SAndy Shevchenko static void charlcd_wait_complete_irq(struct charlcd *lcd)
9300846a44SAndy Shevchenko {
9400846a44SAndy Shevchenko 	int ret;
9500846a44SAndy Shevchenko 
9600846a44SAndy Shevchenko 	ret = wait_for_completion_interruptible_timeout(&lcd->complete,
9700846a44SAndy Shevchenko 							CHARLCD_TIMEOUT);
9800846a44SAndy Shevchenko 	/* Disable IRQ after completion */
9900846a44SAndy Shevchenko 	writel(0x00, lcd->virtbase + CHAR_MASK);
10000846a44SAndy Shevchenko 
10100846a44SAndy Shevchenko 	if (ret < 0) {
10200846a44SAndy Shevchenko 		dev_err(lcd->dev,
10300846a44SAndy Shevchenko 			"wait_for_completion_interruptible_timeout() "
10400846a44SAndy Shevchenko 			"returned %d waiting for ready\n", ret);
10500846a44SAndy Shevchenko 		return;
10600846a44SAndy Shevchenko 	}
10700846a44SAndy Shevchenko 
10800846a44SAndy Shevchenko 	if (ret == 0) {
10900846a44SAndy Shevchenko 		dev_err(lcd->dev, "charlcd controller timed out "
11000846a44SAndy Shevchenko 			"waiting for ready\n");
11100846a44SAndy Shevchenko 		return;
11200846a44SAndy Shevchenko 	}
11300846a44SAndy Shevchenko }
11400846a44SAndy Shevchenko 
11500846a44SAndy Shevchenko static u8 charlcd_4bit_read_char(struct charlcd *lcd)
11600846a44SAndy Shevchenko {
11700846a44SAndy Shevchenko 	u8 data;
11800846a44SAndy Shevchenko 	u32 val;
11900846a44SAndy Shevchenko 	int i;
12000846a44SAndy Shevchenko 
12100846a44SAndy Shevchenko 	/* If we can, use an IRQ to wait for the data, else poll */
12200846a44SAndy Shevchenko 	if (lcd->irq >= 0)
12300846a44SAndy Shevchenko 		charlcd_wait_complete_irq(lcd);
12400846a44SAndy Shevchenko 	else {
12500846a44SAndy Shevchenko 		i = 0;
12600846a44SAndy Shevchenko 		val = 0;
12700846a44SAndy Shevchenko 		while (!(val & CHAR_RAW_VALID) && i < 10) {
12800846a44SAndy Shevchenko 			udelay(100);
12900846a44SAndy Shevchenko 			val = readl(lcd->virtbase + CHAR_RAW);
13000846a44SAndy Shevchenko 			i++;
13100846a44SAndy Shevchenko 		}
13200846a44SAndy Shevchenko 
13300846a44SAndy Shevchenko 		writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW);
13400846a44SAndy Shevchenko 	}
13500846a44SAndy Shevchenko 	msleep(1);
13600846a44SAndy Shevchenko 
13700846a44SAndy Shevchenko 	/* Read the 4 high bits of the data */
13800846a44SAndy Shevchenko 	data = readl(lcd->virtbase + CHAR_RD) & 0xf0;
13900846a44SAndy Shevchenko 
14000846a44SAndy Shevchenko 	/*
14100846a44SAndy Shevchenko 	 * The second read for the low bits does not trigger an IRQ
14200846a44SAndy Shevchenko 	 * so in this case we have to poll for the 4 lower bits
14300846a44SAndy Shevchenko 	 */
14400846a44SAndy Shevchenko 	i = 0;
14500846a44SAndy Shevchenko 	val = 0;
14600846a44SAndy Shevchenko 	while (!(val & CHAR_RAW_VALID) && i < 10) {
14700846a44SAndy Shevchenko 		udelay(100);
14800846a44SAndy Shevchenko 		val = readl(lcd->virtbase + CHAR_RAW);
14900846a44SAndy Shevchenko 		i++;
15000846a44SAndy Shevchenko 	}
15100846a44SAndy Shevchenko 	writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW);
15200846a44SAndy Shevchenko 	msleep(1);
15300846a44SAndy Shevchenko 
15400846a44SAndy Shevchenko 	/* Read the 4 low bits of the data */
15500846a44SAndy Shevchenko 	data |= (readl(lcd->virtbase + CHAR_RD) >> 4) & 0x0f;
15600846a44SAndy Shevchenko 
15700846a44SAndy Shevchenko 	return data;
15800846a44SAndy Shevchenko }
15900846a44SAndy Shevchenko 
16000846a44SAndy Shevchenko static bool charlcd_4bit_read_bf(struct charlcd *lcd)
16100846a44SAndy Shevchenko {
16200846a44SAndy Shevchenko 	if (lcd->irq >= 0) {
16300846a44SAndy Shevchenko 		/*
16400846a44SAndy Shevchenko 		 * If we'll use IRQs to wait for the busyflag, clear any
16500846a44SAndy Shevchenko 		 * pending flag and enable IRQ
16600846a44SAndy Shevchenko 		 */
16700846a44SAndy Shevchenko 		writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW);
16800846a44SAndy Shevchenko 		init_completion(&lcd->complete);
16900846a44SAndy Shevchenko 		writel(0x01, lcd->virtbase + CHAR_MASK);
17000846a44SAndy Shevchenko 	}
17100846a44SAndy Shevchenko 	readl(lcd->virtbase + CHAR_COM);
17200846a44SAndy Shevchenko 	return charlcd_4bit_read_char(lcd) & HD_BUSY_FLAG ? true : false;
17300846a44SAndy Shevchenko }
17400846a44SAndy Shevchenko 
17500846a44SAndy Shevchenko static void charlcd_4bit_wait_busy(struct charlcd *lcd)
17600846a44SAndy Shevchenko {
17700846a44SAndy Shevchenko 	int retries = 50;
17800846a44SAndy Shevchenko 
17900846a44SAndy Shevchenko 	udelay(100);
18000846a44SAndy Shevchenko 	while (charlcd_4bit_read_bf(lcd) && retries)
18100846a44SAndy Shevchenko 		retries--;
18200846a44SAndy Shevchenko 	if (!retries)
18300846a44SAndy Shevchenko 		dev_err(lcd->dev, "timeout waiting for busyflag\n");
18400846a44SAndy Shevchenko }
18500846a44SAndy Shevchenko 
18600846a44SAndy Shevchenko static void charlcd_4bit_command(struct charlcd *lcd, u8 cmd)
18700846a44SAndy Shevchenko {
18800846a44SAndy Shevchenko 	u32 cmdlo = (cmd << 4) & 0xf0;
18900846a44SAndy Shevchenko 	u32 cmdhi = (cmd & 0xf0);
19000846a44SAndy Shevchenko 
19100846a44SAndy Shevchenko 	writel(cmdhi, lcd->virtbase + CHAR_COM);
19200846a44SAndy Shevchenko 	udelay(10);
19300846a44SAndy Shevchenko 	writel(cmdlo, lcd->virtbase + CHAR_COM);
19400846a44SAndy Shevchenko 	charlcd_4bit_wait_busy(lcd);
19500846a44SAndy Shevchenko }
19600846a44SAndy Shevchenko 
19700846a44SAndy Shevchenko static void charlcd_4bit_char(struct charlcd *lcd, u8 ch)
19800846a44SAndy Shevchenko {
19900846a44SAndy Shevchenko 	u32 chlo = (ch << 4) & 0xf0;
20000846a44SAndy Shevchenko 	u32 chhi = (ch & 0xf0);
20100846a44SAndy Shevchenko 
20200846a44SAndy Shevchenko 	writel(chhi, lcd->virtbase + CHAR_DAT);
20300846a44SAndy Shevchenko 	udelay(10);
20400846a44SAndy Shevchenko 	writel(chlo, lcd->virtbase + CHAR_DAT);
20500846a44SAndy Shevchenko 	charlcd_4bit_wait_busy(lcd);
20600846a44SAndy Shevchenko }
20700846a44SAndy Shevchenko 
20800846a44SAndy Shevchenko static void charlcd_4bit_print(struct charlcd *lcd, int line, const char *str)
20900846a44SAndy Shevchenko {
21000846a44SAndy Shevchenko 	u8 offset;
21100846a44SAndy Shevchenko 	int i;
21200846a44SAndy Shevchenko 
21300846a44SAndy Shevchenko 	/*
21400846a44SAndy Shevchenko 	 * We support line 0, 1
21500846a44SAndy Shevchenko 	 * Line 1 runs from 0x00..0x27
21600846a44SAndy Shevchenko 	 * Line 2 runs from 0x28..0x4f
21700846a44SAndy Shevchenko 	 */
21800846a44SAndy Shevchenko 	if (line == 0)
21900846a44SAndy Shevchenko 		offset = 0;
22000846a44SAndy Shevchenko 	else if (line == 1)
22100846a44SAndy Shevchenko 		offset = 0x28;
22200846a44SAndy Shevchenko 	else
22300846a44SAndy Shevchenko 		return;
22400846a44SAndy Shevchenko 
22500846a44SAndy Shevchenko 	/* Set offset */
22600846a44SAndy Shevchenko 	charlcd_4bit_command(lcd, HD_SET_DDRAM | offset);
22700846a44SAndy Shevchenko 
22800846a44SAndy Shevchenko 	/* Send string */
22900846a44SAndy Shevchenko 	for (i = 0; i < strlen(str) && i < 0x28; i++)
23000846a44SAndy Shevchenko 		charlcd_4bit_char(lcd, str[i]);
23100846a44SAndy Shevchenko }
23200846a44SAndy Shevchenko 
23300846a44SAndy Shevchenko static void charlcd_4bit_init(struct charlcd *lcd)
23400846a44SAndy Shevchenko {
23500846a44SAndy Shevchenko 	/* These commands cannot be checked with the busy flag */
23600846a44SAndy Shevchenko 	writel(HD_FUNCSET | HD_FUNCSET_8BIT, lcd->virtbase + CHAR_COM);
23700846a44SAndy Shevchenko 	msleep(5);
23800846a44SAndy Shevchenko 	writel(HD_FUNCSET | HD_FUNCSET_8BIT, lcd->virtbase + CHAR_COM);
23900846a44SAndy Shevchenko 	udelay(100);
24000846a44SAndy Shevchenko 	writel(HD_FUNCSET | HD_FUNCSET_8BIT, lcd->virtbase + CHAR_COM);
24100846a44SAndy Shevchenko 	udelay(100);
24200846a44SAndy Shevchenko 	/* Go to 4bit mode */
24300846a44SAndy Shevchenko 	writel(HD_FUNCSET, lcd->virtbase + CHAR_COM);
24400846a44SAndy Shevchenko 	udelay(100);
24500846a44SAndy Shevchenko 	/*
24600846a44SAndy Shevchenko 	 * 4bit mode, 2 lines, 5x8 font, after this the number of lines
24700846a44SAndy Shevchenko 	 * and the font cannot be changed until the next initialization sequence
24800846a44SAndy Shevchenko 	 */
24900846a44SAndy Shevchenko 	charlcd_4bit_command(lcd, HD_FUNCSET | HD_FUNCSET_2_LINES);
25000846a44SAndy Shevchenko 	charlcd_4bit_command(lcd, HD_DISPCTRL | HD_DISPCTRL_ON);
25100846a44SAndy Shevchenko 	charlcd_4bit_command(lcd, HD_ENTRYMODE | HD_ENTRYMODE_INCREMENT);
25200846a44SAndy Shevchenko 	charlcd_4bit_command(lcd, HD_CLEAR);
25300846a44SAndy Shevchenko 	charlcd_4bit_command(lcd, HD_HOME);
25400846a44SAndy Shevchenko 	/* Put something useful in the display */
25500846a44SAndy Shevchenko 	charlcd_4bit_print(lcd, 0, "ARM Linux");
25600846a44SAndy Shevchenko 	charlcd_4bit_print(lcd, 1, UTS_RELEASE);
25700846a44SAndy Shevchenko }
25800846a44SAndy Shevchenko 
25900846a44SAndy Shevchenko static void charlcd_init_work(struct work_struct *work)
26000846a44SAndy Shevchenko {
26100846a44SAndy Shevchenko 	struct charlcd *lcd =
26200846a44SAndy Shevchenko 		container_of(work, struct charlcd, init_work.work);
26300846a44SAndy Shevchenko 
26400846a44SAndy Shevchenko 	charlcd_4bit_init(lcd);
26500846a44SAndy Shevchenko }
26600846a44SAndy Shevchenko 
26700846a44SAndy Shevchenko static int __init charlcd_probe(struct platform_device *pdev)
26800846a44SAndy Shevchenko {
26900846a44SAndy Shevchenko 	int ret;
27000846a44SAndy Shevchenko 	struct charlcd *lcd;
27100846a44SAndy Shevchenko 	struct resource *res;
27200846a44SAndy Shevchenko 
27300846a44SAndy Shevchenko 	lcd = kzalloc(sizeof(struct charlcd), GFP_KERNEL);
27400846a44SAndy Shevchenko 	if (!lcd)
27500846a44SAndy Shevchenko 		return -ENOMEM;
27600846a44SAndy Shevchenko 
27700846a44SAndy Shevchenko 	lcd->dev = &pdev->dev;
27800846a44SAndy Shevchenko 
27900846a44SAndy Shevchenko 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
28000846a44SAndy Shevchenko 	if (!res) {
28100846a44SAndy Shevchenko 		ret = -ENOENT;
28200846a44SAndy Shevchenko 		goto out_no_resource;
28300846a44SAndy Shevchenko 	}
28400846a44SAndy Shevchenko 	lcd->phybase = res->start;
28500846a44SAndy Shevchenko 	lcd->physize = resource_size(res);
28600846a44SAndy Shevchenko 
28700846a44SAndy Shevchenko 	if (request_mem_region(lcd->phybase, lcd->physize,
28800846a44SAndy Shevchenko 			       DRIVERNAME) == NULL) {
28900846a44SAndy Shevchenko 		ret = -EBUSY;
29000846a44SAndy Shevchenko 		goto out_no_memregion;
29100846a44SAndy Shevchenko 	}
29200846a44SAndy Shevchenko 
29300846a44SAndy Shevchenko 	lcd->virtbase = ioremap(lcd->phybase, lcd->physize);
29400846a44SAndy Shevchenko 	if (!lcd->virtbase) {
29500846a44SAndy Shevchenko 		ret = -ENOMEM;
29600846a44SAndy Shevchenko 		goto out_no_memregion;
29700846a44SAndy Shevchenko 	}
29800846a44SAndy Shevchenko 
29900846a44SAndy Shevchenko 	lcd->irq = platform_get_irq(pdev, 0);
30000846a44SAndy Shevchenko 	/* If no IRQ is supplied, we'll survive without it */
30100846a44SAndy Shevchenko 	if (lcd->irq >= 0) {
30200846a44SAndy Shevchenko 		if (request_irq(lcd->irq, charlcd_interrupt, 0,
30300846a44SAndy Shevchenko 				DRIVERNAME, lcd)) {
30400846a44SAndy Shevchenko 			ret = -EIO;
30500846a44SAndy Shevchenko 			goto out_no_irq;
30600846a44SAndy Shevchenko 		}
30700846a44SAndy Shevchenko 	}
30800846a44SAndy Shevchenko 
30900846a44SAndy Shevchenko 	platform_set_drvdata(pdev, lcd);
31000846a44SAndy Shevchenko 
31100846a44SAndy Shevchenko 	/*
31200846a44SAndy Shevchenko 	 * Initialize the display in a delayed work, because
31300846a44SAndy Shevchenko 	 * it is VERY slow and would slow down the boot of the system.
31400846a44SAndy Shevchenko 	 */
31500846a44SAndy Shevchenko 	INIT_DELAYED_WORK(&lcd->init_work, charlcd_init_work);
31600846a44SAndy Shevchenko 	schedule_delayed_work(&lcd->init_work, 0);
31700846a44SAndy Shevchenko 
31800846a44SAndy Shevchenko 	dev_info(&pdev->dev, "initialized ARM character LCD at %08x\n",
31900846a44SAndy Shevchenko 		lcd->phybase);
32000846a44SAndy Shevchenko 
32100846a44SAndy Shevchenko 	return 0;
32200846a44SAndy Shevchenko 
32300846a44SAndy Shevchenko out_no_irq:
32400846a44SAndy Shevchenko 	iounmap(lcd->virtbase);
32500846a44SAndy Shevchenko out_no_memregion:
32600846a44SAndy Shevchenko 	release_mem_region(lcd->phybase, SZ_4K);
32700846a44SAndy Shevchenko out_no_resource:
32800846a44SAndy Shevchenko 	kfree(lcd);
32900846a44SAndy Shevchenko 	return ret;
33000846a44SAndy Shevchenko }
33100846a44SAndy Shevchenko 
33200846a44SAndy Shevchenko static int charlcd_suspend(struct device *dev)
33300846a44SAndy Shevchenko {
33400846a44SAndy Shevchenko 	struct platform_device *pdev = to_platform_device(dev);
33500846a44SAndy Shevchenko 	struct charlcd *lcd = platform_get_drvdata(pdev);
33600846a44SAndy Shevchenko 
33700846a44SAndy Shevchenko 	/* Power the display off */
33800846a44SAndy Shevchenko 	charlcd_4bit_command(lcd, HD_DISPCTRL);
33900846a44SAndy Shevchenko 	return 0;
34000846a44SAndy Shevchenko }
34100846a44SAndy Shevchenko 
34200846a44SAndy Shevchenko static int charlcd_resume(struct device *dev)
34300846a44SAndy Shevchenko {
34400846a44SAndy Shevchenko 	struct platform_device *pdev = to_platform_device(dev);
34500846a44SAndy Shevchenko 	struct charlcd *lcd = platform_get_drvdata(pdev);
34600846a44SAndy Shevchenko 
34700846a44SAndy Shevchenko 	/* Turn the display back on */
34800846a44SAndy Shevchenko 	charlcd_4bit_command(lcd, HD_DISPCTRL | HD_DISPCTRL_ON);
34900846a44SAndy Shevchenko 	return 0;
35000846a44SAndy Shevchenko }
35100846a44SAndy Shevchenko 
35200846a44SAndy Shevchenko static const struct dev_pm_ops charlcd_pm_ops = {
35300846a44SAndy Shevchenko 	.suspend = charlcd_suspend,
35400846a44SAndy Shevchenko 	.resume = charlcd_resume,
35500846a44SAndy Shevchenko };
35600846a44SAndy Shevchenko 
35700846a44SAndy Shevchenko static const struct of_device_id charlcd_match[] = {
35800846a44SAndy Shevchenko 	{ .compatible = "arm,versatile-lcd", },
35900846a44SAndy Shevchenko 	{}
36000846a44SAndy Shevchenko };
36100846a44SAndy Shevchenko 
36200846a44SAndy Shevchenko static struct platform_driver charlcd_driver = {
36300846a44SAndy Shevchenko 	.driver = {
36400846a44SAndy Shevchenko 		.name = DRIVERNAME,
36500846a44SAndy Shevchenko 		.pm = &charlcd_pm_ops,
36600846a44SAndy Shevchenko 		.suppress_bind_attrs = true,
36700846a44SAndy Shevchenko 		.of_match_table = of_match_ptr(charlcd_match),
36800846a44SAndy Shevchenko 	},
36900846a44SAndy Shevchenko };
37000846a44SAndy Shevchenko builtin_platform_driver_probe(charlcd_driver, charlcd_probe);
371