spitz.c 25 KB

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