View | Details | Raw Unified | Return to bug 144898
Collapse All | Expand All

(-)sys/dev/wpi/if_wpivar.h (-1 / +2 lines)
Lines 185-191 struct wpi_softc { Link Here
185
185
186
	/* Tasks used by the driver */
186
	/* Tasks used by the driver */
187
	struct task		sc_restarttask;	/* reset firmware task */
187
	struct task		sc_restarttask;	/* reset firmware task */
188
	struct task		sc_radiotask;	/* reset rf task */
188
	struct task		sc_radioontask;	/* disable rf task */
189
	struct task		sc_radioofftask;/* enable rf task */
189
190
190
       /* Eeprom info */
191
       /* Eeprom info */
191
	uint8_t			cap;
192
	uint8_t			cap;
(-)sys/dev/wpi/if_wpi.c (-67 / +40 lines)
Lines 228-234 static void wpi_stop_master(struct wpi_softc *); Link Here
228
static int	wpi_power_up(struct wpi_softc *);
228
static int	wpi_power_up(struct wpi_softc *);
229
static int	wpi_reset(struct wpi_softc *);
229
static int	wpi_reset(struct wpi_softc *);
230
static void	wpi_hwreset(void *, int);
230
static void	wpi_hwreset(void *, int);
231
static void	wpi_rfreset(void *, int);
231
static void	wpi_radio_off(void *, int);
232
static void	wpi_radio_on(void *, int);
232
static void	wpi_hw_config(struct wpi_softc *);
233
static void	wpi_hw_config(struct wpi_softc *);
233
static void	wpi_init(void *);
234
static void	wpi_init(void *);
234
static void	wpi_init_locked(struct wpi_softc *, int);
235
static void	wpi_init_locked(struct wpi_softc *, int);
Lines 514-520 wpi_attach(device_t dev) Link Here
514
515
515
	/* Create the tasks that can be queued */
516
	/* Create the tasks that can be queued */
516
	TASK_INIT(&sc->sc_restarttask, 0, wpi_hwreset, sc);
517
	TASK_INIT(&sc->sc_restarttask, 0, wpi_hwreset, sc);
517
	TASK_INIT(&sc->sc_radiotask, 0, wpi_rfreset, sc);
518
	TASK_INIT(&sc->sc_radioontask, 0, wpi_radio_on, sc);
519
	TASK_INIT(&sc->sc_radioofftask, 0, wpi_radio_off, sc);
518
520
519
	WPI_LOCK_INIT(sc);
521
	WPI_LOCK_INIT(sc);
520
522
Lines 719-725 wpi_detach(device_t dev) Link Here
719
		ic = ifp->if_l2com;
721
		ic = ifp->if_l2com;
720
722
721
		ieee80211_draintask(ic, &sc->sc_restarttask);
723
		ieee80211_draintask(ic, &sc->sc_restarttask);
722
		ieee80211_draintask(ic, &sc->sc_radiotask);
724
		ieee80211_draintask(ic, &sc->sc_radioontask);
725
		ieee80211_draintask(ic, &sc->sc_radioofftask);
723
		wpi_stop(sc);
726
		wpi_stop(sc);
724
		callout_drain(&sc->watchdog_to);
727
		callout_drain(&sc->watchdog_to);
725
		callout_drain(&sc->calib_to);
728
		callout_drain(&sc->calib_to);
Lines 1676-1692 wpi_notif_intr(struct wpi_softc *sc) Link Here
1676
		case WPI_STATE_CHANGED:
1679
		case WPI_STATE_CHANGED:
1677
		{
1680
		{
1678
			uint32_t *status = (uint32_t *)(desc + 1);
1681
			uint32_t *status = (uint32_t *)(desc + 1);
1682
			struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
1679
1683
1680
			/* enabled/disabled notification */
1684
			/* enabled/disabled notification */
1681
			DPRINTF(("state changed to %x\n", le32toh(*status)));
1685
			DPRINTF(("state changed to %x\n", le32toh(*status)));
1682
1686
1683
			if (le32toh(*status) & 1) {
1687
			if (le32toh(*status) & 1) {
1688
				sc->sc_scan_timer = 0;
1689
				if (vap) {
1690
					ieee80211_cancel_scan(vap);
1691
					ieee80211_notify_scan_done(vap);
1692
				}
1684
				device_printf(sc->sc_dev,
1693
				device_printf(sc->sc_dev,
1685
				    "Radio transmitter is switched off\n");
1694
				    "Radio transmitter is switched off\n");
1686
				sc->flags |= WPI_FLAG_HW_RADIO_OFF;
1695
				ieee80211_runtask(ic, &sc->sc_radioofftask);
1687
				ifp->if_drv_flags &= ~IFF_DRV_RUNNING;
1688
				/* Disable firmware commands */
1689
				WPI_WRITE(sc, WPI_UCODE_SET, WPI_DISABLE_CMD);
1690
			}
1696
			}
1691
			break;
1697
			break;
1692
		}
1698
		}
Lines 2094-2101 wpi_ioctl(struct ifnet *ifp, u_long cmd, caddr_t d Link Here
2094
				wpi_init_locked(sc, 0);
2100
				wpi_init_locked(sc, 0);
2095
				startall = 1;
2101
				startall = 1;
2096
			}
2102
			}
2097
		} else if ((ifp->if_drv_flags & IFF_DRV_RUNNING) ||
2103
		} else if ((ifp->if_drv_flags & IFF_DRV_RUNNING))
2098
			   (sc->flags & WPI_FLAG_HW_RADIO_OFF))
2099
			wpi_stop_locked(sc);
2104
			wpi_stop_locked(sc);
2100
		WPI_UNLOCK(sc);
2105
		WPI_UNLOCK(sc);
2101
		if (startall)
2106
		if (startall)
Lines 2967-3025 wpi_hw_config(struct wpi_softc *sc) Link Here
2967
}
2972
}
2968
2973
2969
static void
2974
static void
2970
wpi_rfkill_resume(struct wpi_softc *sc)
2971
{
2972
	struct ifnet *ifp = sc->sc_ifp;
2973
	struct ieee80211com *ic = ifp->if_l2com;
2974
	struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
2975
	int ntries;
2976
2977
	/* enable firmware again */
2978
	WPI_WRITE(sc, WPI_UCODE_CLR, WPI_RADIO_OFF);
2979
	WPI_WRITE(sc, WPI_UCODE_CLR, WPI_DISABLE_CMD);
2980
2981
	/* wait for thermal sensors to calibrate */
2982
	for (ntries = 0; ntries < 1000; ntries++) {
2983
		if ((sc->temp = (int)WPI_READ(sc, WPI_TEMPERATURE)) != 0)
2984
			break;
2985
		DELAY(10);
2986
	}
2987
2988
	if (ntries == 1000) {
2989
		device_printf(sc->sc_dev,
2990
		    "timeout waiting for thermal calibration\n");
2991
		WPI_UNLOCK(sc);
2992
		return;
2993
	}
2994
	DPRINTFN(WPI_DEBUG_TEMP,("temperature %d\n", sc->temp));
2995
2996
	if (wpi_config(sc) != 0) {
2997
		device_printf(sc->sc_dev, "device config failed\n");
2998
		WPI_UNLOCK(sc);
2999
		return;
3000
	}
3001
3002
	ifp->if_drv_flags &= ~IFF_DRV_OACTIVE;
3003
	ifp->if_drv_flags |= IFF_DRV_RUNNING;
3004
	sc->flags &= ~WPI_FLAG_HW_RADIO_OFF;
3005
3006
	if (vap != NULL) {
3007
		if ((ic->ic_flags & IEEE80211_F_SCAN) == 0) {
3008
			if (vap->iv_opmode != IEEE80211_M_MONITOR) {
3009
				ieee80211_beacon_miss(ic);
3010
				wpi_set_led(sc, WPI_LED_LINK, 0, 1);
3011
			} else
3012
				wpi_set_led(sc, WPI_LED_LINK, 5, 5);
3013
		} else {
3014
			ieee80211_scan_next(vap);
3015
			wpi_set_led(sc, WPI_LED_LINK, 20, 2);
3016
		}
3017
	}
3018
3019
	callout_reset(&sc->watchdog_to, hz, wpi_watchdog, sc);
3020
}
3021
3022
static void
3023
wpi_init_locked(struct wpi_softc *sc, int force)
2975
wpi_init_locked(struct wpi_softc *sc, int force)
3024
{
2976
{
3025
	struct ifnet *ifp = sc->sc_ifp;
2977
	struct ifnet *ifp = sc->sc_ifp;
Lines 3586-3600 wpi_hwreset(void *arg, int pending) Link Here
3586
}
3538
}
3587
3539
3588
static void
3540
static void
3589
wpi_rfreset(void *arg, int pending)
3541
wpi_radio_off(void *arg, int pending)
3590
{
3542
{
3591
	struct wpi_softc *sc = arg;
3543
	struct wpi_softc *sc = arg;
3544
	struct ifnet *ifp = sc->sc_ifp;
3545
	struct ieee80211com *ic = ifp->if_l2com;
3546
	struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
3592
3547
3593
	WPI_LOCK(sc);
3548
	wpi_stop(sc);
3594
	wpi_rfkill_resume(sc);
3549
	if (vap != NULL)
3595
	WPI_UNLOCK(sc);
3550
		ieee80211_stop(vap);
3551
3552
	sc->flags |= WPI_FLAG_HW_RADIO_OFF;
3553
	callout_reset(&sc->watchdog_to, hz, wpi_watchdog, sc);
3596
}
3554
}
3597
3555
3556
static void
3557
wpi_radio_on(void *arg, int pending)
3558
{
3559
	struct wpi_softc *sc = arg;
3560
	struct ifnet *ifp = sc->sc_ifp;
3561
	struct ieee80211com *ic = ifp->if_l2com;
3562
	struct ieee80211vap *vap = TAILQ_FIRST(&ic->ic_vaps);
3563
3564
	sc->flags &= ~WPI_FLAG_HW_RADIO_OFF;
3565
3566
	wpi_init(sc);
3567
	if (vap != NULL)
3568
		ieee80211_init(vap);
3569
}
3570
3598
/*
3571
/*
3599
 * Allocate DMA-safe memory for firmware transfer.
3572
 * Allocate DMA-safe memory for firmware transfer.
3600
 */
3573
 */
Lines 3638-3644 wpi_watchdog(void *arg) Link Here
3638
		}
3611
		}
3639
3612
3640
		device_printf(sc->sc_dev, "Hardware Switch Enabled\n");
3613
		device_printf(sc->sc_dev, "Hardware Switch Enabled\n");
3641
		ieee80211_runtask(ic, &sc->sc_radiotask);
3614
		ieee80211_runtask(ic, &sc->sc_radioontask);
3642
		return;
3615
		return;
3643
	}
3616
	}
3644
3617

Return to bug 144898