spitz.c 19 KB

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