Daniel Mack | bac07ec | 2009-03-23 02:04:18 +0100 | [diff] [blame^] | 1 | /* |
| 2 | * arch/arm/mach-pxa/colibri-pxa320.c |
| 3 | * |
| 4 | * Support for Toradex PXA320/310 based Colibri module |
| 5 | * |
| 6 | * Daniel Mack <daniel@caiaq.de> |
| 7 | * Matthias Meier <matthias.j.meier@gmx.net> |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or modify |
| 10 | * it under the terms of the GNU General Public License version 2 as |
| 11 | * published by the Free Software Foundation. |
| 12 | */ |
| 13 | |
| 14 | #include <linux/init.h> |
| 15 | #include <linux/kernel.h> |
| 16 | #include <linux/platform_device.h> |
| 17 | #include <linux/gpio.h> |
| 18 | #include <net/ax88796.h> |
| 19 | |
| 20 | #include <asm/mach-types.h> |
| 21 | #include <asm/sizes.h> |
| 22 | #include <asm/mach/arch.h> |
| 23 | #include <asm/mach/irq.h> |
| 24 | |
| 25 | #include <mach/pxa3xx-regs.h> |
| 26 | #include <mach/mfp-pxa320.h> |
| 27 | #include <mach/colibri.h> |
| 28 | #include <mach/ohci.h> |
| 29 | |
| 30 | #include "generic.h" |
| 31 | #include "devices.h" |
| 32 | |
| 33 | #if defined(CONFIG_AX88796) |
| 34 | #define COLIBRI_ETH_IRQ_GPIO mfp_to_gpio(GPIO36_GPIO) |
| 35 | |
| 36 | /* |
| 37 | * Asix AX88796 Ethernet |
| 38 | */ |
| 39 | static struct ax_plat_data colibri_asix_platdata = { |
| 40 | .flags = AXFLG_MAC_FROMDEV, |
| 41 | .wordlength = 2 |
| 42 | }; |
| 43 | |
| 44 | static struct resource colibri_asix_resource[] = { |
| 45 | [0] = { |
| 46 | .start = PXA3xx_CS2_PHYS, |
| 47 | .end = PXA3xx_CS2_PHYS + (0x20 * 2) - 1, |
| 48 | .flags = IORESOURCE_MEM, |
| 49 | }, |
| 50 | [1] = { |
| 51 | .start = gpio_to_irq(COLIBRI_ETH_IRQ_GPIO), |
| 52 | .end = gpio_to_irq(COLIBRI_ETH_IRQ_GPIO), |
| 53 | .flags = IORESOURCE_IRQ |
| 54 | } |
| 55 | }; |
| 56 | |
| 57 | static struct platform_device asix_device = { |
| 58 | .name = "ax88796", |
| 59 | .id = 0, |
| 60 | .num_resources = ARRAY_SIZE(colibri_asix_resource), |
| 61 | .resource = colibri_asix_resource, |
| 62 | .dev = { |
| 63 | .platform_data = &colibri_asix_platdata |
| 64 | } |
| 65 | }; |
| 66 | |
| 67 | static mfp_cfg_t colibri_pxa320_eth_pin_config[] __initdata = { |
| 68 | GPIO3_nCS2, /* AX88796 chip select */ |
| 69 | GPIO36_GPIO | MFP_PULL_HIGH /* AX88796 IRQ */ |
| 70 | }; |
| 71 | |
| 72 | static void __init colibri_pxa320_init_eth(void) |
| 73 | { |
| 74 | pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_eth_pin_config)); |
| 75 | set_irq_type(gpio_to_irq(COLIBRI_ETH_IRQ_GPIO), IRQ_TYPE_EDGE_FALLING); |
| 76 | platform_device_register(&asix_device); |
| 77 | } |
| 78 | #else |
| 79 | static inline void __init colibri_pxa320_init_eth(void) {} |
| 80 | #endif /* CONFIG_AX88796 */ |
| 81 | |
| 82 | #if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) |
| 83 | static mfp_cfg_t colibri_pxa320_usb_pin_config[] __initdata = { |
| 84 | GPIO2_2_USBH_PEN, |
| 85 | GPIO3_2_USBH_PWR, |
| 86 | }; |
| 87 | |
| 88 | static struct pxaohci_platform_data colibri_pxa320_ohci_info = { |
| 89 | .port_mode = PMM_GLOBAL_MODE, |
| 90 | .flags = ENABLE_PORT1 | POWER_CONTROL_LOW | POWER_SENSE_LOW, |
| 91 | }; |
| 92 | |
| 93 | void __init colibri_pxa320_init_ohci(void) |
| 94 | { |
| 95 | pxa3xx_mfp_config(ARRAY_AND_SIZE(colibri_pxa320_usb_pin_config)); |
| 96 | pxa_set_ohci_info(&colibri_pxa320_ohci_info); |
| 97 | } |
| 98 | #else |
| 99 | static inline void colibri_pxa320_init_ohci(void) {} |
| 100 | #endif /* CONFIG_USB_OHCI_HCD || CONFIG_USB_OHCI_HCD_MODULE */ |
| 101 | |
| 102 | static mfp_cfg_t colibri_pxa320_mmc_pin_config[] __initdata = { |
| 103 | GPIO22_MMC1_CLK, |
| 104 | GPIO23_MMC1_CMD, |
| 105 | GPIO18_MMC1_DAT0, |
| 106 | GPIO19_MMC1_DAT1, |
| 107 | GPIO20_MMC1_DAT2, |
| 108 | GPIO21_MMC1_DAT3 |
| 109 | }; |
| 110 | |
| 111 | void __init colibri_pxa320_init(void) |
| 112 | { |
| 113 | colibri_pxa320_init_eth(); |
| 114 | colibri_pxa320_init_ohci(); |
| 115 | colibri_pxa3xx_init_mmc(ARRAY_AND_SIZE(colibri_pxa320_mmc_pin_config), |
| 116 | mfp_to_gpio(MFP_PIN_GPIO28)); |
| 117 | } |
| 118 | |
| 119 | MACHINE_START(COLIBRI320, "Toradex Colibri PXA320") |
| 120 | .phys_io = 0x40000000, |
| 121 | .io_pg_offst = (io_p2v(0x40000000) >> 18) & 0xfffc, |
| 122 | .boot_params = COLIBRI_SDRAM_BASE + 0x100, |
| 123 | .init_machine = colibri_pxa320_init, |
| 124 | .map_io = pxa_map_io, |
| 125 | .init_irq = pxa3xx_init_irq, |
| 126 | .timer = &pxa_timer, |
| 127 | MACHINE_END |
| 128 | |