h3600.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  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 <linux/platform_data/irda-sa11x0.h>
  19. #include <mach/h3xxx.h>
  20. #include <mach/irqs.h>
  21. #include "generic.h"
  22. /*
  23. * helper for sa1100fb
  24. */
  25. static struct gpio h3600_lcd_gpio[] = {
  26. { H3XXX_EGPIO_LCD_ON, GPIOF_OUT_INIT_LOW, "LCD power" },
  27. { H3600_EGPIO_LCD_PCI, GPIOF_OUT_INIT_LOW, "LCD control" },
  28. { H3600_EGPIO_LCD_5V_ON, GPIOF_OUT_INIT_LOW, "LCD 5v" },
  29. { H3600_EGPIO_LVDD_ON, GPIOF_OUT_INIT_LOW, "LCD 9v/-6.5v" },
  30. };
  31. static bool h3600_lcd_request(void)
  32. {
  33. static bool h3600_lcd_ok;
  34. int rc;
  35. if (h3600_lcd_ok)
  36. return true;
  37. rc = gpio_request_array(h3600_lcd_gpio, ARRAY_SIZE(h3600_lcd_gpio));
  38. if (rc)
  39. pr_err("%s: can't request GPIOs\n", __func__);
  40. else
  41. h3600_lcd_ok = true;
  42. return h3600_lcd_ok;
  43. }
  44. static void h3600_lcd_power(int enable)
  45. {
  46. if (!h3600_lcd_request())
  47. return;
  48. gpio_direction_output(H3XXX_EGPIO_LCD_ON, enable);
  49. gpio_direction_output(H3600_EGPIO_LCD_PCI, enable);
  50. gpio_direction_output(H3600_EGPIO_LCD_5V_ON, enable);
  51. gpio_direction_output(H3600_EGPIO_LVDD_ON, enable);
  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 struct gpio h3600_irda_gpio[] = {
  79. { H3600_EGPIO_IR_ON, GPIOF_OUT_INIT_LOW, "IrDA power" },
  80. { H3600_EGPIO_IR_FSEL, GPIOF_OUT_INIT_LOW, "IrDA fsel" },
  81. };
  82. static int h3600_irda_set_power(struct device *dev, unsigned int state)
  83. {
  84. gpio_set_value(H3600_EGPIO_IR_ON, state);
  85. return 0;
  86. }
  87. static void h3600_irda_set_speed(struct device *dev, unsigned int speed)
  88. {
  89. gpio_set_value(H3600_EGPIO_IR_FSEL, !(speed < 4000000));
  90. }
  91. static int h3600_irda_startup(struct device *dev)
  92. {
  93. return gpio_request_array(h3600_irda_gpio, sizeof(h3600_irda_gpio));
  94. }
  95. static void h3600_irda_shutdown(struct device *dev)
  96. {
  97. return gpio_free_array(h3600_irda_gpio, sizeof(h3600_irda_gpio));
  98. }
  99. static struct irda_platform_data h3600_irda_data = {
  100. .set_power = h3600_irda_set_power,
  101. .set_speed = h3600_irda_set_speed,
  102. .startup = h3600_irda_startup,
  103. .shutdown = h3600_irda_shutdown,
  104. };
  105. static void __init h3600_mach_init(void)
  106. {
  107. h3xxx_mach_init();
  108. sa11x0_register_lcd(&h3600_lcd_info);
  109. sa11x0_register_irda(&h3600_irda_data);
  110. }
  111. MACHINE_START(H3600, "Compaq iPAQ H3600")
  112. .atag_offset = 0x100,
  113. .map_io = h3600_map_io,
  114. .nr_irqs = SA1100_NR_IRQS,
  115. .init_irq = sa1100_init_irq,
  116. .init_time = sa1100_timer_init,
  117. .init_machine = h3600_mach_init,
  118. .init_late = sa11x0_init_late,
  119. .restart = sa11x0_restart,
  120. MACHINE_END