h3600.c 4.0 KB

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