Gabor Juhos | e2dbdc4 | 2012-03-14 10:29:21 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Atheros AR71XX/AR724X specific PCI setup code |
| 3 | * |
| 4 | * Copyright (C) 2011 René Bolldorf <xsecute@googlemail.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify it |
| 7 | * under the terms of the GNU General Public License version 2 as published |
| 8 | * by the Free Software Foundation. |
| 9 | */ |
| 10 | |
| 11 | #include <linux/pci.h> |
Gabor Juhos | 6335aef | 2012-03-14 10:29:24 +0100 | [diff] [blame] | 12 | #include <asm/mach-ath79/ath79.h> |
Gabor Juhos | 4c07c7d | 2012-03-14 10:36:07 +0100 | [diff] [blame^] | 13 | #include <asm/mach-ath79/irq.h> |
Gabor Juhos | 6335aef | 2012-03-14 10:29:24 +0100 | [diff] [blame] | 14 | #include <asm/mach-ath79/pci.h> |
Gabor Juhos | 3a6208d | 2012-03-14 10:29:22 +0100 | [diff] [blame] | 15 | #include "pci.h" |
Gabor Juhos | e2dbdc4 | 2012-03-14 10:29:21 +0100 | [diff] [blame] | 16 | |
Gabor Juhos | d624bd3 | 2012-03-14 10:29:26 +0100 | [diff] [blame] | 17 | static struct ar724x_pci_data *pci_data; |
Gabor Juhos | e2dbdc4 | 2012-03-14 10:29:21 +0100 | [diff] [blame] | 18 | static int pci_data_size; |
| 19 | |
Gabor Juhos | d624bd3 | 2012-03-14 10:29:26 +0100 | [diff] [blame] | 20 | void ar724x_pci_add_data(struct ar724x_pci_data *data, int size) |
Gabor Juhos | e2dbdc4 | 2012-03-14 10:29:21 +0100 | [diff] [blame] | 21 | { |
| 22 | pci_data = data; |
| 23 | pci_data_size = size; |
| 24 | } |
| 25 | |
| 26 | int __init pcibios_map_irq(const struct pci_dev *dev, uint8_t slot, uint8_t pin) |
| 27 | { |
| 28 | unsigned int devfn = dev->devfn; |
| 29 | int irq = -1; |
| 30 | |
| 31 | if (devfn > pci_data_size - 1) |
| 32 | return irq; |
| 33 | |
| 34 | irq = pci_data[devfn].irq; |
| 35 | |
| 36 | return irq; |
| 37 | } |
| 38 | |
| 39 | int pcibios_plat_dev_init(struct pci_dev *dev) |
| 40 | { |
| 41 | unsigned int devfn = dev->devfn; |
| 42 | |
| 43 | if (devfn > pci_data_size - 1) |
| 44 | return PCIBIOS_DEVICE_NOT_FOUND; |
| 45 | |
| 46 | dev->dev.platform_data = pci_data[devfn].pdata; |
| 47 | |
| 48 | return PCIBIOS_SUCCESSFUL; |
| 49 | } |
Gabor Juhos | 6335aef | 2012-03-14 10:29:24 +0100 | [diff] [blame] | 50 | |
| 51 | int __init ath79_register_pci(void) |
| 52 | { |
| 53 | if (soc_is_ar724x()) |
Gabor Juhos | 4c07c7d | 2012-03-14 10:36:07 +0100 | [diff] [blame^] | 54 | return ar724x_pcibios_init(ATH79_CPU_IRQ_IP2); |
Gabor Juhos | 6335aef | 2012-03-14 10:29:24 +0100 | [diff] [blame] | 55 | |
| 56 | return -ENODEV; |
| 57 | } |