poodle.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/arch/arm/mach-pxa/poodle.c
  4. *
  5. * Support for the SHARP Poodle Board.
  6. *
  7. * Based on:
  8. * linux/arch/arm/mach-pxa/lubbock.c Author: Nicolas Pitre
  9. *
  10. * Change Log
  11. * 12-Dec-2002 Sharp Corporation for Poodle
  12. * John Lenz <[email protected]> updates to 2.6
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/export.h>
  17. #include <linux/platform_device.h>
  18. #include <linux/fb.h>
  19. #include <linux/pm.h>
  20. #include <linux/delay.h>
  21. #include <linux/mtd/physmap.h>
  22. #include <linux/gpio.h>
  23. #include <linux/gpio/machine.h>
  24. #include <linux/i2c.h>
  25. #include <linux/platform_data/i2c-pxa.h>
  26. #include <linux/regulator/machine.h>
  27. #include <linux/spi/spi.h>
  28. #include <linux/spi/ads7846.h>
  29. #include <linux/spi/pxa2xx_spi.h>
  30. #include <linux/mtd/sharpsl.h>
  31. #include <linux/memblock.h>
  32. #include <asm/mach-types.h>
  33. #include <asm/irq.h>
  34. #include <asm/setup.h>
  35. #include <asm/mach/arch.h>
  36. #include <asm/mach/map.h>
  37. #include <asm/mach/irq.h>
  38. #include "pxa25x.h"
  39. #include "udc.h"
  40. #include "poodle.h"
  41. #include <linux/platform_data/mmc-pxamci.h>
  42. #include <linux/platform_data/irda-pxaficp.h>
  43. #include <linux/platform_data/video-pxafb.h>
  44. #include <linux/platform_data/asoc-poodle.h>
  45. #include <asm/hardware/scoop.h>
  46. #include <asm/hardware/locomo.h>
  47. #include <asm/mach/sharpsl_param.h>
  48. #include "generic.h"
  49. #include "devices.h"
  50. static unsigned long poodle_pin_config[] __initdata = {
  51. /* I/O */
  52. GPIO79_nCS_3,
  53. GPIO80_nCS_4,
  54. GPIO18_RDY,
  55. /* Clock */
  56. GPIO12_32KHz,
  57. /* SSP1 */
  58. GPIO23_SSP1_SCLK,
  59. GPIO25_SSP1_TXD,
  60. GPIO26_SSP1_RXD,
  61. GPIO24_GPIO, /* POODLE_GPIO_TP_CS - SFRM as chip select */
  62. /* I2S */
  63. GPIO28_I2S_BITCLK_OUT,
  64. GPIO29_I2S_SDATA_IN,
  65. GPIO30_I2S_SDATA_OUT,
  66. GPIO31_I2S_SYNC,
  67. GPIO32_I2S_SYSCLK,
  68. /* Infra-Red */
  69. GPIO47_FICP_TXD,
  70. GPIO46_FICP_RXD,
  71. /* FFUART */
  72. GPIO40_FFUART_DTR,
  73. GPIO41_FFUART_RTS,
  74. GPIO39_FFUART_TXD,
  75. GPIO37_FFUART_DSR,
  76. GPIO34_FFUART_RXD,
  77. GPIO35_FFUART_CTS,
  78. /* LCD */
  79. GPIOxx_LCD_TFT_16BPP,
  80. /* PC Card */
  81. GPIO48_nPOE,
  82. GPIO49_nPWE,
  83. GPIO50_nPIOR,
  84. GPIO51_nPIOW,
  85. GPIO52_nPCE_1,
  86. GPIO53_nPCE_2,
  87. GPIO54_nPSKTSEL,
  88. GPIO55_nPREG,
  89. GPIO56_nPWAIT,
  90. GPIO57_nIOIS16,
  91. /* MMC */
  92. GPIO6_MMC_CLK,
  93. GPIO8_MMC_CS0,
  94. /* GPIO */
  95. GPIO9_GPIO, /* POODLE_GPIO_nSD_DETECT */
  96. GPIO7_GPIO, /* POODLE_GPIO_nSD_WP */
  97. GPIO3_GPIO, /* POODLE_GPIO_SD_PWR */
  98. GPIO33_GPIO, /* POODLE_GPIO_SD_PWR1 */
  99. GPIO20_GPIO, /* POODLE_GPIO_USB_PULLUP */
  100. GPIO22_GPIO, /* POODLE_GPIO_IR_ON */
  101. };
  102. static struct resource poodle_scoop_resources[] = {
  103. [0] = {
  104. .start = 0x10800000,
  105. .end = 0x10800fff,
  106. .flags = IORESOURCE_MEM,
  107. },
  108. };
  109. static struct scoop_config poodle_scoop_setup = {
  110. .io_dir = POODLE_SCOOP_IO_DIR,
  111. .io_out = POODLE_SCOOP_IO_OUT,
  112. .gpio_base = POODLE_SCOOP_GPIO_BASE,
  113. };
  114. struct platform_device poodle_scoop_device = {
  115. .name = "sharp-scoop",
  116. .id = -1,
  117. .dev = {
  118. .platform_data = &poodle_scoop_setup,
  119. },
  120. .num_resources = ARRAY_SIZE(poodle_scoop_resources),
  121. .resource = poodle_scoop_resources,
  122. };
  123. static struct scoop_pcmcia_dev poodle_pcmcia_scoop[] = {
  124. {
  125. .dev = &poodle_scoop_device.dev,
  126. .irq = POODLE_IRQ_GPIO_CF_IRQ,
  127. .cd_irq = POODLE_IRQ_GPIO_CF_CD,
  128. .cd_irq_str = "PCMCIA0 CD",
  129. },
  130. };
  131. static struct scoop_pcmcia_config poodle_pcmcia_config = {
  132. .devs = &poodle_pcmcia_scoop[0],
  133. .num_devs = 1,
  134. };
  135. EXPORT_SYMBOL(poodle_scoop_device);
  136. /* LoCoMo device */
  137. static struct resource locomo_resources[] = {
  138. [0] = {
  139. .start = 0x10000000,
  140. .end = 0x10001fff,
  141. .flags = IORESOURCE_MEM,
  142. },
  143. [1] = {
  144. .start = PXA_GPIO_TO_IRQ(10),
  145. .end = PXA_GPIO_TO_IRQ(10),
  146. .flags = IORESOURCE_IRQ,
  147. },
  148. };
  149. static struct locomo_platform_data locomo_info = {
  150. .irq_base = IRQ_BOARD_START,
  151. };
  152. static struct platform_device poodle_locomo_device = {
  153. .name = "locomo",
  154. .id = 0,
  155. .num_resources = ARRAY_SIZE(locomo_resources),
  156. .resource = locomo_resources,
  157. .dev = {
  158. .platform_data = &locomo_info,
  159. },
  160. };
  161. static struct poodle_audio_platform_data poodle_audio_pdata = {
  162. .locomo_dev = &poodle_locomo_device.dev,
  163. .gpio_amp_on = POODLE_LOCOMO_GPIO_AMP_ON,
  164. .gpio_mute_l = POODLE_LOCOMO_GPIO_MUTE_L,
  165. .gpio_mute_r = POODLE_LOCOMO_GPIO_MUTE_R,
  166. .gpio_232vcc_on = POODLE_LOCOMO_GPIO_232VCC_ON,
  167. .gpio_jk_b = POODLE_LOCOMO_GPIO_JK_B,
  168. };
  169. static struct platform_device poodle_audio_device = {
  170. .name = "poodle-audio",
  171. .id = -1,
  172. .dev.platform_data = &poodle_audio_pdata,
  173. };
  174. #if defined(CONFIG_SPI_PXA2XX) || defined(CONFIG_SPI_PXA2XX_MODULE)
  175. static struct pxa2xx_spi_controller poodle_spi_info = {
  176. .num_chipselect = 1,
  177. };
  178. static struct gpiod_lookup_table poodle_spi_gpio_table = {
  179. .dev_id = "pxa2xx-spi.1",
  180. .table = {
  181. GPIO_LOOKUP_IDX("gpio-pxa", POODLE_GPIO_TP_CS, "cs", 0, GPIO_ACTIVE_LOW),
  182. { },
  183. },
  184. };
  185. static struct ads7846_platform_data poodle_ads7846_info = {
  186. .model = 7846,
  187. .vref_delay_usecs = 100,
  188. .x_plate_ohms = 419,
  189. .y_plate_ohms = 486,
  190. .gpio_pendown = POODLE_GPIO_TP_INT,
  191. };
  192. static struct spi_board_info poodle_spi_devices[] = {
  193. {
  194. .modalias = "ads7846",
  195. .max_speed_hz = 10000,
  196. .bus_num = 1,
  197. .platform_data = &poodle_ads7846_info,
  198. .irq = PXA_GPIO_TO_IRQ(POODLE_GPIO_TP_INT),
  199. },
  200. };
  201. static void __init poodle_init_spi(void)
  202. {
  203. gpiod_add_lookup_table(&poodle_spi_gpio_table);
  204. pxa2xx_set_spi_info(1, &poodle_spi_info);
  205. spi_register_board_info(ARRAY_AND_SIZE(poodle_spi_devices));
  206. }
  207. #else
  208. static inline void poodle_init_spi(void) {}
  209. #endif
  210. /*
  211. * MMC/SD Device
  212. *
  213. * The card detect interrupt isn't debounced so we delay it by 250ms
  214. * to give the card a chance to fully insert/eject.
  215. */
  216. static int poodle_mci_init(struct device *dev, irq_handler_t poodle_detect_int, void *data)
  217. {
  218. int err;
  219. err = gpio_request(POODLE_GPIO_SD_PWR, "SD_PWR");
  220. if (err)
  221. goto err_free_2;
  222. err = gpio_request(POODLE_GPIO_SD_PWR1, "SD_PWR1");
  223. if (err)
  224. goto err_free_3;
  225. gpio_direction_output(POODLE_GPIO_SD_PWR, 0);
  226. gpio_direction_output(POODLE_GPIO_SD_PWR1, 0);
  227. return 0;
  228. err_free_3:
  229. gpio_free(POODLE_GPIO_SD_PWR);
  230. err_free_2:
  231. return err;
  232. }
  233. static int poodle_mci_setpower(struct device *dev, unsigned int vdd)
  234. {
  235. struct pxamci_platform_data* p_d = dev->platform_data;
  236. if ((1 << vdd) & p_d->ocr_mask) {
  237. gpio_set_value(POODLE_GPIO_SD_PWR, 1);
  238. mdelay(2);
  239. gpio_set_value(POODLE_GPIO_SD_PWR1, 1);
  240. } else {
  241. gpio_set_value(POODLE_GPIO_SD_PWR1, 0);
  242. gpio_set_value(POODLE_GPIO_SD_PWR, 0);
  243. }
  244. return 0;
  245. }
  246. static void poodle_mci_exit(struct device *dev, void *data)
  247. {
  248. gpio_free(POODLE_GPIO_SD_PWR1);
  249. gpio_free(POODLE_GPIO_SD_PWR);
  250. }
  251. static struct pxamci_platform_data poodle_mci_platform_data = {
  252. .detect_delay_ms = 250,
  253. .ocr_mask = MMC_VDD_32_33|MMC_VDD_33_34,
  254. .init = poodle_mci_init,
  255. .setpower = poodle_mci_setpower,
  256. .exit = poodle_mci_exit,
  257. };
  258. static struct gpiod_lookup_table poodle_mci_gpio_table = {
  259. .dev_id = "pxa2xx-mci.0",
  260. .table = {
  261. GPIO_LOOKUP("gpio-pxa", POODLE_GPIO_nSD_DETECT,
  262. "cd", GPIO_ACTIVE_LOW),
  263. GPIO_LOOKUP("gpio-pxa", POODLE_GPIO_nSD_WP,
  264. "wp", GPIO_ACTIVE_LOW),
  265. { },
  266. },
  267. };
  268. /*
  269. * Irda
  270. */
  271. static struct pxaficp_platform_data poodle_ficp_platform_data = {
  272. .gpio_pwdown = POODLE_GPIO_IR_ON,
  273. .transceiver_cap = IR_SIRMODE | IR_OFF,
  274. };
  275. /*
  276. * USB Device Controller
  277. */
  278. static struct pxa2xx_udc_mach_info udc_info __initdata = {
  279. /* no connect GPIO; poodle can't tell connection status */
  280. .gpio_pullup = POODLE_GPIO_USB_PULLUP,
  281. };
  282. /* PXAFB device */
  283. static struct pxafb_mode_info poodle_fb_mode = {
  284. .pixclock = 144700,
  285. .xres = 320,
  286. .yres = 240,
  287. .bpp = 16,
  288. .hsync_len = 7,
  289. .left_margin = 11,
  290. .right_margin = 30,
  291. .vsync_len = 2,
  292. .upper_margin = 2,
  293. .lower_margin = 0,
  294. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  295. };
  296. static struct pxafb_mach_info poodle_fb_info = {
  297. .modes = &poodle_fb_mode,
  298. .num_modes = 1,
  299. .lcd_conn = LCD_COLOR_TFT_16BPP,
  300. };
  301. static uint8_t scan_ff_pattern[] = { 0xff, 0xff };
  302. static struct nand_bbt_descr sharpsl_bbt = {
  303. .options = 0,
  304. .offs = 4,
  305. .len = 2,
  306. .pattern = scan_ff_pattern
  307. };
  308. static const char * const probes[] = {
  309. "cmdlinepart",
  310. "ofpart",
  311. "sharpslpart",
  312. NULL,
  313. };
  314. static struct sharpsl_nand_platform_data sharpsl_nand_platform_data = {
  315. .badblock_pattern = &sharpsl_bbt,
  316. .part_parsers = probes,
  317. };
  318. static struct resource sharpsl_nand_resources[] = {
  319. {
  320. .start = 0x0C000000,
  321. .end = 0x0C000FFF,
  322. .flags = IORESOURCE_MEM,
  323. },
  324. };
  325. static struct platform_device sharpsl_nand_device = {
  326. .name = "sharpsl-nand",
  327. .id = -1,
  328. .resource = sharpsl_nand_resources,
  329. .num_resources = ARRAY_SIZE(sharpsl_nand_resources),
  330. .dev.platform_data = &sharpsl_nand_platform_data,
  331. };
  332. static struct mtd_partition sharpsl_rom_parts[] = {
  333. {
  334. .name ="Boot PROM Filesystem",
  335. .offset = 0x00120000,
  336. .size = MTDPART_SIZ_FULL,
  337. },
  338. };
  339. static struct physmap_flash_data sharpsl_rom_data = {
  340. .width = 2,
  341. .nr_parts = ARRAY_SIZE(sharpsl_rom_parts),
  342. .parts = sharpsl_rom_parts,
  343. };
  344. static struct resource sharpsl_rom_resources[] = {
  345. {
  346. .start = 0x00000000,
  347. .end = 0x007fffff,
  348. .flags = IORESOURCE_MEM,
  349. },
  350. };
  351. static struct platform_device sharpsl_rom_device = {
  352. .name = "physmap-flash",
  353. .id = -1,
  354. .resource = sharpsl_rom_resources,
  355. .num_resources = ARRAY_SIZE(sharpsl_rom_resources),
  356. .dev.platform_data = &sharpsl_rom_data,
  357. };
  358. static struct platform_device *devices[] __initdata = {
  359. &poodle_locomo_device,
  360. &poodle_scoop_device,
  361. &poodle_audio_device,
  362. &sharpsl_nand_device,
  363. &sharpsl_rom_device,
  364. };
  365. static struct i2c_board_info __initdata poodle_i2c_devices[] = {
  366. { I2C_BOARD_INFO("wm8731", 0x1b) },
  367. };
  368. static void poodle_poweroff(void)
  369. {
  370. pxa_restart(REBOOT_HARD, NULL);
  371. }
  372. static void __init poodle_init(void)
  373. {
  374. int ret = 0;
  375. pm_power_off = poodle_poweroff;
  376. PCFR |= PCFR_OPDE;
  377. pxa2xx_mfp_config(ARRAY_AND_SIZE(poodle_pin_config));
  378. pxa_set_ffuart_info(NULL);
  379. pxa_set_btuart_info(NULL);
  380. pxa_set_stuart_info(NULL);
  381. platform_scoop_config = &poodle_pcmcia_config;
  382. ret = platform_add_devices(devices, ARRAY_SIZE(devices));
  383. if (ret)
  384. pr_warn("poodle: Unable to register LoCoMo device\n");
  385. pxa_set_fb_info(&poodle_locomo_device.dev, &poodle_fb_info);
  386. pxa_set_udc_info(&udc_info);
  387. gpiod_add_lookup_table(&poodle_mci_gpio_table);
  388. pxa_set_mci_info(&poodle_mci_platform_data);
  389. pxa_set_ficp_info(&poodle_ficp_platform_data);
  390. pxa_set_i2c_info(NULL);
  391. i2c_register_board_info(0, ARRAY_AND_SIZE(poodle_i2c_devices));
  392. poodle_init_spi();
  393. regulator_has_full_constraints();
  394. }
  395. static void __init fixup_poodle(struct tag *tags, char **cmdline)
  396. {
  397. sharpsl_save_param();
  398. memblock_add(0xa0000000, SZ_32M);
  399. }
  400. MACHINE_START(POODLE, "SHARP Poodle")
  401. .fixup = fixup_poodle,
  402. .map_io = pxa25x_map_io,
  403. .nr_irqs = POODLE_NR_IRQS, /* 4 for LoCoMo */
  404. .init_irq = pxa25x_init_irq,
  405. .handle_irq = pxa25x_handle_irq,
  406. .init_time = pxa_timer_init,
  407. .init_machine = poodle_init,
  408. .restart = pxa_restart,
  409. MACHINE_END