spitz.c 27 KB

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