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> |
| 13 | #include <asm/mach-ath79/pci.h> |
Gabor Juhos | 3a6208d | 2012-03-14 10:29:22 +0100 | [diff] [blame] | 14 | #include "pci.h" |
Gabor Juhos | e2dbdc4 | 2012-03-14 10:29:21 +0100 | [diff] [blame] | 15 | |
| 16 | static struct ath724x_pci_data *pci_data; |
| 17 | static int pci_data_size; |
| 18 | |
| 19 | void ath724x_pci_add_data(struct ath724x_pci_data *data, int size) |
| 20 | { |
| 21 | pci_data = data; |
| 22 | pci_data_size = size; |
| 23 | } |
| 24 | |
| 25 | int __init pcibios_map_irq(const struct pci_dev *dev, uint8_t slot, uint8_t pin) |
| 26 | { |
| 27 | unsigned int devfn = dev->devfn; |
| 28 | int irq = -1; |
| 29 | |
| 30 | if (devfn > pci_data_size - 1) |
| 31 | return irq; |
| 32 | |
| 33 | irq = pci_data[devfn].irq; |
| 34 | |
| 35 | return irq; |
| 36 | } |
| 37 | |
| 38 | int pcibios_plat_dev_init(struct pci_dev *dev) |
| 39 | { |
| 40 | unsigned int devfn = dev->devfn; |
| 41 | |
| 42 | if (devfn > pci_data_size - 1) |
| 43 | return PCIBIOS_DEVICE_NOT_FOUND; |
| 44 | |
| 45 | dev->dev.platform_data = pci_data[devfn].pdata; |
| 46 | |
| 47 | return PCIBIOS_SUCCESSFUL; |
| 48 | } |
Gabor Juhos | 6335aef | 2012-03-14 10:29:24 +0100 | [diff] [blame^] | 49 | |
| 50 | int __init ath79_register_pci(void) |
| 51 | { |
| 52 | if (soc_is_ar724x()) |
| 53 | return ath724x_pcibios_init(); |
| 54 | |
| 55 | return -ENODEV; |
| 56 | } |