2 * TL-WDR4900 v1 board setup
4 * Copyright (c) 2013 Gabor Juhos <juhosg@openwrt.org>
9 * Copyright 2011 Freescale Semiconductor Inc.
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2 of the License, or (at your
14 * option) any later version.
17 #include <linux/stddef.h>
18 #include <linux/kernel.h>
19 #include <linux/pci.h>
20 #include <linux/delay.h>
21 #include <linux/interrupt.h>
22 #include <linux/of_platform.h>
23 #include <linux/ath9k_platform.h>
24 #include <linux/leds.h>
27 #include <asm/machdep.h>
28 #include <asm/pci-bridge.h>
29 #include <mm/mmu_decl.h>
34 #include <sysdev/fsl_soc.h>
35 #include <sysdev/fsl_pci.h>
39 void __init tl_wdr4900_v1_pic_init(void)
41 struct mpic *mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN |
51 static struct gpio_led tl_wdr4900_v1_wmac_leds_gpio[] = {
53 .name = "tp-link:blue:wps",
59 static struct ath9k_platform_data tl_wdr4900_v1_wmac0_data = {
61 .eeprom_name = "pci_wmac0.eeprom",
62 .leds = tl_wdr4900_v1_wmac_leds_gpio,
63 .num_leds = ARRAY_SIZE(tl_wdr4900_v1_wmac_leds_gpio),
66 static struct ath9k_platform_data tl_wdr4900_v1_wmac1_data = {
68 .eeprom_name = "pci_wmac1.eeprom",
71 static void tl_wdr4900_v1_pci_wmac_fixup(struct pci_dev *dev)
73 if (!machine_is(tl_wdr4900_v1))
76 if (dev->bus->number == 1 &&
77 PCI_SLOT(dev->devfn) == 0) {
78 dev->dev.platform_data = &tl_wdr4900_v1_wmac0_data;
82 if (dev->bus->number == 3 &&
83 PCI_SLOT(dev->devfn) == 0 &&
84 dev->device == 0xabcd) {
85 dev->dev.platform_data = &tl_wdr4900_v1_wmac1_data;
88 * The PCI header of the AR9381 chip is not programmed
89 * correctly by the bootloader and the device uses wrong
90 * data due to that. Replace the broken values with the
94 dev->class = 0x028000;
96 pr_info("pci %s: AR9381 fixup applied\n", pci_name(dev));
100 DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_ATHEROS, PCI_ANY_ID,
101 tl_wdr4900_v1_pci_wmac_fixup);
102 #endif /* CONFIG_PCI */
105 * Setup the architecture
107 static void __init tl_wdr4900_v1_setup_arch(void)
110 ppc_md.progress("tl_wdr4900_v1_setup_arch()", 0);
112 fsl_pci_assign_primary();
114 printk(KERN_INFO "TL-WDR4900 v1 board from TP-Link\n");
117 machine_arch_initcall(tl_wdr4900_v1, mpc85xx_common_publish_devices);
118 machine_arch_initcall(tl_wdr4900_v1, swiotlb_setup_bus_notifier);
121 * Called very early, device-tree isn't unflattened
123 static int __init tl_wdr4900_v1_probe(void)
125 unsigned long root = of_get_flat_dt_root();
127 if (of_flat_dt_is_compatible(root, "tp-link,TL-WDR4900v1"))
133 define_machine(tl_wdr4900_v1) {
134 .name = "Freescale P1014",
135 .probe = tl_wdr4900_v1_probe,
136 .setup_arch = tl_wdr4900_v1_setup_arch,
137 .init_IRQ = tl_wdr4900_v1_pic_init,
139 .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
141 .get_irq = mpic_get_irq,
142 .calibrate_decr = generic_calibrate_decr,
143 .progress = udbg_progress,