locomolcd.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. /*
  2. * Backlight control code for Sharp Zaurus SL-5500
  3. *
  4. * Copyright 2005 John Lenz <lenz@cs.wisc.edu>
  5. * Maintainer: Pavel Machek <pavel@suse.cz> (unless John wants to :-)
  6. * GPL v2
  7. *
  8. * This driver assumes single CPU. That's okay, because collie is
  9. * slightly old hardware, and noone is going to retrofit second CPU to
  10. * old PDA.
  11. */
  12. /* LCD power functions */
  13. #include <linux/config.h>
  14. #include <linux/module.h>
  15. #include <linux/init.h>
  16. #include <linux/delay.h>
  17. #include <linux/device.h>
  18. #include <linux/interrupt.h>
  19. #include <asm/hardware/locomo.h>
  20. #include <asm/irq.h>
  21. #include <asm/mach/sharpsl_param.h>
  22. #include <asm/mach-types.h>
  23. #include "../../../arch/arm/mach-sa1100/generic.h"
  24. static struct locomo_dev *locomolcd_dev;
  25. static void locomolcd_on(int comadj)
  26. {
  27. locomo_gpio_set_dir(locomolcd_dev, LOCOMO_GPIO_LCD_VSHA_ON, 0);
  28. locomo_gpio_write(locomolcd_dev, LOCOMO_GPIO_LCD_VSHA_ON, 1);
  29. mdelay(2);
  30. locomo_gpio_set_dir(locomolcd_dev, LOCOMO_GPIO_LCD_VSHD_ON, 0);
  31. locomo_gpio_write(locomolcd_dev, LOCOMO_GPIO_LCD_VSHD_ON, 1);
  32. mdelay(2);
  33. locomo_m62332_senddata(locomolcd_dev, comadj, 0);
  34. mdelay(5);
  35. locomo_gpio_set_dir(locomolcd_dev, LOCOMO_GPIO_LCD_VEE_ON, 0);
  36. locomo_gpio_write(locomolcd_dev, LOCOMO_GPIO_LCD_VEE_ON, 1);
  37. mdelay(10);
  38. /* TFTCRST | CPSOUT=0 | CPSEN */
  39. locomo_writel(0x01, locomolcd_dev->mapbase + LOCOMO_TC);
  40. /* Set CPSD */
  41. locomo_writel(6, locomolcd_dev->mapbase + LOCOMO_CPSD);
  42. /* TFTCRST | CPSOUT=0 | CPSEN */
  43. locomo_writel((0x04 | 0x01), locomolcd_dev->mapbase + LOCOMO_TC);
  44. mdelay(10);
  45. locomo_gpio_set_dir(locomolcd_dev, LOCOMO_GPIO_LCD_MOD, 0);
  46. locomo_gpio_write(locomolcd_dev, LOCOMO_GPIO_LCD_MOD, 1);
  47. }
  48. static void locomolcd_off(int comadj)
  49. {
  50. /* TFTCRST=1 | CPSOUT=1 | CPSEN = 0 */
  51. locomo_writel(0x06, locomolcd_dev->mapbase + LOCOMO_TC);
  52. mdelay(1);
  53. locomo_gpio_write(locomolcd_dev, LOCOMO_GPIO_LCD_VSHA_ON, 0);
  54. mdelay(110);
  55. locomo_gpio_write(locomolcd_dev, LOCOMO_GPIO_LCD_VEE_ON, 0);
  56. mdelay(700);
  57. /* TFTCRST=0 | CPSOUT=0 | CPSEN = 0 */
  58. locomo_writel(0, locomolcd_dev->mapbase + LOCOMO_TC);
  59. locomo_gpio_write(locomolcd_dev, LOCOMO_GPIO_LCD_MOD, 0);
  60. locomo_gpio_write(locomolcd_dev, LOCOMO_GPIO_LCD_VSHD_ON, 0);
  61. }
  62. void locomolcd_power(int on)
  63. {
  64. int comadj = sharpsl_param.comadj;
  65. unsigned long flags;
  66. local_irq_save(flags);
  67. if (!locomolcd_dev) {
  68. local_irq_restore(flags);
  69. return;
  70. }
  71. /* read comadj */
  72. if (comadj == -1) {
  73. if (machine_is_poodle())
  74. comadj = 118;
  75. if (machine_is_collie())
  76. comadj = 128;
  77. }
  78. if (on)
  79. locomolcd_on(comadj);
  80. else
  81. locomolcd_off(comadj);
  82. local_irq_restore(flags);
  83. }
  84. EXPORT_SYMBOL(locomolcd_power);
  85. static int poodle_lcd_probe(struct locomo_dev *dev)
  86. {
  87. unsigned long flags;
  88. local_irq_save(flags);
  89. locomolcd_dev = dev;
  90. /* the poodle_lcd_power function is called for the first time
  91. * from fs_initcall, which is before locomo is activated.
  92. * We need to recall poodle_lcd_power here*/
  93. #ifdef CONFIG_MACH_POODLE
  94. locomolcd_power(1);
  95. #endif
  96. local_irq_restore(flags);
  97. return 0;
  98. }
  99. static int poodle_lcd_remove(struct locomo_dev *dev)
  100. {
  101. unsigned long flags;
  102. local_irq_save(flags);
  103. locomolcd_dev = NULL;
  104. local_irq_restore(flags);
  105. return 0;
  106. }
  107. static struct locomo_driver poodle_lcd_driver = {
  108. .drv = {
  109. .name = "locomo-backlight",
  110. },
  111. .devid = LOCOMO_DEVID_BACKLIGHT,
  112. .probe = poodle_lcd_probe,
  113. .remove = poodle_lcd_remove,
  114. };
  115. static int __init poodle_lcd_init(void)
  116. {
  117. int ret = locomo_driver_register(&poodle_lcd_driver);
  118. if (ret) return ret;
  119. #ifdef CONFIG_SA1100_COLLIE
  120. sa1100fb_lcd_power = locomolcd_power;
  121. #endif
  122. return 0;
  123. }
  124. device_initcall(poodle_lcd_init);