Guennadi Liakhovetski | 574ec54 | 2009-06-23 13:26:23 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009 |
| 3 | * Guennadi Liakhovetski, DENX Software Engineering, <lg@denx.de> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation. |
| 8 | */ |
| 9 | #include <linux/gpio.h> |
| 10 | #include <linux/gpio_keys.h> |
| 11 | #include <linux/input.h> |
| 12 | #include <linux/platform_device.h> |
| 13 | #include <linux/spi/spi.h> |
| 14 | |
| 15 | #include <mach/common.h> |
Guennadi Liakhovetski | 574ec54 | 2009-06-23 13:26:23 +0200 | [diff] [blame] | 16 | #include <mach/iomux-mx3.h> |
| 17 | |
| 18 | #include <asm/mach-types.h> |
| 19 | |
| 20 | #include "pcm037.h" |
| 21 | #include "devices.h" |
| 22 | |
| 23 | static unsigned int pcm037_eet_pins[] = { |
Guennadi Liakhovetski | 574ec54 | 2009-06-23 13:26:23 +0200 | [diff] [blame] | 24 | /* Reserve and hardwire GPIO 57 high - S6E63D6 chipselect */ |
| 25 | IOMUX_MODE(MX31_PIN_KEY_COL7, IOMUX_CONFIG_GPIO), |
| 26 | /* GPIO keys */ |
| 27 | IOMUX_MODE(MX31_PIN_GPIO1_0, IOMUX_CONFIG_GPIO), /* 0 */ |
| 28 | IOMUX_MODE(MX31_PIN_GPIO1_1, IOMUX_CONFIG_GPIO), /* 1 */ |
| 29 | IOMUX_MODE(MX31_PIN_GPIO1_2, IOMUX_CONFIG_GPIO), /* 2 */ |
| 30 | IOMUX_MODE(MX31_PIN_GPIO1_3, IOMUX_CONFIG_GPIO), /* 3 */ |
| 31 | IOMUX_MODE(MX31_PIN_SVEN0, IOMUX_CONFIG_GPIO), /* 32 */ |
| 32 | IOMUX_MODE(MX31_PIN_STX0, IOMUX_CONFIG_GPIO), /* 33 */ |
| 33 | IOMUX_MODE(MX31_PIN_SRX0, IOMUX_CONFIG_GPIO), /* 34 */ |
| 34 | IOMUX_MODE(MX31_PIN_SIMPD0, IOMUX_CONFIG_GPIO), /* 35 */ |
| 35 | IOMUX_MODE(MX31_PIN_RTS1, IOMUX_CONFIG_GPIO), /* 38 */ |
| 36 | IOMUX_MODE(MX31_PIN_CTS1, IOMUX_CONFIG_GPIO), /* 39 */ |
| 37 | IOMUX_MODE(MX31_PIN_KEY_ROW4, IOMUX_CONFIG_GPIO), /* 50 */ |
| 38 | IOMUX_MODE(MX31_PIN_KEY_ROW5, IOMUX_CONFIG_GPIO), /* 51 */ |
| 39 | IOMUX_MODE(MX31_PIN_KEY_ROW6, IOMUX_CONFIG_GPIO), /* 52 */ |
| 40 | IOMUX_MODE(MX31_PIN_KEY_ROW7, IOMUX_CONFIG_GPIO), /* 53 */ |
| 41 | |
| 42 | /* LEDs */ |
| 43 | IOMUX_MODE(MX31_PIN_DTR_DTE1, IOMUX_CONFIG_GPIO), /* 44 */ |
| 44 | IOMUX_MODE(MX31_PIN_DSR_DTE1, IOMUX_CONFIG_GPIO), /* 45 */ |
| 45 | IOMUX_MODE(MX31_PIN_KEY_COL5, IOMUX_CONFIG_GPIO), /* 55 */ |
| 46 | IOMUX_MODE(MX31_PIN_KEY_COL6, IOMUX_CONFIG_GPIO), /* 56 */ |
| 47 | }; |
| 48 | |
| 49 | /* SPI */ |
| 50 | static struct spi_board_info pcm037_spi_dev[] = { |
| 51 | { |
| 52 | .modalias = "dac124s085", |
| 53 | .max_speed_hz = 400000, |
| 54 | .bus_num = 0, |
| 55 | .chip_select = 0, /* Index in pcm037_spi1_cs[] */ |
| 56 | .mode = SPI_CPHA, |
| 57 | }, |
| 58 | }; |
| 59 | |
| 60 | /* Platform Data for MXC CSPI */ |
| 61 | #if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE) |
| 62 | static int pcm037_spi1_cs[] = {MXC_SPI_CS(1), IOMUX_TO_GPIO(MX31_PIN_KEY_COL7)}; |
| 63 | |
Uwe Kleine-König | a4dc013 | 2010-06-22 10:14:15 +0200 | [diff] [blame] | 64 | static const struct spi_imx_master pcm037_spi1_pdata __initconst = { |
Guennadi Liakhovetski | 574ec54 | 2009-06-23 13:26:23 +0200 | [diff] [blame] | 65 | .chipselect = pcm037_spi1_cs, |
| 66 | .num_chipselect = ARRAY_SIZE(pcm037_spi1_cs), |
| 67 | }; |
| 68 | #endif |
| 69 | |
| 70 | /* GPIO-keys input device */ |
| 71 | static struct gpio_keys_button pcm037_gpio_keys[] = { |
| 72 | { |
| 73 | .type = EV_KEY, |
| 74 | .code = KEY_L, |
| 75 | .gpio = 0, |
| 76 | .desc = "Wheel Manual", |
| 77 | .wakeup = 0, |
| 78 | }, { |
| 79 | .type = EV_KEY, |
| 80 | .code = KEY_A, |
| 81 | .gpio = 1, |
| 82 | .desc = "Wheel AF", |
| 83 | .wakeup = 0, |
| 84 | }, { |
| 85 | .type = EV_KEY, |
| 86 | .code = KEY_V, |
| 87 | .gpio = 2, |
| 88 | .desc = "Wheel View", |
| 89 | .wakeup = 0, |
| 90 | }, { |
| 91 | .type = EV_KEY, |
| 92 | .code = KEY_M, |
| 93 | .gpio = 3, |
| 94 | .desc = "Wheel Menu", |
| 95 | .wakeup = 0, |
| 96 | }, { |
| 97 | .type = EV_KEY, |
| 98 | .code = KEY_UP, |
| 99 | .gpio = 32, |
| 100 | .desc = "Nav Pad Up", |
| 101 | .wakeup = 0, |
| 102 | }, { |
| 103 | .type = EV_KEY, |
| 104 | .code = KEY_RIGHT, |
| 105 | .gpio = 33, |
| 106 | .desc = "Nav Pad Right", |
| 107 | .wakeup = 0, |
| 108 | }, { |
| 109 | .type = EV_KEY, |
| 110 | .code = KEY_DOWN, |
| 111 | .gpio = 34, |
| 112 | .desc = "Nav Pad Down", |
| 113 | .wakeup = 0, |
| 114 | }, { |
| 115 | .type = EV_KEY, |
| 116 | .code = KEY_LEFT, |
| 117 | .gpio = 35, |
| 118 | .desc = "Nav Pad Left", |
| 119 | .wakeup = 0, |
| 120 | }, { |
| 121 | .type = EV_KEY, |
| 122 | .code = KEY_ENTER, |
| 123 | .gpio = 38, |
| 124 | .desc = "Nav Pad Ok", |
| 125 | .wakeup = 0, |
| 126 | }, { |
| 127 | .type = EV_KEY, |
| 128 | .code = KEY_O, |
| 129 | .gpio = 39, |
| 130 | .desc = "Wheel Off", |
| 131 | .wakeup = 0, |
| 132 | }, { |
| 133 | .type = EV_KEY, |
| 134 | .code = BTN_FORWARD, |
| 135 | .gpio = 50, |
| 136 | .desc = "Focus Forward", |
| 137 | .wakeup = 0, |
| 138 | }, { |
| 139 | .type = EV_KEY, |
| 140 | .code = BTN_BACK, |
| 141 | .gpio = 51, |
| 142 | .desc = "Focus Backward", |
| 143 | .wakeup = 0, |
| 144 | }, { |
| 145 | .type = EV_KEY, |
| 146 | .code = BTN_MIDDLE, |
| 147 | .gpio = 52, |
| 148 | .desc = "Release Half", |
| 149 | .wakeup = 0, |
| 150 | }, { |
| 151 | .type = EV_KEY, |
| 152 | .code = BTN_EXTRA, |
| 153 | .gpio = 53, |
| 154 | .desc = "Release Full", |
| 155 | .wakeup = 0, |
| 156 | }, |
| 157 | }; |
| 158 | |
| 159 | static struct gpio_keys_platform_data pcm037_gpio_keys_platform_data = { |
| 160 | .buttons = pcm037_gpio_keys, |
| 161 | .nbuttons = ARRAY_SIZE(pcm037_gpio_keys), |
| 162 | .rep = 0, /* No auto-repeat */ |
| 163 | }; |
| 164 | |
| 165 | static struct platform_device pcm037_gpio_keys_device = { |
| 166 | .name = "gpio-keys", |
| 167 | .id = -1, |
| 168 | .dev = { |
| 169 | .platform_data = &pcm037_gpio_keys_platform_data, |
| 170 | }, |
| 171 | }; |
| 172 | |
| 173 | static int eet_init_devices(void) |
| 174 | { |
| 175 | if (!machine_is_pcm037() || pcm037_variant() != PCM037_EET) |
| 176 | return 0; |
| 177 | |
| 178 | mxc_iomux_setup_multiple_pins(pcm037_eet_pins, |
| 179 | ARRAY_SIZE(pcm037_eet_pins), "pcm037_eet"); |
| 180 | |
| 181 | /* SPI */ |
| 182 | spi_register_board_info(pcm037_spi_dev, ARRAY_SIZE(pcm037_spi_dev)); |
| 183 | #if defined(CONFIG_SPI_IMX) || defined(CONFIG_SPI_IMX_MODULE) |
Uwe Kleine-König | a4dc013 | 2010-06-22 10:14:15 +0200 | [diff] [blame] | 184 | imx35_add_spi_imx0(&pcm037_spi1_pdata); |
Guennadi Liakhovetski | 574ec54 | 2009-06-23 13:26:23 +0200 | [diff] [blame] | 185 | #endif |
| 186 | |
| 187 | platform_device_register(&pcm037_gpio_keys_device); |
| 188 | |
| 189 | return 0; |
| 190 | } |
| 191 | |
| 192 | late_initcall(eet_init_devices); |