spitz.c 25 KB

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