spitz.c 25 KB

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