Lines Matching full:lcd

3  * Driver for the on-board character LCD found on some ARM reference boards
4 * This is basically an Hitachi HD44780 LCD with a custom IP block to drive it
63 * @complete: completion structure for the last LCD command
78 struct charlcd *lcd = data; in charlcd_interrupt() local
81 status = readl(lcd->virtbase + CHAR_STAT) & 0x01; in charlcd_interrupt()
83 writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW); in charlcd_interrupt()
85 complete(&lcd->complete); in charlcd_interrupt()
87 dev_info(lcd->dev, "Spurious IRQ (%02x)\n", status); in charlcd_interrupt()
92 static void charlcd_wait_complete_irq(struct charlcd *lcd) in charlcd_wait_complete_irq() argument
96 ret = wait_for_completion_interruptible_timeout(&lcd->complete, in charlcd_wait_complete_irq()
99 writel(0x00, lcd->virtbase + CHAR_MASK); in charlcd_wait_complete_irq()
102 dev_err(lcd->dev, in charlcd_wait_complete_irq()
109 dev_err(lcd->dev, "charlcd controller timed out " in charlcd_wait_complete_irq()
115 static u8 charlcd_4bit_read_char(struct charlcd *lcd) in charlcd_4bit_read_char() argument
122 if (lcd->irq >= 0) in charlcd_4bit_read_char()
123 charlcd_wait_complete_irq(lcd); in charlcd_4bit_read_char()
129 val = readl(lcd->virtbase + CHAR_RAW); in charlcd_4bit_read_char()
133 writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW); in charlcd_4bit_read_char()
138 data = readl(lcd->virtbase + CHAR_RD) & 0xf0; in charlcd_4bit_read_char()
148 val = readl(lcd->virtbase + CHAR_RAW); in charlcd_4bit_read_char()
151 writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW); in charlcd_4bit_read_char()
155 data |= (readl(lcd->virtbase + CHAR_RD) >> 4) & 0x0f; in charlcd_4bit_read_char()
160 static bool charlcd_4bit_read_bf(struct charlcd *lcd) in charlcd_4bit_read_bf() argument
162 if (lcd->irq >= 0) { in charlcd_4bit_read_bf()
167 writel(CHAR_RAW_CLEAR, lcd->virtbase + CHAR_RAW); in charlcd_4bit_read_bf()
168 init_completion(&lcd->complete); in charlcd_4bit_read_bf()
169 writel(0x01, lcd->virtbase + CHAR_MASK); in charlcd_4bit_read_bf()
171 readl(lcd->virtbase + CHAR_COM); in charlcd_4bit_read_bf()
172 return charlcd_4bit_read_char(lcd) & HD_BUSY_FLAG ? true : false; in charlcd_4bit_read_bf()
175 static void charlcd_4bit_wait_busy(struct charlcd *lcd) in charlcd_4bit_wait_busy() argument
180 while (charlcd_4bit_read_bf(lcd) && retries) in charlcd_4bit_wait_busy()
183 dev_err(lcd->dev, "timeout waiting for busyflag\n"); in charlcd_4bit_wait_busy()
186 static void charlcd_4bit_command(struct charlcd *lcd, u8 cmd) in charlcd_4bit_command() argument
191 writel(cmdhi, lcd->virtbase + CHAR_COM); in charlcd_4bit_command()
193 writel(cmdlo, lcd->virtbase + CHAR_COM); in charlcd_4bit_command()
194 charlcd_4bit_wait_busy(lcd); in charlcd_4bit_command()
197 static void charlcd_4bit_char(struct charlcd *lcd, u8 ch) in charlcd_4bit_char() argument
202 writel(chhi, lcd->virtbase + CHAR_DAT); in charlcd_4bit_char()
204 writel(chlo, lcd->virtbase + CHAR_DAT); in charlcd_4bit_char()
205 charlcd_4bit_wait_busy(lcd); in charlcd_4bit_char()
208 static void charlcd_4bit_print(struct charlcd *lcd, int line, const char *str) in charlcd_4bit_print() argument
226 charlcd_4bit_command(lcd, HD_SET_DDRAM | offset); in charlcd_4bit_print()
230 charlcd_4bit_char(lcd, str[i]); in charlcd_4bit_print()
233 static void charlcd_4bit_init(struct charlcd *lcd) in charlcd_4bit_init() argument
236 writel(HD_FUNCSET | HD_FUNCSET_8BIT, lcd->virtbase + CHAR_COM); in charlcd_4bit_init()
238 writel(HD_FUNCSET | HD_FUNCSET_8BIT, lcd->virtbase + CHAR_COM); in charlcd_4bit_init()
240 writel(HD_FUNCSET | HD_FUNCSET_8BIT, lcd->virtbase + CHAR_COM); in charlcd_4bit_init()
243 writel(HD_FUNCSET, lcd->virtbase + CHAR_COM); in charlcd_4bit_init()
249 charlcd_4bit_command(lcd, HD_FUNCSET | HD_FUNCSET_2_LINES); in charlcd_4bit_init()
250 charlcd_4bit_command(lcd, HD_DISPCTRL | HD_DISPCTRL_ON); in charlcd_4bit_init()
251 charlcd_4bit_command(lcd, HD_ENTRYMODE | HD_ENTRYMODE_INCREMENT); in charlcd_4bit_init()
252 charlcd_4bit_command(lcd, HD_CLEAR); in charlcd_4bit_init()
253 charlcd_4bit_command(lcd, HD_HOME); in charlcd_4bit_init()
255 charlcd_4bit_print(lcd, 0, "ARM Linux"); in charlcd_4bit_init()
256 charlcd_4bit_print(lcd, 1, UTS_RELEASE); in charlcd_4bit_init()
261 struct charlcd *lcd = in charlcd_init_work() local
264 charlcd_4bit_init(lcd); in charlcd_init_work()
270 struct charlcd *lcd; in charlcd_probe() local
273 lcd = kzalloc(sizeof(struct charlcd), GFP_KERNEL); in charlcd_probe()
274 if (!lcd) in charlcd_probe()
277 lcd->dev = &pdev->dev; in charlcd_probe()
284 lcd->phybase = res->start; in charlcd_probe()
285 lcd->physize = resource_size(res); in charlcd_probe()
287 if (request_mem_region(lcd->phybase, lcd->physize, in charlcd_probe()
293 lcd->virtbase = ioremap(lcd->phybase, lcd->physize); in charlcd_probe()
294 if (!lcd->virtbase) { in charlcd_probe()
299 lcd->irq = platform_get_irq(pdev, 0); in charlcd_probe()
301 if (lcd->irq >= 0) { in charlcd_probe()
302 if (request_irq(lcd->irq, charlcd_interrupt, 0, in charlcd_probe()
303 DRIVERNAME, lcd)) { in charlcd_probe()
309 platform_set_drvdata(pdev, lcd); in charlcd_probe()
315 INIT_DELAYED_WORK(&lcd->init_work, charlcd_init_work); in charlcd_probe()
316 schedule_delayed_work(&lcd->init_work, 0); in charlcd_probe()
318 dev_info(&pdev->dev, "initialized ARM character LCD at %08x\n", in charlcd_probe()
319 lcd->phybase); in charlcd_probe()
324 iounmap(lcd->virtbase); in charlcd_probe()
326 release_mem_region(lcd->phybase, SZ_4K); in charlcd_probe()
328 kfree(lcd); in charlcd_probe()
334 struct charlcd *lcd = dev_get_drvdata(dev); in charlcd_suspend() local
337 charlcd_4bit_command(lcd, HD_DISPCTRL); in charlcd_suspend()
343 struct charlcd *lcd = dev_get_drvdata(dev); in charlcd_resume() local
346 charlcd_4bit_command(lcd, HD_DISPCTRL | HD_DISPCTRL_ON); in charlcd_resume()
356 { .compatible = "arm,versatile-lcd", },