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>
26 #include <linux/irqchip/arm-vic.h>
28 #include <asm/sizes.h>
34 module_param_named(lmid
, module_id
, int, 0444);
35 MODULE_PARM_DESC(lmid
, "logic module stack position");
39 void __iomem
*vic_base
;
42 void impd1_tweak_control(struct device
*dev
, u32 mask
, u32 val
)
44 struct impd1_module
*impd1
= dev_get_drvdata(dev
);
48 cur
= readl(impd1
->base
+ IMPD1_CTRL
) & ~mask
;
49 writel(cur
| val
, impd1
->base
+ IMPD1_CTRL
);
52 EXPORT_SYMBOL(impd1_tweak_control
);
57 #define PANEL PROSPECTOR
66 static struct clcd_panel vga
= {
80 .vmode
= FB_VMODE_NONINTERLACED
,
84 .tim2
= TIM2_BCD
| TIM2_IPC
,
85 .cntl
= CNTL_LCDTFT
| CNTL_LCDVCOMP(1),
86 .caps
= CLCD_CAP_5551
,
87 .connector
= IMPD1_CTRL_DISP_VGA
,
93 #define PANELTYPE svga
94 static struct clcd_panel svga
= {
108 .vmode
= FB_VMODE_NONINTERLACED
,
113 .cntl
= CNTL_LCDTFT
| CNTL_LCDVCOMP(1),
114 .connector
= IMPD1_CTRL_DISP_VGA
,
115 .caps
= CLCD_CAP_5551
,
120 #elif PANEL == PROSPECTOR
121 #define PANELTYPE prospector
122 static struct clcd_panel prospector
= {
124 .name
= "PROSPECTOR",
135 .sync
= FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
,
136 .vmode
= FB_VMODE_NONINTERLACED
,
141 .cntl
= CNTL_LCDTFT
| CNTL_LCDVCOMP(1),
142 .caps
= CLCD_CAP_5551
,
144 .connector
= IMPD1_CTRL_DISP_LCD
,
149 #elif PANEL == LTM10C209
150 #define PANELTYPE ltm10c209
154 static struct clcd_panel ltm10c209
= {
167 .sync
= FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
,
168 .vmode
= FB_VMODE_NONINTERLACED
,
173 .cntl
= CNTL_LCDTFT
| CNTL_LCDVCOMP(1),
174 .caps
= CLCD_CAP_5551
,
176 .connector
= IMPD1_CTRL_DISP_LCD
,
183 * Disable all display connectors on the interface module.
185 static void impd1fb_clcd_disable(struct clcd_fb
*fb
)
187 impd1_tweak_control(fb
->dev
->dev
.parent
, IMPD1_CTRL_DISP_MASK
, 0);
191 * Enable the relevant connector on the interface module.
193 static void impd1fb_clcd_enable(struct clcd_fb
*fb
)
195 impd1_tweak_control(fb
->dev
->dev
.parent
, IMPD1_CTRL_DISP_MASK
,
196 fb
->panel
->connector
| IMPD1_CTRL_DISP_ENABLE
);
199 static int impd1fb_clcd_setup(struct clcd_fb
*fb
)
201 unsigned long framebase
= fb
->dev
->res
.start
+ 0x01000000;
202 unsigned long framesize
= SZ_1M
;
205 fb
->panel
= &PANELTYPE
;
207 if (!request_mem_region(framebase
, framesize
, "clcd framebuffer")) {
208 printk(KERN_ERR
"IM-PD1: unable to reserve framebuffer\n");
212 fb
->fb
.screen_base
= ioremap(framebase
, framesize
);
213 if (!fb
->fb
.screen_base
) {
214 printk(KERN_ERR
"IM-PD1: unable to map framebuffer\n");
219 fb
->fb
.fix
.smem_start
= framebase
;
220 fb
->fb
.fix
.smem_len
= framesize
;
225 release_mem_region(framebase
, framesize
);
229 static int impd1fb_clcd_mmap(struct clcd_fb
*fb
, struct vm_area_struct
*vma
)
231 unsigned long start
, size
;
233 start
= vma
->vm_pgoff
+ (fb
->fb
.fix
.smem_start
>> PAGE_SHIFT
);
234 size
= vma
->vm_end
- vma
->vm_start
;
236 return remap_pfn_range(vma
, vma
->vm_start
, start
, size
,
240 static void impd1fb_clcd_remove(struct clcd_fb
*fb
)
242 iounmap(fb
->fb
.screen_base
);
243 release_mem_region(fb
->fb
.fix
.smem_start
, fb
->fb
.fix
.smem_len
);
246 static struct clcd_board impd1_clcd_data
= {
248 .caps
= CLCD_CAP_5551
| CLCD_CAP_888
,
249 .check
= clcdfb_check
,
250 .decode
= clcdfb_decode
,
251 .disable
= impd1fb_clcd_disable
,
252 .enable
= impd1fb_clcd_enable
,
253 .setup
= impd1fb_clcd_setup
,
254 .mmap
= impd1fb_clcd_mmap
,
255 .remove
= impd1fb_clcd_remove
,
258 struct impd1_device
{
259 unsigned long offset
;
265 static struct impd1_device impd1_devs
[] = {
267 .offset
= 0x00100000,
271 .offset
= 0x00200000,
275 .offset
= 0x00300000,
279 .offset
= 0x00400000,
283 .offset
= 0x00500000,
287 .offset
= 0x00600000,
291 .offset
= 0x00700000,
295 .offset
= 0x00800000,
299 .offset
= 0x01000000,
302 .platform_data
= &impd1_clcd_data
,
307 * Valid IRQs: 0 thru 9 and 11, 10 unused.
309 #define IMPD1_VALID_IRQS 0x00000bffU
312 * As this module is bool, it is OK to have this as __init_refok() - no
313 * probe calls will be done after the initial system bootup, as devices
314 * are discovered as part of the machine startup.
316 static int __init_refok
impd1_probe(struct lm_device
*dev
)
318 struct impd1_module
*impd1
;
322 if (dev
->id
!= module_id
)
325 if (!devm_request_mem_region(&dev
->dev
, dev
->resource
.start
,
326 SZ_4K
, "LM registers"))
329 impd1
= devm_kzalloc(&dev
->dev
, sizeof(struct impd1_module
),
334 impd1
->base
= devm_ioremap(&dev
->dev
, dev
->resource
.start
, SZ_4K
);
338 integrator_impd1_clk_init(impd1
->base
, dev
->id
);
340 if (!devm_request_mem_region(&dev
->dev
,
341 dev
->resource
.start
+ 0x03000000,
345 impd1
->vic_base
= devm_ioremap(&dev
->dev
,
346 dev
->resource
.start
+ 0x03000000,
348 if (!impd1
->vic_base
)
351 irq_base
= vic_init_cascaded(impd1
->vic_base
, dev
->irq
,
352 IMPD1_VALID_IRQS
, 0);
354 lm_set_drvdata(dev
, impd1
);
356 dev_info(&dev
->dev
, "IM-PD1 found at 0x%08lx\n",
357 (unsigned long)dev
->resource
.start
);
359 for (i
= 0; i
< ARRAY_SIZE(impd1_devs
); i
++) {
360 struct impd1_device
*idev
= impd1_devs
+ i
;
361 struct amba_device
*d
;
362 unsigned long pc_base
;
364 int irq1
= idev
->irq
[0];
365 int irq2
= idev
->irq
[1];
367 /* Translate IRQs to IM-PD1 local numberspace */
373 pc_base
= dev
->resource
.start
+ idev
->offset
;
374 snprintf(devname
, 32, "lm%x:%5.5lx", dev
->id
, idev
->offset
>> 12);
375 d
= amba_ahb_device_add_res(&dev
->dev
, devname
, pc_base
, SZ_4K
,
377 idev
->platform_data
, idev
->id
,
380 dev_err(&dev
->dev
, "unable to register device: %ld\n", PTR_ERR(d
));
388 static int impd1_remove_one(struct device
*dev
, void *data
)
390 device_unregister(dev
);
394 static void impd1_remove(struct lm_device
*dev
)
396 device_for_each_child(&dev
->dev
, NULL
, impd1_remove_one
);
397 integrator_impd1_clk_exit(dev
->id
);
399 lm_set_drvdata(dev
, NULL
);
402 static struct lm_driver impd1_driver
= {
406 * As we're dropping the probe() function, suppress driver
407 * binding from sysfs.
409 .suppress_bind_attrs
= true,
411 .probe
= impd1_probe
,
412 .remove
= impd1_remove
,
415 static int __init
impd1_init(void)
417 return lm_driver_register(&impd1_driver
);
420 static void __exit
impd1_exit(void)
422 lm_driver_unregister(&impd1_driver
);
425 module_init(impd1_init
);
426 module_exit(impd1_exit
);
428 MODULE_LICENSE("GPL");
429 MODULE_DESCRIPTION("Integrator/IM-PD1 logic module core driver");
430 MODULE_AUTHOR("Deep Blue Solutions Ltd");