h3600.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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 <video/sa1100fb.h>
  16. #include <asm/mach-types.h>
  17. #include <asm/mach/arch.h>
  18. #include <asm/mach/irda.h>
  19. #include <mach/h3xxx.h>
  20. #include <mach/irqs.h>
  21. #include "generic.h"
  22. /*
  23. * helper for sa1100fb
  24. */
  25. static void h3600_lcd_power(int enable)
  26. {
  27. if (gpio_request(H3XXX_EGPIO_LCD_ON, "LCD power")) {
  28. pr_err("%s: can't request H3XXX_EGPIO_LCD_ON\n", __func__);
  29. goto err1;
  30. }
  31. if (gpio_request(H3600_EGPIO_LCD_PCI, "LCD control")) {
  32. pr_err("%s: can't request H3XXX_EGPIO_LCD_PCI\n", __func__);
  33. goto err2;
  34. }
  35. if (gpio_request(H3600_EGPIO_LCD_5V_ON, "LCD 5v")) {
  36. pr_err("%s: can't request H3XXX_EGPIO_LCD_5V_ON\n", __func__);
  37. goto err3;
  38. }
  39. if (gpio_request(H3600_EGPIO_LVDD_ON, "LCD 9v/-6.5v")) {
  40. pr_err("%s: can't request H3600_EGPIO_LVDD_ON\n", __func__);
  41. goto err4;
  42. }
  43. gpio_direction_output(H3XXX_EGPIO_LCD_ON, enable);
  44. gpio_direction_output(H3600_EGPIO_LCD_PCI, enable);
  45. gpio_direction_output(H3600_EGPIO_LCD_5V_ON, enable);
  46. gpio_direction_output(H3600_EGPIO_LVDD_ON, enable);
  47. gpio_free(H3600_EGPIO_LVDD_ON);
  48. err4: gpio_free(H3600_EGPIO_LCD_5V_ON);
  49. err3: gpio_free(H3600_EGPIO_LCD_PCI);
  50. err2: gpio_free(H3XXX_EGPIO_LCD_ON);
  51. err1: return;
  52. }
  53. static const struct sa1100fb_rgb h3600_rgb_16 = {
  54. .red = { .offset = 12, .length = 4, },
  55. .green = { .offset = 7, .length = 4, },
  56. .blue = { .offset = 1, .length = 4, },
  57. .transp = { .offset = 0, .length = 0, },
  58. };
  59. static struct sa1100fb_mach_info h3600_lcd_info = {
  60. .pixclock = 174757, .bpp = 16,
  61. .xres = 320, .yres = 240,
  62. .hsync_len = 3, .vsync_len = 3,
  63. .left_margin = 12, .upper_margin = 10,
  64. .right_margin = 17, .lower_margin = 1,
  65. .cmap_static = 1,
  66. .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
  67. .lccr3 = LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2),
  68. .rgb[RGB_16] = &h3600_rgb_16,
  69. .lcd_power = h3600_lcd_power,
  70. };
  71. static void __init h3600_map_io(void)
  72. {
  73. h3xxx_map_io();
  74. }
  75. /*
  76. * This turns the IRDA power on or off on the Compaq H3600
  77. */
  78. static int h3600_irda_set_power(struct device *dev, unsigned int state)
  79. {
  80. gpio_set_value(H3600_EGPIO_IR_ON, state);
  81. return 0;
  82. }
  83. static void h3600_irda_set_speed(struct device *dev, unsigned int speed)
  84. {
  85. gpio_set_value(H3600_EGPIO_IR_FSEL, !(speed < 4000000));
  86. }
  87. static int h3600_irda_startup(struct device *dev)
  88. {
  89. int err = gpio_request(H3600_EGPIO_IR_ON, "IrDA power");
  90. if (err)
  91. goto err1;
  92. err = gpio_direction_output(H3600_EGPIO_IR_ON, 0);
  93. if (err)
  94. goto err2;
  95. err = gpio_request(H3600_EGPIO_IR_FSEL, "IrDA fsel");
  96. if (err)
  97. goto err2;
  98. err = gpio_direction_output(H3600_EGPIO_IR_FSEL, 0);
  99. if (err)
  100. goto err3;
  101. return 0;
  102. err3: gpio_free(H3600_EGPIO_IR_FSEL);
  103. err2: gpio_free(H3600_EGPIO_IR_ON);
  104. err1: return err;
  105. }
  106. static void h3600_irda_shutdown(struct device *dev)
  107. {
  108. gpio_free(H3600_EGPIO_IR_ON);
  109. gpio_free(H3600_EGPIO_IR_FSEL);
  110. }
  111. static struct irda_platform_data h3600_irda_data = {
  112. .set_power = h3600_irda_set_power,
  113. .set_speed = h3600_irda_set_speed,
  114. .startup = h3600_irda_startup,
  115. .shutdown = h3600_irda_shutdown,
  116. };
  117. static struct gpio_default_state h3600_default_gpio[] = {
  118. { H3XXX_GPIO_COM_DCD, GPIO_MODE_IN, "COM DCD" },
  119. { H3XXX_GPIO_COM_CTS, GPIO_MODE_IN, "COM CTS" },
  120. { H3XXX_GPIO_COM_RTS, GPIO_MODE_OUT0, "COM RTS" },
  121. };
  122. static void __init h3600_mach_init(void)
  123. {
  124. h3xxx_init_gpio(h3600_default_gpio, ARRAY_SIZE(h3600_default_gpio));
  125. h3xxx_mach_init();
  126. sa11x0_register_lcd(&h3600_lcd_info);
  127. sa11x0_register_irda(&h3600_irda_data);
  128. }
  129. MACHINE_START(H3600, "Compaq iPAQ H3600")
  130. .atag_offset = 0x100,
  131. .map_io = h3600_map_io,
  132. .nr_irqs = SA1100_NR_IRQS,
  133. .init_irq = sa1100_init_irq,
  134. .timer = &sa1100_timer,
  135. .init_machine = h3600_mach_init,
  136. .restart = sa11x0_restart,
  137. MACHINE_END