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>
23 #include <asm/hardware/icst525.h>
24 #include <asm/hardware/amba.h>
25 #include <asm/hardware/amba_clcd.h>
26 #include <asm/arch/lm.h>
27 #include <asm/arch/impd1.h>
28 #include <asm/sizes.h>
34 module_param_named(lmid
, module_id
, int, 0444);
35 MODULE_PARM_DESC(lmid
, "logic module stack position");
42 static const struct icst525_params impd1_vco_params
= {
43 .ref
= 24000, /* 24 MHz */
44 .vco_max
= 200000, /* 200 MHz */
51 static void impd1_setvco(struct clk
*clk
, struct icst525_vco vco
)
53 struct impd1_module
*impd1
= clk
->data
;
54 int vconr
= clk
- impd1
->vcos
;
57 val
= vco
.v
| (vco
.r
<< 9) | (vco
.s
<< 16);
59 writel(0xa05f, impd1
->base
+ IMPD1_LOCK
);
62 writel(val
, impd1
->base
+ IMPD1_OSC1
);
65 writel(val
, impd1
->base
+ IMPD1_OSC2
);
68 writel(0, impd1
->base
+ IMPD1_LOCK
);
72 vco
.r
= (val
>> 9) & 0x7f;
73 vco
.s
= (val
>> 16) & 7;
75 pr_debug("IM-PD1: VCO%d clock is %ld kHz\n",
76 vconr
, icst525_khz(&impd1_vco_params
, vco
));
80 void impd1_tweak_control(struct device
*dev
, u32 mask
, u32 val
)
82 struct impd1_module
*impd1
= dev_get_drvdata(dev
);
86 cur
= readl(impd1
->base
+ IMPD1_CTRL
) & ~mask
;
87 writel(cur
| val
, impd1
->base
+ IMPD1_CTRL
);
90 EXPORT_SYMBOL(impd1_tweak_control
);
95 #define PANEL PROSPECTOR
103 #define PANELTYPE vga
104 static struct clcd_panel vga
= {
118 .vmode
= FB_VMODE_NONINTERLACED
,
122 .tim2
= TIM2_BCD
| TIM2_IPC
,
123 .cntl
= CNTL_LCDTFT
| CNTL_LCDVCOMP(1),
124 .connector
= IMPD1_CTRL_DISP_VGA
,
130 #define PANELTYPE svga
131 static struct clcd_panel svga
= {
145 .vmode
= FB_VMODE_NONINTERLACED
,
150 .cntl
= CNTL_LCDTFT
| CNTL_LCDVCOMP(1),
151 .connector
= IMPD1_CTRL_DISP_VGA
,
156 #elif PANEL == PROSPECTOR
157 #define PANELTYPE prospector
158 static struct clcd_panel prospector
= {
160 .name
= "PROSPECTOR",
171 .sync
= FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
,
172 .vmode
= FB_VMODE_NONINTERLACED
,
177 .cntl
= CNTL_LCDTFT
| CNTL_LCDVCOMP(1),
179 .connector
= IMPD1_CTRL_DISP_LCD
,
184 #elif PANEL == LTM10C209
185 #define PANELTYPE ltm10c209
189 static struct clcd_panel ltm10c209
= {
202 .sync
= FB_SYNC_HOR_HIGH_ACT
| FB_SYNC_VERT_HIGH_ACT
,
203 .vmode
= FB_VMODE_NONINTERLACED
,
208 .cntl
= CNTL_LCDTFT
| CNTL_LCDVCOMP(1),
210 .connector
= IMPD1_CTRL_DISP_LCD
,
217 * Disable all display connectors on the interface module.
219 static void impd1fb_clcd_disable(struct clcd_fb
*fb
)
221 impd1_tweak_control(fb
->dev
->dev
.parent
, IMPD1_CTRL_DISP_MASK
, 0);
225 * Enable the relevant connector on the interface module.
227 static void impd1fb_clcd_enable(struct clcd_fb
*fb
)
229 impd1_tweak_control(fb
->dev
->dev
.parent
, IMPD1_CTRL_DISP_MASK
,
230 fb
->panel
->connector
| IMPD1_CTRL_DISP_ENABLE
);
233 static int impd1fb_clcd_setup(struct clcd_fb
*fb
)
235 unsigned long framebase
= fb
->dev
->res
.start
+ 0x01000000;
236 unsigned long framesize
= SZ_1M
;
239 fb
->panel
= &PANELTYPE
;
241 if (!request_mem_region(framebase
, framesize
, "clcd framebuffer")) {
242 printk(KERN_ERR
"IM-PD1: unable to reserve framebuffer\n");
246 fb
->fb
.screen_base
= ioremap(framebase
, framesize
);
247 if (!fb
->fb
.screen_base
) {
248 printk(KERN_ERR
"IM-PD1: unable to map framebuffer\n");
253 fb
->fb
.fix
.smem_start
= framebase
;
254 fb
->fb
.fix
.smem_len
= framesize
;
259 release_mem_region(framebase
, framesize
);
263 static int impd1fb_clcd_mmap(struct clcd_fb
*fb
, struct vm_area_struct
*vma
)
265 unsigned long start
, size
;
267 start
= vma
->vm_pgoff
+ (fb
->fb
.fix
.smem_start
>> PAGE_SHIFT
);
268 size
= vma
->vm_end
- vma
->vm_start
;
270 return remap_pfn_range(vma
, vma
->vm_start
, start
, size
,
274 static void impd1fb_clcd_remove(struct clcd_fb
*fb
)
276 iounmap(fb
->fb
.screen_base
);
277 release_mem_region(fb
->fb
.fix
.smem_start
, fb
->fb
.fix
.smem_len
);
280 static struct clcd_board impd1_clcd_data
= {
282 .check
= clcdfb_check
,
283 .decode
= clcdfb_decode
,
284 .disable
= impd1fb_clcd_disable
,
285 .enable
= impd1fb_clcd_enable
,
286 .setup
= impd1fb_clcd_setup
,
287 .mmap
= impd1fb_clcd_mmap
,
288 .remove
= impd1fb_clcd_remove
,
291 struct impd1_device
{
292 unsigned long offset
;
298 static struct impd1_device impd1_devs
[] = {
300 .offset
= 0x03000000,
303 .offset
= 0x00100000,
307 .offset
= 0x00200000,
311 .offset
= 0x00300000,
315 .offset
= 0x00400000,
319 .offset
= 0x00500000,
323 .offset
= 0x00600000,
327 .offset
= 0x00700000,
331 .offset
= 0x00800000,
335 .offset
= 0x01000000,
338 .platform_data
= &impd1_clcd_data
,
342 static const char *impd1_vconames
[2] = {
347 static int impd1_probe(struct lm_device
*dev
)
349 struct impd1_module
*impd1
;
352 if (dev
->id
!= module_id
)
355 if (!request_mem_region(dev
->resource
.start
, SZ_4K
, "LM registers"))
358 impd1
= kmalloc(sizeof(struct impd1_module
), GFP_KERNEL
);
363 memset(impd1
, 0, sizeof(struct impd1_module
));
365 impd1
->base
= ioremap(dev
->resource
.start
, SZ_4K
);
371 lm_set_drvdata(dev
, impd1
);
373 printk("IM-PD1 found at 0x%08lx\n", dev
->resource
.start
);
375 for (i
= 0; i
< ARRAY_SIZE(impd1
->vcos
); i
++) {
376 impd1
->vcos
[i
].owner
= THIS_MODULE
,
377 impd1
->vcos
[i
].name
= impd1_vconames
[i
],
378 impd1
->vcos
[i
].params
= &impd1_vco_params
,
379 impd1
->vcos
[i
].data
= impd1
,
380 impd1
->vcos
[i
].setvco
= impd1_setvco
;
382 clk_register(&impd1
->vcos
[i
]);
385 for (i
= 0; i
< ARRAY_SIZE(impd1_devs
); i
++) {
386 struct impd1_device
*idev
= impd1_devs
+ i
;
387 struct amba_device
*d
;
388 unsigned long pc_base
;
390 pc_base
= dev
->resource
.start
+ idev
->offset
;
392 d
= kmalloc(sizeof(struct amba_device
), GFP_KERNEL
);
396 memset(d
, 0, sizeof(struct amba_device
));
398 snprintf(d
->dev
.bus_id
, sizeof(d
->dev
.bus_id
),
399 "lm%x:%5.5lx", dev
->id
, idev
->offset
>> 12);
401 d
->dev
.parent
= &dev
->dev
;
402 d
->res
.start
= dev
->resource
.start
+ idev
->offset
;
403 d
->res
.end
= d
->res
.start
+ SZ_4K
- 1;
404 d
->res
.flags
= IORESOURCE_MEM
;
405 d
->irq
[0] = dev
->irq
;
406 d
->irq
[1] = dev
->irq
;
407 d
->periphid
= idev
->id
;
408 d
->dev
.platform_data
= idev
->platform_data
;
410 ret
= amba_device_register(d
, &dev
->resource
);
412 printk("unable to register device %s: %d\n",
421 if (impd1
&& impd1
->base
)
422 iounmap(impd1
->base
);
426 release_mem_region(dev
->resource
.start
, SZ_4K
);
430 static void impd1_remove(struct lm_device
*dev
)
432 struct impd1_module
*impd1
= lm_get_drvdata(dev
);
433 struct list_head
*l
, *n
;
436 list_for_each_safe(l
, n
, &dev
->dev
.children
) {
437 struct device
*d
= list_to_dev(l
);
439 device_unregister(d
);
442 for (i
= 0; i
< ARRAY_SIZE(impd1
->vcos
); i
++)
443 clk_unregister(&impd1
->vcos
[i
]);
445 lm_set_drvdata(dev
, NULL
);
447 iounmap(impd1
->base
);
449 release_mem_region(dev
->resource
.start
, SZ_4K
);
452 static struct lm_driver impd1_driver
= {
456 .probe
= impd1_probe
,
457 .remove
= impd1_remove
,
460 static int __init
impd1_init(void)
462 return lm_driver_register(&impd1_driver
);
465 static void __exit
impd1_exit(void)
467 lm_driver_unregister(&impd1_driver
);
470 module_init(impd1_init
);
471 module_exit(impd1_exit
);
473 MODULE_LICENSE("GPL");
474 MODULE_DESCRIPTION("Integrator/IM-PD1 logic module core driver");
475 MODULE_AUTHOR("Deep Blue Solutions Ltd");