b43: Split PHY alloc and init
PATCH 1/1 b43: Split PHY alloc and init
This splits the PHY allocation from the PHY init. This is needed in order to properly support Analog handling.
Signed-off-by Michael Buesch <[email protected]>
---
Please queue for the next merge window.
drivers/net/wireless/b43/main.c +22 -14
@@ -1088,14 +1088,18 @@ void b43_wireless_core_reset(struct b43_msleep (1 ); tmslow &= ~SSB_TMSLOW_FGC ;ssb_write32 (dev->dev,SSB_TMSLOW , tmslow);ssb_read32 (dev->dev,SSB_TMSLOW );/* flush */ msleep (1 ); -/* Turn Analog ON */ -b43_switch_analog (dev,1 ); +/* Turn Analog ON, but only if we already know the PHY-type. +* This protects against very early setup where we don't know the +* PHY-type, yet. wireless_core_reset will be called once again later, +* when we know the PHY-type. */ +if (dev->phy.ops) +b43_switch_analog (dev,1 ); macctl =b43_read32 (dev,B43_MMIO_MACCTL ); macctl &= ~B43_MACCTL_GMODE ;if (flags &B43_TMSLOW_GMODE ) macctl |=B43_MACCTL_GMODE ; macctl |=B43_MACCTL_IHR_ENABLED ;
@@ -2691,12 +2695,13 @@ static void b43_mgmtframe_txantenna(strub43_shm_write16 (dev,B43_SHM_SHARED ,B43_SHM_SH_PRPHYCTL , tmp); }/* This is the opposite of b43_chip_init() */ static void b43_chip_exit (struct b43_wldev *dev) { +b43_phy_exit (dev);b43_gpio_cleanup (dev);/* firmware is released later */ }/* Initialize the chip * http://bcm-specs.sipsolutions.net/ChipInit
@@ -3949,13 +3954,12 @@ static void b43_wireless_core_exit(strucb43_chip_exit (dev);b43_switch_analog (dev,0 );if (dev->wl->current_beacon) {dev_kfree_skb_any (dev->wl->current_beacon); dev->wl->current_beacon =NULL ; } -b43_phy_exit (dev);ssb_device_disable (dev->dev,0 );ssb_bus_may_powerdown (dev->dev->bus); }/* Initialize a wireless core */
@@ -3976,30 +3980,29 @@ static int b43_wireless_core_init(struct goto out;if (!ssb_device_is_enabled (dev->dev)) { tmp = phy->gmode ?B43_TMSLOW_GMODE :0 ;b43_wireless_core_reset (dev, tmp); } +/* Reset all data structures. */ setup_struct_wldev_for_init (dev); - err =b43_phy_operations_setup (dev); -if (err) - goto err_busdown; + phy->ops->prepare_structs (dev);/* Enable IRQ routing to this device. */ ssb_pcicore_dev_irqvecs_enable (&bus->pcicore, dev->dev);b43_imcfglo_timeouts_workaround (dev);b43_bluetooth_coext_disable (dev); -if (phy->ops->prepare) { - err = phy->ops->prepare (dev); +if (phy->ops->prepare_hardware) { + err = phy->ops->prepare_hardware (dev);if (err) - goto err_phy_exit; + goto err_busdown; } err =b43_chip_init (dev);if (err) - goto err_phy_exit; + goto err_busdown;b43_shm_write16 (dev,B43_SHM_SHARED ,B43_SHM_SH_WLCOREREV , dev->dev->id.revision); hf =b43_hf_read (dev);if (phy->type ==B43_PHYTYPE_G ) { hf |=B43_HF_SYMW ;if (phy->rev ==1 )
@@ -4061,14 +4064,12 @@ static int b43_wireless_core_init(structb43_leds_init (dev); out:return err; err_chip_exit:b43_chip_exit (dev); -err_phy_exit: -b43_phy_exit (dev); err_busdown:ssb_bus_may_powerdown (bus);B43_WARN_ON (b43_status (dev) !=B43_STAT_UNINIT );return err; }
@@ -4339,12 +4340,13 @@ static int b43_setup_bands(struct b43_wlstatic void b43_wireless_core_detach (struct b43_wldev *dev) {/* We release firmware that late to not be required to re-request * is all the time when we reinit the core. */ b43_release_firmware (dev); +b43_phy_free (dev); }static int b43_wireless_core_attach (struct b43_wldev *dev) {struct b43_wl *wl = dev->wl;struct ssb_bus *bus = dev->dev->bus;
@@ -4412,22 +4414,26 @@ static int b43_wireless_core_attach(struif (dev->phy.type !=B43_PHYTYPE_N ) { have_2ghz_phy =1 ; have_5ghz_phy =0 ; } } + err =b43_phy_allocate (dev); +if (err) + goto err_powerdown; + dev->phy.gmode = have_2ghz_phy; tmp = dev->phy.gmode ?B43_TMSLOW_GMODE :0 ;b43_wireless_core_reset (dev, tmp); err =b43_validate_chipaccess (dev);if (err) - goto err_powerdown; + goto err_phy_free; err =b43_setup_bands (dev, have_2ghz_phy, have_5ghz_phy);if (err) - goto err_powerdown; + goto err_phy_free;/* Now set some default "current_dev" */ if (!wl->current_dev) wl->current_dev = dev;INIT_WORK (&dev->restart_work, b43_chip_reset);
@@ -4435,12 +4441,14 @@ static int b43_wireless_core_attach(strussb_device_disable (dev->dev,0 );ssb_bus_may_powerdown (bus); out:return err; +err_phy_free: +b43_phy_free (dev); err_powerdown:ssb_bus_may_powerdown (bus);return err; }static void b43_one_core_detach (struct ssb_device *dev)
drivers/net/wireless/b43/phy_a.c +31 -15
95 lines not on this page · raw message
drivers/net/wireless/b43/phy_a.h +0 -2
@@ -100,14 +100,12 @@ void b43_ofdmtab_write16(struct b43_wldeu32 b43_ofdmtab_read32 (struct b43_wldev *dev,u16 table,u16 offset);void b43_ofdmtab_write32 (struct b43_wldev *dev,u16 table,u16 offset,u32 value);struct b43_phy_a { -bool initialised; -/* Pointer to the table used to convert a * TSSI value to dBm-Q5.2 */ const s8 *tssi2dbm;/* Target idle TSSI */ int tgt_idle_tssi;/* Current idle TSSI */
drivers/net/wireless/b43/phy_common.c +7 -1
@@ -32,13 +32,13 @@#include "phy_n.h" #include "phy_lp.h" #include "b43.h" #include "main.h" -int b43_phy_operations_setup (struct b43_wldev *dev) +int b43_phy_allocate (struct b43_wldev *dev) {struct b43_phy *phy = &(dev->phy);int err; phy->ops =NULL ;
@@ -67,12 +67,18 @@ int b43_phy_operations_setup(struct b43_if (err) phy->ops =NULL ;return err; } +void b43_phy_free (struct b43_wldev *dev) +{ + dev->phy.ops->free (dev); + dev->phy.ops =NULL ; +} +int b43_phy_init (struct b43_wldev *dev) {struct b43_phy *phy = &dev->phy;const struct b43_phy_operations *ops = phy->ops;int err;
drivers/net/wireless/b43/phy_common.h +23 -6
@@ -71,17 +71,27 @@ enum b43_txpwr_result { B43_TXPWR_RES_DONE, };/** * struct b43_phy_operations - Function pointers for PHY ops. * -* @prepare: Prepare the PHY. This is called before @init. +* @allocate: Allocate and initialise the PHY data structures. +* Must not be NULL. +* @free: Destroy and free the PHY data structures. +* Must not be NULL. +* +* @prepare_structs: Prepare the PHY data structures. +* The data structures allocated in @allocate are +* initialized here. +* Must not be NULL. +* @prepare_hardware: Prepare the PHY. This is called before b43_chip_init to +* do some early early PHY hardware init. * Can be NULL, if not required. * @init: Initialize the PHY. * Must not be NULL. -* @exit: Shutdown the PHY and free all data structures. +* @exit: Shutdown the PHY. * Can be NULL, if not required. * * @phy_read: Read from a PHY register. * Must not be NULL. * @phy_write: Write to a PHY register. * Must not be NULL.
@@ -130,13 +140,15 @@ enum b43_txpwr_result {* @pwork_60sec: Periodic work. Called every 60 seconds. * Can be NULL, if not required. */ struct b43_phy_operations {/* Initialisation */ int (*allocate)(struct b43_wldev *dev); -int (*prepare)(struct b43_wldev *dev); +void (*free)(struct b43_wldev *dev); +void (*prepare_structs)(struct b43_wldev *dev); +int (*prepare_hardware)(struct b43_wldev *dev);int (*init)(struct b43_wldev *dev);void (*exit)(struct b43_wldev *dev);/* Register access */ u16 (*phy_read)(struct b43_wldev *dev,u16 reg);void (*phy_write)(struct b43_wldev *dev,u16 reg,u16 value);
@@ -234,16 +246,21 @@ struct b43_phy {bool phy_locked;#endif /* B43_DEBUG */ };/** -* b43_phy_operations_setup - Initialize the PHY operations datastructure -* based on the current PHY type. +* b43_phy_allocate - Allocate PHY structs +* Allocate the PHY data structures, based on the current dev->phy.type +*/ +int b43_phy_allocate (struct b43_wldev *dev); + +/** +* b43_phy_free - Free PHY structs */ -int b43_phy_operations_setup (struct b43_wldev *dev); +void b43_phy_free (struct b43_wldev *dev);/** * b43_phy_init - Initialise the PHY */ int b43_phy_init (struct b43_wldev *dev);
drivers/net/wireless/b43/phy_g.c +63 -33
168 lines not on this page · raw message
drivers/net/wireless/b43/phy_g.h +0 -2
@@ -111,14 +111,12 @@ static inline bool b43_compare_bbatt(con#define B43_TXCTL_PA2DB 0x20/* PA Gain 2dB */ #define B43_TXCTL_TXMIX 0x10/* TX Mixer Gain */ struct b43_txpower_lo_control ;struct b43_phy_g { -bool initialised; -/* ACI (adjacent channel interference) flags. */ bool aci_enable;bool aci_wlan_automatic;bool aci_hw_rssi;/* Radio switched on/off */
drivers/net/wireless/b43/phy_lp.c +15 -14
@@ -33,40 +33,40 @@ static int b43_lpphy_op_allocate(struct lpphy =kzalloc (sizeof (*lpphy),GFP_KERNEL );if (!lpphy)return -ENOMEM ; dev->phy.lp = lpphy; -//TODO -return 0 ; } -static int b43_lpphy_op_init (struct b43_wldev *dev) +static void b43_lpphy_op_prepare_structs (struct b43_wldev *dev) { -struct b43_phy_lp *lpphy = dev->phy.lp; +struct b43_phy *phy = &dev->phy; +struct b43_phy_lp *lpphy = phy->lp; -//TODO - lpphy->initialised =1 ; +memset (lpphy,0 ,sizeof (*lpphy)); -return 0 ; +//TODO } -static void b43_lpphy_op_exit (struct b43_wldev *dev) +static void b43_lpphy_op_free (struct b43_wldev *dev) {struct b43_phy_lp *lpphy = dev->phy.lp; -if (lpphy->initialised) { -//TODO - lpphy->initialised =0 ; - } -kfree (lpphy); dev->phy.lp =NULL ; } +static int b43_lpphy_op_init (struct b43_wldev *dev) +{ +//TODO + +return 0 ; +} +static u16 b43_lpphy_op_read (struct b43_wldev *dev,u16 reg) {b43_write16 (dev,B43_MMIO_PHY_CONTROL , reg);return b43_read16 (dev,B43_MMIO_PHY_DATA ); }
@@ -135,14 +135,15 @@ static enum b43_txpwr_result b43_lpphy_oreturn B43_TXPWR_RES_DONE ; }const struct b43_phy_operations b43_phyops_lp = { .allocate = b43_lpphy_op_allocate, + .free = b43_lpphy_op_free, + .prepare_structs = b43_lpphy_op_prepare_structs, .init = b43_lpphy_op_init, - .exit = b43_lpphy_op_exit, .phy_read = b43_lpphy_op_read, .phy_write = b43_lpphy_op_write, .radio_read = b43_lpphy_op_radio_read, .radio_write = b43_lpphy_op_radio_write, .software_rfkill = b43_lpphy_op_software_rfkill, .switch_channel = b43_lpphy_op_switch_channel,
drivers/net/wireless/b43/phy_lp.h +1 -1
@@ -527,13 +527,13 @@#define B2063_EXT_TSSI_CTL2 B43_LP_RADIO(0x127)/* EXT TSSI Control 2 */ #define B2063_AFE_CTL B43_LP_RADIO(0x128)/* AFE Control */ struct b43_phy_lp { -bool initialised; +//TODO };struct b43_phy_operations ;extern const struct b43_phy_operations b43_phyops_lp;
drivers/net/wireless/b43/phy_n.c +16 -19
@@ -496,41 +496,37 @@ static int b43_nphy_op_allocate(struct b nphy =kzalloc (sizeof (*nphy),GFP_KERNEL );if (!nphy)return -ENOMEM ; dev->phy.n = nphy; -//TODO init struct b43_phy_n -return 0 ; } -static int b43_nphy_op_init (struct b43_wldev *dev) +static void b43_nphy_op_prepare_structs (struct b43_wldev *dev) { -struct b43_phy_n *nphy = dev->phy.n; -int err; +struct b43_phy *phy = &dev->phy; +struct b43_phy_n *nphy = phy->n; - err =b43_phy_initn (dev); -if (err) -return err; - nphy->initialised =1 ; +memset (nphy,0 ,sizeof (*nphy)); -return 0 ; +//TODO init struct b43_phy_n } -static void b43_nphy_op_exit (struct b43_wldev *dev) +static void b43_nphy_op_free (struct b43_wldev *dev) { -struct b43_phy_n *nphy = dev->phy.n; +struct b43_phy *phy = &dev->phy; +struct b43_phy_n *nphy = phy->n; -if (nphy->initialised) { -//TODO - nphy->initialised =0 ; - } -//TODO kfree (nphy); - dev->phy.n =NULL ; + phy->n =NULL ; +} + +static int b43_nphy_op_init (struct b43_wldev *dev) +{ +return b43_phy_initn (dev); }static inline void check_phyreg (struct b43_wldev *dev,u16 offset) {#if B43_DEBUG if ((offset &B43_PHYROUTE ) ==B43_PHYROUTE_OFDM_GPHY ) {
@@ -607,14 +603,15 @@ static unsigned int b43_nphy_op_get_defareturn 1 ;return 36 ; }const struct b43_phy_operations b43_phyops_n = { .allocate = b43_nphy_op_allocate, + .free = b43_nphy_op_free, + .prepare_structs = b43_nphy_op_prepare_structs, .init = b43_nphy_op_init, - .exit = b43_nphy_op_exit, .phy_read = b43_nphy_op_read, .phy_write = b43_nphy_op_write, .radio_read = b43_nphy_op_radio_read, .radio_write = b43_nphy_op_radio_write, .software_rfkill = b43_nphy_op_software_rfkill, .switch_channel = b43_nphy_op_switch_channel,
drivers/net/wireless/b43/phy_n.h +0 -2
@@ -917,14 +917,12 @@struct b43_wldev ;struct b43_phy_n { -bool initialised; -//TODO lots of missing stuff };struct b43_phy_operations ;extern const struct b43_phy_operations b43_phyops_n;