colibri-pxa3xx.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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 <mach/pxa3xx_nand.h>
  28. #include "generic.h"
  29. #include "devices.h"
  30. #if defined(CONFIG_AX88796)
  31. #define ETHER_ADDR_LEN 6
  32. static u8 ether_mac_addr[ETHER_ADDR_LEN];
  33. void __init colibri_pxa3xx_init_eth(struct ax_plat_data *plat_data)
  34. {
  35. int i;
  36. u64 serial = ((u64) system_serial_high << 32) | system_serial_low;
  37. /*
  38. * If the bootloader passed in a serial boot tag, which contains a
  39. * valid ethernet MAC, pass it to the interface. Toradex ships the
  40. * modules with their own bootloader which provides a valid MAC
  41. * this way.
  42. */
  43. for (i = 0; i < ETHER_ADDR_LEN; i++) {
  44. ether_mac_addr[i] = serial & 0xff;
  45. serial >>= 8;
  46. }
  47. if (is_valid_ether_addr(ether_mac_addr)) {
  48. plat_data->flags |= AXFLG_MAC_FROMPLATFORM;
  49. plat_data->mac_addr = ether_mac_addr;
  50. printk(KERN_INFO "%s(): taking MAC from serial boot tag\n",
  51. __func__);
  52. } else {
  53. plat_data->flags |= AXFLG_MAC_FROMDEV;
  54. printk(KERN_INFO "%s(): no valid serial boot tag found, "
  55. "taking MAC from device\n", __func__);
  56. }
  57. }
  58. #endif
  59. #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
  60. static int mmc_detect_pin;
  61. static int colibri_pxa3xx_mci_init(struct device *dev,
  62. irq_handler_t colibri_mmc_detect_int,
  63. void *data)
  64. {
  65. int ret;
  66. ret = gpio_request(mmc_detect_pin, "mmc card detect");
  67. if (ret)
  68. return ret;
  69. gpio_direction_input(mmc_detect_pin);
  70. ret = request_irq(gpio_to_irq(mmc_detect_pin), colibri_mmc_detect_int,
  71. IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
  72. "MMC card detect", data);
  73. if (ret) {
  74. gpio_free(mmc_detect_pin);
  75. return ret;
  76. }
  77. return 0;
  78. }
  79. static void colibri_pxa3xx_mci_exit(struct device *dev, void *data)
  80. {
  81. free_irq(mmc_detect_pin, data);
  82. gpio_free(gpio_to_irq(mmc_detect_pin));
  83. }
  84. static struct pxamci_platform_data colibri_pxa3xx_mci_platform_data = {
  85. .detect_delay = 20,
  86. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  87. .init = colibri_pxa3xx_mci_init,
  88. .exit = colibri_pxa3xx_mci_exit,
  89. .gpio_card_detect = -1,
  90. .gpio_card_ro = -1,
  91. .gpio_power = -1,
  92. };
  93. void __init colibri_pxa3xx_init_mmc(mfp_cfg_t *pins, int len, int detect_pin)
  94. {
  95. pxa3xx_mfp_config(pins, len);
  96. mmc_detect_pin = detect_pin;
  97. pxa_set_mci_info(&colibri_pxa3xx_mci_platform_data);
  98. }
  99. #endif /* CONFIG_MMC_PXA || CONFIG_MMC_PXA_MODULE */
  100. #if defined(CONFIG_FB_PXA) || defined(CONFIG_FB_PXA_MODULE)
  101. static int lcd_bl_pin;
  102. /*
  103. * LCD panel (Sharp LQ043T3DX02)
  104. */
  105. static void colibri_lcd_backlight(int on)
  106. {
  107. gpio_set_value(lcd_bl_pin, !!on);
  108. }
  109. static struct pxafb_mode_info sharp_lq43_mode = {
  110. .pixclock = 101936,
  111. .xres = 480,
  112. .yres = 272,
  113. .bpp = 32,
  114. .depth = 18,
  115. .hsync_len = 41,
  116. .left_margin = 2,
  117. .right_margin = 2,
  118. .vsync_len = 10,
  119. .upper_margin = 2,
  120. .lower_margin = 2,
  121. .sync = 0,
  122. .cmap_greyscale = 0,
  123. };
  124. static struct pxafb_mach_info sharp_lq43_info = {
  125. .modes = &sharp_lq43_mode,
  126. .num_modes = 1,
  127. .cmap_inverse = 0,
  128. .cmap_static = 0,
  129. .lcd_conn = LCD_COLOR_TFT_18BPP,
  130. .pxafb_backlight_power = colibri_lcd_backlight,
  131. };
  132. void __init colibri_pxa3xx_init_lcd(int bl_pin)
  133. {
  134. lcd_bl_pin = bl_pin;
  135. gpio_request(bl_pin, "lcd backlight");
  136. gpio_direction_output(bl_pin, 0);
  137. set_pxa_fb_info(&sharp_lq43_info);
  138. }
  139. #endif
  140. #if defined(CONFIG_MTD_NAND_PXA3xx) || defined(CONFIG_MTD_NAND_PXA3xx_MODULE)
  141. static struct mtd_partition colibri_nand_partitions[] = {
  142. {
  143. .name = "bootloader",
  144. .offset = 0,
  145. .size = SZ_512K,
  146. .mask_flags = MTD_WRITEABLE, /* force read-only */
  147. },
  148. {
  149. .name = "kernel",
  150. .offset = MTDPART_OFS_APPEND,
  151. .size = SZ_4M,
  152. .mask_flags = MTD_WRITEABLE, /* force read-only */
  153. },
  154. {
  155. .name = "reserved",
  156. .offset = MTDPART_OFS_APPEND,
  157. .size = SZ_1M,
  158. .mask_flags = MTD_WRITEABLE, /* force read-only */
  159. },
  160. {
  161. .name = "fs",
  162. .offset = MTDPART_OFS_APPEND,
  163. .size = MTDPART_SIZ_FULL,
  164. },
  165. };
  166. static struct pxa3xx_nand_platform_data colibri_nand_info = {
  167. .enable_arbiter = 1,
  168. .keep_config = 1,
  169. .parts = colibri_nand_partitions,
  170. .nr_parts = ARRAY_SIZE(colibri_nand_partitions),
  171. };
  172. void __init colibri_pxa3xx_init_nand(void)
  173. {
  174. pxa3xx_set_nand_info(&colibri_nand_info);
  175. }
  176. #endif