colibri-pxa3xx.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*
  2. * arch/arm/mach-pxa/colibri-pxa3xx.c
  3. *
  4. * Common functions for all Toradex PXA3xx modules
  5. *
  6. * Daniel Mack <daniel@caiaq.de>
  7. *
  8. * This program is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License version 2 as
  10. * published by the Free Software Foundation.
  11. */
  12. #include <linux/init.h>
  13. #include <linux/kernel.h>
  14. #include <linux/platform_device.h>
  15. #include <linux/gpio.h>
  16. #include <linux/etherdevice.h>
  17. #include <asm/mach-types.h>
  18. #include <mach/hardware.h>
  19. #include <asm/sizes.h>
  20. #include <asm/mach/arch.h>
  21. #include <asm/mach/irq.h>
  22. #include <mach/pxa3xx-regs.h>
  23. #include <mach/mfp-pxa300.h>
  24. #include <mach/colibri.h>
  25. #include <mach/mmc.h>
  26. #include <mach/pxafb.h>
  27. #include "generic.h"
  28. #include "devices.h"
  29. #if defined(CONFIG_AX88796)
  30. #define ETHER_ADDR_LEN 6
  31. static u8 ether_mac_addr[ETHER_ADDR_LEN];
  32. void __init colibri_pxa3xx_init_eth(struct ax_plat_data *plat_data)
  33. {
  34. int i;
  35. u64 serial = ((u64) system_serial_high << 32) | system_serial_low;
  36. /*
  37. * If the bootloader passed in a serial boot tag, which contains a
  38. * valid ethernet MAC, pass it to the interface. Toradex ships the
  39. * modules with their own bootloader which provides a valid MAC
  40. * this way.
  41. */
  42. for (i = 0; i < ETHER_ADDR_LEN; i++) {
  43. ether_mac_addr[i] = serial & 0xff;
  44. serial >>= 8;
  45. }
  46. if (is_valid_ether_addr(ether_mac_addr)) {
  47. plat_data->flags |= AXFLG_MAC_FROMPLATFORM;
  48. plat_data->mac_addr = ether_mac_addr;
  49. printk(KERN_INFO "%s(): taking MAC from serial boot tag\n",
  50. __func__);
  51. } else {
  52. plat_data->flags |= AXFLG_MAC_FROMDEV;
  53. printk(KERN_INFO "%s(): no valid serial boot tag found, "
  54. "taking MAC from device\n", __func__);
  55. }
  56. }
  57. #endif
  58. #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
  59. static int mmc_detect_pin;
  60. static int colibri_pxa3xx_mci_init(struct device *dev,
  61. irq_handler_t colibri_mmc_detect_int,
  62. void *data)
  63. {
  64. int ret;
  65. ret = gpio_request(mmc_detect_pin, "mmc card detect");
  66. if (ret)
  67. return ret;
  68. gpio_direction_input(mmc_detect_pin);
  69. ret = request_irq(gpio_to_irq(mmc_detect_pin), colibri_mmc_detect_int,
  70. IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
  71. "MMC card detect", data);
  72. if (ret) {
  73. gpio_free(mmc_detect_pin);
  74. return ret;
  75. }
  76. return 0;
  77. }
  78. static void colibri_pxa3xx_mci_exit(struct device *dev, void *data)
  79. {
  80. free_irq(mmc_detect_pin, data);
  81. gpio_free(gpio_to_irq(mmc_detect_pin));
  82. }
  83. static struct pxamci_platform_data colibri_pxa3xx_mci_platform_data = {
  84. .detect_delay = 20,
  85. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  86. .init = colibri_pxa3xx_mci_init,
  87. .exit = colibri_pxa3xx_mci_exit,
  88. };
  89. void __init colibri_pxa3xx_init_mmc(mfp_cfg_t *pins, int len, int detect_pin)
  90. {
  91. pxa3xx_mfp_config(pins, len);
  92. mmc_detect_pin = detect_pin;
  93. pxa_set_mci_info(&colibri_pxa3xx_mci_platform_data);
  94. }
  95. #endif /* CONFIG_MMC_PXA || CONFIG_MMC_PXA_MODULE */
  96. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
  97. static int lcd_bl_pin;
  98. /*
  99. * LCD panel (Sharp LQ043T3DX02)
  100. */
  101. static void colibri_lcd_backlight(int on)
  102. {
  103. gpio_set_value(lcd_bl_pin, !!on);
  104. }
  105. static struct pxafb_mode_info sharp_lq43_mode = {
  106. .pixclock = 101936,
  107. .xres = 480,
  108. .yres = 272,
  109. .bpp = 32,
  110. .depth = 18,
  111. .hsync_len = 41,
  112. .left_margin = 2,
  113. .right_margin = 2,
  114. .vsync_len = 10,
  115. .upper_margin = 2,
  116. .lower_margin = 2,
  117. .sync = 0,
  118. .cmap_greyscale = 0,
  119. };
  120. static struct pxafb_mach_info sharp_lq43_info = {
  121. .modes = &sharp_lq43_mode,
  122. .num_modes = 1,
  123. .cmap_inverse = 0,
  124. .cmap_static = 0,
  125. .lcd_conn = LCD_COLOR_TFT_18BPP,
  126. .pxafb_backlight_power = colibri_lcd_backlight,
  127. };
  128. void __init colibri_pxa3xx_init_lcd(int bl_pin)
  129. {
  130. lcd_bl_pin = bl_pin;
  131. gpio_request(bl_pin, "lcd backlight");
  132. gpio_direction_output(bl_pin, 0);
  133. set_pxa_fb_info(&sharp_lq43_info);
  134. }
  135. #endif