aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/wl12xx/wl1271_main.c
diff options
context:
space:
mode:
authorTeemu Paasikivi <ext-teemu.3.paasikivi@nokia.com>2010-02-22 01:38:21 -0500
committerJohn W. Linville <linville@tuxdriver.com>2010-03-09 15:02:56 -0500
commit2d5e82b8bcda58ec1e2fae5277a81e5fd067e627 (patch)
tree1bd34f7cf0f04bbea1ce940fb858ed6ffd2bb6e5 /drivers/net/wireless/wl12xx/wl1271_main.c
parentd57b87fde86a641da7782b99bec0a3130ed32f4a (diff)
wl1271: Moved module basics to wl1271_spi.c
Moved wl1271 drivers probe, remove etc. functions and structres to wl1271_spi.c from wl1271_main.c in preparation of implementing SDIO interface. Signed-off-by: Teemu Paasikivi <ext-teemu.3.paasikivi@nokia.com> Reviewed-by: Juuso Oikarinen <juuso.oikarinen@nokia.com> Signed-off-by: Juuso Oikarinen <juuso.oikarinen@nokia.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/wl12xx/wl1271_main.c')
-rw-r--r--drivers/net/wireless/wl12xx/wl1271_main.c191
1 files changed, 5 insertions, 186 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1271_main.c b/drivers/net/wireless/wl12xx/wl1271_main.c
index 2a864b24291d..66319aabf263 100644
--- a/drivers/net/wireless/wl12xx/wl1271_main.c
+++ b/drivers/net/wireless/wl12xx/wl1271_main.c
@@ -22,16 +22,12 @@
22 */ 22 */
23 23
24#include <linux/module.h> 24#include <linux/module.h>
25#include <linux/platform_device.h>
26#include <linux/interrupt.h>
27#include <linux/firmware.h> 25#include <linux/firmware.h>
28#include <linux/delay.h> 26#include <linux/delay.h>
29#include <linux/irq.h>
30#include <linux/spi/spi.h> 27#include <linux/spi/spi.h>
31#include <linux/crc32.h> 28#include <linux/crc32.h>
32#include <linux/etherdevice.h> 29#include <linux/etherdevice.h>
33#include <linux/vmalloc.h> 30#include <linux/vmalloc.h>
34#include <linux/spi/wl12xx.h>
35#include <linux/inetdevice.h> 31#include <linux/inetdevice.h>
36 32
37#include "wl1271.h" 33#include "wl1271.h"
@@ -484,28 +480,6 @@ out:
484 mutex_unlock(&wl->mutex); 480 mutex_unlock(&wl->mutex);
485} 481}
486 482
487static irqreturn_t wl1271_irq(int irq, void *cookie)
488{
489 struct wl1271 *wl;
490 unsigned long flags;
491
492 wl1271_debug(DEBUG_IRQ, "IRQ");
493
494 wl = cookie;
495
496 /* complete the ELP completion */
497 spin_lock_irqsave(&wl->wl_lock, flags);
498 if (wl->elp_compl) {
499 complete(wl->elp_compl);
500 wl->elp_compl = NULL;
501 }
502
503 ieee80211_queue_work(wl->hw, &wl->irq_work);
504 spin_unlock_irqrestore(&wl->wl_lock, flags);
505
506 return IRQ_HANDLED;
507}
508
509static int wl1271_fetch_firmware(struct wl1271 *wl) 483static int wl1271_fetch_firmware(struct wl1271 *wl)
510{ 484{
511 const struct firmware *fw; 485 const struct firmware *fw;
@@ -1959,7 +1933,7 @@ static const struct ieee80211_ops wl1271_ops = {
1959 CFG80211_TESTMODE_CMD(wl1271_tm_cmd) 1933 CFG80211_TESTMODE_CMD(wl1271_tm_cmd)
1960}; 1934};
1961 1935
1962static int wl1271_register_hw(struct wl1271 *wl) 1936int wl1271_register_hw(struct wl1271 *wl)
1963{ 1937{
1964 int ret; 1938 int ret;
1965 1939
@@ -1981,7 +1955,7 @@ static int wl1271_register_hw(struct wl1271 *wl)
1981 return 0; 1955 return 0;
1982} 1956}
1983 1957
1984static int wl1271_init_ieee80211(struct wl1271 *wl) 1958int wl1271_init_ieee80211(struct wl1271 *wl)
1985{ 1959{
1986 /* The tx descriptor buffer and the TKIP space. */ 1960 /* The tx descriptor buffer and the TKIP space. */
1987 wl->hw->extra_tx_headroom = WL1271_TKIP_IV_SPACE + 1961 wl->hw->extra_tx_headroom = WL1271_TKIP_IV_SPACE +
@@ -2009,24 +1983,9 @@ static int wl1271_init_ieee80211(struct wl1271 *wl)
2009 return 0; 1983 return 0;
2010} 1984}
2011 1985
2012static void wl1271_device_release(struct device *dev)
2013{
2014
2015}
2016
2017static struct platform_device wl1271_device = {
2018 .name = "wl1271",
2019 .id = -1,
2020
2021 /* device model insists to have a release function */
2022 .dev = {
2023 .release = wl1271_device_release,
2024 },
2025};
2026
2027#define WL1271_DEFAULT_CHANNEL 0 1986#define WL1271_DEFAULT_CHANNEL 0
2028 1987
2029static struct ieee80211_hw *wl1271_alloc_hw(void) 1988struct ieee80211_hw *wl1271_alloc_hw(void)
2030{ 1989{
2031 struct ieee80211_hw *hw; 1990 struct ieee80211_hw *hw;
2032 struct wl1271 *wl; 1991 struct wl1271 *wl;
@@ -2073,6 +2032,8 @@ static struct ieee80211_hw *wl1271_alloc_hw(void)
2073 /* Apply default driver configuration. */ 2032 /* Apply default driver configuration. */
2074 wl1271_conf_init(wl); 2033 wl1271_conf_init(wl);
2075 2034
2035 wl1271_debugfs_init(wl);
2036
2076 return hw; 2037 return hw;
2077} 2038}
2078 2039
@@ -2095,145 +2056,3 @@ int wl1271_free_hw(struct wl1271 *wl)
2095 2056
2096 return 0; 2057 return 0;
2097} 2058}
2098
2099static int __devinit wl1271_probe(struct spi_device *spi)
2100{
2101 struct wl12xx_platform_data *pdata;
2102 struct ieee80211_hw *hw;
2103 struct wl1271 *wl;
2104 int ret;
2105
2106 pdata = spi->dev.platform_data;
2107 if (!pdata) {
2108 wl1271_error("no platform data");
2109 return -ENODEV;
2110 }
2111
2112 hw = wl1271_alloc_hw();
2113 if (IS_ERR(hw))
2114 return PTR_ERR(hw);
2115
2116 wl = hw->priv;
2117
2118 dev_set_drvdata(&spi->dev, wl);
2119 wl->spi = spi;
2120
2121 /* This is the only SPI value that we need to set here, the rest
2122 * comes from the board-peripherals file */
2123 spi->bits_per_word = 32;
2124
2125 ret = spi_setup(spi);
2126 if (ret < 0) {
2127 wl1271_error("spi_setup failed");
2128 goto out_free;
2129 }
2130
2131 wl->set_power = pdata->set_power;
2132 if (!wl->set_power) {
2133 wl1271_error("set power function missing in platform data");
2134 ret = -ENODEV;
2135 goto out_free;
2136 }
2137
2138 wl->irq = spi->irq;
2139 if (wl->irq < 0) {
2140 wl1271_error("irq missing in platform data");
2141 ret = -ENODEV;
2142 goto out_free;
2143 }
2144
2145 ret = request_irq(wl->irq, wl1271_irq, 0, DRIVER_NAME, wl);
2146 if (ret < 0) {
2147 wl1271_error("request_irq() failed: %d", ret);
2148 goto out_free;
2149 }
2150
2151 set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
2152
2153 disable_irq(wl->irq);
2154
2155 ret = platform_device_register(&wl1271_device);
2156 if (ret) {
2157 wl1271_error("couldn't register platform device");
2158 goto out_irq;
2159 }
2160 dev_set_drvdata(&wl1271_device.dev, wl);
2161
2162 ret = wl1271_init_ieee80211(wl);
2163 if (ret)
2164 goto out_platform;
2165
2166 ret = wl1271_register_hw(wl);
2167 if (ret)
2168 goto out_platform;
2169
2170 wl1271_debugfs_init(wl);
2171
2172 wl1271_notice("initialized");
2173
2174 return 0;
2175
2176 out_platform:
2177 platform_device_unregister(&wl1271_device);
2178
2179 out_irq:
2180 free_irq(wl->irq, wl);
2181
2182 out_free:
2183 ieee80211_free_hw(hw);
2184
2185 return ret;
2186}
2187
2188static int __devexit wl1271_remove(struct spi_device *spi)
2189{
2190 struct wl1271 *wl = dev_get_drvdata(&spi->dev);
2191
2192 platform_device_unregister(&wl1271_device);
2193 free_irq(wl->irq, wl);
2194
2195 wl1271_free_hw(wl);
2196
2197 return 0;
2198}
2199
2200
2201static struct spi_driver wl1271_spi_driver = {
2202 .driver = {
2203 .name = "wl1271",
2204 .bus = &spi_bus_type,
2205 .owner = THIS_MODULE,
2206 },
2207
2208 .probe = wl1271_probe,
2209 .remove = __devexit_p(wl1271_remove),
2210};
2211
2212static int __init wl1271_init(void)
2213{
2214 int ret;
2215
2216 ret = spi_register_driver(&wl1271_spi_driver);
2217 if (ret < 0) {
2218 wl1271_error("failed to register spi driver: %d", ret);
2219 goto out;
2220 }
2221
2222out:
2223 return ret;
2224}
2225
2226static void __exit wl1271_exit(void)
2227{
2228 spi_unregister_driver(&wl1271_spi_driver);
2229
2230 wl1271_notice("unloaded");
2231}
2232
2233module_init(wl1271_init);
2234module_exit(wl1271_exit);
2235
2236MODULE_LICENSE("GPL");
2237MODULE_AUTHOR("Luciano Coelho <luciano.coelho@nokia.com>");
2238MODULE_AUTHOR("Juuso Oikarinen <juuso.oikarinen@nokia.com>");
2239MODULE_FIRMWARE(WL1271_FW_NAME);