hd44780.c (71ff701bbefec9e3c342f3a01d2d89b7ae026c71) hd44780.c (2c6a82f2342fadfcbd5dd92656e662c326f7a40a)
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * HD44780 Character LCD driver for Linux
4 *
5 * Copyright (C) 2000-2008, Willy Tarreau <w@1wt.eu>
6 * Copyright (C) 2016-2017 Glider bvba
7 */
8

--- 89 unchanged lines hidden (view full) ---

98
99 /* Present the data to the port */
100 gpiod_set_array_value_cansleep(n, &hd->pins[PIN_DATA4], NULL, values);
101
102 hd44780_strobe_gpio(hd);
103}
104
105/* Send a command to the LCD panel in 8 bit GPIO mode */
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * HD44780 Character LCD driver for Linux
4 *
5 * Copyright (C) 2000-2008, Willy Tarreau <w@1wt.eu>
6 * Copyright (C) 2016-2017 Glider bvba
7 */
8

--- 89 unchanged lines hidden (view full) ---

98
99 /* Present the data to the port */
100 gpiod_set_array_value_cansleep(n, &hd->pins[PIN_DATA4], NULL, values);
101
102 hd44780_strobe_gpio(hd);
103}
104
105/* Send a command to the LCD panel in 8 bit GPIO mode */
106static void hd44780_write_cmd_gpio8(struct charlcd *lcd, int cmd)
106static void hd44780_write_cmd_gpio8(struct hd44780_common *hdc, int cmd)
107{
107{
108 struct hd44780_common *hdc = lcd->drvdata;
109 struct hd44780 *hd = hdc->hd44780;
110
111 hd44780_write_gpio8(hd, cmd, 0);
112
113 /* The shortest command takes at least 120 us */
114 udelay(120);
115}
116

--- 4 unchanged lines hidden (view full) ---

121
122 hd44780_write_gpio8(hd, data, 1);
123
124 /* The shortest data takes at least 45 us */
125 udelay(45);
126}
127
128static const struct charlcd_ops hd44780_ops_gpio8 = {
108 struct hd44780 *hd = hdc->hd44780;
109
110 hd44780_write_gpio8(hd, cmd, 0);
111
112 /* The shortest command takes at least 120 us */
113 udelay(120);
114}
115

--- 4 unchanged lines hidden (view full) ---

120
121 hd44780_write_gpio8(hd, data, 1);
122
123 /* The shortest data takes at least 45 us */
124 udelay(45);
125}
126
127static const struct charlcd_ops hd44780_ops_gpio8 = {
129 .write_cmd = hd44780_write_cmd_gpio8,
130 .backlight = hd44780_backlight,
131};
132
133/* Send a command to the LCD panel in 4 bit GPIO mode */
128 .backlight = hd44780_backlight,
129};
130
131/* Send a command to the LCD panel in 4 bit GPIO mode */
134static void hd44780_write_cmd_gpio4(struct charlcd *lcd, int cmd)
132static void hd44780_write_cmd_gpio4(struct hd44780_common *hdc, int cmd)
135{
133{
136 struct hd44780_common *hdc = lcd->drvdata;
137 struct hd44780 *hd = hdc->hd44780;
138
139 hd44780_write_gpio4(hd, cmd, 0);
140
141 /* The shortest command takes at least 120 us */
142 udelay(120);
143}
144
145/* Send 4-bits of a command to the LCD panel in raw 4 bit GPIO mode */
134 struct hd44780 *hd = hdc->hd44780;
135
136 hd44780_write_gpio4(hd, cmd, 0);
137
138 /* The shortest command takes at least 120 us */
139 udelay(120);
140}
141
142/* Send 4-bits of a command to the LCD panel in raw 4 bit GPIO mode */
146static void hd44780_write_cmd_raw_gpio4(struct charlcd *lcd, int cmd)
143static void hd44780_write_cmd_raw_gpio4(struct hd44780_common *hdc, int cmd)
147{
148 DECLARE_BITMAP(values, 6); /* for DATA[4-7], RS, RW */
144{
145 DECLARE_BITMAP(values, 6); /* for DATA[4-7], RS, RW */
149 struct hd44780_common *hdc = lcd->drvdata;
150 struct hd44780 *hd = hdc->hd44780;
151 unsigned int n;
152
153 /* Command nibble + RS, RW */
154 values[0] = cmd & 0x0f;
155 n = hd->pins[PIN_CTRL_RW] ? 6 : 5;
156
157 /* Present the data to the port */

--- 9 unchanged lines hidden (view full) ---

167
168 hd44780_write_gpio4(hd, data, 1);
169
170 /* The shortest data takes at least 45 us */
171 udelay(45);
172}
173
174static const struct charlcd_ops hd44780_ops_gpio4 = {
146 struct hd44780 *hd = hdc->hd44780;
147 unsigned int n;
148
149 /* Command nibble + RS, RW */
150 values[0] = cmd & 0x0f;
151 n = hd->pins[PIN_CTRL_RW] ? 6 : 5;
152
153 /* Present the data to the port */

--- 9 unchanged lines hidden (view full) ---

163
164 hd44780_write_gpio4(hd, data, 1);
165
166 /* The shortest data takes at least 45 us */
167 udelay(45);
168}
169
170static const struct charlcd_ops hd44780_ops_gpio4 = {
175 .write_cmd = hd44780_write_cmd_gpio4,
176 .write_cmd_raw4 = hd44780_write_cmd_raw_gpio4,
177 .backlight = hd44780_backlight,
178};
179
180static int hd44780_probe(struct platform_device *pdev)
181{
182 struct device *dev = &pdev->dev;
183 unsigned int i, base;
184 struct charlcd *lcd;

--- 85 unchanged lines hidden (view full) ---

270
271 /* Optional properties */
272 device_property_read_u32(dev, "internal-buffer-width", &hdc->bwidth);
273
274 hdc->ifwidth = ifwidth;
275 if (ifwidth == 8) {
276 lcd->ops = &hd44780_ops_gpio8;
277 hdc->write_data = hd44780_write_data_gpio8;
171 .backlight = hd44780_backlight,
172};
173
174static int hd44780_probe(struct platform_device *pdev)
175{
176 struct device *dev = &pdev->dev;
177 unsigned int i, base;
178 struct charlcd *lcd;

--- 85 unchanged lines hidden (view full) ---

264
265 /* Optional properties */
266 device_property_read_u32(dev, "internal-buffer-width", &hdc->bwidth);
267
268 hdc->ifwidth = ifwidth;
269 if (ifwidth == 8) {
270 lcd->ops = &hd44780_ops_gpio8;
271 hdc->write_data = hd44780_write_data_gpio8;
272 hdc->write_cmd = hd44780_write_cmd_gpio8;
278 } else {
279 lcd->ops = &hd44780_ops_gpio4;
280 hdc->write_data = hd44780_write_data_gpio4;
273 } else {
274 lcd->ops = &hd44780_ops_gpio4;
275 hdc->write_data = hd44780_write_data_gpio4;
276 hdc->write_cmd = hd44780_write_cmd_gpio4;
277 hdc->write_cmd_raw4 = hd44780_write_cmd_raw_gpio4;
281 }
282
283 ret = charlcd_register(lcd);
284 if (ret)
285 goto fail3;
286
287 platform_set_drvdata(pdev, lcd);
288 return 0;

--- 40 unchanged lines hidden ---
278 }
279
280 ret = charlcd_register(lcd);
281 if (ret)
282 goto fail3;
283
284 platform_set_drvdata(pdev, lcd);
285 return 0;

--- 40 unchanged lines hidden ---