Commit fb11137a authored by Michael Buesch's avatar Michael Buesch Committed by John W. Linville
Browse files

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: default avatarMichael Buesch <mb@bu3sch.de>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 7cb77072
Loading
Loading
Loading
Loading
+22 −14
Original line number Diff line number Diff line
@@ -1091,7 +1091,11 @@ void b43_wireless_core_reset(struct b43_wldev *dev, u32 flags)
	ssb_read32(dev->dev, SSB_TMSLOW);	/* flush */
	msleep(1);

	/* Turn Analog ON */
	/* 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);
@@ -2694,6 +2698,7 @@ static void b43_mgmtframe_txantenna(struct b43_wldev *dev, int antenna)
/* 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 */
}
@@ -3952,7 +3957,6 @@ static void b43_wireless_core_exit(struct b43_wldev *dev)
		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);
@@ -3979,24 +3983,23 @@ static int b43_wireless_core_init(struct b43_wldev *dev)
		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);
@@ -4064,8 +4067,6 @@ static int b43_wireless_core_init(struct b43_wldev *dev)

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);
@@ -4342,6 +4343,7 @@ static 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)
@@ -4415,16 +4417,20 @@ static int b43_wireless_core_attach(struct b43_wldev *dev)
		}
	}

	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)
@@ -4438,6 +4444,8 @@ static int b43_wireless_core_attach(struct b43_wldev *dev)
out:
	return err;

err_phy_free:
	b43_phy_free(dev);
err_powerdown:
	ssb_bus_may_powerdown(bus);
	return err;
+31 −15
Original line number Diff line number Diff line
@@ -391,8 +391,6 @@ static int b43_aphy_op_allocate(struct b43_wldev *dev)
		return -ENOMEM;
	dev->phy.a = aphy;

	//TODO init struct b43_phy_a

	err = b43_aphy_init_tssi2dbm_table(dev);
	if (err)
		goto err_free_aphy;
@@ -406,30 +404,47 @@ static int b43_aphy_op_allocate(struct b43_wldev *dev)
	return err;
}

static int b43_aphy_op_init(struct b43_wldev *dev)
static void b43_aphy_op_prepare_structs(struct b43_wldev *dev)
{
	struct b43_phy_a *aphy = dev->phy.a;
	struct b43_phy *phy = &dev->phy;
	struct b43_phy_a *aphy = phy->a;
	const void *tssi2dbm;
	int tgt_idle_tssi;

	b43_phy_inita(dev);
	aphy->initialised = 1;
	/* tssi2dbm table is constant, so it is initialized at alloc time.
	 * Save a copy of the pointer. */
	tssi2dbm = aphy->tssi2dbm;
	tgt_idle_tssi = aphy->tgt_idle_tssi;

	/* Zero out the whole PHY structure. */
	memset(aphy, 0, sizeof(*aphy));

	aphy->tssi2dbm = tssi2dbm;
	aphy->tgt_idle_tssi = tgt_idle_tssi;

	//TODO init struct b43_phy_a

	return 0;
}

static void b43_aphy_op_exit(struct b43_wldev *dev)
static void b43_aphy_op_free(struct b43_wldev *dev)
{
	struct b43_phy_a *aphy = dev->phy.a;
	struct b43_phy *phy = &dev->phy;
	struct b43_phy_a *aphy = phy->a;

	if (aphy->initialised) {
		//TODO
		aphy->initialised = 0;
	}
	//TODO
	kfree(aphy->tssi2dbm);
	aphy->tssi2dbm = NULL;

	kfree(aphy);
	dev->phy.a = NULL;
}

static int b43_aphy_op_init(struct b43_wldev *dev)
{
	b43_phy_inita(dev);

	return 0;
}

static inline u16 adjust_phyreg(struct b43_wldev *dev, u16 offset)
{
	/* OFDM registers are base-registers for the A-PHY. */
@@ -608,8 +623,9 @@ static void b43_aphy_op_pwork_60sec(struct b43_wldev *dev)

const struct b43_phy_operations b43_phyops_a = {
	.allocate		= b43_aphy_op_allocate,
	.free			= b43_aphy_op_free,
	.prepare_structs	= b43_aphy_op_prepare_structs,
	.init			= b43_aphy_op_init,
	.exit			= b43_aphy_op_exit,
	.phy_read		= b43_aphy_op_read,
	.phy_write		= b43_aphy_op_write,
	.radio_read		= b43_aphy_op_radio_read,
+0 −2
Original line number Diff line number Diff line
@@ -103,8 +103,6 @@ void b43_ofdmtab_write32(struct b43_wldev *dev, u16 table,


struct b43_phy_a {
	bool initialised;

	/* Pointer to the table used to convert a
	 * TSSI value to dBm-Q5.2 */
	const s8 *tssi2dbm;
+7 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@
#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;
@@ -70,6 +70,12 @@ int b43_phy_operations_setup(struct b43_wldev *dev)
	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;
+23 −6
Original line number Diff line number Diff line
@@ -74,11 +74,21 @@ enum b43_txpwr_result {
/**
 * 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.
@@ -133,7 +143,9 @@ enum b43_txpwr_result {
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);

@@ -237,10 +249,15 @@ struct b43_phy {


/**
 * 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
Loading