| 1 | // SPDX-License-Identifier: GPL-2.0-only |
| 2 | /* |
| 3 | * linux/arch/arm/mach-omap1/board-ams-delta.c |
| 4 | * |
| 5 | * Modified from board-generic.c |
| 6 | * |
| 7 | * Board specific inits for the Amstrad E3 (codename Delta) videophone |
| 8 | * |
| 9 | * Copyright (C) 2006 Jonathan McDowell <noodles@earth.li> |
| 10 | */ |
| 11 | #include <linux/gpio/driver.h> |
| 12 | #include <linux/gpio/machine.h> |
| 13 | #include <linux/gpio/consumer.h> |
| 14 | #include <linux/kernel.h> |
| 15 | #include <linux/init.h> |
| 16 | #include <linux/input.h> |
| 17 | #include <linux/interrupt.h> |
| 18 | #include <linux/leds.h> |
| 19 | #include <linux/mtd/nand-gpio.h> |
| 20 | #include <linux/mtd/partitions.h> |
| 21 | #include <linux/platform_device.h> |
| 22 | #include <linux/property.h> |
| 23 | #include <linux/regulator/consumer.h> |
| 24 | #include <linux/regulator/fixed.h> |
| 25 | #include <linux/regulator/machine.h> |
| 26 | #include <linux/serial_8250.h> |
| 27 | #include <linux/export.h> |
| 28 | #include <linux/omapfb.h> |
| 29 | #include <linux/io.h> |
| 30 | #include <linux/platform_data/gpio-omap.h> |
| 31 | #include <linux/soc/ti/omap1-mux.h> |
| 32 | |
| 33 | #include <asm/serial.h> |
| 34 | #include <asm/mach-types.h> |
| 35 | #include <asm/mach/arch.h> |
| 36 | #include <asm/mach/map.h> |
| 37 | |
| 38 | #include <linux/platform_data/keypad-omap.h> |
| 39 | |
| 40 | #include "hardware.h" |
| 41 | #include "usb.h" |
| 42 | #include "ams-delta-fiq.h" |
| 43 | #include "board-ams-delta.h" |
| 44 | #include "iomap.h" |
| 45 | #include "common.h" |
| 46 | |
| 47 | static const unsigned int ams_delta_keymap[] = { |
| 48 | KEY(0, 0, KEY_F1), /* Advert */ |
| 49 | |
| 50 | KEY(0, 3, KEY_COFFEE), /* Games */ |
| 51 | KEY(0, 2, KEY_QUESTION), /* Directory */ |
| 52 | KEY(2, 3, KEY_CONNECT), /* Internet */ |
| 53 | KEY(1, 2, KEY_SHOP), /* Services */ |
| 54 | KEY(1, 1, KEY_PHONE), /* VoiceMail */ |
| 55 | |
| 56 | KEY(0, 1, KEY_DELETE), /* Delete */ |
| 57 | KEY(2, 2, KEY_PLAY), /* Play */ |
| 58 | KEY(1, 0, KEY_PAGEUP), /* Up */ |
| 59 | KEY(1, 3, KEY_PAGEDOWN), /* Down */ |
| 60 | KEY(2, 0, KEY_EMAIL), /* ReadEmail */ |
| 61 | KEY(2, 1, KEY_STOP), /* Stop */ |
| 62 | |
| 63 | /* Numeric keypad portion */ |
| 64 | KEY(0, 7, KEY_KP1), |
| 65 | KEY(0, 6, KEY_KP2), |
| 66 | KEY(0, 5, KEY_KP3), |
| 67 | KEY(1, 7, KEY_KP4), |
| 68 | KEY(1, 6, KEY_KP5), |
| 69 | KEY(1, 5, KEY_KP6), |
| 70 | KEY(2, 7, KEY_KP7), |
| 71 | KEY(2, 6, KEY_KP8), |
| 72 | KEY(2, 5, KEY_KP9), |
| 73 | KEY(3, 6, KEY_KP0), |
| 74 | KEY(3, 7, KEY_KPASTERISK), |
| 75 | KEY(3, 5, KEY_KPDOT), /* # key */ |
| 76 | KEY(7, 2, KEY_NUMLOCK), /* Mute */ |
| 77 | KEY(7, 1, KEY_KPMINUS), /* Recall */ |
| 78 | KEY(6, 1, KEY_KPPLUS), /* Redial */ |
| 79 | KEY(7, 6, KEY_KPSLASH), /* Handsfree */ |
| 80 | KEY(6, 0, KEY_ENTER), /* Video */ |
| 81 | |
| 82 | KEY(7, 4, KEY_CAMERA), /* Photo */ |
| 83 | |
| 84 | KEY(0, 4, KEY_F2), /* Home */ |
| 85 | KEY(1, 4, KEY_F3), /* Office */ |
| 86 | KEY(2, 4, KEY_F4), /* Mobile */ |
| 87 | KEY(7, 7, KEY_F5), /* SMS */ |
| 88 | KEY(7, 5, KEY_F6), /* Email */ |
| 89 | |
| 90 | /* QWERTY portion of keypad */ |
| 91 | KEY(3, 4, KEY_Q), |
| 92 | KEY(3, 3, KEY_W), |
| 93 | KEY(3, 2, KEY_E), |
| 94 | KEY(3, 1, KEY_R), |
| 95 | KEY(3, 0, KEY_T), |
| 96 | KEY(4, 7, KEY_Y), |
| 97 | KEY(4, 6, KEY_U), |
| 98 | KEY(4, 5, KEY_I), |
| 99 | KEY(4, 4, KEY_O), |
| 100 | KEY(4, 3, KEY_P), |
| 101 | |
| 102 | KEY(4, 2, KEY_A), |
| 103 | KEY(4, 1, KEY_S), |
| 104 | KEY(4, 0, KEY_D), |
| 105 | KEY(5, 7, KEY_F), |
| 106 | KEY(5, 6, KEY_G), |
| 107 | KEY(5, 5, KEY_H), |
| 108 | KEY(5, 4, KEY_J), |
| 109 | KEY(5, 3, KEY_K), |
| 110 | KEY(5, 2, KEY_L), |
| 111 | |
| 112 | KEY(5, 1, KEY_Z), |
| 113 | KEY(5, 0, KEY_X), |
| 114 | KEY(6, 7, KEY_C), |
| 115 | KEY(6, 6, KEY_V), |
| 116 | KEY(6, 5, KEY_B), |
| 117 | KEY(6, 4, KEY_N), |
| 118 | KEY(6, 3, KEY_M), |
| 119 | KEY(6, 2, KEY_SPACE), |
| 120 | |
| 121 | KEY(7, 0, KEY_LEFTSHIFT), /* Vol up */ |
| 122 | KEY(7, 3, KEY_LEFTCTRL), /* Vol down */ |
| 123 | }; |
| 124 | |
| 125 | #define LATCH1_PHYS 0x01000000 |
| 126 | #define LATCH1_VIRT 0xEA000000 |
| 127 | #define MODEM_PHYS 0x04000000 |
| 128 | #define MODEM_VIRT 0xEB000000 |
| 129 | #define LATCH2_PHYS 0x08000000 |
| 130 | #define LATCH2_VIRT 0xEC000000 |
| 131 | |
| 132 | static struct map_desc ams_delta_io_desc[] __initdata = { |
| 133 | /* AMS_DELTA_LATCH1 */ |
| 134 | { |
| 135 | .virtual = LATCH1_VIRT, |
| 136 | .pfn = __phys_to_pfn(LATCH1_PHYS), |
| 137 | .length = 0x01000000, |
| 138 | .type = MT_DEVICE |
| 139 | }, |
| 140 | /* AMS_DELTA_LATCH2 */ |
| 141 | { |
| 142 | .virtual = LATCH2_VIRT, |
| 143 | .pfn = __phys_to_pfn(LATCH2_PHYS), |
| 144 | .length = 0x01000000, |
| 145 | .type = MT_DEVICE |
| 146 | }, |
| 147 | /* AMS_DELTA_MODEM */ |
| 148 | { |
| 149 | .virtual = MODEM_VIRT, |
| 150 | .pfn = __phys_to_pfn(MODEM_PHYS), |
| 151 | .length = 0x01000000, |
| 152 | .type = MT_DEVICE |
| 153 | } |
| 154 | }; |
| 155 | |
| 156 | static const struct omap_lcd_config ams_delta_lcd_config __initconst = { |
| 157 | .ctrl_name = "internal" , |
| 158 | }; |
| 159 | |
| 160 | static struct omap_usb_config ams_delta_usb_config __initdata = { |
| 161 | .register_host = 1, |
| 162 | .hmc_mode = 16, |
| 163 | .pins[0] = 2, |
| 164 | }; |
| 165 | |
| 166 | #define LATCH1_NGPIO 8 |
| 167 | |
| 168 | static struct resource latch1_resources[] = { |
| 169 | [0] = { |
| 170 | .name = "dat" , |
| 171 | .start = LATCH1_PHYS, |
| 172 | .end = LATCH1_PHYS + (LATCH1_NGPIO - 1) / 8, |
| 173 | .flags = IORESOURCE_MEM, |
| 174 | }, |
| 175 | }; |
| 176 | |
| 177 | #define LATCH1_LABEL "latch1" |
| 178 | |
| 179 | static const struct property_entry latch1_gpio_props[] = { |
| 180 | PROPERTY_ENTRY_STRING("label" , LATCH1_LABEL), |
| 181 | PROPERTY_ENTRY_U32("ngpios" , LATCH1_NGPIO), |
| 182 | { } |
| 183 | }; |
| 184 | |
| 185 | static const struct platform_device_info latch1_gpio_devinfo = { |
| 186 | .name = "basic-mmio-gpio" , |
| 187 | .id = 0, |
| 188 | .res = latch1_resources, |
| 189 | .num_res = ARRAY_SIZE(latch1_resources), |
| 190 | .properties = latch1_gpio_props, |
| 191 | }; |
| 192 | |
| 193 | #define LATCH1_PIN_LED_CAMERA 0 |
| 194 | #define LATCH1_PIN_LED_ADVERT 1 |
| 195 | #define LATCH1_PIN_LED_MAIL 2 |
| 196 | #define LATCH1_PIN_LED_HANDSFREE 3 |
| 197 | #define LATCH1_PIN_LED_VOICEMAIL 4 |
| 198 | #define LATCH1_PIN_LED_VOICE 5 |
| 199 | #define LATCH1_PIN_DOCKIT1 6 |
| 200 | #define LATCH1_PIN_DOCKIT2 7 |
| 201 | |
| 202 | #define LATCH2_NGPIO 16 |
| 203 | |
| 204 | static struct resource latch2_resources[] = { |
| 205 | [0] = { |
| 206 | .name = "dat" , |
| 207 | .start = LATCH2_PHYS, |
| 208 | .end = LATCH2_PHYS + (LATCH2_NGPIO - 1) / 8, |
| 209 | .flags = IORESOURCE_MEM, |
| 210 | }, |
| 211 | }; |
| 212 | |
| 213 | #define LATCH2_LABEL "latch2" |
| 214 | |
| 215 | static const struct property_entry latch2_gpio_props[] = { |
| 216 | PROPERTY_ENTRY_STRING("label" , LATCH2_LABEL), |
| 217 | PROPERTY_ENTRY_U32("ngpios" , LATCH2_NGPIO), |
| 218 | { } |
| 219 | }; |
| 220 | |
| 221 | static struct platform_device_info latch2_gpio_devinfo = { |
| 222 | .name = "basic-mmio-gpio" , |
| 223 | .id = 1, |
| 224 | .res = latch2_resources, |
| 225 | .num_res = ARRAY_SIZE(latch2_resources), |
| 226 | .properties = latch2_gpio_props, |
| 227 | }; |
| 228 | |
| 229 | #define LATCH2_PIN_LCD_VBLEN 0 |
| 230 | #define LATCH2_PIN_LCD_NDISP 1 |
| 231 | #define LATCH2_PIN_NAND_NCE 2 |
| 232 | #define LATCH2_PIN_NAND_NRE 3 |
| 233 | #define LATCH2_PIN_NAND_NWP 4 |
| 234 | #define LATCH2_PIN_NAND_NWE 5 |
| 235 | #define LATCH2_PIN_NAND_ALE 6 |
| 236 | #define LATCH2_PIN_NAND_CLE 7 |
| 237 | #define LATCH2_PIN_KEYBRD_PWR 8 |
| 238 | #define LATCH2_PIN_KEYBRD_DATAOUT 9 |
| 239 | #define LATCH2_PIN_SCARD_RSTIN 10 |
| 240 | #define LATCH2_PIN_SCARD_CMDVCC 11 |
| 241 | #define LATCH2_PIN_MODEM_NRESET 12 |
| 242 | #define LATCH2_PIN_MODEM_CODEC 13 |
| 243 | #define LATCH2_PIN_HANDSFREE_MUTE 14 |
| 244 | #define LATCH2_PIN_HANDSET_MUTE 15 |
| 245 | |
| 246 | static struct regulator_consumer_supply modem_nreset_consumers[] = { |
| 247 | REGULATOR_SUPPLY("RESET#" , "serial8250.1" ), |
| 248 | REGULATOR_SUPPLY("POR" , "cx20442-codec" ), |
| 249 | }; |
| 250 | |
| 251 | static struct regulator_init_data modem_nreset_data = { |
| 252 | .constraints = { |
| 253 | .valid_ops_mask = REGULATOR_CHANGE_STATUS, |
| 254 | .boot_on = 1, |
| 255 | }, |
| 256 | .num_consumer_supplies = ARRAY_SIZE(modem_nreset_consumers), |
| 257 | .consumer_supplies = modem_nreset_consumers, |
| 258 | }; |
| 259 | |
| 260 | static struct fixed_voltage_config modem_nreset_config = { |
| 261 | .supply_name = "modem_nreset" , |
| 262 | .microvolts = 3300000, |
| 263 | .startup_delay = 25000, |
| 264 | .enabled_at_boot = 1, |
| 265 | .init_data = &modem_nreset_data, |
| 266 | }; |
| 267 | |
| 268 | static struct platform_device modem_nreset_device = { |
| 269 | .name = "reg-fixed-voltage" , |
| 270 | .id = -1, |
| 271 | .dev = { |
| 272 | .platform_data = &modem_nreset_config, |
| 273 | }, |
| 274 | }; |
| 275 | |
| 276 | static struct gpiod_lookup_table ams_delta_nreset_gpiod_table = { |
| 277 | .dev_id = "reg-fixed-voltage" , |
| 278 | .table = { |
| 279 | GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_MODEM_NRESET, |
| 280 | NULL, GPIO_ACTIVE_HIGH), |
| 281 | { }, |
| 282 | }, |
| 283 | }; |
| 284 | |
| 285 | struct modem_private_data { |
| 286 | struct regulator *regulator; |
| 287 | }; |
| 288 | |
| 289 | static struct modem_private_data modem_priv; |
| 290 | |
| 291 | /* |
| 292 | * Define partitions for flash device |
| 293 | */ |
| 294 | |
| 295 | static struct mtd_partition partition_info[] = { |
| 296 | { .name = "Kernel" , |
| 297 | .offset = 0, |
| 298 | .size = 3 * SZ_1M + SZ_512K }, |
| 299 | { .name = "u-boot" , |
| 300 | .offset = 3 * SZ_1M + SZ_512K, |
| 301 | .size = SZ_256K }, |
| 302 | { .name = "u-boot params" , |
| 303 | .offset = 3 * SZ_1M + SZ_512K + SZ_256K, |
| 304 | .size = SZ_256K }, |
| 305 | { .name = "Amstrad LDR" , |
| 306 | .offset = 4 * SZ_1M, |
| 307 | .size = SZ_256K }, |
| 308 | { .name = "File system" , |
| 309 | .offset = 4 * SZ_1M + 1 * SZ_256K, |
| 310 | .size = 27 * SZ_1M }, |
| 311 | { .name = "PBL reserved" , |
| 312 | .offset = 32 * SZ_1M - 3 * SZ_256K, |
| 313 | .size = 3 * SZ_256K }, |
| 314 | }; |
| 315 | |
| 316 | static struct gpio_nand_platdata nand_platdata = { |
| 317 | .parts = partition_info, |
| 318 | .num_parts = ARRAY_SIZE(partition_info), |
| 319 | }; |
| 320 | |
| 321 | static struct platform_device ams_delta_nand_device = { |
| 322 | .name = "ams-delta-nand" , |
| 323 | .id = -1, |
| 324 | .dev = { |
| 325 | .platform_data = &nand_platdata, |
| 326 | }, |
| 327 | }; |
| 328 | |
| 329 | #define OMAP_GPIO_LABEL "gpio-0-15" |
| 330 | #define OMAP_MPUIO_LABEL "mpuio" |
| 331 | |
| 332 | static struct gpiod_lookup_table ams_delta_nand_gpio_table = { |
| 333 | .table = { |
| 334 | GPIO_LOOKUP(OMAP_GPIO_LABEL, AMS_DELTA_GPIO_PIN_NAND_RB, "rdy" , |
| 335 | 0), |
| 336 | GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NCE, "nce" , |
| 337 | GPIO_ACTIVE_LOW), |
| 338 | GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NRE, "nre" , |
| 339 | GPIO_ACTIVE_LOW), |
| 340 | GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NWP, "nwp" , |
| 341 | GPIO_ACTIVE_LOW), |
| 342 | GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_NWE, "nwe" , |
| 343 | GPIO_ACTIVE_LOW), |
| 344 | GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_ALE, "ale" , 0), |
| 345 | GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_NAND_CLE, "cle" , 0), |
| 346 | GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 0, "data" , 0, 0), |
| 347 | GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 1, "data" , 1, 0), |
| 348 | GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 2, "data" , 2, 0), |
| 349 | GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 3, "data" , 3, 0), |
| 350 | GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 4, "data" , 4, 0), |
| 351 | GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 5, "data" , 5, 0), |
| 352 | GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 6, "data" , 6, 0), |
| 353 | GPIO_LOOKUP_IDX(OMAP_MPUIO_LABEL, 7, "data" , 7, 0), |
| 354 | { }, |
| 355 | }, |
| 356 | }; |
| 357 | |
| 358 | static struct resource ams_delta_kp_resources[] = { |
| 359 | [0] = { |
| 360 | .start = INT_KEYBOARD, |
| 361 | .end = INT_KEYBOARD, |
| 362 | .flags = IORESOURCE_IRQ, |
| 363 | }, |
| 364 | }; |
| 365 | |
| 366 | static const struct matrix_keymap_data ams_delta_keymap_data = { |
| 367 | .keymap = ams_delta_keymap, |
| 368 | .keymap_size = ARRAY_SIZE(ams_delta_keymap), |
| 369 | }; |
| 370 | |
| 371 | static struct omap_kp_platform_data ams_delta_kp_data = { |
| 372 | .rows = 8, |
| 373 | .cols = 8, |
| 374 | .keymap_data = &ams_delta_keymap_data, |
| 375 | .delay = 9, |
| 376 | }; |
| 377 | |
| 378 | static struct platform_device ams_delta_kp_device = { |
| 379 | .name = "omap-keypad" , |
| 380 | .id = -1, |
| 381 | .dev = { |
| 382 | .platform_data = &ams_delta_kp_data, |
| 383 | }, |
| 384 | .num_resources = ARRAY_SIZE(ams_delta_kp_resources), |
| 385 | .resource = ams_delta_kp_resources, |
| 386 | }; |
| 387 | |
| 388 | static struct platform_device ams_delta_lcd_device = { |
| 389 | .name = "lcd_ams_delta" , |
| 390 | .id = -1, |
| 391 | }; |
| 392 | |
| 393 | static struct gpiod_lookup_table ams_delta_lcd_gpio_table = { |
| 394 | .table = { |
| 395 | GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_LCD_VBLEN, "vblen" , 0), |
| 396 | GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_LCD_NDISP, "ndisp" , 0), |
| 397 | { }, |
| 398 | }, |
| 399 | }; |
| 400 | |
| 401 | static struct gpio_led gpio_leds[] __initdata = { |
| 402 | [LATCH1_PIN_LED_CAMERA] = { |
| 403 | .name = "camera" , |
| 404 | .default_state = LEDS_GPIO_DEFSTATE_OFF, |
| 405 | }, |
| 406 | [LATCH1_PIN_LED_ADVERT] = { |
| 407 | .name = "advert" , |
| 408 | .default_state = LEDS_GPIO_DEFSTATE_OFF, |
| 409 | }, |
| 410 | [LATCH1_PIN_LED_MAIL] = { |
| 411 | .name = "email" , |
| 412 | .default_state = LEDS_GPIO_DEFSTATE_OFF, |
| 413 | }, |
| 414 | [LATCH1_PIN_LED_HANDSFREE] = { |
| 415 | .name = "handsfree" , |
| 416 | .default_state = LEDS_GPIO_DEFSTATE_OFF, |
| 417 | }, |
| 418 | [LATCH1_PIN_LED_VOICEMAIL] = { |
| 419 | .name = "voicemail" , |
| 420 | .default_state = LEDS_GPIO_DEFSTATE_OFF, |
| 421 | }, |
| 422 | [LATCH1_PIN_LED_VOICE] = { |
| 423 | .name = "voice" , |
| 424 | .default_state = LEDS_GPIO_DEFSTATE_OFF, |
| 425 | }, |
| 426 | }; |
| 427 | |
| 428 | static const struct gpio_led_platform_data leds_pdata __initconst = { |
| 429 | .leds = gpio_leds, |
| 430 | .num_leds = ARRAY_SIZE(gpio_leds), |
| 431 | }; |
| 432 | |
| 433 | static struct gpiod_lookup_table leds_gpio_table = { |
| 434 | .table = { |
| 435 | GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_CAMERA, NULL, |
| 436 | LATCH1_PIN_LED_CAMERA, 0), |
| 437 | GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_ADVERT, NULL, |
| 438 | LATCH1_PIN_LED_ADVERT, 0), |
| 439 | GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_MAIL, NULL, |
| 440 | LATCH1_PIN_LED_MAIL, 0), |
| 441 | GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_HANDSFREE, NULL, |
| 442 | LATCH1_PIN_LED_HANDSFREE, 0), |
| 443 | GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_VOICEMAIL, NULL, |
| 444 | LATCH1_PIN_LED_VOICEMAIL, 0), |
| 445 | GPIO_LOOKUP_IDX(LATCH1_LABEL, LATCH1_PIN_LED_VOICE, NULL, |
| 446 | LATCH1_PIN_LED_VOICE, 0), |
| 447 | { }, |
| 448 | }, |
| 449 | }; |
| 450 | |
| 451 | static struct platform_device ams_delta_audio_device = { |
| 452 | .name = "ams-delta-audio" , |
| 453 | .id = -1, |
| 454 | }; |
| 455 | |
| 456 | static struct gpiod_lookup_table ams_delta_audio_gpio_table = { |
| 457 | .table = { |
| 458 | GPIO_LOOKUP(OMAP_GPIO_LABEL, AMS_DELTA_GPIO_PIN_HOOK_SWITCH, |
| 459 | "hook_switch" , 0), |
| 460 | GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_MODEM_CODEC, |
| 461 | "modem_codec" , 0), |
| 462 | GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_HANDSFREE_MUTE, |
| 463 | "handsfree_mute" , 0), |
| 464 | GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_HANDSET_MUTE, |
| 465 | "handset_mute" , 0), |
| 466 | { }, |
| 467 | }, |
| 468 | }; |
| 469 | |
| 470 | static struct platform_device cx20442_codec_device = { |
| 471 | .name = "cx20442-codec" , |
| 472 | .id = -1, |
| 473 | }; |
| 474 | |
| 475 | static struct resource ams_delta_serio_resources[] = { |
| 476 | { |
| 477 | .flags = IORESOURCE_IRQ, |
| 478 | /* |
| 479 | * Initialize IRQ resource with invalid IRQ number. |
| 480 | * It will be replaced with dynamically allocated GPIO IRQ |
| 481 | * obtained from GPIO chip as soon as the chip is available. |
| 482 | */ |
| 483 | .start = -EINVAL, |
| 484 | .end = -EINVAL, |
| 485 | }, |
| 486 | }; |
| 487 | |
| 488 | static struct platform_device ams_delta_serio_device = { |
| 489 | .name = "ams-delta-serio" , |
| 490 | .id = PLATFORM_DEVID_NONE, |
| 491 | .dev = { |
| 492 | /* |
| 493 | * Initialize .platform_data explicitly with NULL to |
| 494 | * indicate it is going to be used. It will be replaced |
| 495 | * with FIQ buffer address as soon as FIQ is initialized. |
| 496 | */ |
| 497 | .platform_data = NULL, |
| 498 | }, |
| 499 | .num_resources = ARRAY_SIZE(ams_delta_serio_resources), |
| 500 | .resource = ams_delta_serio_resources, |
| 501 | }; |
| 502 | |
| 503 | static struct regulator_consumer_supply keybrd_pwr_consumers[] = { |
| 504 | /* |
| 505 | * Initialize supply .dev_name with NULL. It will be replaced |
| 506 | * with serio dev_name() as soon as the serio device is registered. |
| 507 | */ |
| 508 | REGULATOR_SUPPLY("vcc" , NULL), |
| 509 | }; |
| 510 | |
| 511 | static struct regulator_init_data keybrd_pwr_initdata = { |
| 512 | .constraints = { |
| 513 | .valid_ops_mask = REGULATOR_CHANGE_STATUS, |
| 514 | }, |
| 515 | .num_consumer_supplies = ARRAY_SIZE(keybrd_pwr_consumers), |
| 516 | .consumer_supplies = keybrd_pwr_consumers, |
| 517 | }; |
| 518 | |
| 519 | static struct fixed_voltage_config keybrd_pwr_config = { |
| 520 | .supply_name = "keybrd_pwr" , |
| 521 | .microvolts = 5000000, |
| 522 | .init_data = &keybrd_pwr_initdata, |
| 523 | }; |
| 524 | |
| 525 | static struct platform_device keybrd_pwr_device = { |
| 526 | .name = "reg-fixed-voltage" , |
| 527 | .id = PLATFORM_DEVID_AUTO, |
| 528 | .dev = { |
| 529 | .platform_data = &keybrd_pwr_config, |
| 530 | }, |
| 531 | }; |
| 532 | |
| 533 | static struct gpiod_lookup_table keybrd_pwr_gpio_table = { |
| 534 | .table = { |
| 535 | GPIO_LOOKUP(LATCH2_LABEL, LATCH2_PIN_KEYBRD_PWR, NULL, |
| 536 | GPIO_ACTIVE_HIGH), |
| 537 | { }, |
| 538 | }, |
| 539 | }; |
| 540 | |
| 541 | static struct platform_device *ams_delta_devices[] __initdata = { |
| 542 | &ams_delta_kp_device, |
| 543 | &ams_delta_audio_device, |
| 544 | &ams_delta_serio_device, |
| 545 | &ams_delta_nand_device, |
| 546 | &ams_delta_lcd_device, |
| 547 | &cx20442_codec_device, |
| 548 | &modem_nreset_device, |
| 549 | }; |
| 550 | |
| 551 | static struct gpiod_lookup_table *ams_delta_gpio_tables[] __initdata = { |
| 552 | &ams_delta_nreset_gpiod_table, |
| 553 | &ams_delta_audio_gpio_table, |
| 554 | &keybrd_pwr_gpio_table, |
| 555 | &ams_delta_lcd_gpio_table, |
| 556 | &ams_delta_nand_gpio_table, |
| 557 | }; |
| 558 | |
| 559 | static struct gpiod_hog ams_delta_gpio_hogs[] = { |
| 560 | GPIO_HOG(LATCH2_LABEL, LATCH2_PIN_KEYBRD_DATAOUT, "keybrd_dataout" , |
| 561 | GPIO_ACTIVE_HIGH, GPIOD_OUT_LOW), |
| 562 | {}, |
| 563 | }; |
| 564 | |
| 565 | static struct plat_serial8250_port ams_delta_modem_ports[]; |
| 566 | |
| 567 | /* |
| 568 | * Obtain MODEM IRQ GPIO descriptor using its hardware pin |
| 569 | * number and assign related IRQ number to the MODEM port. |
| 570 | * Keep the GPIO descriptor open so nobody steps in. |
| 571 | */ |
| 572 | static void __init modem_assign_irq(struct gpio_chip *chip) |
| 573 | { |
| 574 | struct gpio_desc *gpiod; |
| 575 | |
| 576 | gpiod = gpiochip_request_own_desc(gc: chip, hwnum: AMS_DELTA_GPIO_PIN_MODEM_IRQ, |
| 577 | label: "modem_irq" , lflags: GPIO_ACTIVE_HIGH, |
| 578 | dflags: GPIOD_IN); |
| 579 | if (IS_ERR(ptr: gpiod)) { |
| 580 | pr_err("%s: modem IRQ GPIO request failed (%ld)\n" , __func__, |
| 581 | PTR_ERR(gpiod)); |
| 582 | } else { |
| 583 | ams_delta_modem_ports[0].irq = gpiod_to_irq(desc: gpiod); |
| 584 | } |
| 585 | } |
| 586 | |
| 587 | /* |
| 588 | * The purpose of this function is to take care of proper initialization of |
| 589 | * devices and data structures which depend on GPIO lines provided by OMAP GPIO |
| 590 | * banks but their drivers don't use GPIO lookup tables or GPIO layer at all. |
| 591 | * The function may be called as soon as OMAP GPIO devices are probed. |
| 592 | * Since that happens at postcore_initcall, it can be called successfully |
| 593 | * from init_machine or later. |
| 594 | * Dependent devices may be registered from within this function or later. |
| 595 | */ |
| 596 | static void __init omap_gpio_deps_init(void) |
| 597 | { |
| 598 | struct gpio_device *gdev; |
| 599 | struct gpio_chip *chip; |
| 600 | |
| 601 | /* |
| 602 | * Some drivers may not use GPIO lookup tables but need to be provided |
| 603 | * with GPIO numbers. The same applies to GPIO based IRQ lines - some |
| 604 | * drivers may even not use GPIO layer but expect just IRQ numbers. |
| 605 | * We could either define GPIO lookup tables then use them on behalf |
| 606 | * of those devices, or we can use GPIO driver level methods for |
| 607 | * identification of GPIO and IRQ numbers. |
| 608 | * |
| 609 | * This reference will be leaked but that's alright as this device |
| 610 | * never goes down. |
| 611 | */ |
| 612 | gdev = gpio_device_find_by_label(OMAP_GPIO_LABEL); |
| 613 | if (!gdev) { |
| 614 | pr_err("%s: OMAP GPIO device not found\n" , __func__); |
| 615 | return; |
| 616 | } |
| 617 | |
| 618 | chip = gpio_device_get_chip(gdev); |
| 619 | |
| 620 | /* |
| 621 | * Start with FIQ initialization as it may have to request |
| 622 | * and release successfully each OMAP GPIO pin in turn. |
| 623 | */ |
| 624 | ams_delta_init_fiq(chip, pdev: &ams_delta_serio_device); |
| 625 | |
| 626 | modem_assign_irq(chip); |
| 627 | } |
| 628 | |
| 629 | /* |
| 630 | * Initialize latch2 pins with values which are safe for dependent on-board |
| 631 | * devices or useful for their successull initialization even before GPIO |
| 632 | * driver takes control over the latch pins: |
| 633 | * - LATCH2_PIN_LCD_VBLEN = 0 |
| 634 | * - LATCH2_PIN_LCD_NDISP = 0 Keep LCD device powered off before its |
| 635 | * driver takes control over it. |
| 636 | * - LATCH2_PIN_NAND_NCE = 0 |
| 637 | * - LATCH2_PIN_NAND_NWP = 0 Keep NAND device down and write- |
| 638 | * protected before its driver takes |
| 639 | * control over it. |
| 640 | * - LATCH2_PIN_KEYBRD_PWR = 0 Keep keyboard powered off before serio |
| 641 | * driver takes control over it. |
| 642 | * - LATCH2_PIN_KEYBRD_DATAOUT = 0 Keep low to avoid corruption of first |
| 643 | * byte of data received from attached |
| 644 | * keyboard when serio device is probed; |
| 645 | * the pin is also hogged low by the latch2 |
| 646 | * GPIO driver as soon as it is ready. |
| 647 | * - LATCH2_PIN_MODEM_NRESET = 1 Enable voice MODEM device, allowing for |
| 648 | * its successful probe even before a |
| 649 | * regulator it depends on, which in turn |
| 650 | * takes control over the pin, is set up. |
| 651 | * - LATCH2_PIN_MODEM_CODEC = 1 Attach voice MODEM CODEC data port |
| 652 | * to the MODEM so the CODEC is under |
| 653 | * control even if audio driver doesn't |
| 654 | * take it over. |
| 655 | */ |
| 656 | static void __init ams_delta_latch2_init(void) |
| 657 | { |
| 658 | u16 latch2 = 1 << LATCH2_PIN_MODEM_NRESET | 1 << LATCH2_PIN_MODEM_CODEC; |
| 659 | |
| 660 | __raw_writew(val: latch2, addr: IOMEM(LATCH2_VIRT)); |
| 661 | } |
| 662 | |
| 663 | static void __init ams_delta_init(void) |
| 664 | { |
| 665 | struct platform_device *leds_pdev; |
| 666 | |
| 667 | /* mux pins for uarts */ |
| 668 | omap_cfg_reg(reg_cfg: UART1_TX); |
| 669 | omap_cfg_reg(reg_cfg: UART1_RTS); |
| 670 | |
| 671 | /* parallel camera interface */ |
| 672 | omap_cfg_reg(reg_cfg: H19_1610_CAM_EXCLK); |
| 673 | omap_cfg_reg(reg_cfg: J15_1610_CAM_LCLK); |
| 674 | omap_cfg_reg(reg_cfg: L18_1610_CAM_VS); |
| 675 | omap_cfg_reg(reg_cfg: L15_1610_CAM_HS); |
| 676 | omap_cfg_reg(reg_cfg: L19_1610_CAM_D0); |
| 677 | omap_cfg_reg(reg_cfg: K14_1610_CAM_D1); |
| 678 | omap_cfg_reg(reg_cfg: K15_1610_CAM_D2); |
| 679 | omap_cfg_reg(reg_cfg: K19_1610_CAM_D3); |
| 680 | omap_cfg_reg(reg_cfg: K18_1610_CAM_D4); |
| 681 | omap_cfg_reg(reg_cfg: J14_1610_CAM_D5); |
| 682 | omap_cfg_reg(reg_cfg: J19_1610_CAM_D6); |
| 683 | omap_cfg_reg(reg_cfg: J18_1610_CAM_D7); |
| 684 | |
| 685 | omap_gpio_deps_init(); |
| 686 | ams_delta_latch2_init(); |
| 687 | gpiod_add_hogs(hogs: ams_delta_gpio_hogs); |
| 688 | |
| 689 | omap_serial_init(); |
| 690 | omap_register_i2c_bus(bus_id: 1, clkrate: 100, NULL, len: 0); |
| 691 | |
| 692 | omap1_usb_init(pdata: &ams_delta_usb_config); |
| 693 | platform_add_devices(ams_delta_devices, ARRAY_SIZE(ams_delta_devices)); |
| 694 | |
| 695 | platform_device_register_full(pdevinfo: &latch1_gpio_devinfo); |
| 696 | platform_device_register_full(pdevinfo: &latch2_gpio_devinfo); |
| 697 | |
| 698 | /* |
| 699 | * As soon as regulator consumers have been registered, assign their |
| 700 | * dev_names to consumer supply entries of respective regulators. |
| 701 | */ |
| 702 | keybrd_pwr_consumers[0].dev_name = |
| 703 | dev_name(dev: &ams_delta_serio_device.dev); |
| 704 | |
| 705 | /* |
| 706 | * Once consumer supply entries are populated with dev_names, |
| 707 | * register regulator devices. At this stage only the keyboard |
| 708 | * power regulator has its consumer supply table fully populated. |
| 709 | */ |
| 710 | platform_device_register(&keybrd_pwr_device); |
| 711 | |
| 712 | /* |
| 713 | * As soon as GPIO consumers have been registered, assign |
| 714 | * their dev_names to respective GPIO lookup tables. |
| 715 | */ |
| 716 | ams_delta_audio_gpio_table.dev_id = |
| 717 | dev_name(dev: &ams_delta_audio_device.dev); |
| 718 | keybrd_pwr_gpio_table.dev_id = dev_name(dev: &keybrd_pwr_device.dev); |
| 719 | ams_delta_nand_gpio_table.dev_id = dev_name(dev: &ams_delta_nand_device.dev); |
| 720 | ams_delta_lcd_gpio_table.dev_id = dev_name(dev: &ams_delta_lcd_device.dev); |
| 721 | |
| 722 | /* |
| 723 | * Once GPIO lookup tables are populated with dev_names, register them. |
| 724 | */ |
| 725 | gpiod_add_lookup_tables(tables: ams_delta_gpio_tables, |
| 726 | ARRAY_SIZE(ams_delta_gpio_tables)); |
| 727 | |
| 728 | leds_pdev = gpio_led_register_device(PLATFORM_DEVID_NONE, pdata: &leds_pdata); |
| 729 | if (!IS_ERR_OR_NULL(ptr: leds_pdev)) { |
| 730 | leds_gpio_table.dev_id = dev_name(dev: &leds_pdev->dev); |
| 731 | gpiod_add_lookup_table(table: &leds_gpio_table); |
| 732 | } |
| 733 | |
| 734 | omap_writew(omap_readw(ARM_RSTCT1) | 0x0004, ARM_RSTCT1); |
| 735 | |
| 736 | omapfb_set_lcd_config(config: &ams_delta_lcd_config); |
| 737 | } |
| 738 | |
| 739 | static void modem_pm(struct uart_port *port, unsigned int state, unsigned old) |
| 740 | { |
| 741 | struct modem_private_data *priv = port->private_data; |
| 742 | int ret; |
| 743 | |
| 744 | if (!priv) |
| 745 | return; |
| 746 | |
| 747 | if (IS_ERR(ptr: priv->regulator)) |
| 748 | return; |
| 749 | |
| 750 | if (state == old) |
| 751 | return; |
| 752 | |
| 753 | if (state == 0) |
| 754 | ret = regulator_enable(regulator: priv->regulator); |
| 755 | else if (old == 0) |
| 756 | ret = regulator_disable(regulator: priv->regulator); |
| 757 | else |
| 758 | ret = 0; |
| 759 | |
| 760 | if (ret) |
| 761 | dev_warn(port->dev, |
| 762 | "ams_delta modem_pm: failed to %sable regulator: %d\n" , |
| 763 | state ? "dis" : "en" , ret); |
| 764 | } |
| 765 | |
| 766 | static struct plat_serial8250_port ams_delta_modem_ports[] = { |
| 767 | { |
| 768 | .membase = IOMEM(MODEM_VIRT), |
| 769 | .mapbase = MODEM_PHYS, |
| 770 | .irq = IRQ_NOTCONNECTED, /* changed later */ |
| 771 | .flags = UPF_BOOT_AUTOCONF, |
| 772 | .irqflags = IRQF_TRIGGER_RISING, |
| 773 | .iotype = UPIO_MEM, |
| 774 | .regshift = 1, |
| 775 | .uartclk = BASE_BAUD * 16, |
| 776 | .pm = modem_pm, |
| 777 | .private_data = &modem_priv, |
| 778 | }, |
| 779 | { }, |
| 780 | }; |
| 781 | |
| 782 | static int ams_delta_modem_pm_activate(struct device *dev) |
| 783 | { |
| 784 | modem_priv.regulator = regulator_get(dev, id: "RESET#" ); |
| 785 | if (IS_ERR(ptr: modem_priv.regulator)) |
| 786 | return -EPROBE_DEFER; |
| 787 | |
| 788 | return 0; |
| 789 | } |
| 790 | |
| 791 | static struct dev_pm_domain ams_delta_modem_pm_domain = { |
| 792 | .activate = ams_delta_modem_pm_activate, |
| 793 | }; |
| 794 | |
| 795 | static struct platform_device ams_delta_modem_device = { |
| 796 | .name = "serial8250" , |
| 797 | .id = PLAT8250_DEV_PLATFORM1, |
| 798 | .dev = { |
| 799 | .platform_data = ams_delta_modem_ports, |
| 800 | .pm_domain = &ams_delta_modem_pm_domain, |
| 801 | }, |
| 802 | }; |
| 803 | |
| 804 | /* |
| 805 | * This function expects MODEM IRQ number already assigned to the port. |
| 806 | * The MODEM device requires its RESET# pin kept high during probe. |
| 807 | * That requirement can be fulfilled in several ways: |
| 808 | * - with a descriptor of already functional modem_nreset regulator |
| 809 | * assigned to the MODEM private data, |
| 810 | * - with the regulator not yet controlled by modem_pm function but |
| 811 | * already enabled by default on probe, |
| 812 | * - before the modem_nreset regulator is probed, with the pin already |
| 813 | * set high explicitly. |
| 814 | * The last one is already guaranteed by ams_delta_latch2_init() called |
| 815 | * from machine_init. |
| 816 | * In order to avoid taking over ttyS0 device slot, the MODEM device |
| 817 | * should be registered after OMAP serial ports. Since those ports |
| 818 | * are registered at arch_initcall, this function can be called safely |
| 819 | * at arch_initcall_sync earliest. |
| 820 | */ |
| 821 | static int __init ams_delta_modem_init(void) |
| 822 | { |
| 823 | if (!machine_is_ams_delta()) |
| 824 | return -ENODEV; |
| 825 | |
| 826 | omap_cfg_reg(reg_cfg: M14_1510_GPIO2); |
| 827 | |
| 828 | /* Initialize the modem_nreset regulator consumer before use */ |
| 829 | modem_priv.regulator = ERR_PTR(error: -ENODEV); |
| 830 | |
| 831 | return platform_device_register(&ams_delta_modem_device); |
| 832 | } |
| 833 | arch_initcall_sync(ams_delta_modem_init); |
| 834 | |
| 835 | static void __init ams_delta_map_io(void) |
| 836 | { |
| 837 | omap1_map_io(); |
| 838 | iotable_init(ams_delta_io_desc, ARRAY_SIZE(ams_delta_io_desc)); |
| 839 | } |
| 840 | |
| 841 | MACHINE_START(AMS_DELTA, "Amstrad E3 (Delta)" ) |
| 842 | /* Maintainer: Jonathan McDowell <noodles@earth.li> */ |
| 843 | .atag_offset = 0x100, |
| 844 | .map_io = ams_delta_map_io, |
| 845 | .init_early = omap1_init_early, |
| 846 | .init_irq = omap1_init_irq, |
| 847 | .init_machine = ams_delta_init, |
| 848 | .init_late = omap1_init_late, |
| 849 | .init_time = omap1_timer_init, |
| 850 | .restart = omap1_restart, |
| 851 | MACHINE_END |
| 852 | |