From 45421ffefbb5f195de02ead952755329ef8576d8 Mon Sep 17 00:00:00 2001 From: Lars Poeschel Date: Tue, 3 Nov 2020 10:58:14 +0100 Subject: auxdisplay: Move clear_display to hd44780_common This moves the clear_display function from charlcd to hd44780_common. This is one more step to make charlcd independent from device specific code. The two hd44780 drivers use the new function from hd44780_common and charlcd calls this function through its function pointer in its ops structure. Reviewed-by: Willy Tarreau Signed-off-by: Lars Poeschel Signed-off-by: Miguel Ojeda --- drivers/auxdisplay/hd44780_common.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'drivers/auxdisplay/hd44780_common.c') diff --git a/drivers/auxdisplay/hd44780_common.c b/drivers/auxdisplay/hd44780_common.c index ea62beada9d8..2f7d55668eb4 100644 --- a/drivers/auxdisplay/hd44780_common.c +++ b/drivers/auxdisplay/hd44780_common.c @@ -1,13 +1,22 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include +#include #include #include "charlcd.h" #include "hd44780_common.h" /* LCD commands */ +#define LCD_CMD_DISPLAY_CLEAR 0x01 /* Clear entire display */ + #define LCD_CMD_SET_DDRAM_ADDR 0x80 /* Set display data RAM address */ +/* sleeps that many milliseconds with a reschedule */ +static void long_sleep(int ms) +{ + schedule_timeout_interruptible(msecs_to_jiffies(ms)); +} + int hd44780_common_print(struct charlcd *lcd, int c) { struct hd44780_common *hdc = lcd->drvdata; @@ -49,6 +58,18 @@ int hd44780_common_home(struct charlcd *lcd) } EXPORT_SYMBOL_GPL(hd44780_common_home); +/* clears the display and resets X/Y */ +int hd44780_common_clear_display(struct charlcd *lcd) +{ + struct hd44780_common *hdc = lcd->drvdata; + + hdc->write_cmd(hdc, LCD_CMD_DISPLAY_CLEAR); + /* we must wait a few milliseconds (15) */ + long_sleep(15); + return 0; +} +EXPORT_SYMBOL_GPL(hd44780_common_clear_display); + struct hd44780_common *hd44780_common_alloc(void) { struct hd44780_common *hd; -- cgit v1.2.3