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 | a68ad4d | 2012-03-14 10:36:09 +0100 | [diff] [blame^] | 17 | static int (*ath79_pci_plat_dev_init)(struct pci_dev *dev); |
Gabor Juhos | d624bd3 | 2012-03-14 10:29:26 +0100 | [diff] [blame] | 18 | static struct ar724x_pci_data *pci_data; |
Gabor Juhos | e2dbdc4 | 2012-03-14 10:29:21 +0100 | [diff] [blame] | 19 | static int pci_data_size; |
| 20 | |
Gabor Juhos | d624bd3 | 2012-03-14 10:29:26 +0100 | [diff] [blame] | 21 | void ar724x_pci_add_data(struct ar724x_pci_data *data, int size) |
Gabor Juhos | e2dbdc4 | 2012-03-14 10:29:21 +0100 | [diff] [blame] | 22 | { |
| 23 | pci_data = data; |
| 24 | pci_data_size = size; |
| 25 | } |
| 26 | |
| 27 | int __init pcibios_map_irq(const struct pci_dev *dev, uint8_t slot, uint8_t pin) |
| 28 | { |
| 29 | unsigned int devfn = dev->devfn; |
| 30 | int irq = -1; |
| 31 | |
| 32 | if (devfn > pci_data_size - 1) |
| 33 | return irq; |
| 34 | |
| 35 | irq = pci_data[devfn].irq; |
| 36 | |
| 37 | return irq; |
| 38 | } |
| 39 | |
| 40 | int pcibios_plat_dev_init(struct pci_dev *dev) |
| 41 | { |
Gabor Juhos | a68ad4d | 2012-03-14 10:36:09 +0100 | [diff] [blame^] | 42 | if (ath79_pci_plat_dev_init) |
| 43 | return ath79_pci_plat_dev_init(dev); |
Gabor Juhos | e2dbdc4 | 2012-03-14 10:29:21 +0100 | [diff] [blame] | 44 | |
Gabor Juhos | a68ad4d | 2012-03-14 10:36:09 +0100 | [diff] [blame^] | 45 | return 0; |
| 46 | } |
Gabor Juhos | e2dbdc4 | 2012-03-14 10:29:21 +0100 | [diff] [blame] | 47 | |
Gabor Juhos | a68ad4d | 2012-03-14 10:36:09 +0100 | [diff] [blame^] | 48 | void __init ath79_pci_set_plat_dev_init(int (*func)(struct pci_dev *dev)) |
| 49 | { |
| 50 | ath79_pci_plat_dev_init = func; |
Gabor Juhos | e2dbdc4 | 2012-03-14 10:29:21 +0100 | [diff] [blame] | 51 | } |
Gabor Juhos | 6335aef | 2012-03-14 10:29:24 +0100 | [diff] [blame] | 52 | |
| 53 | int __init ath79_register_pci(void) |
| 54 | { |
| 55 | if (soc_is_ar724x()) |
Gabor Juhos | 4c07c7d | 2012-03-14 10:36:07 +0100 | [diff] [blame] | 56 | return ar724x_pcibios_init(ATH79_CPU_IRQ_IP2); |
Gabor Juhos | 6335aef | 2012-03-14 10:29:24 +0100 | [diff] [blame] | 57 | |
| 58 | return -ENODEV; |
| 59 | } |