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> |
Guennadi Liakhovetski | 574ec54 | 2009-06-23 13:26:23 +0200 | [diff] [blame] | 10 | #include <linux/input.h> |
| 11 | #include <linux/platform_device.h> |
| 12 | #include <linux/spi/spi.h> |
| 13 | |
Guennadi Liakhovetski | 574ec54 | 2009-06-23 13:26:23 +0200 | [diff] [blame] | 14 | #include <asm/mach-types.h> |
| 15 | |
| 16 | #include "pcm037.h" |
Shawn Guo | e337247 | 2012-09-13 21:01:00 +0800 | [diff] [blame] | 17 | #include "common.h" |
Eric Bénard | c0f832b | 2010-10-15 01:00:01 +0200 | [diff] [blame] | 18 | #include "devices-imx31.h" |
Shawn Guo | 267dd34 | 2012-09-13 13:26:00 +0800 | [diff] [blame] | 19 | #include "iomux-mx3.h" |
Guennadi Liakhovetski | 574ec54 | 2009-06-23 13:26:23 +0200 | [diff] [blame] | 20 | |
| 21 | static unsigned int pcm037_eet_pins[] = { |
Guennadi Liakhovetski | 574ec54 | 2009-06-23 13:26:23 +0200 | [diff] [blame] | 22 | /* Reserve and hardwire GPIO 57 high - S6E63D6 chipselect */ |
| 23 | IOMUX_MODE(MX31_PIN_KEY_COL7, IOMUX_CONFIG_GPIO), |
| 24 | /* GPIO keys */ |
| 25 | IOMUX_MODE(MX31_PIN_GPIO1_0, IOMUX_CONFIG_GPIO), /* 0 */ |
| 26 | IOMUX_MODE(MX31_PIN_GPIO1_1, IOMUX_CONFIG_GPIO), /* 1 */ |
| 27 | IOMUX_MODE(MX31_PIN_GPIO1_2, IOMUX_CONFIG_GPIO), /* 2 */ |
| 28 | IOMUX_MODE(MX31_PIN_GPIO1_3, IOMUX_CONFIG_GPIO), /* 3 */ |
| 29 | IOMUX_MODE(MX31_PIN_SVEN0, IOMUX_CONFIG_GPIO), /* 32 */ |
| 30 | IOMUX_MODE(MX31_PIN_STX0, IOMUX_CONFIG_GPIO), /* 33 */ |
| 31 | IOMUX_MODE(MX31_PIN_SRX0, IOMUX_CONFIG_GPIO), /* 34 */ |
| 32 | IOMUX_MODE(MX31_PIN_SIMPD0, IOMUX_CONFIG_GPIO), /* 35 */ |
| 33 | IOMUX_MODE(MX31_PIN_RTS1, IOMUX_CONFIG_GPIO), /* 38 */ |
| 34 | IOMUX_MODE(MX31_PIN_CTS1, IOMUX_CONFIG_GPIO), /* 39 */ |
| 35 | IOMUX_MODE(MX31_PIN_KEY_ROW4, IOMUX_CONFIG_GPIO), /* 50 */ |
| 36 | IOMUX_MODE(MX31_PIN_KEY_ROW5, IOMUX_CONFIG_GPIO), /* 51 */ |
| 37 | IOMUX_MODE(MX31_PIN_KEY_ROW6, IOMUX_CONFIG_GPIO), /* 52 */ |
| 38 | IOMUX_MODE(MX31_PIN_KEY_ROW7, IOMUX_CONFIG_GPIO), /* 53 */ |
| 39 | |
| 40 | /* LEDs */ |
| 41 | IOMUX_MODE(MX31_PIN_DTR_DTE1, IOMUX_CONFIG_GPIO), /* 44 */ |
| 42 | IOMUX_MODE(MX31_PIN_DSR_DTE1, IOMUX_CONFIG_GPIO), /* 45 */ |
| 43 | IOMUX_MODE(MX31_PIN_KEY_COL5, IOMUX_CONFIG_GPIO), /* 55 */ |
| 44 | IOMUX_MODE(MX31_PIN_KEY_COL6, IOMUX_CONFIG_GPIO), /* 56 */ |
| 45 | }; |
| 46 | |
| 47 | /* SPI */ |
| 48 | static struct spi_board_info pcm037_spi_dev[] = { |
| 49 | { |
| 50 | .modalias = "dac124s085", |
| 51 | .max_speed_hz = 400000, |
| 52 | .bus_num = 0, |
| 53 | .chip_select = 0, /* Index in pcm037_spi1_cs[] */ |
| 54 | .mode = SPI_CPHA, |
| 55 | }, |
| 56 | }; |
| 57 | |
| 58 | /* Platform Data for MXC CSPI */ |
Guennadi Liakhovetski | 574ec54 | 2009-06-23 13:26:23 +0200 | [diff] [blame] | 59 | static int pcm037_spi1_cs[] = {MXC_SPI_CS(1), IOMUX_TO_GPIO(MX31_PIN_KEY_COL7)}; |
| 60 | |
Uwe Kleine-König | a4dc013 | 2010-06-22 10:14:15 +0200 | [diff] [blame] | 61 | static const struct spi_imx_master pcm037_spi1_pdata __initconst = { |
Guennadi Liakhovetski | 574ec54 | 2009-06-23 13:26:23 +0200 | [diff] [blame] | 62 | .chipselect = pcm037_spi1_cs, |
| 63 | .num_chipselect = ARRAY_SIZE(pcm037_spi1_cs), |
| 64 | }; |
Guennadi Liakhovetski | 574ec54 | 2009-06-23 13:26:23 +0200 | [diff] [blame] | 65 | |
| 66 | /* GPIO-keys input device */ |
| 67 | static struct gpio_keys_button pcm037_gpio_keys[] = { |
| 68 | { |
| 69 | .type = EV_KEY, |
| 70 | .code = KEY_L, |
| 71 | .gpio = 0, |
| 72 | .desc = "Wheel Manual", |
| 73 | .wakeup = 0, |
| 74 | }, { |
| 75 | .type = EV_KEY, |
| 76 | .code = KEY_A, |
| 77 | .gpio = 1, |
| 78 | .desc = "Wheel AF", |
| 79 | .wakeup = 0, |
| 80 | }, { |
| 81 | .type = EV_KEY, |
| 82 | .code = KEY_V, |
| 83 | .gpio = 2, |
| 84 | .desc = "Wheel View", |
| 85 | .wakeup = 0, |
| 86 | }, { |
| 87 | .type = EV_KEY, |
| 88 | .code = KEY_M, |
| 89 | .gpio = 3, |
| 90 | .desc = "Wheel Menu", |
| 91 | .wakeup = 0, |
| 92 | }, { |
| 93 | .type = EV_KEY, |
| 94 | .code = KEY_UP, |
| 95 | .gpio = 32, |
| 96 | .desc = "Nav Pad Up", |
| 97 | .wakeup = 0, |
| 98 | }, { |
| 99 | .type = EV_KEY, |
| 100 | .code = KEY_RIGHT, |
| 101 | .gpio = 33, |
| 102 | .desc = "Nav Pad Right", |
| 103 | .wakeup = 0, |
| 104 | }, { |
| 105 | .type = EV_KEY, |
| 106 | .code = KEY_DOWN, |
| 107 | .gpio = 34, |
| 108 | .desc = "Nav Pad Down", |
| 109 | .wakeup = 0, |
| 110 | }, { |
| 111 | .type = EV_KEY, |
| 112 | .code = KEY_LEFT, |
| 113 | .gpio = 35, |
| 114 | .desc = "Nav Pad Left", |
| 115 | .wakeup = 0, |
| 116 | }, { |
| 117 | .type = EV_KEY, |
| 118 | .code = KEY_ENTER, |
| 119 | .gpio = 38, |
| 120 | .desc = "Nav Pad Ok", |
| 121 | .wakeup = 0, |
| 122 | }, { |
| 123 | .type = EV_KEY, |
| 124 | .code = KEY_O, |
| 125 | .gpio = 39, |
| 126 | .desc = "Wheel Off", |
| 127 | .wakeup = 0, |
| 128 | }, { |
| 129 | .type = EV_KEY, |
| 130 | .code = BTN_FORWARD, |
| 131 | .gpio = 50, |
| 132 | .desc = "Focus Forward", |
| 133 | .wakeup = 0, |
| 134 | }, { |
| 135 | .type = EV_KEY, |
| 136 | .code = BTN_BACK, |
| 137 | .gpio = 51, |
| 138 | .desc = "Focus Backward", |
| 139 | .wakeup = 0, |
| 140 | }, { |
| 141 | .type = EV_KEY, |
| 142 | .code = BTN_MIDDLE, |
| 143 | .gpio = 52, |
| 144 | .desc = "Release Half", |
| 145 | .wakeup = 0, |
| 146 | }, { |
| 147 | .type = EV_KEY, |
| 148 | .code = BTN_EXTRA, |
| 149 | .gpio = 53, |
| 150 | .desc = "Release Full", |
| 151 | .wakeup = 0, |
| 152 | }, |
| 153 | }; |
| 154 | |
Uwe Kleine-König | 5309498 | 2011-02-28 18:04:33 +0100 | [diff] [blame] | 155 | static const struct gpio_keys_platform_data |
| 156 | pcm037_gpio_keys_platform_data __initconst = { |
Guennadi Liakhovetski | 574ec54 | 2009-06-23 13:26:23 +0200 | [diff] [blame] | 157 | .buttons = pcm037_gpio_keys, |
| 158 | .nbuttons = ARRAY_SIZE(pcm037_gpio_keys), |
| 159 | .rep = 0, /* No auto-repeat */ |
| 160 | }; |
| 161 | |
Shawn Guo | 8321b75 | 2012-04-26 11:42:34 +0800 | [diff] [blame] | 162 | int __init pcm037_eet_init_devices(void) |
Guennadi Liakhovetski | 574ec54 | 2009-06-23 13:26:23 +0200 | [diff] [blame] | 163 | { |
Shawn Guo | 8321b75 | 2012-04-26 11:42:34 +0800 | [diff] [blame] | 164 | if (pcm037_variant() != PCM037_EET) |
Guennadi Liakhovetski | 574ec54 | 2009-06-23 13:26:23 +0200 | [diff] [blame] | 165 | return 0; |
| 166 | |
| 167 | mxc_iomux_setup_multiple_pins(pcm037_eet_pins, |
| 168 | ARRAY_SIZE(pcm037_eet_pins), "pcm037_eet"); |
| 169 | |
| 170 | /* SPI */ |
| 171 | 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] | 172 | imx31_add_spi_imx0(&pcm037_spi1_pdata); |
Guennadi Liakhovetski | 574ec54 | 2009-06-23 13:26:23 +0200 | [diff] [blame] | 173 | |
Uwe Kleine-König | 5309498 | 2011-02-28 18:04:33 +0100 | [diff] [blame] | 174 | imx_add_gpio_keys(&pcm037_gpio_keys_platform_data); |
Guennadi Liakhovetski | 574ec54 | 2009-06-23 13:26:23 +0200 | [diff] [blame] | 175 | |
| 176 | return 0; |
| 177 | } |