spitz.c 19 KB

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