Merge git://git.infradead.org/iommu-2.6
[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
32 #include "pins-db8500.h"
33
34 static pin_cfg_t mop500_pins[] = {
35         /* SSP0 */
36         GPIO143_SSP0_CLK,
37         GPIO144_SSP0_FRM,
38         GPIO145_SSP0_RXD,
39         GPIO146_SSP0_TXD,
40
41         /* I2C */
42         GPIO147_I2C0_SCL,
43         GPIO148_I2C0_SDA,
44         GPIO16_I2C1_SCL,
45         GPIO17_I2C1_SDA,
46         GPIO10_I2C2_SDA,
47         GPIO11_I2C2_SCL,
48         GPIO229_I2C3_SDA,
49         GPIO230_I2C3_SCL,
50 };
51
52 static void ab4500_spi_cs_control(u32 command)
53 {
54         /* set the FRM signal, which is CS  - TODO */
55 }
56
57 struct pl022_config_chip ab4500_chip_info = {
58         .lbm = LOOPBACK_DISABLED,
59         .com_mode = INTERRUPT_TRANSFER,
60         .iface = SSP_INTERFACE_MOTOROLA_SPI,
61         /* we can act as master only */
62         .hierarchy = SSP_MASTER,
63         .slave_tx_disable = 0,
64         .endian_rx = SSP_RX_MSB,
65         .endian_tx = SSP_TX_MSB,
66         .data_size = SSP_DATA_BITS_24,
67         .rx_lev_trig = SSP_RX_1_OR_MORE_ELEM,
68         .tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC,
69         .clk_phase = SSP_CLK_SECOND_EDGE,
70         .clk_pol = SSP_CLK_POL_IDLE_HIGH,
71         .cs_control = ab4500_spi_cs_control,
72 };
73
74 static struct ab8500_platform_data ab8500_platdata = {
75         .irq_base       = MOP500_AB8500_IRQ_BASE,
76 };
77
78 static struct spi_board_info u8500_spi_devices[] = {
79         {
80                 .modalias = "ab8500",
81                 .controller_data = &ab4500_chip_info,
82                 .platform_data = &ab8500_platdata,
83                 .max_speed_hz = 12000000,
84                 .bus_num = 0,
85                 .chip_select = 0,
86                 .mode = SPI_MODE_0,
87                 .irq = IRQ_DB8500_AB8500,
88         },
89 };
90
91 static struct pl022_ssp_controller ssp0_platform_data = {
92         .bus_id = 0,
93         /* pl022 not yet supports dma */
94         .enable_dma = 0,
95         /* on this platform, gpio 31,142,144,214 &
96          * 224 are connected as chip selects
97          */
98         .num_chipselect = 5,
99 };
100
101 #define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \
102 static struct nmk_i2c_controller u8500_i2c##id##_data = { \
103         /*                              \
104          * slave data setup time, which is      \
105          * 250 ns,100ns,10ns which is 14,6,2    \
106          * respectively for a 48 Mhz    \
107          * i2c clock                    \
108          */                             \
109         .slsu           = _slsu,        \
110         /* Tx FIFO threshold */         \
111         .tft            = _tft,         \
112         /* Rx FIFO threshold */         \
113         .rft            = _rft,         \
114         /* std. mode operation */       \
115         .clk_freq       = clk,          \
116         .sm             = _sm,          \
117 }
118
119 /*
120  * The board uses 4 i2c controllers, initialize all of
121  * them with slave data setup time of 250 ns,
122  * Tx & Rx FIFO threshold values as 1 and standard
123  * mode of operation
124  */
125 U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
126 U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
127 U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
128 U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
129
130 static struct amba_device *amba_devs[] __initdata = {
131         &ux500_uart0_device,
132         &ux500_uart1_device,
133         &ux500_uart2_device,
134         &u8500_ssp0_device,
135 };
136
137 /* add any platform devices here - TODO */
138 static struct platform_device *platform_devs[] __initdata = {
139         &u8500_i2c0_device,
140         &ux500_i2c1_device,
141         &ux500_i2c2_device,
142         &ux500_i2c3_device,
143 };
144
145 static void __init u8500_init_machine(void)
146 {
147         int i;
148
149         u8500_init_devices();
150
151         nmk_config_pins(mop500_pins, ARRAY_SIZE(mop500_pins));
152
153         u8500_i2c0_device.dev.platform_data = &u8500_i2c0_data;
154         ux500_i2c1_device.dev.platform_data = &u8500_i2c1_data;
155         ux500_i2c2_device.dev.platform_data = &u8500_i2c2_data;
156         ux500_i2c3_device.dev.platform_data = &u8500_i2c3_data;
157
158         u8500_ssp0_device.dev.platform_data = &ssp0_platform_data;
159
160         /* Register the active AMBA devices on this board */
161         for (i = 0; i < ARRAY_SIZE(amba_devs); i++)
162                 amba_device_register(amba_devs[i], &iomem_resource);
163
164         platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
165
166         spi_register_board_info(u8500_spi_devices,
167                         ARRAY_SIZE(u8500_spi_devices));
168 }
169
170 MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
171         /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
172         .phys_io        = U8500_UART2_BASE,
173         .io_pg_offst    = (IO_ADDRESS(U8500_UART2_BASE) >> 18) & 0xfffc,
174         .boot_params    = 0x100,
175         .map_io         = u8500_map_io,
176         .init_irq       = ux500_init_irq,
177         /* we re-use nomadik timer here */
178         .timer          = &ux500_timer,
179         .init_machine   = u8500_init_machine,
180 MACHINE_END