Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Support for Sharp SL-Cxx00 Series of PDAs |
| 3 | * Models: SL-C3000 (Spitz), SL-C1000 (Akita) and SL-C3100 (Borzoi) |
| 4 | * |
| 5 | * Copyright (c) 2005 Richard Purdie |
| 6 | * |
| 7 | * Based on Sharp's 2.4 kernel patches/lubbock.c |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
| 12 | * |
| 13 | */ |
| 14 | |
| 15 | #include <linux/kernel.h> |
| 16 | #include <linux/init.h> |
Russell King | d052d1b | 2005-10-29 19:07:23 +0100 | [diff] [blame] | 17 | #include <linux/platform_device.h> |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 18 | #include <linux/delay.h> |
| 19 | #include <linux/major.h> |
| 20 | #include <linux/fs.h> |
| 21 | #include <linux/interrupt.h> |
Eric Miao | dd5980d | 2008-09-02 17:34:33 +0800 | [diff] [blame] | 22 | #include <linux/gpio.h> |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 23 | #include <linux/mmc/host.h> |
Richard Purdie | 74617fb | 2006-06-19 19:57:12 +0100 | [diff] [blame] | 24 | #include <linux/pm.h> |
Richard Purdie | c3f8f65 | 2007-09-03 00:27:00 +0100 | [diff] [blame] | 25 | #include <linux/backlight.h> |
Eric Miao | 859b796 | 2008-09-03 12:09:24 +0800 | [diff] [blame] | 26 | #include <linux/spi/spi.h> |
| 27 | #include <linux/spi/ads7846.h> |
| 28 | #include <linux/spi/corgi_lcd.h> |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 29 | |
| 30 | #include <asm/setup.h> |
| 31 | #include <asm/memory.h> |
| 32 | #include <asm/mach-types.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 33 | #include <mach/hardware.h> |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 34 | #include <asm/irq.h> |
| 35 | #include <asm/io.h> |
Richard Purdie | 74617fb | 2006-06-19 19:57:12 +0100 | [diff] [blame] | 36 | #include <asm/system.h> |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 37 | |
| 38 | #include <asm/mach/arch.h> |
| 39 | #include <asm/mach/map.h> |
| 40 | #include <asm/mach/irq.h> |
| 41 | |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 42 | #include <mach/pxa-regs.h> |
| 43 | #include <mach/pxa2xx-regs.h> |
Eric Miao | 5e96ade | 2008-09-03 09:47:42 +0800 | [diff] [blame] | 44 | #include <mach/mfp-pxa27x.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 45 | #include <mach/pxa27x-udc.h> |
Russell King | afd2fc0 | 2008-08-07 11:05:25 +0100 | [diff] [blame] | 46 | #include <mach/reset.h> |
Mark Brown | f8787fd | 2008-08-26 13:30:03 +0100 | [diff] [blame] | 47 | #include <mach/i2c.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 48 | #include <mach/irda.h> |
| 49 | #include <mach/mmc.h> |
| 50 | #include <mach/ohci.h> |
| 51 | #include <mach/udc.h> |
| 52 | #include <mach/pxafb.h> |
Eric Miao | 859b796 | 2008-09-03 12:09:24 +0800 | [diff] [blame] | 53 | #include <mach/pxa2xx_spi.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 54 | #include <mach/akita.h> |
| 55 | #include <mach/spitz.h> |
| 56 | #include <mach/sharpsl.h> |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 57 | |
| 58 | #include <asm/mach/sharpsl_param.h> |
| 59 | #include <asm/hardware/scoop.h> |
| 60 | |
| 61 | #include "generic.h" |
Russell King | 46c41e6 | 2007-05-15 15:39:36 +0100 | [diff] [blame] | 62 | #include "devices.h" |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 63 | #include "sharpsl.h" |
| 64 | |
Eric Miao | 5e96ade | 2008-09-03 09:47:42 +0800 | [diff] [blame] | 65 | static unsigned long spitz_pin_config[] __initdata = { |
| 66 | /* Chip Selects */ |
| 67 | GPIO78_nCS_2, /* SCOOP #2 */ |
| 68 | GPIO80_nCS_4, /* SCOOP #1 */ |
| 69 | |
| 70 | /* LCD - 16bpp Active TFT */ |
| 71 | GPIO58_LCD_LDD_0, |
| 72 | GPIO59_LCD_LDD_1, |
| 73 | GPIO60_LCD_LDD_2, |
| 74 | GPIO61_LCD_LDD_3, |
| 75 | GPIO62_LCD_LDD_4, |
| 76 | GPIO63_LCD_LDD_5, |
| 77 | GPIO64_LCD_LDD_6, |
| 78 | GPIO65_LCD_LDD_7, |
| 79 | GPIO66_LCD_LDD_8, |
| 80 | GPIO67_LCD_LDD_9, |
| 81 | GPIO68_LCD_LDD_10, |
| 82 | GPIO69_LCD_LDD_11, |
| 83 | GPIO70_LCD_LDD_12, |
| 84 | GPIO71_LCD_LDD_13, |
| 85 | GPIO72_LCD_LDD_14, |
| 86 | GPIO73_LCD_LDD_15, |
| 87 | GPIO74_LCD_FCLK, |
| 88 | GPIO75_LCD_LCLK, |
| 89 | GPIO76_LCD_PCLK, |
| 90 | |
| 91 | /* PC Card */ |
| 92 | GPIO48_nPOE, |
| 93 | GPIO49_nPWE, |
| 94 | GPIO50_nPIOR, |
| 95 | GPIO51_nPIOW, |
| 96 | GPIO85_nPCE_1, |
| 97 | GPIO54_nPCE_2, |
| 98 | GPIO79_PSKTSEL, |
| 99 | GPIO55_nPREG, |
| 100 | GPIO56_nPWAIT, |
| 101 | GPIO57_nIOIS16, |
| 102 | |
| 103 | /* MMC */ |
| 104 | GPIO32_MMC_CLK, |
| 105 | GPIO112_MMC_CMD, |
| 106 | GPIO92_MMC_DAT_0, |
| 107 | GPIO109_MMC_DAT_1, |
| 108 | GPIO110_MMC_DAT_2, |
| 109 | GPIO111_MMC_DAT_3, |
| 110 | |
| 111 | /* GPIOs */ |
| 112 | GPIO9_GPIO, /* SPITZ_GPIO_nSD_DETECT */ |
| 113 | GPIO81_GPIO, /* SPITZ_GPIO_nSD_WP */ |
| 114 | GPIO41_GPIO, /* SPITZ_GPIO_USB_CONNECT */ |
| 115 | GPIO37_GPIO, /* SPITZ_GPIO_USB_HOST */ |
| 116 | GPIO35_GPIO, /* SPITZ_GPIO_USB_DEVICE */ |
| 117 | GPIO22_GPIO, /* SPITZ_GPIO_HSYNC */ |
| 118 | GPIO94_GPIO, /* SPITZ_GPIO_CF_CD */ |
| 119 | GPIO105_GPIO, /* SPITZ_GPIO_CF_IRQ */ |
| 120 | GPIO106_GPIO, /* SPITZ_GPIO_CF2_IRQ */ |
| 121 | |
| 122 | GPIO1_GPIO | WAKEUP_ON_EDGE_RISE, |
| 123 | }; |
| 124 | |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 125 | /* |
| 126 | * Spitz SCOOP Device #1 |
| 127 | */ |
| 128 | static struct resource spitz_scoop_resources[] = { |
| 129 | [0] = { |
| 130 | .start = 0x10800000, |
| 131 | .end = 0x10800fff, |
| 132 | .flags = IORESOURCE_MEM, |
| 133 | }, |
| 134 | }; |
| 135 | |
| 136 | static struct scoop_config spitz_scoop_setup = { |
| 137 | .io_dir = SPITZ_SCP_IO_DIR, |
| 138 | .io_out = SPITZ_SCP_IO_OUT, |
| 139 | .suspend_clr = SPITZ_SCP_SUS_CLR, |
| 140 | .suspend_set = SPITZ_SCP_SUS_SET, |
| 141 | }; |
| 142 | |
| 143 | struct platform_device spitzscoop_device = { |
| 144 | .name = "sharp-scoop", |
| 145 | .id = 0, |
| 146 | .dev = { |
| 147 | .platform_data = &spitz_scoop_setup, |
| 148 | }, |
| 149 | .num_resources = ARRAY_SIZE(spitz_scoop_resources), |
| 150 | .resource = spitz_scoop_resources, |
| 151 | }; |
| 152 | |
| 153 | /* |
| 154 | * Spitz SCOOP Device #2 |
| 155 | */ |
| 156 | static struct resource spitz_scoop2_resources[] = { |
| 157 | [0] = { |
| 158 | .start = 0x08800040, |
| 159 | .end = 0x08800fff, |
| 160 | .flags = IORESOURCE_MEM, |
| 161 | }, |
| 162 | }; |
| 163 | |
| 164 | static struct scoop_config spitz_scoop2_setup = { |
| 165 | .io_dir = SPITZ_SCP2_IO_DIR, |
| 166 | .io_out = SPITZ_SCP2_IO_OUT, |
| 167 | .suspend_clr = SPITZ_SCP2_SUS_CLR, |
| 168 | .suspend_set = SPITZ_SCP2_SUS_SET, |
| 169 | }; |
| 170 | |
| 171 | struct platform_device spitzscoop2_device = { |
| 172 | .name = "sharp-scoop", |
| 173 | .id = 1, |
| 174 | .dev = { |
| 175 | .platform_data = &spitz_scoop2_setup, |
| 176 | }, |
| 177 | .num_resources = ARRAY_SIZE(spitz_scoop2_resources), |
| 178 | .resource = spitz_scoop2_resources, |
| 179 | }; |
| 180 | |
Richard Purdie | a63ae44 | 2005-11-08 19:15:43 +0000 | [diff] [blame] | 181 | #define SPITZ_PWR_SD 0x01 |
| 182 | #define SPITZ_PWR_CF 0x02 |
| 183 | |
| 184 | /* Power control is shared with between one of the CF slots and SD */ |
| 185 | static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr) |
| 186 | { |
| 187 | unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR); |
| 188 | |
| 189 | if (new_cpr & 0x0007) { |
| 190 | set_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER); |
| 191 | if (!(cpr & 0x0002) && !(cpr & 0x0004)) |
| 192 | mdelay(5); |
| 193 | if (device == SPITZ_PWR_CF) |
| 194 | cpr |= 0x0002; |
| 195 | if (device == SPITZ_PWR_SD) |
| 196 | cpr |= 0x0004; |
| 197 | write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr); |
| 198 | } else { |
| 199 | if (device == SPITZ_PWR_CF) |
| 200 | cpr &= ~0x0002; |
| 201 | if (device == SPITZ_PWR_SD) |
| 202 | cpr &= ~0x0004; |
Richard Purdie | a63ae44 | 2005-11-08 19:15:43 +0000 | [diff] [blame] | 203 | if (!(cpr & 0x0002) && !(cpr & 0x0004)) { |
Richard Purdie | 945b957 | 2006-01-05 20:44:57 +0000 | [diff] [blame] | 204 | write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, 0x0000); |
Richard Purdie | a63ae44 | 2005-11-08 19:15:43 +0000 | [diff] [blame] | 205 | mdelay(1); |
| 206 | reset_scoop_gpio(&spitzscoop_device.dev, SPITZ_SCP_CF_POWER); |
Richard Purdie | 945b957 | 2006-01-05 20:44:57 +0000 | [diff] [blame] | 207 | } else { |
| 208 | write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr); |
Richard Purdie | a63ae44 | 2005-11-08 19:15:43 +0000 | [diff] [blame] | 209 | } |
| 210 | } |
| 211 | } |
| 212 | |
Richard Purdie | a63ae44 | 2005-11-08 19:15:43 +0000 | [diff] [blame] | 213 | static void spitz_pcmcia_pwr(struct device *scoop, unsigned short cpr, int nr) |
| 214 | { |
| 215 | /* Only need to override behaviour for slot 0 */ |
| 216 | if (nr == 0) |
| 217 | spitz_card_pwr_ctrl(SPITZ_PWR_CF, cpr); |
| 218 | else |
| 219 | write_scoop_reg(scoop, SCOOP_CPR, cpr); |
| 220 | } |
| 221 | |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 222 | static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = { |
| 223 | { |
| 224 | .dev = &spitzscoop_device.dev, |
| 225 | .irq = SPITZ_IRQ_GPIO_CF_IRQ, |
| 226 | .cd_irq = SPITZ_IRQ_GPIO_CF_CD, |
| 227 | .cd_irq_str = "PCMCIA0 CD", |
| 228 | },{ |
| 229 | .dev = &spitzscoop2_device.dev, |
| 230 | .irq = SPITZ_IRQ_GPIO_CF2_IRQ, |
| 231 | .cd_irq = -1, |
| 232 | }, |
| 233 | }; |
| 234 | |
Richard Purdie | a63ae44 | 2005-11-08 19:15:43 +0000 | [diff] [blame] | 235 | static struct scoop_pcmcia_config spitz_pcmcia_config = { |
| 236 | .devs = &spitz_pcmcia_scoop[0], |
| 237 | .num_devs = 2, |
Richard Purdie | a63ae44 | 2005-11-08 19:15:43 +0000 | [diff] [blame] | 238 | .power_ctrl = spitz_pcmcia_pwr, |
| 239 | }; |
| 240 | |
| 241 | EXPORT_SYMBOL(spitzscoop_device); |
| 242 | EXPORT_SYMBOL(spitzscoop2_device); |
| 243 | |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 244 | /* |
| 245 | * Spitz Keyboard Device |
| 246 | */ |
| 247 | static struct platform_device spitzkbd_device = { |
| 248 | .name = "spitz-keyboard", |
| 249 | .id = -1, |
| 250 | }; |
| 251 | |
| 252 | |
| 253 | /* |
Richard Purdie | 3179108 | 2006-03-31 02:31:09 -0800 | [diff] [blame] | 254 | * Spitz LEDs |
| 255 | */ |
| 256 | static struct platform_device spitzled_device = { |
| 257 | .name = "spitz-led", |
| 258 | .id = -1, |
| 259 | }; |
| 260 | |
Eric Miao | 859b796 | 2008-09-03 12:09:24 +0800 | [diff] [blame] | 261 | #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE) |
| 262 | static struct pxa2xx_spi_master spitz_spi_info = { |
| 263 | .num_chipselect = 3, |
| 264 | }; |
Richard Purdie | ca4d6cf | 2008-01-02 01:09:54 +0100 | [diff] [blame] | 265 | |
Eric Miao | 859b796 | 2008-09-03 12:09:24 +0800 | [diff] [blame] | 266 | static struct ads7846_platform_data spitz_ads7846_info = { |
| 267 | .model = 7846, |
| 268 | .vref_delay_usecs = 100, |
| 269 | .x_plate_ohms = 419, |
| 270 | .y_plate_ohms = 486, |
| 271 | .gpio_pendown = SPITZ_GPIO_TP_INT, |
| 272 | }; |
Richard Purdie | ca4d6cf | 2008-01-02 01:09:54 +0100 | [diff] [blame] | 273 | |
Eric Miao | 859b796 | 2008-09-03 12:09:24 +0800 | [diff] [blame] | 274 | static void spitz_ads7846_cs(u32 command) |
Richard Purdie | ca4d6cf | 2008-01-02 01:09:54 +0100 | [diff] [blame] | 275 | { |
Eric Miao | 859b796 | 2008-09-03 12:09:24 +0800 | [diff] [blame] | 276 | gpio_set_value(SPITZ_GPIO_ADS7846_CS, !(command == PXA2XX_CS_ASSERT)); |
Richard Purdie | ca4d6cf | 2008-01-02 01:09:54 +0100 | [diff] [blame] | 277 | } |
| 278 | |
Eric Miao | 859b796 | 2008-09-03 12:09:24 +0800 | [diff] [blame] | 279 | static struct pxa2xx_spi_chip spitz_ads7846_chip = { |
| 280 | .cs_control = spitz_ads7846_cs, |
| 281 | }; |
Richard Purdie | ca4d6cf | 2008-01-02 01:09:54 +0100 | [diff] [blame] | 282 | |
Eric Miao | 859b796 | 2008-09-03 12:09:24 +0800 | [diff] [blame] | 283 | static void spitz_notify_intensity(int intensity) |
Richard Purdie | ca4d6cf | 2008-01-02 01:09:54 +0100 | [diff] [blame] | 284 | { |
Eric Miao | 859b796 | 2008-09-03 12:09:24 +0800 | [diff] [blame] | 285 | if (machine_is_spitz() || machine_is_borzoi()) { |
| 286 | /* Bit 5 is via SCOOP */ |
| 287 | if (intensity & 0x0020) |
| 288 | reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_CONT); |
| 289 | else |
| 290 | set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_CONT); |
Richard Purdie | ca4d6cf | 2008-01-02 01:09:54 +0100 | [diff] [blame] | 291 | |
Eric Miao | 859b796 | 2008-09-03 12:09:24 +0800 | [diff] [blame] | 292 | if (intensity) |
| 293 | set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_ON); |
| 294 | else |
| 295 | reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_BACKLIGHT_ON); |
| 296 | return; |
Richard Purdie | ca4d6cf | 2008-01-02 01:09:54 +0100 | [diff] [blame] | 297 | } |
Eric Miao | 859b796 | 2008-09-03 12:09:24 +0800 | [diff] [blame] | 298 | |
| 299 | if (machine_is_akita()) { |
| 300 | /* Bit 5 is via IO-Expander */ |
| 301 | if (intensity & 0x0020) |
| 302 | akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_CONT); |
| 303 | else |
| 304 | akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_CONT); |
| 305 | |
| 306 | if (intensity) |
| 307 | akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_ON); |
| 308 | else |
| 309 | akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_BACKLIGHT_ON); |
| 310 | return; |
| 311 | } |
| 312 | } |
| 313 | |
| 314 | static void spitz_bl_kick_battery(void) |
| 315 | { |
| 316 | void (*kick_batt)(void); |
| 317 | |
| 318 | kick_batt = symbol_get(sharpsl_battery_kick); |
| 319 | if (kick_batt) { |
| 320 | kick_batt(); |
| 321 | symbol_put(sharpsl_battery_kick); |
| 322 | } |
| 323 | } |
| 324 | |
| 325 | static struct corgi_lcd_platform_data spitz_lcdcon_info = { |
| 326 | .init_mode = CORGI_LCD_MODE_VGA, |
| 327 | .max_intensity = 0x2f, |
| 328 | .default_intensity = 0x1f, |
| 329 | .limit_mask = 0x0b, |
| 330 | .notify = spitz_notify_intensity, |
| 331 | .kick_battery = spitz_bl_kick_battery, |
| 332 | }; |
| 333 | |
| 334 | static void spitz_lcdcon_cs(u32 command) |
| 335 | { |
| 336 | gpio_set_value(SPITZ_GPIO_LCDCON_CS, !(command == PXA2XX_CS_ASSERT)); |
| 337 | } |
| 338 | |
| 339 | static struct pxa2xx_spi_chip spitz_lcdcon_chip = { |
| 340 | .cs_control = spitz_lcdcon_cs, |
| 341 | }; |
| 342 | |
| 343 | static void spitz_max1111_cs(u32 command) |
| 344 | { |
| 345 | gpio_set_value(SPITZ_GPIO_MAX1111_CS, !(command == PXA2XX_CS_ASSERT)); |
| 346 | } |
| 347 | |
| 348 | static struct pxa2xx_spi_chip spitz_max1111_chip = { |
| 349 | .cs_control = spitz_max1111_cs, |
| 350 | }; |
| 351 | |
| 352 | static struct spi_board_info spitz_spi_devices[] = { |
| 353 | { |
| 354 | .modalias = "ads7846", |
| 355 | .max_speed_hz = 1200000, |
| 356 | .bus_num = 2, |
| 357 | .chip_select = 0, |
| 358 | .platform_data = &spitz_ads7846_info, |
| 359 | .controller_data= &spitz_ads7846_chip, |
| 360 | .irq = gpio_to_irq(SPITZ_GPIO_TP_INT), |
| 361 | }, { |
| 362 | .modalias = "corgi-lcd", |
| 363 | .max_speed_hz = 50000, |
| 364 | .bus_num = 2, |
| 365 | .chip_select = 1, |
| 366 | .platform_data = &spitz_lcdcon_info, |
| 367 | .controller_data= &spitz_lcdcon_chip, |
| 368 | }, { |
| 369 | .modalias = "max1111", |
| 370 | .max_speed_hz = 450000, |
| 371 | .bus_num = 2, |
| 372 | .chip_select = 2, |
| 373 | .controller_data= &spitz_max1111_chip, |
| 374 | }, |
| 375 | }; |
| 376 | |
| 377 | static void __init spitz_init_spi(void) |
| 378 | { |
| 379 | int err; |
| 380 | |
| 381 | err = gpio_request(SPITZ_GPIO_ADS7846_CS, "ADS7846_CS"); |
| 382 | if (err) |
| 383 | return; |
| 384 | |
| 385 | err = gpio_request(SPITZ_GPIO_LCDCON_CS, "LCDCON_CS"); |
| 386 | if (err) |
| 387 | goto err_free_1; |
| 388 | |
| 389 | err = gpio_request(SPITZ_GPIO_MAX1111_CS, "MAX1111_CS"); |
| 390 | if (err) |
| 391 | goto err_free_2; |
| 392 | |
| 393 | pxa2xx_set_spi_info(2, &spitz_spi_info); |
| 394 | spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices)); |
| 395 | return; |
| 396 | |
| 397 | err_free_2: |
| 398 | gpio_free(SPITZ_GPIO_LCDCON_CS); |
| 399 | err_free_1: |
| 400 | gpio_free(SPITZ_GPIO_ADS7846_CS); |
| 401 | } |
| 402 | #else |
| 403 | static inline void spitz_init_spi(void) {} |
Richard Purdie | ca4d6cf | 2008-01-02 01:09:54 +0100 | [diff] [blame] | 404 | #endif |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 405 | |
| 406 | /* |
| 407 | * MMC/SD Device |
| 408 | * |
| 409 | * The card detect interrupt isn't debounced so we delay it by 250ms |
| 410 | * to give the card a chance to fully insert/eject. |
| 411 | */ |
| 412 | |
| 413 | static struct pxamci_platform_data spitz_mci_platform_data; |
| 414 | |
David Howells | 40220c1 | 2006-10-09 12:19:47 +0100 | [diff] [blame] | 415 | static int spitz_mci_init(struct device *dev, irq_handler_t spitz_detect_int, void *data) |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 416 | { |
| 417 | int err; |
| 418 | |
Eric Miao | dd5980d | 2008-09-02 17:34:33 +0800 | [diff] [blame] | 419 | err = gpio_request(SPITZ_GPIO_nSD_DETECT, "nSD_DETECT"); |
| 420 | if (err) |
| 421 | goto err_out; |
| 422 | |
| 423 | err = gpio_request(SPITZ_GPIO_nSD_WP, "nSD_WP"); |
| 424 | if (err) |
| 425 | goto err_free_1; |
| 426 | |
| 427 | gpio_direction_input(SPITZ_GPIO_nSD_DETECT); |
| 428 | gpio_direction_input(SPITZ_GPIO_nSD_WP); |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 429 | |
| 430 | spitz_mci_platform_data.detect_delay = msecs_to_jiffies(250); |
| 431 | |
Russell King | 9ded96f | 2006-01-08 01:02:07 -0800 | [diff] [blame] | 432 | err = request_irq(SPITZ_IRQ_GPIO_nSD_DETECT, spitz_detect_int, |
Eric Miao | dd5980d | 2008-09-02 17:34:33 +0800 | [diff] [blame] | 433 | IRQF_DISABLED | IRQF_TRIGGER_RISING | |
| 434 | IRQF_TRIGGER_FALLING, |
Russell King | 9ded96f | 2006-01-08 01:02:07 -0800 | [diff] [blame] | 435 | "MMC card detect", data); |
Eric Miao | dd5980d | 2008-09-02 17:34:33 +0800 | [diff] [blame] | 436 | if (err) { |
| 437 | pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n", |
| 438 | __func__); |
| 439 | goto err_free_2; |
| 440 | } |
| 441 | return 0; |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 442 | |
Eric Miao | dd5980d | 2008-09-02 17:34:33 +0800 | [diff] [blame] | 443 | err_free_2: |
| 444 | gpio_free(SPITZ_GPIO_nSD_WP); |
| 445 | err_free_1: |
| 446 | gpio_free(SPITZ_GPIO_nSD_DETECT); |
| 447 | err_out: |
Russell King | 2687bd3 | 2008-01-23 14:05:58 +0000 | [diff] [blame] | 448 | return err; |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 449 | } |
| 450 | |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 451 | static void spitz_mci_setpower(struct device *dev, unsigned int vdd) |
| 452 | { |
| 453 | struct pxamci_platform_data* p_d = dev->platform_data; |
| 454 | |
Richard Purdie | a63ae44 | 2005-11-08 19:15:43 +0000 | [diff] [blame] | 455 | if (( 1 << vdd) & p_d->ocr_mask) |
| 456 | spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0004); |
| 457 | else |
| 458 | spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0000); |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 459 | } |
| 460 | |
| 461 | static int spitz_mci_get_ro(struct device *dev) |
| 462 | { |
Eric Miao | dd5980d | 2008-09-02 17:34:33 +0800 | [diff] [blame] | 463 | return gpio_get_value(SPITZ_GPIO_nSD_WP); |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 464 | } |
| 465 | |
| 466 | static void spitz_mci_exit(struct device *dev, void *data) |
| 467 | { |
| 468 | free_irq(SPITZ_IRQ_GPIO_nSD_DETECT, data); |
Eric Miao | dd5980d | 2008-09-02 17:34:33 +0800 | [diff] [blame] | 469 | gpio_free(SPITZ_GPIO_nSD_WP); |
| 470 | gpio_free(SPITZ_GPIO_nSD_DETECT); |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 471 | } |
| 472 | |
| 473 | static struct pxamci_platform_data spitz_mci_platform_data = { |
| 474 | .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34, |
| 475 | .init = spitz_mci_init, |
| 476 | .get_ro = spitz_mci_get_ro, |
| 477 | .setpower = spitz_mci_setpower, |
| 478 | .exit = spitz_mci_exit, |
| 479 | }; |
| 480 | |
| 481 | |
| 482 | /* |
Richard Purdie | 3125c68 | 2006-01-05 20:44:52 +0000 | [diff] [blame] | 483 | * USB Host (OHCI) |
| 484 | */ |
| 485 | static int spitz_ohci_init(struct device *dev) |
| 486 | { |
Eric Miao | dd5980d | 2008-09-02 17:34:33 +0800 | [diff] [blame] | 487 | int err; |
| 488 | |
| 489 | err = gpio_request(SPITZ_GPIO_USB_HOST, "USB_HOST"); |
| 490 | if (err) |
| 491 | return err; |
| 492 | |
Eric Miao | 5e96ade | 2008-09-03 09:47:42 +0800 | [diff] [blame] | 493 | /* Only Port 2 is connected |
| 494 | * Setup USB Port 2 Output Control Register |
| 495 | */ |
Richard Purdie | 3125c68 | 2006-01-05 20:44:52 +0000 | [diff] [blame] | 496 | UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE; |
| 497 | |
Eric Miao | dd5980d | 2008-09-02 17:34:33 +0800 | [diff] [blame] | 498 | gpio_direction_output(SPITZ_GPIO_USB_HOST, 1); |
Richard Purdie | 3125c68 | 2006-01-05 20:44:52 +0000 | [diff] [blame] | 499 | |
| 500 | UHCHR = (UHCHR) & |
| 501 | ~(UHCHR_SSEP1 | UHCHR_SSEP2 | UHCHR_SSEP3 | UHCHR_SSE); |
| 502 | |
| 503 | UHCRHDA |= UHCRHDA_NOCP; |
| 504 | |
| 505 | return 0; |
| 506 | } |
| 507 | |
| 508 | static struct pxaohci_platform_data spitz_ohci_platform_data = { |
| 509 | .port_mode = PMM_NPS_MODE, |
| 510 | .init = spitz_ohci_init, |
Richard Purdie | 0c27c5d | 2006-06-08 22:44:07 +0100 | [diff] [blame] | 511 | .power_budget = 150, |
Richard Purdie | 3125c68 | 2006-01-05 20:44:52 +0000 | [diff] [blame] | 512 | }; |
| 513 | |
| 514 | |
| 515 | /* |
Richard Purdie | dc07845 | 2005-10-30 14:50:25 +0000 | [diff] [blame] | 516 | * Irda |
| 517 | */ |
| 518 | static void spitz_irda_transceiver_mode(struct device *dev, int mode) |
| 519 | { |
| 520 | if (mode & IR_OFF) |
| 521 | set_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON); |
| 522 | else |
| 523 | reset_scoop_gpio(&spitzscoop2_device.dev, SPITZ_SCP2_IR_ON); |
Dmitry Baryshkov | 0fc3ff3 | 2008-07-02 13:54:46 +0100 | [diff] [blame] | 524 | pxa2xx_transceiver_mode(dev, mode); |
Richard Purdie | dc07845 | 2005-10-30 14:50:25 +0000 | [diff] [blame] | 525 | } |
| 526 | |
Richard Purdie | 94cabd0 | 2005-11-12 18:53:48 +0000 | [diff] [blame] | 527 | #ifdef CONFIG_MACH_AKITA |
| 528 | static void akita_irda_transceiver_mode(struct device *dev, int mode) |
| 529 | { |
| 530 | if (mode & IR_OFF) |
| 531 | akita_set_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_IR_ON); |
| 532 | else |
| 533 | akita_reset_ioexp(&akitaioexp_device.dev, AKITA_IOEXP_IR_ON); |
Dmitry Baryshkov | 0fc3ff3 | 2008-07-02 13:54:46 +0100 | [diff] [blame] | 534 | pxa2xx_transceiver_mode(dev, mode); |
Richard Purdie | 94cabd0 | 2005-11-12 18:53:48 +0000 | [diff] [blame] | 535 | } |
| 536 | #endif |
| 537 | |
Richard Purdie | dc07845 | 2005-10-30 14:50:25 +0000 | [diff] [blame] | 538 | static struct pxaficp_platform_data spitz_ficp_platform_data = { |
| 539 | .transceiver_cap = IR_SIRMODE | IR_OFF, |
| 540 | .transceiver_mode = spitz_irda_transceiver_mode, |
| 541 | }; |
| 542 | |
| 543 | |
| 544 | /* |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 545 | * Spitz PXA Framebuffer |
| 546 | */ |
Richard Purdie | d14b272 | 2006-09-20 22:54:21 +0100 | [diff] [blame] | 547 | |
| 548 | static struct pxafb_mode_info spitz_pxafb_modes[] = { |
| 549 | { |
| 550 | .pixclock = 19231, |
| 551 | .xres = 480, |
| 552 | .yres = 640, |
| 553 | .bpp = 16, |
| 554 | .hsync_len = 40, |
| 555 | .left_margin = 46, |
| 556 | .right_margin = 125, |
| 557 | .vsync_len = 3, |
| 558 | .upper_margin = 1, |
| 559 | .lower_margin = 0, |
| 560 | .sync = 0, |
| 561 | },{ |
| 562 | .pixclock = 134617, |
| 563 | .xres = 240, |
| 564 | .yres = 320, |
| 565 | .bpp = 16, |
| 566 | .hsync_len = 20, |
| 567 | .left_margin = 20, |
| 568 | .right_margin = 46, |
| 569 | .vsync_len = 2, |
| 570 | .upper_margin = 1, |
| 571 | .lower_margin = 0, |
| 572 | .sync = 0, |
| 573 | }, |
| 574 | }; |
| 575 | |
| 576 | static struct pxafb_mach_info spitz_pxafb_info = { |
| 577 | .modes = &spitz_pxafb_modes[0], |
| 578 | .num_modes = 2, |
| 579 | .fixed_modes = 1, |
Eric Miao | 79009a0 | 2008-09-03 10:00:38 +0800 | [diff] [blame] | 580 | .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_ALTERNATE_MAPPING, |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 581 | }; |
| 582 | |
| 583 | |
| 584 | static struct platform_device *devices[] __initdata = { |
| 585 | &spitzscoop_device, |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 586 | &spitzkbd_device, |
Richard Purdie | 3179108 | 2006-03-31 02:31:09 -0800 | [diff] [blame] | 587 | &spitzled_device, |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 588 | }; |
| 589 | |
Richard Purdie | 74617fb | 2006-06-19 19:57:12 +0100 | [diff] [blame] | 590 | static void spitz_poweroff(void) |
| 591 | { |
Dmitry Baryshkov | 86159a9 | 2008-05-22 16:21:48 +0100 | [diff] [blame] | 592 | arm_machine_restart('g'); |
Richard Purdie | 74617fb | 2006-06-19 19:57:12 +0100 | [diff] [blame] | 593 | } |
| 594 | |
| 595 | static void spitz_restart(char mode) |
| 596 | { |
| 597 | /* Bootloader magic for a reboot */ |
| 598 | if((MSC0 & 0xffff0000) == 0x7ff00000) |
| 599 | MSC0 = (MSC0 & 0xffff) | 0x7ee00000; |
| 600 | |
| 601 | spitz_poweroff(); |
| 602 | } |
| 603 | |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 604 | static void __init common_init(void) |
| 605 | { |
Dmitry Baryshkov | 86159a9 | 2008-05-22 16:21:48 +0100 | [diff] [blame] | 606 | init_gpio_reset(SPITZ_GPIO_ON_RESET); |
Richard Purdie | 74617fb | 2006-06-19 19:57:12 +0100 | [diff] [blame] | 607 | pm_power_off = spitz_poweroff; |
| 608 | arm_pm_restart = spitz_restart; |
| 609 | |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 610 | PMCR = 0x00; |
| 611 | |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 612 | /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */ |
| 613 | PCFR |= PCFR_OPDE; |
| 614 | |
Eric Miao | 5e96ade | 2008-09-03 09:47:42 +0800 | [diff] [blame] | 615 | pxa2xx_mfp_config(ARRAY_AND_SIZE(spitz_pin_config)); |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 616 | |
Eric Miao | 859b796 | 2008-09-03 12:09:24 +0800 | [diff] [blame] | 617 | spitz_init_spi(); |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 618 | |
| 619 | platform_add_devices(devices, ARRAY_SIZE(devices)); |
| 620 | pxa_set_mci_info(&spitz_mci_platform_data); |
Richard Purdie | 3125c68 | 2006-01-05 20:44:52 +0000 | [diff] [blame] | 621 | pxa_set_ohci_info(&spitz_ohci_platform_data); |
Richard Purdie | dc07845 | 2005-10-30 14:50:25 +0000 | [diff] [blame] | 622 | pxa_set_ficp_info(&spitz_ficp_platform_data); |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 623 | set_pxa_fb_info(&spitz_pxafb_info); |
Mark Brown | f8787fd | 2008-08-26 13:30:03 +0100 | [diff] [blame] | 624 | pxa_set_i2c_info(NULL); |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 625 | } |
| 626 | |
Richard Purdie | ca4d6cf | 2008-01-02 01:09:54 +0100 | [diff] [blame] | 627 | #if defined(CONFIG_MACH_SPITZ) || defined(CONFIG_MACH_BORZOI) |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 628 | static void __init spitz_init(void) |
| 629 | { |
Richard Purdie | a63ae44 | 2005-11-08 19:15:43 +0000 | [diff] [blame] | 630 | platform_scoop_config = &spitz_pcmcia_config; |
| 631 | |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 632 | common_init(); |
| 633 | |
| 634 | platform_device_register(&spitzscoop2_device); |
| 635 | } |
Richard Purdie | ca4d6cf | 2008-01-02 01:09:54 +0100 | [diff] [blame] | 636 | #endif |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 637 | |
Richard Purdie | 94cabd0 | 2005-11-12 18:53:48 +0000 | [diff] [blame] | 638 | #ifdef CONFIG_MACH_AKITA |
| 639 | /* |
| 640 | * Akita IO Expander |
| 641 | */ |
| 642 | struct platform_device akitaioexp_device = { |
| 643 | .name = "akita-ioexp", |
| 644 | .id = -1, |
| 645 | }; |
| 646 | |
Richard Purdie | bd8f103 | 2006-03-26 21:40:27 +0100 | [diff] [blame] | 647 | EXPORT_SYMBOL_GPL(akitaioexp_device); |
| 648 | |
Richard Purdie | 94cabd0 | 2005-11-12 18:53:48 +0000 | [diff] [blame] | 649 | static void __init akita_init(void) |
| 650 | { |
| 651 | spitz_ficp_platform_data.transceiver_mode = akita_irda_transceiver_mode; |
| 652 | |
| 653 | /* We just pretend the second element of the array doesn't exist */ |
| 654 | spitz_pcmcia_config.num_devs = 1; |
| 655 | platform_scoop_config = &spitz_pcmcia_config; |
Richard Purdie | 94cabd0 | 2005-11-12 18:53:48 +0000 | [diff] [blame] | 656 | |
| 657 | platform_device_register(&akitaioexp_device); |
| 658 | |
| 659 | spitzscoop_device.dev.parent = &akitaioexp_device.dev; |
| 660 | common_init(); |
| 661 | } |
| 662 | #endif |
| 663 | |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 664 | static void __init fixup_spitz(struct machine_desc *desc, |
| 665 | struct tag *tags, char **cmdline, struct meminfo *mi) |
| 666 | { |
| 667 | sharpsl_save_param(); |
| 668 | mi->nr_banks = 1; |
| 669 | mi->bank[0].start = 0xa0000000; |
| 670 | mi->bank[0].node = 0; |
| 671 | mi->bank[0].size = (64*1024*1024); |
| 672 | } |
| 673 | |
| 674 | #ifdef CONFIG_MACH_SPITZ |
| 675 | MACHINE_START(SPITZ, "SHARP Spitz") |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 676 | .phys_io = 0x40000000, |
| 677 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, |
| 678 | .fixup = fixup_spitz, |
| 679 | .map_io = pxa_map_io, |
Eric Miao | cd49104 | 2007-06-22 04:14:09 +0100 | [diff] [blame] | 680 | .init_irq = pxa27x_init_irq, |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 681 | .init_machine = spitz_init, |
| 682 | .timer = &pxa_timer, |
| 683 | MACHINE_END |
| 684 | #endif |
| 685 | |
| 686 | #ifdef CONFIG_MACH_BORZOI |
| 687 | MACHINE_START(BORZOI, "SHARP Borzoi") |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 688 | .phys_io = 0x40000000, |
| 689 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, |
| 690 | .fixup = fixup_spitz, |
| 691 | .map_io = pxa_map_io, |
Eric Miao | cd49104 | 2007-06-22 04:14:09 +0100 | [diff] [blame] | 692 | .init_irq = pxa27x_init_irq, |
Richard Purdie | 0dd28f1 | 2005-09-13 01:25:34 -0700 | [diff] [blame] | 693 | .init_machine = spitz_init, |
| 694 | .timer = &pxa_timer, |
| 695 | MACHINE_END |
| 696 | #endif |
Richard Purdie | 94cabd0 | 2005-11-12 18:53:48 +0000 | [diff] [blame] | 697 | |
| 698 | #ifdef CONFIG_MACH_AKITA |
| 699 | MACHINE_START(AKITA, "SHARP Akita") |
Richard Purdie | 94cabd0 | 2005-11-12 18:53:48 +0000 | [diff] [blame] | 700 | .phys_io = 0x40000000, |
| 701 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, |
| 702 | .fixup = fixup_spitz, |
| 703 | .map_io = pxa_map_io, |
Eric Miao | cd49104 | 2007-06-22 04:14:09 +0100 | [diff] [blame] | 704 | .init_irq = pxa27x_init_irq, |
Richard Purdie | 94cabd0 | 2005-11-12 18:53:48 +0000 | [diff] [blame] | 705 | .init_machine = akita_init, |
| 706 | .timer = &pxa_timer, |
| 707 | MACHINE_END |
| 708 | #endif |