colibri-pxa300.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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 "generic.h"
  23. #include "devices.h"
  24. /*
  25. * GPIO configuration
  26. */
  27. static mfp_cfg_t colibri_pxa300_pin_config[] __initdata = {
  28. GPIO1_nCS2, /* AX88796 chip select */
  29. GPIO26_GPIO | MFP_PULL_HIGH, /* AX88796 IRQ */
  30. #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
  31. GPIO7_MMC1_CLK,
  32. GPIO14_MMC1_CMD,
  33. GPIO3_MMC1_DAT0,
  34. GPIO4_MMC1_DAT1,
  35. GPIO5_MMC1_DAT2,
  36. GPIO6_MMC1_DAT3,
  37. #endif
  38. };
  39. #if defined(CONFIG_AX88796)
  40. /*
  41. * Asix AX88796 Ethernet
  42. */
  43. static struct ax_plat_data colibri_asix_platdata = {
  44. .flags = AXFLG_MAC_FROMDEV,
  45. .wordlength = 2,
  46. .dcr_val = 0x01,
  47. .rcr_val = 0x0e,
  48. .gpoc_val = 0x19
  49. };
  50. static struct resource colibri_asix_resource[] = {
  51. [0] = {
  52. .start = PXA3xx_CS2_PHYS,
  53. .end = PXA3xx_CS2_PHYS + (0x18 * 0x2) - 1,
  54. .flags = IORESOURCE_MEM,
  55. },
  56. [1] = {
  57. .start = PXA3xx_CS2_PHYS + (1 << 11),
  58. .end = PXA3xx_CS2_PHYS + (1 << 11) + 0x3fff,
  59. .flags = IORESOURCE_MEM,
  60. },
  61. [2] = {
  62. .start = COLIBRI_PXA300_ETH_IRQ,
  63. .end = COLIBRI_PXA300_ETH_IRQ,
  64. .flags = IORESOURCE_IRQ
  65. }
  66. };
  67. static struct platform_device asix_device = {
  68. .name = "ax88796",
  69. .id = 0,
  70. .num_resources = ARRAY_SIZE(colibri_asix_resource),
  71. .resource = colibri_asix_resource,
  72. .dev = {
  73. .platform_data = &colibri_asix_platdata
  74. }
  75. };
  76. #endif /* CONFIG_AX88796 */
  77. static struct platform_device *colibri_pxa300_devices[] __initdata = {
  78. #if defined(CONFIG_AX88796)
  79. &asix_device
  80. #endif
  81. };
  82. #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE)
  83. #define MMC_DETECT_PIN mfp_to_gpio(MFP_PIN_GPIO13)
  84. static int colibri_pxa300_mci_init(struct device *dev,
  85. irq_handler_t colibri_mmc_detect_int,
  86. void *data)
  87. {
  88. int ret;
  89. ret = gpio_request(MMC_DETECT_PIN, "mmc card detect");
  90. if (ret)
  91. return ret;
  92. gpio_direction_input(MMC_DETECT_PIN);
  93. ret = request_irq(gpio_to_irq(MMC_DETECT_PIN), colibri_mmc_detect_int,
  94. IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
  95. "MMC card detect", data);
  96. if (ret) {
  97. gpio_free(MMC_DETECT_PIN);
  98. return ret;
  99. }
  100. return 0;
  101. }
  102. static void colibri_pxa300_mci_exit(struct device *dev, void *data)
  103. {
  104. free_irq(MMC_DETECT_PIN, data);
  105. gpio_free(gpio_to_irq(MMC_DETECT_PIN));
  106. }
  107. static struct pxamci_platform_data colibri_pxa300_mci_platform_data = {
  108. .detect_delay = 20,
  109. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  110. .init = colibri_pxa300_mci_init,
  111. .exit = colibri_pxa300_mci_exit,
  112. };
  113. static void __init colibri_pxa300_init_mmc(void)
  114. {
  115. pxa_set_mci_info(&colibri_pxa300_mci_platform_data);
  116. }
  117. #else
  118. static inline void colibri_pxa300_init_mmc(void) {}
  119. #endif /* CONFIG_MMC_PXA */
  120. static void __init colibri_pxa300_init(void)
  121. {
  122. set_irq_type(COLIBRI_PXA300_ETH_IRQ, IRQ_TYPE_EDGE_FALLING);
  123. pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa300_pin_config));
  124. platform_add_devices(ARRAY_AND_SIZE(colibri_pxa300_devices));
  125. colibri_pxa300_init_mmc();
  126. }
  127. MACHINE_START(COLIBRI300, "Toradex Colibri PXA300")
  128. .phys_io = 0x40000000,
  129. .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc,
  130. .boot_params = COLIBRI_SDRAM_BASE + 0x100,
  131. .init_machine = colibri_pxa300_init,
  132. .map_io = pxa_map_io,
  133. .init_irq = pxa3xx_init_irq,
  134. .timer = &pxa_timer,
  135. MACHINE_END