| 1 | #include <linux/platform_device.h> |
| 2 | #include <linux/mtd/mtd.h> |
| 3 | #include <linux/mtd/physmap.h> |
| 4 | #include <linux/gpio.h> |
| 5 | #include <linux/leds.h> |
| 6 | |
| 7 | #include <mach/common.h> |
| 8 | #include <mach/hardware.h> |
| 9 | #include <asm/mach-types.h> |
| 10 | #include <asm/mach/arch.h> |
| 11 | #include <asm/mach/time.h> |
| 12 | #include <asm/mach/map.h> |
| 13 | #include <mach/imx-uart.h> |
| 14 | #include <mach/imxfb.h> |
| 15 | #include <mach/iomux-mx21.h> |
| 16 | #include <mach/board-vp6500.h> |
| 17 | |
| 18 | #include "devices.h" |
| 19 | |
| 20 | #include <linux/input.h> |
| 21 | #include <linux/input/matrix_keypad.h> |
| 22 | #include <linux/gpio_keys.h> |
| 23 | #include <linux/pwm_backlight.h> |
| 24 | |
| 25 | static unsigned int vp6500_pins[] = { |
| 26 | /* UART1 */ |
| 27 | PE12_PF_UART1_TXD, |
| 28 | PE13_PF_UART1_RXD, |
| 29 | |
| 30 | #if 0 |
| 31 | /* LCDC */ |
| 32 | PA5_PF_LSCLK, |
| 33 | PA6_PF_LD0, |
| 34 | PA7_PF_LD1, |
| 35 | PA8_PF_LD2, |
| 36 | PA9_PF_LD3, |
| 37 | PA10_PF_LD4, |
| 38 | PA11_PF_LD5, |
| 39 | PA12_PF_LD6, |
| 40 | PA13_PF_LD7, |
| 41 | PA14_PF_LD8, |
| 42 | PA15_PF_LD9, |
| 43 | PA16_PF_LD10, |
| 44 | PA17_PF_LD11, |
| 45 | PA18_PF_LD12, |
| 46 | PA19_PF_LD13, |
| 47 | PA20_PF_LD14, |
| 48 | PA21_PF_LD15, |
| 49 | PA22_PF_LD16, |
| 50 | PA28_PF_HSYNC, |
| 51 | PA29_PF_VSYNC, |
| 52 | PA30_PF_CONTRAST, |
| 53 | PA31_PF_OE_ACD, |
| 54 | #endif |
| 55 | |
| 56 | /* LCD Backlight */ |
| 57 | PE5_PF_PWMO, |
| 58 | VP6500_GPIO_BACKLIGHT_EN | GPIO_GPIO | GPIO_OUT, |
| 59 | }; |
| 60 | |
| 61 | /* Flash */ |
| 62 | |
| 63 | static struct physmap_flash_data vp6500_flash_data = { |
| 64 | .width = 2, |
| 65 | }; |
| 66 | |
| 67 | static struct resource vp6500_flash_resource = { |
| 68 | .start = MX21_CS0_BASE_ADDR, |
| 69 | .end = MX21_CS0_BASE_ADDR + SZ_64M - 1, |
| 70 | .flags = IORESOURCE_MEM, |
| 71 | }; |
| 72 | |
| 73 | static struct platform_device vp6500_nor_mtd_device = { |
| 74 | .name = "physmap-flash", |
| 75 | .id = -1, |
| 76 | .dev = { |
| 77 | .platform_data = &vp6500_flash_data, |
| 78 | }, |
| 79 | .num_resources = 1, |
| 80 | .resource = &vp6500_flash_resource, |
| 81 | }; |
| 82 | |
| 83 | /* LEDs */ |
| 84 | |
| 85 | static struct gpio_led vp6500_leds[] = { |
| 86 | { |
| 87 | .name = "vp6500:orange:keypad", |
| 88 | .gpio = VP6500_GPIO_LED_KEYPAD, |
| 89 | }, |
| 90 | { |
| 91 | .name = "vp6500:green:", |
| 92 | .gpio = VP6500_GPIO_LED_GREEN, |
| 93 | .active_low = 1, |
| 94 | .default_state = LEDS_GPIO_DEFSTATE_ON, |
| 95 | }, |
| 96 | { |
| 97 | .name = "vp6500:red:", |
| 98 | .gpio = VP6500_GPIO_LED_RED, |
| 99 | }, |
| 100 | { |
| 101 | .name = "vp6500:red:camera", |
| 102 | .gpio = VP6500_GPIO_LED_CAMERA, |
| 103 | }, |
| 104 | }; |
| 105 | |
| 106 | static struct gpio_led_platform_data vp6500_leds_data = { |
| 107 | .leds = vp6500_leds, |
| 108 | .num_leds = ARRAY_SIZE(vp6500_leds), |
| 109 | }; |
| 110 | |
| 111 | static struct platform_device vp6500_leds_device = { |
| 112 | .name = "leds-gpio", |
| 113 | .id = -1, |
| 114 | .dev = { |
| 115 | .platform_data = &vp6500_leds_data, |
| 116 | }, |
| 117 | }; |
| 118 | |
| 119 | /* Keypad */ |
| 120 | |
| 121 | static const uint32_t vp6500_keypad_keys[] = { |
| 122 | KEY(0, 3, KEY_F2), |
| 123 | KEY(0, 4, KEY_RIGHT), |
| 124 | KEY(1, 0, KEY_ZOOM), |
| 125 | KEY(1, 1, KEY_NUMERIC_POUND), |
| 126 | KEY(1, 2, KEY_0), |
| 127 | KEY(1, 3, KEY_ENTER), |
| 128 | KEY(1, 4, KEY_8), |
| 129 | KEY(2, 0, KEY_5), |
| 130 | KEY(2, 1, KEY_2), |
| 131 | KEY(2, 2, KEY_DOWN), |
| 132 | KEY(2, 3, KEY_OK), |
| 133 | KEY(2, 4, KEY_UP), |
| 134 | KEY(3, 0, KEY_CAMERA), |
| 135 | KEY(3, 1, KEY_NUMERIC_STAR), |
| 136 | KEY(3, 2, KEY_9), |
| 137 | KEY(3, 3, KEY_LEFT), |
| 138 | KEY(3, 4, KEY_6), |
| 139 | KEY(4, 0, KEY_7), |
| 140 | KEY(4, 1, KEY_4), |
| 141 | KEY(4, 2, KEY_1), |
| 142 | KEY(4, 3, KEY_3), |
| 143 | KEY(4, 4, KEY_F1), |
| 144 | }; |
| 145 | |
| 146 | static struct matrix_keymap_data vp6500_keypad_data = { |
| 147 | .keymap = vp6500_keypad_keys, |
| 148 | .keymap_size = ARRAY_SIZE(vp6500_keypad_keys), |
| 149 | }; |
| 150 | |
| 151 | static struct resource vp6500_keypad_resources[] = { |
| 152 | { |
| 153 | .start = MX21_KPP_BASE_ADDR, |
| 154 | .end = MX21_KPP_BASE_ADDR + 0x10 - 1, |
| 155 | .flags = IORESOURCE_MEM, |
| 156 | }, |
| 157 | { |
| 158 | .start = MX21_INT_KPP, |
| 159 | .flags = IORESOURCE_IRQ, |
| 160 | } |
| 161 | }; |
| 162 | |
| 163 | static struct platform_device vp6500_keypad_device = { |
| 164 | .name = "imx-keypad", |
| 165 | .id = 0, |
| 166 | .dev = { |
| 167 | .platform_data = &vp6500_keypad_data, |
| 168 | }, |
| 169 | .resource = vp6500_keypad_resources, |
| 170 | .num_resources = ARRAY_SIZE(vp6500_keypad_resources), |
| 171 | }; |
| 172 | |
| 173 | static struct gpio_keys_button vp6500_keys = { |
| 174 | .gpio = VP6500_GPIO_POWER_KEY, |
| 175 | .code = KEY_POWER, |
| 176 | .desc = "Power button", |
| 177 | .active_low = 1, |
| 178 | }; |
| 179 | |
| 180 | static struct gpio_keys_platform_data vp6500_key_data = { |
| 181 | .buttons = &vp6500_keys, |
| 182 | .nbuttons = 1, |
| 183 | }; |
| 184 | |
| 185 | static struct platform_device vp6500_key_device = { |
| 186 | .name = "gpio-keys", |
| 187 | .id = -1, |
| 188 | .dev = { |
| 189 | .platform_data = &vp6500_key_data, |
| 190 | }, |
| 191 | }; |
| 192 | |
| 193 | /* LCD backlight */ |
| 194 | |
| 195 | static int vp6500_backlight_notify(struct device *dev, int brightness) |
| 196 | { |
| 197 | gpio_set_value(VP6500_GPIO_BACKLIGHT_EN, !!brightness); |
| 198 | |
| 199 | return brightness; |
| 200 | } |
| 201 | |
| 202 | static struct platform_pwm_backlight_data vp6500_backlight_data = { |
| 203 | .max_brightness = 255, |
| 204 | .dft_brightness = 100, |
| 205 | .pwm_period_ns = 15000000, |
| 206 | .notify = vp6500_backlight_notify, |
| 207 | }; |
| 208 | |
| 209 | static struct platform_device vp6500_backlight_device = { |
| 210 | .name = "pwm-backlight", |
| 211 | .id = -1, |
| 212 | .dev = { |
| 213 | .parent = &mxc_pwm_device.dev, |
| 214 | .platform_data = &vp6500_backlight_data, |
| 215 | }, |
| 216 | }; |
| 217 | |
| 218 | |
| 219 | static struct platform_device *platform_devices[] __initdata = { |
| 220 | &vp6500_nor_mtd_device, |
| 221 | &vp6500_leds_device, |
| 222 | &vp6500_keypad_device, |
| 223 | &vp6500_key_device, |
| 224 | &vp6500_backlight_device, |
| 225 | }; |
| 226 | |
| 227 | static void __init vp6500_board_init(void) |
| 228 | { |
| 229 | mxc_gpio_setup_multiple_pins(vp6500_pins, ARRAY_SIZE(vp6500_pins), |
| 230 | "vp6500"); |
| 231 | |
| 232 | mxc_register_device(&mxc_uart_device0, NULL); |
| 233 | mxc_register_device(&mxc_pwm_device, NULL); |
| 234 | |
| 235 | platform_add_devices(platform_devices, ARRAY_SIZE(platform_devices)); |
| 236 | } |
| 237 | |
| 238 | static void __init vp6500_timer_init(void) |
| 239 | { |
| 240 | mx21_clocks_init(32768, 26000000); |
| 241 | } |
| 242 | |
| 243 | static struct sys_timer vp6500_timer = { |
| 244 | .init = vp6500_timer_init, |
| 245 | }; |
| 246 | |
| 247 | MACHINE_START(VP6500, "Phillips VP6500") |
| 248 | .phys_io = MX21_AIPI_BASE_ADDR, |
| 249 | .io_pg_offst = ((MX21_AIPI_BASE_ADDR_VIRT) >> 18) & 0xfffc, |
| 250 | .boot_params = MX21_PHYS_OFFSET + 0x100, |
| 251 | .map_io = mx21_map_io, |
| 252 | .init_irq = mx21_init_irq, |
| 253 | .init_machine = vp6500_board_init, |
| 254 | .timer = &vp6500_timer, |
| 255 | MACHINE_END |
| 256 | |