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>
22 #include <asm/hardware/icst525.h>
23 #include <asm/hardware/amba.h>
24 #include <asm/hardware/amba_clcd.h>
25 #include <asm/arch/lm.h>
26 #include <asm/arch/impd1.h>
27 #include <asm/sizes.h>
33 module_param_named(lmid
, module_id
, int, 0444);
34 MODULE_PARM_DESC(lmid
, "logic module stack position");
41 static const struct icst525_params impd1_vco_params
= {
42 .ref
= 24000, /* 24 MHz */
43 .vco_max
= 200000, /* 200 MHz */
50 static void impd1_setvco(struct clk
*clk
, struct icst525_vco vco
)
52 struct impd1_module
*impd1
= clk
->data
;
53 int vconr
= clk
- impd1
->vcos
;
56 val
= vco
.v
| (vco
.r
<< 9) | (vco
.s
<< 16);
58 writel(0xa05f, impd1
->base
+ IMPD1_LOCK
);
61 writel(val
, impd1
->base
+ IMPD1_OSC1
);
64 writel(val
, impd1
->base
+ IMPD1_OSC2
);
67 writel(0, impd1
->base
+ IMPD1_LOCK
);
71 vco
.r
= (val
>> 9) & 0x7f;
72 vco
.s
= (val
>> 16) & 7;
74 pr_debug("IM-PD1: VCO%d clock is %ld kHz\n",
75 vconr
, icst525_khz(&impd1_vco_params
, vco
));
79 void impd1_tweak_control(struct device
*dev
, u32 mask
, u32 val
)
81 struct impd1_module
*impd1
= dev_get_drvdata(dev
);
85 cur
= readl(impd1
->base
+ IMPD1_CTRL
) & ~mask
;
86 writel(cur
| val
, impd1
->base
+ IMPD1_CTRL
);
89 EXPORT_SYMBOL(impd1_tweak_control
);
94 #define PANEL PROSPECTOR
102 #define PANELTYPE vga
103 static struct clcd_panel vga
= {
117 .vmode
= FB_VMODE_NONINTERLACED
,
121 .tim2
= TIM2_BCD
| TIM2_IPC
,
122 .cntl
= CNTL_LCDTFT
| CNTL_LCDVCOMP(1),
123 .connector
= IMPD1_CTRL_DISP_VGA
,
129 #define PANELTYPE svga
130 static struct clcd_panel svga
= {
144 .vmode
= FB_VMODE_NONINTERLACED
,
149 .cntl
= CNTL_LCDTFT
| CNTL_LCDVCOMP(1),
150 .connector
= IMPD1_CTRL_DISP_VGA
,
155 #elif PANEL == PROSPECTOR
156 #define PANELTYPE prospector
157 static struct clcd_panel prospector
= {
159 .name
= "PROSPECTOR",
170 .sync
= FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
,
171 .vmode
= FB_VMODE_NONINTERLACED
,
176 .cntl
= CNTL_LCDTFT
| CNTL_LCDVCOMP(1),
178 .connector
= IMPD1_CTRL_DISP_LCD
,
183 #elif PANEL == LTM10C209
184 #define PANELTYPE ltm10c209
188 static struct clcd_panel ltm10c209
= {
201 .sync
= FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
,
202 .vmode
= FB_VMODE_NONINTERLACED
,
207 .cntl
= CNTL_LCDTFT
| CNTL_LCDVCOMP(1),
209 .connector
= IMPD1_CTRL_DISP_LCD
,
216 * Disable all display connectors on the interface module.
218 static void impd1fb_clcd_disable(struct clcd_fb
*fb
)
220 impd1_tweak_control(fb
->dev
->dev
.parent
, IMPD1_CTRL_DISP_MASK
, 0);
224 * Enable the relevant connector on the interface module.
226 static void impd1fb_clcd_enable(struct clcd_fb
*fb
)
228 impd1_tweak_control(fb
->dev
->dev
.parent
, IMPD1_CTRL_DISP_MASK
,
229 fb
->panel
->connector
| IMPD1_CTRL_DISP_ENABLE
);
232 static int impd1fb_clcd_setup(struct clcd_fb
*fb
)
234 unsigned long framebase
= fb
->dev
->res
.start
+ 0x01000000;
235 unsigned long framesize
= SZ_1M
;
238 fb
->panel
= &PANELTYPE
;
240 if (!request_mem_region(framebase
, framesize
, "clcd framebuffer")) {
241 printk(KERN_ERR
"IM-PD1: unable to reserve framebuffer\n");
245 fb
->fb
.screen_base
= ioremap(framebase
, framesize
);
246 if (!fb
->fb
.screen_base
) {
247 printk(KERN_ERR
"IM-PD1: unable to map framebuffer\n");
252 fb
->fb
.fix
.smem_start
= framebase
;
253 fb
->fb
.fix
.smem_len
= framesize
;
258 release_mem_region(framebase
, framesize
);
262 static void impd1fb_clcd_remove(struct clcd_fb
*fb
)
264 iounmap(fb
->fb
.screen_base
);
265 release_mem_region(fb
->fb
.fix
.smem_start
, fb
->fb
.fix
.smem_len
);
268 static struct clcd_board impd1_clcd_data
= {
270 .check
= clcdfb_check
,
271 .decode
= clcdfb_decode
,
272 .disable
= impd1fb_clcd_disable
,
273 .enable
= impd1fb_clcd_enable
,
274 .setup
= impd1fb_clcd_setup
,
275 .remove
= impd1fb_clcd_remove
,
278 struct impd1_device
{
279 unsigned long offset
;
285 static struct impd1_device impd1_devs
[] = {
287 .offset
= 0x03000000,
290 .offset
= 0x00100000,
294 .offset
= 0x00200000,
298 .offset
= 0x00300000,
302 .offset
= 0x00400000,
306 .offset
= 0x00500000,
310 .offset
= 0x00600000,
314 .offset
= 0x00700000,
318 .offset
= 0x00800000,
322 .offset
= 0x01000000,
325 .platform_data
= &impd1_clcd_data
,
329 static const char *impd1_vconames
[2] = {
334 static int impd1_probe(struct lm_device
*dev
)
336 struct impd1_module
*impd1
;
339 if (dev
->id
!= module_id
)
342 if (!request_mem_region(dev
->resource
.start
, SZ_4K
, "LM registers"))
345 impd1
= kmalloc(sizeof(struct impd1_module
), GFP_KERNEL
);
350 memset(impd1
, 0, sizeof(struct impd1_module
));
352 impd1
->base
= ioremap(dev
->resource
.start
, SZ_4K
);
358 lm_set_drvdata(dev
, impd1
);
360 printk("IM-PD1 found at 0x%08lx\n", dev
->resource
.start
);
362 for (i
= 0; i
< ARRAY_SIZE(impd1
->vcos
); i
++) {
363 impd1
->vcos
[i
].owner
= THIS_MODULE
,
364 impd1
->vcos
[i
].name
= impd1_vconames
[i
],
365 impd1
->vcos
[i
].params
= &impd1_vco_params
,
366 impd1
->vcos
[i
].data
= impd1
,
367 impd1
->vcos
[i
].setvco
= impd1_setvco
;
369 clk_register(&impd1
->vcos
[i
]);
372 for (i
= 0; i
< ARRAY_SIZE(impd1_devs
); i
++) {
373 struct impd1_device
*idev
= impd1_devs
+ i
;
374 struct amba_device
*d
;
375 unsigned long pc_base
;
377 pc_base
= dev
->resource
.start
+ idev
->offset
;
379 d
= kmalloc(sizeof(struct amba_device
), GFP_KERNEL
);
383 memset(d
, 0, sizeof(struct amba_device
));
385 snprintf(d
->dev
.bus_id
, sizeof(d
->dev
.bus_id
),
386 "lm%x:%5.5lx", dev
->id
, idev
->offset
>> 12);
388 d
->dev
.parent
= &dev
->dev
;
389 d
->res
.start
= dev
->resource
.start
+ idev
->offset
;
390 d
->res
.end
= d
->res
.start
+ SZ_4K
- 1;
391 d
->res
.flags
= IORESOURCE_MEM
;
392 d
->irq
[0] = dev
->irq
;
393 d
->irq
[1] = dev
->irq
;
394 d
->periphid
= idev
->id
;
395 d
->dev
.platform_data
= idev
->platform_data
;
397 ret
= amba_device_register(d
, &dev
->resource
);
399 printk("unable to register device %s: %d\n",
408 if (impd1
&& impd1
->base
)
409 iounmap(impd1
->base
);
413 release_mem_region(dev
->resource
.start
, SZ_4K
);
417 static void impd1_remove(struct lm_device
*dev
)
419 struct impd1_module
*impd1
= lm_get_drvdata(dev
);
420 struct list_head
*l
, *n
;
423 list_for_each_safe(l
, n
, &dev
->dev
.children
) {
424 struct device
*d
= list_to_dev(l
);
426 device_unregister(d
);
429 for (i
= 0; i
< ARRAY_SIZE(impd1
->vcos
); i
++)
430 clk_unregister(&impd1
->vcos
[i
]);
432 lm_set_drvdata(dev
, NULL
);
434 iounmap(impd1
->base
);
436 release_mem_region(dev
->resource
.start
, SZ_4K
);
439 static struct lm_driver impd1_driver
= {
443 .probe
= impd1_probe
,
444 .remove
= impd1_remove
,
447 static int __init
impd1_init(void)
449 return lm_driver_register(&impd1_driver
);
452 static void __exit
impd1_exit(void)
454 lm_driver_unregister(&impd1_driver
);
457 module_init(impd1_init
);
458 module_exit(impd1_exit
);
460 MODULE_LICENSE("GPL");
461 MODULE_DESCRIPTION("Integrator/IM-PD1 logic module core driver");
462 MODULE_AUTHOR("Deep Blue Solutions Ltd");