h3100.c 3.2 KB

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