hd44780.c (3fc04dd7eb77b54228a17753ec01128417433e46) | hd44780.c (71ff701bbefec9e3c342f3a01d2d89b7ae026c71) |
---|---|
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 --- 101 unchanged lines hidden (view full) --- 110 111 hd44780_write_gpio8(hd, cmd, 0); 112 113 /* The shortest command takes at least 120 us */ 114 udelay(120); 115} 116 117/* Send data 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 --- 101 unchanged lines hidden (view full) --- 110 111 hd44780_write_gpio8(hd, cmd, 0); 112 113 /* The shortest command takes at least 120 us */ 114 udelay(120); 115} 116 117/* Send data to the LCD panel in 8 bit GPIO mode */ |
118static void hd44780_write_data_gpio8(struct charlcd *lcd, int data) | 118static void hd44780_write_data_gpio8(struct hd44780_common *hdc, int data) |
119{ | 119{ |
120 struct hd44780_common *hdc = lcd->drvdata; | |
121 struct hd44780 *hd = hdc->hd44780; 122 123 hd44780_write_gpio8(hd, data, 1); 124 125 /* The shortest data takes at least 45 us */ 126 udelay(45); 127} 128 129static const struct charlcd_ops hd44780_ops_gpio8 = { 130 .write_cmd = hd44780_write_cmd_gpio8, | 120 struct hd44780 *hd = hdc->hd44780; 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 = { 129 .write_cmd = hd44780_write_cmd_gpio8, |
131 .write_data = hd44780_write_data_gpio8, | |
132 .backlight = hd44780_backlight, 133}; 134 135/* Send a command to the LCD panel in 4 bit GPIO mode */ 136static void hd44780_write_cmd_gpio4(struct charlcd *lcd, int cmd) 137{ 138 struct hd44780_common *hdc = lcd->drvdata; 139 struct hd44780 *hd = hdc->hd44780; --- 18 unchanged lines hidden (view full) --- 158 159 /* Present the data to the port */ 160 gpiod_set_array_value_cansleep(n, &hd->pins[PIN_DATA4], NULL, values); 161 162 hd44780_strobe_gpio(hd); 163} 164 165/* Send data to the LCD panel in 4 bit GPIO mode */ | 130 .backlight = hd44780_backlight, 131}; 132 133/* Send a command to the LCD panel in 4 bit GPIO mode */ 134static void hd44780_write_cmd_gpio4(struct charlcd *lcd, int cmd) 135{ 136 struct hd44780_common *hdc = lcd->drvdata; 137 struct hd44780 *hd = hdc->hd44780; --- 18 unchanged lines hidden (view full) --- 156 157 /* Present the data to the port */ 158 gpiod_set_array_value_cansleep(n, &hd->pins[PIN_DATA4], NULL, values); 159 160 hd44780_strobe_gpio(hd); 161} 162 163/* Send data to the LCD panel in 4 bit GPIO mode */ |
166static void hd44780_write_data_gpio4(struct charlcd *lcd, int data) | 164static void hd44780_write_data_gpio4(struct hd44780_common *hdc, int data) |
167{ | 165{ |
168 struct hd44780_common *hdc = lcd->drvdata; | |
169 struct hd44780 *hd = hdc->hd44780; 170 171 hd44780_write_gpio4(hd, data, 1); 172 173 /* The shortest data takes at least 45 us */ 174 udelay(45); 175} 176 177static const struct charlcd_ops hd44780_ops_gpio4 = { 178 .write_cmd = hd44780_write_cmd_gpio4, 179 .write_cmd_raw4 = hd44780_write_cmd_raw_gpio4, | 166 struct hd44780 *hd = hdc->hd44780; 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 = { 175 .write_cmd = hd44780_write_cmd_gpio4, 176 .write_cmd_raw4 = hd44780_write_cmd_raw_gpio4, |
180 .write_data = hd44780_write_data_gpio4, | |
181 .backlight = hd44780_backlight, 182}; 183 184static int hd44780_probe(struct platform_device *pdev) 185{ 186 struct device *dev = &pdev->dev; 187 unsigned int i, base; 188 struct charlcd *lcd; --- 82 unchanged lines hidden (view full) --- 271 */ 272 if (lcd->height > 2) 273 hdc->bwidth = lcd->width; 274 275 /* Optional properties */ 276 device_property_read_u32(dev, "internal-buffer-width", &hdc->bwidth); 277 278 hdc->ifwidth = ifwidth; | 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; --- 82 unchanged lines hidden (view full) --- 267 */ 268 if (lcd->height > 2) 269 hdc->bwidth = lcd->width; 270 271 /* Optional properties */ 272 device_property_read_u32(dev, "internal-buffer-width", &hdc->bwidth); 273 274 hdc->ifwidth = ifwidth; |
279 lcd->ops = ifwidth == 8 ? &hd44780_ops_gpio8 : &hd44780_ops_gpio4; | 275 if (ifwidth == 8) { 276 lcd->ops = &hd44780_ops_gpio8; 277 hdc->write_data = hd44780_write_data_gpio8; 278 } else { 279 lcd->ops = &hd44780_ops_gpio4; 280 hdc->write_data = hd44780_write_data_gpio4; 281 } |
280 281 ret = charlcd_register(lcd); 282 if (ret) 283 goto fail3; 284 285 platform_set_drvdata(pdev, lcd); 286 return 0; 287 --- 39 unchanged lines hidden --- | 282 283 ret = charlcd_register(lcd); 284 if (ret) 285 goto fail3; 286 287 platform_set_drvdata(pdev, lcd); 288 return 0; 289 --- 39 unchanged lines hidden --- |