]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/staging/brcm80211/brcmfmac/wl_cfg80211.c
staging: brcm80211: move sdio related suspend/resume code to bus interface layer
[mv-sheeva.git] / drivers / staging / brcm80211 / brcmfmac / wl_cfg80211.c
index dd4745181d449a3ede5acd50d838195ef3668671..a3c2e8703a5149138f8e8305d61a2a19d9b47e64 100644 (file)
@@ -36,8 +36,6 @@
 #include "dhd.h"
 #include "wl_cfg80211.h"
 
-void brcmf_sdioh_set_host_pm_flags(int flag);
-
 static struct sdio_func *cfg80211_sdio_func;
 static struct wl_dev *wl_cfg80211_dev;
 static const u8 ether_bcast[ETH_ALEN] = {255, 255, 255, 255, 255, 255};
@@ -250,20 +248,6 @@ static void wl_init_conf(struct wl_conf *conf);
 /*
 ** dongle configuration utilities
 */
-#ifndef EMBEDDED_PLATFORM
-static s32 wl_dongle_mode(struct net_device *ndev, s32 iftype);
-static s32 wl_dongle_country(struct net_device *ndev, u8 ccode);
-static s32 wl_dongle_up(struct net_device *ndev, u32 up);
-static s32 wl_dongle_power(struct net_device *ndev, u32 power_mode);
-static s32 wl_dongle_glom(struct net_device *ndev, u32 glom,
-                           u32 dongle_align);
-static s32 wl_dongle_offload(struct net_device *ndev, s32 arpoe,
-                              s32 arp_ol);
-static s32 wl_pattern_atoh(s8 *src, s8 *dst);
-static s32 wl_dongle_filter(struct net_device *ndev, u32 filter_mode);
-static s32 wl_update_wiphybands(struct wl_priv *wl);
-#endif                         /* !EMBEDDED_PLATFORM */
-
 static s32 wl_dongle_eventmsg(struct net_device *ndev);
 static s32 wl_dongle_scantime(struct net_device *ndev, s32 scan_assoc_time,
                                s32 scan_unassoc_time, s32 scan_passive_time);
@@ -342,7 +326,6 @@ do {                                                                        \
        }                                                               \
 } while (0)
 
-extern int dhd_wait_pend8021x(struct net_device *dev);
 #define CHAN2G(_channel, _freq, _flags) {                      \
        .band                   = IEEE80211_BAND_2GHZ,          \
        .center_freq            = (_freq),                      \
@@ -1677,7 +1660,7 @@ wl_add_keyext(struct wiphy *wiphy, struct net_device *dev,
                }
                swap_key_from_BE(&key);
 
-               dhd_wait_pend8021x(dev);
+               brcmf_netdev_wait_pend8021x(dev);
                err = wl_dev_ioctl(dev, BRCMF_C_SET_KEY, &key, sizeof(key));
                if (unlikely(err)) {
                        WL_ERR("WLC_SET_KEY error (%d)\n", err);
@@ -2086,7 +2069,6 @@ done:
 static s32 wl_cfg80211_resume(struct wiphy *wiphy)
 {
        struct wl_priv *wl = wiphy_to_wl(wiphy);
-       struct net_device *ndev = wl_to_ndev(wl);
 
        /*
         * Check for WL_STATUS_READY before any function call which
@@ -2096,14 +2078,11 @@ static s32 wl_cfg80211_resume(struct wiphy *wiphy)
        WL_TRACE("Enter\n");
 
 #if defined(CONFIG_PM_SLEEP)
-       atomic_set(&dhd_mmc_suspend, false);
+       atomic_set(&brcmf_mmc_suspend, false);
 #endif /*  defined(CONFIG_PM_SLEEP) */
 
-       if (test_bit(WL_STATUS_READY, &wl->status)) {
-               /* Turn on Watchdog timer */
-               wl_os_wd_timer(ndev, brcmf_watchdog_ms);
+       if (test_bit(WL_STATUS_READY, &wl->status))
                wl_invoke_iscan(wiphy_to_wl(wiphy));
-       }
 
        WL_TRACE("Exit\n");
        return 0;
@@ -2156,18 +2135,14 @@ static s32 wl_cfg80211_suspend(struct wiphy *wiphy, struct cfg80211_wowlan *wow)
        clear_bit(WL_STATUS_SCANNING, &wl->status);
        clear_bit(WL_STATUS_SCAN_ABORTING, &wl->status);
 
-       /* Inform SDIO stack not to switch off power to the chip */
-       brcmf_sdioh_set_host_pm_flags(MMC_PM_KEEP_POWER);
-
        /* Turn off watchdog timer */
        if (test_bit(WL_STATUS_READY, &wl->status)) {
-               WL_INFO("Terminate watchdog timer and enable MPC\n");
+               WL_INFO("Enable MPC\n");
                wl_set_mpc(ndev, 1);
-               wl_os_wd_timer(ndev, 0);
        }
 
 #if defined(CONFIG_PM_SLEEP)
-       atomic_set(&dhd_mmc_suspend, true);
+       atomic_set(&brcmf_mmc_suspend, true);
 #endif /*  defined(CONFIG_PM_SLEEP) */
 
        WL_TRACE("Exit\n");
@@ -3658,212 +3633,6 @@ static s32 wl_dongle_mode(struct net_device *ndev, s32 iftype)
        return 0;
 }
 
-#ifndef EMBEDDED_PLATFORM
-static s32 wl_dongle_country(struct net_device *ndev, u8 ccode)
-{
-
-       s32 err = 0;
-
-       return err;
-}
-
-static s32 wl_dongle_up(struct net_device *ndev, u32 up)
-{
-       s32 err = 0;
-
-       err = wl_dev_ioctl(ndev, BRCMF_C_UP, &up, sizeof(up));
-       if (unlikely(err)) {
-               WL_ERR("WLC_UP error (%d)\n", err);
-       }
-       return err;
-}
-
-static s32 wl_dongle_power(struct net_device *ndev, u32 power_mode)
-{
-       s32 err = 0;
-
-       err = wl_dev_ioctl(ndev, BRCMF_C_SET_PM,
-                          &power_mode, sizeof(power_mode));
-       if (unlikely(err)) {
-               WL_ERR("WLC_SET_PM error (%d)\n", err);
-       }
-       return err;
-}
-
-static s32
-wl_dongle_glom(struct net_device *ndev, u32 glom, u32 dongle_align)
-{
-       s8 iovbuf[WL_EVENTING_MASK_LEN + 12];   /*  Room for "event_msgs" +
-                                                '\0' + bitvec  */
-       s32 err = 0;
-
-       /* Match Host and Dongle rx alignment */
-       brcmu_mkiovar("bus:txglomalign", (char *)&dongle_align, 4, iovbuf,
-                   sizeof(iovbuf));
-       err = wl_dev_ioctl(ndev, BRCMF_C_SET_VAR, iovbuf, sizeof(iovbuf));
-       if (unlikely(err)) {
-               WL_ERR("txglomalign error (%d)\n", err);
-               goto dongle_glom_out;
-       }
-       /* disable glom option per default */
-       brcmu_mkiovar("bus:txglom", (char *)&glom, 4, iovbuf, sizeof(iovbuf));
-       err = wl_dev_ioctl(ndev, BRCMF_C_SET_VAR, iovbuf, sizeof(iovbuf));
-       if (unlikely(err)) {
-               WL_ERR("txglom error (%d)\n", err);
-               goto dongle_glom_out;
-       }
-dongle_glom_out:
-       return err;
-}
-
-static s32
-wl_dongle_offload(struct net_device *ndev, s32 arpoe, s32 arp_ol)
-{
-       s8 iovbuf[WL_EVENTING_MASK_LEN + 12];   /*  Room for "event_msgs" +
-                                                        '\0' + bitvec  */
-       s32 err = 0;
-
-       /* Set ARP offload */
-       brcmu_mkiovar("arpoe", (char *)&arpoe, 4, iovbuf, sizeof(iovbuf));
-       err = wl_dev_ioctl(ndev, BRCMF_C_SET_VAR, iovbuf, sizeof(iovbuf));
-       if (err) {
-               if (err == -EOPNOTSUPP)
-                       WL_INFO("arpoe is not supported\n");
-               else
-                       WL_ERR("arpoe error (%d)\n", err);
-
-               goto dongle_offload_out;
-       }
-       brcmu_mkiovar("arp_ol", (char *)&arp_ol, 4, iovbuf, sizeof(iovbuf));
-       err = wl_dev_ioctl(ndev, BRCMF_C_SET_VAR, iovbuf, sizeof(iovbuf));
-       if (err) {
-               if (err == -EOPNOTSUPP)
-                       WL_INFO("arp_ol is not supported\n");
-               else
-                       WL_ERR("arp_ol error (%d)\n", err);
-
-               goto dongle_offload_out;
-       }
-
-dongle_offload_out:
-       return err;
-}
-
-static s32 wl_pattern_atoh(s8 *src, s8 *dst)
-{
-       int i;
-       if (strncmp(src, "0x", 2) != 0 && strncmp(src, "0X", 2) != 0) {
-               WL_ERR("Mask invalid format. Needs to start with 0x\n");
-               return -1;
-       }
-       src = src + 2;          /* Skip past 0x */
-       if (strlen(src) % 2 != 0) {
-               WL_ERR("Mask invalid format. Needs to be of even length\n");
-               return -1;
-       }
-       for (i = 0; *src != '\0'; i++) {
-               char num[3];
-               strncpy(num, src, 2);
-               num[2] = '\0';
-               dst[i] = (u8) simple_strtoul(num, NULL, 16);
-               src += 2;
-       }
-       return i;
-}
-
-static s32 wl_dongle_filter(struct net_device *ndev, u32 filter_mode)
-{
-       s8 iovbuf[WL_EVENTING_MASK_LEN + 12];   /*  Room for "event_msgs" +
-                                                        '\0' + bitvec  */
-       const s8 *str;
-       struct wl_pkt_filter pkt_filter;
-       struct wl_pkt_filter *pkt_filterp;
-       s32 buf_len;
-       s32 str_len;
-       u32 mask_size;
-       u32 pattern_size;
-       s8 buf[256];
-       s32 err = 0;
-
-/* add a default packet filter pattern */
-       str = "pkt_filter_add";
-       str_len = strlen(str);
-       strncpy(buf, str, str_len);
-       buf[str_len] = '\0';
-       buf_len = str_len + 1;
-
-       pkt_filterp = (struct wl_pkt_filter *)(buf + str_len + 1);
-
-       /* Parse packet filter id. */
-       pkt_filter.id = cpu_to_le32(100);
-
-       /* Parse filter polarity. */
-       pkt_filter.negate_match = cpu_to_le32(0);
-
-       /* Parse filter type. */
-       pkt_filter.type = cpu_to_le32(0);
-
-       /* Parse pattern filter offset. */
-       pkt_filter.u.pattern.offset = cpu_to_le32(0);
-
-       /* Parse pattern filter mask. */
-       mask_size = cpu_to_le32(wl_pattern_atoh("0xff",
-                                               (char *)pkt_filterp->u.pattern.
-                                               mask_and_pattern));
-
-       /* Parse pattern filter pattern. */
-       pattern_size = cpu_to_le32(wl_pattern_atoh("0x00",
-                                                  (char *)&pkt_filterp->u.
-                                                  pattern.
-                                                  mask_and_pattern
-                                                  [mask_size]));
-
-       if (mask_size != pattern_size) {
-               WL_ERR("Mask and pattern not the same size\n");
-               err = -EINVAL;
-               goto dongle_filter_out;
-       }
-
-       pkt_filter.u.pattern.size_bytes = mask_size;
-       buf_len += WL_PKT_FILTER_FIXED_LEN;
-       buf_len += (WL_PKT_FILTER_PATTERN_FIXED_LEN + 2 * mask_size);
-
-       /* Keep-alive attributes are set in local
-        * variable (keep_alive_pkt), and
-        * then memcpy'ed into buffer (keep_alive_pktp) since there is no
-        * guarantee that the buffer is properly aligned.
-        */
-       memcpy((char *)pkt_filterp, &pkt_filter,
-              WL_PKT_FILTER_FIXED_LEN + WL_PKT_FILTER_PATTERN_FIXED_LEN);
-
-       err = wl_dev_ioctl(ndev, BRCMF_C_SET_VAR, buf, buf_len);
-       if (err) {
-               if (err == -EOPNOTSUPP) {
-                       WL_INFO("filter not supported\n");
-               } else {
-                       WL_ERR("filter (%d)\n", err);
-               }
-               goto dongle_filter_out;
-       }
-
-       /* set mode to allow pattern */
-       brcmu_mkiovar("pkt_filter_mode", (char *)&filter_mode, 4, iovbuf,
-                   sizeof(iovbuf));
-       err = wl_dev_ioctl(ndev, BRCMF_C_SET_VAR, iovbuf, sizeof(iovbuf));
-       if (err) {
-               if (err == -EOPNOTSUPP) {
-                       WL_INFO("filter_mode not supported\n");
-               } else {
-                       WL_ERR("filter_mode (%d)\n", err);
-               }
-               goto dongle_filter_out;
-       }
-
-dongle_filter_out:
-       return err;
-}
-#endif                         /* !EMBEDDED_PLATFORM */
-
 static s32 wl_dongle_eventmsg(struct net_device *ndev)
 {
        s8 iovbuf[WL_EVENTING_MASK_LEN + 12];   /*  Room for "event_msgs" +
@@ -4015,9 +3784,6 @@ dongle_scantime_out:
 
 s32 wl_config_dongle(struct wl_priv *wl, bool need_lock)
 {
-#ifndef DHD_SDALIGN
-#define DHD_SDALIGN    32
-#endif
        struct net_device *ndev;
        struct wireless_dev *wdev;
        s32 err = 0;
@@ -4030,24 +3796,6 @@ s32 wl_config_dongle(struct wl_priv *wl, bool need_lock)
        if (need_lock)
                rtnl_lock();
 
-#ifndef EMBEDDED_PLATFORM
-       err = wl_dongle_up(ndev, 0);
-       if (unlikely(err))
-               goto default_conf_out;
-       err = wl_dongle_country(ndev, 0);
-       if (unlikely(err))
-               goto default_conf_out;
-       err = wl_dongle_power(ndev, PM_FAST);
-       if (unlikely(err))
-               goto default_conf_out;
-       err = wl_dongle_glom(ndev, 0, DHD_SDALIGN);
-       if (unlikely(err))
-               goto default_conf_out;
-
-       wl_dongle_offload(ndev, 1, 0xf);
-       wl_dongle_filter(ndev, 1);
-#endif /* !EMBEDDED_PLATFORM */
-
        wl_dongle_scantime(ndev, WL_SCAN_CHANNEL_TIME,
                        WL_SCAN_UNASSOC_TIME, WL_SCAN_PASSIVE_TIME);