Merge branch 'for-linus' of git://opensource.wolfsonmicro.com/regulator
[pandora-kernel.git] / arch / arm / mach-netx / nxeb500hmi.c
1 /*
2  * arch/arm/mach-netx/nxeb500hmi.c
3  *
4  * Copyright (c) 2005 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
5  *
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
8  * as published by the Free Software Foundation.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19
20 #include <linux/dma-mapping.h>
21 #include <linux/init.h>
22 #include <linux/interrupt.h>
23 #include <linux/mtd/plat-ram.h>
24 #include <linux/platform_device.h>
25 #include <linux/amba/bus.h>
26 #include <linux/amba/clcd.h>
27
28 #include <mach/hardware.h>
29 #include <asm/mach-types.h>
30 #include <asm/mach/arch.h>
31 #include <mach/netx-regs.h>
32 #include <mach/eth.h>
33
34 #include "generic.h"
35 #include "fb.h"
36
37 static struct clcd_panel qvga = {
38         .mode           = {
39                 .name           = "QVGA",
40                 .refresh        = 60,
41                 .xres           = 240,
42                 .yres           = 320,
43                 .pixclock       = 187617,
44                 .left_margin    = 6,
45                 .right_margin   = 26,
46                 .upper_margin   = 0,
47                 .lower_margin   = 6,
48                 .hsync_len      = 6,
49                 .vsync_len      = 1,
50                 .sync           = 0,
51                 .vmode          = FB_VMODE_NONINTERLACED,
52         },
53         .width          = -1,
54         .height         = -1,
55         .tim2           =  16,
56         .cntl           = CNTL_LCDTFT | CNTL_BGR,
57         .bpp            = 16,
58         .grayscale      = 0,
59 };
60
61 static inline int nxeb500hmi_check(struct clcd_fb *fb, struct fb_var_screeninfo *var)
62 {
63         var->green.length = 5;
64         var->green.msb_right = 0;
65
66         return clcdfb_check(fb, var);
67 }
68
69 static int nxeb500hmi_clcd_setup(struct clcd_fb *fb)
70 {
71         unsigned int val;
72
73         fb->fb.var.green.length = 5;
74         fb->fb.var.green.msb_right = 0;
75
76         /* enable asic control */
77         val = readl(NETX_SYSTEM_IOC_ACCESS_KEY);
78         writel(val, NETX_SYSTEM_IOC_ACCESS_KEY);
79
80         writel(3, NETX_SYSTEM_IOC_CR);
81
82         /* GPIO 14 is used for display enable on newer boards */
83         writel(9, NETX_GPIO_CFG(14));
84
85         val = readl(NETX_PIO_OUTPIO);
86         writel(val | 1, NETX_PIO_OUTPIO);
87
88         val = readl(NETX_PIO_OEPIO);
89         writel(val | 1, NETX_PIO_OEPIO);
90         return netx_clcd_setup(fb);
91 }
92
93 static struct clcd_board clcd_data = {
94         .name           = "netX",
95         .check          = nxeb500hmi_check,
96         .decode         = clcdfb_decode,
97         .enable         = netx_clcd_enable,
98         .setup          = nxeb500hmi_clcd_setup,
99         .mmap           = netx_clcd_mmap,
100         .remove         = netx_clcd_remove,
101 };
102
103 static struct netxeth_platform_data eth0_platform_data = {
104         .xcno = 0,
105 };
106
107 static struct platform_device netx_eth0_device = {
108         .name           = "netx-eth",
109         .id             = 0,
110         .num_resources  = 0,
111         .resource       = NULL,
112         .dev = {
113                 .platform_data = &eth0_platform_data,
114         }
115 };
116
117 static struct netxeth_platform_data eth1_platform_data = {
118         .xcno = 1,
119 };
120
121 static struct platform_device netx_eth1_device = {
122         .name           = "netx-eth",
123         .id             = 1,
124         .num_resources  = 0,
125         .resource       = NULL,
126         .dev = {
127                 .platform_data = &eth1_platform_data,
128         }
129 };
130
131 static struct resource netx_cf_resources[] = {
132         [0] = {
133                 .start  = 0x20000000,
134                 .end    = 0x25ffffff,
135                 .flags  = IORESOURCE_MEM | IORESOURCE_MEM_8AND16BIT,
136         },
137 };
138
139 static struct platform_device netx_cf_device = {
140         .name           = "netx-cf",
141         .id             = 0,
142         .resource       = netx_cf_resources,
143         .num_resources  = ARRAY_SIZE(netx_cf_resources),
144 };
145
146 static struct resource netx_uart0_resources[] = {
147         [0] = {
148                 .start  = 0x00100A00,
149                 .end    = 0x00100A3F,
150                 .flags  = IORESOURCE_MEM,
151         },
152         [1] = {
153                 .start  = (NETX_IRQ_UART0),
154                 .end    = (NETX_IRQ_UART0),
155                 .flags  = IORESOURCE_IRQ,
156         },
157 };
158
159 static struct platform_device netx_uart0_device = {
160         .name           = "netx-uart",
161         .id             = 0,
162         .num_resources  = ARRAY_SIZE(netx_uart0_resources),
163         .resource       = netx_uart0_resources,
164 };
165
166 static struct platform_device *devices[] __initdata = {
167         &netx_eth0_device,
168         &netx_eth1_device,
169         &netx_cf_device,
170         &netx_uart0_device,
171 };
172
173 static void __init nxeb500hmi_init(void)
174 {
175         netx_fb_init(&clcd_data, &qvga);
176         platform_add_devices(devices, ARRAY_SIZE(devices));
177 }
178
179 MACHINE_START(NXEB500HMI, "Hilscher nxeb500hmi")
180         .atag_offset    = 0x100,
181         .map_io         = netx_map_io,
182         .init_irq       = netx_init_irq,
183         .timer          = &netx_timer,
184         .init_machine   = nxeb500hmi_init,
185 MACHINE_END