spitz.c 26 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066
  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. #include <linux/kernel.h>
  15. #include <linux/module.h> /* symbol_get ; symbol_put */
  16. #include <linux/platform_device.h>
  17. #include <linux/delay.h>
  18. #include <linux/gpio_keys.h>
  19. #include <linux/gpio.h>
  20. #include <linux/leds.h>
  21. #include <linux/i2c.h>
  22. #include <linux/i2c/pxa-i2c.h>
  23. #include <linux/platform_data/pca953x.h>
  24. #include <linux/spi/spi.h>
  25. #include <linux/spi/ads7846.h>
  26. #include <linux/spi/corgi_lcd.h>
  27. #include <linux/spi/pxa2xx_spi.h>
  28. #include <linux/mtd/sharpsl.h>
  29. #include <linux/mtd/physmap.h>
  30. #include <linux/input/matrix_keypad.h>
  31. #include <linux/regulator/machine.h>
  32. #include <linux/io.h>
  33. #include <linux/module.h>
  34. #include <linux/reboot.h>
  35. #include <linux/memblock.h>
  36. #include <asm/setup.h>
  37. #include <asm/mach-types.h>
  38. #include <asm/mach/arch.h>
  39. #include <asm/mach/sharpsl_param.h>
  40. #include <asm/hardware/scoop.h>
  41. #include "pxa27x.h"
  42. #include "pxa27x-udc.h"
  43. #include <mach/reset.h>
  44. #include <linux/platform_data/irda-pxaficp.h>
  45. #include <linux/platform_data/mmc-pxamci.h>
  46. #include <linux/platform_data/usb-ohci-pxa27x.h>
  47. #include <linux/platform_data/video-pxafb.h>
  48. #include <mach/spitz.h>
  49. #include "sharpsl_pm.h"
  50. #include <mach/smemc.h>
  51. #include "generic.h"
  52. #include "devices.h"
  53. /******************************************************************************
  54. * Pin configuration
  55. ******************************************************************************/
  56. static unsigned long spitz_pin_config[] __initdata = {
  57. /* Chip Selects */
  58. GPIO78_nCS_2, /* SCOOP #2 */
  59. GPIO79_nCS_3, /* NAND */
  60. GPIO80_nCS_4, /* SCOOP #1 */
  61. /* LCD - 16bpp Active TFT */
  62. GPIOxx_LCD_TFT_16BPP,
  63. /* PC Card */
  64. GPIO48_nPOE,
  65. GPIO49_nPWE,
  66. GPIO50_nPIOR,
  67. GPIO51_nPIOW,
  68. GPIO85_nPCE_1,
  69. GPIO54_nPCE_2,
  70. GPIO55_nPREG,
  71. GPIO56_nPWAIT,
  72. GPIO57_nIOIS16,
  73. GPIO104_PSKTSEL,
  74. /* I2S */
  75. GPIO28_I2S_BITCLK_OUT,
  76. GPIO29_I2S_SDATA_IN,
  77. GPIO30_I2S_SDATA_OUT,
  78. GPIO31_I2S_SYNC,
  79. /* MMC */
  80. GPIO32_MMC_CLK,
  81. GPIO112_MMC_CMD,
  82. GPIO92_MMC_DAT_0,
  83. GPIO109_MMC_DAT_1,
  84. GPIO110_MMC_DAT_2,
  85. GPIO111_MMC_DAT_3,
  86. /* GPIOs */
  87. GPIO9_GPIO, /* SPITZ_GPIO_nSD_DETECT */
  88. GPIO16_GPIO, /* SPITZ_GPIO_SYNC */
  89. GPIO81_GPIO, /* SPITZ_GPIO_nSD_WP */
  90. GPIO41_GPIO, /* SPITZ_GPIO_USB_CONNECT */
  91. GPIO37_GPIO, /* SPITZ_GPIO_USB_HOST */
  92. GPIO35_GPIO, /* SPITZ_GPIO_USB_DEVICE */
  93. GPIO22_GPIO, /* SPITZ_GPIO_HSYNC */
  94. GPIO94_GPIO, /* SPITZ_GPIO_CF_CD */
  95. GPIO105_GPIO, /* SPITZ_GPIO_CF_IRQ */
  96. GPIO106_GPIO, /* SPITZ_GPIO_CF2_IRQ */
  97. /* GPIO matrix keypad */
  98. GPIO88_GPIO, /* column 0 */
  99. GPIO23_GPIO, /* column 1 */
  100. GPIO24_GPIO, /* column 2 */
  101. GPIO25_GPIO, /* column 3 */
  102. GPIO26_GPIO, /* column 4 */
  103. GPIO27_GPIO, /* column 5 */
  104. GPIO52_GPIO, /* column 6 */
  105. GPIO103_GPIO, /* column 7 */
  106. GPIO107_GPIO, /* column 8 */
  107. GPIO108_GPIO, /* column 9 */
  108. GPIO114_GPIO, /* column 10 */
  109. GPIO12_GPIO, /* row 0 */
  110. GPIO17_GPIO, /* row 1 */
  111. GPIO91_GPIO, /* row 2 */
  112. GPIO34_GPIO, /* row 3 */
  113. GPIO36_GPIO, /* row 4 */
  114. GPIO38_GPIO, /* row 5 */
  115. GPIO39_GPIO, /* row 6 */
  116. /* I2C */
  117. GPIO117_I2C_SCL,
  118. GPIO118_I2C_SDA,
  119. GPIO0_GPIO | WAKEUP_ON_EDGE_RISE, /* SPITZ_GPIO_KEY_INT */
  120. GPIO1_GPIO | WAKEUP_ON_EDGE_FALL, /* SPITZ_GPIO_RESET */
  121. };
  122. /******************************************************************************
  123. * Scoop GPIO expander
  124. ******************************************************************************/
  125. #if defined(CONFIG_SHARP_SCOOP) || defined(CONFIG_SHARP_SCOOP_MODULE)
  126. /* SCOOP Device #1 */
  127. static struct resource spitz_scoop_1_resources[] = {
  128. [0] = {
  129. .start = 0x10800000,
  130. .end = 0x10800fff,
  131. .flags = IORESOURCE_MEM,
  132. },
  133. };
  134. static struct scoop_config spitz_scoop_1_setup = {
  135. .io_dir = SPITZ_SCP_IO_DIR,
  136. .io_out = SPITZ_SCP_IO_OUT,
  137. .suspend_clr = SPITZ_SCP_SUS_CLR,
  138. .suspend_set = SPITZ_SCP_SUS_SET,
  139. .gpio_base = SPITZ_SCP_GPIO_BASE,
  140. };
  141. struct platform_device spitz_scoop_1_device = {
  142. .name = "sharp-scoop",
  143. .id = 0,
  144. .dev = {
  145. .platform_data = &spitz_scoop_1_setup,
  146. },
  147. .num_resources = ARRAY_SIZE(spitz_scoop_1_resources),
  148. .resource = spitz_scoop_1_resources,
  149. };
  150. /* SCOOP Device #2 */
  151. static struct resource spitz_scoop_2_resources[] = {
  152. [0] = {
  153. .start = 0x08800040,
  154. .end = 0x08800fff,
  155. .flags = IORESOURCE_MEM,
  156. },
  157. };
  158. static struct scoop_config spitz_scoop_2_setup = {
  159. .io_dir = SPITZ_SCP2_IO_DIR,
  160. .io_out = SPITZ_SCP2_IO_OUT,
  161. .suspend_clr = SPITZ_SCP2_SUS_CLR,
  162. .suspend_set = SPITZ_SCP2_SUS_SET,
  163. .gpio_base = SPITZ_SCP2_GPIO_BASE,
  164. };
  165. struct platform_device spitz_scoop_2_device = {
  166. .name = "sharp-scoop",
  167. .id = 1,
  168. .dev = {
  169. .platform_data = &spitz_scoop_2_setup,
  170. },
  171. .num_resources = ARRAY_SIZE(spitz_scoop_2_resources),
  172. .resource = spitz_scoop_2_resources,
  173. };
  174. static void __init spitz_scoop_init(void)
  175. {
  176. platform_device_register(&spitz_scoop_1_device);
  177. /* Akita doesn't have the second SCOOP chip */
  178. if (!machine_is_akita())
  179. platform_device_register(&spitz_scoop_2_device);
  180. }
  181. /* Power control is shared with between one of the CF slots and SD */
  182. static void __maybe_unused spitz_card_pwr_ctrl(uint8_t enable, uint8_t new_cpr)
  183. {
  184. unsigned short cpr;
  185. unsigned long flags;
  186. if (new_cpr & 0x7) {
  187. gpio_set_value(SPITZ_GPIO_CF_POWER, 1);
  188. mdelay(5);
  189. }
  190. local_irq_save(flags);
  191. cpr = read_scoop_reg(&spitz_scoop_1_device.dev, SCOOP_CPR);
  192. if (enable & new_cpr)
  193. cpr |= new_cpr;
  194. else
  195. cpr &= ~enable;
  196. write_scoop_reg(&spitz_scoop_1_device.dev, SCOOP_CPR, cpr);
  197. local_irq_restore(flags);
  198. if (!(cpr & 0x7)) {
  199. mdelay(1);
  200. gpio_set_value(SPITZ_GPIO_CF_POWER, 0);
  201. }
  202. }
  203. #else
  204. static inline void spitz_scoop_init(void) {}
  205. static inline void spitz_card_pwr_ctrl(uint8_t enable, uint8_t new_cpr) {}
  206. #endif
  207. /******************************************************************************
  208. * PCMCIA
  209. ******************************************************************************/
  210. #if defined(CONFIG_PCMCIA_PXA2XX) || defined(CONFIG_PCMCIA_PXA2XX_MODULE)
  211. static void spitz_pcmcia_pwr(struct device *scoop, uint16_t cpr, int nr)
  212. {
  213. /* Only need to override behaviour for slot 0 */
  214. if (nr == 0)
  215. spitz_card_pwr_ctrl(
  216. cpr & (SCOOP_CPR_CF_3V | SCOOP_CPR_CF_XV), cpr);
  217. else
  218. write_scoop_reg(scoop, SCOOP_CPR, cpr);
  219. }
  220. static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = {
  221. {
  222. .dev = &spitz_scoop_1_device.dev,
  223. .irq = SPITZ_IRQ_GPIO_CF_IRQ,
  224. .cd_irq = SPITZ_IRQ_GPIO_CF_CD,
  225. .cd_irq_str = "PCMCIA0 CD",
  226. }, {
  227. .dev = &spitz_scoop_2_device.dev,
  228. .irq = SPITZ_IRQ_GPIO_CF2_IRQ,
  229. .cd_irq = -1,
  230. },
  231. };
  232. static struct scoop_pcmcia_config spitz_pcmcia_config = {
  233. .devs = &spitz_pcmcia_scoop[0],
  234. .num_devs = 2,
  235. .power_ctrl = spitz_pcmcia_pwr,
  236. };
  237. static void __init spitz_pcmcia_init(void)
  238. {
  239. /* Akita has only one PCMCIA slot used */
  240. if (machine_is_akita())
  241. spitz_pcmcia_config.num_devs = 1;
  242. platform_scoop_config = &spitz_pcmcia_config;
  243. }
  244. #else
  245. static inline void spitz_pcmcia_init(void) {}
  246. #endif
  247. /******************************************************************************
  248. * GPIO keyboard
  249. ******************************************************************************/
  250. #if defined(CONFIG_KEYBOARD_MATRIX) || defined(CONFIG_KEYBOARD_MATRIX_MODULE)
  251. #define SPITZ_KEY_CALENDAR KEY_F1
  252. #define SPITZ_KEY_ADDRESS KEY_F2
  253. #define SPITZ_KEY_FN KEY_F3
  254. #define SPITZ_KEY_CANCEL KEY_F4
  255. #define SPITZ_KEY_EXOK KEY_F5
  256. #define SPITZ_KEY_EXCANCEL KEY_F6
  257. #define SPITZ_KEY_EXJOGDOWN KEY_F7
  258. #define SPITZ_KEY_EXJOGUP KEY_F8
  259. #define SPITZ_KEY_JAP1 KEY_LEFTALT
  260. #define SPITZ_KEY_JAP2 KEY_RIGHTCTRL
  261. #define SPITZ_KEY_SYNC KEY_F9
  262. #define SPITZ_KEY_MAIL KEY_F10
  263. #define SPITZ_KEY_OK KEY_F11
  264. #define SPITZ_KEY_MENU KEY_F12
  265. static const uint32_t spitz_keymap[] = {
  266. KEY(0, 0, KEY_LEFTCTRL),
  267. KEY(0, 1, KEY_1),
  268. KEY(0, 2, KEY_3),
  269. KEY(0, 3, KEY_5),
  270. KEY(0, 4, KEY_6),
  271. KEY(0, 5, KEY_7),
  272. KEY(0, 6, KEY_9),
  273. KEY(0, 7, KEY_0),
  274. KEY(0, 8, KEY_BACKSPACE),
  275. KEY(0, 9, SPITZ_KEY_EXOK), /* EXOK */
  276. KEY(0, 10, SPITZ_KEY_EXCANCEL), /* EXCANCEL */
  277. KEY(1, 1, KEY_2),
  278. KEY(1, 2, KEY_4),
  279. KEY(1, 3, KEY_R),
  280. KEY(1, 4, KEY_Y),
  281. KEY(1, 5, KEY_8),
  282. KEY(1, 6, KEY_I),
  283. KEY(1, 7, KEY_O),
  284. KEY(1, 8, KEY_P),
  285. KEY(1, 9, SPITZ_KEY_EXJOGDOWN), /* EXJOGDOWN */
  286. KEY(1, 10, SPITZ_KEY_EXJOGUP), /* EXJOGUP */
  287. KEY(2, 0, KEY_TAB),
  288. KEY(2, 1, KEY_Q),
  289. KEY(2, 2, KEY_E),
  290. KEY(2, 3, KEY_T),
  291. KEY(2, 4, KEY_G),
  292. KEY(2, 5, KEY_U),
  293. KEY(2, 6, KEY_J),
  294. KEY(2, 7, KEY_K),
  295. KEY(3, 0, SPITZ_KEY_ADDRESS), /* ADDRESS */
  296. KEY(3, 1, KEY_W),
  297. KEY(3, 2, KEY_S),
  298. KEY(3, 3, KEY_F),
  299. KEY(3, 4, KEY_V),
  300. KEY(3, 5, KEY_H),
  301. KEY(3, 6, KEY_M),
  302. KEY(3, 7, KEY_L),
  303. KEY(3, 9, KEY_RIGHTSHIFT),
  304. KEY(4, 0, SPITZ_KEY_CALENDAR), /* CALENDAR */
  305. KEY(4, 1, KEY_A),
  306. KEY(4, 2, KEY_D),
  307. KEY(4, 3, KEY_C),
  308. KEY(4, 4, KEY_B),
  309. KEY(4, 5, KEY_N),
  310. KEY(4, 6, KEY_DOT),
  311. KEY(4, 8, KEY_ENTER),
  312. KEY(4, 9, KEY_LEFTSHIFT),
  313. KEY(5, 0, SPITZ_KEY_MAIL), /* MAIL */
  314. KEY(5, 1, KEY_Z),
  315. KEY(5, 2, KEY_X),
  316. KEY(5, 3, KEY_MINUS),
  317. KEY(5, 4, KEY_SPACE),
  318. KEY(5, 5, KEY_COMMA),
  319. KEY(5, 7, KEY_UP),
  320. KEY(5, 10, SPITZ_KEY_FN), /* FN */
  321. KEY(6, 0, KEY_SYSRQ),
  322. KEY(6, 1, SPITZ_KEY_JAP1), /* JAP1 */
  323. KEY(6, 2, SPITZ_KEY_JAP2), /* JAP2 */
  324. KEY(6, 3, SPITZ_KEY_CANCEL), /* CANCEL */
  325. KEY(6, 4, SPITZ_KEY_OK), /* OK */
  326. KEY(6, 5, SPITZ_KEY_MENU), /* MENU */
  327. KEY(6, 6, KEY_LEFT),
  328. KEY(6, 7, KEY_DOWN),
  329. KEY(6, 8, KEY_RIGHT),
  330. };
  331. static const struct matrix_keymap_data spitz_keymap_data = {
  332. .keymap = spitz_keymap,
  333. .keymap_size = ARRAY_SIZE(spitz_keymap),
  334. };
  335. static const uint32_t spitz_row_gpios[] =
  336. { 12, 17, 91, 34, 36, 38, 39 };
  337. static const uint32_t spitz_col_gpios[] =
  338. { 88, 23, 24, 25, 26, 27, 52, 103, 107, 108, 114 };
  339. static struct matrix_keypad_platform_data spitz_mkp_pdata = {
  340. .keymap_data = &spitz_keymap_data,
  341. .row_gpios = spitz_row_gpios,
  342. .col_gpios = spitz_col_gpios,
  343. .num_row_gpios = ARRAY_SIZE(spitz_row_gpios),
  344. .num_col_gpios = ARRAY_SIZE(spitz_col_gpios),
  345. .col_scan_delay_us = 10,
  346. .debounce_ms = 10,
  347. .wakeup = 1,
  348. };
  349. static struct platform_device spitz_mkp_device = {
  350. .name = "matrix-keypad",
  351. .id = -1,
  352. .dev = {
  353. .platform_data = &spitz_mkp_pdata,
  354. },
  355. };
  356. static void __init spitz_mkp_init(void)
  357. {
  358. platform_device_register(&spitz_mkp_device);
  359. }
  360. #else
  361. static inline void spitz_mkp_init(void) {}
  362. #endif
  363. /******************************************************************************
  364. * GPIO keys
  365. ******************************************************************************/
  366. #if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)
  367. static struct gpio_keys_button spitz_gpio_keys[] = {
  368. {
  369. .type = EV_PWR,
  370. .code = KEY_SUSPEND,
  371. .gpio = SPITZ_GPIO_ON_KEY,
  372. .desc = "On Off",
  373. .wakeup = 1,
  374. },
  375. /* Two buttons detecting the lid state */
  376. {
  377. .type = EV_SW,
  378. .code = 0,
  379. .gpio = SPITZ_GPIO_SWA,
  380. .desc = "Display Down",
  381. },
  382. {
  383. .type = EV_SW,
  384. .code = 1,
  385. .gpio = SPITZ_GPIO_SWB,
  386. .desc = "Lid Closed",
  387. },
  388. };
  389. static struct gpio_keys_platform_data spitz_gpio_keys_platform_data = {
  390. .buttons = spitz_gpio_keys,
  391. .nbuttons = ARRAY_SIZE(spitz_gpio_keys),
  392. };
  393. static struct platform_device spitz_gpio_keys_device = {
  394. .name = "gpio-keys",
  395. .id = -1,
  396. .dev = {
  397. .platform_data = &spitz_gpio_keys_platform_data,
  398. },
  399. };
  400. static void __init spitz_keys_init(void)
  401. {
  402. platform_device_register(&spitz_gpio_keys_device);
  403. }
  404. #else
  405. static inline void spitz_keys_init(void) {}
  406. #endif
  407. /******************************************************************************
  408. * LEDs
  409. ******************************************************************************/
  410. #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE)
  411. static struct gpio_led spitz_gpio_leds[] = {
  412. {
  413. .name = "spitz:amber:charge",
  414. .default_trigger = "sharpsl-charge",
  415. .gpio = SPITZ_GPIO_LED_ORANGE,
  416. },
  417. {
  418. .name = "spitz:green:hddactivity",
  419. .default_trigger = "disk-activity",
  420. .gpio = SPITZ_GPIO_LED_GREEN,
  421. },
  422. };
  423. static struct gpio_led_platform_data spitz_gpio_leds_info = {
  424. .leds = spitz_gpio_leds,
  425. .num_leds = ARRAY_SIZE(spitz_gpio_leds),
  426. };
  427. static struct platform_device spitz_led_device = {
  428. .name = "leds-gpio",
  429. .id = -1,
  430. .dev = {
  431. .platform_data = &spitz_gpio_leds_info,
  432. },
  433. };
  434. static void __init spitz_leds_init(void)
  435. {
  436. platform_device_register(&spitz_led_device);
  437. }
  438. #else
  439. static inline void spitz_leds_init(void) {}
  440. #endif
  441. /******************************************************************************
  442. * SSP Devices
  443. ******************************************************************************/
  444. #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
  445. static void spitz_ads7846_wait_for_hsync(void)
  446. {
  447. while (gpio_get_value(SPITZ_GPIO_HSYNC))
  448. cpu_relax();
  449. while (!gpio_get_value(SPITZ_GPIO_HSYNC))
  450. cpu_relax();
  451. }
  452. static struct ads7846_platform_data spitz_ads7846_info = {
  453. .model = 7846,
  454. .vref_delay_usecs = 100,
  455. .x_plate_ohms = 419,
  456. .y_plate_ohms = 486,
  457. .pressure_max = 1024,
  458. .gpio_pendown = SPITZ_GPIO_TP_INT,
  459. .wait_for_sync = spitz_ads7846_wait_for_hsync,
  460. };
  461. static struct pxa2xx_spi_chip spitz_ads7846_chip = {
  462. .gpio_cs = SPITZ_GPIO_ADS7846_CS,
  463. };
  464. static void spitz_bl_kick_battery(void)
  465. {
  466. void (*kick_batt)(void);
  467. kick_batt = symbol_get(sharpsl_battery_kick);
  468. if (kick_batt) {
  469. kick_batt();
  470. symbol_put(sharpsl_battery_kick);
  471. }
  472. }
  473. static struct corgi_lcd_platform_data spitz_lcdcon_info = {
  474. .init_mode = CORGI_LCD_MODE_VGA,
  475. .max_intensity = 0x2f,
  476. .default_intensity = 0x1f,
  477. .limit_mask = 0x0b,
  478. .gpio_backlight_cont = SPITZ_GPIO_BACKLIGHT_CONT,
  479. .gpio_backlight_on = SPITZ_GPIO_BACKLIGHT_ON,
  480. .kick_battery = spitz_bl_kick_battery,
  481. };
  482. static struct pxa2xx_spi_chip spitz_lcdcon_chip = {
  483. .gpio_cs = SPITZ_GPIO_LCDCON_CS,
  484. };
  485. static struct pxa2xx_spi_chip spitz_max1111_chip = {
  486. .gpio_cs = SPITZ_GPIO_MAX1111_CS,
  487. };
  488. static struct spi_board_info spitz_spi_devices[] = {
  489. {
  490. .modalias = "ads7846",
  491. .max_speed_hz = 1200000,
  492. .bus_num = 2,
  493. .chip_select = 0,
  494. .platform_data = &spitz_ads7846_info,
  495. .controller_data = &spitz_ads7846_chip,
  496. .irq = PXA_GPIO_TO_IRQ(SPITZ_GPIO_TP_INT),
  497. }, {
  498. .modalias = "corgi-lcd",
  499. .max_speed_hz = 50000,
  500. .bus_num = 2,
  501. .chip_select = 1,
  502. .platform_data = &spitz_lcdcon_info,
  503. .controller_data = &spitz_lcdcon_chip,
  504. }, {
  505. .modalias = "max1111",
  506. .max_speed_hz = 450000,
  507. .bus_num = 2,
  508. .chip_select = 2,
  509. .controller_data = &spitz_max1111_chip,
  510. },
  511. };
  512. static struct pxa2xx_spi_master spitz_spi_info = {
  513. .num_chipselect = 3,
  514. };
  515. static void __init spitz_spi_init(void)
  516. {
  517. struct corgi_lcd_platform_data *lcd_data = &spitz_lcdcon_info;
  518. if (machine_is_akita()) {
  519. lcd_data->gpio_backlight_cont = AKITA_GPIO_BACKLIGHT_CONT;
  520. lcd_data->gpio_backlight_on = AKITA_GPIO_BACKLIGHT_ON;
  521. }
  522. pxa2xx_set_spi_info(2, &spitz_spi_info);
  523. spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices));
  524. }
  525. #else
  526. static inline void spitz_spi_init(void) {}
  527. #endif
  528. /******************************************************************************
  529. * SD/MMC card controller
  530. ******************************************************************************/
  531. #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
  532. /*
  533. * NOTE: The card detect interrupt isn't debounced so we delay it by 250ms to
  534. * give the card a chance to fully insert/eject.
  535. */
  536. static int spitz_mci_setpower(struct device *dev, unsigned int vdd)
  537. {
  538. struct pxamci_platform_data* p_d = dev->platform_data;
  539. if ((1 << vdd) & p_d->ocr_mask)
  540. spitz_card_pwr_ctrl(SCOOP_CPR_SD_3V, SCOOP_CPR_SD_3V);
  541. else
  542. spitz_card_pwr_ctrl(SCOOP_CPR_SD_3V, 0x0);
  543. return 0;
  544. }
  545. static struct pxamci_platform_data spitz_mci_platform_data = {
  546. .detect_delay_ms = 250,
  547. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  548. .setpower = spitz_mci_setpower,
  549. .gpio_card_detect = SPITZ_GPIO_nSD_DETECT,
  550. .gpio_card_ro = SPITZ_GPIO_nSD_WP,
  551. .gpio_power = -1,
  552. };
  553. static void __init spitz_mmc_init(void)
  554. {
  555. pxa_set_mci_info(&spitz_mci_platform_data);
  556. }
  557. #else
  558. static inline void spitz_mmc_init(void) {}
  559. #endif
  560. /******************************************************************************
  561. * USB Host
  562. ******************************************************************************/
  563. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  564. static int spitz_ohci_init(struct device *dev)
  565. {
  566. int err;
  567. err = gpio_request(SPITZ_GPIO_USB_HOST, "USB_HOST");
  568. if (err)
  569. return err;
  570. /* Only Port 2 is connected, setup USB Port 2 Output Control Register */
  571. UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
  572. return gpio_direction_output(SPITZ_GPIO_USB_HOST, 1);
  573. }
  574. static void spitz_ohci_exit(struct device *dev)
  575. {
  576. gpio_free(SPITZ_GPIO_USB_HOST);
  577. }
  578. static struct pxaohci_platform_data spitz_ohci_platform_data = {
  579. .port_mode = PMM_NPS_MODE,
  580. .init = spitz_ohci_init,
  581. .exit = spitz_ohci_exit,
  582. .flags = ENABLE_PORT_ALL | NO_OC_PROTECTION,
  583. .power_budget = 150,
  584. };
  585. static void __init spitz_uhc_init(void)
  586. {
  587. pxa_set_ohci_info(&spitz_ohci_platform_data);
  588. }
  589. #else
  590. static inline void spitz_uhc_init(void) {}
  591. #endif
  592. /******************************************************************************
  593. * IrDA
  594. ******************************************************************************/
  595. #if defined(CONFIG_PXA_FICP) || defined(CONFIG_PXA_FICP_MODULE)
  596. static struct pxaficp_platform_data spitz_ficp_platform_data = {
  597. .transceiver_cap = IR_SIRMODE | IR_OFF,
  598. };
  599. static void __init spitz_irda_init(void)
  600. {
  601. if (machine_is_akita())
  602. spitz_ficp_platform_data.gpio_pwdown = AKITA_GPIO_IR_ON;
  603. else
  604. spitz_ficp_platform_data.gpio_pwdown = SPITZ_GPIO_IR_ON;
  605. pxa_set_ficp_info(&spitz_ficp_platform_data);
  606. }
  607. #else
  608. static inline void spitz_irda_init(void) {}
  609. #endif
  610. /******************************************************************************
  611. * Framebuffer
  612. ******************************************************************************/
  613. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
  614. static struct pxafb_mode_info spitz_pxafb_modes[] = {
  615. {
  616. .pixclock = 19231,
  617. .xres = 480,
  618. .yres = 640,
  619. .bpp = 16,
  620. .hsync_len = 40,
  621. .left_margin = 46,
  622. .right_margin = 125,
  623. .vsync_len = 3,
  624. .upper_margin = 1,
  625. .lower_margin = 0,
  626. .sync = 0,
  627. }, {
  628. .pixclock = 134617,
  629. .xres = 240,
  630. .yres = 320,
  631. .bpp = 16,
  632. .hsync_len = 20,
  633. .left_margin = 20,
  634. .right_margin = 46,
  635. .vsync_len = 2,
  636. .upper_margin = 1,
  637. .lower_margin = 0,
  638. .sync = 0,
  639. },
  640. };
  641. static struct pxafb_mach_info spitz_pxafb_info = {
  642. .modes = spitz_pxafb_modes,
  643. .num_modes = ARRAY_SIZE(spitz_pxafb_modes),
  644. .fixed_modes = 1,
  645. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_ALTERNATE_MAPPING,
  646. };
  647. static void __init spitz_lcd_init(void)
  648. {
  649. pxa_set_fb_info(NULL, &spitz_pxafb_info);
  650. }
  651. #else
  652. static inline void spitz_lcd_init(void) {}
  653. #endif
  654. /******************************************************************************
  655. * NAND Flash
  656. ******************************************************************************/
  657. #if defined(CONFIG_MTD_NAND_SHARPSL) || defined(CONFIG_MTD_NAND_SHARPSL_MODULE)
  658. static struct mtd_partition spitz_nand_partitions[] = {
  659. {
  660. .name = "System Area",
  661. .offset = 0,
  662. .size = 7 * 1024 * 1024,
  663. }, {
  664. .name = "Root Filesystem",
  665. .offset = 7 * 1024 * 1024,
  666. }, {
  667. .name = "Home Filesystem",
  668. .offset = MTDPART_OFS_APPEND,
  669. .size = MTDPART_SIZ_FULL,
  670. },
  671. };
  672. static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
  673. static struct nand_bbt_descr spitz_nand_bbt = {
  674. .options = 0,
  675. .offs = 4,
  676. .len = 2,
  677. .pattern = scan_ff_pattern
  678. };
  679. static int akita_ooblayout_ecc(struct mtd_info *mtd, int section,
  680. struct mtd_oob_region *oobregion)
  681. {
  682. if (section > 12)
  683. return -ERANGE;
  684. switch (section % 3) {
  685. case 0:
  686. oobregion->offset = 5;
  687. oobregion->length = 1;
  688. break;
  689. case 1:
  690. oobregion->offset = 1;
  691. oobregion->length = 3;
  692. break;
  693. case 2:
  694. oobregion->offset = 6;
  695. oobregion->length = 2;
  696. break;
  697. }
  698. oobregion->offset += (section / 3) * 0x10;
  699. return 0;
  700. }
  701. static int akita_ooblayout_free(struct mtd_info *mtd, int section,
  702. struct mtd_oob_region *oobregion)
  703. {
  704. if (section)
  705. return -ERANGE;
  706. oobregion->offset = 8;
  707. oobregion->length = 9;
  708. return 0;
  709. }
  710. static const struct mtd_ooblayout_ops akita_ooblayout_ops = {
  711. .ecc = akita_ooblayout_ecc,
  712. .free = akita_ooblayout_free,
  713. };
  714. static struct sharpsl_nand_platform_data spitz_nand_pdata = {
  715. .badblock_pattern = &spitz_nand_bbt,
  716. .partitions = spitz_nand_partitions,
  717. .nr_partitions = ARRAY_SIZE(spitz_nand_partitions),
  718. };
  719. static struct resource spitz_nand_resources[] = {
  720. {
  721. .start = PXA_CS3_PHYS,
  722. .end = PXA_CS3_PHYS + SZ_4K - 1,
  723. .flags = IORESOURCE_MEM,
  724. },
  725. };
  726. static struct platform_device spitz_nand_device = {
  727. .name = "sharpsl-nand",
  728. .id = -1,
  729. .resource = spitz_nand_resources,
  730. .num_resources = ARRAY_SIZE(spitz_nand_resources),
  731. .dev = {
  732. .platform_data = &spitz_nand_pdata,
  733. }
  734. };
  735. static void __init spitz_nand_init(void)
  736. {
  737. if (machine_is_spitz()) {
  738. spitz_nand_partitions[1].size = 5 * 1024 * 1024;
  739. } else if (machine_is_akita()) {
  740. spitz_nand_partitions[1].size = 58 * 1024 * 1024;
  741. spitz_nand_bbt.len = 1;
  742. spitz_nand_pdata.ecc_layout = &akita_ooblayout_ops;
  743. } else if (machine_is_borzoi()) {
  744. spitz_nand_partitions[1].size = 32 * 1024 * 1024;
  745. spitz_nand_bbt.len = 1;
  746. spitz_nand_pdata.ecc_layout = &akita_ooblayout_ops;
  747. }
  748. platform_device_register(&spitz_nand_device);
  749. }
  750. #else
  751. static inline void spitz_nand_init(void) {}
  752. #endif
  753. /******************************************************************************
  754. * NOR Flash
  755. ******************************************************************************/
  756. #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_PHYSMAP_MODULE)
  757. static struct mtd_partition spitz_rom_parts[] = {
  758. {
  759. .name ="Boot PROM Filesystem",
  760. .offset = 0x00140000,
  761. .size = MTDPART_SIZ_FULL,
  762. },
  763. };
  764. static struct physmap_flash_data spitz_rom_data = {
  765. .width = 2,
  766. .nr_parts = ARRAY_SIZE(spitz_rom_parts),
  767. .parts = spitz_rom_parts,
  768. };
  769. static struct resource spitz_rom_resources[] = {
  770. {
  771. .start = PXA_CS0_PHYS,
  772. .end = PXA_CS0_PHYS + SZ_8M - 1,
  773. .flags = IORESOURCE_MEM,
  774. },
  775. };
  776. static struct platform_device spitz_rom_device = {
  777. .name = "physmap-flash",
  778. .id = -1,
  779. .resource = spitz_rom_resources,
  780. .num_resources = ARRAY_SIZE(spitz_rom_resources),
  781. .dev = {
  782. .platform_data = &spitz_rom_data,
  783. },
  784. };
  785. static void __init spitz_nor_init(void)
  786. {
  787. platform_device_register(&spitz_rom_device);
  788. }
  789. #else
  790. static inline void spitz_nor_init(void) {}
  791. #endif
  792. /******************************************************************************
  793. * I2C devices
  794. ******************************************************************************/
  795. #if defined(CONFIG_I2C_PXA) || defined(CONFIG_I2C_PXA_MODULE)
  796. static struct pca953x_platform_data akita_pca953x_pdata = {
  797. .gpio_base = AKITA_IOEXP_GPIO_BASE,
  798. };
  799. static struct i2c_board_info spitz_i2c_devs[] = {
  800. {
  801. .type = "wm8750",
  802. .addr = 0x1b,
  803. }, {
  804. .type = "max7310",
  805. .addr = 0x18,
  806. .platform_data = &akita_pca953x_pdata,
  807. },
  808. };
  809. static struct regulator_consumer_supply isl6271a_consumers[] = {
  810. REGULATOR_SUPPLY("vcc_core", NULL),
  811. };
  812. static struct regulator_init_data isl6271a_info[] = {
  813. {
  814. .constraints = {
  815. .name = "vcc_core range",
  816. .min_uV = 850000,
  817. .max_uV = 1600000,
  818. .always_on = 1,
  819. .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
  820. },
  821. .consumer_supplies = isl6271a_consumers,
  822. .num_consumer_supplies = ARRAY_SIZE(isl6271a_consumers),
  823. }
  824. };
  825. static struct i2c_board_info spitz_pi2c_devs[] = {
  826. {
  827. .type = "isl6271a",
  828. .addr = 0x0c,
  829. .platform_data = &isl6271a_info,
  830. },
  831. };
  832. static void __init spitz_i2c_init(void)
  833. {
  834. int size = ARRAY_SIZE(spitz_i2c_devs);
  835. /* Only Akita has the max7310 chip */
  836. if (!machine_is_akita())
  837. size--;
  838. pxa_set_i2c_info(NULL);
  839. pxa27x_set_i2c_power_info(NULL);
  840. i2c_register_board_info(0, spitz_i2c_devs, size);
  841. i2c_register_board_info(1, ARRAY_AND_SIZE(spitz_pi2c_devs));
  842. }
  843. #else
  844. static inline void spitz_i2c_init(void) {}
  845. #endif
  846. /******************************************************************************
  847. * Audio devices
  848. ******************************************************************************/
  849. static inline void spitz_audio_init(void)
  850. {
  851. platform_device_register_simple("spitz-audio", -1, NULL, 0);
  852. }
  853. /******************************************************************************
  854. * Machine init
  855. ******************************************************************************/
  856. static void spitz_poweroff(void)
  857. {
  858. pxa_restart(REBOOT_GPIO, NULL);
  859. }
  860. static void spitz_restart(enum reboot_mode mode, const char *cmd)
  861. {
  862. uint32_t msc0 = __raw_readl(MSC0);
  863. /* Bootloader magic for a reboot */
  864. if ((msc0 & 0xffff0000) == 0x7ff00000)
  865. __raw_writel((msc0 & 0xffff) | 0x7ee00000, MSC0);
  866. spitz_poweroff();
  867. }
  868. static void __init spitz_init(void)
  869. {
  870. init_gpio_reset(SPITZ_GPIO_ON_RESET, 1, 0);
  871. pm_power_off = spitz_poweroff;
  872. PMCR = 0x00;
  873. /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
  874. PCFR |= PCFR_OPDE;
  875. pxa2xx_mfp_config(ARRAY_AND_SIZE(spitz_pin_config));
  876. pxa_set_ffuart_info(NULL);
  877. pxa_set_btuart_info(NULL);
  878. pxa_set_stuart_info(NULL);
  879. spitz_spi_init();
  880. spitz_scoop_init();
  881. spitz_mkp_init();
  882. spitz_keys_init();
  883. spitz_leds_init();
  884. spitz_mmc_init();
  885. spitz_pcmcia_init();
  886. spitz_irda_init();
  887. spitz_uhc_init();
  888. spitz_lcd_init();
  889. spitz_nor_init();
  890. spitz_nand_init();
  891. spitz_i2c_init();
  892. spitz_audio_init();
  893. regulator_has_full_constraints();
  894. }
  895. static void __init spitz_fixup(struct tag *tags, char **cmdline)
  896. {
  897. sharpsl_save_param();
  898. memblock_add(0xa0000000, SZ_64M);
  899. }
  900. #ifdef CONFIG_MACH_SPITZ
  901. MACHINE_START(SPITZ, "SHARP Spitz")
  902. .fixup = spitz_fixup,
  903. .map_io = pxa27x_map_io,
  904. .nr_irqs = PXA_NR_IRQS,
  905. .init_irq = pxa27x_init_irq,
  906. .handle_irq = pxa27x_handle_irq,
  907. .init_machine = spitz_init,
  908. .init_time = pxa_timer_init,
  909. .restart = spitz_restart,
  910. MACHINE_END
  911. #endif
  912. #ifdef CONFIG_MACH_BORZOI
  913. MACHINE_START(BORZOI, "SHARP Borzoi")
  914. .fixup = spitz_fixup,
  915. .map_io = pxa27x_map_io,
  916. .nr_irqs = PXA_NR_IRQS,
  917. .init_irq = pxa27x_init_irq,
  918. .handle_irq = pxa27x_handle_irq,
  919. .init_machine = spitz_init,
  920. .init_time = pxa_timer_init,
  921. .restart = spitz_restart,
  922. MACHINE_END
  923. #endif
  924. #ifdef CONFIG_MACH_AKITA
  925. MACHINE_START(AKITA, "SHARP Akita")
  926. .fixup = spitz_fixup,
  927. .map_io = pxa27x_map_io,
  928. .nr_irqs = PXA_NR_IRQS,
  929. .init_irq = pxa27x_init_irq,
  930. .handle_irq = pxa27x_handle_irq,
  931. .init_machine = spitz_init,
  932. .init_time = pxa_timer_init,
  933. .restart = spitz_restart,
  934. MACHINE_END
  935. #endif