Merge branch 'kvm-updates/2.6.37' of git://git.kernel.org/pub/scm/virt/kvm/kvm
[pandora-kernel.git] / arch / arm / mach-ux500 / board-mop500.c
1 /*
2  * Copyright (C) 2008-2009 ST-Ericsson
3  *
4  * Author: Srinidhi KASAGAR <srinidhi.kasagar@stericsson.com>
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, as
8  * published by the Free Software Foundation.
9  *
10  */
11 #include <linux/kernel.h>
12 #include <linux/init.h>
13 #include <linux/interrupt.h>
14 #include <linux/platform_device.h>
15 #include <linux/io.h>
16 #include <linux/gpio.h>
17 #include <linux/amba/bus.h>
18 #include <linux/amba/pl022.h>
19 #include <linux/spi/spi.h>
20 #include <linux/mfd/ab8500.h>
21
22 #include <asm/mach-types.h>
23 #include <asm/mach/arch.h>
24
25 #include <plat/pincfg.h>
26 #include <plat/i2c.h>
27
28 #include <mach/hardware.h>
29 #include <mach/setup.h>
30 #include <mach/devices.h>
31 #include <mach/irqs.h>
32
33 #include "pins-db8500.h"
34 #include "board-mop500.h"
35
36 static pin_cfg_t mop500_pins[] = {
37         /* SSP0 */
38         GPIO143_SSP0_CLK,
39         GPIO144_SSP0_FRM,
40         GPIO145_SSP0_RXD,
41         GPIO146_SSP0_TXD,
42
43         /* I2C */
44         GPIO147_I2C0_SCL,
45         GPIO148_I2C0_SDA,
46         GPIO16_I2C1_SCL,
47         GPIO17_I2C1_SDA,
48         GPIO10_I2C2_SDA,
49         GPIO11_I2C2_SCL,
50         GPIO229_I2C3_SDA,
51         GPIO230_I2C3_SCL,
52 };
53
54 static void ab4500_spi_cs_control(u32 command)
55 {
56         /* set the FRM signal, which is CS  - TODO */
57 }
58
59 struct pl022_config_chip ab4500_chip_info = {
60         .com_mode = INTERRUPT_TRANSFER,
61         .iface = SSP_INTERFACE_MOTOROLA_SPI,
62         /* we can act as master only */
63         .hierarchy = SSP_MASTER,
64         .slave_tx_disable = 0,
65         .rx_lev_trig = SSP_RX_1_OR_MORE_ELEM,
66         .tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC,
67         .cs_control = ab4500_spi_cs_control,
68 };
69
70 static struct ab8500_platform_data ab8500_platdata = {
71         .irq_base       = MOP500_AB8500_IRQ_BASE,
72 };
73
74 static struct resource ab8500_resources[] = {
75         [0] = {
76                 .start = IRQ_AB8500,
77                 .end = IRQ_AB8500,
78                 .flags = IORESOURCE_IRQ
79         }
80 };
81
82 struct platform_device ab8500_device = {
83         .name = "ab8500-i2c",
84         .id = 0,
85         .dev = {
86                 .platform_data = &ab8500_platdata,
87         },
88         .num_resources = 1,
89         .resource = ab8500_resources,
90 };
91
92 static struct spi_board_info ab8500_spi_devices[] = {
93         {
94                 .modalias = "ab8500-spi",
95                 .controller_data = &ab4500_chip_info,
96                 .platform_data = &ab8500_platdata,
97                 .max_speed_hz = 12000000,
98                 .bus_num = 0,
99                 .chip_select = 0,
100                 .mode = SPI_MODE_3,
101                 .irq = IRQ_DB8500_AB8500,
102         },
103 };
104
105 static struct pl022_ssp_controller ssp0_platform_data = {
106         .bus_id = 0,
107         /* pl022 not yet supports dma */
108         .enable_dma = 0,
109         /* on this platform, gpio 31,142,144,214 &
110          * 224 are connected as chip selects
111          */
112         .num_chipselect = 5,
113 };
114
115 #define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \
116 static struct nmk_i2c_controller u8500_i2c##id##_data = { \
117         /*                              \
118          * slave data setup time, which is      \
119          * 250 ns,100ns,10ns which is 14,6,2    \
120          * respectively for a 48 Mhz    \
121          * i2c clock                    \
122          */                             \
123         .slsu           = _slsu,        \
124         /* Tx FIFO threshold */         \
125         .tft            = _tft,         \
126         /* Rx FIFO threshold */         \
127         .rft            = _rft,         \
128         /* std. mode operation */       \
129         .clk_freq       = clk,          \
130         .sm             = _sm,          \
131 }
132
133 /*
134  * The board uses 4 i2c controllers, initialize all of
135  * them with slave data setup time of 250 ns,
136  * Tx & Rx FIFO threshold values as 1 and standard
137  * mode of operation
138  */
139 U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
140 U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
141 U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
142 U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
143
144 static struct amba_device *amba_devs[] __initdata = {
145         &ux500_uart0_device,
146         &ux500_uart1_device,
147         &ux500_uart2_device,
148         &u8500_ssp0_device,
149 };
150
151 /* add any platform devices here - TODO */
152 static struct platform_device *platform_devs[] __initdata = {
153         &u8500_i2c0_device,
154         &ux500_i2c1_device,
155         &ux500_i2c2_device,
156         &ux500_i2c3_device,
157 };
158
159 static void __init u8500_init_machine(void)
160 {
161         int i;
162
163         u8500_init_devices();
164
165         nmk_config_pins(mop500_pins, ARRAY_SIZE(mop500_pins));
166
167         u8500_i2c0_device.dev.platform_data = &u8500_i2c0_data;
168         ux500_i2c1_device.dev.platform_data = &u8500_i2c1_data;
169         ux500_i2c2_device.dev.platform_data = &u8500_i2c2_data;
170         ux500_i2c3_device.dev.platform_data = &u8500_i2c3_data;
171
172         u8500_ssp0_device.dev.platform_data = &ssp0_platform_data;
173
174         /* Register the active AMBA devices on this board */
175         for (i = 0; i < ARRAY_SIZE(amba_devs); i++)
176                 amba_device_register(amba_devs[i], &iomem_resource);
177
178         platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
179
180         mop500_sdi_init();
181
182         /* If HW is early drop (ED) or V1.0 then use SPI to access AB8500 */
183         if (cpu_is_u8500ed() || cpu_is_u8500v10())
184                 spi_register_board_info(ab8500_spi_devices,
185                         ARRAY_SIZE(ab8500_spi_devices));
186         else /* If HW is v.1.1 or later use I2C to access AB8500 */
187                 platform_device_register(&ab8500_device);
188 }
189
190 MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
191         /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
192         .boot_params    = 0x100,
193         .map_io         = u8500_map_io,
194         .init_irq       = ux500_init_irq,
195         /* we re-use nomadik timer here */
196         .timer          = &ux500_timer,
197         .init_machine   = u8500_init_machine,
198 MACHINE_END