h3600.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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/init.h>
  13. #include <linux/kernel.h>
  14. #include <linux/gpio.h>
  15. #include <asm/mach-types.h>
  16. #include <asm/mach/arch.h>
  17. #include <asm/mach/irda.h>
  18. #include <mach/h3xxx.h>
  19. #include "generic.h"
  20. /*
  21. * helper for sa1100fb
  22. */
  23. static void h3600_lcd_power(int enable)
  24. {
  25. if (gpio_request(H3XXX_EGPIO_LCD_ON, "LCD power")) {
  26. pr_err("%s: can't request H3XXX_EGPIO_LCD_ON\n", __func__);
  27. goto err1;
  28. }
  29. if (gpio_request(H3600_EGPIO_LCD_PCI, "LCD control")) {
  30. pr_err("%s: can't request H3XXX_EGPIO_LCD_PCI\n", __func__);
  31. goto err2;
  32. }
  33. if (gpio_request(H3600_EGPIO_LCD_5V_ON, "LCD 5v")) {
  34. pr_err("%s: can't request H3XXX_EGPIO_LCD_5V_ON\n", __func__);
  35. goto err3;
  36. }
  37. if (gpio_request(H3600_EGPIO_LVDD_ON, "LCD 9v/-6.5v")) {
  38. pr_err("%s: can't request H3600_EGPIO_LVDD_ON\n", __func__);
  39. goto err4;
  40. }
  41. gpio_direction_output(H3XXX_EGPIO_LCD_ON, enable);
  42. gpio_direction_output(H3600_EGPIO_LCD_PCI, enable);
  43. gpio_direction_output(H3600_EGPIO_LCD_5V_ON, enable);
  44. gpio_direction_output(H3600_EGPIO_LVDD_ON, enable);
  45. gpio_free(H3600_EGPIO_LVDD_ON);
  46. err4: gpio_free(H3600_EGPIO_LCD_5V_ON);
  47. err3: gpio_free(H3600_EGPIO_LCD_PCI);
  48. err2: gpio_free(H3XXX_EGPIO_LCD_ON);
  49. err1: return;
  50. }
  51. static void __init h3600_map_io(void)
  52. {
  53. h3xxx_map_io();
  54. sa1100fb_lcd_power = h3600_lcd_power;
  55. }
  56. /*
  57. * This turns the IRDA power on or off on the Compaq H3600
  58. */
  59. static int h3600_irda_set_power(struct device *dev, unsigned int state)
  60. {
  61. gpio_set_value(H3600_EGPIO_IR_ON, state);
  62. return 0;
  63. }
  64. static void h3600_irda_set_speed(struct device *dev, unsigned int speed)
  65. {
  66. gpio_set_value(H3600_EGPIO_IR_FSEL, !(speed < 4000000));
  67. }
  68. static int h3600_irda_startup(struct device *dev)
  69. {
  70. int err = gpio_request(H3600_EGPIO_IR_ON, "IrDA power");
  71. if (err)
  72. goto err1;
  73. err = gpio_direction_output(H3600_EGPIO_IR_ON, 0);
  74. if (err)
  75. goto err2;
  76. err = gpio_request(H3600_EGPIO_IR_FSEL, "IrDA fsel");
  77. if (err)
  78. goto err2;
  79. err = gpio_direction_output(H3600_EGPIO_IR_FSEL, 0);
  80. if (err)
  81. goto err3;
  82. return 0;
  83. err3: gpio_free(H3600_EGPIO_IR_FSEL);
  84. err2: gpio_free(H3600_EGPIO_IR_ON);
  85. err1: return err;
  86. }
  87. static void h3600_irda_shutdown(struct device *dev)
  88. {
  89. gpio_free(H3600_EGPIO_IR_ON);
  90. gpio_free(H3600_EGPIO_IR_FSEL);
  91. }
  92. static struct irda_platform_data h3600_irda_data = {
  93. .set_power = h3600_irda_set_power,
  94. .set_speed = h3600_irda_set_speed,
  95. .startup = h3600_irda_startup,
  96. .shutdown = h3600_irda_shutdown,
  97. };
  98. static struct gpio_default_state h3600_default_gpio[] = {
  99. { H3XXX_GPIO_COM_DCD, GPIO_MODE_IN, "COM DCD" },
  100. { H3XXX_GPIO_COM_CTS, GPIO_MODE_IN, "COM CTS" },
  101. { H3XXX_GPIO_COM_RTS, GPIO_MODE_OUT0, "COM RTS" },
  102. };
  103. static void __init h3600_mach_init(void)
  104. {
  105. h3xxx_init_gpio(h3600_default_gpio, ARRAY_SIZE(h3600_default_gpio));
  106. h3xxx_mach_init();
  107. sa11x0_register_irda(&h3600_irda_data);
  108. }
  109. MACHINE_START(H3600, "Compaq iPAQ H3600")
  110. .phys_io = 0x80000000,
  111. .io_pg_offst = ((0xf8000000) >> 18) & 0xfffc,
  112. .boot_params = 0xc0000100,
  113. .map_io = h3600_map_io,
  114. .init_irq = sa1100_init_irq,
  115. .timer = &sa1100_timer,
  116. .init_machine = h3600_mach_init,
  117. MACHINE_END