2 * linux/arch/arm/mach-nspire/clcd.c
4 * Copyright (C) 2013 Daniel Tang <tangrs@tangrs.id.au>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2, as
8 * published by the Free Software Foundation.
12 #include <linux/init.h>
14 #include <linux/amba/bus.h>
15 #include <linux/amba/clcd.h>
16 #include <linux/dma-mapping.h>
18 static struct clcd_panel nspire_cx_lcd_panel = {
25 .vmode = FB_VMODE_NONINTERLACED,
34 .width = 65, /* ~6.50 cm */
35 .height = 49, /* ~4.87 cm */
37 .cntl = CNTL_LCDTFT | CNTL_LCDVCOMP(1),
42 static struct clcd_panel nspire_classic_lcd_panel = {
44 .name = "Grayscale LCD",
48 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
49 .vmode = FB_VMODE_NONINTERLACED,
56 .width = 71, /* 7.11cm */
57 .height = 53, /* 5.33cm */
59 .cntl = CNTL_LCDMONO8,
62 .caps = CLCD_CAP_5551,
65 int nspire_clcd_setup(struct clcd_fb *fb)
67 struct clcd_panel *panel;
73 BUG_ON(!fb->dev->dev.of_node);
75 err = of_property_read_string(fb->dev->dev.of_node, "lcd-type", &type);
77 pr_err("CLCD: Could not find lcd-type property\n");
81 if (!strcmp(type, "cx")) {
82 panel = &nspire_cx_lcd_panel;
83 } else if (!strcmp(type, "classic")) {
84 panel = &nspire_classic_lcd_panel;
86 pr_err("CLCD: Unknown lcd-type %s\n", type);
90 panel_size = ((panel->mode.xres * panel->mode.yres) * panel->bpp) / 8;
91 panel_size = ALIGN(panel_size, PAGE_SIZE);
93 fb->fb.screen_base = dma_alloc_wc(&fb->dev->dev, panel_size, &dma,
96 if (!fb->fb.screen_base) {
97 pr_err("CLCD: unable to map framebuffer\n");
101 fb->fb.fix.smem_start = dma;
102 fb->fb.fix.smem_len = panel_size;
108 int nspire_clcd_mmap(struct clcd_fb *fb, struct vm_area_struct *vma)
110 return dma_mmap_wc(&fb->dev->dev, vma, fb->fb.screen_base,
111 fb->fb.fix.smem_start, fb->fb.fix.smem_len);
114 void nspire_clcd_remove(struct clcd_fb *fb)
116 dma_free_wc(&fb->dev->dev, fb->fb.fix.smem_len, fb->fb.screen_base,
117 fb->fb.fix.smem_start);