Daniel Mack | 5fc9f9a | 2009-03-13 16:37:09 +0100 | [diff] [blame] | 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 | |
| 12 | #include <linux/init.h> |
| 13 | #include <linux/kernel.h> |
| 14 | #include <linux/platform_device.h> |
| 15 | #include <linux/gpio.h> |
| 16 | #include <net/ax88796.h> |
| 17 | |
| 18 | #include <asm/mach-types.h> |
| 19 | #include <asm/mach/arch.h> |
| 20 | #include <asm/mach/irq.h> |
| 21 | |
| 22 | #include <mach/pxa300.h> |
| 23 | #include <mach/colibri.h> |
Daniel Mack | ebc046c | 2009-03-13 16:37:10 +0100 | [diff] [blame] | 24 | #include <mach/mmc.h> |
Daniel Mack | 42e07ad | 2009-03-13 16:37:11 +0100 | [diff] [blame] | 25 | #include <mach/ohci.h> |
Daniel Mack | 5fc9f9a | 2009-03-13 16:37:09 +0100 | [diff] [blame] | 26 | |
| 27 | #include "generic.h" |
| 28 | #include "devices.h" |
| 29 | |
| 30 | /* |
| 31 | * GPIO configuration |
| 32 | */ |
| 33 | static mfp_cfg_t colibri_pxa300_pin_config[] __initdata = { |
| 34 | GPIO1_nCS2, /* AX88796 chip select */ |
| 35 | GPIO26_GPIO | MFP_PULL_HIGH, /* AX88796 IRQ */ |
Daniel Mack | ebc046c | 2009-03-13 16:37:10 +0100 | [diff] [blame] | 36 | |
| 37 | #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) |
| 38 | GPIO7_MMC1_CLK, |
| 39 | GPIO14_MMC1_CMD, |
| 40 | GPIO3_MMC1_DAT0, |
| 41 | GPIO4_MMC1_DAT1, |
| 42 | GPIO5_MMC1_DAT2, |
| 43 | GPIO6_MMC1_DAT3, |
| 44 | #endif |
Daniel Mack | 42e07ad | 2009-03-13 16:37:11 +0100 | [diff] [blame] | 45 | |
| 46 | #if defined (CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) |
| 47 | GPIO0_2_USBH_PEN, |
| 48 | GPIO1_2_USBH_PWR, |
| 49 | #endif |
Daniel Mack | 5fc9f9a | 2009-03-13 16:37:09 +0100 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | #if defined(CONFIG_AX88796) |
| 53 | /* |
| 54 | * Asix AX88796 Ethernet |
| 55 | */ |
| 56 | static struct ax_plat_data colibri_asix_platdata = { |
| 57 | .flags = AXFLG_MAC_FROMDEV, |
Daniel Mack | 626806d | 2009-03-23 02:04:16 +0100 | [diff] [blame^] | 58 | .wordlength = 2 |
Daniel Mack | 5fc9f9a | 2009-03-13 16:37:09 +0100 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | static struct resource colibri_asix_resource[] = { |
| 62 | [0] = { |
| 63 | .start = PXA3xx_CS2_PHYS, |
Daniel Mack | 626806d | 2009-03-23 02:04:16 +0100 | [diff] [blame^] | 64 | .end = PXA3xx_CS2_PHYS + (0x20 * 2) - 1, |
Daniel Mack | 5fc9f9a | 2009-03-13 16:37:09 +0100 | [diff] [blame] | 65 | .flags = IORESOURCE_MEM, |
| 66 | }, |
| 67 | [1] = { |
Daniel Mack | 5fc9f9a | 2009-03-13 16:37:09 +0100 | [diff] [blame] | 68 | .start = COLIBRI_PXA300_ETH_IRQ, |
| 69 | .end = COLIBRI_PXA300_ETH_IRQ, |
| 70 | .flags = IORESOURCE_IRQ |
| 71 | } |
| 72 | }; |
| 73 | |
| 74 | static struct platform_device asix_device = { |
| 75 | .name = "ax88796", |
| 76 | .id = 0, |
| 77 | .num_resources = ARRAY_SIZE(colibri_asix_resource), |
| 78 | .resource = colibri_asix_resource, |
| 79 | .dev = { |
| 80 | .platform_data = &colibri_asix_platdata |
| 81 | } |
| 82 | }; |
| 83 | #endif /* CONFIG_AX88796 */ |
| 84 | |
| 85 | static struct platform_device *colibri_pxa300_devices[] __initdata = { |
| 86 | #if defined(CONFIG_AX88796) |
| 87 | &asix_device |
| 88 | #endif |
| 89 | }; |
| 90 | |
Daniel Mack | ebc046c | 2009-03-13 16:37:10 +0100 | [diff] [blame] | 91 | #if defined(CONFIG_MMC_PXA) || defined(CONFIG_MMC_PXA_MODULE) |
| 92 | #define MMC_DETECT_PIN mfp_to_gpio(MFP_PIN_GPIO13) |
| 93 | |
| 94 | static int colibri_pxa300_mci_init(struct device *dev, |
| 95 | irq_handler_t colibri_mmc_detect_int, |
| 96 | void *data) |
| 97 | { |
| 98 | int ret; |
| 99 | |
| 100 | ret = gpio_request(MMC_DETECT_PIN, "mmc card detect"); |
| 101 | if (ret) |
| 102 | return ret; |
| 103 | |
| 104 | gpio_direction_input(MMC_DETECT_PIN); |
| 105 | ret = request_irq(gpio_to_irq(MMC_DETECT_PIN), colibri_mmc_detect_int, |
| 106 | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, |
| 107 | "MMC card detect", data); |
| 108 | if (ret) { |
| 109 | gpio_free(MMC_DETECT_PIN); |
| 110 | return ret; |
| 111 | } |
| 112 | |
| 113 | return 0; |
| 114 | } |
| 115 | |
| 116 | static void colibri_pxa300_mci_exit(struct device *dev, void *data) |
| 117 | { |
| 118 | free_irq(MMC_DETECT_PIN, data); |
| 119 | gpio_free(gpio_to_irq(MMC_DETECT_PIN)); |
| 120 | } |
| 121 | |
| 122 | static struct pxamci_platform_data colibri_pxa300_mci_platform_data = { |
| 123 | .detect_delay = 20, |
| 124 | .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34, |
| 125 | .init = colibri_pxa300_mci_init, |
| 126 | .exit = colibri_pxa300_mci_exit, |
| 127 | }; |
| 128 | |
| 129 | static void __init colibri_pxa300_init_mmc(void) |
| 130 | { |
| 131 | pxa_set_mci_info(&colibri_pxa300_mci_platform_data); |
| 132 | } |
| 133 | |
| 134 | #else |
| 135 | static inline void colibri_pxa300_init_mmc(void) {} |
| 136 | #endif /* CONFIG_MMC_PXA */ |
| 137 | |
Daniel Mack | 42e07ad | 2009-03-13 16:37:11 +0100 | [diff] [blame] | 138 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) |
| 139 | static struct pxaohci_platform_data colibri_pxa300_ohci_info = { |
| 140 | .port_mode = PMM_GLOBAL_MODE, |
| 141 | .flags = ENABLE_PORT1 | POWER_CONTROL_LOW | POWER_SENSE_LOW, |
| 142 | }; |
| 143 | |
| 144 | static void __init colibri_pxa300_init_ohci(void) |
| 145 | { |
| 146 | pxa_set_ohci_info(&colibri_pxa300_ohci_info); |
| 147 | } |
| 148 | #else |
| 149 | static inline void colibri_pxa300_init_ohci(void) {} |
| 150 | #endif /* CONFIG_USB_OHCI_HCD || CONFIG_USB_OHCI_HCD_MODULE */ |
| 151 | |
Daniel Mack | 5fc9f9a | 2009-03-13 16:37:09 +0100 | [diff] [blame] | 152 | static void __init colibri_pxa300_init(void) |
| 153 | { |
| 154 | set_irq_type(COLIBRI_PXA300_ETH_IRQ, IRQ_TYPE_EDGE_FALLING); |
| 155 | pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa300_pin_config)); |
| 156 | platform_add_devices(ARRAY_AND_SIZE(colibri_pxa300_devices)); |
Daniel Mack | ebc046c | 2009-03-13 16:37:10 +0100 | [diff] [blame] | 157 | colibri_pxa300_init_mmc(); |
Daniel Mack | 42e07ad | 2009-03-13 16:37:11 +0100 | [diff] [blame] | 158 | colibri_pxa300_init_ohci(); |
Daniel Mack | 5fc9f9a | 2009-03-13 16:37:09 +0100 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | MACHINE_START(COLIBRI300, "Toradex Colibri PXA300") |
| 162 | .phys_io = 0x40000000, |
| 163 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, |
| 164 | .boot_params = COLIBRI_SDRAM_BASE + 0x100, |
| 165 | .init_machine = colibri_pxa300_init, |
| 166 | .map_io = pxa_map_io, |
| 167 | .init_irq = pxa3xx_init_irq, |
| 168 | .timer = &pxa_timer, |
| 169 | MACHINE_END |
| 170 | |