spitz.c 26 KB

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