Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-ixp4xx/gtwx5715-pci.c |
| 3 | * |
| 4 | * Gemtek GTWX5715 (Linksys WRV54G) board setup |
| 5 | * |
| 6 | * Copyright (C) 2004 George T. Joseph |
| 7 | * Derived from Coyote |
| 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License |
| 11 | * as published by the Free Software Foundation; either version 2 |
| 12 | * of the License, or (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | #include <linux/pci.h> |
| 26 | #include <linux/init.h> |
| 27 | #include <linux/delay.h> |
Michael-Luke Jones | ddaca4a | 2007-05-31 12:27:14 +0100 | [diff] [blame] | 28 | #include <linux/irq.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 29 | #include <asm/mach-types.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 30 | #include <mach/hardware.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | #include <asm/mach/pci.h> |
| 32 | |
Krzysztof Hałasa | 8d3fdf3 | 2009-11-17 18:48:23 +0100 | [diff] [blame^] | 33 | #define SLOT0_DEVID 0 |
| 34 | #define SLOT0_INTA 10 |
| 35 | #define SLOT0_INTB 11 |
Krzysztof Hałasa | a8b7b34 | 2009-11-16 23:24:57 +0100 | [diff] [blame] | 36 | |
Krzysztof Hałasa | 8d3fdf3 | 2009-11-17 18:48:23 +0100 | [diff] [blame^] | 37 | #define SLOT1_DEVID 1 |
| 38 | #define SLOT1_INTA 11 |
| 39 | #define SLOT1_INTB 10 |
Krzysztof Hałasa | a8b7b34 | 2009-11-16 23:24:57 +0100 | [diff] [blame] | 40 | |
Krzysztof Hałasa | 8d3fdf3 | 2009-11-17 18:48:23 +0100 | [diff] [blame^] | 41 | #define SLOT_COUNT 2 |
| 42 | #define INT_PIN_COUNT 2 |
Krzysztof Hałasa | a8b7b34 | 2009-11-16 23:24:57 +0100 | [diff] [blame] | 43 | |
Deepak Saxena | bdf82b5 | 2005-08-29 22:46:30 +0100 | [diff] [blame] | 44 | /* |
Deepak Saxena | bdf82b5 | 2005-08-29 22:46:30 +0100 | [diff] [blame] | 45 | * Slot 0 isn't actually populated with a card connector but |
| 46 | * we initialize it anyway in case a future version has the |
| 47 | * slot populated or someone with good soldering skills has |
| 48 | * some free time. |
| 49 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | void __init gtwx5715_pci_preinit(void) |
| 51 | { |
Krzysztof Hałasa | 8d3fdf3 | 2009-11-17 18:48:23 +0100 | [diff] [blame^] | 52 | set_irq_type(IXP4XX_GPIO_IRQ(SLOT0_INTA), IRQ_TYPE_LEVEL_LOW); |
| 53 | set_irq_type(IXP4XX_GPIO_IRQ(SLOT0_INTB), IRQ_TYPE_LEVEL_LOW); |
| 54 | set_irq_type(IXP4XX_GPIO_IRQ(SLOT1_INTA), IRQ_TYPE_LEVEL_LOW); |
| 55 | set_irq_type(IXP4XX_GPIO_IRQ(SLOT1_INTB), IRQ_TYPE_LEVEL_LOW); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | ixp4xx_pci_preinit(); |
| 57 | } |
| 58 | |
| 59 | |
| 60 | static int __init gtwx5715_map_irq(struct pci_dev *dev, u8 slot, u8 pin) |
| 61 | { |
| 62 | int rc; |
Krzysztof Hałasa | 8d3fdf3 | 2009-11-17 18:48:23 +0100 | [diff] [blame^] | 63 | static int gtwx5715_irqmap[SLOT_COUNT][INT_PIN_COUNT] = { |
| 64 | {IXP4XX_GPIO_IRQ(SLOT0_INTA), IXP4XX_GPIO_IRQ(SLOT0_INTB)}, |
| 65 | {IXP4XX_GPIO_IRQ(SLOT1_INTA), IXP4XX_GPIO_IRQ(SLOT1_INTB)}, |
| 66 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | |
Krzysztof Hałasa | 8d3fdf3 | 2009-11-17 18:48:23 +0100 | [diff] [blame^] | 68 | if (slot >= SLOT_COUNT || pin >= INT_PIN_COUNT) |
| 69 | rc = -1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | else |
Krzysztof Hałasa | 8d3fdf3 | 2009-11-17 18:48:23 +0100 | [diff] [blame^] | 71 | rc = gtwx5715_irqmap[slot][pin - 1]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | |
Krzysztof Hałasa | 8d3fdf3 | 2009-11-17 18:48:23 +0100 | [diff] [blame^] | 73 | printk(KERN_INFO "%s: Mapped slot %d pin %d to IRQ %d\n", |
| 74 | __func__, slot, pin, rc); |
| 75 | return rc; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | } |
| 77 | |
| 78 | struct hw_pci gtwx5715_pci __initdata = { |
| 79 | .nr_controllers = 1, |
| 80 | .preinit = gtwx5715_pci_preinit, |
| 81 | .swizzle = pci_std_swizzle, |
| 82 | .setup = ixp4xx_setup, |
| 83 | .scan = ixp4xx_scan_bus, |
| 84 | .map_irq = gtwx5715_map_irq, |
| 85 | }; |
| 86 | |
| 87 | int __init gtwx5715_pci_init(void) |
| 88 | { |
| 89 | if (machine_is_gtwx5715()) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | pci_common_init(>wx5715_pci); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 91 | |
| 92 | return 0; |
| 93 | } |
| 94 | |
| 95 | subsys_initcall(gtwx5715_pci_init); |