spitz.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809
  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.h>
  18. #include <linux/leds.h>
  19. #include <linux/mtd/physmap.h>
  20. #include <linux/i2c.h>
  21. #include <linux/i2c/pca953x.h>
  22. #include <linux/spi/spi.h>
  23. #include <linux/spi/ads7846.h>
  24. #include <linux/spi/corgi_lcd.h>
  25. #include <linux/mtd/sharpsl.h>
  26. #include <asm/setup.h>
  27. #include <asm/mach-types.h>
  28. #include <asm/mach/arch.h>
  29. #include <asm/mach/sharpsl_param.h>
  30. #include <asm/hardware/scoop.h>
  31. #include <mach/pxa27x.h>
  32. #include <mach/pxa27x-udc.h>
  33. #include <mach/reset.h>
  34. #include <plat/i2c.h>
  35. #include <mach/irda.h>
  36. #include <mach/mmc.h>
  37. #include <mach/ohci.h>
  38. #include <mach/pxafb.h>
  39. #include <mach/pxa2xx_spi.h>
  40. #include <mach/spitz.h>
  41. #include "generic.h"
  42. #include "devices.h"
  43. #include "sharpsl.h"
  44. static unsigned long spitz_pin_config[] __initdata = {
  45. /* Chip Selects */
  46. GPIO78_nCS_2, /* SCOOP #2 */
  47. GPIO79_nCS_3, /* NAND */
  48. GPIO80_nCS_4, /* SCOOP #1 */
  49. /* LCD - 16bpp Active TFT */
  50. GPIO58_LCD_LDD_0,
  51. GPIO59_LCD_LDD_1,
  52. GPIO60_LCD_LDD_2,
  53. GPIO61_LCD_LDD_3,
  54. GPIO62_LCD_LDD_4,
  55. GPIO63_LCD_LDD_5,
  56. GPIO64_LCD_LDD_6,
  57. GPIO65_LCD_LDD_7,
  58. GPIO66_LCD_LDD_8,
  59. GPIO67_LCD_LDD_9,
  60. GPIO68_LCD_LDD_10,
  61. GPIO69_LCD_LDD_11,
  62. GPIO70_LCD_LDD_12,
  63. GPIO71_LCD_LDD_13,
  64. GPIO72_LCD_LDD_14,
  65. GPIO73_LCD_LDD_15,
  66. GPIO74_LCD_FCLK,
  67. GPIO75_LCD_LCLK,
  68. GPIO76_LCD_PCLK,
  69. /* PC Card */
  70. GPIO48_nPOE,
  71. GPIO49_nPWE,
  72. GPIO50_nPIOR,
  73. GPIO51_nPIOW,
  74. GPIO85_nPCE_1,
  75. GPIO54_nPCE_2,
  76. GPIO55_nPREG,
  77. GPIO56_nPWAIT,
  78. GPIO57_nIOIS16,
  79. GPIO104_PSKTSEL,
  80. /* I2S */
  81. GPIO28_I2S_BITCLK_OUT,
  82. GPIO29_I2S_SDATA_IN,
  83. GPIO30_I2S_SDATA_OUT,
  84. GPIO31_I2S_SYNC,
  85. /* MMC */
  86. GPIO32_MMC_CLK,
  87. GPIO112_MMC_CMD,
  88. GPIO92_MMC_DAT_0,
  89. GPIO109_MMC_DAT_1,
  90. GPIO110_MMC_DAT_2,
  91. GPIO111_MMC_DAT_3,
  92. /* GPIOs */
  93. GPIO9_GPIO, /* SPITZ_GPIO_nSD_DETECT */
  94. GPIO81_GPIO, /* SPITZ_GPIO_nSD_WP */
  95. GPIO41_GPIO, /* SPITZ_GPIO_USB_CONNECT */
  96. GPIO37_GPIO, /* SPITZ_GPIO_USB_HOST */
  97. GPIO35_GPIO, /* SPITZ_GPIO_USB_DEVICE */
  98. GPIO22_GPIO, /* SPITZ_GPIO_HSYNC */
  99. GPIO94_GPIO, /* SPITZ_GPIO_CF_CD */
  100. GPIO105_GPIO, /* SPITZ_GPIO_CF_IRQ */
  101. GPIO106_GPIO, /* SPITZ_GPIO_CF2_IRQ */
  102. /* I2C */
  103. GPIO117_I2C_SCL,
  104. GPIO118_I2C_SDA,
  105. GPIO1_GPIO | WAKEUP_ON_EDGE_RISE,
  106. };
  107. /*
  108. * Spitz SCOOP Device #1
  109. */
  110. static struct resource spitz_scoop_resources[] = {
  111. [0] = {
  112. .start = 0x10800000,
  113. .end = 0x10800fff,
  114. .flags = IORESOURCE_MEM,
  115. },
  116. };
  117. static struct scoop_config spitz_scoop_setup = {
  118. .io_dir = SPITZ_SCP_IO_DIR,
  119. .io_out = SPITZ_SCP_IO_OUT,
  120. .suspend_clr = SPITZ_SCP_SUS_CLR,
  121. .suspend_set = SPITZ_SCP_SUS_SET,
  122. .gpio_base = SPITZ_SCP_GPIO_BASE,
  123. };
  124. struct platform_device spitzscoop_device = {
  125. .name = "sharp-scoop",
  126. .id = 0,
  127. .dev = {
  128. .platform_data = &spitz_scoop_setup,
  129. },
  130. .num_resources = ARRAY_SIZE(spitz_scoop_resources),
  131. .resource = spitz_scoop_resources,
  132. };
  133. /*
  134. * Spitz SCOOP Device #2
  135. */
  136. static struct resource spitz_scoop2_resources[] = {
  137. [0] = {
  138. .start = 0x08800040,
  139. .end = 0x08800fff,
  140. .flags = IORESOURCE_MEM,
  141. },
  142. };
  143. static struct scoop_config spitz_scoop2_setup = {
  144. .io_dir = SPITZ_SCP2_IO_DIR,
  145. .io_out = SPITZ_SCP2_IO_OUT,
  146. .suspend_clr = SPITZ_SCP2_SUS_CLR,
  147. .suspend_set = SPITZ_SCP2_SUS_SET,
  148. .gpio_base = SPITZ_SCP2_GPIO_BASE,
  149. };
  150. struct platform_device spitzscoop2_device = {
  151. .name = "sharp-scoop",
  152. .id = 1,
  153. .dev = {
  154. .platform_data = &spitz_scoop2_setup,
  155. },
  156. .num_resources = ARRAY_SIZE(spitz_scoop2_resources),
  157. .resource = spitz_scoop2_resources,
  158. };
  159. #define SPITZ_PWR_SD 0x01
  160. #define SPITZ_PWR_CF 0x02
  161. /* Power control is shared with between one of the CF slots and SD */
  162. static void spitz_card_pwr_ctrl(int device, unsigned short new_cpr)
  163. {
  164. unsigned short cpr = read_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR);
  165. if (new_cpr & 0x0007) {
  166. gpio_set_value(SPITZ_GPIO_CF_POWER, 1);
  167. if (!(cpr & 0x0002) && !(cpr & 0x0004))
  168. mdelay(5);
  169. if (device == SPITZ_PWR_CF)
  170. cpr |= 0x0002;
  171. if (device == SPITZ_PWR_SD)
  172. cpr |= 0x0004;
  173. write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
  174. } else {
  175. if (device == SPITZ_PWR_CF)
  176. cpr &= ~0x0002;
  177. if (device == SPITZ_PWR_SD)
  178. cpr &= ~0x0004;
  179. if (!(cpr & 0x0002) && !(cpr & 0x0004)) {
  180. write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, 0x0000);
  181. mdelay(1);
  182. gpio_set_value(SPITZ_GPIO_CF_POWER, 0);
  183. } else {
  184. write_scoop_reg(&spitzscoop_device.dev, SCOOP_CPR, cpr | new_cpr);
  185. }
  186. }
  187. }
  188. static void spitz_pcmcia_pwr(struct device *scoop, unsigned short cpr, int nr)
  189. {
  190. /* Only need to override behaviour for slot 0 */
  191. if (nr == 0)
  192. spitz_card_pwr_ctrl(SPITZ_PWR_CF, cpr);
  193. else
  194. write_scoop_reg(scoop, SCOOP_CPR, cpr);
  195. }
  196. static struct scoop_pcmcia_dev spitz_pcmcia_scoop[] = {
  197. {
  198. .dev = &spitzscoop_device.dev,
  199. .irq = SPITZ_IRQ_GPIO_CF_IRQ,
  200. .cd_irq = SPITZ_IRQ_GPIO_CF_CD,
  201. .cd_irq_str = "PCMCIA0 CD",
  202. },{
  203. .dev = &spitzscoop2_device.dev,
  204. .irq = SPITZ_IRQ_GPIO_CF2_IRQ,
  205. .cd_irq = -1,
  206. },
  207. };
  208. static struct scoop_pcmcia_config spitz_pcmcia_config = {
  209. .devs = &spitz_pcmcia_scoop[0],
  210. .num_devs = 2,
  211. .power_ctrl = spitz_pcmcia_pwr,
  212. };
  213. EXPORT_SYMBOL(spitzscoop_device);
  214. EXPORT_SYMBOL(spitzscoop2_device);
  215. /*
  216. * Spitz Keyboard Device
  217. */
  218. static struct platform_device spitzkbd_device = {
  219. .name = "spitz-keyboard",
  220. .id = -1,
  221. };
  222. /*
  223. * Spitz LEDs
  224. */
  225. static struct gpio_led spitz_gpio_leds[] = {
  226. {
  227. .name = "spitz:amber:charge",
  228. .default_trigger = "sharpsl-charge",
  229. .gpio = SPITZ_GPIO_LED_ORANGE,
  230. },
  231. {
  232. .name = "spitz:green:hddactivity",
  233. .default_trigger = "ide-disk",
  234. .gpio = SPITZ_GPIO_LED_GREEN,
  235. },
  236. };
  237. static struct gpio_led_platform_data spitz_gpio_leds_info = {
  238. .leds = spitz_gpio_leds,
  239. .num_leds = ARRAY_SIZE(spitz_gpio_leds),
  240. };
  241. static struct platform_device spitzled_device = {
  242. .name = "leds-gpio",
  243. .id = -1,
  244. .dev = {
  245. .platform_data = &spitz_gpio_leds_info,
  246. },
  247. };
  248. #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
  249. static struct pxa2xx_spi_master spitz_spi_info = {
  250. .num_chipselect = 3,
  251. };
  252. static void spitz_wait_for_hsync(void)
  253. {
  254. while (gpio_get_value(SPITZ_GPIO_HSYNC))
  255. cpu_relax();
  256. while (!gpio_get_value(SPITZ_GPIO_HSYNC))
  257. cpu_relax();
  258. }
  259. static struct ads7846_platform_data spitz_ads7846_info = {
  260. .model = 7846,
  261. .vref_delay_usecs = 100,
  262. .x_plate_ohms = 419,
  263. .y_plate_ohms = 486,
  264. .gpio_pendown = SPITZ_GPIO_TP_INT,
  265. .wait_for_sync = spitz_wait_for_hsync,
  266. };
  267. static struct pxa2xx_spi_chip spitz_ads7846_chip = {
  268. .gpio_cs = SPITZ_GPIO_ADS7846_CS,
  269. };
  270. static void spitz_bl_kick_battery(void)
  271. {
  272. void (*kick_batt)(void);
  273. kick_batt = symbol_get(sharpsl_battery_kick);
  274. if (kick_batt) {
  275. kick_batt();
  276. symbol_put(sharpsl_battery_kick);
  277. }
  278. }
  279. static struct corgi_lcd_platform_data spitz_lcdcon_info = {
  280. .init_mode = CORGI_LCD_MODE_VGA,
  281. .max_intensity = 0x2f,
  282. .default_intensity = 0x1f,
  283. .limit_mask = 0x0b,
  284. .gpio_backlight_cont = SPITZ_GPIO_BACKLIGHT_CONT,
  285. .gpio_backlight_on = SPITZ_GPIO_BACKLIGHT_ON,
  286. .kick_battery = spitz_bl_kick_battery,
  287. };
  288. static struct pxa2xx_spi_chip spitz_lcdcon_chip = {
  289. .gpio_cs = SPITZ_GPIO_LCDCON_CS,
  290. };
  291. static struct pxa2xx_spi_chip spitz_max1111_chip = {
  292. .gpio_cs = SPITZ_GPIO_MAX1111_CS,
  293. };
  294. static struct spi_board_info spitz_spi_devices[] = {
  295. {
  296. .modalias = "ads7846",
  297. .max_speed_hz = 1200000,
  298. .bus_num = 2,
  299. .chip_select = 0,
  300. .platform_data = &spitz_ads7846_info,
  301. .controller_data= &spitz_ads7846_chip,
  302. .irq = gpio_to_irq(SPITZ_GPIO_TP_INT),
  303. }, {
  304. .modalias = "corgi-lcd",
  305. .max_speed_hz = 50000,
  306. .bus_num = 2,
  307. .chip_select = 1,
  308. .platform_data = &spitz_lcdcon_info,
  309. .controller_data= &spitz_lcdcon_chip,
  310. }, {
  311. .modalias = "max1111",
  312. .max_speed_hz = 450000,
  313. .bus_num = 2,
  314. .chip_select = 2,
  315. .controller_data= &spitz_max1111_chip,
  316. },
  317. };
  318. static void __init spitz_init_spi(void)
  319. {
  320. if (machine_is_akita()) {
  321. spitz_lcdcon_info.gpio_backlight_cont = AKITA_GPIO_BACKLIGHT_CONT;
  322. spitz_lcdcon_info.gpio_backlight_on = AKITA_GPIO_BACKLIGHT_ON;
  323. }
  324. pxa2xx_set_spi_info(2, &spitz_spi_info);
  325. spi_register_board_info(ARRAY_AND_SIZE(spitz_spi_devices));
  326. }
  327. #else
  328. static inline void spitz_init_spi(void) {}
  329. #endif
  330. /*
  331. * MMC/SD Device
  332. *
  333. * The card detect interrupt isn't debounced so we delay it by 250ms
  334. * to give the card a chance to fully insert/eject.
  335. */
  336. static struct pxamci_platform_data spitz_mci_platform_data;
  337. static int spitz_mci_init(struct device *dev, irq_handler_t spitz_detect_int, void *data)
  338. {
  339. int err;
  340. err = gpio_request(SPITZ_GPIO_nSD_DETECT, "nSD_DETECT");
  341. if (err)
  342. goto err_out;
  343. err = gpio_request(SPITZ_GPIO_nSD_WP, "nSD_WP");
  344. if (err)
  345. goto err_free_1;
  346. gpio_direction_input(SPITZ_GPIO_nSD_DETECT);
  347. gpio_direction_input(SPITZ_GPIO_nSD_WP);
  348. spitz_mci_platform_data.detect_delay = msecs_to_jiffies(250);
  349. err = request_irq(SPITZ_IRQ_GPIO_nSD_DETECT, spitz_detect_int,
  350. IRQF_DISABLED | IRQF_TRIGGER_RISING |
  351. IRQF_TRIGGER_FALLING,
  352. "MMC card detect", data);
  353. if (err) {
  354. pr_err("%s: MMC/SD: can't request MMC card detect IRQ\n",
  355. __func__);
  356. goto err_free_2;
  357. }
  358. return 0;
  359. err_free_2:
  360. gpio_free(SPITZ_GPIO_nSD_WP);
  361. err_free_1:
  362. gpio_free(SPITZ_GPIO_nSD_DETECT);
  363. err_out:
  364. return err;
  365. }
  366. static void spitz_mci_setpower(struct device *dev, unsigned int vdd)
  367. {
  368. struct pxamci_platform_data* p_d = dev->platform_data;
  369. if (( 1 << vdd) & p_d->ocr_mask)
  370. spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0004);
  371. else
  372. spitz_card_pwr_ctrl(SPITZ_PWR_SD, 0x0000);
  373. }
  374. static int spitz_mci_get_ro(struct device *dev)
  375. {
  376. return gpio_get_value(SPITZ_GPIO_nSD_WP);
  377. }
  378. static void spitz_mci_exit(struct device *dev, void *data)
  379. {
  380. free_irq(SPITZ_IRQ_GPIO_nSD_DETECT, data);
  381. gpio_free(SPITZ_GPIO_nSD_WP);
  382. gpio_free(SPITZ_GPIO_nSD_DETECT);
  383. }
  384. static struct pxamci_platform_data spitz_mci_platform_data = {
  385. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  386. .init = spitz_mci_init,
  387. .get_ro = spitz_mci_get_ro,
  388. .setpower = spitz_mci_setpower,
  389. .exit = spitz_mci_exit,
  390. };
  391. /*
  392. * USB Host (OHCI)
  393. */
  394. static int spitz_ohci_init(struct device *dev)
  395. {
  396. int err;
  397. err = gpio_request(SPITZ_GPIO_USB_HOST, "USB_HOST");
  398. if (err)
  399. return err;
  400. /* Only Port 2 is connected
  401. * Setup USB Port 2 Output Control Register
  402. */
  403. UP2OCR = UP2OCR_HXS | UP2OCR_HXOE | UP2OCR_DPPDE | UP2OCR_DMPDE;
  404. return gpio_direction_output(SPITZ_GPIO_USB_HOST, 1);
  405. }
  406. static void spitz_ohci_exit(struct device *dev)
  407. {
  408. gpio_free(SPITZ_GPIO_USB_HOST);
  409. }
  410. static struct pxaohci_platform_data spitz_ohci_platform_data = {
  411. .port_mode = PMM_NPS_MODE,
  412. .init = spitz_ohci_init,
  413. .exit = spitz_ohci_exit,
  414. .flags = ENABLE_PORT_ALL | NO_OC_PROTECTION,
  415. .power_budget = 150,
  416. };
  417. /*
  418. * Irda
  419. */
  420. static int spitz_irda_startup(struct device *dev)
  421. {
  422. int rc;
  423. rc = gpio_request(SPITZ_GPIO_IR_ON, "IrDA on");
  424. if (rc)
  425. goto err;
  426. rc = gpio_direction_output(SPITZ_GPIO_IR_ON, 1);
  427. if (rc)
  428. goto err_dir;
  429. return 0;
  430. err_dir:
  431. gpio_free(SPITZ_GPIO_IR_ON);
  432. err:
  433. return rc;
  434. }
  435. static void spitz_irda_shutdown(struct device *dev)
  436. {
  437. gpio_free(SPITZ_GPIO_IR_ON);
  438. }
  439. static void spitz_irda_transceiver_mode(struct device *dev, int mode)
  440. {
  441. gpio_set_value(SPITZ_GPIO_IR_ON, mode & IR_OFF);
  442. pxa2xx_transceiver_mode(dev, mode);
  443. }
  444. #ifdef CONFIG_MACH_AKITA
  445. static void akita_irda_transceiver_mode(struct device *dev, int mode)
  446. {
  447. gpio_set_value(AKITA_GPIO_IR_ON, mode & IR_OFF);
  448. pxa2xx_transceiver_mode(dev, mode);
  449. }
  450. #endif
  451. static struct pxaficp_platform_data spitz_ficp_platform_data = {
  452. .transceiver_cap = IR_SIRMODE | IR_OFF,
  453. .transceiver_mode = spitz_irda_transceiver_mode,
  454. .startup = spitz_irda_startup,
  455. .shutdown = spitz_irda_shutdown,
  456. };
  457. /*
  458. * Spitz PXA Framebuffer
  459. */
  460. static struct pxafb_mode_info spitz_pxafb_modes[] = {
  461. {
  462. .pixclock = 19231,
  463. .xres = 480,
  464. .yres = 640,
  465. .bpp = 16,
  466. .hsync_len = 40,
  467. .left_margin = 46,
  468. .right_margin = 125,
  469. .vsync_len = 3,
  470. .upper_margin = 1,
  471. .lower_margin = 0,
  472. .sync = 0,
  473. },{
  474. .pixclock = 134617,
  475. .xres = 240,
  476. .yres = 320,
  477. .bpp = 16,
  478. .hsync_len = 20,
  479. .left_margin = 20,
  480. .right_margin = 46,
  481. .vsync_len = 2,
  482. .upper_margin = 1,
  483. .lower_margin = 0,
  484. .sync = 0,
  485. },
  486. };
  487. static struct pxafb_mach_info spitz_pxafb_info = {
  488. .modes = &spitz_pxafb_modes[0],
  489. .num_modes = 2,
  490. .fixed_modes = 1,
  491. .lcd_conn = LCD_COLOR_TFT_16BPP | LCD_ALTERNATE_MAPPING,
  492. };
  493. static struct mtd_partition sharpsl_nand_partitions[] = {
  494. {
  495. .name = "System Area",
  496. .offset = 0,
  497. .size = 7 * 1024 * 1024,
  498. },
  499. {
  500. .name = "Root Filesystem",
  501. .offset = 7 * 1024 * 1024,
  502. },
  503. {
  504. .name = "Home Filesystem",
  505. .offset = MTDPART_OFS_APPEND,
  506. .size = MTDPART_SIZ_FULL,
  507. },
  508. };
  509. static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
  510. static struct nand_bbt_descr sharpsl_bbt = {
  511. .options = 0,
  512. .offs = 4,
  513. .len = 2,
  514. .pattern = scan_ff_pattern
  515. };
  516. static struct sharpsl_nand_platform_data sharpsl_nand_platform_data = {
  517. .badblock_pattern = &sharpsl_bbt,
  518. .partitions = sharpsl_nand_partitions,
  519. .nr_partitions = ARRAY_SIZE(sharpsl_nand_partitions),
  520. };
  521. static struct resource sharpsl_nand_resources[] = {
  522. {
  523. .start = 0x0C000000,
  524. .end = 0x0C000FFF,
  525. .flags = IORESOURCE_MEM,
  526. },
  527. };
  528. static struct platform_device sharpsl_nand_device = {
  529. .name = "sharpsl-nand",
  530. .id = -1,
  531. .resource = sharpsl_nand_resources,
  532. .num_resources = ARRAY_SIZE(sharpsl_nand_resources),
  533. .dev.platform_data = &sharpsl_nand_platform_data,
  534. };
  535. static struct mtd_partition sharpsl_rom_parts[] = {
  536. {
  537. .name ="Boot PROM Filesystem",
  538. .offset = 0x00140000,
  539. .size = MTDPART_SIZ_FULL,
  540. },
  541. };
  542. static struct physmap_flash_data sharpsl_rom_data = {
  543. .width = 2,
  544. .nr_parts = ARRAY_SIZE(sharpsl_rom_parts),
  545. .parts = sharpsl_rom_parts,
  546. };
  547. static struct resource sharpsl_rom_resources[] = {
  548. {
  549. .start = 0x00000000,
  550. .end = 0x007fffff,
  551. .flags = IORESOURCE_MEM,
  552. },
  553. };
  554. static struct platform_device sharpsl_rom_device = {
  555. .name = "physmap-flash",
  556. .id = -1,
  557. .resource = sharpsl_rom_resources,
  558. .num_resources = ARRAY_SIZE(sharpsl_rom_resources),
  559. .dev.platform_data = &sharpsl_rom_data,
  560. };
  561. static struct platform_device *devices[] __initdata = {
  562. &spitzscoop_device,
  563. &spitzkbd_device,
  564. &spitzled_device,
  565. &sharpsl_nand_device,
  566. &sharpsl_rom_device,
  567. };
  568. static void spitz_poweroff(void)
  569. {
  570. arm_machine_restart('g', NULL);
  571. }
  572. static void spitz_restart(char mode, const char *cmd)
  573. {
  574. /* Bootloader magic for a reboot */
  575. if((MSC0 & 0xffff0000) == 0x7ff00000)
  576. MSC0 = (MSC0 & 0xffff) | 0x7ee00000;
  577. spitz_poweroff();
  578. }
  579. static void __init common_init(void)
  580. {
  581. init_gpio_reset(SPITZ_GPIO_ON_RESET, 1, 0);
  582. pm_power_off = spitz_poweroff;
  583. arm_pm_restart = spitz_restart;
  584. if (machine_is_spitz()) {
  585. sharpsl_nand_partitions[1].size = 5 * 1024 * 1024;
  586. } else if (machine_is_akita()) {
  587. sharpsl_nand_partitions[1].size = 58 * 1024 * 1024;
  588. } else if (machine_is_borzoi()) {
  589. sharpsl_nand_partitions[1].size = 32 * 1024 * 1024;
  590. }
  591. PMCR = 0x00;
  592. /* Stop 3.6MHz and drive HIGH to PCMCIA and CS */
  593. PCFR |= PCFR_OPDE;
  594. pxa2xx_mfp_config(ARRAY_AND_SIZE(spitz_pin_config));
  595. spitz_init_spi();
  596. platform_add_devices(devices, ARRAY_SIZE(devices));
  597. pxa_set_mci_info(&spitz_mci_platform_data);
  598. pxa_set_ohci_info(&spitz_ohci_platform_data);
  599. pxa_set_ficp_info(&spitz_ficp_platform_data);
  600. set_pxa_fb_info(&spitz_pxafb_info);
  601. pxa_set_i2c_info(NULL);
  602. }
  603. #if defined(CONFIG_MACH_SPITZ) || defined(CONFIG_MACH_BORZOI)
  604. static void __init spitz_init(void)
  605. {
  606. platform_scoop_config = &spitz_pcmcia_config;
  607. common_init();
  608. platform_device_register(&spitzscoop2_device);
  609. }
  610. #endif
  611. #ifdef CONFIG_MACH_AKITA
  612. /*
  613. * Akita IO Expander
  614. */
  615. static struct pca953x_platform_data akita_ioexp = {
  616. .gpio_base = AKITA_IOEXP_GPIO_BASE,
  617. };
  618. static struct i2c_board_info akita_i2c_board_info[] = {
  619. {
  620. .type = "max7310",
  621. .addr = 0x18,
  622. .platform_data = &akita_ioexp,
  623. },
  624. };
  625. static struct nand_bbt_descr sharpsl_akita_bbt = {
  626. .options = 0,
  627. .offs = 4,
  628. .len = 1,
  629. .pattern = scan_ff_pattern
  630. };
  631. static struct nand_ecclayout akita_oobinfo = {
  632. .eccbytes = 24,
  633. .eccpos = {
  634. 0x5, 0x1, 0x2, 0x3, 0x6, 0x7, 0x15, 0x11,
  635. 0x12, 0x13, 0x16, 0x17, 0x25, 0x21, 0x22, 0x23,
  636. 0x26, 0x27, 0x35, 0x31, 0x32, 0x33, 0x36, 0x37},
  637. .oobfree = {{0x08, 0x09}}
  638. };
  639. static void __init akita_init(void)
  640. {
  641. spitz_ficp_platform_data.transceiver_mode = akita_irda_transceiver_mode;
  642. sharpsl_nand_platform_data.badblock_pattern = &sharpsl_akita_bbt;
  643. sharpsl_nand_platform_data.ecc_layout = &akita_oobinfo;
  644. /* We just pretend the second element of the array doesn't exist */
  645. spitz_pcmcia_config.num_devs = 1;
  646. platform_scoop_config = &spitz_pcmcia_config;
  647. i2c_register_board_info(0, ARRAY_AND_SIZE(akita_i2c_board_info));
  648. common_init();
  649. }
  650. #endif
  651. static void __init fixup_spitz(struct machine_desc *desc,
  652. struct tag *tags, char **cmdline, struct meminfo *mi)
  653. {
  654. sharpsl_save_param();
  655. mi->nr_banks = 1;
  656. mi->bank[0].start = 0xa0000000;
  657. mi->bank[0].node = 0;
  658. mi->bank[0].size = (64*1024*1024);
  659. }
  660. #ifdef CONFIG_MACH_SPITZ
  661. MACHINE_START(SPITZ, "SHARP Spitz")
  662. .phys_io = 0x40000000,
  663. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  664. .fixup = fixup_spitz,
  665. .map_io = pxa_map_io,
  666. .init_irq = pxa27x_init_irq,
  667. .init_machine = spitz_init,
  668. .timer = &pxa_timer,
  669. MACHINE_END
  670. #endif
  671. #ifdef CONFIG_MACH_BORZOI
  672. MACHINE_START(BORZOI, "SHARP Borzoi")
  673. .phys_io = 0x40000000,
  674. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  675. .fixup = fixup_spitz,
  676. .map_io = pxa_map_io,
  677. .init_irq = pxa27x_init_irq,
  678. .init_machine = spitz_init,
  679. .timer = &pxa_timer,
  680. MACHINE_END
  681. #endif
  682. #ifdef CONFIG_MACH_AKITA
  683. MACHINE_START(AKITA, "SHARP Akita")
  684. .phys_io = 0x40000000,
  685. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  686. .fixup = fixup_spitz,
  687. .map_io = pxa_map_io,
  688. .init_irq = pxa27x_init_irq,
  689. .init_machine = akita_init,
  690. .timer = &pxa_timer,
  691. MACHINE_END
  692. #endif