Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ath9k: introduce platform driver for AHB bus support

This patch adds the platform_driver itself, and modifies the main driver
to register it.

Changes-licensed-under: ISC

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Signed-off-by: Imre Kaloz <kaloz@openwrt.org>
Tested-by: Pavel Roskin <proski@gnu.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

authored by

Gabor Juhos and committed by
John W. Linville
09329d37 6baff7f9

+179
+1
drivers/net/wireless/ath9k/Makefile
··· 12 12 rc.o 13 13 14 14 ath9k-$(CONFIG_PCI) += pci.o 15 + ath9k-$(CONFIG_ATHEROS_AR71XX) += ahb.o 15 16 ath9k-$(CONFIG_ATH9K_DEBUG) += debug.o 16 17 17 18 obj-$(CONFIG_ATH9K) += ath9k.o
+160
drivers/net/wireless/ath9k/ahb.c
··· 1 + /* 2 + * Copyright (c) 2008 Atheros Communications Inc. 3 + * Copyright (c) 2009 Gabor Juhos <juhosg@openwrt.org> 4 + * Copyright (c) 2009 Imre Kaloz <kaloz@openwrt.org> 5 + * 6 + * Permission to use, copy, modify, and/or distribute this software for any 7 + * purpose with or without fee is hereby granted, provided that the above 8 + * copyright notice and this permission notice appear in all copies. 9 + * 10 + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 11 + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 12 + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 13 + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 14 + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 15 + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 16 + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 17 + */ 18 + 19 + #include <linux/nl80211.h> 20 + #include <linux/platform_device.h> 21 + #include "core.h" 22 + #include "reg.h" 23 + #include "hw.h" 24 + 25 + /* return bus cachesize in 4B word units */ 26 + static void ath_ahb_read_cachesize(struct ath_softc *sc, int *csz) 27 + { 28 + *csz = L1_CACHE_BYTES >> 2; 29 + } 30 + 31 + static void ath_ahb_cleanup(struct ath_softc *sc) 32 + { 33 + iounmap(sc->mem); 34 + } 35 + 36 + static struct ath_bus_ops ath_ahb_bus_ops = { 37 + .read_cachesize = ath_ahb_read_cachesize, 38 + .cleanup = ath_ahb_cleanup, 39 + }; 40 + 41 + static int ath_ahb_probe(struct platform_device *pdev) 42 + { 43 + void __iomem *mem; 44 + struct ath_softc *sc; 45 + struct ieee80211_hw *hw; 46 + struct resource *res; 47 + int irq; 48 + int ret = 0; 49 + struct ath_hal *ah; 50 + 51 + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 52 + if (res == NULL) { 53 + dev_err(&pdev->dev, "no memory resource found\n"); 54 + ret = -ENXIO; 55 + goto err_out; 56 + } 57 + 58 + mem = ioremap_nocache(res->start, res->end - res->start + 1); 59 + if (mem == NULL) { 60 + dev_err(&pdev->dev, "ioremap failed\n"); 61 + ret = -ENOMEM; 62 + goto err_out; 63 + } 64 + 65 + res = platform_get_resource(pdev, IORESOURCE_IRQ, 0); 66 + if (res == NULL) { 67 + dev_err(&pdev->dev, "no IRQ resource found\n"); 68 + ret = -ENXIO; 69 + goto err_iounmap; 70 + } 71 + 72 + irq = res->start; 73 + 74 + hw = ieee80211_alloc_hw(sizeof(struct ath_softc), &ath9k_ops); 75 + if (hw == NULL) { 76 + dev_err(&pdev->dev, "no memory for ieee80211_hw\n"); 77 + ret = -ENOMEM; 78 + goto err_iounmap; 79 + } 80 + 81 + SET_IEEE80211_DEV(hw, &pdev->dev); 82 + platform_set_drvdata(pdev, hw); 83 + 84 + sc = hw->priv; 85 + sc->hw = hw; 86 + sc->dev = &pdev->dev; 87 + sc->mem = mem; 88 + sc->bus_ops = &ath_ahb_bus_ops; 89 + sc->irq = irq; 90 + 91 + ret = ath_attach(AR5416_AR9100_DEVID, sc); 92 + if (ret != 0) { 93 + dev_err(&pdev->dev, "failed to attach device, err=%d\n", ret); 94 + ret = -ENODEV; 95 + goto err_free_hw; 96 + } 97 + 98 + ret = request_irq(irq, ath_isr, IRQF_SHARED, "ath9k", sc); 99 + if (ret) { 100 + dev_err(&pdev->dev, "request_irq failed, err=%d\n", ret); 101 + ret = -EIO; 102 + goto err_detach; 103 + } 104 + 105 + ah = sc->sc_ah; 106 + printk(KERN_INFO 107 + "%s: Atheros AR%s MAC/BB Rev:%x, " 108 + "AR%s RF Rev:%x, mem=0x%lx, irq=%d\n", 109 + wiphy_name(hw->wiphy), 110 + ath_mac_bb_name(ah->ah_macVersion), 111 + ah->ah_macRev, 112 + ath_rf_name((ah->ah_analog5GhzRev & AR_RADIO_SREV_MAJOR)), 113 + ah->ah_phyRev, 114 + (unsigned long)mem, irq); 115 + 116 + return 0; 117 + 118 + err_detach: 119 + ath_detach(sc); 120 + err_free_hw: 121 + ieee80211_free_hw(hw); 122 + platform_set_drvdata(pdev, NULL); 123 + err_iounmap: 124 + iounmap(mem); 125 + err_out: 126 + return ret; 127 + } 128 + 129 + static int ath_ahb_remove(struct platform_device *pdev) 130 + { 131 + struct ieee80211_hw *hw = platform_get_drvdata(pdev); 132 + 133 + if (hw) { 134 + struct ath_softc *sc = hw->priv; 135 + 136 + ath_cleanup(sc); 137 + platform_set_drvdata(pdev, NULL); 138 + } 139 + 140 + return 0; 141 + } 142 + 143 + static struct platform_driver ath_ahb_driver = { 144 + .probe = ath_ahb_probe, 145 + .remove = ath_ahb_remove, 146 + .driver = { 147 + .name = "ath9k", 148 + .owner = THIS_MODULE, 149 + }, 150 + }; 151 + 152 + int ath_ahb_init(void) 153 + { 154 + return platform_driver_register(&ath_ahb_driver); 155 + } 156 + 157 + void ath_ahb_exit(void) 158 + { 159 + platform_driver_unregister(&ath_ahb_driver); 160 + }
+8
drivers/net/wireless/ath9k/core.h
··· 784 784 static inline void ath_pci_exit(void) {}; 785 785 #endif 786 786 787 + #ifdef CONFIG_ATHEROS_AR71XX 788 + int ath_ahb_init(void); 789 + void ath_ahb_exit(void); 790 + #else 791 + static inline int ath_ahb_init(void) { return 0; }; 792 + static inline void ath_ahb_exit(void) {}; 793 + #endif 794 + 787 795 #endif /* CORE_H */
+10
drivers/net/wireless/ath9k/main.c
··· 2527 2527 goto err_rate_unregister; 2528 2528 } 2529 2529 2530 + error = ath_ahb_init(); 2531 + if (error < 0) { 2532 + error = -ENODEV; 2533 + goto err_pci_exit; 2534 + } 2535 + 2530 2536 return 0; 2537 + 2538 + err_pci_exit: 2539 + ath_pci_exit(); 2531 2540 2532 2541 err_rate_unregister: 2533 2542 ath_rate_control_unregister(); ··· 2547 2538 2548 2539 static void __exit ath9k_exit(void) 2549 2540 { 2541 + ath_ahb_exit(); 2550 2542 ath_pci_exit(); 2551 2543 ath_rate_control_unregister(); 2552 2544 printk(KERN_INFO "%s: Driver unloaded\n", dev_info);