2 * Atheros AP9X reference board PCI initialization
4 * Copyright (C) 2009-2012 Gabor Juhos <juhosg@openwrt.org>
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.
11 #include <linux/pci.h>
12 #include <linux/ath9k_platform.h>
13 #include <linux/delay.h>
15 #include <asm/mach-ath79/ath79.h>
17 #include "dev-ap9x-pci.h"
18 #include "pci-ath9k-fixup.h"
21 static struct ath9k_platform_data ap9x_wmac0_data
= {
24 static struct ath9k_platform_data ap9x_wmac1_data
= {
27 static char ap9x_wmac0_mac
[6];
28 static char ap9x_wmac1_mac
[6];
30 __init
void ap9x_pci_setup_wmac_led_pin(unsigned wmac
, int pin
)
34 ap9x_wmac0_data
.led_pin
= pin
;
37 ap9x_wmac1_data
.led_pin
= pin
;
42 __init
void ap9x_pci_setup_wmac_led_name(unsigned wmac
, const char *led_name
)
46 ap9x_wmac0_data
.led_name
= led_name
;
49 ap9x_wmac1_data
.led_name
= led_name
;
54 __init
struct ath9k_platform_data
*ap9x_pci_get_wmac_data(unsigned wmac
)
58 return &ap9x_wmac0_data
;
61 return &ap9x_wmac1_data
;
67 __init
void ap9x_pci_setup_wmac_gpio(unsigned wmac
, u32 mask
, u32 val
)
71 ap9x_wmac0_data
.gpio_mask
= mask
;
72 ap9x_wmac0_data
.gpio_val
= val
;
75 ap9x_wmac1_data
.gpio_mask
= mask
;
76 ap9x_wmac1_data
.gpio_val
= val
;
81 __init
void ap9x_pci_setup_wmac_leds(unsigned wmac
, struct gpio_led
*leds
,
86 ap9x_wmac0_data
.leds
= leds
;
87 ap9x_wmac0_data
.num_leds
= num_leds
;
90 ap9x_wmac1_data
.leds
= leds
;
91 ap9x_wmac1_data
.num_leds
= num_leds
;
96 static int ap91_pci_plat_dev_init(struct pci_dev
*dev
)
98 switch (PCI_SLOT(dev
->devfn
)) {
100 dev
->dev
.platform_data
= &ap9x_wmac0_data
;
107 __init
void ap91_pci_init(u8
*cal_data
, u8
*mac_addr
)
110 memcpy(ap9x_wmac0_data
.eeprom_data
, cal_data
,
111 sizeof(ap9x_wmac0_data
.eeprom_data
));
114 memcpy(ap9x_wmac0_mac
, mac_addr
, sizeof(ap9x_wmac0_mac
));
115 ap9x_wmac0_data
.macaddr
= ap9x_wmac0_mac
;
118 ath79_pci_set_plat_dev_init(ap91_pci_plat_dev_init
);
119 ath79_register_pci();
121 pci_enable_ath9k_fixup(0, ap9x_wmac0_data
.eeprom_data
);
124 __init
void ap91_pci_init_simple(void)
126 ap91_pci_init(NULL
, NULL
);
127 ap9x_wmac0_data
.eeprom_name
= "pci_wmac0.eeprom";
130 static int ap94_pci_plat_dev_init(struct pci_dev
*dev
)
132 switch (PCI_SLOT(dev
->devfn
)) {
134 dev
->dev
.platform_data
= &ap9x_wmac0_data
;
138 dev
->dev
.platform_data
= &ap9x_wmac1_data
;
145 __init
void ap94_pci_init(u8
*cal_data0
, u8
*mac_addr0
,
146 u8
*cal_data1
, u8
*mac_addr1
)
149 memcpy(ap9x_wmac0_data
.eeprom_data
, cal_data0
,
150 sizeof(ap9x_wmac0_data
.eeprom_data
));
153 memcpy(ap9x_wmac1_data
.eeprom_data
, cal_data1
,
154 sizeof(ap9x_wmac1_data
.eeprom_data
));
157 memcpy(ap9x_wmac0_mac
, mac_addr0
, sizeof(ap9x_wmac0_mac
));
158 ap9x_wmac0_data
.macaddr
= ap9x_wmac0_mac
;
162 memcpy(ap9x_wmac1_mac
, mac_addr1
, sizeof(ap9x_wmac1_mac
));
163 ap9x_wmac1_data
.macaddr
= ap9x_wmac1_mac
;
166 ath79_pci_set_plat_dev_init(ap94_pci_plat_dev_init
);
167 ath79_register_pci();
169 pci_enable_ath9k_fixup(17, ap9x_wmac0_data
.eeprom_data
);
170 pci_enable_ath9k_fixup(18, ap9x_wmac1_data
.eeprom_data
);