OpenWrt – Diff between revs 2 and 3
?pathlinks?
Rev 2 | Rev 3 | |||
---|---|---|---|---|
1 | From bbebbf735a02b6d044ed928978ab4bd5f1833364 Mon Sep 17 00:00:00 2001 |
1 | From bbebbf735a02b6d044ed928978ab4bd5f1833364 Mon Sep 17 00:00:00 2001 |
|
2 | From: Jonas Gorski <jonas.gorski@gmail.com> |
2 | From: Jonas Gorski <jonas.gorski@gmail.com> |
|
3 | Date: Thu, 3 May 2012 14:36:11 +0200 |
3 | Date: Thu, 3 May 2012 14:36:11 +0200 |
|
4 | Subject: [PATCH 61/72] BCM63XX: add a fixup for ath9k devices |
4 | Subject: [PATCH 61/72] BCM63XX: add a fixup for ath9k devices |
|
5 | |
5 | |
|
6 | --- |
6 | --- |
|
7 | arch/mips/bcm63xx/Makefile | 3 +- |
7 | arch/mips/bcm63xx/Makefile | 3 +- |
|
8 | arch/mips/bcm63xx/pci-ath9k-fixup.c | 190 ++++++++++++++++++++ |
8 | arch/mips/bcm63xx/pci-ath9k-fixup.c | 190 ++++++++++++++++++++ |
|
9 | .../include/asm/mach-bcm63xx/pci_ath9k_fixup.h | 7 + |
9 | .../include/asm/mach-bcm63xx/pci_ath9k_fixup.h | 7 + |
|
10 | 3 files changed, 199 insertions(+), 1 deletion(-) |
10 | 3 files changed, 199 insertions(+), 1 deletion(-) |
|
11 | create mode 100644 arch/mips/bcm63xx/pci-ath9k-fixup.c |
11 | create mode 100644 arch/mips/bcm63xx/pci-ath9k-fixup.c |
|
12 | create mode 100644 arch/mips/include/asm/mach-bcm63xx/pci_ath9k_fixup.h |
12 | create mode 100644 arch/mips/include/asm/mach-bcm63xx/pci_ath9k_fixup.h |
|
13 | |
13 | |
|
14 | --- a/arch/mips/bcm63xx/Makefile |
14 | --- a/arch/mips/bcm63xx/Makefile |
|
15 | +++ b/arch/mips/bcm63xx/Makefile |
15 | +++ b/arch/mips/bcm63xx/Makefile |
|
16 | @@ -3,7 +3,7 @@ obj-y += clk.o cpu.o cs.o gpio.o irq.o |
16 | @@ -3,7 +3,7 @@ obj-y += clk.o cpu.o cs.o gpio.o irq.o |
|
17 | setup.o timer.o dev-enet.o dev-flash.o dev-pcmcia.o \ |
17 | setup.o timer.o dev-dsp.o dev-enet.o dev-flash.o \ |
|
18 | dev-rng.o dev-wdt.o \ |
18 | dev-pcmcia.o dev-rng.o \ |
|
19 | dev-usb-ehci.o dev-usb-ohci.o dev-usb-usbd.o usb-common.o \ |
19 | dev-wdt.o dev-usb-ehci.o dev-usb-ohci.o dev-usb-usbd.o \ |
|
20 | - sprom.o |
20 | - usb-common.o sprom.o |
|
21 | + pci-ath9k-fixup.o sprom.o |
21 | + pci-ath9k-fixup.o usb-common.o sprom.o |
|
22 | obj-$(CONFIG_EARLY_PRINTK) += early_printk.o |
22 | obj-$(CONFIG_EARLY_PRINTK) += early_printk.o |
|
23 | |
23 | |
|
24 | obj-y += boards/ |
24 | obj-y += boards/ |
|
25 | --- /dev/null |
25 | --- /dev/null |
|
26 | +++ b/arch/mips/bcm63xx/pci-ath9k-fixup.c |
26 | +++ b/arch/mips/bcm63xx/pci-ath9k-fixup.c |
|
27 | @@ -0,0 +1,200 @@ |
27 | @@ -0,0 +1,200 @@ |
|
28 | +/* |
28 | +/* |
|
29 | + * Broadcom BCM63XX Ath9k EEPROM fixup helper. |
29 | + * Broadcom BCM63XX Ath9k EEPROM fixup helper. |
|
30 | + * |
30 | + * |
|
31 | + * Copytight (C) 2012 Jonas Gorski <jonas.gorski@gmail.com> |
31 | + * Copytight (C) 2012 Jonas Gorski <jonas.gorski@gmail.com> |
|
32 | + * |
32 | + * |
|
33 | + * Based on |
33 | + * Based on |
|
34 | + * |
34 | + * |
|
35 | + * Atheros AP94 reference board PCI initialization |
35 | + * Atheros AP94 reference board PCI initialization |
|
36 | + * |
36 | + * |
|
37 | + * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org> |
37 | + * Copyright (C) 2009-2010 Gabor Juhos <juhosg@openwrt.org> |
|
38 | + * |
38 | + * |
|
39 | + * This program is free software; you can redistribute it and/or modify it |
39 | + * This program is free software; you can redistribute it and/or modify it |
|
40 | + * under the terms of the GNU General Public License version 2 as published |
40 | + * under the terms of the GNU General Public License version 2 as published |
|
41 | + * by the Free Software Foundation. |
41 | + * by the Free Software Foundation. |
|
42 | + */ |
42 | + */ |
|
43 | + |
43 | + |
|
44 | +#include <linux/if_ether.h> |
44 | +#include <linux/if_ether.h> |
|
45 | +#include <linux/pci.h> |
45 | +#include <linux/pci.h> |
|
46 | +#include <linux/delay.h> |
46 | +#include <linux/delay.h> |
|
47 | +#include <linux/ath9k_platform.h> |
47 | +#include <linux/ath9k_platform.h> |
|
48 | + |
48 | + |
|
49 | +#include <bcm63xx_cpu.h> |
49 | +#include <bcm63xx_cpu.h> |
|
50 | +#include <bcm63xx_regs.h> |
50 | +#include <bcm63xx_regs.h> |
|
51 | +#include <bcm63xx_io.h> |
51 | +#include <bcm63xx_io.h> |
|
52 | +#include <bcm63xx_nvram.h> |
52 | +#include <bcm63xx_nvram.h> |
|
53 | +#include <bcm63xx_dev_pci.h> |
53 | +#include <bcm63xx_dev_pci.h> |
|
54 | +#include <bcm63xx_dev_flash.h> |
54 | +#include <bcm63xx_dev_flash.h> |
|
55 | +#include <pci_ath9k_fixup.h> |
55 | +#include <pci_ath9k_fixup.h> |
|
56 | + |
56 | + |
|
57 | +#define bcm_hsspi_writel(v, o) bcm_rset_writel(RSET_HSSPI, (v), (o)) |
57 | +#define bcm_hsspi_writel(v, o) bcm_rset_writel(RSET_HSSPI, (v), (o)) |
|
58 | + |
58 | + |
|
59 | +struct ath9k_fixup { |
59 | +struct ath9k_fixup { |
|
60 | + unsigned slot; |
60 | + unsigned slot; |
|
61 | + u8 mac[ETH_ALEN]; |
61 | + u8 mac[ETH_ALEN]; |
|
62 | + struct ath9k_platform_data pdata; |
62 | + struct ath9k_platform_data pdata; |
|
63 | +}; |
63 | +}; |
|
64 | + |
64 | + |
|
65 | +static int ath9k_num_fixups; |
65 | +static int ath9k_num_fixups; |
|
66 | +static struct ath9k_fixup ath9k_fixups[2] = { |
66 | +static struct ath9k_fixup ath9k_fixups[2] = { |
|
67 | + { |
67 | + { |
|
68 | + .slot = 255, |
68 | + .slot = 255, |
|
69 | + .pdata = { |
69 | + .pdata = { |
|
70 | + .led_pin = -1, |
70 | + .led_pin = -1, |
|
71 | + }, |
71 | + }, |
|
72 | + }, |
72 | + }, |
|
73 | + { |
73 | + { |
|
74 | + .slot = 255, |
74 | + .slot = 255, |
|
75 | + .pdata = { |
75 | + .pdata = { |
|
76 | + .led_pin = -1, |
76 | + .led_pin = -1, |
|
77 | + }, |
77 | + }, |
|
78 | + }, |
78 | + }, |
|
79 | +}; |
79 | +}; |
|
80 | + |
80 | + |
|
81 | +static u16 *bcm63xx_read_eeprom(u16 *eeprom, u32 offset) |
81 | +static u16 *bcm63xx_read_eeprom(u16 *eeprom, u32 offset) |
|
82 | +{ |
82 | +{ |
|
83 | + u32 addr; |
83 | + u32 addr; |
|
84 | + |
84 | + |
|
85 | + if (BCMCPU_IS_6328()) { |
85 | + if (BCMCPU_IS_6328()) { |
|
86 | + addr = 0x18000000; |
86 | + addr = 0x18000000; |
|
87 | + } else { |
87 | + } else { |
|
88 | + addr = bcm_mpi_readl(MPI_CSBASE_REG(0)); |
88 | + addr = bcm_mpi_readl(MPI_CSBASE_REG(0)); |
|
89 | + addr &= MPI_CSBASE_BASE_MASK; |
89 | + addr &= MPI_CSBASE_BASE_MASK; |
|
90 | + } |
90 | + } |
|
91 | + |
91 | + |
|
92 | + switch (bcm63xx_flash_get_type()) { |
92 | + switch (bcm63xx_flash_get_type()) { |
|
93 | + case BCM63XX_FLASH_TYPE_PARALLEL: |
93 | + case BCM63XX_FLASH_TYPE_PARALLEL: |
|
94 | + memcpy(eeprom, (void *)KSEG1ADDR(addr + offset), ATH9K_PLAT_EEP_MAX_WORDS * sizeof(u16)); |
94 | + memcpy(eeprom, (void *)KSEG1ADDR(addr + offset), ATH9K_PLAT_EEP_MAX_WORDS * sizeof(u16)); |
|
95 | + return eeprom; |
95 | + return eeprom; |
|
96 | + case BCM63XX_FLASH_TYPE_SERIAL: |
96 | + case BCM63XX_FLASH_TYPE_SERIAL: |
|
97 | + /* the first megabyte is memory mapped */ |
97 | + /* the first megabyte is memory mapped */ |
|
98 | + if (offset < 0x100000) { |
98 | + if (offset < 0x100000) { |
|
99 | + memcpy(eeprom, (void *)KSEG1ADDR(addr + offset), ATH9K_PLAT_EEP_MAX_WORDS * sizeof(u16)); |
99 | + memcpy(eeprom, (void *)KSEG1ADDR(addr + offset), ATH9K_PLAT_EEP_MAX_WORDS * sizeof(u16)); |
|
100 | + return eeprom; |
100 | + return eeprom; |
|
101 | + } |
101 | + } |
|
102 | + |
102 | + |
|
103 | + if (BCMCPU_IS_6328()) { |
103 | + if (BCMCPU_IS_6328()) { |
|
104 | + /* we can change the memory mapped megabyte */ |
104 | + /* we can change the memory mapped megabyte */ |
|
105 | + bcm_hsspi_writel(offset & 0xf00000, 0x18); |
105 | + bcm_hsspi_writel(offset & 0xf00000, 0x18); |
|
106 | + memcpy(eeprom, (void *)KSEG1ADDR(addr + (offset & 0xfffff)), ATH9K_PLAT_EEP_MAX_WORDS * sizeof(u16)); |
106 | + memcpy(eeprom, (void *)KSEG1ADDR(addr + (offset & 0xfffff)), ATH9K_PLAT_EEP_MAX_WORDS * sizeof(u16)); |
|
107 | + bcm_hsspi_writel(0, 0x18); |
107 | + bcm_hsspi_writel(0, 0x18); |
|
108 | + return eeprom; |
108 | + return eeprom; |
|
109 | + } |
109 | + } |
|
110 | + /* can't do anything here without talking to the SPI controller. */ |
110 | + /* can't do anything here without talking to the SPI controller. */ |
|
111 | + case BCM63XX_FLASH_TYPE_NAND: |
111 | + case BCM63XX_FLASH_TYPE_NAND: |
|
112 | + default: |
112 | + default: |
|
113 | + return NULL; |
113 | + return NULL; |
|
114 | + } |
114 | + } |
|
115 | +} |
115 | +} |
|
116 | + |
116 | + |
|
117 | +static void ath9k_pci_fixup(struct pci_dev *dev) |
117 | +static void ath9k_pci_fixup(struct pci_dev *dev) |
|
118 | +{ |
118 | +{ |
|
119 | + void __iomem *mem; |
119 | + void __iomem *mem; |
|
120 | + struct ath9k_platform_data *pdata = NULL; |
120 | + struct ath9k_platform_data *pdata = NULL; |
|
121 | + struct pci_dev *bridge = pci_upstream_bridge(dev); |
121 | + struct pci_dev *bridge = pci_upstream_bridge(dev); |
|
122 | + u16 *cal_data = NULL; |
122 | + u16 *cal_data = NULL; |
|
123 | + u16 cmd; |
123 | + u16 cmd; |
|
124 | + u32 bar0; |
124 | + u32 bar0; |
|
125 | + u32 val; |
125 | + u32 val; |
|
126 | + unsigned i; |
126 | + unsigned i; |
|
127 | + |
127 | + |
|
128 | + for (i = 0; i < ath9k_num_fixups; i++) { |
128 | + for (i = 0; i < ath9k_num_fixups; i++) { |
|
129 | + if (ath9k_fixups[i].slot != PCI_SLOT(dev->devfn)) |
129 | + if (ath9k_fixups[i].slot != PCI_SLOT(dev->devfn)) |
|
130 | + continue; |
130 | + continue; |
|
131 | + |
131 | + |
|
132 | + cal_data = ath9k_fixups[i].pdata.eeprom_data; |
132 | + cal_data = ath9k_fixups[i].pdata.eeprom_data; |
|
133 | + pdata = &ath9k_fixups[i].pdata; |
133 | + pdata = &ath9k_fixups[i].pdata; |
|
134 | + break; |
134 | + break; |
|
135 | + } |
135 | + } |
|
136 | + |
136 | + |
|
137 | + if (cal_data == NULL) |
137 | + if (cal_data == NULL) |
|
138 | + return; |
138 | + return; |
|
139 | + |
139 | + |
|
140 | + if (*cal_data != 0xa55a) { |
140 | + if (*cal_data != 0xa55a) { |
|
141 | + pr_err("pci %s: invalid calibration data\n", pci_name(dev)); |
141 | + pr_err("pci %s: invalid calibration data\n", pci_name(dev)); |
|
142 | + return; |
142 | + return; |
|
143 | + } |
143 | + } |
|
144 | + |
144 | + |
|
145 | + pr_info("pci %s: fixup device configuration\n", pci_name(dev)); |
145 | + pr_info("pci %s: fixup device configuration\n", pci_name(dev)); |
|
146 | + |
146 | + |
|
147 | + switch (bcm63xx_get_cpu_id()) { |
147 | + switch (bcm63xx_get_cpu_id()) { |
|
148 | + case BCM6328_CPU_ID: |
148 | + case BCM6328_CPU_ID: |
|
149 | + val = BCM_PCIE_MEM_BASE_PA_6328; |
149 | + val = BCM_PCIE_MEM_BASE_PA_6328; |
|
150 | + break; |
150 | + break; |
|
151 | + case BCM6348_CPU_ID: |
151 | + case BCM6348_CPU_ID: |
|
152 | + case BCM6358_CPU_ID: |
152 | + case BCM6358_CPU_ID: |
|
153 | + case BCM6368_CPU_ID: |
153 | + case BCM6368_CPU_ID: |
|
154 | + val = BCM_PCI_MEM_BASE_PA; |
154 | + val = BCM_PCI_MEM_BASE_PA; |
|
155 | + break; |
155 | + break; |
|
156 | + default: |
156 | + default: |
|
157 | + BUG(); |
157 | + BUG(); |
|
158 | + } |
158 | + } |
|
159 | + |
159 | + |
|
160 | + mem = ioremap(val, 0x10000); |
160 | + mem = ioremap(val, 0x10000); |
|
161 | + if (!mem) { |
161 | + if (!mem) { |
|
162 | + pr_err("pci %s: ioremap error\n", pci_name(dev)); |
162 | + pr_err("pci %s: ioremap error\n", pci_name(dev)); |
|
163 | + return; |
163 | + return; |
|
164 | + } |
164 | + } |
|
165 | + |
165 | + |
|
166 | + if (bridge) |
166 | + if (bridge) |
|
167 | + pci_enable_device(bridge); |
167 | + pci_enable_device(bridge); |
|
168 | + |
168 | + |
|
169 | + pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &bar0); |
169 | + pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &bar0); |
|
170 | + pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &bar0); |
170 | + pci_read_config_dword(dev, PCI_BASE_ADDRESS_0, &bar0); |
|
171 | + pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, val); |
171 | + pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, val); |
|
172 | + |
172 | + |
|
173 | + pci_read_config_word(dev, PCI_COMMAND, &cmd); |
173 | + pci_read_config_word(dev, PCI_COMMAND, &cmd); |
|
174 | + cmd |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY; |
174 | + cmd |= PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY; |
|
175 | + pci_write_config_word(dev, PCI_COMMAND, cmd); |
175 | + pci_write_config_word(dev, PCI_COMMAND, cmd); |
|
176 | + |
176 | + |
|
177 | + /* set offset to first reg address */ |
177 | + /* set offset to first reg address */ |
|
178 | + cal_data += 3; |
178 | + cal_data += 3; |
|
179 | + while(*cal_data != 0xffff) { |
179 | + while(*cal_data != 0xffff) { |
|
180 | + u32 reg; |
180 | + u32 reg; |
|
181 | + reg = *cal_data++; |
181 | + reg = *cal_data++; |
|
182 | + val = *cal_data++; |
182 | + val = *cal_data++; |
|
183 | + val |= (*cal_data++) << 16; |
183 | + val |= (*cal_data++) << 16; |
|
184 | + |
184 | + |
|
185 | + writel(val, mem + reg); |
185 | + writel(val, mem + reg); |
|
186 | + udelay(100); |
186 | + udelay(100); |
|
187 | + } |
187 | + } |
|
188 | + |
188 | + |
|
189 | + pci_read_config_dword(dev, PCI_VENDOR_ID, &val); |
189 | + pci_read_config_dword(dev, PCI_VENDOR_ID, &val); |
|
190 | + dev->vendor = val & 0xffff; |
190 | + dev->vendor = val & 0xffff; |
|
191 | + dev->device = (val >> 16) & 0xffff; |
191 | + dev->device = (val >> 16) & 0xffff; |
|
192 | + |
192 | + |
|
193 | + pci_read_config_dword(dev, PCI_CLASS_REVISION, &val); |
193 | + pci_read_config_dword(dev, PCI_CLASS_REVISION, &val); |
|
194 | + dev->revision = val & 0xff; |
194 | + dev->revision = val & 0xff; |
|
195 | + dev->class = val >> 8; /* upper 3 bytes */ |
195 | + dev->class = val >> 8; /* upper 3 bytes */ |
|
196 | + |
196 | + |
|
197 | + pci_read_config_word(dev, PCI_COMMAND, &cmd); |
197 | + pci_read_config_word(dev, PCI_COMMAND, &cmd); |
|
198 | + cmd &= ~(PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY); |
198 | + cmd &= ~(PCI_COMMAND_MASTER | PCI_COMMAND_MEMORY); |
|
199 | + pci_write_config_word(dev, PCI_COMMAND, cmd); |
199 | + pci_write_config_word(dev, PCI_COMMAND, cmd); |
|
200 | + |
200 | + |
|
201 | + pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, bar0); |
201 | + pci_write_config_dword(dev, PCI_BASE_ADDRESS_0, bar0); |
|
202 | + |
202 | + |
|
203 | + if (bridge) |
203 | + if (bridge) |
|
204 | + pci_disable_device(bridge); |
204 | + pci_disable_device(bridge); |
|
205 | + |
205 | + |
|
206 | + iounmap(mem); |
206 | + iounmap(mem); |
|
207 | + |
207 | + |
|
208 | + dev->dev.platform_data = pdata; |
208 | + dev->dev.platform_data = pdata; |
|
209 | +} |
209 | +} |
|
210 | +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATHEROS, PCI_ANY_ID, ath9k_pci_fixup); |
210 | +DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATHEROS, PCI_ANY_ID, ath9k_pci_fixup); |
|
211 | + |
211 | + |
|
212 | +void __init pci_enable_ath9k_fixup(unsigned slot, u32 offset) |
212 | +void __init pci_enable_ath9k_fixup(unsigned slot, u32 offset) |
|
213 | +{ |
213 | +{ |
|
214 | + if (ath9k_num_fixups >= ARRAY_SIZE(ath9k_fixups)) |
214 | + if (ath9k_num_fixups >= ARRAY_SIZE(ath9k_fixups)) |
|
215 | + return; |
215 | + return; |
|
216 | + |
216 | + |
|
217 | + ath9k_fixups[ath9k_num_fixups].slot = slot; |
217 | + ath9k_fixups[ath9k_num_fixups].slot = slot; |
|
218 | + |
218 | + |
|
219 | + if (!bcm63xx_read_eeprom(ath9k_fixups[ath9k_num_fixups].pdata.eeprom_data, offset)) |
219 | + if (!bcm63xx_read_eeprom(ath9k_fixups[ath9k_num_fixups].pdata.eeprom_data, offset)) |
|
220 | + return; |
220 | + return; |
|
221 | + |
221 | + |
|
222 | + if (bcm63xx_nvram_get_mac_address(ath9k_fixups[ath9k_num_fixups].mac)) |
222 | + if (bcm63xx_nvram_get_mac_address(ath9k_fixups[ath9k_num_fixups].mac)) |
|
223 | + return; |
223 | + return; |
|
224 | + |
224 | + |
|
225 | + ath9k_fixups[ath9k_num_fixups].pdata.macaddr = ath9k_fixups[ath9k_num_fixups].mac; |
225 | + ath9k_fixups[ath9k_num_fixups].pdata.macaddr = ath9k_fixups[ath9k_num_fixups].mac; |
|
226 | + ath9k_num_fixups++; |
226 | + ath9k_num_fixups++; |
|
227 | +} |
227 | +} |
|
228 | --- /dev/null |
228 | --- /dev/null |
|
229 | +++ b/arch/mips/include/asm/mach-bcm63xx/pci_ath9k_fixup.h |
229 | +++ b/arch/mips/include/asm/mach-bcm63xx/pci_ath9k_fixup.h |
|
230 | @@ -0,0 +1,7 @@ |
230 | @@ -0,0 +1,7 @@ |
|
231 | +#ifndef _PCI_ATH9K_FIXUP |
231 | +#ifndef _PCI_ATH9K_FIXUP |
|
232 | +#define _PCI_ATH9K_FIXUP |
232 | +#define _PCI_ATH9K_FIXUP |
|
233 | + |
233 | + |
|
234 | + |
234 | + |
|
235 | +void pci_enable_ath9k_fixup(unsigned slot, u32 offset) __init; |
235 | +void pci_enable_ath9k_fixup(unsigned slot, u32 offset) __init; |
|
236 | + |
236 | + |
|
237 | +#endif /* _PCI_ATH9K_FIXUP */ |
237 | +#endif /* _PCI_ATH9K_FIXUP */ |
|
238 | |
238 | |
|
239 | |
239 | |
|
240 |
|
240 |
|
|
241 | |
241 | |
|
242 | |
242 | |
|
243 | |
243 | |