h3600.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * Support for Compaq iPAQ H3600 handheld computer
  4. *
  5. * Copyright (c) 2000,1 Compaq Computer Corporation. (Author: Jamey Hicks)
  6. * Copyright (c) 2009 Dmitry Artamonow <[email protected]>
  7. */
  8. #include <linux/init.h>
  9. #include <linux/kernel.h>
  10. #include <linux/gpio.h>
  11. #include <video/sa1100fb.h>
  12. #include <asm/mach-types.h>
  13. #include <asm/mach/arch.h>
  14. #include <linux/platform_data/irda-sa11x0.h>
  15. #include <mach/h3xxx.h>
  16. #include <mach/irqs.h>
  17. #include "generic.h"
  18. /*
  19. * helper for sa1100fb
  20. */
  21. static struct gpio h3600_lcd_gpio[] = {
  22. { H3XXX_EGPIO_LCD_ON, GPIOF_OUT_INIT_LOW, "LCD power" },
  23. { H3600_EGPIO_LCD_PCI, GPIOF_OUT_INIT_LOW, "LCD control" },
  24. { H3600_EGPIO_LCD_5V_ON, GPIOF_OUT_INIT_LOW, "LCD 5v" },
  25. { H3600_EGPIO_LVDD_ON, GPIOF_OUT_INIT_LOW, "LCD 9v/-6.5v" },
  26. };
  27. static bool h3600_lcd_request(void)
  28. {
  29. static bool h3600_lcd_ok;
  30. int rc;
  31. if (h3600_lcd_ok)
  32. return true;
  33. rc = gpio_request_array(h3600_lcd_gpio, ARRAY_SIZE(h3600_lcd_gpio));
  34. if (rc)
  35. pr_err("%s: can't request GPIOs\n", __func__);
  36. else
  37. h3600_lcd_ok = true;
  38. return h3600_lcd_ok;
  39. }
  40. static void h3600_lcd_power(int enable)
  41. {
  42. if (!h3600_lcd_request())
  43. return;
  44. gpio_direction_output(H3XXX_EGPIO_LCD_ON, enable);
  45. gpio_direction_output(H3600_EGPIO_LCD_PCI, enable);
  46. gpio_direction_output(H3600_EGPIO_LCD_5V_ON, enable);
  47. gpio_direction_output(H3600_EGPIO_LVDD_ON, enable);
  48. }
  49. static const struct sa1100fb_rgb h3600_rgb_16 = {
  50. .red = { .offset = 12, .length = 4, },
  51. .green = { .offset = 7, .length = 4, },
  52. .blue = { .offset = 1, .length = 4, },
  53. .transp = { .offset = 0, .length = 0, },
  54. };
  55. static struct sa1100fb_mach_info h3600_lcd_info = {
  56. .pixclock = 174757, .bpp = 16,
  57. .xres = 320, .yres = 240,
  58. .hsync_len = 3, .vsync_len = 3,
  59. .left_margin = 12, .upper_margin = 10,
  60. .right_margin = 17, .lower_margin = 1,
  61. .cmap_static = 1,
  62. .lccr0 = LCCR0_Color | LCCR0_Sngl | LCCR0_Act,
  63. .lccr3 = LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2),
  64. .rgb[RGB_16] = &h3600_rgb_16,
  65. .lcd_power = h3600_lcd_power,
  66. };
  67. static void __init h3600_map_io(void)
  68. {
  69. h3xxx_map_io();
  70. }
  71. /*
  72. * This turns the IRDA power on or off on the Compaq H3600
  73. */
  74. static struct gpio h3600_irda_gpio[] = {
  75. { H3600_EGPIO_IR_ON, GPIOF_OUT_INIT_LOW, "IrDA power" },
  76. { H3600_EGPIO_IR_FSEL, GPIOF_OUT_INIT_LOW, "IrDA fsel" },
  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. return gpio_request_array(h3600_irda_gpio, sizeof(h3600_irda_gpio));
  90. }
  91. static void h3600_irda_shutdown(struct device *dev)
  92. {
  93. return gpio_free_array(h3600_irda_gpio, sizeof(h3600_irda_gpio));
  94. }
  95. static struct irda_platform_data h3600_irda_data = {
  96. .set_power = h3600_irda_set_power,
  97. .set_speed = h3600_irda_set_speed,
  98. .startup = h3600_irda_startup,
  99. .shutdown = h3600_irda_shutdown,
  100. };
  101. static void __init h3600_mach_init(void)
  102. {
  103. h3xxx_mach_init();
  104. sa11x0_register_lcd(&h3600_lcd_info);
  105. sa11x0_register_irda(&h3600_irda_data);
  106. }
  107. MACHINE_START(H3600, "Compaq iPAQ H3600")
  108. .atag_offset = 0x100,
  109. .map_io = h3600_map_io,
  110. .nr_irqs = SA1100_NR_IRQS,
  111. .init_irq = sa1100_init_irq,
  112. .init_time = sa1100_timer_init,
  113. .init_machine = h3600_mach_init,
  114. .init_late = sa11x0_init_late,
  115. .restart = sa11x0_restart,
  116. MACHINE_END