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> |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame^] | 22 | #include <linux/mfd/tc35892.h> |
Sundar Iyer | 4c61c84 | 2010-09-29 19:43:09 -0700 | [diff] [blame] | 23 | #include <linux/input/matrix_keypad.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 24 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 25 | #include <asm/mach-types.h> |
| 26 | #include <asm/mach/arch.h> |
| 27 | |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 28 | #include <plat/pincfg.h> |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 29 | #include <plat/i2c.h> |
Sundar Iyer | 4c61c84 | 2010-09-29 19:43:09 -0700 | [diff] [blame] | 30 | #include <plat/ske.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 31 | |
| 32 | #include <mach/hardware.h> |
| 33 | #include <mach/setup.h> |
Rabin Vincent | 9e4e7fe | 2010-05-03 08:03:52 +0100 | [diff] [blame] | 34 | #include <mach/devices.h> |
Linus Walleij | 29aeb3c | 2010-09-06 22:15:08 +0100 | [diff] [blame] | 35 | #include <mach/irqs.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 36 | |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 37 | #include "pins-db8500.h" |
Hanumath Prasad | 008f8a2 | 2010-08-19 12:06:32 +0100 | [diff] [blame] | 38 | #include "board-mop500.h" |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 39 | |
| 40 | static 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 Iyer | 4c61c84 | 2010-09-29 19:43:09 -0700 | [diff] [blame] | 56 | |
| 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 Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame^] | 74 | |
| 75 | GPIO217_GPIO, /* GPIO_EXP_INT */ |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 76 | }; |
| 77 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 78 | static void ab4500_spi_cs_control(u32 command) |
| 79 | { |
| 80 | /* set the FRM signal, which is CS - TODO */ |
| 81 | } |
| 82 | |
| 83 | struct pl022_config_chip ab4500_chip_info = { |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 84 | .com_mode = INTERRUPT_TRANSFER, |
| 85 | .iface = SSP_INTERFACE_MOTOROLA_SPI, |
| 86 | /* we can act as master only */ |
| 87 | .hierarchy = SSP_MASTER, |
| 88 | .slave_tx_disable = 0, |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 89 | .rx_lev_trig = SSP_RX_1_OR_MORE_ELEM, |
| 90 | .tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC, |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 91 | .cs_control = ab4500_spi_cs_control, |
| 92 | }; |
| 93 | |
Rabin Vincent | 39ae702 | 2010-07-26 11:12:15 +0100 | [diff] [blame] | 94 | static struct ab8500_platform_data ab8500_platdata = { |
| 95 | .irq_base = MOP500_AB8500_IRQ_BASE, |
| 96 | }; |
| 97 | |
Linus Walleij | 29aeb3c | 2010-09-06 22:15:08 +0100 | [diff] [blame] | 98 | static struct resource ab8500_resources[] = { |
| 99 | [0] = { |
| 100 | .start = IRQ_AB8500, |
| 101 | .end = IRQ_AB8500, |
| 102 | .flags = IORESOURCE_IRQ |
| 103 | } |
| 104 | }; |
| 105 | |
| 106 | struct platform_device ab8500_device = { |
| 107 | .name = "ab8500-i2c", |
| 108 | .id = 0, |
| 109 | .dev = { |
| 110 | .platform_data = &ab8500_platdata, |
| 111 | }, |
| 112 | .num_resources = 1, |
| 113 | .resource = ab8500_resources, |
| 114 | }; |
| 115 | |
| 116 | static struct spi_board_info ab8500_spi_devices[] = { |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 117 | { |
Linus Walleij | 29aeb3c | 2010-09-06 22:15:08 +0100 | [diff] [blame] | 118 | .modalias = "ab8500-spi", |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 119 | .controller_data = &ab4500_chip_info, |
Rabin Vincent | 39ae702 | 2010-07-26 11:12:15 +0100 | [diff] [blame] | 120 | .platform_data = &ab8500_platdata, |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 121 | .max_speed_hz = 12000000, |
| 122 | .bus_num = 0, |
| 123 | .chip_select = 0, |
Kevin Wells | bde435a | 2010-09-16 06:18:50 -0700 | [diff] [blame] | 124 | .mode = SPI_MODE_3, |
Rabin Vincent | 6055930 | 2010-07-26 11:09:27 +0100 | [diff] [blame] | 125 | .irq = IRQ_DB8500_AB8500, |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 126 | }, |
| 127 | }; |
| 128 | |
| 129 | static struct pl022_ssp_controller ssp0_platform_data = { |
| 130 | .bus_id = 0, |
| 131 | /* pl022 not yet supports dma */ |
| 132 | .enable_dma = 0, |
| 133 | /* on this platform, gpio 31,142,144,214 & |
| 134 | * 224 are connected as chip selects |
| 135 | */ |
| 136 | .num_chipselect = 5, |
| 137 | }; |
| 138 | |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame^] | 139 | /* |
| 140 | * TC35892 |
| 141 | */ |
| 142 | |
| 143 | static void mop500_tc35892_init(struct tc35892 *tc35892, unsigned int base) |
| 144 | { |
| 145 | mop500_sdi_tc35892_init(); |
| 146 | } |
| 147 | |
| 148 | static struct tc35892_gpio_platform_data mop500_tc35892_gpio_data = { |
| 149 | .gpio_base = MOP500_EGPIO(0), |
| 150 | .setup = mop500_tc35892_init, |
| 151 | }; |
| 152 | |
| 153 | static struct tc35892_platform_data mop500_tc35892_data = { |
| 154 | .gpio = &mop500_tc35892_gpio_data, |
| 155 | .irq_base = MOP500_EGPIO_IRQ_BASE, |
| 156 | }; |
| 157 | |
| 158 | static struct i2c_board_info mop500_i2c0_devices[] = { |
| 159 | { |
| 160 | I2C_BOARD_INFO("tc35892", 0x42), |
| 161 | .irq = NOMADIK_GPIO_TO_IRQ(217), |
| 162 | .platform_data = &mop500_tc35892_data, |
| 163 | }, |
| 164 | }; |
| 165 | |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 166 | #define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \ |
Rabin Vincent | f9faf23 | 2010-05-03 08:24:37 +0100 | [diff] [blame] | 167 | static struct nmk_i2c_controller u8500_i2c##id##_data = { \ |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 168 | /* \ |
| 169 | * slave data setup time, which is \ |
| 170 | * 250 ns,100ns,10ns which is 14,6,2 \ |
| 171 | * respectively for a 48 Mhz \ |
| 172 | * i2c clock \ |
| 173 | */ \ |
| 174 | .slsu = _slsu, \ |
| 175 | /* Tx FIFO threshold */ \ |
| 176 | .tft = _tft, \ |
| 177 | /* Rx FIFO threshold */ \ |
| 178 | .rft = _rft, \ |
| 179 | /* std. mode operation */ \ |
| 180 | .clk_freq = clk, \ |
| 181 | .sm = _sm, \ |
| 182 | } |
| 183 | |
| 184 | /* |
| 185 | * The board uses 4 i2c controllers, initialize all of |
| 186 | * them with slave data setup time of 250 ns, |
| 187 | * Tx & Rx FIFO threshold values as 1 and standard |
| 188 | * mode of operation |
| 189 | */ |
| 190 | U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 191 | U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 192 | U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 193 | U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 194 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 195 | static struct amba_device *amba_devs[] __initdata = { |
Rabin Vincent | 4b27aa4 | 2010-05-03 08:18:38 +0100 | [diff] [blame] | 196 | &ux500_uart0_device, |
| 197 | &ux500_uart1_device, |
| 198 | &ux500_uart2_device, |
Rabin Vincent | 9e4e7fe | 2010-05-03 08:03:52 +0100 | [diff] [blame] | 199 | &u8500_ssp0_device, |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 200 | }; |
| 201 | |
Sundar Iyer | 4c61c84 | 2010-09-29 19:43:09 -0700 | [diff] [blame] | 202 | static const unsigned int ux500_keymap[] = { |
| 203 | KEY(2, 5, KEY_END), |
| 204 | KEY(4, 1, KEY_POWER), |
| 205 | KEY(3, 5, KEY_VOLUMEDOWN), |
| 206 | KEY(1, 3, KEY_3), |
| 207 | KEY(5, 2, KEY_RIGHT), |
| 208 | KEY(5, 0, KEY_9), |
| 209 | |
| 210 | KEY(0, 5, KEY_MENU), |
| 211 | KEY(7, 6, KEY_ENTER), |
| 212 | KEY(4, 5, KEY_0), |
| 213 | KEY(6, 7, KEY_2), |
| 214 | KEY(3, 4, KEY_UP), |
| 215 | KEY(3, 3, KEY_DOWN), |
| 216 | |
| 217 | KEY(6, 4, KEY_SEND), |
| 218 | KEY(6, 2, KEY_BACK), |
| 219 | KEY(4, 2, KEY_VOLUMEUP), |
| 220 | KEY(5, 5, KEY_1), |
| 221 | KEY(4, 3, KEY_LEFT), |
| 222 | KEY(3, 2, KEY_7), |
| 223 | }; |
| 224 | |
| 225 | static const struct matrix_keymap_data ux500_keymap_data = { |
| 226 | .keymap = ux500_keymap, |
| 227 | .keymap_size = ARRAY_SIZE(ux500_keymap), |
| 228 | }; |
| 229 | |
| 230 | /* |
| 231 | * Nomadik SKE keypad |
| 232 | */ |
| 233 | #define ROW_PIN_I0 164 |
| 234 | #define ROW_PIN_I1 163 |
| 235 | #define ROW_PIN_I2 162 |
| 236 | #define ROW_PIN_I3 161 |
| 237 | #define ROW_PIN_I4 156 |
| 238 | #define ROW_PIN_I5 155 |
| 239 | #define ROW_PIN_I6 154 |
| 240 | #define ROW_PIN_I7 153 |
| 241 | #define COL_PIN_O0 168 |
| 242 | #define COL_PIN_O1 167 |
| 243 | #define COL_PIN_O2 166 |
| 244 | #define COL_PIN_O3 165 |
| 245 | #define COL_PIN_O4 160 |
| 246 | #define COL_PIN_O5 159 |
| 247 | #define COL_PIN_O6 158 |
| 248 | #define COL_PIN_O7 157 |
| 249 | |
| 250 | #define SKE_KPD_MAX_ROWS 8 |
| 251 | #define SKE_KPD_MAX_COLS 8 |
| 252 | |
| 253 | static int ske_kp_rows[] = { |
| 254 | ROW_PIN_I0, ROW_PIN_I1, ROW_PIN_I2, ROW_PIN_I3, |
| 255 | ROW_PIN_I4, ROW_PIN_I5, ROW_PIN_I6, ROW_PIN_I7, |
| 256 | }; |
| 257 | |
| 258 | /* |
| 259 | * ske_set_gpio_row: request and set gpio rows |
| 260 | */ |
| 261 | static int ske_set_gpio_row(int gpio) |
| 262 | { |
| 263 | int ret; |
| 264 | |
| 265 | ret = gpio_request(gpio, "ske-kp"); |
| 266 | if (ret < 0) { |
| 267 | pr_err("ske_set_gpio_row: gpio request failed\n"); |
| 268 | return ret; |
| 269 | } |
| 270 | |
| 271 | ret = gpio_direction_output(gpio, 1); |
| 272 | if (ret < 0) { |
| 273 | pr_err("ske_set_gpio_row: gpio direction failed\n"); |
| 274 | gpio_free(gpio); |
| 275 | } |
| 276 | |
| 277 | return ret; |
| 278 | } |
| 279 | |
| 280 | /* |
| 281 | * ske_kp_init - enable the gpio configuration |
| 282 | */ |
| 283 | static int ske_kp_init(void) |
| 284 | { |
| 285 | int ret, i; |
| 286 | |
| 287 | for (i = 0; i < SKE_KPD_MAX_ROWS; i++) { |
| 288 | ret = ske_set_gpio_row(ske_kp_rows[i]); |
| 289 | if (ret < 0) { |
| 290 | pr_err("ske_kp_init: failed init\n"); |
| 291 | return ret; |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | return 0; |
| 296 | } |
| 297 | |
| 298 | static struct ske_keypad_platform_data ske_keypad_board = { |
| 299 | .init = ske_kp_init, |
| 300 | .keymap_data = &ux500_keymap_data, |
| 301 | .no_autorepeat = true, |
| 302 | .krow = SKE_KPD_MAX_ROWS, /* 8x8 matrix */ |
| 303 | .kcol = SKE_KPD_MAX_COLS, |
| 304 | .debounce_ms = 40, /* in millsecs */ |
| 305 | }; |
| 306 | |
| 307 | |
| 308 | |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 309 | /* add any platform devices here - TODO */ |
| 310 | static struct platform_device *platform_devs[] __initdata = { |
Rabin Vincent | f9faf23 | 2010-05-03 08:24:37 +0100 | [diff] [blame] | 311 | &u8500_i2c0_device, |
| 312 | &ux500_i2c1_device, |
| 313 | &ux500_i2c2_device, |
| 314 | &ux500_i2c3_device, |
Sundar Iyer | 4c61c84 | 2010-09-29 19:43:09 -0700 | [diff] [blame] | 315 | &ux500_ske_keypad_device, |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 316 | }; |
| 317 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 318 | static void __init u8500_init_machine(void) |
| 319 | { |
| 320 | int i; |
| 321 | |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 322 | u8500_init_devices(); |
| 323 | |
| 324 | nmk_config_pins(mop500_pins, ARRAY_SIZE(mop500_pins)); |
| 325 | |
Rabin Vincent | f9faf23 | 2010-05-03 08:24:37 +0100 | [diff] [blame] | 326 | u8500_i2c0_device.dev.platform_data = &u8500_i2c0_data; |
| 327 | ux500_i2c1_device.dev.platform_data = &u8500_i2c1_data; |
| 328 | ux500_i2c2_device.dev.platform_data = &u8500_i2c2_data; |
| 329 | ux500_i2c3_device.dev.platform_data = &u8500_i2c3_data; |
Sundar Iyer | 4c61c84 | 2010-09-29 19:43:09 -0700 | [diff] [blame] | 330 | ux500_ske_keypad_device.dev.platform_data = &ske_keypad_board; |
Rabin Vincent | f9faf23 | 2010-05-03 08:24:37 +0100 | [diff] [blame] | 331 | |
Rabin Vincent | 9e4e7fe | 2010-05-03 08:03:52 +0100 | [diff] [blame] | 332 | u8500_ssp0_device.dev.platform_data = &ssp0_platform_data; |
| 333 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 334 | /* Register the active AMBA devices on this board */ |
| 335 | for (i = 0; i < ARRAY_SIZE(amba_devs); i++) |
| 336 | amba_device_register(amba_devs[i], &iomem_resource); |
| 337 | |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 338 | platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs)); |
| 339 | |
Hanumath Prasad | 008f8a2 | 2010-08-19 12:06:32 +0100 | [diff] [blame] | 340 | mop500_sdi_init(); |
| 341 | |
Linus Walleij | 29aeb3c | 2010-09-06 22:15:08 +0100 | [diff] [blame] | 342 | /* If HW is early drop (ED) or V1.0 then use SPI to access AB8500 */ |
| 343 | if (cpu_is_u8500ed() || cpu_is_u8500v10()) |
| 344 | spi_register_board_info(ab8500_spi_devices, |
| 345 | ARRAY_SIZE(ab8500_spi_devices)); |
| 346 | else /* If HW is v.1.1 or later use I2C to access AB8500 */ |
| 347 | platform_device_register(&ab8500_device); |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame^] | 348 | |
| 349 | i2c_register_board_info(0, mop500_i2c0_devices, |
| 350 | ARRAY_SIZE(mop500_i2c0_devices)); |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | MACHINE_START(U8500, "ST-Ericsson MOP500 platform") |
| 354 | /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */ |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 355 | .boot_params = 0x100, |
| 356 | .map_io = u8500_map_io, |
Rabin Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 357 | .init_irq = ux500_init_irq, |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 358 | /* we re-use nomadik timer here */ |
Rabin Vincent | 41ac329 | 2010-05-03 08:28:05 +0100 | [diff] [blame] | 359 | .timer = &ux500_timer, |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 360 | .init_machine = u8500_init_machine, |
| 361 | MACHINE_END |