2 * linux/arch/arm/mach-integrator/impd1.c
4 * Copyright (C) 2003 Deep Blue Solutions Ltd, All Rights Reserved.
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.
10 * This file provides the core support for the IM-PD1 module.
12 * Module / boot parameters.
13 * lmid=n impd1.lmid=n - set the logic module position in stack to 'n'
15 #include <linux/module.h>
16 #include <linux/moduleparam.h>
17 #include <linux/init.h>
18 #include <linux/device.h>
19 #include <linux/errno.h>
21 #include <linux/amba/bus.h>
22 #include <linux/amba/clcd.h>
24 #include <linux/platform_data/clk-integrator.h>
25 #include <linux/slab.h>
28 #include <mach/impd1.h>
29 #include <asm/sizes.h>
33 module_param_named(lmid, module_id, int, 0444);
34 MODULE_PARM_DESC(lmid, "logic module stack position");
40 void impd1_tweak_control(struct device *dev, u32 mask, u32 val)
42 struct impd1_module *impd1 = dev_get_drvdata(dev);
46 cur = readl(impd1->base + IMPD1_CTRL) & ~mask;
47 writel(cur | val, impd1->base + IMPD1_CTRL);
50 EXPORT_SYMBOL(impd1_tweak_control);
55 #define PANEL PROSPECTOR
64 static struct clcd_panel vga = {
78 .vmode = FB_VMODE_NONINTERLACED,
82 .tim2 = TIM2_BCD | TIM2_IPC,
83 .cntl = CNTL_LCDTFT | CNTL_LCDVCOMP(1),
84 .caps = CLCD_CAP_5551,
85 .connector = IMPD1_CTRL_DISP_VGA,
91 #define PANELTYPE svga
92 static struct clcd_panel svga = {
106 .vmode = FB_VMODE_NONINTERLACED,
111 .cntl = CNTL_LCDTFT | CNTL_LCDVCOMP(1),
112 .connector = IMPD1_CTRL_DISP_VGA,
113 .caps = CLCD_CAP_5551,
118 #elif PANEL == PROSPECTOR
119 #define PANELTYPE prospector
120 static struct clcd_panel prospector = {
122 .name = "PROSPECTOR",
133 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
134 .vmode = FB_VMODE_NONINTERLACED,
139 .cntl = CNTL_LCDTFT | CNTL_LCDVCOMP(1),
140 .caps = CLCD_CAP_5551,
142 .connector = IMPD1_CTRL_DISP_LCD,
147 #elif PANEL == LTM10C209
148 #define PANELTYPE ltm10c209
152 static struct clcd_panel ltm10c209 = {
165 .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
166 .vmode = FB_VMODE_NONINTERLACED,
171 .cntl = CNTL_LCDTFT | CNTL_LCDVCOMP(1),
172 .caps = CLCD_CAP_5551,
174 .connector = IMPD1_CTRL_DISP_LCD,
181 * Disable all display connectors on the interface module.
183 static void impd1fb_clcd_disable(struct clcd_fb *fb)
185 impd1_tweak_control(fb->dev->dev.parent, IMPD1_CTRL_DISP_MASK, 0);
189 * Enable the relevant connector on the interface module.
191 static void impd1fb_clcd_enable(struct clcd_fb *fb)
193 impd1_tweak_control(fb->dev->dev.parent, IMPD1_CTRL_DISP_MASK,
194 fb->panel->connector | IMPD1_CTRL_DISP_ENABLE);
197 static int impd1fb_clcd_setup(struct clcd_fb *fb)
199 unsigned long framebase = fb->dev->res.start + 0x01000000;
200 unsigned long framesize = SZ_1M;
203 fb->panel = &PANELTYPE;
205 if (!request_mem_region(framebase, framesize, "clcd framebuffer")) {
206 printk(KERN_ERR "IM-PD1: unable to reserve framebuffer\n");
210 fb->fb.screen_base = ioremap(framebase, framesize);
211 if (!fb->fb.screen_base) {
212 printk(KERN_ERR "IM-PD1: unable to map framebuffer\n");
217 fb->fb.fix.smem_start = framebase;
218 fb->fb.fix.smem_len = framesize;
223 release_mem_region(framebase, framesize);
227 static int impd1fb_clcd_mmap(struct clcd_fb *fb, struct vm_area_struct *vma)
229 unsigned long start, size;
231 start = vma->vm_pgoff + (fb->fb.fix.smem_start >> PAGE_SHIFT);
232 size = vma->vm_end - vma->vm_start;
234 return remap_pfn_range(vma, vma->vm_start, start, size,
238 static void impd1fb_clcd_remove(struct clcd_fb *fb)
240 iounmap(fb->fb.screen_base);
241 release_mem_region(fb->fb.fix.smem_start, fb->fb.fix.smem_len);
244 static struct clcd_board impd1_clcd_data = {
246 .caps = CLCD_CAP_5551 | CLCD_CAP_888,
247 .check = clcdfb_check,
248 .decode = clcdfb_decode,
249 .disable = impd1fb_clcd_disable,
250 .enable = impd1fb_clcd_enable,
251 .setup = impd1fb_clcd_setup,
252 .mmap = impd1fb_clcd_mmap,
253 .remove = impd1fb_clcd_remove,
256 struct impd1_device {
257 unsigned long offset;
263 static struct impd1_device impd1_devs[] = {
265 .offset = 0x03000000,
268 .offset = 0x00100000,
272 .offset = 0x00200000,
276 .offset = 0x00300000,
280 .offset = 0x00400000,
284 .offset = 0x00500000,
288 .offset = 0x00600000,
292 .offset = 0x00700000,
296 .offset = 0x00800000,
300 .offset = 0x01000000,
303 .platform_data = &impd1_clcd_data,
307 static int impd1_probe(struct lm_device *dev)
309 struct impd1_module *impd1;
312 if (dev->id != module_id)
315 if (!request_mem_region(dev->resource.start, SZ_4K, "LM registers"))
318 impd1 = kzalloc(sizeof(struct impd1_module), GFP_KERNEL);
324 impd1->base = ioremap(dev->resource.start, SZ_4K);
330 lm_set_drvdata(dev, impd1);
332 printk("IM-PD1 found at 0x%08lx\n",
333 (unsigned long)dev->resource.start);
335 integrator_impd1_clk_init(impd1->base, dev->id);
337 for (i = 0; i < ARRAY_SIZE(impd1_devs); i++) {
338 struct impd1_device *idev = impd1_devs + i;
339 struct amba_device *d;
340 unsigned long pc_base;
343 pc_base = dev->resource.start + idev->offset;
344 snprintf(devname, 32, "lm%x:%5.5lx", dev->id, idev->offset >> 12);
345 d = amba_ahb_device_add_res(&dev->dev, devname, pc_base, SZ_4K,
347 idev->platform_data, idev->id,
350 dev_err(&dev->dev, "unable to register device: %ld\n", PTR_ERR(d));
358 if (impd1 && impd1->base)
359 iounmap(impd1->base);
362 release_mem_region(dev->resource.start, SZ_4K);
366 static int impd1_remove_one(struct device *dev, void *data)
368 device_unregister(dev);
372 static void impd1_remove(struct lm_device *dev)
374 struct impd1_module *impd1 = lm_get_drvdata(dev);
376 device_for_each_child(&dev->dev, NULL, impd1_remove_one);
377 integrator_impd1_clk_exit(dev->id);
379 lm_set_drvdata(dev, NULL);
381 iounmap(impd1->base);
383 release_mem_region(dev->resource.start, SZ_4K);
386 static struct lm_driver impd1_driver = {
390 .probe = impd1_probe,
391 .remove = impd1_remove,
394 static int __init impd1_init(void)
396 return lm_driver_register(&impd1_driver);
399 static void __exit impd1_exit(void)
401 lm_driver_unregister(&impd1_driver);
404 module_init(impd1_init);
405 module_exit(impd1_exit);
407 MODULE_LICENSE("GPL");
408 MODULE_DESCRIPTION("Integrator/IM-PD1 logic module core driver");
409 MODULE_AUTHOR("Deep Blue Solutions Ltd");