1 /* linux/arch/arm/mach-vt8500/devices.c
3 * Copyright (C) 2010 Alexey Charkov <alchark@gmail.com>
5 * This software is licensed under the terms of the GNU General Public
6 * License version 2, as published by the Free Software Foundation, and
7 * may be copied, distributed, and modified under those terms.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
16 #include <linux/kernel.h>
18 #include <linux/device.h>
19 #include <linux/dma-mapping.h>
20 #include <linux/platform_device.h>
21 #include <linux/pwm_backlight.h>
22 #include <linux/memblock.h>
24 #include <asm/mach/arch.h>
26 #include <mach/vt8500fb.h>
27 #include <mach/i8042.h>
30 /* These can't use resources currently */
31 unsigned long wmt_ic_base __initdata;
32 unsigned long wmt_sic_base __initdata;
33 unsigned long wmt_gpio_base __initdata;
34 unsigned long wmt_pmc_base __initdata;
35 unsigned long wmt_i8042_base __initdata;
37 int wmt_nr_irqs __initdata;
38 int wmt_timer_irq __initdata;
39 int wmt_gpio_ext_irq[8] __initdata;
41 /* Should remain accessible after init.
42 * i8042 driver desperately calls for attention...
44 int wmt_i8042_kbd_irq;
45 int wmt_i8042_aux_irq;
47 static u64 fb_dma_mask = DMA_BIT_MASK(32);
49 struct platform_device vt8500_device_lcdc = {
53 .dma_mask = &fb_dma_mask,
54 .coherent_dma_mask = DMA_BIT_MASK(32),
58 struct platform_device vt8500_device_wm8505_fb = {
63 /* Smallest to largest */
64 static struct vt8500fb_platform_data panels[] = {
65 #ifdef CONFIG_WMT_PANEL_800X480
68 .yres_virtual = 480 * 2,
79 .vmode = FB_VMODE_NONINTERLACED,
83 #ifdef CONFIG_WMT_PANEL_800X600
86 .yres_virtual = 600 * 2,
97 .vmode = FB_VMODE_NONINTERLACED,
101 #ifdef CONFIG_WMT_PANEL_1024X576
103 .xres_virtual = 1024,
104 .yres_virtual = 576 * 2,
115 .vmode = FB_VMODE_NONINTERLACED,
119 #ifdef CONFIG_WMT_PANEL_1024X600
121 .xres_virtual = 1024,
122 .yres_virtual = 600 * 2,
133 .vmode = FB_VMODE_NONINTERLACED,
139 static int current_panel_idx __initdata = ARRAY_SIZE(panels) - 1;
141 static int __init panel_setup(char *str)
145 for (i = 0; i < ARRAY_SIZE(panels); i++) {
146 if (strcmp(panels[i].mode.name, str) == 0) {
147 current_panel_idx = i;
154 early_param("panel", panel_setup);
156 static inline void preallocate_fb(struct vt8500fb_platform_data *p,
157 unsigned long align) {
158 p->video_mem_len = (p->xres_virtual * p->yres_virtual * 4) >>
159 (p->bpp > 16 ? 0 : (p->bpp > 8 ? 1 :
161 p->video_mem_phys = (unsigned long)memblock_alloc(p->video_mem_len,
163 p->video_mem_virt = phys_to_virt(p->video_mem_phys);
166 struct platform_device vt8500_device_uart0 = {
167 .name = "vt8500_serial",
171 struct platform_device vt8500_device_uart1 = {
172 .name = "vt8500_serial",
176 struct platform_device vt8500_device_uart2 = {
177 .name = "vt8500_serial",
181 struct platform_device vt8500_device_uart3 = {
182 .name = "vt8500_serial",
186 struct platform_device vt8500_device_uart4 = {
187 .name = "vt8500_serial",
191 struct platform_device vt8500_device_uart5 = {
192 .name = "vt8500_serial",
196 static u64 ehci_dma_mask = DMA_BIT_MASK(32);
198 struct platform_device vt8500_device_ehci = {
199 .name = "vt8500-ehci",
202 .dma_mask = &ehci_dma_mask,
203 .coherent_dma_mask = DMA_BIT_MASK(32),
207 struct platform_device vt8500_device_ge_rops = {
208 .name = "wmt_ge_rops",
212 struct platform_device vt8500_device_pwm = {
213 .name = "vt8500-pwm",
217 static struct platform_pwm_backlight_data vt8500_pwmbl_data = {
219 .max_brightness = 128,
220 .dft_brightness = 70,
221 .pwm_period_ns = 250000, /* revisit when clocks are implemented */
224 struct platform_device vt8500_device_pwmbl = {
225 .name = "pwm-backlight",
228 .platform_data = &vt8500_pwmbl_data,
232 struct platform_device vt8500_device_rtc = {
233 .name = "vt8500-rtc",
237 struct map_desc wmt_io_desc[] __initdata = {
238 /* SoC MMIO registers */
240 .virtual = 0xf8000000,
241 .pfn = __phys_to_pfn(0xd8000000),
242 .length = 0x00390000, /* max of all chip variants */
245 /* PCI I/O space, numbers tied to those in <mach/io.h> */
247 .virtual = 0xf0000000,
248 .pfn = __phys_to_pfn(0xc0000000),
254 void __init vt8500_reserve_mem(void)
256 #ifdef CONFIG_FB_VT8500
257 panels[current_panel_idx].bpp = 16; /* Always use RGB565 */
258 preallocate_fb(&panels[current_panel_idx], SZ_4M);
259 vt8500_device_lcdc.dev.platform_data = &panels[current_panel_idx];
263 void __init wm8505_reserve_mem(void)
265 #if defined CONFIG_FB_WM8505
266 panels[current_panel_idx].bpp = 32; /* Always use RGB888 */
267 preallocate_fb(&panels[current_panel_idx], 32);
268 vt8500_device_wm8505_fb.dev.platform_data = &panels[current_panel_idx];