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> |
Sundar Iyer | 4c61c84 | 2010-09-29 19:43:09 -0700 | [diff] [blame] | 29 | #include <plat/ske.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 30 | |
| 31 | #include <mach/hardware.h> |
| 32 | #include <mach/setup.h> |
Rabin Vincent | 9e4e7fe | 2010-05-03 08:03:52 +0100 | [diff] [blame] | 33 | #include <mach/devices.h> |
Linus Walleij | 29aeb3c | 2010-09-06 22:15:08 +0100 | [diff] [blame] | 34 | #include <mach/irqs.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 35 | |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 36 | #include "devices-db8500.h" |
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 | |
Rabin Vincent | 39ae702 | 2010-07-26 11:12:15 +0100 | [diff] [blame] | 78 | static struct ab8500_platform_data ab8500_platdata = { |
| 79 | .irq_base = MOP500_AB8500_IRQ_BASE, |
| 80 | }; |
| 81 | |
Linus Walleij | 29aeb3c | 2010-09-06 22:15:08 +0100 | [diff] [blame] | 82 | static struct resource ab8500_resources[] = { |
| 83 | [0] = { |
Rabin Vincent | 22039b7 | 2010-12-08 11:07:56 +0530 | [diff] [blame] | 84 | .start = IRQ_DB8500_AB8500, |
| 85 | .end = IRQ_DB8500_AB8500, |
| 86 | .flags = IORESOURCE_IRQ |
Linus Walleij | 29aeb3c | 2010-09-06 22:15:08 +0100 | [diff] [blame] | 87 | } |
| 88 | }; |
| 89 | |
| 90 | struct platform_device ab8500_device = { |
| 91 | .name = "ab8500-i2c", |
| 92 | .id = 0, |
| 93 | .dev = { |
| 94 | .platform_data = &ab8500_platdata, |
| 95 | }, |
| 96 | .num_resources = 1, |
| 97 | .resource = ab8500_resources, |
| 98 | }; |
| 99 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 100 | static struct pl022_ssp_controller ssp0_platform_data = { |
| 101 | .bus_id = 0, |
| 102 | /* pl022 not yet supports dma */ |
| 103 | .enable_dma = 0, |
| 104 | /* on this platform, gpio 31,142,144,214 & |
| 105 | * 224 are connected as chip selects |
| 106 | */ |
| 107 | .num_chipselect = 5, |
| 108 | }; |
| 109 | |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 110 | /* |
| 111 | * TC35892 |
| 112 | */ |
| 113 | |
Sundar Iyer | 20406eb | 2010-12-13 09:33:14 +0530 | [diff] [blame] | 114 | static void mop500_tc35892_init(struct tc3589x *tc3589x, unsigned int base) |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 115 | { |
| 116 | mop500_sdi_tc35892_init(); |
| 117 | } |
| 118 | |
Sundar Iyer | 20406eb | 2010-12-13 09:33:14 +0530 | [diff] [blame] | 119 | static struct tc3589x_gpio_platform_data mop500_tc35892_gpio_data = { |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 120 | .gpio_base = MOP500_EGPIO(0), |
| 121 | .setup = mop500_tc35892_init, |
| 122 | }; |
| 123 | |
Sundar Iyer | 20406eb | 2010-12-13 09:33:14 +0530 | [diff] [blame] | 124 | static struct tc3589x_platform_data mop500_tc35892_data = { |
Sundar Iyer | 611b759 | 2010-12-13 09:33:15 +0530 | [diff] [blame^] | 125 | .block = TC3589x_BLOCK_GPIO, |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 126 | .gpio = &mop500_tc35892_gpio_data, |
| 127 | .irq_base = MOP500_EGPIO_IRQ_BASE, |
| 128 | }; |
| 129 | |
| 130 | static struct i2c_board_info mop500_i2c0_devices[] = { |
| 131 | { |
Sundar Iyer | 20406eb | 2010-12-13 09:33:14 +0530 | [diff] [blame] | 132 | I2C_BOARD_INFO("tc3589x", 0x42), |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 133 | .irq = NOMADIK_GPIO_TO_IRQ(217), |
| 134 | .platform_data = &mop500_tc35892_data, |
| 135 | }, |
| 136 | }; |
| 137 | |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 138 | #define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \ |
Rabin Vincent | f9faf23 | 2010-05-03 08:24:37 +0100 | [diff] [blame] | 139 | static struct nmk_i2c_controller u8500_i2c##id##_data = { \ |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 140 | /* \ |
| 141 | * slave data setup time, which is \ |
| 142 | * 250 ns,100ns,10ns which is 14,6,2 \ |
| 143 | * respectively for a 48 Mhz \ |
| 144 | * i2c clock \ |
| 145 | */ \ |
| 146 | .slsu = _slsu, \ |
| 147 | /* Tx FIFO threshold */ \ |
| 148 | .tft = _tft, \ |
| 149 | /* Rx FIFO threshold */ \ |
| 150 | .rft = _rft, \ |
| 151 | /* std. mode operation */ \ |
| 152 | .clk_freq = clk, \ |
| 153 | .sm = _sm, \ |
| 154 | } |
| 155 | |
| 156 | /* |
| 157 | * The board uses 4 i2c controllers, initialize all of |
| 158 | * them with slave data setup time of 250 ns, |
| 159 | * Tx & Rx FIFO threshold values as 1 and standard |
| 160 | * mode of operation |
| 161 | */ |
| 162 | U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 163 | U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 164 | U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 165 | U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 166 | |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 167 | static void __init mop500_i2c_init(void) |
| 168 | { |
| 169 | db8500_add_i2c0(&u8500_i2c0_data); |
| 170 | db8500_add_i2c1(&u8500_i2c1_data); |
| 171 | db8500_add_i2c2(&u8500_i2c2_data); |
| 172 | db8500_add_i2c3(&u8500_i2c3_data); |
| 173 | } |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 174 | |
Sundar Iyer | 4c61c84 | 2010-09-29 19:43:09 -0700 | [diff] [blame] | 175 | static const unsigned int ux500_keymap[] = { |
| 176 | KEY(2, 5, KEY_END), |
| 177 | KEY(4, 1, KEY_POWER), |
| 178 | KEY(3, 5, KEY_VOLUMEDOWN), |
| 179 | KEY(1, 3, KEY_3), |
| 180 | KEY(5, 2, KEY_RIGHT), |
| 181 | KEY(5, 0, KEY_9), |
| 182 | |
| 183 | KEY(0, 5, KEY_MENU), |
| 184 | KEY(7, 6, KEY_ENTER), |
| 185 | KEY(4, 5, KEY_0), |
| 186 | KEY(6, 7, KEY_2), |
| 187 | KEY(3, 4, KEY_UP), |
| 188 | KEY(3, 3, KEY_DOWN), |
| 189 | |
| 190 | KEY(6, 4, KEY_SEND), |
| 191 | KEY(6, 2, KEY_BACK), |
| 192 | KEY(4, 2, KEY_VOLUMEUP), |
| 193 | KEY(5, 5, KEY_1), |
| 194 | KEY(4, 3, KEY_LEFT), |
| 195 | KEY(3, 2, KEY_7), |
| 196 | }; |
| 197 | |
| 198 | static const struct matrix_keymap_data ux500_keymap_data = { |
| 199 | .keymap = ux500_keymap, |
| 200 | .keymap_size = ARRAY_SIZE(ux500_keymap), |
| 201 | }; |
| 202 | |
| 203 | /* |
| 204 | * Nomadik SKE keypad |
| 205 | */ |
| 206 | #define ROW_PIN_I0 164 |
| 207 | #define ROW_PIN_I1 163 |
| 208 | #define ROW_PIN_I2 162 |
| 209 | #define ROW_PIN_I3 161 |
| 210 | #define ROW_PIN_I4 156 |
| 211 | #define ROW_PIN_I5 155 |
| 212 | #define ROW_PIN_I6 154 |
| 213 | #define ROW_PIN_I7 153 |
| 214 | #define COL_PIN_O0 168 |
| 215 | #define COL_PIN_O1 167 |
| 216 | #define COL_PIN_O2 166 |
| 217 | #define COL_PIN_O3 165 |
| 218 | #define COL_PIN_O4 160 |
| 219 | #define COL_PIN_O5 159 |
| 220 | #define COL_PIN_O6 158 |
| 221 | #define COL_PIN_O7 157 |
| 222 | |
| 223 | #define SKE_KPD_MAX_ROWS 8 |
| 224 | #define SKE_KPD_MAX_COLS 8 |
| 225 | |
| 226 | static int ske_kp_rows[] = { |
| 227 | ROW_PIN_I0, ROW_PIN_I1, ROW_PIN_I2, ROW_PIN_I3, |
| 228 | ROW_PIN_I4, ROW_PIN_I5, ROW_PIN_I6, ROW_PIN_I7, |
| 229 | }; |
| 230 | |
| 231 | /* |
| 232 | * ske_set_gpio_row: request and set gpio rows |
| 233 | */ |
| 234 | static int ske_set_gpio_row(int gpio) |
| 235 | { |
| 236 | int ret; |
| 237 | |
| 238 | ret = gpio_request(gpio, "ske-kp"); |
| 239 | if (ret < 0) { |
| 240 | pr_err("ske_set_gpio_row: gpio request failed\n"); |
| 241 | return ret; |
| 242 | } |
| 243 | |
| 244 | ret = gpio_direction_output(gpio, 1); |
| 245 | if (ret < 0) { |
| 246 | pr_err("ske_set_gpio_row: gpio direction failed\n"); |
| 247 | gpio_free(gpio); |
| 248 | } |
| 249 | |
| 250 | return ret; |
| 251 | } |
| 252 | |
| 253 | /* |
| 254 | * ske_kp_init - enable the gpio configuration |
| 255 | */ |
| 256 | static int ske_kp_init(void) |
| 257 | { |
| 258 | int ret, i; |
| 259 | |
| 260 | for (i = 0; i < SKE_KPD_MAX_ROWS; i++) { |
| 261 | ret = ske_set_gpio_row(ske_kp_rows[i]); |
| 262 | if (ret < 0) { |
| 263 | pr_err("ske_kp_init: failed init\n"); |
| 264 | return ret; |
| 265 | } |
| 266 | } |
| 267 | |
| 268 | return 0; |
| 269 | } |
| 270 | |
| 271 | static struct ske_keypad_platform_data ske_keypad_board = { |
| 272 | .init = ske_kp_init, |
| 273 | .keymap_data = &ux500_keymap_data, |
| 274 | .no_autorepeat = true, |
| 275 | .krow = SKE_KPD_MAX_ROWS, /* 8x8 matrix */ |
| 276 | .kcol = SKE_KPD_MAX_COLS, |
| 277 | .debounce_ms = 40, /* in millsecs */ |
| 278 | }; |
| 279 | |
| 280 | |
| 281 | |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 282 | /* add any platform devices here - TODO */ |
| 283 | static struct platform_device *platform_devs[] __initdata = { |
Sundar Iyer | 4c61c84 | 2010-09-29 19:43:09 -0700 | [diff] [blame] | 284 | &ux500_ske_keypad_device, |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 285 | }; |
| 286 | |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 287 | static void __init mop500_spi_init(void) |
| 288 | { |
| 289 | db8500_add_ssp0(&ssp0_platform_data); |
| 290 | } |
| 291 | |
| 292 | static void __init mop500_uart_init(void) |
| 293 | { |
| 294 | db8500_add_uart0(); |
| 295 | db8500_add_uart1(); |
| 296 | db8500_add_uart2(); |
| 297 | } |
| 298 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 299 | static void __init u8500_init_machine(void) |
| 300 | { |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 301 | u8500_init_devices(); |
| 302 | |
| 303 | nmk_config_pins(mop500_pins, ARRAY_SIZE(mop500_pins)); |
| 304 | |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 305 | platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs)); |
| 306 | |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 307 | mop500_i2c_init(); |
Hanumath Prasad | 008f8a2 | 2010-08-19 12:06:32 +0100 | [diff] [blame] | 308 | mop500_sdi_init(); |
Rabin Vincent | fbf1ead | 2010-09-29 19:46:32 +0530 | [diff] [blame] | 309 | mop500_spi_init(); |
| 310 | mop500_uart_init(); |
Hanumath Prasad | 008f8a2 | 2010-08-19 12:06:32 +0100 | [diff] [blame] | 311 | |
Sundar Iyer | d5d2281 | 2010-12-13 09:33:11 +0530 | [diff] [blame] | 312 | platform_device_register(&ab8500_device); |
Rabin Vincent | b8410a1 | 2010-08-09 19:18:17 +0530 | [diff] [blame] | 313 | |
| 314 | i2c_register_board_info(0, mop500_i2c0_devices, |
| 315 | ARRAY_SIZE(mop500_i2c0_devices)); |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 316 | } |
| 317 | |
| 318 | MACHINE_START(U8500, "ST-Ericsson MOP500 platform") |
| 319 | /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */ |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 320 | .boot_params = 0x100, |
| 321 | .map_io = u8500_map_io, |
Rabin Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 322 | .init_irq = ux500_init_irq, |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 323 | /* we re-use nomadik timer here */ |
Rabin Vincent | 41ac329 | 2010-05-03 08:28:05 +0100 | [diff] [blame] | 324 | .timer = &ux500_timer, |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 325 | .init_machine = u8500_init_machine, |
| 326 | MACHINE_END |