blob: fd6d5090caea07802e42ea8eb57a74bc7940f0e9 [file] [log] [blame]
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +01001/*
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>
Rabin Vincentb8410a12010-08-09 19:18:17 +053016#include <linux/i2c.h>
Rabin Vincentea05a572010-06-03 07:58:42 +010017#include <linux/gpio.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010018#include <linux/amba/bus.h>
19#include <linux/amba/pl022.h>
20#include <linux/spi/spi.h>
Rabin Vincent39ae7022010-07-26 11:12:15 +010021#include <linux/mfd/ab8500.h>
Sundar Iyer20406eb2010-12-13 09:33:14 +053022#include <linux/mfd/tc3589x.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010023
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010024#include <asm/mach-types.h>
25#include <asm/mach/arch.h>
26
Rabin Vincentea05a572010-06-03 07:58:42 +010027#include <plat/pincfg.h>
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +010028#include <plat/i2c.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010029
30#include <mach/hardware.h>
31#include <mach/setup.h>
Rabin Vincent9e4e7fe2010-05-03 08:03:52 +010032#include <mach/devices.h>
Linus Walleij29aeb3c2010-09-06 22:15:08 +010033#include <mach/irqs.h>
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +010034
Rabin Vincentfbf1ead2010-09-29 19:46:32 +053035#include "devices-db8500.h"
Rabin Vincentea05a572010-06-03 07:58:42 +010036#include "pins-db8500.h"
Hanumath Prasad008f8a22010-08-19 12:06:32 +010037#include "board-mop500.h"
Bengt Jonssona1e516e2010-12-10 11:08:48 +010038#include "board-mop500-regulators.h"
Rabin Vincentea05a572010-06-03 07:58:42 +010039
40static pin_cfg_t mop500_pins[] = {
41 /* SSP0 */
42 GPIO143_SSP0_CLK,
43 GPIO144_SSP0_FRM,
44 GPIO145_SSP0_RXD,
45 GPIO146_SSP0_TXD,
46
47 /* I2C */
48 GPIO147_I2C0_SCL,
49 GPIO148_I2C0_SDA,
50 GPIO16_I2C1_SCL,
51 GPIO17_I2C1_SDA,
52 GPIO10_I2C2_SDA,
53 GPIO11_I2C2_SCL,
54 GPIO229_I2C3_SDA,
55 GPIO230_I2C3_SCL,
Sundar Iyer4c61c842010-09-29 19:43:09 -070056
57 /* SKE keypad */
58 GPIO153_KP_I7,
59 GPIO154_KP_I6,
60 GPIO155_KP_I5,
61 GPIO156_KP_I4,
62 GPIO157_KP_O7,
63 GPIO158_KP_O6,
64 GPIO159_KP_O5,
65 GPIO160_KP_O4,
66 GPIO161_KP_I3,
67 GPIO162_KP_I2,
68 GPIO163_KP_I1,
69 GPIO164_KP_I0,
70 GPIO165_KP_O3,
71 GPIO166_KP_O2,
72 GPIO167_KP_O1,
73 GPIO168_KP_O0,
Rabin Vincentb8410a12010-08-09 19:18:17 +053074
Sundar Iyer556fb032010-12-03 20:35:38 +053075 /* GPIO_EXP_INT */
76 GPIO217_GPIO,
77
78 /* STMPE1601 IRQ */
79 GPIO218_GPIO | PIN_INPUT_PULLUP,
Sundar Iyer71f933f2011-01-21 10:56:18 +053080
81 /* touch screen */
82 GPIO84_GPIO | PIN_INPUT_PULLUP,
Rabin Vincentea05a572010-06-03 07:58:42 +010083};
84
Rabin Vincent39ae7022010-07-26 11:12:15 +010085static struct ab8500_platform_data ab8500_platdata = {
86 .irq_base = MOP500_AB8500_IRQ_BASE,
Bengt Jonssona1e516e2010-12-10 11:08:48 +010087 .regulator = ab8500_regulators,
88 .num_regulator = ARRAY_SIZE(ab8500_regulators),
Rabin Vincent39ae7022010-07-26 11:12:15 +010089};
90
Linus Walleij29aeb3c2010-09-06 22:15:08 +010091static struct resource ab8500_resources[] = {
92 [0] = {
Rabin Vincent22039b72010-12-08 11:07:56 +053093 .start = IRQ_DB8500_AB8500,
94 .end = IRQ_DB8500_AB8500,
95 .flags = IORESOURCE_IRQ
Linus Walleij29aeb3c2010-09-06 22:15:08 +010096 }
97};
98
99struct platform_device ab8500_device = {
100 .name = "ab8500-i2c",
101 .id = 0,
102 .dev = {
103 .platform_data = &ab8500_platdata,
104 },
105 .num_resources = 1,
106 .resource = ab8500_resources,
107};
108
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100109static struct pl022_ssp_controller ssp0_platform_data = {
110 .bus_id = 0,
111 /* pl022 not yet supports dma */
112 .enable_dma = 0,
113 /* on this platform, gpio 31,142,144,214 &
114 * 224 are connected as chip selects
115 */
116 .num_chipselect = 5,
117};
118
Rabin Vincentb8410a12010-08-09 19:18:17 +0530119/*
120 * TC35892
121 */
122
Sundar Iyer20406eb2010-12-13 09:33:14 +0530123static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base)
Rabin Vincentb8410a12010-08-09 19:18:17 +0530124{
125 mop500_sdi_tc35892_init();
126}
127
Sundar Iyer20406eb2010-12-13 09:33:14 +0530128static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = {
Rabin Vincentb8410a12010-08-09 19:18:17 +0530129 .gpio_base = MOP500_EGPIO(0),
130 .setup = mop500_tc35892_init,
131};
132
Sundar Iyer20406eb2010-12-13 09:33:14 +0530133static struct tc3589x_platform_data mop500_tc35892_data = {
Sundar Iyer611b7592010-12-13 09:33:15 +0530134 .block = TC3589x_BLOCK_GPIO,
Rabin Vincentb8410a12010-08-09 19:18:17 +0530135 .gpio = &mop500_tc35892_gpio_data,
136 .irq_base = MOP500_EGPIO_IRQ_BASE,
137};
138
139static struct i2c_board_info mop500_i2c0_devices[] = {
140 {
Sundar Iyer20406eb2010-12-13 09:33:14 +0530141 I2C_BOARD_INFO("tc3589x", 0x42),
Rabin Vincentb8410a12010-08-09 19:18:17 +0530142 .irq = NOMADIK_GPIO_TO_IRQ(217),
143 .platform_data = &mop500_tc35892_data,
144 },
145};
146
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100147#define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \
Rabin Vincentf9faf232010-05-03 08:24:37 +0100148static struct nmk_i2c_controller u8500_i2c##id##_data = { \
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100149 /* \
150 * slave data setup time, which is \
151 * 250 ns,100ns,10ns which is 14,6,2 \
152 * respectively for a 48 Mhz \
153 * i2c clock \
154 */ \
155 .slsu = _slsu, \
156 /* Tx FIFO threshold */ \
157 .tft = _tft, \
158 /* Rx FIFO threshold */ \
159 .rft = _rft, \
160 /* std. mode operation */ \
161 .clk_freq = clk, \
162 .sm = _sm, \
163}
164
165/*
166 * The board uses 4 i2c controllers, initialize all of
167 * them with slave data setup time of 250 ns,
168 * Tx & Rx FIFO threshold values as 1 and standard
169 * mode of operation
170 */
171U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
172U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
173U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
174U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD);
175
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530176static void __init mop500_i2c_init(void)
177{
178 db8500_add_i2c0(&u8500_i2c0_data);
179 db8500_add_i2c1(&u8500_i2c1_data);
180 db8500_add_i2c2(&u8500_i2c2_data);
181 db8500_add_i2c3(&u8500_i2c3_data);
182}
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100183
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100184/* add any platform devices here - TODO */
185static struct platform_device *platform_devs[] __initdata = {
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100186};
187
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530188static void __init mop500_spi_init(void)
189{
190 db8500_add_ssp0(&ssp0_platform_data);
191}
192
193static void __init mop500_uart_init(void)
194{
195 db8500_add_uart0();
196 db8500_add_uart1();
197 db8500_add_uart2();
198}
199
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100200static void __init u8500_init_machine(void)
201{
Rabin Vincentea05a572010-06-03 07:58:42 +0100202 u8500_init_devices();
203
204 nmk_config_pins(mop500_pins, ARRAY_SIZE(mop500_pins));
205
Srinidhi Kasagard48a41c2010-02-03 13:02:48 +0100206 platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs));
207
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530208 mop500_i2c_init();
Hanumath Prasad008f8a22010-08-19 12:06:32 +0100209 mop500_sdi_init();
Rabin Vincentfbf1ead2010-09-29 19:46:32 +0530210 mop500_spi_init();
211 mop500_uart_init();
Hanumath Prasad008f8a22010-08-19 12:06:32 +0100212
Sundar Iyerd5d22812010-12-13 09:33:11 +0530213 platform_device_register(&ab8500_device);
Rabin Vincentb8410a12010-08-09 19:18:17 +0530214
215 i2c_register_board_info(0, mop500_i2c0_devices,
216 ARRAY_SIZE(mop500_i2c0_devices));
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100217}
218
219MACHINE_START(U8500, "ST-Ericsson MOP500 platform")
220 /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100221 .boot_params = 0x100,
222 .map_io = u8500_map_io,
Rabin Vincent178980f2010-05-03 07:39:02 +0100223 .init_irq = ux500_init_irq,
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100224 /* we re-use nomadik timer here */
Rabin Vincent41ac3292010-05-03 08:28:05 +0100225 .timer = &ux500_timer,
Srinidhi Kasagaraa44ef42009-11-28 08:17:18 +0100226 .init_machine = u8500_init_machine,
227MACHINE_END