pcm970-baseboard.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. * Copyright (C) 2008 Juergen Beisert (kernel@pengutronix.de)
  3. *
  4. * This program is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU General Public License
  6. * as published by the Free Software Foundation; either version 2
  7. * of the License, or (at your option) any later version.
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program; if not, write to the Free Software
  15. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  16. * MA 02110-1301, USA.
  17. */
  18. #include <linux/platform_device.h>
  19. #include <linux/gpio.h>
  20. #include <linux/irq.h>
  21. #include <asm/mach/arch.h>
  22. #include <mach/hardware.h>
  23. #include <mach/common.h>
  24. #include <mach/mmc.h>
  25. #include <mach/imxfb.h>
  26. #include <mach/iomux.h>
  27. #include "devices.h"
  28. static int pcm970_sdhc2_get_ro(struct device *dev)
  29. {
  30. return gpio_get_value(GPIO_PORTC + 28);
  31. }
  32. static int pcm970_sdhc2_pins[] = {
  33. PB4_PF_SD2_D0,
  34. PB5_PF_SD2_D1,
  35. PB6_PF_SD2_D2,
  36. PB7_PF_SD2_D3,
  37. PB8_PF_SD2_CMD,
  38. PB9_PF_SD2_CLK,
  39. };
  40. static int pcm970_sdhc2_init(struct device *dev, irq_handler_t detect_irq, void *data)
  41. {
  42. int ret;
  43. ret = mxc_gpio_setup_multiple_pins(pcm970_sdhc2_pins,
  44. ARRAY_SIZE(pcm970_sdhc2_pins), "sdhc2");
  45. if(ret)
  46. return ret;
  47. ret = request_irq(IRQ_GPIOC(29), detect_irq, 0,
  48. "imx-mmc-detect", data);
  49. if (ret)
  50. goto out_release_gpio;
  51. set_irq_type(IRQ_GPIOC(29), IRQF_TRIGGER_FALLING);
  52. ret = gpio_request(GPIO_PORTC + 28, "imx-mmc-ro");
  53. if (ret)
  54. goto out_release_gpio;
  55. mxc_gpio_mode((GPIO_PORTC | 28) | GPIO_GPIO | GPIO_IN);
  56. gpio_direction_input(GPIO_PORTC + 28);
  57. return 0;
  58. out_release_gpio:
  59. mxc_gpio_release_multiple_pins(pcm970_sdhc2_pins,
  60. ARRAY_SIZE(pcm970_sdhc2_pins));
  61. return ret;
  62. }
  63. static void pcm970_sdhc2_exit(struct device *dev, void *data)
  64. {
  65. free_irq(IRQ_GPIOC(29), data);
  66. gpio_free(GPIO_PORTC + 28);
  67. mxc_gpio_release_multiple_pins(pcm970_sdhc2_pins,
  68. ARRAY_SIZE(pcm970_sdhc2_pins));
  69. }
  70. static struct imxmmc_platform_data sdhc_pdata = {
  71. .get_ro = pcm970_sdhc2_get_ro,
  72. .init = pcm970_sdhc2_init,
  73. .exit = pcm970_sdhc2_exit,
  74. };
  75. static int mxc_fb_pins[] = {
  76. PA5_PF_LSCLK, PA6_PF_LD0, PA7_PF_LD1, PA8_PF_LD2,
  77. PA9_PF_LD3, PA10_PF_LD4, PA11_PF_LD5, PA12_PF_LD6,
  78. PA13_PF_LD7, PA14_PF_LD8, PA15_PF_LD9, PA16_PF_LD10,
  79. PA17_PF_LD11, PA18_PF_LD12, PA19_PF_LD13, PA20_PF_LD14,
  80. PA21_PF_LD15, PA22_PF_LD16, PA23_PF_LD17, PA24_PF_REV,
  81. PA25_PF_CLS, PA26_PF_PS, PA27_PF_SPL_SPR, PA28_PF_HSYNC,
  82. PA29_PF_VSYNC, PA30_PF_CONTRAST, PA31_PF_OE_ACD
  83. };
  84. static int pcm038_fb_init(struct platform_device *pdev)
  85. {
  86. return mxc_gpio_setup_multiple_pins(mxc_fb_pins,
  87. ARRAY_SIZE(mxc_fb_pins), "FB");
  88. }
  89. static int pcm038_fb_exit(struct platform_device *pdev)
  90. {
  91. mxc_gpio_release_multiple_pins(mxc_fb_pins, ARRAY_SIZE(mxc_fb_pins));
  92. return 0;
  93. }
  94. /*
  95. * Connected is a portrait Sharp-QVGA display
  96. * of type: LQ035Q7DH06
  97. */
  98. static struct imx_fb_platform_data pcm038_fb_data = {
  99. .pixclock = 188679, /* in ps (5.3MHz) */
  100. .xres = 240,
  101. .yres = 320,
  102. .bpp = 16,
  103. .hsync_len = 7,
  104. .left_margin = 5,
  105. .right_margin = 16,
  106. .vsync_len = 1,
  107. .upper_margin = 7,
  108. .lower_margin = 9,
  109. .fixed_screen_cpu = 0,
  110. /*
  111. * - HSYNC active high
  112. * - VSYNC active high
  113. * - clk notenabled while idle
  114. * - clock not inverted
  115. * - data not inverted
  116. * - data enable low active
  117. * - enable sharp mode
  118. */
  119. .pcr = 0xFA0080C0,
  120. .pwmr = 0x00A903FF,
  121. .lscr1 = 0x00120300,
  122. .dmacr = 0x00020010,
  123. .init = pcm038_fb_init,
  124. .exit = pcm038_fb_exit,
  125. };
  126. /*
  127. * system init for baseboard usage. Will be called by pcm038 init.
  128. *
  129. * Add platform devices present on this baseboard and init
  130. * them from CPU side as far as required to use them later on
  131. */
  132. void __init pcm970_baseboard_init(void)
  133. {
  134. mxc_register_device(&mxc_fb_device, &pcm038_fb_data);
  135. mxc_register_device(&mxc_sdhc_device1, &sdhc_pdata);
  136. }