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> |
Sascha Hauer | 8cad8fa | 2010-08-09 09:45:09 +0200 | [diff] [blame] | 17 | #include <mach/spi.h> |
Guennadi Liakhovetski | 574ec54 | 2009-06-23 13:26:23 +0200 | [diff] [blame] | 18 | |
| 19 | #include <asm/mach-types.h> |
| 20 | |
| 21 | #include "pcm037.h" |
| 22 | #include "devices.h" |
Eric Bénard | c0f832b | 2010-10-15 01:00:01 +0200 | [diff] [blame] | 23 | #include "devices-imx31.h" |
Guennadi Liakhovetski | 574ec54 | 2009-06-23 13:26:23 +0200 | [diff] [blame] | 24 | |
| 25 | static unsigned int pcm037_eet_pins[] = { |
Guennadi Liakhovetski | 574ec54 | 2009-06-23 13:26:23 +0200 | [diff] [blame] | 26 | /* Reserve and hardwire GPIO 57 high - S6E63D6 chipselect */ |
| 27 | IOMUX_MODE(MX31_PIN_KEY_COL7, IOMUX_CONFIG_GPIO), |
| 28 | /* GPIO keys */ |
| 29 | IOMUX_MODE(MX31_PIN_GPIO1_0, IOMUX_CONFIG_GPIO), /* 0 */ |
| 30 | IOMUX_MODE(MX31_PIN_GPIO1_1, IOMUX_CONFIG_GPIO), /* 1 */ |
| 31 | IOMUX_MODE(MX31_PIN_GPIO1_2, IOMUX_CONFIG_GPIO), /* 2 */ |
| 32 | IOMUX_MODE(MX31_PIN_GPIO1_3, IOMUX_CONFIG_GPIO), /* 3 */ |
| 33 | IOMUX_MODE(MX31_PIN_SVEN0, IOMUX_CONFIG_GPIO), /* 32 */ |
| 34 | IOMUX_MODE(MX31_PIN_STX0, IOMUX_CONFIG_GPIO), /* 33 */ |
| 35 | IOMUX_MODE(MX31_PIN_SRX0, IOMUX_CONFIG_GPIO), /* 34 */ |
| 36 | IOMUX_MODE(MX31_PIN_SIMPD0, IOMUX_CONFIG_GPIO), /* 35 */ |
| 37 | IOMUX_MODE(MX31_PIN_RTS1, IOMUX_CONFIG_GPIO), /* 38 */ |
| 38 | IOMUX_MODE(MX31_PIN_CTS1, IOMUX_CONFIG_GPIO), /* 39 */ |
| 39 | IOMUX_MODE(MX31_PIN_KEY_ROW4, IOMUX_CONFIG_GPIO), /* 50 */ |
| 40 | IOMUX_MODE(MX31_PIN_KEY_ROW5, IOMUX_CONFIG_GPIO), /* 51 */ |
| 41 | IOMUX_MODE(MX31_PIN_KEY_ROW6, IOMUX_CONFIG_GPIO), /* 52 */ |
| 42 | IOMUX_MODE(MX31_PIN_KEY_ROW7, IOMUX_CONFIG_GPIO), /* 53 */ |
| 43 | |
| 44 | /* LEDs */ |
| 45 | IOMUX_MODE(MX31_PIN_DTR_DTE1, IOMUX_CONFIG_GPIO), /* 44 */ |
| 46 | IOMUX_MODE(MX31_PIN_DSR_DTE1, IOMUX_CONFIG_GPIO), /* 45 */ |
| 47 | IOMUX_MODE(MX31_PIN_KEY_COL5, IOMUX_CONFIG_GPIO), /* 55 */ |
| 48 | IOMUX_MODE(MX31_PIN_KEY_COL6, IOMUX_CONFIG_GPIO), /* 56 */ |
| 49 | }; |
| 50 | |
| 51 | /* SPI */ |
| 52 | static struct spi_board_info pcm037_spi_dev[] = { |
| 53 | { |
| 54 | .modalias = "dac124s085", |
| 55 | .max_speed_hz = 400000, |
| 56 | .bus_num = 0, |
| 57 | .chip_select = 0, /* Index in pcm037_spi1_cs[] */ |
| 58 | .mode = SPI_CPHA, |
| 59 | }, |
| 60 | }; |
| 61 | |
| 62 | /* Platform Data for MXC CSPI */ |
Guennadi Liakhovetski | 574ec54 | 2009-06-23 13:26:23 +0200 | [diff] [blame] | 63 | static int pcm037_spi1_cs[] = {MXC_SPI_CS(1), IOMUX_TO_GPIO(MX31_PIN_KEY_COL7)}; |
| 64 | |
Uwe Kleine-König | a4dc013 | 2010-06-22 10:14:15 +0200 | [diff] [blame] | 65 | static const struct spi_imx_master pcm037_spi1_pdata __initconst = { |
Guennadi Liakhovetski | 574ec54 | 2009-06-23 13:26:23 +0200 | [diff] [blame] | 66 | .chipselect = pcm037_spi1_cs, |
| 67 | .num_chipselect = ARRAY_SIZE(pcm037_spi1_cs), |
| 68 | }; |
Guennadi Liakhovetski | 574ec54 | 2009-06-23 13:26:23 +0200 | [diff] [blame] | 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 | |
Alberto Panizzo | f0573e6 | 2010-11-01 18:00:03 +0100 | [diff] [blame] | 173 | static int __init eet_init_devices(void) |
Guennadi Liakhovetski | 574ec54 | 2009-06-23 13:26:23 +0200 | [diff] [blame] | 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)); |
Eric Bénard | c0f832b | 2010-10-15 01:00:01 +0200 | [diff] [blame] | 183 | imx31_add_spi_imx0(&pcm037_spi1_pdata); |
Guennadi Liakhovetski | 574ec54 | 2009-06-23 13:26:23 +0200 | [diff] [blame] | 184 | |
| 185 | platform_device_register(&pcm037_gpio_keys_device); |
| 186 | |
| 187 | return 0; |
| 188 | } |
| 189 | |
| 190 | late_initcall(eet_init_devices); |