apm821xx: add support for the Netgear Centria N900 WNDR4700/WNDR4720
[openwrt/openwrt.git] / target / linux / apm821xx / files / arch / powerpc / platforms / 44x / wndr4700.c
1 /*
2 * Netgear Centria N900 WNDR4700/WNDR4720 platform support
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; version 2 of the License.
7 *
8 * This implemention is based on the simple platform support for the
9 * PowerPC 44x chips.
10 */
11
12 #include <asm/machdep.h>
13 #include <asm/pci-bridge.h>
14 #include <asm/ppc4xx.h>
15 #include <asm/prom.h>
16 #include <asm/time.h>
17 #include <asm/udbg.h>
18 #include <asm/uic.h>
19
20 #include <linux/init.h>
21 #include <linux/of_platform.h>
22 #include <linux/pci.h>
23 #include <linux/platform_device.h>
24 #include <linux/ath9k_platform.h>
25 #include <linux/firmware.h>
26 #include <linux/delay.h>
27 #include <asm/unaligned.h>
28
29 static const struct of_device_id ppc44x_of_bus[] __initconst = {
30 { .compatible = "ibm,plb4", },
31 { .compatible = "ibm,opb", },
32 { .compatible = "ibm,ebc", },
33 { .compatible = "simple-bus", },
34 {},
35 };
36
37 static int __init ppc44x_device_probe(void)
38 {
39 of_platform_bus_probe(NULL, ppc44x_of_bus, NULL);
40
41 return 0;
42 }
43 machine_device_initcall(wndr4700, ppc44x_device_probe);
44
45 static char *board[] __initdata = {
46 "netgear,wndr4700",
47 };
48
49 static int __init ppc44x_probe(void)
50 {
51 unsigned long root = of_get_flat_dt_root();
52 int i = 0;
53
54 pcie_bus_config = PCIE_BUS_PEER2PEER; /* force 128 Byte MPS */
55
56 for (i = 0; i < ARRAY_SIZE(board); i++) {
57 if (of_flat_dt_is_compatible(root, board[i])) {
58 pci_set_flags(PCI_REASSIGN_ALL_RSRC); /* PCI_PROBE_ONLY */
59 return 1;
60 }
61 }
62
63 return 0;
64 }
65
66 define_machine(wndr4700) {
67 .name = "WNDR4700 Platform",
68 .probe = ppc44x_probe,
69 .progress = udbg_progress,
70 .init_IRQ = uic_init_tree,
71 .get_irq = uic_get_irq,
72 .restart = ppc4xx_reset_system,
73 .calibrate_decr = generic_calibrate_decr,
74 };
75
76 static struct ath9k_platform_data ar9380_wmac0_data = {
77 .led_pin = -1,
78 .eeprom_name = "pci_wmac1.eeprom",
79 };
80 static struct ath9k_platform_data ar9580_wmac1_data = {
81 .led_pin = -1,
82 .eeprom_name = "pci_wmac0.eeprom",
83 };
84
85 static void load_eeprom_ar9380(struct pci_dev *dev)
86 {
87 dev->dev.platform_data = &ar9380_wmac0_data;
88 }
89
90 static void load_eeprom_ar9580(struct pci_dev *dev)
91 {
92 dev->dev.platform_data = &ar9580_wmac1_data;
93 }
94
95 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATHEROS, 0x0030, load_eeprom_ar9380);
96 DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATHEROS, 0x0033, load_eeprom_ar9580);