colibri-pxa300.c 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. };
  52. static struct resource colibri_asix_resource[] = {
  53. [0] = {
  54. .start = PXA3xx_CS2_PHYS,
  55. .end = PXA3xx_CS2_PHYS + (0x20 * 2) - 1,
  56. .flags = IORESOURCE_MEM,
  57. },
  58. [1] = {
  59. .start = COLIBRI_PXA300_ETH_IRQ,
  60. .end = COLIBRI_PXA300_ETH_IRQ,
  61. .flags = IORESOURCE_IRQ
  62. }
  63. };
  64. static struct platform_device asix_device = {
  65. .name = "ax88796",
  66. .id = 0,
  67. .num_resources = ARRAY_SIZE(colibri_asix_resource),
  68. .resource = colibri_asix_resource,
  69. .dev = {
  70. .platform_data = &colibri_asix_platdata
  71. }
  72. };
  73. #endif /* CONFIG_AX88796 */
  74. static struct platform_device *colibri_pxa300_devices[] __initdata = {
  75. #if defined(CONFIG_AX88796)
  76. &asix_device
  77. #endif
  78. };
  79. #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
  80. #define MMC_DETECT_PIN mfp_to_gpio(MFP_PIN_GPIO13)
  81. static int colibri_pxa300_mci_init(struct device *dev,
  82. irq_handler_t colibri_mmc_detect_int,
  83. void *data)
  84. {
  85. int ret;
  86. ret = gpio_request(MMC_DETECT_PIN, "mmc card detect");
  87. if (ret)
  88. return ret;
  89. gpio_direction_input(MMC_DETECT_PIN);
  90. ret = request_irq(gpio_to_irq(MMC_DETECT_PIN), colibri_mmc_detect_int,
  91. IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
  92. "MMC card detect", data);
  93. if (ret) {
  94. gpio_free(MMC_DETECT_PIN);
  95. return ret;
  96. }
  97. return 0;
  98. }
  99. static void colibri_pxa300_mci_exit(struct device *dev, void *data)
  100. {
  101. free_irq(MMC_DETECT_PIN, data);
  102. gpio_free(gpio_to_irq(MMC_DETECT_PIN));
  103. }
  104. static struct pxamci_platform_data colibri_pxa300_mci_platform_data = {
  105. .detect_delay = 20,
  106. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  107. .init = colibri_pxa300_mci_init,
  108. .exit = colibri_pxa300_mci_exit,
  109. };
  110. static void __init colibri_pxa300_init_mmc(void)
  111. {
  112. pxa_set_mci_info(&colibri_pxa300_mci_platform_data);
  113. }
  114. #else
  115. static inline void colibri_pxa300_init_mmc(void) {}
  116. #endif /* CONFIG_MMC_PXA */
  117. #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
  118. static struct pxaohci_platform_data colibri_pxa300_ohci_info = {
  119. .port_mode = PMM_GLOBAL_MODE,
  120. .flags = ENABLE_PORT1 | POWER_CONTROL_LOW | POWER_SENSE_LOW,
  121. };
  122. static void __init colibri_pxa300_init_ohci(void)
  123. {
  124. pxa_set_ohci_info(&colibri_pxa300_ohci_info);
  125. }
  126. #else
  127. static inline void colibri_pxa300_init_ohci(void) {}
  128. #endif /* CONFIG_USB_OHCI_HCD || CONFIG_USB_OHCI_HCD_MODULE */
  129. static void __init colibri_pxa300_init(void)
  130. {
  131. set_irq_type(COLIBRI_PXA300_ETH_IRQ, IRQ_TYPE_EDGE_FALLING);
  132. pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa300_pin_config));
  133. platform_add_devices(ARRAY_AND_SIZE(colibri_pxa300_devices));
  134. colibri_pxa300_init_mmc();
  135. colibri_pxa300_init_ohci();
  136. }
  137. MACHINE_START(COLIBRI300, "Toradex Colibri PXA300")
  138. .phys_io = 0x40000000,
  139. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  140. .boot_params = COLIBRI_SDRAM_BASE + 0x100,
  141. .init_machine = colibri_pxa300_init,
  142. .map_io = pxa_map_io,
  143. .init_irq = pxa3xx_init_irq,
  144. .timer = &pxa_timer,
  145. MACHINE_END