Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 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> |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 16 | #include <linux/i2c.h> |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 17 | #include <linux/gpio.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 18 | #include <linux/amba/bus.h> |
| 19 | #include <linux/amba/pl022.h> |
| 20 | #include <linux/spi/spi.h> |
Rabin Vincent | 39ae702 | 2010-07-26 11:12:15 +0100 | [diff] [blame] | 21 | #include <linux/mfd/ab8500.h> |
Sundar Iyer | 20406eb | 2010-12-13 09:33:14 +0530 | [diff] [blame] | 22 | #include <linux/mfd/tc3589x.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 23 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 24 | #include <asm/mach-types.h> |
| 25 | #include <asm/mach/arch.h> |
| 26 | |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 27 | #include <plat/pincfg.h> |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 28 | #include <plat/i2c.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 29 | |
| 30 | #include <mach/hardware.h> |
| 31 | #include <mach/setup.h> |
Rabin Vincent | 9e4e7fe | 2010-05-03 08:03:52 +0100 | [diff] [blame] | 32 | #include <mach/devices.h> |
Linus Walleij | 29aeb3c | 2010-09-06 22:15:08 +0100 | [diff] [blame] | 33 | #include <mach/irqs.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 34 | |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 35 | #include "devices-db8500.h" |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 36 | #include "pins-db8500.h" |
Hanumath Prasad | 008f8a2 | 2010-08-19 12:06:32 +0100 | [diff] [blame] | 37 | #include "board-mop500.h" |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 38 | |
| 39 | static pin_cfg_t mop500_pins[] = { |
| 40 | /* SSP0 */ |
| 41 | GPIO143_SSP0_CLK, |
| 42 | GPIO144_SSP0_FRM, |
| 43 | GPIO145_SSP0_RXD, |
| 44 | GPIO146_SSP0_TXD, |
| 45 | |
| 46 | /* I2C */ |
| 47 | GPIO147_I2C0_SCL, |
| 48 | GPIO148_I2C0_SDA, |
| 49 | GPIO16_I2C1_SCL, |
| 50 | GPIO17_I2C1_SDA, |
| 51 | GPIO10_I2C2_SDA, |
| 52 | GPIO11_I2C2_SCL, |
| 53 | GPIO229_I2C3_SDA, |
| 54 | GPIO230_I2C3_SCL, |
Sundar Iyer | 4c61c84 | 2010-09-29 19:43:09 -0700 | [diff] [blame] | 55 | |
| 56 | /* SKE keypad */ |
| 57 | GPIO153_KP_I7, |
| 58 | GPIO154_KP_I6, |
| 59 | GPIO155_KP_I5, |
| 60 | GPIO156_KP_I4, |
| 61 | GPIO157_KP_O7, |
| 62 | GPIO158_KP_O6, |
| 63 | GPIO159_KP_O5, |
| 64 | GPIO160_KP_O4, |
| 65 | GPIO161_KP_I3, |
| 66 | GPIO162_KP_I2, |
| 67 | GPIO163_KP_I1, |
| 68 | GPIO164_KP_I0, |
| 69 | GPIO165_KP_O3, |
| 70 | GPIO166_KP_O2, |
| 71 | GPIO167_KP_O1, |
| 72 | GPIO168_KP_O0, |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 73 | |
Sundar Iyer | 556fb03 | 2010-12-03 20:35:38 +0530 | [diff] [blame^] | 74 | /* GPIO_EXP_INT */ |
| 75 | GPIO217_GPIO, |
| 76 | |
| 77 | /* STMPE1601 IRQ */ |
| 78 | GPIO218_GPIO | PIN_INPUT_PULLUP, |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 79 | }; |
| 80 | |
Rabin Vincent | 39ae702 | 2010-07-26 11:12:15 +0100 | [diff] [blame] | 81 | static struct ab8500_platform_data ab8500_platdata = { |
| 82 | .irq_base = MOP500_AB8500_IRQ_BASE, |
| 83 | }; |
| 84 | |
Linus Walleij | 29aeb3c | 2010-09-06 22:15:08 +0100 | [diff] [blame] | 85 | static struct resource ab8500_resources[] = { |
| 86 | [0] = { |
Rabin Vincent | 22039b7 | 2010-12-08 11:07:56 +0530 | [diff] [blame] | 87 | .start = IRQ_DB8500_AB8500, |
| 88 | .end = IRQ_DB8500_AB8500, |
| 89 | .flags = IORESOURCE_IRQ |
Linus Walleij | 29aeb3c | 2010-09-06 22:15:08 +0100 | [diff] [blame] | 90 | } |
| 91 | }; |
| 92 | |
| 93 | struct platform_device ab8500_device = { |
| 94 | .name = "ab8500-i2c", |
| 95 | .id = 0, |
| 96 | .dev = { |
| 97 | .platform_data = &ab8500_platdata, |
| 98 | }, |
| 99 | .num_resources = 1, |
| 100 | .resource = ab8500_resources, |
| 101 | }; |
| 102 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 103 | static struct pl022_ssp_controller ssp0_platform_data = { |
| 104 | .bus_id = 0, |
| 105 | /* pl022 not yet supports dma */ |
| 106 | .enable_dma = 0, |
| 107 | /* on this platform, gpio 31,142,144,214 & |
| 108 | * 224 are connected as chip selects |
| 109 | */ |
| 110 | .num_chipselect = 5, |
| 111 | }; |
| 112 | |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 113 | /* |
| 114 | * TC35892 |
| 115 | */ |
| 116 | |
Sundar Iyer | 20406eb | 2010-12-13 09:33:14 +0530 | [diff] [blame] | 117 | static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base) |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 118 | { |
| 119 | mop500_sdi_tc35892_init(); |
| 120 | } |
| 121 | |
Sundar Iyer | 20406eb | 2010-12-13 09:33:14 +0530 | [diff] [blame] | 122 | static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = { |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 123 | .gpio_base = MOP500_EGPIO(0), |
| 124 | .setup = mop500_tc35892_init, |
| 125 | }; |
| 126 | |
Sundar Iyer | 20406eb | 2010-12-13 09:33:14 +0530 | [diff] [blame] | 127 | static struct tc3589x_platform_data mop500_tc35892_data = { |
Sundar Iyer | 611b759 | 2010-12-13 09:33:15 +0530 | [diff] [blame] | 128 | .block = TC3589x_BLOCK_GPIO, |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 129 | .gpio = &mop500_tc35892_gpio_data, |
| 130 | .irq_base = MOP500_EGPIO_IRQ_BASE, |
| 131 | }; |
| 132 | |
| 133 | static struct i2c_board_info mop500_i2c0_devices[] = { |
| 134 | { |
Sundar Iyer | 20406eb | 2010-12-13 09:33:14 +0530 | [diff] [blame] | 135 | I2C_BOARD_INFO("tc3589x", 0x42), |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 136 | .irq = NOMADIK_GPIO_TO_IRQ(217), |
| 137 | .platform_data = &mop500_tc35892_data, |
| 138 | }, |
| 139 | }; |
| 140 | |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 141 | #define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \ |
Rabin Vincent | f9faf23 | 2010-05-03 08:24:37 +0100 | [diff] [blame] | 142 | static struct nmk_i2c_controller u8500_i2c##id##_data = { \ |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 143 | /* \ |
| 144 | * slave data setup time, which is \ |
| 145 | * 250 ns,100ns,10ns which is 14,6,2 \ |
| 146 | * respectively for a 48 Mhz \ |
| 147 | * i2c clock \ |
| 148 | */ \ |
| 149 | .slsu = _slsu, \ |
| 150 | /* Tx FIFO threshold */ \ |
| 151 | .tft = _tft, \ |
| 152 | /* Rx FIFO threshold */ \ |
| 153 | .rft = _rft, \ |
| 154 | /* std. mode operation */ \ |
| 155 | .clk_freq = clk, \ |
| 156 | .sm = _sm, \ |
| 157 | } |
| 158 | |
| 159 | /* |
| 160 | * The board uses 4 i2c controllers, initialize all of |
| 161 | * them with slave data setup time of 250 ns, |
| 162 | * Tx & Rx FIFO threshold values as 1 and standard |
| 163 | * mode of operation |
| 164 | */ |
| 165 | U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 166 | U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 167 | U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 168 | U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 169 | |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 170 | static void __init mop500_i2c_init(void) |
| 171 | { |
| 172 | db8500_add_i2c0(&u8500_i2c0_data); |
| 173 | db8500_add_i2c1(&u8500_i2c1_data); |
| 174 | db8500_add_i2c2(&u8500_i2c2_data); |
| 175 | db8500_add_i2c3(&u8500_i2c3_data); |
| 176 | } |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 177 | |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 178 | /* add any platform devices here - TODO */ |
| 179 | static struct platform_device *platform_devs[] __initdata = { |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 180 | }; |
| 181 | |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 182 | static void __init mop500_spi_init(void) |
| 183 | { |
| 184 | db8500_add_ssp0(&ssp0_platform_data); |
| 185 | } |
| 186 | |
| 187 | static void __init mop500_uart_init(void) |
| 188 | { |
| 189 | db8500_add_uart0(); |
| 190 | db8500_add_uart1(); |
| 191 | db8500_add_uart2(); |
| 192 | } |
| 193 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 194 | static void __init u8500_init_machine(void) |
| 195 | { |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 196 | u8500_init_devices(); |
| 197 | |
| 198 | nmk_config_pins(mop500_pins, ARRAY_SIZE(mop500_pins)); |
| 199 | |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 200 | platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs)); |
| 201 | |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 202 | mop500_i2c_init(); |
Hanumath Prasad | 008f8a2 | 2010-08-19 12:06:32 +0100 | [diff] [blame] | 203 | mop500_sdi_init(); |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 204 | mop500_spi_init(); |
| 205 | mop500_uart_init(); |
Hanumath Prasad | 008f8a2 | 2010-08-19 12:06:32 +0100 | [diff] [blame] | 206 | |
Sundar Iyer | e43abe6 | 2010-12-03 20:35:36 +0530 | [diff] [blame] | 207 | mop500_keypad_init(); |
| 208 | |
Sundar Iyer | d5d2281 | 2010-12-13 09:33:11 +0530 | [diff] [blame] | 209 | platform_device_register(&ab8500_device); |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 210 | |
| 211 | i2c_register_board_info(0, mop500_i2c0_devices, |
| 212 | ARRAY_SIZE(mop500_i2c0_devices)); |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 213 | } |
| 214 | |
| 215 | MACHINE_START(U8500, "ST-Ericsson MOP500 platform") |
| 216 | /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */ |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 217 | .boot_params = 0x100, |
| 218 | .map_io = u8500_map_io, |
Rabin Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 219 | .init_irq = ux500_init_irq, |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 220 | /* we re-use nomadik timer here */ |
Rabin Vincent | 41ac329 | 2010-05-03 08:28:05 +0100 | [diff] [blame] | 221 | .timer = &ux500_timer, |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 222 | .init_machine = u8500_init_machine, |
| 223 | MACHINE_END |