colibri-pxa300.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /*
  2. * arch/arm/mach-pxa/colibri-pxa300.c
  3. *
  4. * Support for Toradex PXA300 based Colibri module
  5. * Daniel Mack <daniel@caiaq.de>
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. */
  11. #include <linux/init.h>
  12. #include <linux/kernel.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/gpio.h>
  15. #include <net/ax88796.h>
  16. #include <asm/mach-types.h>
  17. #include <asm/mach/arch.h>
  18. #include <asm/mach/irq.h>
  19. #include <mach/pxa300.h>
  20. #include <mach/colibri.h>
  21. #include <mach/mmc.h>
  22. #include <mach/ohci.h>
  23. #include "generic.h"
  24. #include "devices.h"
  25. /*
  26. * GPIO configuration
  27. */
  28. static mfp_cfg_t colibri_pxa300_pin_config[] __initdata = {
  29. GPIO1_nCS2, /* AX88796 chip select */
  30. GPIO26_GPIO | MFP_PULL_HIGH, /* AX88796 IRQ */
  31. #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
  32. GPIO7_MMC1_CLK,
  33. GPIO14_MMC1_CMD,
  34. GPIO3_MMC1_DAT0,
  35. GPIO4_MMC1_DAT1,
  36. GPIO5_MMC1_DAT2,
  37. GPIO6_MMC1_DAT3,
  38. #endif
  39. #if defined (CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  40. GPIO0_2_USBH_PEN,
  41. GPIO1_2_USBH_PWR,
  42. #endif
  43. };
  44. #if defined(CONFIG_AX88796)
  45. /*
  46. * Asix AX88796 Ethernet
  47. */
  48. static struct ax_plat_data colibri_asix_platdata = {
  49. .flags = AXFLG_MAC_FROMDEV,
  50. .wordlength = 2,
  51. .dcr_val = 0x01,
  52. .rcr_val = 0x0e,
  53. .gpoc_val = 0x19
  54. };
  55. static struct resource colibri_asix_resource[] = {
  56. [0] = {
  57. .start = PXA3xx_CS2_PHYS,
  58. .end = PXA3xx_CS2_PHYS + (0x18 * 0x2) - 1,
  59. .flags = IORESOURCE_MEM,
  60. },
  61. [1] = {
  62. .start = PXA3xx_CS2_PHYS + (1 << 11),
  63. .end = PXA3xx_CS2_PHYS + (1 << 11) + 0x3fff,
  64. .flags = IORESOURCE_MEM,
  65. },
  66. [2] = {
  67. .start = COLIBRI_PXA300_ETH_IRQ,
  68. .end = COLIBRI_PXA300_ETH_IRQ,
  69. .flags = IORESOURCE_IRQ
  70. }
  71. };
  72. static struct platform_device asix_device = {
  73. .name = "ax88796",
  74. .id = 0,
  75. .num_resources = ARRAY_SIZE(colibri_asix_resource),
  76. .resource = colibri_asix_resource,
  77. .dev = {
  78. .platform_data = &colibri_asix_platdata
  79. }
  80. };
  81. #endif /* CONFIG_AX88796 */
  82. static struct platform_device *colibri_pxa300_devices[] __initdata = {
  83. #if defined(CONFIG_AX88796)
  84. &asix_device
  85. #endif
  86. };
  87. #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
  88. #define MMC_DETECT_PIN mfp_to_gpio(MFP_PIN_GPIO13)
  89. static int colibri_pxa300_mci_init(struct device *dev,
  90. irq_handler_t colibri_mmc_detect_int,
  91. void *data)
  92. {
  93. int ret;
  94. ret = gpio_request(MMC_DETECT_PIN, "mmc card detect");
  95. if (ret)
  96. return ret;
  97. gpio_direction_input(MMC_DETECT_PIN);
  98. ret = request_irq(gpio_to_irq(MMC_DETECT_PIN), colibri_mmc_detect_int,
  99. IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
  100. "MMC card detect", data);
  101. if (ret) {
  102. gpio_free(MMC_DETECT_PIN);
  103. return ret;
  104. }
  105. return 0;
  106. }
  107. static void colibri_pxa300_mci_exit(struct device *dev, void *data)
  108. {
  109. free_irq(MMC_DETECT_PIN, data);
  110. gpio_free(gpio_to_irq(MMC_DETECT_PIN));
  111. }
  112. static struct pxamci_platform_data colibri_pxa300_mci_platform_data = {
  113. .detect_delay = 20,
  114. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  115. .init = colibri_pxa300_mci_init,
  116. .exit = colibri_pxa300_mci_exit,
  117. };
  118. static void __init colibri_pxa300_init_mmc(void)
  119. {
  120. pxa_set_mci_info(&colibri_pxa300_mci_platform_data);
  121. }
  122. #else
  123. static inline void colibri_pxa300_init_mmc(void) {}
  124. #endif /* CONFIG_MMC_PXA */
  125. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  126. static struct pxaohci_platform_data colibri_pxa300_ohci_info = {
  127. .port_mode = PMM_GLOBAL_MODE,
  128. .flags = ENABLE_PORT1 | POWER_CONTROL_LOW | POWER_SENSE_LOW,
  129. };
  130. static void __init colibri_pxa300_init_ohci(void)
  131. {
  132. pxa_set_ohci_info(&colibri_pxa300_ohci_info);
  133. }
  134. #else
  135. static inline void colibri_pxa300_init_ohci(void) {}
  136. #endif /* CONFIG_USB_OHCI_HCD || CONFIG_USB_OHCI_HCD_MODULE */
  137. static void __init colibri_pxa300_init(void)
  138. {
  139. set_irq_type(COLIBRI_PXA300_ETH_IRQ, IRQ_TYPE_EDGE_FALLING);
  140. pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa300_pin_config));
  141. platform_add_devices(ARRAY_AND_SIZE(colibri_pxa300_devices));
  142. colibri_pxa300_init_mmc();
  143. colibri_pxa300_init_ohci();
  144. }
  145. MACHINE_START(COLIBRI300, "Toradex Colibri PXA300")
  146. .phys_io = 0x40000000,
  147. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  148. .boot_params = COLIBRI_SDRAM_BASE + 0x100,
  149. .init_machine = colibri_pxa300_init,
  150. .map_io = pxa_map_io,
  151. .init_irq = pxa3xx_init_irq,
  152. .timer = &pxa_timer,
  153. MACHINE_END