OpenWrt – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
4 | office | 1 | /* |
2 | * TL-WDR4900 v1 board setup |
||
3 | * |
||
4 | * Copyright (c) 2013 Gabor Juhos <juhosg@openwrt.org> |
||
5 | * |
||
6 | * Based on: |
||
7 | * p1010rdb.c: |
||
8 | * P1010RDB Board Setup |
||
9 | * Copyright 2011 Freescale Semiconductor Inc. |
||
10 | * |
||
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. |
||
15 | */ |
||
16 | |||
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> |
||
25 | |||
26 | #include <asm/time.h> |
||
27 | #include <asm/machdep.h> |
||
28 | #include <asm/pci-bridge.h> |
||
29 | #include <mm/mmu_decl.h> |
||
30 | #include <asm/prom.h> |
||
31 | #include <asm/udbg.h> |
||
32 | #include <asm/mpic.h> |
||
33 | |||
34 | #include <sysdev/fsl_soc.h> |
||
35 | #include <sysdev/fsl_pci.h> |
||
36 | |||
37 | #include "mpc85xx.h" |
||
38 | |||
39 | void __init tl_wdr4900_v1_pic_init(void) |
||
40 | { |
||
41 | struct mpic *mpic = mpic_alloc(NULL, 0, MPIC_BIG_ENDIAN | |
||
42 | MPIC_SINGLE_DEST_CPU, |
||
43 | 0, 256, " OpenPIC "); |
||
44 | |||
45 | BUG_ON(mpic == NULL); |
||
46 | |||
47 | mpic_init(mpic); |
||
48 | } |
||
49 | |||
50 | #ifdef CONFIG_PCI |
||
51 | static struct gpio_led tl_wdr4900_v1_wmac_leds_gpio[] = { |
||
52 | { |
||
53 | .name = "tp-link:blue:wps", |
||
54 | .gpio = 1, |
||
55 | .active_low = 1, |
||
56 | }, |
||
57 | }; |
||
58 | |||
59 | static struct ath9k_platform_data tl_wdr4900_v1_wmac0_data = { |
||
60 | .led_pin = 0, |
||
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), |
||
64 | }; |
||
65 | |||
66 | static struct ath9k_platform_data tl_wdr4900_v1_wmac1_data = { |
||
67 | .led_pin = 0, |
||
68 | .eeprom_name = "pci_wmac1.eeprom", |
||
69 | }; |
||
70 | |||
71 | static void tl_wdr4900_v1_pci_wmac_fixup(struct pci_dev *dev) |
||
72 | { |
||
73 | if (!machine_is(tl_wdr4900_v1)) |
||
74 | return; |
||
75 | |||
76 | if (dev->bus->number == 1 && |
||
77 | PCI_SLOT(dev->devfn) == 0) { |
||
78 | dev->dev.platform_data = &tl_wdr4900_v1_wmac0_data; |
||
79 | return; |
||
80 | } |
||
81 | |||
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; |
||
86 | |||
87 | /* |
||
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 |
||
91 | * correct ones. |
||
92 | */ |
||
93 | dev->device = 0x30; |
||
94 | dev->class = 0x028000; |
||
95 | |||
96 | pr_info("pci %s: AR9381 fixup applied\n", pci_name(dev)); |
||
97 | } |
||
98 | } |
||
99 | |||
100 | DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_ATHEROS, PCI_ANY_ID, |
||
101 | tl_wdr4900_v1_pci_wmac_fixup); |
||
102 | #endif /* CONFIG_PCI */ |
||
103 | |||
104 | /* |
||
105 | * Setup the architecture |
||
106 | */ |
||
107 | static void __init tl_wdr4900_v1_setup_arch(void) |
||
108 | { |
||
109 | if (ppc_md.progress) |
||
110 | ppc_md.progress("tl_wdr4900_v1_setup_arch()", 0); |
||
111 | |||
112 | fsl_pci_assign_primary(); |
||
113 | |||
114 | printk(KERN_INFO "TL-WDR4900 v1 board from TP-Link\n"); |
||
115 | } |
||
116 | |||
117 | machine_arch_initcall(tl_wdr4900_v1, mpc85xx_common_publish_devices); |
||
118 | machine_arch_initcall(tl_wdr4900_v1, swiotlb_setup_bus_notifier); |
||
119 | |||
120 | /* |
||
121 | * Called very early, device-tree isn't unflattened |
||
122 | */ |
||
123 | static int __init tl_wdr4900_v1_probe(void) |
||
124 | { |
||
125 | unsigned long root = of_get_flat_dt_root(); |
||
126 | |||
127 | if (of_flat_dt_is_compatible(root, "tplink,tl-wdr4900-v1")) |
||
128 | return 1; |
||
129 | |||
130 | return 0; |
||
131 | } |
||
132 | |||
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, |
||
138 | #ifdef CONFIG_PCI |
||
139 | .pcibios_fixup_bus = fsl_pcibios_fixup_bus, |
||
140 | #endif |
||
141 | .get_irq = mpic_get_irq, |
||
142 | .calibrate_decr = generic_calibrate_decr, |
||
143 | .progress = udbg_progress, |
||
144 | }; |