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 | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 16 | #include <linux/gpio.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 17 | #include <linux/amba/bus.h> |
| 18 | #include <linux/amba/pl022.h> |
| 19 | #include <linux/spi/spi.h> |
Rabin Vincent | 39ae702 | 2010-07-26 11:12:15 +0100 | [diff] [blame] | 20 | #include <linux/mfd/ab8500.h> |
Sundar Iyer | 4c61c84 | 2010-09-29 19:43:09 -0700 | [diff] [blame^] | 21 | #include <linux/input/matrix_keypad.h> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 22 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 23 | #include <asm/mach-types.h> |
| 24 | #include <asm/mach/arch.h> |
| 25 | |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 26 | #include <plat/pincfg.h> |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 27 | #include <plat/i2c.h> |
Sundar Iyer | 4c61c84 | 2010-09-29 19:43:09 -0700 | [diff] [blame^] | 28 | #include <plat/ske.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> |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 33 | |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 34 | #include "pins-db8500.h" |
| 35 | |
| 36 | static pin_cfg_t mop500_pins[] = { |
| 37 | /* SSP0 */ |
| 38 | GPIO143_SSP0_CLK, |
| 39 | GPIO144_SSP0_FRM, |
| 40 | GPIO145_SSP0_RXD, |
| 41 | GPIO146_SSP0_TXD, |
| 42 | |
| 43 | /* I2C */ |
| 44 | GPIO147_I2C0_SCL, |
| 45 | GPIO148_I2C0_SDA, |
| 46 | GPIO16_I2C1_SCL, |
| 47 | GPIO17_I2C1_SDA, |
| 48 | GPIO10_I2C2_SDA, |
| 49 | GPIO11_I2C2_SCL, |
| 50 | GPIO229_I2C3_SDA, |
| 51 | GPIO230_I2C3_SCL, |
Sundar Iyer | 4c61c84 | 2010-09-29 19:43:09 -0700 | [diff] [blame^] | 52 | |
| 53 | /* SKE keypad */ |
| 54 | GPIO153_KP_I7, |
| 55 | GPIO154_KP_I6, |
| 56 | GPIO155_KP_I5, |
| 57 | GPIO156_KP_I4, |
| 58 | GPIO157_KP_O7, |
| 59 | GPIO158_KP_O6, |
| 60 | GPIO159_KP_O5, |
| 61 | GPIO160_KP_O4, |
| 62 | GPIO161_KP_I3, |
| 63 | GPIO162_KP_I2, |
| 64 | GPIO163_KP_I1, |
| 65 | GPIO164_KP_I0, |
| 66 | GPIO165_KP_O3, |
| 67 | GPIO166_KP_O2, |
| 68 | GPIO167_KP_O1, |
| 69 | GPIO168_KP_O0, |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 70 | }; |
| 71 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 72 | static void ab4500_spi_cs_control(u32 command) |
| 73 | { |
| 74 | /* set the FRM signal, which is CS - TODO */ |
| 75 | } |
| 76 | |
| 77 | struct pl022_config_chip ab4500_chip_info = { |
| 78 | .lbm = LOOPBACK_DISABLED, |
| 79 | .com_mode = INTERRUPT_TRANSFER, |
| 80 | .iface = SSP_INTERFACE_MOTOROLA_SPI, |
| 81 | /* we can act as master only */ |
| 82 | .hierarchy = SSP_MASTER, |
| 83 | .slave_tx_disable = 0, |
| 84 | .endian_rx = SSP_RX_MSB, |
| 85 | .endian_tx = SSP_TX_MSB, |
| 86 | .data_size = SSP_DATA_BITS_24, |
| 87 | .rx_lev_trig = SSP_RX_1_OR_MORE_ELEM, |
| 88 | .tx_lev_trig = SSP_TX_1_OR_MORE_EMPTY_LOC, |
| 89 | .clk_phase = SSP_CLK_SECOND_EDGE, |
| 90 | .clk_pol = SSP_CLK_POL_IDLE_HIGH, |
| 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 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 98 | static struct spi_board_info u8500_spi_devices[] = { |
| 99 | { |
Rabin Vincent | 6257926 | 2010-05-19 11:39:02 +0200 | [diff] [blame] | 100 | .modalias = "ab8500", |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 101 | .controller_data = &ab4500_chip_info, |
Rabin Vincent | 39ae702 | 2010-07-26 11:12:15 +0100 | [diff] [blame] | 102 | .platform_data = &ab8500_platdata, |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 103 | .max_speed_hz = 12000000, |
| 104 | .bus_num = 0, |
| 105 | .chip_select = 0, |
| 106 | .mode = SPI_MODE_0, |
Rabin Vincent | 6055930 | 2010-07-26 11:09:27 +0100 | [diff] [blame] | 107 | .irq = IRQ_DB8500_AB8500, |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 108 | }, |
| 109 | }; |
| 110 | |
| 111 | static struct pl022_ssp_controller ssp0_platform_data = { |
| 112 | .bus_id = 0, |
| 113 | /* pl022 not yet supports dma */ |
| 114 | .enable_dma = 0, |
| 115 | /* on this platform, gpio 31,142,144,214 & |
| 116 | * 224 are connected as chip selects |
| 117 | */ |
| 118 | .num_chipselect = 5, |
| 119 | }; |
| 120 | |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 121 | #define U8500_I2C_CONTROLLER(id, _slsu, _tft, _rft, clk, _sm) \ |
Rabin Vincent | f9faf23 | 2010-05-03 08:24:37 +0100 | [diff] [blame] | 122 | static struct nmk_i2c_controller u8500_i2c##id##_data = { \ |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 123 | /* \ |
| 124 | * slave data setup time, which is \ |
| 125 | * 250 ns,100ns,10ns which is 14,6,2 \ |
| 126 | * respectively for a 48 Mhz \ |
| 127 | * i2c clock \ |
| 128 | */ \ |
| 129 | .slsu = _slsu, \ |
| 130 | /* Tx FIFO threshold */ \ |
| 131 | .tft = _tft, \ |
| 132 | /* Rx FIFO threshold */ \ |
| 133 | .rft = _rft, \ |
| 134 | /* std. mode operation */ \ |
| 135 | .clk_freq = clk, \ |
| 136 | .sm = _sm, \ |
| 137 | } |
| 138 | |
| 139 | /* |
| 140 | * The board uses 4 i2c controllers, initialize all of |
| 141 | * them with slave data setup time of 250 ns, |
| 142 | * Tx & Rx FIFO threshold values as 1 and standard |
| 143 | * mode of operation |
| 144 | */ |
| 145 | U8500_I2C_CONTROLLER(0, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 146 | U8500_I2C_CONTROLLER(1, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 147 | U8500_I2C_CONTROLLER(2, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 148 | U8500_I2C_CONTROLLER(3, 0xe, 1, 1, 100000, I2C_FREQ_MODE_STANDARD); |
| 149 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 150 | static struct amba_device *amba_devs[] __initdata = { |
Rabin Vincent | 4b27aa4 | 2010-05-03 08:18:38 +0100 | [diff] [blame] | 151 | &ux500_uart0_device, |
| 152 | &ux500_uart1_device, |
| 153 | &ux500_uart2_device, |
Rabin Vincent | 9e4e7fe | 2010-05-03 08:03:52 +0100 | [diff] [blame] | 154 | &u8500_ssp0_device, |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 155 | }; |
| 156 | |
Sundar Iyer | 4c61c84 | 2010-09-29 19:43:09 -0700 | [diff] [blame^] | 157 | static const unsigned int ux500_keymap[] = { |
| 158 | KEY(2, 5, KEY_END), |
| 159 | KEY(4, 1, KEY_POWER), |
| 160 | KEY(3, 5, KEY_VOLUMEDOWN), |
| 161 | KEY(1, 3, KEY_3), |
| 162 | KEY(5, 2, KEY_RIGHT), |
| 163 | KEY(5, 0, KEY_9), |
| 164 | |
| 165 | KEY(0, 5, KEY_MENU), |
| 166 | KEY(7, 6, KEY_ENTER), |
| 167 | KEY(4, 5, KEY_0), |
| 168 | KEY(6, 7, KEY_2), |
| 169 | KEY(3, 4, KEY_UP), |
| 170 | KEY(3, 3, KEY_DOWN), |
| 171 | |
| 172 | KEY(6, 4, KEY_SEND), |
| 173 | KEY(6, 2, KEY_BACK), |
| 174 | KEY(4, 2, KEY_VOLUMEUP), |
| 175 | KEY(5, 5, KEY_1), |
| 176 | KEY(4, 3, KEY_LEFT), |
| 177 | KEY(3, 2, KEY_7), |
| 178 | }; |
| 179 | |
| 180 | static const struct matrix_keymap_data ux500_keymap_data = { |
| 181 | .keymap = ux500_keymap, |
| 182 | .keymap_size = ARRAY_SIZE(ux500_keymap), |
| 183 | }; |
| 184 | |
| 185 | /* |
| 186 | * Nomadik SKE keypad |
| 187 | */ |
| 188 | #define ROW_PIN_I0 164 |
| 189 | #define ROW_PIN_I1 163 |
| 190 | #define ROW_PIN_I2 162 |
| 191 | #define ROW_PIN_I3 161 |
| 192 | #define ROW_PIN_I4 156 |
| 193 | #define ROW_PIN_I5 155 |
| 194 | #define ROW_PIN_I6 154 |
| 195 | #define ROW_PIN_I7 153 |
| 196 | #define COL_PIN_O0 168 |
| 197 | #define COL_PIN_O1 167 |
| 198 | #define COL_PIN_O2 166 |
| 199 | #define COL_PIN_O3 165 |
| 200 | #define COL_PIN_O4 160 |
| 201 | #define COL_PIN_O5 159 |
| 202 | #define COL_PIN_O6 158 |
| 203 | #define COL_PIN_O7 157 |
| 204 | |
| 205 | #define SKE_KPD_MAX_ROWS 8 |
| 206 | #define SKE_KPD_MAX_COLS 8 |
| 207 | |
| 208 | static int ske_kp_rows[] = { |
| 209 | ROW_PIN_I0, ROW_PIN_I1, ROW_PIN_I2, ROW_PIN_I3, |
| 210 | ROW_PIN_I4, ROW_PIN_I5, ROW_PIN_I6, ROW_PIN_I7, |
| 211 | }; |
| 212 | |
| 213 | /* |
| 214 | * ske_set_gpio_row: request and set gpio rows |
| 215 | */ |
| 216 | static int ske_set_gpio_row(int gpio) |
| 217 | { |
| 218 | int ret; |
| 219 | |
| 220 | ret = gpio_request(gpio, "ske-kp"); |
| 221 | if (ret < 0) { |
| 222 | pr_err("ske_set_gpio_row: gpio request failed\n"); |
| 223 | return ret; |
| 224 | } |
| 225 | |
| 226 | ret = gpio_direction_output(gpio, 1); |
| 227 | if (ret < 0) { |
| 228 | pr_err("ske_set_gpio_row: gpio direction failed\n"); |
| 229 | gpio_free(gpio); |
| 230 | } |
| 231 | |
| 232 | return ret; |
| 233 | } |
| 234 | |
| 235 | /* |
| 236 | * ske_kp_init - enable the gpio configuration |
| 237 | */ |
| 238 | static int ske_kp_init(void) |
| 239 | { |
| 240 | int ret, i; |
| 241 | |
| 242 | for (i = 0; i < SKE_KPD_MAX_ROWS; i++) { |
| 243 | ret = ske_set_gpio_row(ske_kp_rows[i]); |
| 244 | if (ret < 0) { |
| 245 | pr_err("ske_kp_init: failed init\n"); |
| 246 | return ret; |
| 247 | } |
| 248 | } |
| 249 | |
| 250 | return 0; |
| 251 | } |
| 252 | |
| 253 | static struct ske_keypad_platform_data ske_keypad_board = { |
| 254 | .init = ske_kp_init, |
| 255 | .keymap_data = &ux500_keymap_data, |
| 256 | .no_autorepeat = true, |
| 257 | .krow = SKE_KPD_MAX_ROWS, /* 8x8 matrix */ |
| 258 | .kcol = SKE_KPD_MAX_COLS, |
| 259 | .debounce_ms = 40, /* in millsecs */ |
| 260 | }; |
| 261 | |
| 262 | |
| 263 | |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 264 | /* add any platform devices here - TODO */ |
| 265 | static struct platform_device *platform_devs[] __initdata = { |
Rabin Vincent | f9faf23 | 2010-05-03 08:24:37 +0100 | [diff] [blame] | 266 | &u8500_i2c0_device, |
| 267 | &ux500_i2c1_device, |
| 268 | &ux500_i2c2_device, |
| 269 | &ux500_i2c3_device, |
Sundar Iyer | 4c61c84 | 2010-09-29 19:43:09 -0700 | [diff] [blame^] | 270 | &ux500_ske_keypad_device, |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 271 | }; |
| 272 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 273 | static void __init u8500_init_machine(void) |
| 274 | { |
| 275 | int i; |
| 276 | |
Rabin Vincent | ea05a57 | 2010-06-03 07:58:42 +0100 | [diff] [blame] | 277 | u8500_init_devices(); |
| 278 | |
| 279 | nmk_config_pins(mop500_pins, ARRAY_SIZE(mop500_pins)); |
| 280 | |
Rabin Vincent | f9faf23 | 2010-05-03 08:24:37 +0100 | [diff] [blame] | 281 | u8500_i2c0_device.dev.platform_data = &u8500_i2c0_data; |
| 282 | ux500_i2c1_device.dev.platform_data = &u8500_i2c1_data; |
| 283 | ux500_i2c2_device.dev.platform_data = &u8500_i2c2_data; |
| 284 | ux500_i2c3_device.dev.platform_data = &u8500_i2c3_data; |
Sundar Iyer | 4c61c84 | 2010-09-29 19:43:09 -0700 | [diff] [blame^] | 285 | ux500_ske_keypad_device.dev.platform_data = &ske_keypad_board; |
Rabin Vincent | f9faf23 | 2010-05-03 08:24:37 +0100 | [diff] [blame] | 286 | |
Rabin Vincent | 9e4e7fe | 2010-05-03 08:03:52 +0100 | [diff] [blame] | 287 | u8500_ssp0_device.dev.platform_data = &ssp0_platform_data; |
| 288 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 289 | /* Register the active AMBA devices on this board */ |
| 290 | for (i = 0; i < ARRAY_SIZE(amba_devs); i++) |
| 291 | amba_device_register(amba_devs[i], &iomem_resource); |
| 292 | |
Srinidhi Kasagar | d48a41c | 2010-02-03 13:02:48 +0100 | [diff] [blame] | 293 | platform_add_devices(platform_devs, ARRAY_SIZE(platform_devs)); |
| 294 | |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 295 | spi_register_board_info(u8500_spi_devices, |
| 296 | ARRAY_SIZE(u8500_spi_devices)); |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 297 | } |
| 298 | |
| 299 | MACHINE_START(U8500, "ST-Ericsson MOP500 platform") |
| 300 | /* Maintainer: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> */ |
| 301 | .phys_io = U8500_UART2_BASE, |
| 302 | .io_pg_offst = (IO_ADDRESS(U8500_UART2_BASE) >> 18) & 0xfffc, |
| 303 | .boot_params = 0x100, |
| 304 | .map_io = u8500_map_io, |
Rabin Vincent | 178980f | 2010-05-03 07:39:02 +0100 | [diff] [blame] | 305 | .init_irq = ux500_init_irq, |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 306 | /* we re-use nomadik timer here */ |
Rabin Vincent | 41ac329 | 2010-05-03 08:28:05 +0100 | [diff] [blame] | 307 | .timer = &ux500_timer, |
Srinidhi Kasagar | aa44ef4 | 2009-11-28 08:17:18 +0100 | [diff] [blame] | 308 | .init_machine = u8500_init_machine, |
| 309 | MACHINE_END |