b43: split upload of init values into 2 functions
PATCH 1/4 b43: split upload of init values into 2 functions
There are two groups of init values. The first one has to be uploaded once per wireless core reset but the second one on every band switch. To implement band switching in an optimal way allow uploading band init values only (by using a separated function).
Signed-off-by Rafa? Mi?ecki <[email protected]>
--- drivers/net/wireless/b43/main.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-)
drivers/net/wireless/b43/main.c +22 -15
@@ -2711,27 +2711,30 @@ static int b43_upload_initvals(struct b43_wldev *dev)struct b43_firmware *fw = &dev->fw;const struct b43_iv *ivals;size_t count; -int err; hdr = (const struct b43_fw_header *)(fw->initvals.data->data); ivals = (const struct b43_iv *)(fw->initvals.data->data + hdr_len); count =be32_to_cpu (hdr->size); - err =b43_write_initvals (dev, ivals, count, +return b43_write_initvals (dev, ivals, count, fw->initvals.data->size - hdr_len); -if (err) - goto out; -if (fw->initvals_band.data) { - hdr = (const struct b43_fw_header *)(fw->initvals_band.data->data); - ivals = (const struct b43_iv *)(fw->initvals_band.data->data + hdr_len); - count =be32_to_cpu (hdr->size); - err =b43_write_initvals (dev, ivals, count, - fw->initvals_band.data->size - hdr_len); -if (err) - goto out; - } -out: +} -return err; +static int b43_upload_initvals_band (struct b43_wldev *dev) +{ +const size_t hdr_len =sizeof (struct b43_fw_header ); +const struct b43_fw_header *hdr; +struct b43_firmware *fw = &dev->fw; +const struct b43_iv *ivals; +size_t count; + +if (!fw->initvals_band.data) +return 0 ; + + hdr = (const struct b43_fw_header *)(fw->initvals_band.data->data); + ivals = (const struct b43_iv *)(fw->initvals_band.data->data + hdr_len); + count =be32_to_cpu (hdr->size); +return b43_write_initvals (dev, ivals, count, + fw->initvals_band.data->size - hdr_len); }/* Initialize the GPIOs
@@ -3100,6 +3103,10 @@ static int b43_chip_init(struct b43_wldev *dev)if (err) goto err_gpio_clean; + err =b43_upload_initvals_band (dev); +if (err) + goto err_gpio_clean; +/* Turn the Analog on and initialize the PHY. */ phy->ops->switch_analog (dev,1 ); err =b43_phy_init (dev);
Signature · 1 line
1.8.4.5
PATCH 2/4 b43: move PHY reset code into PHY specific file
Signed-off-by Rafa? Mi?ecki <[email protected]>
--- drivers/net/wireless/b43/main.c | 35 +---------------------------------- drivers/net/wireless/b43/phy_common.c | 33 +++++++++++++++++++++++++++++++++ drivers/net/wireless/b43/phy_common.h | 2 ++ 3 files changed, 36 insertions(+), 34 deletions(-)
drivers/net/wireless/b43/main.c +1 -34
@@ -3706,39 +3706,6 @@ static void b43_op_set_tsf(struct ieee80211_hw *hw,mutex_unlock (&wl->mutex); } -static void b43_put_phy_into_reset (struct b43_wldev *dev) -{ -#ifdef CONFIG_B43_SSB -u32 tmp; -#endif - -switch (dev->dev->bus_type) { -#ifdef CONFIG_B43_BCMA -case B43_BUS_BCMA : -b43err (dev->wl, -"Putting PHY into reset not supported on BCMA\n" ); -break ; -#endif -#ifdef CONFIG_B43_SSB -case B43_BUS_SSB : - tmp =ssb_read32 (dev->dev->sdev,SSB_TMSLOW ); - tmp &= ~B43_TMSLOW_GMODE ; - tmp |=B43_TMSLOW_PHYRESET ; - tmp |=SSB_TMSLOW_FGC ; -ssb_write32 (dev->dev->sdev,SSB_TMSLOW , tmp); -msleep (1 ); - - tmp =ssb_read32 (dev->dev->sdev,SSB_TMSLOW ); - tmp &= ~SSB_TMSLOW_FGC ; - tmp |=B43_TMSLOW_PHYRESET ; -ssb_write32 (dev->dev->sdev,SSB_TMSLOW , tmp); -msleep (1 ); - -break ; -#endif - } -} -static const char *band_to_string (enum ieee80211_band band) {switch (band) {
@@ -3804,7 +3771,7 @@ static int b43_switch_band(struct b43_wl *wl, struct ieee80211_channel *chan)if (down_dev != up_dev) {/* We switch to a different core, so we put PHY into * RESET on the old core. */ -b43_put_phy_into_reset (down_dev); +b43_phy_put_into_reset (down_dev); }/* Now start the new core. */
drivers/net/wireless/b43/phy_common.c +33 -0
@@ -312,6 +312,39 @@ void b43_phy_maskset(struct b43_wldev *dev, u16 offset, u16 mask, u16 set) } } +void b43_phy_put_into_reset (struct b43_wldev *dev) +{ +#ifdef CONFIG_B43_SSB +u32 tmp; +#endif + +switch (dev->dev->bus_type) { +#ifdef CONFIG_B43_BCMA +case B43_BUS_BCMA : +b43err (dev->wl, +"Putting PHY into reset not supported on BCMA\n" ); +break ; +#endif +#ifdef CONFIG_B43_SSB +case B43_BUS_SSB : + tmp =ssb_read32 (dev->dev->sdev,SSB_TMSLOW ); + tmp &= ~B43_TMSLOW_GMODE ; + tmp |=B43_TMSLOW_PHYRESET ; + tmp |=SSB_TMSLOW_FGC ; +ssb_write32 (dev->dev->sdev,SSB_TMSLOW , tmp); +msleep (1 ); + + tmp =ssb_read32 (dev->dev->sdev,SSB_TMSLOW ); + tmp &= ~SSB_TMSLOW_FGC ; + tmp |=B43_TMSLOW_PHYRESET ; +ssb_write32 (dev->dev->sdev,SSB_TMSLOW , tmp); +msleep (1 ); + +break ; +#endif + } +} +int b43_switch_channel (struct b43_wldev *dev,unsigned int new_channel) {struct b43_phy *phy = &(dev->phy);
drivers/net/wireless/b43/phy_common.h +2 -0
@@ -390,6 +390,8 @@ void b43_phy_lock(struct b43_wldev *dev);*/ void b43_phy_unlock (struct b43_wldev *dev); +void b43_phy_put_into_reset (struct b43_wldev *dev); +/** * b43_switch_channel - Switch to another channel */
Signature · 1 line
1.8.4.5
PATCH 3/4 b43: complete PHY reset
In reply to Rafał MiłeckiUse separated function for taking PHY out of reset and implement reset for BCMA.
Signed-off-by Rafa? Mi?ecki <[email protected]>
--- drivers/net/wireless/b43/main.c | 27 ++------------- drivers/net/wireless/b43/phy_common.c | 65 +++++++++++++++++++++++++++++++---- drivers/net/wireless/b43/phy_common.h | 1 + 3 files changed, 61 insertions(+), 32 deletions(-)
drivers/net/wireless/b43/main.c +2 -25
@@ -1175,18 +1175,7 @@ static void b43_bcma_phy_reset(struct b43_wldev *dev)bcma_awrite32 (dev->dev->bdev,BCMA_IOCTL , flags);udelay (2 ); -/* Take PHY out of reset */ - flags =bcma_aread32 (dev->dev->bdev,BCMA_IOCTL ); - flags &= ~B43_BCMA_IOCTL_PHY_RESET ; - flags |=BCMA_IOCTL_FGC ; -bcma_awrite32 (dev->dev->bdev,BCMA_IOCTL , flags); -udelay (1 ); - -/* Do not force clock anymore */ - flags =bcma_aread32 (dev->dev->bdev,BCMA_IOCTL ); - flags &= ~BCMA_IOCTL_FGC ; -bcma_awrite32 (dev->dev->bdev,BCMA_IOCTL , flags); -udelay (1 ); +b43_phy_take_out_of_reset (dev); }static void b43_bcma_wireless_core_reset (struct b43_wldev *dev,bool gmode)
@@ -1211,8 +1200,6 @@ static void b43_bcma_wireless_core_reset(struct b43_wldev *dev, bool gmode)#ifdef CONFIG_B43_SSB static void b43_ssb_wireless_core_reset (struct b43_wldev *dev,bool gmode) { -struct ssb_device *sdev = dev->dev->sdev; -u32 tmslow;u32 flags =0 ;if (gmode)
@@ -1224,17 +1211,7 @@ static void b43_ssb_wireless_core_reset(struct b43_wldev *dev, bool gmode)b43_device_enable (dev, flags);msleep (2 );/* Wait for the PLL to turn on. */ -/* Now take the PHY out of Reset again */ - tmslow =ssb_read32 (sdev,SSB_TMSLOW ); - tmslow |=SSB_TMSLOW_FGC ; - tmslow &= ~B43_TMSLOW_PHYRESET ; -ssb_write32 (sdev,SSB_TMSLOW , tmslow); -ssb_read32 (sdev,SSB_TMSLOW );/* flush */ -msleep (1 ); - tmslow &= ~SSB_TMSLOW_FGC ; -ssb_write32 (sdev,SSB_TMSLOW , tmslow); -ssb_read32 (sdev,SSB_TMSLOW );/* flush */ - msleep(1); + b43_phy_take_out_of_reset(dev); }#endif
drivers/net/wireless/b43/phy_common.c +58 -7
87 lines not on this page · raw message
drivers/net/wireless/b43/phy_common.h +1 -0
@@ -391,6 +391,7 @@ void b43_phy_lock(struct b43_wldev *dev);void b43_phy_unlock (struct b43_wldev *dev);void b43_phy_put_into_reset (struct b43_wldev *dev); +void b43_phy_take_out_of_reset (struct b43_wldev *dev);/** * b43_switch_channel - Switch to another channel
Signature · 1 line
1.8.4.5
PATCH 4/4 b43: rework band switching
In reply to Rafał MiłeckiWe always operate on one core and simple band switch doesn't require full core reset. Simply reset the PHY.
Signed-off-by Rafa? Mi?ecki <[email protected]>
--- drivers/net/wireless/b43/main.c | 104 ++++++++++++++-------------------- drivers/net/wireless/b43/phy_common.c | 1 + 2 files changed, 45 insertions(+), 60 deletions(-)
drivers/net/wireless/b43/main.c +44 -60
@@ -3698,89 +3698,73 @@ static const char *band_to_string(enum ieee80211_band band) }/* Expects wl->mutex locked */ -static int b43_switch_band (struct b43_wl *wl,struct ieee80211_channel *chan) +static int b43_switch_band (struct b43_wldev *dev, +struct ieee80211_channel *chan) { -struct b43_wldev *up_dev =NULL ; -struct b43_wldev *down_dev; -int err; -bool uninitialized_var (gmode ); -int prev_status; +struct b43_phy *phy = &dev->phy; +bool gmode; +u32 tmp; -/* Find a device and PHY which supports the band. */ switch (chan->band) {case IEEE80211_BAND_5GHZ : -if (wl->current_dev->phy.supports_5ghz) { - up_dev = wl->current_dev; - gmode = false; - } + gmode = false;break ;case IEEE80211_BAND_2GHZ : -if (wl->current_dev->phy.supports_2ghz) { - up_dev = wl->current_dev; - gmode = true; - } + gmode = true;break ;default :B43_WARN_ON (1 );return -EINVAL ; } -if (!up_dev) { -b43err (wl,"Could not find a device for %s-GHz band operation\n" , +if (!((gmode && phy->supports_2ghz) || + (!gmode && phy->supports_5ghz))) { +b43err (dev->wl,"This device doesn't support %s-GHz band\n" ,band_to_string (chan->band));return -ENODEV ; } -if (!!wl->current_dev->phy.gmode == !!gmode) { + +if (!!phy->gmode == !!gmode) {/* This device is already running. */ return 0 ; } -b43dbg (wl,"Switching to %s-GHz band\n" , + +b43dbg (dev->wl,"Switching to %s GHz band\n" ,band_to_string (chan->band)); - down_dev = wl->current_dev; - prev_status =b43_status (down_dev); -/* Shutdown the currently running core. */ -if (prev_status >=B43_STAT_STARTED ) - down_dev =b43_wireless_core_stop (down_dev); -if (prev_status >=B43_STAT_INITIALIZED ) -b43_wireless_core_exit (down_dev); +b43_software_rfkill (dev, true); -if (down_dev != up_dev) { -/* We switch to a different core, so we put PHY into -* RESET on the old core. */ -b43_phy_put_into_reset (down_dev); + phy->gmode = gmode; +b43_phy_put_into_reset (dev); +switch (dev->dev->bus_type) { +#ifdef CONFIG_B43_BCMA +case B43_BUS_BCMA : + tmp =bcma_aread32 (dev->dev->bdev,BCMA_IOCTL ); +if (gmode) + tmp |=B43_BCMA_IOCTL_GMODE ; +else + tmp &= ~B43_BCMA_IOCTL_GMODE ; +bcma_awrite32 (dev->dev->bdev,BCMA_IOCTL , tmp); +break ; +#endif +#ifdef CONFIG_B43_SSB +case B43_BUS_SSB : + tmp =ssb_read32 (dev->dev->sdev,SSB_TMSLOW ); +if (gmode) + tmp |=B43_TMSLOW_GMODE ; +else + tmp &= ~B43_TMSLOW_GMODE ; +ssb_write32 (dev->dev->sdev,SSB_TMSLOW , tmp); +break ; +#endif } +b43_phy_take_out_of_reset (dev); -/* Now start the new core. */ - up_dev->phy.gmode = gmode; -if (prev_status >=B43_STAT_INITIALIZED ) { - err =b43_wireless_core_init (up_dev); -if (err) { -b43err (wl,"Fatal: Could not initialize device for " -"selected %s-GHz band\n" , -band_to_string (chan->band)); - goto init_failure; - } - } -if (prev_status >=B43_STAT_STARTED ) { - err =b43_wireless_core_start (up_dev); -if (err) { -b43err (wl,"Fatal: Could not start device for " -"selected %s-GHz band\n" , -band_to_string (chan->band)); -b43_wireless_core_exit (up_dev); - goto init_failure; - } - } -B43_WARN_ON (b43_status (up_dev) != prev_status); +b43_upload_initvals_band (dev); - wl->current_dev = up_dev; +b43_phy_init (dev);return 0 ; -init_failure: -/* Whoops, failed to init the new core. No core is operating now. */ - wl->current_dev =NULL ; -return err; }/* Write the short and long frame retry limit values. */
@@ -3813,8 +3797,10 @@ static int b43_op_config(struct ieee80211_hw *hw, u32 changed) dev = wl->current_dev; +b43_mac_suspend (dev); +/* Switch the band (if necessary). This might change the active core. */ - err =b43_switch_band (wl, conf->chandef.chan); + err =b43_switch_band (dev, conf->chandef.chan);if (err) goto out_unlock_mutex;
@@ -3833,8 +3819,6 @@ static int b43_op_config(struct ieee80211_hw *hw, u32 changed)else phy->is_40mhz = false; -b43_mac_suspend (dev); -if (changed &IEEE80211_CONF_CHANGE_RETRY_LIMITS )b43_set_retry_limits (dev, conf->short_frame_max_tx_count, conf->long_frame_max_tx_count);
drivers/net/wireless/b43/phy_common.c +1 -0
@@ -96,6 +96,7 @@ int b43_phy_init(struct b43_wldev *dev) phy->channel = ops->get_default_chan (dev); + phy->ops->switch_analog (dev, true);b43_software_rfkill (dev, false); err = ops->init (dev);if (err) {
Signature · 1 line
1.8.4.5