h3100.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /*
  2. * Support for Compaq iPAQ H3100 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 h3100_lcd_gpio[] = {
  26. { H3100_GPIO_LCD_3V_ON, GPIOF_OUT_INIT_LOW, "LCD 3V" },
  27. { H3XXX_EGPIO_LCD_ON, GPIOF_OUT_INIT_LOW, "LCD ON" },
  28. };
  29. static bool h3100_lcd_request(void)
  30. {
  31. static bool h3100_lcd_ok;
  32. int rc;
  33. if (h3100_lcd_ok)
  34. return true;
  35. rc = gpio_request_array(h3100_lcd_gpio, ARRAY_SIZE(h3100_lcd_gpio));
  36. if (rc)
  37. pr_err("%s: can't request GPIOs\n", __func__);
  38. else
  39. h3100_lcd_ok = true;
  40. return h3100_lcd_ok;
  41. }
  42. static void h3100_lcd_power(int enable)
  43. {
  44. if (!h3100_lcd_request())
  45. return;
  46. gpio_set_value(H3100_GPIO_LCD_3V_ON, enable);
  47. gpio_set_value(H3XXX_EGPIO_LCD_ON, enable);
  48. }
  49. static struct sa1100fb_mach_info h3100_lcd_info = {
  50. .pixclock = 406977, .bpp = 4,
  51. .xres = 320, .yres = 240,
  52. .hsync_len = 26, .vsync_len = 41,
  53. .left_margin = 4, .upper_margin = 0,
  54. .right_margin = 4, .lower_margin = 0,
  55. .sync = FB_SYNC_HOR_HIGH_ACT | FB_SYNC_VERT_HIGH_ACT,
  56. .cmap_greyscale = 1,
  57. .cmap_inverse = 1,
  58. .lccr0 = LCCR0_Mono | LCCR0_4PixMono | LCCR0_Sngl | LCCR0_Pas,
  59. .lccr3 = LCCR3_OutEnH | LCCR3_PixRsEdg | LCCR3_ACBsDiv(2),
  60. .lcd_power = h3100_lcd_power,
  61. };
  62. static void __init h3100_map_io(void)
  63. {
  64. h3xxx_map_io();
  65. /* Older bootldrs put GPIO2-9 in alternate mode on the
  66. assumption that they are used for video */
  67. GAFR &= ~0x000001fb;
  68. }
  69. /*
  70. * This turns the IRDA power on or off on the Compaq H3100
  71. */
  72. static struct gpio h3100_irda_gpio[] = {
  73. { H3100_GPIO_IR_ON, GPIOF_OUT_INIT_LOW, "IrDA power" },
  74. { H3100_GPIO_IR_FSEL, GPIOF_OUT_INIT_LOW, "IrDA fsel" },
  75. };
  76. static int h3100_irda_set_power(struct device *dev, unsigned int state)
  77. {
  78. gpio_set_value(H3100_GPIO_IR_ON, state);
  79. return 0;
  80. }
  81. static void h3100_irda_set_speed(struct device *dev, unsigned int speed)
  82. {
  83. gpio_set_value(H3100_GPIO_IR_FSEL, !(speed < 4000000));
  84. }
  85. static int h3100_irda_startup(struct device *dev)
  86. {
  87. return gpio_request_array(h3100_irda_gpio, sizeof(h3100_irda_gpio));
  88. }
  89. static void h3100_irda_shutdown(struct device *dev)
  90. {
  91. return gpio_free_array(h3100_irda_gpio, sizeof(h3100_irda_gpio));
  92. }
  93. static struct irda_platform_data h3100_irda_data = {
  94. .set_power = h3100_irda_set_power,
  95. .set_speed = h3100_irda_set_speed,
  96. .startup = h3100_irda_startup,
  97. .shutdown = h3100_irda_shutdown,
  98. };
  99. static void __init h3100_mach_init(void)
  100. {
  101. h3xxx_mach_init();
  102. sa11x0_register_lcd(&h3100_lcd_info);
  103. sa11x0_register_irda(&h3100_irda_data);
  104. }
  105. MACHINE_START(H3100, "Compaq iPAQ H3100")
  106. .atag_offset = 0x100,
  107. .map_io = h3100_map_io,
  108. .nr_irqs = SA1100_NR_IRQS,
  109. .init_irq = sa1100_init_irq,
  110. .init_time = sa1100_timer_init,
  111. .init_machine = h3100_mach_init,
  112. .init_late = sa11x0_init_late,
  113. .restart = sa11x0_restart,
  114. MACHINE_END