aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArend van Spriel <arend@broadcom.com>2011-12-08 18:06:46 -0500
committerJohn W. Linville <linville@tuxdriver.com>2011-12-13 15:31:59 -0500
commit2e756560a8a47ce754b852d0bc1ff7549433d0eb (patch)
tree700a6fdd3f2f27fc2ab7c8f289d302ca7d883abb
parentb2ffec46ea230acac52170dd0a747526328d25fe (diff)
brcm80211: smac: change from pci device driver to bcma device driver
A new bus driver called "bcma" has been introduced into the kernel tree which considers the Broadcom AMBA chip interconnect as a bus. Each core in the chip is a bcma device. This commit changes brcms_mac80211.c into a bcma device driver. Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com> Reviewed-by: Alwin Beukers <alwin@broadcom.com> Signed-off-by: Arend van Spriel <arend@broadcom.com> Signed-off-by: Franky Lin <frankyl@broadcom.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
-rw-r--r--drivers/net/wireless/brcm80211/Kconfig3
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c168
-rw-r--r--drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h2
3 files changed, 64 insertions, 109 deletions
diff --git a/drivers/net/wireless/brcm80211/Kconfig b/drivers/net/wireless/brcm80211/Kconfig
index 2069fc8f7ad..8f54c2eb682 100644
--- a/drivers/net/wireless/brcm80211/Kconfig
+++ b/drivers/net/wireless/brcm80211/Kconfig
@@ -3,9 +3,8 @@ config BRCMUTIL
3 3
4config BRCMSMAC 4config BRCMSMAC
5 tristate "Broadcom IEEE802.11n PCIe SoftMAC WLAN driver" 5 tristate "Broadcom IEEE802.11n PCIe SoftMAC WLAN driver"
6 depends on PCI
7 depends on MAC80211 6 depends on MAC80211
8 depends on BCMA=n 7 depends on BCMA
9 select BRCMUTIL 8 select BRCMUTIL
10 select FW_LOADER 9 select FW_LOADER
11 select CRC_CCITT 10 select CRC_CCITT
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
index 76376eb112f..9e07dc4376f 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
+++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
@@ -17,11 +17,11 @@
17#define __UNDEF_NO_VERSION__ 17#define __UNDEF_NO_VERSION__
18 18
19#include <linux/etherdevice.h> 19#include <linux/etherdevice.h>
20#include <linux/pci.h>
21#include <linux/sched.h> 20#include <linux/sched.h>
22#include <linux/firmware.h> 21#include <linux/firmware.h>
23#include <linux/interrupt.h> 22#include <linux/interrupt.h>
24#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/bcma/bcma.h>
25#include <net/mac80211.h> 25#include <net/mac80211.h>
26#include <defs.h> 26#include <defs.h>
27#include "nicpci.h" 27#include "nicpci.h"
@@ -87,16 +87,14 @@ MODULE_DESCRIPTION("Broadcom 802.11n wireless LAN driver.");
87MODULE_SUPPORTED_DEVICE("Broadcom 802.11n WLAN cards"); 87MODULE_SUPPORTED_DEVICE("Broadcom 802.11n WLAN cards");
88MODULE_LICENSE("Dual BSD/GPL"); 88MODULE_LICENSE("Dual BSD/GPL");
89 89
90/* recognized PCI IDs */
91static DEFINE_PCI_DEVICE_TABLE(brcms_pci_id_table) = {
92 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4357) }, /* 43225 2G */
93 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4353) }, /* 43224 DUAL */
94 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4727) }, /* 4313 DUAL */
95 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x0576) }, /* 43224 Ven */
96 {0}
97};
98 90
99MODULE_DEVICE_TABLE(pci, brcms_pci_id_table); 91/* recognized BCMA Core IDs */
92static struct bcma_device_id brcms_coreid_table[] = {
93 BCMA_CORE(BCMA_MANUF_BCM, BCMA_CORE_80211,
94 BCMA_ANY_REV, BCMA_ANY_CLASS),
95 BCMA_CORETABLE_END
96};
97MODULE_DEVICE_TABLE(bcma, brcms_coreid_table);
100 98
101#ifdef BCMDBG 99#ifdef BCMDBG
102static int msglevel = 0xdeadbeef; 100static int msglevel = 0xdeadbeef;
@@ -724,7 +722,7 @@ static const struct ieee80211_ops brcms_ops = {
724}; 722};
725 723
726/* 724/*
727 * is called in brcms_pci_probe() context, therefore no locking required. 725 * is called in brcms_bcma_probe() context, therefore no locking required.
728 */ 726 */
729static int brcms_set_hint(struct brcms_info *wl, char *abbrev) 727static int brcms_set_hint(struct brcms_info *wl, char *abbrev)
730{ 728{
@@ -864,25 +862,15 @@ static void brcms_free(struct brcms_info *wl)
864#endif 862#endif
865 kfree(t); 863 kfree(t);
866 } 864 }
867
868 /*
869 * unregister_netdev() calls get_stats() which may read chip
870 * registers so we cannot unmap the chip registers until
871 * after calling unregister_netdev() .
872 */
873 if (wl->regsva)
874 iounmap(wl->regsva);
875
876 wl->regsva = NULL;
877} 865}
878 866
879/* 867/*
880* called from both kernel as from this kernel module (error flow on attach) 868* called from both kernel as from this kernel module (error flow on attach)
881* precondition: perimeter lock is not acquired. 869* precondition: perimeter lock is not acquired.
882*/ 870*/
883static void brcms_remove(struct pci_dev *pdev) 871static void brcms_remove(struct bcma_device *pdev)
884{ 872{
885 struct ieee80211_hw *hw = pci_get_drvdata(pdev); 873 struct ieee80211_hw *hw = bcma_get_drvdata(pdev);
886 struct brcms_info *wl = hw->priv; 874 struct brcms_info *wl = hw->priv;
887 875
888 if (wl->wlc) { 876 if (wl->wlc) {
@@ -890,11 +878,10 @@ static void brcms_remove(struct pci_dev *pdev)
890 wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy); 878 wiphy_rfkill_stop_polling(wl->pub->ieee_hw->wiphy);
891 ieee80211_unregister_hw(hw); 879 ieee80211_unregister_hw(hw);
892 } 880 }
893 pci_disable_device(pdev);
894 881
895 brcms_free(wl); 882 brcms_free(wl);
896 883
897 pci_set_drvdata(pdev, NULL); 884 bcma_set_drvdata(pdev, NULL);
898 ieee80211_free_hw(hw); 885 ieee80211_free_hw(hw);
899} 886}
900 887
@@ -1002,11 +989,9 @@ static int ieee_hw_init(struct ieee80211_hw *hw)
1002 * it as static. 989 * it as static.
1003 * 990 *
1004 * 991 *
1005 * is called in brcms_pci_probe() context, therefore no locking required. 992 * is called in brcms_bcma_probe() context, therefore no locking required.
1006 */ 993 */
1007static struct brcms_info *brcms_attach(u16 vendor, u16 device, 994static struct brcms_info *brcms_attach(struct bcma_device *pdev)
1008 resource_size_t regs,
1009 struct pci_dev *btparam, uint irq)
1010{ 995{
1011 struct brcms_info *wl = NULL; 996 struct brcms_info *wl = NULL;
1012 int unit, err; 997 int unit, err;
@@ -1020,7 +1005,7 @@ static struct brcms_info *brcms_attach(u16 vendor, u16 device,
1020 return NULL; 1005 return NULL;
1021 1006
1022 /* allocate private info */ 1007 /* allocate private info */
1023 hw = pci_get_drvdata(btparam); /* btparam == pdev */ 1008 hw = bcma_get_drvdata(pdev);
1024 if (hw != NULL) 1009 if (hw != NULL)
1025 wl = hw->priv; 1010 wl = hw->priv;
1026 if (WARN_ON(hw == NULL) || WARN_ON(wl == NULL)) 1011 if (WARN_ON(hw == NULL) || WARN_ON(wl == NULL))
@@ -1032,26 +1017,22 @@ static struct brcms_info *brcms_attach(u16 vendor, u16 device,
1032 /* setup the bottom half handler */ 1017 /* setup the bottom half handler */
1033 tasklet_init(&wl->tasklet, brcms_dpc, (unsigned long) wl); 1018 tasklet_init(&wl->tasklet, brcms_dpc, (unsigned long) wl);
1034 1019
1035 wl->regsva = ioremap_nocache(regs, PCI_BAR0_WINSZ);
1036 if (wl->regsva == NULL) {
1037 wiphy_err(wl->wiphy, "wl%d: ioremap() failed\n", unit);
1038 goto fail;
1039 }
1040 spin_lock_init(&wl->lock); 1020 spin_lock_init(&wl->lock);
1041 spin_lock_init(&wl->isr_lock); 1021 spin_lock_init(&wl->isr_lock);
1042 1022
1043 /* prepare ucode */ 1023 /* prepare ucode */
1044 if (brcms_request_fw(wl, btparam) < 0) { 1024 if (brcms_request_fw(wl, pdev->bus->host_pci) < 0) {
1045 wiphy_err(wl->wiphy, "%s: Failed to find firmware usually in " 1025 wiphy_err(wl->wiphy, "%s: Failed to find firmware usually in "
1046 "%s\n", KBUILD_MODNAME, "/lib/firmware/brcm"); 1026 "%s\n", KBUILD_MODNAME, "/lib/firmware/brcm");
1047 brcms_release_fw(wl); 1027 brcms_release_fw(wl);
1048 brcms_remove(btparam); 1028 brcms_remove(pdev);
1049 return NULL; 1029 return NULL;
1050 } 1030 }
1051 1031
1052 /* common load-time initialization */ 1032 /* common load-time initialization */
1053 wl->wlc = brcms_c_attach(wl, vendor, device, unit, false, 1033 wl->wlc = brcms_c_attach((void *)wl, pdev->bus->host_pci->vendor,
1054 wl->regsva, btparam, &err); 1034 pdev->bus->host_pci->device, unit, false,
1035 pdev->bus->mmio, pdev->bus->host_pci, &err);
1055 brcms_release_fw(wl); 1036 brcms_release_fw(wl);
1056 if (!wl->wlc) { 1037 if (!wl->wlc) {
1057 wiphy_err(wl->wiphy, "%s: attach() failed with code %d\n", 1038 wiphy_err(wl->wiphy, "%s: attach() failed with code %d\n",
@@ -1063,11 +1044,12 @@ static struct brcms_info *brcms_attach(u16 vendor, u16 device,
1063 wl->pub->ieee_hw = hw; 1044 wl->pub->ieee_hw = hw;
1064 1045
1065 /* register our interrupt handler */ 1046 /* register our interrupt handler */
1066 if (request_irq(irq, brcms_isr, IRQF_SHARED, KBUILD_MODNAME, wl)) { 1047 if (request_irq(pdev->bus->host_pci->irq, brcms_isr,
1048 IRQF_SHARED, KBUILD_MODNAME, wl)) {
1067 wiphy_err(wl->wiphy, "wl%d: request_irq() failed\n", unit); 1049 wiphy_err(wl->wiphy, "wl%d: request_irq() failed\n", unit);
1068 goto fail; 1050 goto fail;
1069 } 1051 }
1070 wl->irq = irq; 1052 wl->irq = pdev->bus->host_pci->irq;
1071 1053
1072 /* register module */ 1054 /* register module */
1073 brcms_c_module_register(wl->pub, "linux", wl, NULL); 1055 brcms_c_module_register(wl->pub, "linux", wl, NULL);
@@ -1114,37 +1096,18 @@ fail:
1114 * 1096 *
1115 * Perimeter lock is initialized in the course of this function. 1097 * Perimeter lock is initialized in the course of this function.
1116 */ 1098 */
1117static int __devinit 1099static int __devinit brcms_bcma_probe(struct bcma_device *pdev)
1118brcms_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1119{ 1100{
1120 int rc;
1121 struct brcms_info *wl; 1101 struct brcms_info *wl;
1122 struct ieee80211_hw *hw; 1102 struct ieee80211_hw *hw;
1123 u32 val;
1124
1125 dev_info(&pdev->dev, "bus %d slot %d func %d irq %d\n",
1126 pdev->bus->number, PCI_SLOT(pdev->devfn),
1127 PCI_FUNC(pdev->devfn), pdev->irq);
1128 1103
1129 if ((pdev->vendor != PCI_VENDOR_ID_BROADCOM) || 1104 dev_info(&pdev->dev, "mfg %x core %x rev %d class %d irq %d\n",
1130 ((pdev->device != 0x0576) && 1105 pdev->id.manuf, pdev->id.id, pdev->id.rev, pdev->id.class,
1131 ((pdev->device & 0xff00) != 0x4300) && 1106 pdev->bus->host_pci->irq);
1132 ((pdev->device & 0xff00) != 0x4700) &&
1133 ((pdev->device < 43000) || (pdev->device > 43999))))
1134 return -ENODEV;
1135 1107
1136 rc = pci_enable_device(pdev); 1108 if ((pdev->id.manuf != BCMA_MANUF_BCM) ||
1137 if (rc) { 1109 (pdev->id.id != BCMA_CORE_80211))
1138 pr_err("%s: Cannot enable device %d-%d_%d\n",
1139 __func__, pdev->bus->number, PCI_SLOT(pdev->devfn),
1140 PCI_FUNC(pdev->devfn));
1141 return -ENODEV; 1110 return -ENODEV;
1142 }
1143 pci_set_master(pdev);
1144
1145 pci_read_config_dword(pdev, 0x40, &val);
1146 if ((val & 0x0000ff00) != 0)
1147 pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
1148 1111
1149 hw = ieee80211_alloc_hw(sizeof(struct brcms_info), &brcms_ops); 1112 hw = ieee80211_alloc_hw(sizeof(struct brcms_info), &brcms_ops);
1150 if (!hw) { 1113 if (!hw) {
@@ -1154,14 +1117,11 @@ brcms_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1154 1117
1155 SET_IEEE80211_DEV(hw, &pdev->dev); 1118 SET_IEEE80211_DEV(hw, &pdev->dev);
1156 1119
1157 pci_set_drvdata(pdev, hw); 1120 bcma_set_drvdata(pdev, hw);
1158 1121
1159 memset(hw->priv, 0, sizeof(*wl)); 1122 memset(hw->priv, 0, sizeof(*wl));
1160 1123
1161 wl = brcms_attach(pdev->vendor, pdev->device, 1124 wl = brcms_attach(pdev);
1162 pci_resource_start(pdev, 0), pdev,
1163 pdev->irq);
1164
1165 if (!wl) { 1125 if (!wl) {
1166 pr_err("%s: %s: brcms_attach failed!\n", KBUILD_MODNAME, 1126 pr_err("%s: %s: brcms_attach failed!\n", KBUILD_MODNAME,
1167 __func__); 1127 __func__);
@@ -1170,16 +1130,23 @@ brcms_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1170 return 0; 1130 return 0;
1171} 1131}
1172 1132
1173static int brcms_suspend(struct pci_dev *pdev, pm_message_t state) 1133static int brcms_pci_suspend(struct pci_dev *pdev)
1134{
1135 pci_save_state(pdev);
1136 pci_disable_device(pdev);
1137 return pci_set_power_state(pdev, PCI_D3hot);
1138}
1139
1140static int brcms_suspend(struct bcma_device *pdev, pm_message_t state)
1174{ 1141{
1175 struct brcms_info *wl; 1142 struct brcms_info *wl;
1176 struct ieee80211_hw *hw; 1143 struct ieee80211_hw *hw;
1177 1144
1178 hw = pci_get_drvdata(pdev); 1145 hw = bcma_get_drvdata(pdev);
1179 wl = hw->priv; 1146 wl = hw->priv;
1180 if (!wl) { 1147 if (!wl) {
1181 wiphy_err(wl->wiphy, 1148 wiphy_err(wl->wiphy,
1182 "brcms_suspend: pci_get_drvdata failed\n"); 1149 "brcms_suspend: bcma_get_drvdata failed\n");
1183 return -ENODEV; 1150 return -ENODEV;
1184 } 1151 }
1185 1152
@@ -1188,25 +1155,14 @@ static int brcms_suspend(struct pci_dev *pdev, pm_message_t state)
1188 wl->pub->hw_up = false; 1155 wl->pub->hw_up = false;
1189 spin_unlock_bh(&wl->lock); 1156 spin_unlock_bh(&wl->lock);
1190 1157
1191 pci_save_state(pdev); 1158 /* temporarily do suspend ourselves */
1192 pci_disable_device(pdev); 1159 return brcms_pci_suspend(pdev->bus->host_pci);
1193 return pci_set_power_state(pdev, PCI_D3hot);
1194} 1160}
1195 1161
1196static int brcms_resume(struct pci_dev *pdev) 1162static int brcms_pci_resume(struct pci_dev *pdev)
1197{ 1163{
1198 struct brcms_info *wl;
1199 struct ieee80211_hw *hw;
1200 int err = 0; 1164 int err = 0;
1201 u32 val; 1165 uint val;
1202
1203 hw = pci_get_drvdata(pdev);
1204 wl = hw->priv;
1205 if (!wl) {
1206 wiphy_err(wl->wiphy,
1207 "wl: brcms_resume: pci_get_drvdata failed\n");
1208 return -ENODEV;
1209 }
1210 1166
1211 err = pci_set_power_state(pdev, PCI_D0); 1167 err = pci_set_power_state(pdev, PCI_D0);
1212 if (err) 1168 if (err)
@@ -1224,24 +1180,28 @@ static int brcms_resume(struct pci_dev *pdev)
1224 if ((val & 0x0000ff00) != 0) 1180 if ((val & 0x0000ff00) != 0)
1225 pci_write_config_dword(pdev, 0x40, val & 0xffff00ff); 1181 pci_write_config_dword(pdev, 0x40, val & 0xffff00ff);
1226 1182
1183 return 0;
1184}
1185
1186static int brcms_resume(struct bcma_device *pdev)
1187{
1227 /* 1188 /*
1228 * done. driver will be put in up state 1189 * just do pci resume for now until bcma supports it.
1229 * in brcms_ops_add_interface() call.
1230 */ 1190 */
1231 return err; 1191 return brcms_pci_resume(pdev->bus->host_pci);
1232} 1192}
1233 1193
1234static struct pci_driver brcms_pci_driver = { 1194static struct bcma_driver brcms_bcma_driver = {
1235 .name = KBUILD_MODNAME, 1195 .name = KBUILD_MODNAME,
1236 .probe = brcms_pci_probe, 1196 .probe = brcms_bcma_probe,
1237 .suspend = brcms_suspend, 1197 .suspend = brcms_suspend,
1238 .resume = brcms_resume, 1198 .resume = brcms_resume,
1239 .remove = __devexit_p(brcms_remove), 1199 .remove = __devexit_p(brcms_remove),
1240 .id_table = brcms_pci_id_table, 1200 .id_table = brcms_coreid_table,
1241}; 1201};
1242 1202
1243/** 1203/**
1244 * This is the main entry point for the WL driver. 1204 * This is the main entry point for the brcmsmac driver.
1245 * 1205 *
1246 * This function determines if a device pointed to by pdev is a WL device, 1206 * This function determines if a device pointed to by pdev is a WL device,
1247 * and if so, performs a brcms_attach() on it. 1207 * and if so, performs a brcms_attach() on it.
@@ -1256,26 +1216,24 @@ static int __init brcms_module_init(void)
1256 brcm_msg_level = msglevel; 1216 brcm_msg_level = msglevel;
1257#endif /* BCMDBG */ 1217#endif /* BCMDBG */
1258 1218
1259 error = pci_register_driver(&brcms_pci_driver); 1219 error = bcma_driver_register(&brcms_bcma_driver);
1220 printk(KERN_ERR "%s: register returned %d\n", __func__, error);
1260 if (!error) 1221 if (!error)
1261 return 0; 1222 return 0;
1262 1223
1263
1264
1265 return error; 1224 return error;
1266} 1225}
1267 1226
1268/** 1227/**
1269 * This function unloads the WL driver from the system. 1228 * This function unloads the brcmsmac driver from the system.
1270 * 1229 *
1271 * This function unconditionally unloads the WL driver module from the 1230 * This function unconditionally unloads the brcmsmac driver module from the
1272 * system. 1231 * system.
1273 * 1232 *
1274 */ 1233 */
1275static void __exit brcms_module_exit(void) 1234static void __exit brcms_module_exit(void)
1276{ 1235{
1277 pci_unregister_driver(&brcms_pci_driver); 1236 bcma_driver_unregister(&brcms_bcma_driver);
1278
1279} 1237}
1280 1238
1281module_init(brcms_module_init); 1239module_init(brcms_module_init);
@@ -1562,7 +1520,7 @@ fail:
1562} 1520}
1563 1521
1564/* 1522/*
1565 * Precondition: Since this function is called in brcms_pci_probe() context, 1523 * Precondition: Since this function is called in brcms_bcma_probe() context,
1566 * no locking is required. 1524 * no locking is required.
1567 */ 1525 */
1568int brcms_ucode_init_uint(struct brcms_info *wl, size_t *n_bytes, u32 idx) 1526int brcms_ucode_init_uint(struct brcms_info *wl, size_t *n_bytes, u32 idx)
@@ -1602,7 +1560,7 @@ void brcms_ucode_free_buf(void *p)
1602/* 1560/*
1603 * checks validity of all firmware images loaded from user space 1561 * checks validity of all firmware images loaded from user space
1604 * 1562 *
1605 * Precondition: Since this function is called in brcms_pci_probe() context, 1563 * Precondition: Since this function is called in brcms_bcma_probe() context,
1606 * no locking is required. 1564 * no locking is required.
1607 */ 1565 */
1608int brcms_check_firmwares(struct brcms_info *wl) 1566int brcms_check_firmwares(struct brcms_info *wl)
diff --git a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h
index 6242f188b71..8f60419c37b 100644
--- a/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h
+++ b/drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.h
@@ -68,8 +68,6 @@ struct brcms_info {
68 spinlock_t lock; /* per-device perimeter lock */ 68 spinlock_t lock; /* per-device perimeter lock */
69 spinlock_t isr_lock; /* per-device ISR synchronization lock */ 69 spinlock_t isr_lock; /* per-device ISR synchronization lock */
70 70
71 /* regsva for unmap in brcms_free() */
72 void __iomem *regsva; /* opaque chip registers virtual address */
73 71
74 /* timer related fields */ 72 /* timer related fields */
75 atomic_t callbacks; /* # outstanding callback functions */ 73 atomic_t callbacks; /* # outstanding callback functions */