Lines Matching +full:lcd +full:- +full:backlight
1 // SPDX-License-Identifier: GPL-2.0+
3 * HD44780 Character LCD driver for Linux
5 * Copyright (C) 2000-2008, Willy Tarreau <w@1wt.eu>
6 * Copyright (C) 2016-2017 Glider bvba
40 static void hd44780_backlight(struct charlcd *lcd, int on) in hd44780_backlight() argument
42 struct hd44780 *hd = lcd->drvdata; in hd44780_backlight()
44 if (hd->pins[PIN_CTRL_BL]) in hd44780_backlight()
45 gpiod_set_value_cansleep(hd->pins[PIN_CTRL_BL], on); in hd44780_backlight()
53 gpiod_set_value_cansleep(hd->pins[PIN_CTRL_E], 1); in hd44780_strobe_gpio()
58 gpiod_set_value_cansleep(hd->pins[PIN_CTRL_E], 0); in hd44780_strobe_gpio()
61 /* write to an LCD panel register in 8 bit GPIO mode */
64 DECLARE_BITMAP(values, 10); /* for DATA[0-7], RS, RW */ in hd44780_write_gpio8()
69 n = hd->pins[PIN_CTRL_RW] ? 10 : 9; in hd44780_write_gpio8()
72 gpiod_set_array_value_cansleep(n, &hd->pins[PIN_DATA0], NULL, values); in hd44780_write_gpio8()
77 /* write to an LCD panel register in 4 bit GPIO mode */
80 DECLARE_BITMAP(values, 6); /* for DATA[4-7], RS, RW */ in hd44780_write_gpio4()
86 n = hd->pins[PIN_CTRL_RW] ? 6 : 5; in hd44780_write_gpio4()
89 gpiod_set_array_value_cansleep(n, &hd->pins[PIN_DATA4], NULL, values); in hd44780_write_gpio4()
98 gpiod_set_array_value_cansleep(n, &hd->pins[PIN_DATA4], NULL, values); in hd44780_write_gpio4()
103 /* Send a command to the LCD panel in 8 bit GPIO mode */
104 static void hd44780_write_cmd_gpio8(struct charlcd *lcd, int cmd) in hd44780_write_cmd_gpio8() argument
106 struct hd44780 *hd = lcd->drvdata; in hd44780_write_cmd_gpio8()
114 /* Send data to the LCD panel in 8 bit GPIO mode */
115 static void hd44780_write_data_gpio8(struct charlcd *lcd, int data) in hd44780_write_data_gpio8() argument
117 struct hd44780 *hd = lcd->drvdata; in hd44780_write_data_gpio8()
128 .backlight = hd44780_backlight,
131 /* Send a command to the LCD panel in 4 bit GPIO mode */
132 static void hd44780_write_cmd_gpio4(struct charlcd *lcd, int cmd) in hd44780_write_cmd_gpio4() argument
134 struct hd44780 *hd = lcd->drvdata; in hd44780_write_cmd_gpio4()
142 /* Send 4-bits of a command to the LCD panel in raw 4 bit GPIO mode */
143 static void hd44780_write_cmd_raw_gpio4(struct charlcd *lcd, int cmd) in hd44780_write_cmd_raw_gpio4() argument
145 DECLARE_BITMAP(values, 6); /* for DATA[4-7], RS, RW */ in hd44780_write_cmd_raw_gpio4()
146 struct hd44780 *hd = lcd->drvdata; in hd44780_write_cmd_raw_gpio4()
151 n = hd->pins[PIN_CTRL_RW] ? 6 : 5; in hd44780_write_cmd_raw_gpio4()
154 gpiod_set_array_value_cansleep(n, &hd->pins[PIN_DATA4], NULL, values); in hd44780_write_cmd_raw_gpio4()
159 /* Send data to the LCD panel in 4 bit GPIO mode */
160 static void hd44780_write_data_gpio4(struct charlcd *lcd, int data) in hd44780_write_data_gpio4() argument
162 struct hd44780 *hd = lcd->drvdata; in hd44780_write_data_gpio4()
174 .backlight = hd44780_backlight,
179 struct device *dev = &pdev->dev; in hd44780_probe()
181 struct charlcd *lcd; in hd44780_probe() local
198 return -EINVAL; in hd44780_probe()
201 lcd = charlcd_alloc(sizeof(struct hd44780)); in hd44780_probe()
202 if (!lcd) in hd44780_probe()
203 return -ENOMEM; in hd44780_probe()
205 hd = lcd->drvdata; in hd44780_probe()
208 hd->pins[base + i] = devm_gpiod_get_index(dev, "data", i, in hd44780_probe()
210 if (IS_ERR(hd->pins[base + i])) { in hd44780_probe()
211 ret = PTR_ERR(hd->pins[base + i]); in hd44780_probe()
216 hd->pins[PIN_CTRL_E] = devm_gpiod_get(dev, "enable", GPIOD_OUT_LOW); in hd44780_probe()
217 if (IS_ERR(hd->pins[PIN_CTRL_E])) { in hd44780_probe()
218 ret = PTR_ERR(hd->pins[PIN_CTRL_E]); in hd44780_probe()
222 hd->pins[PIN_CTRL_RS] = devm_gpiod_get(dev, "rs", GPIOD_OUT_HIGH); in hd44780_probe()
223 if (IS_ERR(hd->pins[PIN_CTRL_RS])) { in hd44780_probe()
224 ret = PTR_ERR(hd->pins[PIN_CTRL_RS]); in hd44780_probe()
229 hd->pins[PIN_CTRL_RW] = devm_gpiod_get_optional(dev, "rw", in hd44780_probe()
231 if (IS_ERR(hd->pins[PIN_CTRL_RW])) { in hd44780_probe()
232 ret = PTR_ERR(hd->pins[PIN_CTRL_RW]); in hd44780_probe()
236 hd->pins[PIN_CTRL_BL] = devm_gpiod_get_optional(dev, "backlight", in hd44780_probe()
238 if (IS_ERR(hd->pins[PIN_CTRL_BL])) { in hd44780_probe()
239 ret = PTR_ERR(hd->pins[PIN_CTRL_BL]); in hd44780_probe()
244 ret = device_property_read_u32(dev, "display-height-chars", in hd44780_probe()
245 &lcd->height); in hd44780_probe()
248 ret = device_property_read_u32(dev, "display-width-chars", &lcd->width); in hd44780_probe()
256 if (lcd->height > 2) in hd44780_probe()
257 lcd->bwidth = lcd->width; in hd44780_probe()
260 device_property_read_u32(dev, "internal-buffer-width", &lcd->bwidth); in hd44780_probe()
262 lcd->ifwidth = ifwidth; in hd44780_probe()
263 lcd->ops = ifwidth == 8 ? &hd44780_ops_gpio8 : &hd44780_ops_gpio4; in hd44780_probe()
265 ret = charlcd_register(lcd); in hd44780_probe()
269 platform_set_drvdata(pdev, lcd); in hd44780_probe()
273 charlcd_free(lcd); in hd44780_probe()
279 struct charlcd *lcd = platform_get_drvdata(pdev); in hd44780_remove() local
281 charlcd_unregister(lcd); in hd44780_remove()
283 charlcd_free(lcd); in hd44780_remove()
303 MODULE_DESCRIPTION("HD44780 Character LCD driver");
304 MODULE_AUTHOR("Geert Uytterhoeven <geert@linux-m68k.org>");