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