h3600.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647
  1. /*
  2. * Hardware definitions for Compaq iPAQ H3xxx Handheld Computers
  3. *
  4. * Copyright 2000,1 Compaq Computer Corporation.
  5. *
  6. * Use consistent with the GNU GPL is permitted,
  7. * provided that this copyright notice is
  8. * preserved in its entirety in all copies and derived works.
  9. *
  10. * COMPAQ COMPUTER CORPORATION MAKES NO WARRANTIES, EXPRESSED OR IMPLIED,
  11. * AS TO THE USEFULNESS OR CORRECTNESS OF THIS CODE OR ITS
  12. * FITNESS FOR ANY PARTICULAR PURPOSE.
  13. *
  14. * Author: Jamey Hicks.
  15. *
  16. * History:
  17. *
  18. * 2001-10-?? Andrew Christian Added support for iPAQ H3800
  19. * and abstracted EGPIO interface.
  20. *
  21. */
  22. #include <linux/module.h>
  23. #include <linux/init.h>
  24. #include <linux/kernel.h>
  25. #include <linux/tty.h>
  26. #include <linux/pm.h>
  27. #include <linux/device.h>
  28. #include <linux/mfd/htc-egpio.h>
  29. #include <linux/mtd/mtd.h>
  30. #include <linux/mtd/partitions.h>
  31. #include <linux/serial_core.h>
  32. #include <linux/gpio.h>
  33. #include <linux/platform_device.h>
  34. #include <asm/irq.h>
  35. #include <mach/hardware.h>
  36. #include <asm/mach-types.h>
  37. #include <asm/setup.h>
  38. #include <asm/mach/irq.h>
  39. #include <asm/mach/arch.h>
  40. #include <asm/mach/flash.h>
  41. #include <asm/mach/irda.h>
  42. #include <asm/mach/map.h>
  43. #include <asm/mach/serial_sa1100.h>
  44. #include <mach/h3600.h>
  45. #include <mach/h3600_gpio.h>
  46. #include "generic.h"
  47. void (*assign_h3600_egpio)(enum ipaq_egpio_type x, int level);
  48. EXPORT_SYMBOL(assign_h3600_egpio);
  49. struct gpio_default_state {
  50. int gpio;
  51. int mode;
  52. const char *name;
  53. };
  54. #define GPIO_MODE_IN -1
  55. #define GPIO_MODE_OUT0 0
  56. #define GPIO_MODE_OUT1 1
  57. static void h3xxx_init_gpio(struct gpio_default_state *s, size_t n)
  58. {
  59. while (n--) {
  60. const char *name = s->name;
  61. int err;
  62. if (!name)
  63. name = "[init]";
  64. err = gpio_request(s->gpio, name);
  65. if (err) {
  66. printk(KERN_ERR "gpio%u: unable to request: %d\n",
  67. s->gpio, err);
  68. continue;
  69. }
  70. if (s->mode >= 0) {
  71. err = gpio_direction_output(s->gpio, s->mode);
  72. } else {
  73. err = gpio_direction_input(s->gpio);
  74. }
  75. if (err) {
  76. printk(KERN_ERR "gpio%u: unable to set direction: %d\n",
  77. s->gpio, err);
  78. continue;
  79. }
  80. if (!s->name)
  81. gpio_free(s->gpio);
  82. s++;
  83. }
  84. }
  85. /*
  86. * H3xxx flash support
  87. */
  88. static struct mtd_partition h3xxx_partitions[] = {
  89. {
  90. .name = "H3XXX boot firmware",
  91. .size = 0x00040000,
  92. .offset = 0,
  93. .mask_flags = MTD_WRITEABLE, /* force read-only */
  94. }, {
  95. .name = "H3XXX rootfs",
  96. .size = MTDPART_SIZ_FULL,
  97. .offset = 0x00040000,
  98. }
  99. };
  100. static void h3xxx_set_vpp(int vpp)
  101. {
  102. gpio_set_value(H3XXX_EGPIO_VPP_ON, vpp);
  103. }
  104. static int h3xxx_flash_init(void)
  105. {
  106. int err = gpio_request(H3XXX_EGPIO_VPP_ON, "Flash Vpp");
  107. if (err)
  108. return err;
  109. err = gpio_direction_output(H3XXX_EGPIO_VPP_ON, 0);
  110. if (err)
  111. gpio_free(H3XXX_EGPIO_VPP_ON);
  112. return err;
  113. }
  114. static void h3xxx_flash_exit(void)
  115. {
  116. gpio_free(H3XXX_EGPIO_VPP_ON);
  117. }
  118. static struct flash_platform_data h3xxx_flash_data = {
  119. .map_name = "cfi_probe",
  120. .set_vpp = h3xxx_set_vpp,
  121. .init = h3xxx_flash_init,
  122. .exit = h3xxx_flash_exit,
  123. .parts = h3xxx_partitions,
  124. .nr_parts = ARRAY_SIZE(h3xxx_partitions),
  125. };
  126. static struct resource h3xxx_flash_resource = {
  127. .start = SA1100_CS0_PHYS,
  128. .end = SA1100_CS0_PHYS + SZ_32M - 1,
  129. .flags = IORESOURCE_MEM,
  130. };
  131. /*
  132. * H3xxx uart support
  133. */
  134. static void h3xxx_uart_set_mctrl(struct uart_port *port, u_int mctrl)
  135. {
  136. if (port->mapbase == _Ser3UTCR0) {
  137. gpio_set_value(H3XXX_GPIO_COM_RTS, !(mctrl & TIOCM_RTS));
  138. }
  139. }
  140. static u_int h3xxx_uart_get_mctrl(struct uart_port *port)
  141. {
  142. u_int ret = TIOCM_CD | TIOCM_CTS | TIOCM_DSR;
  143. if (port->mapbase == _Ser3UTCR0) {
  144. /*
  145. * DCD and CTS bits are inverted in GPLR by RS232 transceiver
  146. */
  147. if (gpio_get_value(H3XXX_GPIO_COM_DCD))
  148. ret &= ~TIOCM_CD;
  149. if (gpio_get_value(H3XXX_GPIO_COM_CTS))
  150. ret &= ~TIOCM_CTS;
  151. }
  152. return ret;
  153. }
  154. static void h3xxx_uart_pm(struct uart_port *port, u_int state, u_int oldstate)
  155. {
  156. if (port->mapbase == _Ser3UTCR0)
  157. if (!gpio_request(H3XXX_EGPIO_RS232_ON, "RS232 transceiver")) {
  158. gpio_direction_output(H3XXX_EGPIO_RS232_ON, !state);
  159. gpio_free(H3XXX_EGPIO_RS232_ON);
  160. }
  161. }
  162. /*
  163. * Enable/Disable wake up events for this serial port.
  164. * Obviously, we only support this on the normal COM port.
  165. */
  166. static int h3xxx_uart_set_wake(struct uart_port *port, u_int enable)
  167. {
  168. int err = -EINVAL;
  169. if (port->mapbase == _Ser3UTCR0) {
  170. if (enable)
  171. PWER |= PWER_GPIO23 | PWER_GPIO25; /* DCD and CTS */
  172. else
  173. PWER &= ~(PWER_GPIO23 | PWER_GPIO25); /* DCD and CTS */
  174. err = 0;
  175. }
  176. return err;
  177. }
  178. static struct sa1100_port_fns h3xxx_port_fns __initdata = {
  179. .set_mctrl = h3xxx_uart_set_mctrl,
  180. .get_mctrl = h3xxx_uart_get_mctrl,
  181. .pm = h3xxx_uart_pm,
  182. .set_wake = h3xxx_uart_set_wake,
  183. };
  184. /*
  185. * EGPIO
  186. */
  187. static struct resource egpio_resources[] = {
  188. [0] = {
  189. .start = H3600_EGPIO_PHYS,
  190. .end = H3600_EGPIO_PHYS + 0x4 - 1,
  191. .flags = IORESOURCE_MEM,
  192. },
  193. };
  194. static struct htc_egpio_chip egpio_chips[] = {
  195. [0] = {
  196. .reg_start = 0,
  197. .gpio_base = H3XXX_EGPIO_BASE,
  198. .num_gpios = 16,
  199. .direction = HTC_EGPIO_OUTPUT,
  200. .initial_values = 0x0080, /* H3XXX_EGPIO_RS232_ON */
  201. },
  202. };
  203. static struct htc_egpio_platform_data egpio_info = {
  204. .reg_width = 16,
  205. .bus_width = 16,
  206. .chip = egpio_chips,
  207. .num_chips = ARRAY_SIZE(egpio_chips),
  208. };
  209. static struct platform_device h3xxx_egpio = {
  210. .name = "htc-egpio",
  211. .id = -1,
  212. .resource = egpio_resources,
  213. .num_resources = ARRAY_SIZE(egpio_resources),
  214. .dev = {
  215. .platform_data = &egpio_info,
  216. },
  217. };
  218. static struct platform_device *h3xxx_devices[] = {
  219. &h3xxx_egpio,
  220. };
  221. static void __init h3xxx_mach_init(void)
  222. {
  223. sa1100_register_uart_fns(&h3xxx_port_fns);
  224. sa11x0_register_mtd(&h3xxx_flash_data, &h3xxx_flash_resource, 1);
  225. platform_add_devices(h3xxx_devices, ARRAY_SIZE(h3xxx_devices));
  226. }
  227. static struct map_desc h3600_io_desc[] __initdata = {
  228. { /* static memory bank 2 CS#2 */
  229. .virtual = H3600_BANK_2_VIRT,
  230. .pfn = __phys_to_pfn(SA1100_CS2_PHYS),
  231. .length = 0x02800000,
  232. .type = MT_DEVICE
  233. }, { /* static memory bank 4 CS#4 */
  234. .virtual = H3600_BANK_4_VIRT,
  235. .pfn = __phys_to_pfn(SA1100_CS4_PHYS),
  236. .length = 0x00800000,
  237. .type = MT_DEVICE
  238. }, { /* EGPIO 0 CS#5 */
  239. .virtual = H3600_EGPIO_VIRT,
  240. .pfn = __phys_to_pfn(H3600_EGPIO_PHYS),
  241. .length = 0x01000000,
  242. .type = MT_DEVICE
  243. }
  244. };
  245. /*
  246. * Common map_io initialization
  247. */
  248. static void __init h3xxx_map_io(void)
  249. {
  250. sa1100_map_io();
  251. iotable_init(h3600_io_desc, ARRAY_SIZE(h3600_io_desc));
  252. sa1100_register_uart(0, 3); /* Common serial port */
  253. // sa1100_register_uart(1, 1); /* Microcontroller on 3100/3600 */
  254. /* Ensure those pins are outputs and driving low */
  255. PPDR |= PPC_TXD4 | PPC_SCLK | PPC_SFRM;
  256. PPSR &= ~(PPC_TXD4 | PPC_SCLK | PPC_SFRM);
  257. /* Configure suspend conditions */
  258. PGSR = 0;
  259. PWER = PWER_GPIO0;
  260. PCFR = PCFR_OPDE;
  261. PSDR = 0;
  262. }
  263. /************************* H3100 *************************/
  264. #ifdef CONFIG_SA1100_H3100
  265. #define H3100_EGPIO (*(volatile unsigned int *)H3600_EGPIO_VIRT)
  266. static unsigned int h3100_egpio = 0;
  267. static void h3100_control_egpio(enum ipaq_egpio_type x, int setp)
  268. {
  269. unsigned int egpio = 0;
  270. long gpio = 0;
  271. unsigned long flags;
  272. switch (x) {
  273. case IPAQ_EGPIO_LCD_POWER:
  274. egpio |= EGPIO_H3600_LCD_ON;
  275. gpio |= GPIO_H3100_LCD_3V_ON;
  276. break;
  277. case IPAQ_EGPIO_LCD_ENABLE:
  278. break;
  279. case IPAQ_EGPIO_CODEC_NRESET:
  280. egpio |= EGPIO_H3600_CODEC_NRESET;
  281. break;
  282. case IPAQ_EGPIO_AUDIO_ON:
  283. gpio |= GPIO_H3100_AUD_PWR_ON
  284. | GPIO_H3100_AUD_ON;
  285. break;
  286. case IPAQ_EGPIO_QMUTE:
  287. gpio |= GPIO_H3100_QMUTE;
  288. break;
  289. case IPAQ_EGPIO_OPT_NVRAM_ON:
  290. egpio |= EGPIO_H3600_OPT_NVRAM_ON;
  291. break;
  292. case IPAQ_EGPIO_OPT_ON:
  293. egpio |= EGPIO_H3600_OPT_ON;
  294. break;
  295. case IPAQ_EGPIO_CARD_RESET:
  296. egpio |= EGPIO_H3600_CARD_RESET;
  297. break;
  298. case IPAQ_EGPIO_OPT_RESET:
  299. egpio |= EGPIO_H3600_OPT_RESET;
  300. break;
  301. case IPAQ_EGPIO_IR_ON:
  302. gpio |= GPIO_H3100_IR_ON;
  303. break;
  304. case IPAQ_EGPIO_IR_FSEL:
  305. gpio |= GPIO_H3100_IR_FSEL;
  306. break;
  307. case IPAQ_EGPIO_RS232_ON:
  308. egpio |= EGPIO_H3600_RS232_ON;
  309. break;
  310. case IPAQ_EGPIO_VPP_ON:
  311. egpio |= EGPIO_H3600_VPP_ON;
  312. break;
  313. }
  314. if (egpio || gpio) {
  315. local_irq_save(flags);
  316. if (setp) {
  317. h3100_egpio |= egpio;
  318. GPSR = gpio;
  319. } else {
  320. h3100_egpio &= ~egpio;
  321. GPCR = gpio;
  322. }
  323. H3100_EGPIO = h3100_egpio;
  324. local_irq_restore(flags);
  325. }
  326. }
  327. #define H3100_DIRECT_EGPIO (GPIO_H3100_BT_ON \
  328. | GPIO_H3100_GPIO3 \
  329. | GPIO_H3100_QMUTE \
  330. | GPIO_H3100_LCD_3V_ON \
  331. | GPIO_H3100_AUD_ON \
  332. | GPIO_H3100_AUD_PWR_ON \
  333. | GPIO_H3100_IR_ON \
  334. | GPIO_H3100_IR_FSEL)
  335. /*
  336. * helper for sa1100fb
  337. */
  338. static void h3100_lcd_power(int enable)
  339. {
  340. if (!gpio_request(H3XXX_EGPIO_LCD_ON, "LCD ON")) {
  341. gpio_set_value(H3100_GPIO_LCD_3V_ON, enable);
  342. gpio_direction_output(H3XXX_EGPIO_LCD_ON, enable);
  343. gpio_free(H3XXX_EGPIO_LCD_ON);
  344. }
  345. }
  346. static void __init h3100_map_io(void)
  347. {
  348. h3xxx_map_io();
  349. sa1100fb_lcd_power = h3100_lcd_power;
  350. /* Initialize h3100-specific values here */
  351. GPCR = 0x0fffffff; /* All outputs are set low by default */
  352. GPDR = GPIO_H3600_L3_CLOCK |
  353. GPIO_H3600_L3_MODE | GPIO_H3600_L3_DATA |
  354. GPIO_H3600_CLK_SET1 | GPIO_H3600_CLK_SET0 |
  355. H3100_DIRECT_EGPIO;
  356. /* Older bootldrs put GPIO2-9 in alternate mode on the
  357. assumption that they are used for video */
  358. GAFR &= ~H3100_DIRECT_EGPIO;
  359. H3100_EGPIO = h3100_egpio;
  360. assign_h3600_egpio = h3100_control_egpio;
  361. }
  362. /*
  363. * This turns the IRDA power on or off on the Compaq H3100
  364. */
  365. static int h3100_irda_set_power(struct device *dev, unsigned int state)
  366. {
  367. gpio_set_value(H3100_GPIO_IR_ON, state);
  368. return 0;
  369. }
  370. static void h3100_irda_set_speed(struct device *dev, unsigned int speed)
  371. {
  372. gpio_set_value(H3100_GPIO_IR_FSEL, !(speed < 4000000));
  373. }
  374. static struct irda_platform_data h3100_irda_data = {
  375. .set_power = h3100_irda_set_power,
  376. .set_speed = h3100_irda_set_speed,
  377. };
  378. static struct gpio_default_state h3100_default_gpio[] = {
  379. { H3100_GPIO_IR_ON, GPIO_MODE_OUT0, "IrDA power" },
  380. { H3100_GPIO_IR_FSEL, GPIO_MODE_OUT0, "IrDA fsel" },
  381. { H3XXX_GPIO_COM_DCD, GPIO_MODE_IN, "COM DCD" },
  382. { H3XXX_GPIO_COM_CTS, GPIO_MODE_IN, "COM CTS" },
  383. { H3XXX_GPIO_COM_RTS, GPIO_MODE_OUT0, "COM RTS" },
  384. { H3100_GPIO_LCD_3V_ON, GPIO_MODE_OUT0, "LCD 3v" },
  385. };
  386. static void __init h3100_mach_init(void)
  387. {
  388. h3xxx_init_gpio(h3100_default_gpio, ARRAY_SIZE(h3100_default_gpio));
  389. h3xxx_mach_init();
  390. sa11x0_register_irda(&h3100_irda_data);
  391. }
  392. MACHINE_START(H3100, "Compaq iPAQ H3100")
  393. .phys_io = 0x80000000,
  394. .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc,
  395. .boot_params = 0xc0000100,
  396. .map_io = h3100_map_io,
  397. .init_irq = sa1100_init_irq,
  398. .timer = &sa1100_timer,
  399. .init_machine = h3100_mach_init,
  400. MACHINE_END
  401. #endif /* CONFIG_SA1100_H3100 */
  402. /************************* H3600 *************************/
  403. #ifdef CONFIG_SA1100_H3600
  404. #define H3600_EGPIO (*(volatile unsigned int *)H3600_EGPIO_VIRT)
  405. static unsigned int h3600_egpio = EGPIO_H3600_RS232_ON;
  406. static void h3600_control_egpio(enum ipaq_egpio_type x, int setp)
  407. {
  408. unsigned int egpio = 0;
  409. unsigned long flags;
  410. switch (x) {
  411. case IPAQ_EGPIO_LCD_POWER:
  412. egpio |= EGPIO_H3600_LCD_ON |
  413. EGPIO_H3600_LCD_PCI |
  414. EGPIO_H3600_LCD_5V_ON |
  415. EGPIO_H3600_LVDD_ON;
  416. break;
  417. case IPAQ_EGPIO_LCD_ENABLE:
  418. break;
  419. case IPAQ_EGPIO_CODEC_NRESET:
  420. egpio |= EGPIO_H3600_CODEC_NRESET;
  421. break;
  422. case IPAQ_EGPIO_AUDIO_ON:
  423. egpio |= EGPIO_H3600_AUD_AMP_ON |
  424. EGPIO_H3600_AUD_PWR_ON;
  425. break;
  426. case IPAQ_EGPIO_QMUTE:
  427. egpio |= EGPIO_H3600_QMUTE;
  428. break;
  429. case IPAQ_EGPIO_OPT_NVRAM_ON:
  430. egpio |= EGPIO_H3600_OPT_NVRAM_ON;
  431. break;
  432. case IPAQ_EGPIO_OPT_ON:
  433. egpio |= EGPIO_H3600_OPT_ON;
  434. break;
  435. case IPAQ_EGPIO_CARD_RESET:
  436. egpio |= EGPIO_H3600_CARD_RESET;
  437. break;
  438. case IPAQ_EGPIO_OPT_RESET:
  439. egpio |= EGPIO_H3600_OPT_RESET;
  440. break;
  441. case IPAQ_EGPIO_IR_ON:
  442. egpio |= EGPIO_H3600_IR_ON;
  443. break;
  444. case IPAQ_EGPIO_IR_FSEL:
  445. egpio |= EGPIO_H3600_IR_FSEL;
  446. break;
  447. case IPAQ_EGPIO_RS232_ON:
  448. egpio |= EGPIO_H3600_RS232_ON;
  449. break;
  450. case IPAQ_EGPIO_VPP_ON:
  451. egpio |= EGPIO_H3600_VPP_ON;
  452. break;
  453. }
  454. if (egpio) {
  455. local_irq_save(flags);
  456. if (setp)
  457. h3600_egpio |= egpio;
  458. else
  459. h3600_egpio &= ~egpio;
  460. H3600_EGPIO = h3600_egpio;
  461. local_irq_restore(flags);
  462. }
  463. }
  464. /*
  465. * helper for sa1100fb
  466. */
  467. static void h3600_lcd_power(int enable)
  468. {
  469. if (gpio_request(H3XXX_EGPIO_LCD_ON, "LCD power"))
  470. goto err1;
  471. if (gpio_request(H3600_EGPIO_LCD_PCI, "LCD control"))
  472. goto err2;
  473. if (gpio_request(H3600_EGPIO_LCD_5V_ON, "LCD 5v"))
  474. goto err3;
  475. if (gpio_request(H3600_EGPIO_LVDD_ON, "LCD 9v/-6.5v"))
  476. goto err4;
  477. gpio_direction_output(H3XXX_EGPIO_LCD_ON, enable);
  478. gpio_direction_output(H3600_EGPIO_LCD_PCI, enable);
  479. gpio_direction_output(H3600_EGPIO_LCD_5V_ON, enable);
  480. gpio_direction_output(H3600_EGPIO_LVDD_ON, enable);
  481. gpio_free(H3600_EGPIO_LVDD_ON);
  482. err4: gpio_free(H3600_EGPIO_LCD_5V_ON);
  483. err3: gpio_free(H3600_EGPIO_LCD_PCI);
  484. err2: gpio_free(H3XXX_EGPIO_LCD_ON);
  485. err1: return;
  486. }
  487. static void __init h3600_map_io(void)
  488. {
  489. h3xxx_map_io();
  490. sa1100fb_lcd_power = h3600_lcd_power;
  491. /* Initialize h3600-specific values here */
  492. GPCR = 0x0fffffff; /* All outputs are set low by default */
  493. GPDR = GPIO_H3600_L3_CLOCK |
  494. GPIO_H3600_L3_MODE | GPIO_H3600_L3_DATA |
  495. GPIO_H3600_CLK_SET1 | GPIO_H3600_CLK_SET0;
  496. H3600_EGPIO = h3600_egpio; /* Maintains across sleep? */
  497. assign_h3600_egpio = h3600_control_egpio;
  498. }
  499. /*
  500. * This turns the IRDA power on or off on the Compaq H3600
  501. */
  502. static int h3600_irda_set_power(struct device *dev, unsigned int state)
  503. {
  504. gpio_set_value(H3600_EGPIO_IR_ON, state);
  505. return 0;
  506. }
  507. static void h3600_irda_set_speed(struct device *dev, unsigned int speed)
  508. {
  509. gpio_set_value(H3600_EGPIO_IR_FSEL, !(speed < 4000000));
  510. }
  511. static int h3600_irda_startup(struct device *dev)
  512. {
  513. int err = gpio_request(H3600_EGPIO_IR_ON, "IrDA power");
  514. if (err)
  515. goto err1;
  516. err = gpio_direction_output(H3600_EGPIO_IR_ON, 0);
  517. if (err)
  518. goto err2;
  519. err = gpio_request(H3600_EGPIO_IR_FSEL, "IrDA fsel");
  520. if (err)
  521. goto err2;
  522. err = gpio_direction_output(H3600_EGPIO_IR_FSEL, 0);
  523. if (err)
  524. goto err3;
  525. return 0;
  526. err3: gpio_free(H3600_EGPIO_IR_FSEL);
  527. err2: gpio_free(H3600_EGPIO_IR_ON);
  528. err1: return err;
  529. }
  530. static void h3600_irda_shutdown(struct device *dev)
  531. {
  532. gpio_free(H3600_EGPIO_IR_ON);
  533. gpio_free(H3600_EGPIO_IR_FSEL);
  534. }
  535. static struct irda_platform_data h3600_irda_data = {
  536. .set_power = h3600_irda_set_power,
  537. .set_speed = h3600_irda_set_speed,
  538. .startup = h3600_irda_startup,
  539. .shutdown = h3600_irda_shutdown,
  540. };
  541. static struct gpio_default_state h3600_default_gpio[] = {
  542. { H3XXX_GPIO_COM_DCD, GPIO_MODE_IN, "COM DCD" },
  543. { H3XXX_GPIO_COM_CTS, GPIO_MODE_IN, "COM CTS" },
  544. { H3XXX_GPIO_COM_RTS, GPIO_MODE_OUT0, "COM RTS" },
  545. };
  546. static void __init h3600_mach_init(void)
  547. {
  548. h3xxx_init_gpio(h3600_default_gpio, ARRAY_SIZE(h3600_default_gpio));
  549. h3xxx_mach_init();
  550. sa11x0_register_irda(&h3600_irda_data);
  551. }
  552. MACHINE_START(H3600, "Compaq iPAQ H3600")
  553. .phys_io = 0x80000000,
  554. .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc,
  555. .boot_params = 0xc0000100,
  556. .map_io = h3600_map_io,
  557. .init_irq = sa1100_init_irq,
  558. .timer = &sa1100_timer,
  559. .init_machine = h3600_mach_init,
  560. MACHINE_END
  561. #endif /* CONFIG_SA1100_H3600 */