Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 1 | /* |
| 2 | * arch/arm/mach-ixp4xx/avila-pci.c |
| 3 | * |
| 4 | * Gateworks Avila board-level PCI initialization |
| 5 | * |
| 6 | * Author: Michael-Luke Jones <mlj28@cam.ac.uk> |
| 7 | * |
| 8 | * Based on ixdp-pci.c |
| 9 | * Copyright (C) 2002 Intel Corporation. |
| 10 | * Copyright (C) 2003-2004 MontaVista Software, Inc. |
| 11 | * |
| 12 | * Maintainer: Deepak Saxena <dsaxena@plexity.net> |
| 13 | * |
| 14 | * This program is free software; you can redistribute it and/or modify |
| 15 | * it under the terms of the GNU General Public License version 2 as |
| 16 | * published by the Free Software Foundation. |
| 17 | * |
| 18 | */ |
| 19 | |
| 20 | #include <linux/kernel.h> |
| 21 | #include <linux/pci.h> |
| 22 | #include <linux/init.h> |
| 23 | #include <linux/irq.h> |
| 24 | #include <linux/delay.h> |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 25 | #include <asm/mach/pci.h> |
| 26 | #include <asm/irq.h> |
Russell King | a09e64f | 2008-08-05 16:14:15 +0100 | [diff] [blame] | 27 | #include <mach/hardware.h> |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 28 | #include <asm/mach-types.h> |
| 29 | |
Krzysztof Hałasa | 8d3fdf3 | 2009-11-17 18:48:23 +0100 | [diff] [blame] | 30 | #define AVILA_MAX_DEV 4 |
| 31 | #define LOFT_MAX_DEV 6 |
| 32 | #define IRQ_LINES 4 |
Krzysztof Hałasa | ec66969 | 2009-11-16 15:39:11 +0100 | [diff] [blame] | 33 | |
| 34 | /* PCI controller GPIO to IRQ pin mappings */ |
Krzysztof Hałasa | 8d3fdf3 | 2009-11-17 18:48:23 +0100 | [diff] [blame] | 35 | #define INTA 11 |
| 36 | #define INTB 10 |
| 37 | #define INTC 9 |
| 38 | #define INTD 8 |
Krzysztof Hałasa | ec66969 | 2009-11-16 15:39:11 +0100 | [diff] [blame] | 39 | |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 40 | void __init avila_pci_preinit(void) |
| 41 | { |
Thomas Gleixner | 6845664a | 2011-03-24 13:25:22 +0100 | [diff] [blame] | 42 | irq_set_irq_type(IXP4XX_GPIO_IRQ(INTA), IRQ_TYPE_LEVEL_LOW); |
| 43 | irq_set_irq_type(IXP4XX_GPIO_IRQ(INTB), IRQ_TYPE_LEVEL_LOW); |
| 44 | irq_set_irq_type(IXP4XX_GPIO_IRQ(INTC), IRQ_TYPE_LEVEL_LOW); |
| 45 | irq_set_irq_type(IXP4XX_GPIO_IRQ(INTD), IRQ_TYPE_LEVEL_LOW); |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 46 | ixp4xx_pci_preinit(); |
| 47 | } |
| 48 | |
Ralf Baechle | d534194 | 2011-06-10 15:30:21 +0100 | [diff] [blame] | 49 | static int __init avila_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 50 | { |
Krzysztof Hałasa | 8d3fdf3 | 2009-11-17 18:48:23 +0100 | [diff] [blame] | 51 | static int pci_irq_table[IRQ_LINES] = { |
| 52 | IXP4XX_GPIO_IRQ(INTA), |
| 53 | IXP4XX_GPIO_IRQ(INTB), |
| 54 | IXP4XX_GPIO_IRQ(INTC), |
| 55 | IXP4XX_GPIO_IRQ(INTD) |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 56 | }; |
| 57 | |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 58 | if (slot >= 1 && |
Krzysztof Hałasa | 8d3fdf3 | 2009-11-17 18:48:23 +0100 | [diff] [blame] | 59 | slot <= (machine_is_loft() ? LOFT_MAX_DEV : AVILA_MAX_DEV) && |
| 60 | pin >= 1 && pin <= IRQ_LINES) |
| 61 | return pci_irq_table[(slot + pin - 2) % 4]; |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 62 | |
Krzysztof Hałasa | 8d3fdf3 | 2009-11-17 18:48:23 +0100 | [diff] [blame] | 63 | return -1; |
Michael-Luke Jones | 0f18597 | 2006-12-16 23:04:05 +0100 | [diff] [blame] | 64 | } |
| 65 | |
| 66 | struct hw_pci avila_pci __initdata = { |
| 67 | .nr_controllers = 1, |
| 68 | .preinit = avila_pci_preinit, |
| 69 | .swizzle = pci_std_swizzle, |
| 70 | .setup = ixp4xx_setup, |
| 71 | .scan = ixp4xx_scan_bus, |
| 72 | .map_irq = avila_map_irq, |
| 73 | }; |
| 74 | |
| 75 | int __init avila_pci_init(void) |
| 76 | { |
| 77 | if (machine_is_avila() || machine_is_loft()) |
| 78 | pci_common_init(&avila_pci); |
| 79 | return 0; |
| 80 | } |
| 81 | |
| 82 | subsys_initcall(avila_pci_init); |