h3600.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /*
  2. * Support for Compaq iPAQ H3600 handheld computer
  3. *
  4. * Copyright (c) 2000,1 Compaq Computer Corporation. (Author: Jamey Hicks)
  5. * Copyright (c) 2009 Dmitry Artamonow <mad_soft@inbox.ru>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. */
  12. #include <linux/module.h>
  13. #include <linux/init.h>
  14. #include <linux/kernel.h>
  15. #include <linux/tty.h>
  16. #include <linux/pm.h>
  17. #include <linux/device.h>
  18. #include <linux/mfd/htc-egpio.h>
  19. #include <linux/mtd/mtd.h>
  20. #include <linux/mtd/partitions.h>
  21. #include <linux/serial_core.h>
  22. #include <linux/gpio.h>
  23. #include <linux/platform_device.h>
  24. #include <asm/irq.h>
  25. #include <mach/hardware.h>
  26. #include <asm/mach-types.h>
  27. #include <asm/setup.h>
  28. #include <asm/mach/irq.h>
  29. #include <asm/mach/arch.h>
  30. #include <asm/mach/flash.h>
  31. #include <asm/mach/irda.h>
  32. #include <asm/mach/map.h>
  33. #include <asm/mach/serial_sa1100.h>
  34. #include <mach/h3xxx.h>
  35. #include "generic.h"
  36. /*
  37. * helper for sa1100fb
  38. */
  39. static void h3600_lcd_power(int enable)
  40. {
  41. if (gpio_request(H3XXX_EGPIO_LCD_ON, "LCD power"))
  42. goto err1;
  43. if (gpio_request(H3600_EGPIO_LCD_PCI, "LCD control"))
  44. goto err2;
  45. if (gpio_request(H3600_EGPIO_LCD_5V_ON, "LCD 5v"))
  46. goto err3;
  47. if (gpio_request(H3600_EGPIO_LVDD_ON, "LCD 9v/-6.5v"))
  48. goto err4;
  49. gpio_direction_output(H3XXX_EGPIO_LCD_ON, enable);
  50. gpio_direction_output(H3600_EGPIO_LCD_PCI, enable);
  51. gpio_direction_output(H3600_EGPIO_LCD_5V_ON, enable);
  52. gpio_direction_output(H3600_EGPIO_LVDD_ON, enable);
  53. gpio_free(H3600_EGPIO_LVDD_ON);
  54. err4: gpio_free(H3600_EGPIO_LCD_5V_ON);
  55. err3: gpio_free(H3600_EGPIO_LCD_PCI);
  56. err2: gpio_free(H3XXX_EGPIO_LCD_ON);
  57. err1: return;
  58. }
  59. static void __init h3600_map_io(void)
  60. {
  61. h3xxx_map_io();
  62. sa1100fb_lcd_power = h3600_lcd_power;
  63. }
  64. /*
  65. * This turns the IRDA power on or off on the Compaq H3600
  66. */
  67. static int h3600_irda_set_power(struct device *dev, unsigned int state)
  68. {
  69. gpio_set_value(H3600_EGPIO_IR_ON, state);
  70. return 0;
  71. }
  72. static void h3600_irda_set_speed(struct device *dev, unsigned int speed)
  73. {
  74. gpio_set_value(H3600_EGPIO_IR_FSEL, !(speed < 4000000));
  75. }
  76. static int h3600_irda_startup(struct device *dev)
  77. {
  78. int err = gpio_request(H3600_EGPIO_IR_ON, "IrDA power");
  79. if (err)
  80. goto err1;
  81. err = gpio_direction_output(H3600_EGPIO_IR_ON, 0);
  82. if (err)
  83. goto err2;
  84. err = gpio_request(H3600_EGPIO_IR_FSEL, "IrDA fsel");
  85. if (err)
  86. goto err2;
  87. err = gpio_direction_output(H3600_EGPIO_IR_FSEL, 0);
  88. if (err)
  89. goto err3;
  90. return 0;
  91. err3: gpio_free(H3600_EGPIO_IR_FSEL);
  92. err2: gpio_free(H3600_EGPIO_IR_ON);
  93. err1: return err;
  94. }
  95. static void h3600_irda_shutdown(struct device *dev)
  96. {
  97. gpio_free(H3600_EGPIO_IR_ON);
  98. gpio_free(H3600_EGPIO_IR_FSEL);
  99. }
  100. static struct irda_platform_data h3600_irda_data = {
  101. .set_power = h3600_irda_set_power,
  102. .set_speed = h3600_irda_set_speed,
  103. .startup = h3600_irda_startup,
  104. .shutdown = h3600_irda_shutdown,
  105. };
  106. static struct gpio_default_state h3600_default_gpio[] = {
  107. { H3XXX_GPIO_COM_DCD, GPIO_MODE_IN, "COM DCD" },
  108. { H3XXX_GPIO_COM_CTS, GPIO_MODE_IN, "COM CTS" },
  109. { H3XXX_GPIO_COM_RTS, GPIO_MODE_OUT0, "COM RTS" },
  110. };
  111. static void __init h3600_mach_init(void)
  112. {
  113. h3xxx_init_gpio(h3600_default_gpio, ARRAY_SIZE(h3600_default_gpio));
  114. h3xxx_mach_init();
  115. sa11x0_register_irda(&h3600_irda_data);
  116. }
  117. MACHINE_START(H3600, "Compaq iPAQ H3600")
  118. .phys_io = 0x80000000,
  119. .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc,
  120. .boot_params = 0xc0000100,
  121. .map_io = h3600_map_io,
  122. .init_irq = sa1100_init_irq,
  123. .timer = &sa1100_timer,
  124. .init_machine = h3600_mach_init,
  125. MACHINE_END