Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 207532 | Differences between
and this patch

Collapse All | Expand All

(-)linux-2.6/drivers/ssb/b43_pci_bridge.c (+1 lines)
Lines 27-32 static const struct pci_device_id b43_pc Link Here
27
	{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4321) },
27
	{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4321) },
28
	{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4324) },
28
	{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4324) },
29
	{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4325) },
29
	{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4325) },
30
	{ PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, 0x4328) },
30
	{ 0, },
31
	{ 0, },
31
};
32
};
32
MODULE_DEVICE_TABLE(pci, b43_pci_bridge_tbl);
33
MODULE_DEVICE_TABLE(pci, b43_pci_bridge_tbl);
(-)linux-2.6/drivers/ssb/main.c (-1 / +9 lines)
Lines 872-885 EXPORT_SYMBOL(ssb_clockspeed); Link Here
872
872
873
static u32 ssb_tmslow_reject_bitmask(struct ssb_device *dev)
873
static u32 ssb_tmslow_reject_bitmask(struct ssb_device *dev)
874
{
874
{
875
	u32 rev = ssb_read32(dev, SSB_IDLOW) & SSB_IDLOW_SSBREV;
876
875
	/* The REJECT bit changed position in TMSLOW between
877
	/* The REJECT bit changed position in TMSLOW between
876
	 * Backplane revisions. */
878
	 * Backplane revisions. */
877
	switch (ssb_read32(dev, SSB_IDLOW) & SSB_IDLOW_SSBREV) {
879
	switch (rev) {
878
	case SSB_IDLOW_SSBREV_22:
880
	case SSB_IDLOW_SSBREV_22:
879
		return SSB_TMSLOW_REJECT_22;
881
		return SSB_TMSLOW_REJECT_22;
880
	case SSB_IDLOW_SSBREV_23:
882
	case SSB_IDLOW_SSBREV_23:
881
		return SSB_TMSLOW_REJECT_23;
883
		return SSB_TMSLOW_REJECT_23;
884
	case SSB_IDLOW_SSBREV_24:     /* TODO - find the proper REJECT bits */
885
	case SSB_IDLOW_SSBREV_25:     /* same here */
886
	case SSB_IDLOW_SSBREV_26:     /* same here */
887
	case SSB_IDLOW_SSBREV_27:     /* same here */
888
		return SSB_TMSLOW_REJECT_23;	/* this is a guess */
882
	default:
889
	default:
890
		printk(KERN_INFO "ssb: Backplane Revision 0x%.8X\n", rev);
883
		WARN_ON(1);
891
		WARN_ON(1);
884
	}
892
	}
885
	return (SSB_TMSLOW_REJECT_22 | SSB_TMSLOW_REJECT_23);
893
	return (SSB_TMSLOW_REJECT_22 | SSB_TMSLOW_REJECT_23);
(-)linux-2.6/drivers/ssb/pci.c (-114 / +107 lines)
Lines 212-240 static inline u8 ssb_crc8(u8 crc, u8 dat Link Here
212
	return t[crc ^ data];
212
	return t[crc ^ data];
213
}
213
}
214
214
215
static u8 ssb_sprom_crc(const u16 *sprom)
215
static u8 ssb_sprom_crc(const u16 *sprom, u16 size)
216
{
216
{
217
	int word;
217
	int word;
218
	u8 crc = 0xFF;
218
	u8 crc = 0xFF;
219
219
220
	for (word = 0; word < SSB_SPROMSIZE_WORDS - 1; word++) {
220
	for (word = 0; word < size - 1; word++) {
221
		crc = ssb_crc8(crc, sprom[word] & 0x00FF);
221
		crc = ssb_crc8(crc, sprom[word] & 0x00FF);
222
		crc = ssb_crc8(crc, (sprom[word] & 0xFF00) >> 8);
222
		crc = ssb_crc8(crc, (sprom[word] & 0xFF00) >> 8);
223
	}
223
	}
224
	crc = ssb_crc8(crc, sprom[SPOFF(SSB_SPROM_REVISION)] & 0x00FF);
224
	crc = ssb_crc8(crc, sprom[size - 1] & 0x00FF);
225
	crc ^= 0xFF;
225
	crc ^= 0xFF;
226
226
227
	return crc;
227
	return crc;
228
}
228
}
229
229
230
static int sprom_check_crc(const u16 *sprom)
230
static int sprom_check_crc(const u16 *sprom, u16 size)
231
{
231
{
232
	u8 crc;
232
	u8 crc;
233
	u8 expected_crc;
233
	u8 expected_crc;
234
	u16 tmp;
234
	u16 tmp;
235
235
236
	crc = ssb_sprom_crc(sprom);
236
	crc = ssb_sprom_crc(sprom, size);
237
	tmp = sprom[SPOFF(SSB_SPROM_REVISION)] & SSB_SPROM_REVISION_CRC;
237
	tmp = sprom[size - 1] & SSB_SPROM_REVISION_CRC;
238
	expected_crc = tmp >> SSB_SPROM_REVISION_CRC_SHIFT;
238
	expected_crc = tmp >> SSB_SPROM_REVISION_CRC_SHIFT;
239
	if (crc != expected_crc)
239
	if (crc != expected_crc)
240
		return -EPROTO;
240
		return -EPROTO;
Lines 246-252 static void sprom_do_read(struct ssb_bus Link Here
246
{
246
{
247
	int i;
247
	int i;
248
248
249
	for (i = 0; i < SSB_SPROMSIZE_WORDS; i++)
249
	for (i = 0; i < bus->sprom_size; i++)
250
		sprom[i] = readw(bus->mmio + SSB_SPROM_BASE + (i * 2));
250
		sprom[i] = readw(bus->mmio + SSB_SPROM_BASE + (i * 2));
251
}
251
}
252
252
Lines 255-260 static int sprom_do_write(struct ssb_bus Link Here
255
	struct pci_dev *pdev = bus->host_pci;
255
	struct pci_dev *pdev = bus->host_pci;
256
	int i, err;
256
	int i, err;
257
	u32 spromctl;
257
	u32 spromctl;
258
	u16 size = bus->sprom_size;
258
259
259
	ssb_printk(KERN_NOTICE PFX "Writing SPROM. Do NOT turn off the power! Please stand by...\n");
260
	ssb_printk(KERN_NOTICE PFX "Writing SPROM. Do NOT turn off the power! Please stand by...\n");
260
	err = pci_read_config_dword(pdev, SSB_SPROMCTL, &spromctl);
261
	err = pci_read_config_dword(pdev, SSB_SPROMCTL, &spromctl);
Lines 266-277 static int sprom_do_write(struct ssb_bus Link Here
266
		goto err_ctlreg;
267
		goto err_ctlreg;
267
	ssb_printk(KERN_NOTICE PFX "[ 0%%");
268
	ssb_printk(KERN_NOTICE PFX "[ 0%%");
268
	msleep(500);
269
	msleep(500);
269
	for (i = 0; i < SSB_SPROMSIZE_WORDS; i++) {
270
	for (i = 0; i < size; i++) {
270
		if (i == SSB_SPROMSIZE_WORDS / 4)
271
		if (i == size / 4)
271
			ssb_printk("25%%");
272
			ssb_printk("25%%");
272
		else if (i == SSB_SPROMSIZE_WORDS / 2)
273
		else if (i == size / 2)
273
			ssb_printk("50%%");
274
			ssb_printk("50%%");
274
		else if (i == (SSB_SPROMSIZE_WORDS / 4) * 3)
275
		else if (i == (size * 3) / 4)
275
			ssb_printk("75%%");
276
			ssb_printk("75%%");
276
		else if (i % 2)
277
		else if (i % 2)
277
			ssb_printk(".");
278
			ssb_printk(".");
Lines 296-333 err_ctlreg: Link Here
296
	return err;
297
	return err;
297
}
298
}
298
299
299
static void sprom_extract_r1(struct ssb_sprom_r1 *out, const u16 *in)
300
static void sprom_extract_r123(struct ssb_sprom *out, const u16 *in)
300
{
301
{
301
	int i;
302
	int i;
302
	u16 v;
303
	u16 v;
304
	u16 loc[3];
303
305
304
	SPEX(pci_spid, SSB_SPROM1_SPID, 0xFFFF, 0);
306
	if (out->revision == 3) {			/* rev 3 moved MAC */
305
	SPEX(pci_svid, SSB_SPROM1_SVID, 0xFFFF, 0);
307
		loc[0] = SSB_SPROM3_IL0MAC;
306
	SPEX(pci_pid, SSB_SPROM1_PID, 0xFFFF, 0);
308
		loc[1] = SSB_SPROM3_ET0MAC;
309
		loc[2] = SSB_SPROM3_ET1MAC;
310
	} else {
311
		loc[0] = SSB_SPROM1_IL0MAC;
312
		loc[1] = SSB_SPROM1_ET0MAC;
313
		loc[2] = SSB_SPROM1_ET1MAC;
314
	}
307
	for (i = 0; i < 3; i++) {
315
	for (i = 0; i < 3; i++) {
308
		v = in[SPOFF(SSB_SPROM1_IL0MAC) + i];
316
		v = in[SPOFF(loc[0]) + i];
309
		*(((__be16 *)out->il0mac) + i) = cpu_to_be16(v);
317
		*(((__be16 *)out->il0mac) + i) = cpu_to_be16(v);
310
	}
318
	}
311
	for (i = 0; i < 3; i++) {
319
	for (i = 0; i < 3; i++) {
312
		v = in[SPOFF(SSB_SPROM1_ET0MAC) + i];
320
		v = in[SPOFF(loc[1]) + i];
313
		*(((__be16 *)out->et0mac) + i) = cpu_to_be16(v);
321
		*(((__be16 *)out->et0mac) + i) = cpu_to_be16(v);
314
	}
322
	}
315
	for (i = 0; i < 3; i++) {
323
	for (i = 0; i < 3; i++) {
316
		v = in[SPOFF(SSB_SPROM1_ET1MAC) + i];
324
		v = in[SPOFF(loc[2]) + i];
317
		*(((__be16 *)out->et1mac) + i) = cpu_to_be16(v);
325
		*(((__be16 *)out->et1mac) + i) = cpu_to_be16(v);
318
	}
326
	}
319
	SPEX(et0phyaddr, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET0A, 0);
327
	SPEX(et0phyaddr, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET0A, 0);
320
	SPEX(et1phyaddr, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET1A,
328
	SPEX(et1phyaddr, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET1A,
321
	     SSB_SPROM1_ETHPHY_ET1A_SHIFT);
329
	     SSB_SPROM1_ETHPHY_ET1A_SHIFT);
322
	SPEX(et0mdcport, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET0M, 14);
323
	SPEX(et1mdcport, SSB_SPROM1_ETHPHY, SSB_SPROM1_ETHPHY_ET1M, 15);
324
	SPEX(board_rev, SSB_SPROM1_BINF, SSB_SPROM1_BINF_BREV, 0);
325
	SPEX(country_code, SSB_SPROM1_BINF, SSB_SPROM1_BINF_CCODE,
330
	SPEX(country_code, SSB_SPROM1_BINF, SSB_SPROM1_BINF_CCODE,
326
	     SSB_SPROM1_BINF_CCODE_SHIFT);
331
	     SSB_SPROM1_BINF_CCODE_SHIFT);
327
	SPEX(antenna_a, SSB_SPROM1_BINF, SSB_SPROM1_BINF_ANTA,
328
	     SSB_SPROM1_BINF_ANTA_SHIFT);
329
	SPEX(antenna_bg, SSB_SPROM1_BINF, SSB_SPROM1_BINF_ANTBG,
330
	     SSB_SPROM1_BINF_ANTBG_SHIFT);
331
	SPEX(pa0b0, SSB_SPROM1_PA0B0, 0xFFFF, 0);
332
	SPEX(pa0b0, SSB_SPROM1_PA0B0, 0xFFFF, 0);
332
	SPEX(pa0b1, SSB_SPROM1_PA0B1, 0xFFFF, 0);
333
	SPEX(pa0b1, SSB_SPROM1_PA0B1, 0xFFFF, 0);
333
	SPEX(pa0b2, SSB_SPROM1_PA0B2, 0xFFFF, 0);
334
	SPEX(pa0b2, SSB_SPROM1_PA0B2, 0xFFFF, 0);
Lines 350-446 static void sprom_extract_r1(struct ssb_ Link Here
350
	SPEX(antenna_gain_a, SSB_SPROM1_AGAIN, SSB_SPROM1_AGAIN_A, 0);
351
	SPEX(antenna_gain_a, SSB_SPROM1_AGAIN, SSB_SPROM1_AGAIN_A, 0);
351
	SPEX(antenna_gain_bg, SSB_SPROM1_AGAIN, SSB_SPROM1_AGAIN_BG,
352
	SPEX(antenna_gain_bg, SSB_SPROM1_AGAIN, SSB_SPROM1_AGAIN_BG,
352
	     SSB_SPROM1_AGAIN_BG_SHIFT);
353
	     SSB_SPROM1_AGAIN_BG_SHIFT);
353
	for (i = 0; i < 4; i++) {
354
		v = in[SPOFF(SSB_SPROM1_OEM) + i];
355
		*(((__le16 *)out->oem) + i) = cpu_to_le16(v);
356
	}
357
}
354
}
358
355
359
static void sprom_extract_r2(struct ssb_sprom_r2 *out, const u16 *in)
356
static void sprom_extract_r4(struct ssb_sprom *out, const u16 *in)
360
{
357
{
361
	int i;
358
	int i;
362
	u16 v;
359
	u16 v;
363
360
364
	SPEX(boardflags_hi, SSB_SPROM2_BFLHI,  0xFFFF, 0);
361
	/* extract the equivalent of the r1 variables */
365
	SPEX(maxpwr_a_hi, SSB_SPROM2_MAXP_A, SSB_SPROM2_MAXP_A_HI, 0);
362
	for (i = 0; i < 3; i++) {
366
	SPEX(maxpwr_a_lo, SSB_SPROM2_MAXP_A, SSB_SPROM2_MAXP_A_LO,
363
		v = in[SPOFF(SSB_SPROM4_IL0MAC) + i];
367
	     SSB_SPROM2_MAXP_A_LO_SHIFT);
364
		*(((__be16 *)out->il0mac) + i) = cpu_to_be16(v);
368
	SPEX(pa1lob0, SSB_SPROM2_PA1LOB0, 0xFFFF, 0);
369
	SPEX(pa1lob1, SSB_SPROM2_PA1LOB1, 0xFFFF, 0);
370
	SPEX(pa1lob2, SSB_SPROM2_PA1LOB2, 0xFFFF, 0);
371
	SPEX(pa1hib0, SSB_SPROM2_PA1HIB0, 0xFFFF, 0);
372
	SPEX(pa1hib1, SSB_SPROM2_PA1HIB1, 0xFFFF, 0);
373
	SPEX(pa1hib2, SSB_SPROM2_PA1HIB2, 0xFFFF, 0);
374
	SPEX(ofdm_pwr_off, SSB_SPROM2_OPO, SSB_SPROM2_OPO_VALUE, 0);
375
	for (i = 0; i < 4; i++) {
376
		v = in[SPOFF(SSB_SPROM2_CCODE) + i];
377
		*(((__le16 *)out->country_str) + i) = cpu_to_le16(v);
378
	}
365
	}
366
	for (i = 0; i < 3; i++) {
367
		v = in[SPOFF(SSB_SPROM4_ET0MAC) + i];
368
		*(((__be16 *)out->et0mac) + i) = cpu_to_be16(v);
369
	}
370
	for (i = 0; i < 3; i++) {
371
		v = in[SPOFF(SSB_SPROM4_ET1MAC) + i];
372
		*(((__be16 *)out->et1mac) + i) = cpu_to_be16(v);
373
	}
374
	SPEX(et0phyaddr, SSB_SPROM4_ETHPHY, SSB_SPROM4_ETHPHY_ET0A, 0);
375
	SPEX(et1phyaddr, SSB_SPROM4_ETHPHY, SSB_SPROM4_ETHPHY_ET1A,
376
	     SSB_SPROM4_ETHPHY_ET1A_SHIFT);
377
	SPEX(country_code, SSB_SPROM4_CCODE, 0xFFFF, 0);
378
	SPEX(boardflags_lo, SSB_SPROM4_BFLLO, 0xFFFF, 0);
379
	SPEX(antenna_gain_a, SSB_SPROM4_AGAIN, SSB_SPROM4_AGAIN_0, 0);
380
	SPEX(antenna_gain_bg, SSB_SPROM4_AGAIN, SSB_SPROM4_AGAIN_1,
381
	     SSB_SPROM4_AGAIN_1_SHIFT);
382
	SPEX(maxpwr_bg, SSB_SPROM4_MAXP_BG, SSB_SPROM4_MAXP_BG_MASK, 0);
383
	SPEX(itssi_bg, SSB_SPROM4_MAXP_BG, SSB_SPROM4_ITSSI_BG,
384
	     SSB_SPROM4_ITSSI_BG_SHIFT);
385
	SPEX(maxpwr_a, SSB_SPROM4_MAXP_A, SSB_SPROM4_MAXP_A_MASK, 0);
386
	SPEX(itssi_a, SSB_SPROM4_MAXP_A, SSB_SPROM4_ITSSI_A,
387
	     SSB_SPROM4_ITSSI_A_SHIFT);
388
	SPEX(gpio0, SSB_SPROM4_GPIOA, SSB_SPROM4_GPIOA_P0, 0);
389
	SPEX(gpio1, SSB_SPROM4_GPIOA, SSB_SPROM4_GPIOA_P1,
390
	     SSB_SPROM4_GPIOA_P1_SHIFT);
391
	SPEX(gpio2, SSB_SPROM4_GPIOB, SSB_SPROM4_GPIOB_P2, 0);
392
	SPEX(gpio3, SSB_SPROM4_GPIOB, SSB_SPROM4_GPIOB_P3,
393
	     SSB_SPROM4_GPIOB_P3_SHIFT);
394
	/* TODO - get remaining rev 4 stuff needed */
379
}
395
}
380
396
381
static void sprom_extract_r3(struct ssb_sprom_r3 *out, const u16 *in)
397
static int sprom_extract(struct ssb_bus *bus, struct ssb_sprom *out,
382
{
398
			 const u16 *in, u16 size)
383
	out->ofdmapo  = (in[SPOFF(SSB_SPROM3_OFDMAPO) + 0] & 0xFF00) >> 8;
384
	out->ofdmapo |= (in[SPOFF(SSB_SPROM3_OFDMAPO) + 0] & 0x00FF) << 8;
385
	out->ofdmapo <<= 16;
386
	out->ofdmapo |= (in[SPOFF(SSB_SPROM3_OFDMAPO) + 1] & 0xFF00) >> 8;
387
	out->ofdmapo |= (in[SPOFF(SSB_SPROM3_OFDMAPO) + 1] & 0x00FF) << 8;
388
389
	out->ofdmalpo  = (in[SPOFF(SSB_SPROM3_OFDMALPO) + 0] & 0xFF00) >> 8;
390
	out->ofdmalpo |= (in[SPOFF(SSB_SPROM3_OFDMALPO) + 0] & 0x00FF) << 8;
391
	out->ofdmalpo <<= 16;
392
	out->ofdmalpo |= (in[SPOFF(SSB_SPROM3_OFDMALPO) + 1] & 0xFF00) >> 8;
393
	out->ofdmalpo |= (in[SPOFF(SSB_SPROM3_OFDMALPO) + 1] & 0x00FF) << 8;
394
395
	out->ofdmahpo  = (in[SPOFF(SSB_SPROM3_OFDMAHPO) + 0] & 0xFF00) >> 8;
396
	out->ofdmahpo |= (in[SPOFF(SSB_SPROM3_OFDMAHPO) + 0] & 0x00FF) << 8;
397
	out->ofdmahpo <<= 16;
398
	out->ofdmahpo |= (in[SPOFF(SSB_SPROM3_OFDMAHPO) + 1] & 0xFF00) >> 8;
399
	out->ofdmahpo |= (in[SPOFF(SSB_SPROM3_OFDMAHPO) + 1] & 0x00FF) << 8;
400
401
	SPEX(gpioldc_on_cnt, SSB_SPROM3_GPIOLDC, SSB_SPROM3_GPIOLDC_ON,
402
	     SSB_SPROM3_GPIOLDC_ON_SHIFT);
403
	SPEX(gpioldc_off_cnt, SSB_SPROM3_GPIOLDC, SSB_SPROM3_GPIOLDC_OFF,
404
	     SSB_SPROM3_GPIOLDC_OFF_SHIFT);
405
	SPEX(cckpo_1M, SSB_SPROM3_CCKPO, SSB_SPROM3_CCKPO_1M, 0);
406
	SPEX(cckpo_2M, SSB_SPROM3_CCKPO, SSB_SPROM3_CCKPO_2M,
407
	     SSB_SPROM3_CCKPO_2M_SHIFT);
408
	SPEX(cckpo_55M, SSB_SPROM3_CCKPO, SSB_SPROM3_CCKPO_55M,
409
	     SSB_SPROM3_CCKPO_55M_SHIFT);
410
	SPEX(cckpo_11M, SSB_SPROM3_CCKPO, SSB_SPROM3_CCKPO_11M,
411
	     SSB_SPROM3_CCKPO_11M_SHIFT);
412
413
	out->ofdmgpo  = (in[SPOFF(SSB_SPROM3_OFDMGPO) + 0] & 0xFF00) >> 8;
414
	out->ofdmgpo |= (in[SPOFF(SSB_SPROM3_OFDMGPO) + 0] & 0x00FF) << 8;
415
	out->ofdmgpo <<= 16;
416
	out->ofdmgpo |= (in[SPOFF(SSB_SPROM3_OFDMGPO) + 1] & 0xFF00) >> 8;
417
	out->ofdmgpo |= (in[SPOFF(SSB_SPROM3_OFDMGPO) + 1] & 0x00FF) << 8;
418
}
419
420
static int sprom_extract(struct ssb_bus *bus,
421
			 struct ssb_sprom *out, const u16 *in)
422
{
399
{
423
	memset(out, 0, sizeof(*out));
400
	memset(out, 0, sizeof(*out));
424
401
425
	SPEX(revision, SSB_SPROM_REVISION, SSB_SPROM_REVISION_REV, 0);
402
	out->revision = in[size - 1] & 0x00FF;
426
	SPEX(crc, SSB_SPROM_REVISION, SSB_SPROM_REVISION_CRC,
403
	ssb_printk(KERN_INFO PFX "SPROM revision %d detected.\n", out->revision);
427
	     SSB_SPROM_REVISION_CRC_SHIFT);
428
429
	if ((bus->chip_id & 0xFF00) == 0x4400) {
404
	if ((bus->chip_id & 0xFF00) == 0x4400) {
430
		/* Workaround: The BCM44XX chip has a stupid revision
405
		/* Workaround: The BCM44XX chip has a stupid revision
431
		 * number stored in the SPROM.
406
		 * number stored in the SPROM.
432
		 * Always extract r1. */
407
		 * Always extract r1. */
433
		sprom_extract_r1(&out->r1, in);
408
		out->revision = 1;
409
		sprom_extract_r123(out, in);
410
	} else if (bus->chip_id == 0x4321) {
411
		/* the BCM4328 has a chipid == 0x4321 and a rev 4 SPROM */
412
		out->revision = 4;
413
		sprom_extract_r4(out, in);
434
	} else {
414
	} else {
435
		if (out->revision == 0)
415
		if (out->revision == 0)
436
			goto unsupported;
416
			goto unsupported;
437
		if (out->revision >= 1 && out->revision <= 3)
417
		if (out->revision >= 1 && out->revision <= 3) {
438
			sprom_extract_r1(&out->r1, in);
418
			sprom_extract_r123(out, in);
439
		if (out->revision >= 2 && out->revision <= 3)
419
		}
440
			sprom_extract_r2(&out->r2, in);
420
		if (out->revision == 4)
441
		if (out->revision == 3)
421
			sprom_extract_r4(out, in);
442
			sprom_extract_r3(&out->r3, in);
422
		if (out->revision >= 5)
443
		if (out->revision >= 4)
444
			goto unsupported;
423
			goto unsupported;
445
	}
424
	}
446
425
Lines 448-454 static int sprom_extract(struct ssb_bus Link Here
448
unsupported:
427
unsupported:
449
	ssb_printk(KERN_WARNING PFX "Unsupported SPROM revision %d "
428
	ssb_printk(KERN_WARNING PFX "Unsupported SPROM revision %d "
450
		   "detected. Will extract v1\n", out->revision);
429
		   "detected. Will extract v1\n", out->revision);
451
	sprom_extract_r1(&out->r1, in);
430
	sprom_extract_r123(out, in);
452
	return 0;
431
	return 0;
453
}
432
}
454
433
Lines 458-473 static int ssb_pci_sprom_get(struct ssb_ Link Here
458
	int err = -ENOMEM;
437
	int err = -ENOMEM;
459
	u16 *buf;
438
	u16 *buf;
460
439
461
	buf = kcalloc(SSB_SPROMSIZE_WORDS, sizeof(u16), GFP_KERNEL);
440
	buf = kcalloc(SSB_SPROMSIZE_WORDS_R123, sizeof(u16), GFP_KERNEL);
462
	if (!buf)
441
	if (!buf)
463
		goto out;
442
		goto out;
443
	bus->sprom_size = SSB_SPROMSIZE_WORDS_R123;
464
	sprom_do_read(bus, buf);
444
	sprom_do_read(bus, buf);
465
	err = sprom_check_crc(buf);
445
	err = sprom_check_crc(buf, bus->sprom_size);
466
	if (err) {
446
	if (err) {
467
		ssb_printk(KERN_WARNING PFX
447
		/* check for rev 4 sprom - has special signature */
468
			   "WARNING: Invalid SPROM CRC (corrupt SPROM)\n");
448
		if (buf [32] == 0x5372) {
449
			ssb_printk(KERN_WARNING PFX "Extracting a rev 4"
450
				   " SPROM\n");
451
			kfree(buf);
452
			buf = kcalloc(SSB_SPROMSIZE_WORDS_R4, sizeof(u16),
453
				      GFP_KERNEL);
454
			if (!buf)
455
				goto out;
456
			bus->sprom_size = SSB_SPROMSIZE_WORDS_R4;
457
			sprom_do_read(bus, buf);
458
			err = sprom_check_crc(buf, bus->sprom_size);
459
		}
460
		if (err)
461
			ssb_printk(KERN_WARNING PFX "WARNING: Invalid"
462
				   " SPROM CRC (corrupt SPROM)\n");
469
	}
463
	}
470
	err = sprom_extract(bus, sprom, buf);
464
	err = sprom_extract(bus, sprom, buf, bus->sprom_size);
471
465
472
	kfree(buf);
466
	kfree(buf);
473
out:
467
out:
Lines 581-609 const struct ssb_bus_ops ssb_pci_ops = { Link Here
581
	.write32	= ssb_pci_write32,
575
	.write32	= ssb_pci_write32,
582
};
576
};
583
577
584
static int sprom2hex(const u16 *sprom, char *buf, size_t buf_len)
578
static int sprom2hex(const u16 *sprom, char *buf, size_t buf_len, u16 size)
585
{
579
{
586
	int i, pos = 0;
580
	int i, pos = 0;
587
581
588
	for (i = 0; i < SSB_SPROMSIZE_WORDS; i++) {
582
	for (i = 0; i < size; i++)
589
		pos += snprintf(buf + pos, buf_len - pos - 1,
583
		pos += snprintf(buf + pos, buf_len - pos - 1,
590
				"%04X", swab16(sprom[i]) & 0xFFFF);
584
				"%04X", swab16(sprom[i]) & 0xFFFF);
591
	}
592
	pos += snprintf(buf + pos, buf_len - pos - 1, "\n");
585
	pos += snprintf(buf + pos, buf_len - pos - 1, "\n");
593
586
594
	return pos + 1;
587
	return pos + 1;
595
}
588
}
596
589
597
static int hex2sprom(u16 *sprom, const char *dump, size_t len)
590
static int hex2sprom(u16 *sprom, const char *dump, size_t len, u16 size)
598
{
591
{
599
	char tmp[5] = { 0 };
592
	char tmp[5] = { 0 };
600
	int cnt = 0;
593
	int cnt = 0;
601
	unsigned long parsed;
594
	unsigned long parsed;
602
595
603
	if (len < SSB_SPROMSIZE_BYTES * 2)
596
	if (len < size * 2)
604
		return -EINVAL;
597
		return -EINVAL;
605
598
606
	while (cnt < SSB_SPROMSIZE_WORDS) {
599
	while (cnt < size) {
607
		memcpy(tmp, dump, 4);
600
		memcpy(tmp, dump, 4);
608
		dump += 4;
601
		dump += 4;
609
		parsed = simple_strtoul(tmp, NULL, 16);
602
		parsed = simple_strtoul(tmp, NULL, 16);
Lines 627-633 static ssize_t ssb_pci_attr_sprom_show(s Link Here
627
	if (!bus)
620
	if (!bus)
628
		goto out;
621
		goto out;
629
	err = -ENOMEM;
622
	err = -ENOMEM;
630
	sprom = kcalloc(SSB_SPROMSIZE_WORDS, sizeof(u16), GFP_KERNEL);
623
	sprom = kcalloc(bus->sprom_size, sizeof(u16), GFP_KERNEL);
631
	if (!sprom)
624
	if (!sprom)
632
		goto out;
625
		goto out;
633
626
Lines 640-646 static ssize_t ssb_pci_attr_sprom_show(s Link Here
640
	sprom_do_read(bus, sprom);
633
	sprom_do_read(bus, sprom);
641
	mutex_unlock(&bus->pci_sprom_mutex);
634
	mutex_unlock(&bus->pci_sprom_mutex);
642
635
643
	count = sprom2hex(sprom, buf, PAGE_SIZE);
636
	count = sprom2hex(sprom, buf, PAGE_SIZE, bus->sprom_size);
644
	err = 0;
637
	err = 0;
645
638
646
out_kfree:
639
out_kfree:
Lines 662-676 static ssize_t ssb_pci_attr_sprom_store( Link Here
662
	if (!bus)
655
	if (!bus)
663
		goto out;
656
		goto out;
664
	err = -ENOMEM;
657
	err = -ENOMEM;
665
	sprom = kcalloc(SSB_SPROMSIZE_WORDS, sizeof(u16), GFP_KERNEL);
658
	sprom = kcalloc(bus->sprom_size, sizeof(u16), GFP_KERNEL);
666
	if (!sprom)
659
	if (!sprom)
667
		goto out;
660
		goto out;
668
	err = hex2sprom(sprom, buf, count);
661
	err = hex2sprom(sprom, buf, count, bus->sprom_size);
669
	if (err) {
662
	if (err) {
670
		err = -EINVAL;
663
		err = -EINVAL;
671
		goto out_kfree;
664
		goto out_kfree;
672
	}
665
	}
673
	err = sprom_check_crc(sprom);
666
	err = sprom_check_crc(sprom, bus->sprom_size);
674
	if (err) {
667
	if (err) {
675
		err = -EINVAL;
668
		err = -EINVAL;
676
		goto out_kfree;
669
		goto out_kfree;
(-)linux-2.6/include/linux/ssb/ssb.h (-62 / +9 lines)
Lines 15-36 struct pcmcia_device; Link Here
15
struct ssb_bus;
15
struct ssb_bus;
16
struct ssb_driver;
16
struct ssb_driver;
17
17
18
18
struct ssb_sprom {
19
struct ssb_sprom_r1 {
19
	u8 revision;
20
	u16 pci_spid;		/* Subsystem Product ID for PCI */
21
	u16 pci_svid;		/* Subsystem Vendor ID for PCI */
22
	u16 pci_pid;		/* Product ID for PCI */
23
	u8 il0mac[6];		/* MAC address for 802.11b/g */
20
	u8 il0mac[6];		/* MAC address for 802.11b/g */
24
	u8 et0mac[6];		/* MAC address for Ethernet */
21
	u8 et0mac[6];		/* MAC address for Ethernet */
25
	u8 et1mac[6];		/* MAC address for 802.11a */
22
	u8 et1mac[6];		/* MAC address for 802.11a */
26
	u8 et0phyaddr:5;	/* MII address for enet0 */
23
	u8 et0phyaddr;		/* MII address for enet0 */
27
	u8 et1phyaddr:5;	/* MII address for enet1 */
24
	u8 et1phyaddr;		/* MII address for enet1 */
28
	u8 et0mdcport:1;	/* MDIO for enet0 */
25
	u8 country_code;	/* Country Code */
29
	u8 et1mdcport:1;	/* MDIO for enet1 */
30
	u8 board_rev;		/* Board revision */
31
	u8 country_code:4;	/* Country Code */
32
	u8 antenna_a:2;		/* Antenna 0/1 available for A-PHY */
33
	u8 antenna_bg:2;	/* Antenna 0/1 available for B-PHY and G-PHY */
34
	u16 pa0b0;
26
	u16 pa0b0;
35
	u16 pa0b1;
27
	u16 pa0b1;
36
	u16 pa0b2;
28
	u16 pa0b2;
Lines 41-101 struct ssb_sprom_r1 { Link Here
41
	u8 gpio1;		/* GPIO pin 1 */
33
	u8 gpio1;		/* GPIO pin 1 */
42
	u8 gpio2;		/* GPIO pin 2 */
34
	u8 gpio2;		/* GPIO pin 2 */
43
	u8 gpio3;		/* GPIO pin 3 */
35
	u8 gpio3;		/* GPIO pin 3 */
44
	u16 maxpwr_a;		/* A-PHY Power Amplifier Max Power (in dBm Q5.2) */
36
	u16 maxpwr_a;		/* A-PHY Amplifier Max Power (in dBm Q5.2) */
45
	u16 maxpwr_bg;		/* B/G-PHY Power Amplifier Max Power (in dBm Q5.2) */
37
	u16 maxpwr_bg;		/* B/G-PHY Amplifier Max Power (in dBm Q5.2) */
46
	u8 itssi_a;		/* Idle TSSI Target for A-PHY */
38
	u8 itssi_a;		/* Idle TSSI Target for A-PHY */
47
	u8 itssi_bg;		/* Idle TSSI Target for B/G-PHY */
39
	u8 itssi_bg;		/* Idle TSSI Target for B/G-PHY */
48
	u16 boardflags_lo;	/* Boardflags (low 16 bits) */
40
	u16 boardflags_lo;	/* Boardflags (low 16 bits) */
49
	u8 antenna_gain_a;	/* A-PHY Antenna gain (in dBm Q5.2) */
41
	u8 antenna_gain_a;	/* A-PHY Antenna gain (in dBm Q5.2) */
50
	u8 antenna_gain_bg;	/* B/G-PHY Antenna gain (in dBm Q5.2) */
42
	u8 antenna_gain_bg;	/* B/G-PHY Antenna gain (in dBm Q5.2) */
51
	u8 oem[8];		/* OEM string (rev 1 only) */
52
};
53
54
struct ssb_sprom_r2 {
55
	u16 boardflags_hi;	/* Boardflags (high 16 bits) */
56
	u8 maxpwr_a_lo;		/* A-PHY Max Power Low */
57
	u8 maxpwr_a_hi;		/* A-PHY Max Power High */
58
	u16 pa1lob0;		/* A-PHY PA Low Settings */
59
	u16 pa1lob1;		/* A-PHY PA Low Settings */
60
	u16 pa1lob2;		/* A-PHY PA Low Settings */
61
	u16 pa1hib0;		/* A-PHY PA High Settings */
62
	u16 pa1hib1;		/* A-PHY PA High Settings */
63
	u16 pa1hib2;		/* A-PHY PA High Settings */
64
	u8 ofdm_pwr_off;	/* OFDM Power Offset from CCK Level */
65
	u8 country_str[2];	/* Two char Country Code */
66
};
67
43
68
struct ssb_sprom_r3 {
44
	/* TODO - add any parameters needed from rev 2, 3, or 4 SPROMs */
69
	u32 ofdmapo;		/* A-PHY OFDM Mid Power Offset */
70
	u32 ofdmalpo;		/* A-PHY OFDM Low Power Offset */
71
	u32 ofdmahpo;		/* A-PHY OFDM High Power Offset */
72
	u8 gpioldc_on_cnt;	/* GPIO LED Powersave Duty Cycle ON count */
73
	u8 gpioldc_off_cnt;	/* GPIO LED Powersave Duty Cycle OFF count */
74
	u8 cckpo_1M:4;		/* CCK Power Offset for Rate 1M */
75
	u8 cckpo_2M:4;		/* CCK Power Offset for Rate 2M */
76
	u8 cckpo_55M:4;		/* CCK Power Offset for Rate 5.5M */
77
	u8 cckpo_11M:4;		/* CCK Power Offset for Rate 11M */
78
	u32 ofdmgpo;		/* G-PHY OFDM Power Offset */
79
};
80
81
struct ssb_sprom_r4 {
82
	/* TODO */
83
};
84
85
struct ssb_sprom {
86
	u8 revision;
87
	u8 crc;
88
	/* The valid r# fields are selected by the "revision".
89
	 * Revision 3 and lower inherit from lower revisions.
90
	 */
91
	union {
92
		struct {
93
			struct ssb_sprom_r1 r1;
94
			struct ssb_sprom_r2 r2;
95
			struct ssb_sprom_r3 r3;
96
		};
97
		struct ssb_sprom_r4 r4;
98
	};
99
};
45
};
100
46
101
/* Information about the PCB the circuitry is soldered on. */
47
/* Information about the PCB the circuitry is soldered on. */
Lines 288-293 struct ssb_bus { Link Here
288
	/* ID information about the Chip. */
234
	/* ID information about the Chip. */
289
	u16 chip_id;
235
	u16 chip_id;
290
	u16 chip_rev;
236
	u16 chip_rev;
237
	u16 sprom_size;		/* number of words in sprom */
291
	u8 chip_package;
238
	u8 chip_package;
292
239
293
	/* List of devices (cores) on the backplane. */
240
	/* List of devices (cores) on the backplane. */
(-)linux-2.6/include/linux/ssb/ssb_regs.h (-2 / +57 lines)
Lines 147-152 Link Here
147
#define  SSB_IDLOW_SSBREV	0xF0000000 /* Sonics Backplane Revision code */
147
#define  SSB_IDLOW_SSBREV	0xF0000000 /* Sonics Backplane Revision code */
148
#define  SSB_IDLOW_SSBREV_22	0x00000000 /* <= 2.2 */
148
#define  SSB_IDLOW_SSBREV_22	0x00000000 /* <= 2.2 */
149
#define  SSB_IDLOW_SSBREV_23	0x10000000 /* 2.3 */
149
#define  SSB_IDLOW_SSBREV_23	0x10000000 /* 2.3 */
150
#define  SSB_IDLOW_SSBREV_24	0x40000000 /* ?? Found in BCM4328 */
151
#define  SSB_IDLOW_SSBREV_25	0x50000000 /* ?? Not Found yet */
152
#define  SSB_IDLOW_SSBREV_26	0x60000000 /* ?? Found in some BCM4311/2 */
153
#define  SSB_IDLOW_SSBREV_27	0x70000000 /* ?? Found in some BCM4311/2 */
150
#define SSB_IDHIGH		0x0FFC     /* SB Identification High */
154
#define SSB_IDHIGH		0x0FFC     /* SB Identification High */
151
#define  SSB_IDHIGH_RCLO	0x0000000F /* Revision Code (low part) */
155
#define  SSB_IDHIGH_RCLO	0x0000000F /* Revision Code (low part) */
152
#define  SSB_IDHIGH_CC		0x00008FF0 /* Core Code */
156
#define  SSB_IDHIGH_CC		0x00008FF0 /* Core Code */
Lines 162-172 Link Here
162
 */
166
 */
163
#define SSB_SPROMSIZE_WORDS		64
167
#define SSB_SPROMSIZE_WORDS		64
164
#define SSB_SPROMSIZE_BYTES		(SSB_SPROMSIZE_WORDS * sizeof(u16))
168
#define SSB_SPROMSIZE_BYTES		(SSB_SPROMSIZE_WORDS * sizeof(u16))
169
#define SSB_SPROMSIZE_WORDS_R123	64
170
#define SSB_SPROMSIZE_WORDS_R4		220
171
#define SSB_SPROMSIZE_BYTES_R123	(SSB_SPROMSIZE_WORDS_R123 * sizeof(u16))
172
#define SSB_SPROMSIZE_BYTES_R4		(SSB_SPROMSIZE_WORDS_R4 * sizeof(u16))
165
#define SSB_SPROM_BASE			0x1000
173
#define SSB_SPROM_BASE			0x1000
166
#define SSB_SPROM_REVISION		0x107E
174
#define SSB_SPROM_REVISION		0x107E
167
#define  SSB_SPROM_REVISION_REV		0x00FF	/* SPROM Revision number */
175
#define  SSB_SPROM_REVISION_REV		0x00FF	/* SPROM Revision number */
168
#define  SSB_SPROM_REVISION_CRC		0xFF00	/* SPROM CRC8 value */
176
#define  SSB_SPROM_REVISION_CRC		0xFF00	/* SPROM CRC8 value */
169
#define  SSB_SPROM_REVISION_CRC_SHIFT	8
177
#define  SSB_SPROM_REVISION_CRC_SHIFT	8
178
170
/* SPROM Revision 1 */
179
/* SPROM Revision 1 */
171
#define SSB_SPROM1_SPID			0x1004	/* Subsystem Product ID for PCI */
180
#define SSB_SPROM1_SPID			0x1004	/* Subsystem Product ID for PCI */
172
#define SSB_SPROM1_SVID			0x1006	/* Subsystem Vendor ID for PCI */
181
#define SSB_SPROM1_SVID			0x1006	/* Subsystem Vendor ID for PCI */
Lines 215-221 Link Here
215
#define  SSB_SPROM1_AGAIN_A		0x00FF	/* A-PHY */
224
#define  SSB_SPROM1_AGAIN_A		0x00FF	/* A-PHY */
216
#define  SSB_SPROM1_AGAIN_BG		0xFF00	/* B-PHY and G-PHY */
225
#define  SSB_SPROM1_AGAIN_BG		0xFF00	/* B-PHY and G-PHY */
217
#define  SSB_SPROM1_AGAIN_BG_SHIFT	8
226
#define  SSB_SPROM1_AGAIN_BG_SHIFT	8
218
#define SSB_SPROM1_OEM			0x1076	/* 8 bytes OEM string (rev 1 only) */
227
219
/* SPROM Revision 2 (inherits from rev 1) */
228
/* SPROM Revision 2 (inherits from rev 1) */
220
#define SSB_SPROM2_BFLHI		0x1038	/* Boardflags (high 16 bits) */
229
#define SSB_SPROM2_BFLHI		0x1038	/* Boardflags (high 16 bits) */
221
#define SSB_SPROM2_MAXP_A		0x103A	/* A-PHY Max Power */
230
#define SSB_SPROM2_MAXP_A		0x103A	/* A-PHY Max Power */
Lines 232-238 Link Here
232
#define  SSB_SPROM2_OPO_VALUE		0x00FF
241
#define  SSB_SPROM2_OPO_VALUE		0x00FF
233
#define  SSB_SPROM2_OPO_UNUSED		0xFF00
242
#define  SSB_SPROM2_OPO_UNUSED		0xFF00
234
#define SSB_SPROM2_CCODE		0x107C	/* Two char Country Code */
243
#define SSB_SPROM2_CCODE		0x107C	/* Two char Country Code */
235
/* SPROM Revision 3 (inherits from rev 2) */
244
245
/* SPROM Revision 3 (inherits most data from rev 2) */
246
#define SSB_SPROM3_IL0MAC		0x104A	/* 6 bytes MAC address for 802.11b/g */
247
#define SSB_SPROM3_ET0MAC		0x1050	/* 6 bytes MAC address for Ethernet ?? */
248
#define SSB_SPROM3_ET1MAC		0x1050	/* 6 bytes MAC address for 802.11a ?? */
236
#define SSB_SPROM3_OFDMAPO		0x102C	/* A-PHY OFDM Mid Power Offset (4 bytes, BigEndian) */
249
#define SSB_SPROM3_OFDMAPO		0x102C	/* A-PHY OFDM Mid Power Offset (4 bytes, BigEndian) */
237
#define SSB_SPROM3_OFDMALPO		0x1030	/* A-PHY OFDM Low Power Offset (4 bytes, BigEndian) */
250
#define SSB_SPROM3_OFDMALPO		0x1030	/* A-PHY OFDM Low Power Offset (4 bytes, BigEndian) */
238
#define SSB_SPROM3_OFDMAHPO		0x1034	/* A-PHY OFDM High Power Offset (4 bytes, BigEndian) */
251
#define SSB_SPROM3_OFDMAHPO		0x1034	/* A-PHY OFDM High Power Offset (4 bytes, BigEndian) */
Lines 251-256 Link Here
251
#define  SSB_SPROM3_CCKPO_11M_SHIFT	12
264
#define  SSB_SPROM3_CCKPO_11M_SHIFT	12
252
#define  SSB_SPROM3_OFDMGPO		0x107A	/* G-PHY OFDM Power Offset (4 bytes, BigEndian) */
265
#define  SSB_SPROM3_OFDMGPO		0x107A	/* G-PHY OFDM Power Offset (4 bytes, BigEndian) */
253
266
267
/* SPROM Revision 4 		entries with ?? in comment are unknown */
268
#define SSB_SPROM4_IL0MAC		0x104C	/* 6 byte MAC address for a/b/g/n */
269
#define SSB_SPROM4_ET0MAC		0x1018	/* 6 bytes MAC address for Ethernet ?? */
270
#define SSB_SPROM4_ET1MAC		0x1018	/* 6 bytes MAC address for 802.11a ?? */
271
#define SSB_SPROM4_ETHPHY		0x105A	/* Ethernet PHY settings ?? */
272
#define  SSB_SPROM4_ETHPHY_ET0A		0x001F	/* MII Address for enet0 */
273
#define  SSB_SPROM4_ETHPHY_ET1A		0x03E0	/* MII Address for enet1 */
274
#define  SSB_SPROM4_ETHPHY_ET1A_SHIFT	5
275
#define  SSB_SPROM4_ETHPHY_ET0M		(1<<14)	/* MDIO for enet0 */
276
#define  SSB_SPROM4_ETHPHY_ET1M		(1<<15)	/* MDIO for enet1 */
277
#define SSB_SPROM4_CCODE		0x1052	/* Country Code (2 bytes) */
278
#define SSB_SPROM4_ANT_A		0x105D  /* A Antennas */
279
#define SSB_SPROM4_ANT_BG		0x105C  /* B/G Antennas */
280
#define SSB_SPROM4_BFLLO		0x1044	/* Boardflags (low 16 bits) */
281
#define SSB_SPROM4_AGAIN		0x105E	/* Antenna Gain (in dBm Q5.2) */
282
#define  SSB_SPROM4_AGAIN_0		0x00FF	/* Antenna 0 */
283
#define  SSB_SPROM4_AGAIN_1		0xFF00	/* Antenna 1 */
284
#define  SSB_SPROM4_AGAIN_1_SHIFT	8
285
#define SSB_SPROM4_BFLHI		0x1046  /* Board Flags Hi */
286
#define SSB_SPROM4_MAXP_BG		0x1080  /* Max Power BG in path 1 */
287
#define  SSB_SPROM4_MAXP_BG_MASK	0x00FF  /* Mask for Max Power BG */
288
#define  SSB_SPROM4_ITSSI_BG		0xFF00	/* Mask for path 1 itssi_bg */
289
#define  SSB_SPROM4_ITSSI_BG_SHIFT	8
290
#define SSB_SPROM4_MAXP_A		0x108A  /* Max Power A in path 1 */
291
#define  SSB_SPROM4_MAXP_A_MASK		0x00FF  /* Mask for Max Power A */
292
#define  SSB_SPROM4_ITSSI_A		0xFF00	/* Mask for path 1 itssi_a */
293
#define  SSB_SPROM4_ITSSI_A_SHIFT	8
294
#define SSB_SPROM4_GPIOA		0x1056	/* Gen. Purpose IO # 0 and 1 */
295
#define  SSB_SPROM4_GPIOA_P0		0x00FF	/* Pin 0 */
296
#define  SSB_SPROM4_GPIOA_P1		0xFF00	/* Pin 1 */
297
#define  SSB_SPROM4_GPIOA_P1_SHIFT	8
298
#define SSB_SPROM4_GPIOB		0x1058	/* Gen. Purpose IO # 2 and 3 */
299
#define  SSB_SPROM4_GPIOB_P2		0x00FF	/* Pin 2 */
300
#define  SSB_SPROM4_GPIOB_P3		0xFF00	/* Pin 3 */
301
#define  SSB_SPROM4_GPIOB_P3_SHIFT	8
302
#define SSB_SPROM4_PA0B0		0x1082	/* The paXbY locations are */
303
#define SSB_SPROM4_PA0B1		0x1084	/*   only guesses */
304
#define SSB_SPROM4_PA0B2		0x1086
305
#define SSB_SPROM4_PA1B0		0x108E
306
#define SSB_SPROM4_PA1B1		0x1090
307
#define SSB_SPROM4_PA1B2		0x1092
308
254
/* Values for SSB_SPROM1_BINF_CCODE */
309
/* Values for SSB_SPROM1_BINF_CCODE */
255
enum {
310
enum {
256
	SSB_SPROM1CCODE_WORLD = 0,
311
	SSB_SPROM1CCODE_WORLD = 0,
(-)linux-2.6/drivers/net/wireless/b43/b43.h (+4 lines)
Lines 542-547 struct b43_phy { Link Here
542
	u16 lofcal;
542
	u16 lofcal;
543
543
544
	u16 initval;		//FIXME rename?
544
	u16 initval;		//FIXME rename?
545
546
	/* OFDM address read/write caching for hardware auto-increment. */
547
	u16 ofdm_addr;
548
	u8 ofdm_valid; /* 0: invalid, 1: read, 2: write */
545
};
549
};
546
550
547
/* Data structures for DMA transmission, per 80211 core. */
551
/* Data structures for DMA transmission, per 80211 core. */
(-)linux-2.6/drivers/net/wireless/b43/debugfs.c (-1 / +1 lines)
Lines 352-358 static ssize_t b43_debugfs_read(struct f Link Here
352
	struct b43_wldev *dev;
352
	struct b43_wldev *dev;
353
	struct b43_debugfs_fops *dfops;
353
	struct b43_debugfs_fops *dfops;
354
	struct b43_dfs_file *dfile;
354
	struct b43_dfs_file *dfile;
355
	ssize_t ret;
355
	ssize_t uninitialized_var(ret);
356
	char *buf;
356
	char *buf;
357
	const size_t bufsize = 1024 * 128;
357
	const size_t bufsize = 1024 * 128;
358
	const size_t buforder = get_order(bufsize);
358
	const size_t buforder = get_order(bufsize);
(-)linux-2.6/drivers/net/wireless/b43/dma.c (-8 / +22 lines)
Lines 165-171 static void op64_fill_descriptor(struct Link Here
165
	addrhi = (((u64) dmaaddr >> 32) & ~SSB_DMA_TRANSLATION_MASK);
165
	addrhi = (((u64) dmaaddr >> 32) & ~SSB_DMA_TRANSLATION_MASK);
166
	addrext = (((u64) dmaaddr >> 32) & SSB_DMA_TRANSLATION_MASK)
166
	addrext = (((u64) dmaaddr >> 32) & SSB_DMA_TRANSLATION_MASK)
167
	    >> SSB_DMA_TRANSLATION_SHIFT;
167
	    >> SSB_DMA_TRANSLATION_SHIFT;
168
	addrhi |= ssb_dma_translation(ring->dev->dev);
168
	addrhi |= (ssb_dma_translation(ring->dev->dev) << 1);
169
	if (slot == ring->nr_slots - 1)
169
	if (slot == ring->nr_slots - 1)
170
		ctl0 |= B43_DMA64_DCTL0_DTABLEEND;
170
		ctl0 |= B43_DMA64_DCTL0_DTABLEEND;
171
	if (start)
171
	if (start)
Lines 426-434 static inline Link Here
426
static int alloc_ringmemory(struct b43_dmaring *ring)
426
static int alloc_ringmemory(struct b43_dmaring *ring)
427
{
427
{
428
	struct device *dev = ring->dev->dev->dev;
428
	struct device *dev = ring->dev->dev->dev;
429
	gfp_t flags = GFP_KERNEL;
429
430
431
	/* The specs call for 4K buffers for 30- and 32-bit DMA with 4K
432
	 * alignment and 8K buffers for 64-bit DMA with 8K alignment. Testing
433
	 * has shown that 4K is sufficient for the latter as long as the buffer
434
	 * does not cross an 8K boundary.
435
	 *
436
	 * For unknown reasons - possibly a hardware error - the BCM4311 rev
437
	 * 02, which uses 64-bit DMA, needs the ring buffer in very low memory,
438
	 * which accounts for the GFP_DMA flag below.
439
	 */
440
	if (ring->dma64)
441
		flags |= GFP_DMA;
430
	ring->descbase = dma_alloc_coherent(dev, B43_DMA_RINGMEMSIZE,
442
	ring->descbase = dma_alloc_coherent(dev, B43_DMA_RINGMEMSIZE,
431
					    &(ring->dmabase), GFP_KERNEL);
443
					    &(ring->dmabase), flags);
432
	if (!ring->descbase) {
444
	if (!ring->descbase) {
433
		b43err(ring->dev->wl, "DMA ringmemory allocation failed\n");
445
		b43err(ring->dev->wl, "DMA ringmemory allocation failed\n");
434
		return -ENOMEM;
446
		return -ENOMEM;
Lines 483-489 int b43_dmacontroller_rx_reset(struct b4 Link Here
483
	return 0;
495
	return 0;
484
}
496
}
485
497
486
/* Reset the RX DMA channel */
498
/* Reset the TX DMA channel */
487
int b43_dmacontroller_tx_reset(struct b43_wldev *dev, u16 mmio_base, int dma64)
499
int b43_dmacontroller_tx_reset(struct b43_wldev *dev, u16 mmio_base, int dma64)
488
{
500
{
489
	int i;
501
	int i;
Lines 647-653 static int dmacontroller_setup(struct b4 Link Here
647
			b43_dma_write(ring, B43_DMA64_TXRINGHI,
659
			b43_dma_write(ring, B43_DMA64_TXRINGHI,
648
				      ((ringbase >> 32) &
660
				      ((ringbase >> 32) &
649
				       ~SSB_DMA_TRANSLATION_MASK)
661
				       ~SSB_DMA_TRANSLATION_MASK)
650
				      | trans);
662
				      | (trans << 1));
651
		} else {
663
		} else {
652
			u32 ringbase = (u32) (ring->dmabase);
664
			u32 ringbase = (u32) (ring->dmabase);
653
665
Lines 680-687 static int dmacontroller_setup(struct b4 Link Here
680
			b43_dma_write(ring, B43_DMA64_RXRINGHI,
692
			b43_dma_write(ring, B43_DMA64_RXRINGHI,
681
				      ((ringbase >> 32) &
693
				      ((ringbase >> 32) &
682
				       ~SSB_DMA_TRANSLATION_MASK)
694
				       ~SSB_DMA_TRANSLATION_MASK)
683
				      | trans);
695
				      | (trans << 1));
684
			b43_dma_write(ring, B43_DMA64_RXINDEX, 200);
696
			b43_dma_write(ring, B43_DMA64_RXINDEX, ring->nr_slots *
697
				      sizeof(struct b43_dmadesc64));
685
		} else {
698
		} else {
686
			u32 ringbase = (u32) (ring->dmabase);
699
			u32 ringbase = (u32) (ring->dmabase);
687
700
Lines 695-705 static int dmacontroller_setup(struct b4 Link Here
695
			b43_dma_write(ring, B43_DMA32_RXRING,
708
			b43_dma_write(ring, B43_DMA32_RXRING,
696
				      (ringbase & ~SSB_DMA_TRANSLATION_MASK)
709
				      (ringbase & ~SSB_DMA_TRANSLATION_MASK)
697
				      | trans);
710
				      | trans);
698
			b43_dma_write(ring, B43_DMA32_RXINDEX, 200);
711
			b43_dma_write(ring, B43_DMA32_RXINDEX, ring->nr_slots *
712
				      sizeof(struct b43_dmadesc32));
699
		}
713
		}
700
	}
714
	}
701
715
702
      out:
716
out:
703
	return err;
717
	return err;
704
}
718
}
705
719
(-)linux-2.6/drivers/net/wireless/b43/leds.c (-5 / +5 lines)
Lines 4-10 Link Here
4
  LED control
4
  LED control
5
5
6
  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
6
  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
7
  Copyright (c) 2005 Stefano Brivio <st3@riseup.net>
7
  Copyright (c) 2005 Stefano Brivio <stefano.brivio@polimi.it>
8
  Copyright (c) 2005-2007 Michael Buesch <mb@bu3sch.de>
8
  Copyright (c) 2005-2007 Michael Buesch <mb@bu3sch.de>
9
  Copyright (c) 2005 Danny van Dyk <kugelfang@gentoo.org>
9
  Copyright (c) 2005 Danny van Dyk <kugelfang@gentoo.org>
10
  Copyright (c) 2005 Andreas Jaggi <andreas.jaggi@waterwave.ch>
10
  Copyright (c) 2005 Andreas Jaggi <andreas.jaggi@waterwave.ch>
Lines 187-196 void b43_leds_init(struct b43_wldev *dev Link Here
187
	enum b43_led_behaviour behaviour;
187
	enum b43_led_behaviour behaviour;
188
	bool activelow;
188
	bool activelow;
189
189
190
	sprom[0] = bus->sprom.r1.gpio0;
190
	sprom[0] = bus->sprom.gpio0;
191
	sprom[1] = bus->sprom.r1.gpio1;
191
	sprom[1] = bus->sprom.gpio1;
192
	sprom[2] = bus->sprom.r1.gpio2;
192
	sprom[2] = bus->sprom.gpio2;
193
	sprom[3] = bus->sprom.r1.gpio3;
193
	sprom[3] = bus->sprom.gpio3;
194
194
195
	for (i = 0; i < 4; i++) {
195
	for (i = 0; i < 4; i++) {
196
		if (sprom[i] == 0xFF) {
196
		if (sprom[i] == 0xFF) {
(-)linux-2.6/drivers/net/wireless/b43/lo.c (-4 / +4 lines)
Lines 5-11 Link Here
5
  G PHY LO (LocalOscillator) Measuring and Control routines
5
  G PHY LO (LocalOscillator) Measuring and Control routines
6
6
7
  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
7
  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
8
  Copyright (c) 2005, 2006 Stefano Brivio <st3@riseup.net>
8
  Copyright (c) 2005, 2006 Stefano Brivio <stefano.brivio@polimi.it>
9
  Copyright (c) 2005-2007 Michael Buesch <mb@bu3sch.de>
9
  Copyright (c) 2005-2007 Michael Buesch <mb@bu3sch.de>
10
  Copyright (c) 2005, 2006 Danny van Dyk <kugelfang@gentoo.org>
10
  Copyright (c) 2005, 2006 Danny van Dyk <kugelfang@gentoo.org>
11
  Copyright (c) 2005, 2006 Andreas Jaggi <andreas.jaggi@waterwave.ch>
11
  Copyright (c) 2005, 2006 Andreas Jaggi <andreas.jaggi@waterwave.ch>
Lines 264-271 static u16 lo_measure_feedthrough(struct Link Here
264
		rfover |= pga;
264
		rfover |= pga;
265
		rfover |= lna;
265
		rfover |= lna;
266
		rfover |= trsw_rx;
266
		rfover |= trsw_rx;
267
		if ((dev->dev->bus->sprom.r1.boardflags_lo & B43_BFL_EXTLNA) &&
267
		if ((dev->dev->bus->sprom.boardflags_lo & B43_BFL_EXTLNA)
268
		    phy->rev > 6)
268
		    && phy->rev > 6)
269
			rfover |= B43_PHY_RFOVERVAL_EXTLNA;
269
			rfover |= B43_PHY_RFOVERVAL_EXTLNA;
270
270
271
		b43_phy_write(dev, B43_PHY_PGACTL, 0xE300);
271
		b43_phy_write(dev, B43_PHY_PGACTL, 0xE300);
Lines 634-640 static void lo_measure_setup(struct b43_ Link Here
634
			      & 0xFFFC);
634
			      & 0xFFFC);
635
		if (phy->type == B43_PHYTYPE_G) {
635
		if (phy->type == B43_PHYTYPE_G) {
636
			if ((phy->rev >= 7) &&
636
			if ((phy->rev >= 7) &&
637
			    (sprom->r1.boardflags_lo & B43_BFL_EXTLNA)) {
637
			    (sprom->boardflags_lo & B43_BFL_EXTLNA)) {
638
				b43_phy_write(dev, B43_PHY_RFOVER, 0x933);
638
				b43_phy_write(dev, B43_PHY_RFOVER, 0x933);
639
			} else {
639
			} else {
640
				b43_phy_write(dev, B43_PHY_RFOVER, 0x133);
640
				b43_phy_write(dev, B43_PHY_RFOVER, 0x133);
(-)linux-2.6/drivers/net/wireless/b43/main.c (-86 / +111 lines)
Lines 3-9 Link Here
3
  Broadcom B43 wireless driver
3
  Broadcom B43 wireless driver
4
4
5
  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>
5
  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>
6
  Copyright (c) 2005 Stefano Brivio <st3@riseup.net>
6
  Copyright (c) 2005 Stefano Brivio <stefano.brivio@polimi.it>
7
  Copyright (c) 2005, 2006 Michael Buesch <mb@bu3sch.de>
7
  Copyright (c) 2005, 2006 Michael Buesch <mb@bu3sch.de>
8
  Copyright (c) 2005 Danny van Dyk <kugelfang@gentoo.org>
8
  Copyright (c) 2005 Danny van Dyk <kugelfang@gentoo.org>
9
  Copyright (c) 2005 Andreas Jaggi <andreas.jaggi@waterwave.ch>
9
  Copyright (c) 2005 Andreas Jaggi <andreas.jaggi@waterwave.ch>
Lines 75-88 module_param_named(bad_frames_preempt, m Link Here
75
MODULE_PARM_DESC(bad_frames_preempt,
75
MODULE_PARM_DESC(bad_frames_preempt,
76
		 "enable(1) / disable(0) Bad Frames Preemption");
76
		 "enable(1) / disable(0) Bad Frames Preemption");
77
77
78
static int modparam_short_retry = B43_DEFAULT_SHORT_RETRY_LIMIT;
79
module_param_named(short_retry, modparam_short_retry, int, 0444);
80
MODULE_PARM_DESC(short_retry, "Short-Retry-Limit (0 - 15)");
81
82
static int modparam_long_retry = B43_DEFAULT_LONG_RETRY_LIMIT;
83
module_param_named(long_retry, modparam_long_retry, int, 0444);
84
MODULE_PARM_DESC(long_retry, "Long-Retry-Limit (0 - 15)");
85
86
static char modparam_fwpostfix[16];
78
static char modparam_fwpostfix[16];
87
module_param_string(fwpostfix, modparam_fwpostfix, 16, 0444);
79
module_param_string(fwpostfix, modparam_fwpostfix, 16, 0444);
88
MODULE_PARM_DESC(fwpostfix, "Postfix for the .fw files to load.");
80
MODULE_PARM_DESC(fwpostfix, "Postfix for the .fw files to load.");
Lines 101-106 static const struct ssb_device_id b43_ss Link Here
101
	SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_80211, 7),
93
	SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_80211, 7),
102
	SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_80211, 9),
94
	SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_80211, 9),
103
	SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_80211, 10),
95
	SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_80211, 10),
96
	SSB_DEVICE(SSB_VENDOR_BROADCOM, SSB_DEV_80211, 13),
104
	SSB_DEVTABLE_END
97
	SSB_DEVTABLE_END
105
};
98
};
106
99
Lines 1932-1938 static int b43_gpio_init(struct b43_wlde Link Here
1932
		mask |= 0x0180;
1925
		mask |= 0x0180;
1933
		set |= 0x0180;
1926
		set |= 0x0180;
1934
	}
1927
	}
1935
	if (dev->dev->bus->sprom.r1.boardflags_lo & B43_BFL_PACTRL) {
1928
	if (dev->dev->bus->sprom.boardflags_lo & B43_BFL_PACTRL) {
1936
		b43_write16(dev, B43_MMIO_GPIO_MASK,
1929
		b43_write16(dev, B43_MMIO_GPIO_MASK,
1937
			    b43_read16(dev, B43_MMIO_GPIO_MASK)
1930
			    b43_read16(dev, B43_MMIO_GPIO_MASK)
1938
			    | 0x0200);
1931
			    | 0x0200);
Lines 2264-2269 static int b43_chip_init(struct b43_wlde Link Here
2264
	b43_write16(dev, B43_MMIO_POWERUP_DELAY,
2257
	b43_write16(dev, B43_MMIO_POWERUP_DELAY,
2265
		    dev->dev->bus->chipco.fast_pwrup_delay);
2258
		    dev->dev->bus->chipco.fast_pwrup_delay);
2266
2259
2260
	/* OFDM address caching. */
2261
	phy->ofdm_valid = 0;
2262
2267
	err = 0;
2263
	err = 0;
2268
	b43dbg(dev->wl, "Chip initialized\n");
2264
	b43dbg(dev->wl, "Chip initialized\n");
2269
out:
2265
out:
Lines 2297-2303 static void b43_periodic_every60sec(stru Link Here
2297
2293
2298
	if (!b43_has_hardware_pctl(phy))
2294
	if (!b43_has_hardware_pctl(phy))
2299
		b43_lo_g_ctl_mark_all_unused(dev);
2295
		b43_lo_g_ctl_mark_all_unused(dev);
2300
	if (dev->dev->bus->sprom.r1.boardflags_lo & B43_BFL_RSSI) {
2296
	if (dev->dev->bus->sprom.boardflags_lo & B43_BFL_RSSI) {
2301
		b43_mac_suspend(dev);
2297
		b43_mac_suspend(dev);
2302
		b43_calc_nrssi_slope(dev);
2298
		b43_calc_nrssi_slope(dev);
2303
		if ((phy->radio_ver == 0x2050) && (phy->radio_rev == 8)) {
2299
		if ((phy->radio_ver == 0x2050) && (phy->radio_rev == 8)) {
Lines 2494-2501 static int b43_rng_init(struct b43_wl *w Link Here
2494
	return err;
2490
	return err;
2495
}
2491
}
2496
2492
2497
static int b43_tx(struct ieee80211_hw *hw,
2493
static int b43_op_tx(struct ieee80211_hw *hw,
2498
		  struct sk_buff *skb, struct ieee80211_tx_control *ctl)
2494
		     struct sk_buff *skb,
2495
		     struct ieee80211_tx_control *ctl)
2499
{
2496
{
2500
	struct b43_wl *wl = hw_to_b43_wl(hw);
2497
	struct b43_wl *wl = hw_to_b43_wl(hw);
2501
	struct b43_wldev *dev = wl->current_dev;
2498
	struct b43_wldev *dev = wl->current_dev;
Lines 2513-2533 static int b43_tx(struct ieee80211_hw *h Link Here
2513
		spin_unlock_irqrestore(&wl->irq_lock, flags);
2510
		spin_unlock_irqrestore(&wl->irq_lock, flags);
2514
	} else
2511
	} else
2515
		err = b43_dma_tx(dev, skb, ctl);
2512
		err = b43_dma_tx(dev, skb, ctl);
2516
      out:
2513
out:
2517
	if (unlikely(err))
2514
	if (unlikely(err))
2518
		return NETDEV_TX_BUSY;
2515
		return NETDEV_TX_BUSY;
2519
	return NETDEV_TX_OK;
2516
	return NETDEV_TX_OK;
2520
}
2517
}
2521
2518
2522
static int b43_conf_tx(struct ieee80211_hw *hw,
2519
static int b43_op_conf_tx(struct ieee80211_hw *hw,
2523
		       int queue,
2520
			  int queue,
2524
		       const struct ieee80211_tx_queue_params *params)
2521
			  const struct ieee80211_tx_queue_params *params)
2525
{
2522
{
2526
	return 0;
2523
	return 0;
2527
}
2524
}
2528
2525
2529
static int b43_get_tx_stats(struct ieee80211_hw *hw,
2526
static int b43_op_get_tx_stats(struct ieee80211_hw *hw,
2530
			    struct ieee80211_tx_queue_stats *stats)
2527
			       struct ieee80211_tx_queue_stats *stats)
2531
{
2528
{
2532
	struct b43_wl *wl = hw_to_b43_wl(hw);
2529
	struct b43_wl *wl = hw_to_b43_wl(hw);
2533
	struct b43_wldev *dev = wl->current_dev;
2530
	struct b43_wldev *dev = wl->current_dev;
Lines 2545-2556 static int b43_get_tx_stats(struct ieee8 Link Here
2545
		err = 0;
2542
		err = 0;
2546
	}
2543
	}
2547
	spin_unlock_irqrestore(&wl->irq_lock, flags);
2544
	spin_unlock_irqrestore(&wl->irq_lock, flags);
2548
      out:
2545
out:
2549
	return err;
2546
	return err;
2550
}
2547
}
2551
2548
2552
static int b43_get_stats(struct ieee80211_hw *hw,
2549
static int b43_op_get_stats(struct ieee80211_hw *hw,
2553
			 struct ieee80211_low_level_stats *stats)
2550
			    struct ieee80211_low_level_stats *stats)
2554
{
2551
{
2555
	struct b43_wl *wl = hw_to_b43_wl(hw);
2552
	struct b43_wl *wl = hw_to_b43_wl(hw);
2556
	unsigned long flags;
2553
	unsigned long flags;
Lines 2703-2709 static int b43_antenna_from_ieee80211(u8 Link Here
2703
	}
2700
	}
2704
}
2701
}
2705
2702
2706
static int b43_dev_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
2703
static int b43_op_config(struct ieee80211_hw *hw, struct ieee80211_conf *conf)
2707
{
2704
{
2708
	struct b43_wl *wl = hw_to_b43_wl(hw);
2705
	struct b43_wl *wl = hw_to_b43_wl(hw);
2709
	struct b43_wldev *dev;
2706
	struct b43_wldev *dev;
Lines 2808-2830 static int b43_dev_config(struct ieee802 Link Here
2808
	return err;
2805
	return err;
2809
}
2806
}
2810
2807
2811
static int b43_dev_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
2808
static int b43_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd,
2812
			   const u8 *local_addr, const u8 *addr,
2809
			   const u8 *local_addr, const u8 *addr,
2813
			   struct ieee80211_key_conf *key)
2810
			   struct ieee80211_key_conf *key)
2814
{
2811
{
2815
	struct b43_wl *wl = hw_to_b43_wl(hw);
2812
	struct b43_wl *wl = hw_to_b43_wl(hw);
2816
	struct b43_wldev *dev = wl->current_dev;
2813
	struct b43_wldev *dev;
2817
	unsigned long flags;
2814
	unsigned long flags;
2818
	u8 algorithm;
2815
	u8 algorithm;
2819
	u8 index;
2816
	u8 index;
2820
	int err = -EINVAL;
2817
	int err;
2821
	DECLARE_MAC_BUF(mac);
2818
	DECLARE_MAC_BUF(mac);
2822
2819
2823
	if (modparam_nohwcrypt)
2820
	if (modparam_nohwcrypt)
2824
		return -ENOSPC; /* User disabled HW-crypto */
2821
		return -ENOSPC; /* User disabled HW-crypto */
2825
2822
2826
	if (!dev)
2823
	mutex_lock(&wl->mutex);
2827
		return -ENODEV;
2824
	spin_lock_irqsave(&wl->irq_lock, flags);
2825
2826
	dev = wl->current_dev;
2827
	err = -ENODEV;
2828
	if (!dev || b43_status(dev) < B43_STAT_INITIALIZED)
2829
		goto out_unlock;
2830
2831
	err = -EINVAL;
2828
	switch (key->alg) {
2832
	switch (key->alg) {
2829
	case ALG_WEP:
2833
	case ALG_WEP:
2830
		if (key->keylen == 5)
2834
		if (key->keylen == 5)
Lines 2840-2859 static int b43_dev_set_key(struct ieee80 Link Here
2840
		break;
2844
		break;
2841
	default:
2845
	default:
2842
		B43_WARN_ON(1);
2846
		B43_WARN_ON(1);
2843
		goto out;
2847
		goto out_unlock;
2844
	}
2848
	}
2845
2846
	index = (u8) (key->keyidx);
2849
	index = (u8) (key->keyidx);
2847
	if (index > 3)
2850
	if (index > 3)
2848
		goto out;
2849
2850
	mutex_lock(&wl->mutex);
2851
	spin_lock_irqsave(&wl->irq_lock, flags);
2852
2853
	if (b43_status(dev) < B43_STAT_INITIALIZED) {
2854
		err = -ENODEV;
2855
		goto out_unlock;
2851
		goto out_unlock;
2856
	}
2857
2852
2858
	switch (cmd) {
2853
	switch (cmd) {
2859
	case SET_KEY:
2854
	case SET_KEY:
Lines 2899-2905 static int b43_dev_set_key(struct ieee80 Link Here
2899
out_unlock:
2894
out_unlock:
2900
	spin_unlock_irqrestore(&wl->irq_lock, flags);
2895
	spin_unlock_irqrestore(&wl->irq_lock, flags);
2901
	mutex_unlock(&wl->mutex);
2896
	mutex_unlock(&wl->mutex);
2902
out:
2903
	if (!err) {
2897
	if (!err) {
2904
		b43dbg(wl, "%s hardware based encryption for keyidx: %d, "
2898
		b43dbg(wl, "%s hardware based encryption for keyidx: %d, "
2905
		       "mac: %s\n",
2899
		       "mac: %s\n",
Lines 2909-2917 out: Link Here
2909
	return err;
2903
	return err;
2910
}
2904
}
2911
2905
2912
static void b43_configure_filter(struct ieee80211_hw *hw,
2906
static void b43_op_configure_filter(struct ieee80211_hw *hw,
2913
				 unsigned int changed, unsigned int *fflags,
2907
				    unsigned int changed, unsigned int *fflags,
2914
				 int mc_count, struct dev_addr_list *mc_list)
2908
				    int mc_count, struct dev_addr_list *mc_list)
2915
{
2909
{
2916
	struct b43_wl *wl = hw_to_b43_wl(hw);
2910
	struct b43_wl *wl = hw_to_b43_wl(hw);
2917
	struct b43_wldev *dev = wl->current_dev;
2911
	struct b43_wldev *dev = wl->current_dev;
Lines 2946-2953 static void b43_configure_filter(struct Link Here
2946
	spin_unlock_irqrestore(&wl->irq_lock, flags);
2940
	spin_unlock_irqrestore(&wl->irq_lock, flags);
2947
}
2941
}
2948
2942
2949
static int b43_config_interface(struct ieee80211_hw *hw,
2943
static int b43_op_config_interface(struct ieee80211_hw *hw,
2950
				int if_id, struct ieee80211_if_conf *conf)
2944
				   int if_id,
2945
				   struct ieee80211_if_conf *conf)
2951
{
2946
{
2952
	struct b43_wl *wl = hw_to_b43_wl(hw);
2947
	struct b43_wl *wl = hw_to_b43_wl(hw);
2953
	struct b43_wldev *dev = wl->current_dev;
2948
	struct b43_wldev *dev = wl->current_dev;
Lines 3070-3076 static int b43_phy_versioning(struct b43 Link Here
3070
			unsupported = 1;
3065
			unsupported = 1;
3071
		break;
3066
		break;
3072
	case B43_PHYTYPE_G:
3067
	case B43_PHYTYPE_G:
3073
		if (phy_rev > 8)
3068
		if (phy_rev > 9)
3074
			unsupported = 1;
3069
			unsupported = 1;
3075
		break;
3070
		break;
3076
	default:
3071
	default:
Lines 3217-3229 static void b43_bluetooth_coext_enable(s Link Here
3217
	struct ssb_sprom *sprom = &dev->dev->bus->sprom;
3212
	struct ssb_sprom *sprom = &dev->dev->bus->sprom;
3218
	u32 hf;
3213
	u32 hf;
3219
3214
3220
	if (!(sprom->r1.boardflags_lo & B43_BFL_BTCOEXIST))
3215
	if (!(sprom->boardflags_lo & B43_BFL_BTCOEXIST))
3221
		return;
3216
		return;
3222
	if (dev->phy.type != B43_PHYTYPE_B && !dev->phy.gmode)
3217
	if (dev->phy.type != B43_PHYTYPE_B && !dev->phy.gmode)
3223
		return;
3218
		return;
3224
3219
3225
	hf = b43_hf_read(dev);
3220
	hf = b43_hf_read(dev);
3226
	if (sprom->r1.boardflags_lo & B43_BFL_BTCMOD)
3221
	if (sprom->boardflags_lo & B43_BFL_BTCMOD)
3227
		hf |= B43_HF_BTCOEXALT;
3222
		hf |= B43_HF_BTCOEXALT;
3228
	else
3223
	else
3229
		hf |= B43_HF_BTCOEX;
3224
		hf |= B43_HF_BTCOEX;
Lines 3262-3267 static void b43_imcfglo_timeouts_workaro Link Here
3262
#endif /* CONFIG_SSB_DRIVER_PCICORE */
3257
#endif /* CONFIG_SSB_DRIVER_PCICORE */
3263
}
3258
}
3264
3259
3260
/* Write the short and long frame retry limit values. */
3261
static void b43_set_retry_limits(struct b43_wldev *dev,
3262
				 unsigned int short_retry,
3263
				 unsigned int long_retry)
3264
{
3265
	/* The retry limit is a 4-bit counter. Enforce this to avoid overflowing
3266
	 * the chip-internal counter. */
3267
	short_retry = min(short_retry, (unsigned int)0xF);
3268
	long_retry = min(long_retry, (unsigned int)0xF);
3269
3270
	b43_shm_write16(dev, B43_SHM_SCRATCH, B43_SHM_SC_SRLIMIT,
3271
			short_retry);
3272
	b43_shm_write16(dev, B43_SHM_SCRATCH, B43_SHM_SC_LRLIMIT,
3273
			long_retry);
3274
}
3275
3265
/* Shutdown a wireless core */
3276
/* Shutdown a wireless core */
3266
/* Locking: wl->mutex */
3277
/* Locking: wl->mutex */
3267
static void b43_wireless_core_exit(struct b43_wldev *dev)
3278
static void b43_wireless_core_exit(struct b43_wldev *dev)
Lines 3341-3347 static int b43_wireless_core_init(struct Link Here
3341
		hf |= B43_HF_SYMW;
3352
		hf |= B43_HF_SYMW;
3342
		if (phy->rev == 1)
3353
		if (phy->rev == 1)
3343
			hf |= B43_HF_GDCW;
3354
			hf |= B43_HF_GDCW;
3344
		if (sprom->r1.boardflags_lo & B43_BFL_PACTRL)
3355
		if (sprom->boardflags_lo & B43_BFL_PACTRL)
3345
			hf |= B43_HF_OFDMPABOOST;
3356
			hf |= B43_HF_OFDMPABOOST;
3346
	} else if (phy->type == B43_PHYTYPE_B) {
3357
	} else if (phy->type == B43_PHYTYPE_B) {
3347
		hf |= B43_HF_SYMW;
3358
		hf |= B43_HF_SYMW;
Lines 3350-3364 static int b43_wireless_core_init(struct Link Here
3350
	}
3361
	}
3351
	b43_hf_write(dev, hf);
3362
	b43_hf_write(dev, hf);
3352
3363
3353
	/* Short/Long Retry Limit.
3364
	b43_set_retry_limits(dev, B43_DEFAULT_SHORT_RETRY_LIMIT,
3354
	 * The retry-limit is a 4-bit counter. Enforce this to avoid overflowing
3365
			     B43_DEFAULT_LONG_RETRY_LIMIT);
3355
	 * the chip-internal counter.
3356
	 */
3357
	tmp = limit_value(modparam_short_retry, 0, 0xF);
3358
	b43_shm_write16(dev, B43_SHM_SCRATCH, B43_SHM_SC_SRLIMIT, tmp);
3359
	tmp = limit_value(modparam_long_retry, 0, 0xF);
3360
	b43_shm_write16(dev, B43_SHM_SCRATCH, B43_SHM_SC_LRLIMIT, tmp);
3361
3362
	b43_shm_write16(dev, B43_SHM_SHARED, B43_SHM_SH_SFFBLIM, 3);
3366
	b43_shm_write16(dev, B43_SHM_SHARED, B43_SHM_SH_SFFBLIM, 3);
3363
	b43_shm_write16(dev, B43_SHM_SHARED, B43_SHM_SH_LFFBLIM, 2);
3367
	b43_shm_write16(dev, B43_SHM_SHARED, B43_SHM_SH_LFFBLIM, 2);
3364
3368
Lines 3427-3434 static int b43_wireless_core_init(struct Link Here
3427
	return err;
3431
	return err;
3428
}
3432
}
3429
3433
3430
static int b43_add_interface(struct ieee80211_hw *hw,
3434
static int b43_op_add_interface(struct ieee80211_hw *hw,
3431
			     struct ieee80211_if_init_conf *conf)
3435
				struct ieee80211_if_init_conf *conf)
3432
{
3436
{
3433
	struct b43_wl *wl = hw_to_b43_wl(hw);
3437
	struct b43_wl *wl = hw_to_b43_wl(hw);
3434
	struct b43_wldev *dev;
3438
	struct b43_wldev *dev;
Lines 3467-3474 static int b43_add_interface(struct ieee Link Here
3467
	return err;
3471
	return err;
3468
}
3472
}
3469
3473
3470
static void b43_remove_interface(struct ieee80211_hw *hw,
3474
static void b43_op_remove_interface(struct ieee80211_hw *hw,
3471
				 struct ieee80211_if_init_conf *conf)
3475
				    struct ieee80211_if_init_conf *conf)
3472
{
3476
{
3473
	struct b43_wl *wl = hw_to_b43_wl(hw);
3477
	struct b43_wl *wl = hw_to_b43_wl(hw);
3474
	struct b43_wldev *dev = wl->current_dev;
3478
	struct b43_wldev *dev = wl->current_dev;
Lines 3492-3498 static void b43_remove_interface(struct Link Here
3492
	mutex_unlock(&wl->mutex);
3496
	mutex_unlock(&wl->mutex);
3493
}
3497
}
3494
3498
3495
static int b43_start(struct ieee80211_hw *hw)
3499
static int b43_op_start(struct ieee80211_hw *hw)
3496
{
3500
{
3497
	struct b43_wl *wl = hw_to_b43_wl(hw);
3501
	struct b43_wl *wl = hw_to_b43_wl(hw);
3498
	struct b43_wldev *dev = wl->current_dev;
3502
	struct b43_wldev *dev = wl->current_dev;
Lines 3523-3529 static int b43_start(struct ieee80211_hw Link Here
3523
	return err;
3527
	return err;
3524
}
3528
}
3525
3529
3526
static void b43_stop(struct ieee80211_hw *hw)
3530
static void b43_op_stop(struct ieee80211_hw *hw)
3527
{
3531
{
3528
	struct b43_wl *wl = hw_to_b43_wl(hw);
3532
	struct b43_wl *wl = hw_to_b43_wl(hw);
3529
	struct b43_wldev *dev = wl->current_dev;
3533
	struct b43_wldev *dev = wl->current_dev;
Lines 3535-3553 static void b43_stop(struct ieee80211_hw Link Here
3535
	mutex_unlock(&wl->mutex);
3539
	mutex_unlock(&wl->mutex);
3536
}
3540
}
3537
3541
3542
static int b43_op_set_retry_limit(struct ieee80211_hw *hw,
3543
				  u32 short_retry_limit, u32 long_retry_limit)
3544
{
3545
	struct b43_wl *wl = hw_to_b43_wl(hw);
3546
	struct b43_wldev *dev;
3547
	int err = 0;
3548
3549
	mutex_lock(&wl->mutex);
3550
	dev = wl->current_dev;
3551
	if (unlikely(!dev || (b43_status(dev) < B43_STAT_INITIALIZED))) {
3552
		err = -ENODEV;
3553
		goto out_unlock;
3554
	}
3555
	b43_set_retry_limits(dev, short_retry_limit, long_retry_limit);
3556
out_unlock:
3557
	mutex_unlock(&wl->mutex);
3558
3559
	return err;
3560
}
3561
3538
static const struct ieee80211_ops b43_hw_ops = {
3562
static const struct ieee80211_ops b43_hw_ops = {
3539
	.tx = b43_tx,
3563
	.tx			= b43_op_tx,
3540
	.conf_tx = b43_conf_tx,
3564
	.conf_tx		= b43_op_conf_tx,
3541
	.add_interface = b43_add_interface,
3565
	.add_interface		= b43_op_add_interface,
3542
	.remove_interface = b43_remove_interface,
3566
	.remove_interface	= b43_op_remove_interface,
3543
	.config = b43_dev_config,
3567
	.config			= b43_op_config,
3544
	.config_interface = b43_config_interface,
3568
	.config_interface	= b43_op_config_interface,
3545
	.configure_filter = b43_configure_filter,
3569
	.configure_filter	= b43_op_configure_filter,
3546
	.set_key = b43_dev_set_key,
3570
	.set_key		= b43_op_set_key,
3547
	.get_stats = b43_get_stats,
3571
	.get_stats		= b43_op_get_stats,
3548
	.get_tx_stats = b43_get_tx_stats,
3572
	.get_tx_stats		= b43_op_get_tx_stats,
3549
	.start = b43_start,
3573
	.start			= b43_op_start,
3550
	.stop = b43_stop,
3574
	.stop			= b43_op_stop,
3575
	.set_retry_limit	= b43_op_set_retry_limit,
3551
};
3576
};
3552
3577
3553
/* Hard-reset the chip. Do not call this directly.
3578
/* Hard-reset the chip. Do not call this directly.
Lines 3838-3857 static void b43_sprom_fixup(struct ssb_b Link Here
3838
	/* boardflags workarounds */
3863
	/* boardflags workarounds */
3839
	if (bus->boardinfo.vendor == SSB_BOARDVENDOR_DELL &&
3864
	if (bus->boardinfo.vendor == SSB_BOARDVENDOR_DELL &&
3840
	    bus->chip_id == 0x4301 && bus->boardinfo.rev == 0x74)
3865
	    bus->chip_id == 0x4301 && bus->boardinfo.rev == 0x74)
3841
		bus->sprom.r1.boardflags_lo |= B43_BFL_BTCOEXIST;
3866
		bus->sprom.boardflags_lo |= B43_BFL_BTCOEXIST;
3842
	if (bus->boardinfo.vendor == PCI_VENDOR_ID_APPLE &&
3867
	if (bus->boardinfo.vendor == PCI_VENDOR_ID_APPLE &&
3843
	    bus->boardinfo.type == 0x4E && bus->boardinfo.rev > 0x40)
3868
	    bus->boardinfo.type == 0x4E && bus->boardinfo.rev > 0x40)
3844
		bus->sprom.r1.boardflags_lo |= B43_BFL_PACTRL;
3869
		bus->sprom.boardflags_lo |= B43_BFL_PACTRL;
3845
3870
3846
	/* Handle case when gain is not set in sprom */
3871
	/* Handle case when gain is not set in sprom */
3847
	if (bus->sprom.r1.antenna_gain_a == 0xFF)
3872
	if (bus->sprom.antenna_gain_a == 0xFF)
3848
		bus->sprom.r1.antenna_gain_a = 2;
3873
		bus->sprom.antenna_gain_a = 2;
3849
	if (bus->sprom.r1.antenna_gain_bg == 0xFF)
3874
	if (bus->sprom.antenna_gain_bg == 0xFF)
3850
		bus->sprom.r1.antenna_gain_bg = 2;
3875
		bus->sprom.antenna_gain_bg = 2;
3851
3876
3852
	/* Convert Antennagain values to Q5.2 */
3877
	/* Convert Antennagain values to Q5.2 */
3853
	bus->sprom.r1.antenna_gain_a <<= 2;
3878
	bus->sprom.antenna_gain_a <<= 2;
3854
	bus->sprom.r1.antenna_gain_bg <<= 2;
3879
	bus->sprom.antenna_gain_bg <<= 2;
3855
}
3880
}
3856
3881
3857
static void b43_wireless_exit(struct ssb_device *dev, struct b43_wl *wl)
3882
static void b43_wireless_exit(struct ssb_device *dev, struct b43_wl *wl)
Lines 3884-3893 static int b43_wireless_init(struct ssb_ Link Here
3884
	hw->max_noise = -110;
3909
	hw->max_noise = -110;
3885
	hw->queues = 1;		/* FIXME: hardware has more queues */
3910
	hw->queues = 1;		/* FIXME: hardware has more queues */
3886
	SET_IEEE80211_DEV(hw, dev->dev);
3911
	SET_IEEE80211_DEV(hw, dev->dev);
3887
	if (is_valid_ether_addr(sprom->r1.et1mac))
3912
	if (is_valid_ether_addr(sprom->et1mac))
3888
		SET_IEEE80211_PERM_ADDR(hw, sprom->r1.et1mac);
3913
		SET_IEEE80211_PERM_ADDR(hw, sprom->et1mac);
3889
	else
3914
	else
3890
		SET_IEEE80211_PERM_ADDR(hw, sprom->r1.il0mac);
3915
		SET_IEEE80211_PERM_ADDR(hw, sprom->il0mac);
3891
3916
3892
	/* Get and initialize struct b43_wl */
3917
	/* Get and initialize struct b43_wl */
3893
	wl = hw_to_b43_wl(hw);
3918
	wl = hw_to_b43_wl(hw);
(-)linux-2.6/drivers/net/wireless/b43/main.h (-1 / +1 lines)
Lines 3-9 Link Here
3
  Broadcom B43 wireless driver
3
  Broadcom B43 wireless driver
4
4
5
  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
5
  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
6
                     Stefano Brivio <st3@riseup.net>
6
                     Stefano Brivio <stefano.brivio@polimi.it>
7
                     Michael Buesch <mb@bu3sch.de>
7
                     Michael Buesch <mb@bu3sch.de>
8
                     Danny van Dyk <kugelfang@gentoo.org>
8
                     Danny van Dyk <kugelfang@gentoo.org>
9
                     Andreas Jaggi <andreas.jaggi@waterwave.ch>
9
                     Andreas Jaggi <andreas.jaggi@waterwave.ch>
(-)linux-2.6/drivers/net/wireless/b43/Makefile (+1 lines)
Lines 5-10 b43-y += phy.o Link Here
5
b43-y				+= sysfs.o
5
b43-y				+= sysfs.o
6
b43-y				+= xmit.o
6
b43-y				+= xmit.o
7
b43-y				+= lo.o
7
b43-y				+= lo.o
8
b43-y				+= wa.o
8
# b43 RFKILL button support
9
# b43 RFKILL button support
9
b43-$(CONFIG_B43_RFKILL)	+= rfkill.o
10
b43-$(CONFIG_B43_RFKILL)	+= rfkill.o
10
# b43 LED support
11
# b43 LED support
(-)linux-2.6/drivers/net/wireless/b43/phy.c (-526 / +148 lines)
Lines 3-9 Link Here
3
  Broadcom B43 wireless driver
3
  Broadcom B43 wireless driver
4
4
5
  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
5
  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
6
  Copyright (c) 2005, 2006 Stefano Brivio <st3@riseup.net>
6
  Copyright (c) 2005-2007 Stefano Brivio <stefano.brivio@polimi.it>
7
  Copyright (c) 2005, 2006 Michael Buesch <mb@bu3sch.de>
7
  Copyright (c) 2005, 2006 Michael Buesch <mb@bu3sch.de>
8
  Copyright (c) 2005, 2006 Danny van Dyk <kugelfang@gentoo.org>
8
  Copyright (c) 2005, 2006 Danny van Dyk <kugelfang@gentoo.org>
9
  Copyright (c) 2005, 2006 Andreas Jaggi <andreas.jaggi@waterwave.ch>
9
  Copyright (c) 2005, 2006 Andreas Jaggi <andreas.jaggi@waterwave.ch>
Lines 34-39 Link Here
34
#include "main.h"
34
#include "main.h"
35
#include "tables.h"
35
#include "tables.h"
36
#include "lo.h"
36
#include "lo.h"
37
#include "wa.h"
38
37
39
38
static const s8 b43_tssi2dbm_b_table[] = {
40
static const s8 b43_tssi2dbm_b_table[] = {
39
	0x4D, 0x4C, 0x4B, 0x4A,
41
	0x4D, 0x4C, 0x4B, 0x4A,
Lines 303-310 void b43_phy_write(struct b43_wldev *dev Link Here
303
	b43_write16(dev, B43_MMIO_PHY_DATA, val);
305
	b43_write16(dev, B43_MMIO_PHY_DATA, val);
304
}
306
}
305
307
306
static void b43_radio_set_txpower_a(struct b43_wldev *dev, u16 txpower);
307
308
/* Adjust the transmission power output (G-PHY) */
308
/* Adjust the transmission power output (G-PHY) */
309
void b43_set_txpower_g(struct b43_wldev *dev,
309
void b43_set_txpower_g(struct b43_wldev *dev,
310
		       const struct b43_bbatt *bbatt,
310
		       const struct b43_bbatt *bbatt,
Lines 763-1128 static void b43_phy_init_pctl(struct b43 Link Here
763
	b43_shm_clear_tssi(dev);
763
	b43_shm_clear_tssi(dev);
764
}
764
}
765
765
766
static void b43_phy_agcsetup(struct b43_wldev *dev)
766
static void b43_phy_rssiagc(struct b43_wldev *dev, u8 enable)
767
{
768
	struct b43_phy *phy = &dev->phy;
769
	u16 offset = 0x0000;
770
771
	if (phy->rev == 1)
772
		offset = 0x4C00;
773
774
	b43_ofdmtab_write16(dev, offset, 0, 0x00FE);
775
	b43_ofdmtab_write16(dev, offset, 1, 0x000D);
776
	b43_ofdmtab_write16(dev, offset, 2, 0x0013);
777
	b43_ofdmtab_write16(dev, offset, 3, 0x0019);
778
779
	if (phy->rev == 1) {
780
		b43_ofdmtab_write16(dev, 0x1800, 0, 0x2710);
781
		b43_ofdmtab_write16(dev, 0x1801, 0, 0x9B83);
782
		b43_ofdmtab_write16(dev, 0x1802, 0, 0x9B83);
783
		b43_ofdmtab_write16(dev, 0x1803, 0, 0x0F8D);
784
		b43_phy_write(dev, 0x0455, 0x0004);
785
	}
786
787
	b43_phy_write(dev, 0x04A5, (b43_phy_read(dev, 0x04A5)
788
				    & 0x00FF) | 0x5700);
789
	b43_phy_write(dev, 0x041A, (b43_phy_read(dev, 0x041A)
790
				    & 0xFF80) | 0x000F);
791
	b43_phy_write(dev, 0x041A, (b43_phy_read(dev, 0x041A)
792
				    & 0xC07F) | 0x2B80);
793
	b43_phy_write(dev, 0x048C, (b43_phy_read(dev, 0x048C)
794
				    & 0xF0FF) | 0x0300);
795
796
	b43_radio_write16(dev, 0x007A, b43_radio_read16(dev, 0x007A)
797
			  | 0x0008);
798
799
	b43_phy_write(dev, 0x04A0, (b43_phy_read(dev, 0x04A0)
800
				    & 0xFFF0) | 0x0008);
801
	b43_phy_write(dev, 0x04A1, (b43_phy_read(dev, 0x04A1)
802
				    & 0xF0FF) | 0x0600);
803
	b43_phy_write(dev, 0x04A2, (b43_phy_read(dev, 0x04A2)
804
				    & 0xF0FF) | 0x0700);
805
	b43_phy_write(dev, 0x04A0, (b43_phy_read(dev, 0x04A0)
806
				    & 0xF0FF) | 0x0100);
807
808
	if (phy->rev == 1) {
809
		b43_phy_write(dev, 0x04A2, (b43_phy_read(dev, 0x04A2)
810
					    & 0xFFF0) | 0x0007);
811
	}
812
813
	b43_phy_write(dev, 0x0488, (b43_phy_read(dev, 0x0488)
814
				    & 0xFF00) | 0x001C);
815
	b43_phy_write(dev, 0x0488, (b43_phy_read(dev, 0x0488)
816
				    & 0xC0FF) | 0x0200);
817
	b43_phy_write(dev, 0x0496, (b43_phy_read(dev, 0x0496)
818
				    & 0xFF00) | 0x001C);
819
	b43_phy_write(dev, 0x0489, (b43_phy_read(dev, 0x0489)
820
				    & 0xFF00) | 0x0020);
821
	b43_phy_write(dev, 0x0489, (b43_phy_read(dev, 0x0489)
822
				    & 0xC0FF) | 0x0200);
823
	b43_phy_write(dev, 0x0482, (b43_phy_read(dev, 0x0482)
824
				    & 0xFF00) | 0x002E);
825
	b43_phy_write(dev, 0x0496, (b43_phy_read(dev, 0x0496)
826
				    & 0x00FF) | 0x1A00);
827
	b43_phy_write(dev, 0x0481, (b43_phy_read(dev, 0x0481)
828
				    & 0xFF00) | 0x0028);
829
	b43_phy_write(dev, 0x0481, (b43_phy_read(dev, 0x0481)
830
				    & 0x00FF) | 0x2C00);
831
832
	if (phy->rev == 1) {
833
		b43_phy_write(dev, 0x0430, 0x092B);
834
		b43_phy_write(dev, 0x041B, (b43_phy_read(dev, 0x041B)
835
					    & 0xFFE1) | 0x0002);
836
	} else {
837
		b43_phy_write(dev, 0x041B, b43_phy_read(dev, 0x041B)
838
			      & 0xFFE1);
839
		b43_phy_write(dev, 0x041F, 0x287A);
840
		b43_phy_write(dev, 0x0420, (b43_phy_read(dev, 0x0420)
841
					    & 0xFFF0) | 0x0004);
842
	}
843
844
	if (phy->rev >= 6) {
845
		b43_phy_write(dev, 0x0422, 0x287A);
846
		b43_phy_write(dev, 0x0420, (b43_phy_read(dev, 0x0420)
847
					    & 0x0FFF) | 0x3000);
848
	}
849
850
	b43_phy_write(dev, 0x04A8, (b43_phy_read(dev, 0x04A8)
851
				    & 0x8080) | 0x7874);
852
	b43_phy_write(dev, 0x048E, 0x1C00);
853
854
	offset = 0x0800;
855
	if (phy->rev == 1) {
856
		offset = 0x5400;
857
		b43_phy_write(dev, 0x04AB, (b43_phy_read(dev, 0x04AB)
858
					    & 0xF0FF) | 0x0600);
859
		b43_phy_write(dev, 0x048B, 0x005E);
860
		b43_phy_write(dev, 0x048C, (b43_phy_read(dev, 0x048C)
861
					    & 0xFF00) | 0x001E);
862
		b43_phy_write(dev, 0x048D, 0x0002);
863
	}
864
	b43_ofdmtab_write16(dev, offset, 0, 0x00);
865
	b43_ofdmtab_write16(dev, offset, 1, 0x07);
866
	b43_ofdmtab_write16(dev, offset, 2, 0x10);
867
	b43_ofdmtab_write16(dev, offset, 3, 0x1C);
868
869
	if (phy->rev >= 6) {
870
		b43_phy_write(dev, 0x0426, b43_phy_read(dev, 0x0426)
871
			      & 0xFFFC);
872
		b43_phy_write(dev, 0x0426, b43_phy_read(dev, 0x0426)
873
			      & 0xEFFF);
874
	}
875
}
876
877
static void b43_phy_setupg(struct b43_wldev *dev)
878
{
879
	struct ssb_bus *bus = dev->dev->bus;
880
	struct b43_phy *phy = &dev->phy;
881
	u16 i;
882
883
	B43_WARN_ON(phy->type != B43_PHYTYPE_G);
884
	if (phy->rev == 1) {
885
		b43_phy_write(dev, 0x0406, 0x4F19);
886
		b43_phy_write(dev, B43_PHY_G_CRS,
887
			      (b43_phy_read(dev, B43_PHY_G_CRS) & 0xFC3F) |
888
			      0x0340);
889
		b43_phy_write(dev, 0x042C, 0x005A);
890
		b43_phy_write(dev, 0x0427, 0x001A);
891
892
		for (i = 0; i < B43_TAB_FINEFREQG_SIZE; i++)
893
			b43_ofdmtab_write16(dev, 0x5800, i,
894
					    b43_tab_finefreqg[i]);
895
		for (i = 0; i < B43_TAB_NOISEG1_SIZE; i++)
896
			b43_ofdmtab_write16(dev, 0x1800, i, b43_tab_noiseg1[i]);
897
		for (i = 0; i < B43_TAB_ROTOR_SIZE; i++)
898
			b43_ofdmtab_write16(dev, 0x2000, i, b43_tab_rotor[i]);
899
	} else {
900
		/* nrssi values are signed 6-bit values. Not sure why we write 0x7654 here... */
901
		b43_nrssi_hw_write(dev, 0xBA98, (s16) 0x7654);
902
903
		if (phy->rev == 2) {
904
			b43_phy_write(dev, 0x04C0, 0x1861);
905
			b43_phy_write(dev, 0x04C1, 0x0271);
906
		} else if (phy->rev > 2) {
907
			b43_phy_write(dev, 0x04C0, 0x0098);
908
			b43_phy_write(dev, 0x04C1, 0x0070);
909
			b43_phy_write(dev, 0x04C9, 0x0080);
910
		}
911
		b43_phy_write(dev, 0x042B, b43_phy_read(dev, 0x042B) | 0x800);
912
913
		for (i = 0; i < 64; i++)
914
			b43_ofdmtab_write16(dev, 0x4000, i, i);
915
		for (i = 0; i < B43_TAB_NOISEG2_SIZE; i++)
916
			b43_ofdmtab_write16(dev, 0x1800, i, b43_tab_noiseg2[i]);
917
	}
918
919
	if (phy->rev <= 2)
920
		for (i = 0; i < B43_TAB_NOISESCALEG_SIZE; i++)
921
			b43_ofdmtab_write16(dev, 0x1400, i,
922
					    b43_tab_noisescaleg1[i]);
923
	else if ((phy->rev >= 7) && (b43_phy_read(dev, 0x0449) & 0x0200))
924
		for (i = 0; i < B43_TAB_NOISESCALEG_SIZE; i++)
925
			b43_ofdmtab_write16(dev, 0x1400, i,
926
					    b43_tab_noisescaleg3[i]);
927
	else
928
		for (i = 0; i < B43_TAB_NOISESCALEG_SIZE; i++)
929
			b43_ofdmtab_write16(dev, 0x1400, i,
930
					    b43_tab_noisescaleg2[i]);
931
932
	if (phy->rev == 2)
933
		for (i = 0; i < B43_TAB_SIGMASQR_SIZE; i++)
934
			b43_ofdmtab_write16(dev, 0x5000, i,
935
					    b43_tab_sigmasqr1[i]);
936
	else if ((phy->rev > 2) && (phy->rev <= 8))
937
		for (i = 0; i < B43_TAB_SIGMASQR_SIZE; i++)
938
			b43_ofdmtab_write16(dev, 0x5000, i,
939
					    b43_tab_sigmasqr2[i]);
940
941
	if (phy->rev == 1) {
942
		for (i = 0; i < B43_TAB_RETARD_SIZE; i++)
943
			b43_ofdmtab_write32(dev, 0x2400, i, b43_tab_retard[i]);
944
		for (i = 4; i < 20; i++)
945
			b43_ofdmtab_write16(dev, 0x5400, i, 0x0020);
946
		b43_phy_agcsetup(dev);
947
948
		if ((bus->boardinfo.vendor == SSB_BOARDVENDOR_BCM) &&
949
		    (bus->boardinfo.type == SSB_BOARD_BU4306) &&
950
		    (bus->boardinfo.rev == 0x17))
951
			return;
952
953
		b43_ofdmtab_write16(dev, 0x5001, 0, 0x0002);
954
		b43_ofdmtab_write16(dev, 0x5002, 0, 0x0001);
955
	} else {
956
		for (i = 0; i < 0x20; i++)
957
			b43_ofdmtab_write16(dev, 0x1000, i, 0x0820);
958
		b43_phy_agcsetup(dev);
959
		b43_phy_read(dev, 0x0400);	/* dummy read */
960
		b43_phy_write(dev, 0x0403, 0x1000);
961
		b43_ofdmtab_write16(dev, 0x3C02, 0, 0x000F);
962
		b43_ofdmtab_write16(dev, 0x3C03, 0, 0x0014);
963
964
		if ((bus->boardinfo.vendor == SSB_BOARDVENDOR_BCM) &&
965
		    (bus->boardinfo.type == SSB_BOARD_BU4306) &&
966
		    (bus->boardinfo.rev == 0x17))
967
			return;
968
969
		b43_ofdmtab_write16(dev, 0x0401, 0, 0x0002);
970
		b43_ofdmtab_write16(dev, 0x0402, 0, 0x0001);
971
	}
972
}
973
974
/* Initialize the noisescaletable for APHY */
975
static void b43_phy_init_noisescaletbl(struct b43_wldev *dev)
976
{
767
{
977
	struct b43_phy *phy = &dev->phy;
978
	int i;
768
	int i;
979
769
980
	for (i = 0; i < 12; i++) {
770
	if (dev->phy.rev < 3) {
981
		if (phy->rev == 2)
771
		if (enable)
982
			b43_ofdmtab_write16(dev, 0x1400, i, 0x6767);
772
			for (i = 0; i < B43_TAB_RSSIAGC1_SIZE; i++) {
773
				b43_ofdmtab_write16(dev,
774
					B43_OFDMTAB_LNAHPFGAIN1, i, 0xFFF8);
775
				b43_ofdmtab_write16(dev,
776
					B43_OFDMTAB_WRSSI, i, 0xFFF8);
777
			}
983
		else
778
		else
984
			b43_ofdmtab_write16(dev, 0x1400, i, 0x2323);
779
			for (i = 0; i < B43_TAB_RSSIAGC1_SIZE; i++) {
985
	}
780
				b43_ofdmtab_write16(dev,
986
	if (phy->rev == 2)
781
					B43_OFDMTAB_LNAHPFGAIN1, i, b43_tab_rssiagc1[i]);
987
		b43_ofdmtab_write16(dev, 0x1400, i, 0x6700);
782
				b43_ofdmtab_write16(dev,
988
	else
783
					B43_OFDMTAB_WRSSI, i, b43_tab_rssiagc1[i]);
989
		b43_ofdmtab_write16(dev, 0x1400, i, 0x2300);
784
			}
990
	for (i = 0; i < 11; i++) {
785
	} else {
991
		if (phy->rev == 2)
786
		if (enable)
992
			b43_ofdmtab_write16(dev, 0x1400, i, 0x6767);
787
			for (i = 0; i < B43_TAB_RSSIAGC1_SIZE; i++)
788
				b43_ofdmtab_write16(dev,
789
					B43_OFDMTAB_WRSSI, i, 0x0820);
993
		else
790
		else
994
			b43_ofdmtab_write16(dev, 0x1400, i, 0x2323);
791
			for (i = 0; i < B43_TAB_RSSIAGC2_SIZE; i++)
792
				b43_ofdmtab_write16(dev,
793
					B43_OFDMTAB_WRSSI, i, b43_tab_rssiagc2[i]);
995
	}
794
	}
996
	if (phy->rev == 2)
997
		b43_ofdmtab_write16(dev, 0x1400, i, 0x0067);
998
	else
999
		b43_ofdmtab_write16(dev, 0x1400, i, 0x0023);
1000
}
795
}
1001
796
1002
static void b43_phy_setupa(struct b43_wldev *dev)
797
static void b43_phy_ww(struct b43_wldev *dev)
1003
{
798
{
1004
	struct b43_phy *phy = &dev->phy;
799
	u16 b, curr_s, best_s = 0xFFFF;
1005
	u16 i;
800
	int i;
1006
1007
	B43_WARN_ON(phy->type != B43_PHYTYPE_A);
1008
	switch (phy->rev) {
1009
	case 2:
1010
		b43_phy_write(dev, 0x008E, 0x3800);
1011
		b43_phy_write(dev, 0x0035, 0x03FF);
1012
		b43_phy_write(dev, 0x0036, 0x0400);
1013
1014
		b43_ofdmtab_write16(dev, 0x3807, 0, 0x0051);
1015
1016
		b43_phy_write(dev, 0x001C, 0x0FF9);
1017
		b43_phy_write(dev, 0x0020, b43_phy_read(dev, 0x0020) & 0xFF0F);
1018
		b43_ofdmtab_write16(dev, 0x3C0C, 0, 0x07BF);
1019
		b43_radio_write16(dev, 0x0002, 0x07BF);
1020
1021
		b43_phy_write(dev, 0x0024, 0x4680);
1022
		b43_phy_write(dev, 0x0020, 0x0003);
1023
		b43_phy_write(dev, 0x001D, 0x0F40);
1024
		b43_phy_write(dev, 0x001F, 0x1C00);
1025
1026
		b43_phy_write(dev, 0x002A, (b43_phy_read(dev, 0x002A)
1027
					    & 0x00FF) | 0x0400);
1028
		b43_phy_write(dev, 0x002B, b43_phy_read(dev, 0x002B)
1029
			      & 0xFBFF);
1030
		b43_phy_write(dev, 0x008E, 0x58C1);
1031
1032
		b43_ofdmtab_write16(dev, 0x0803, 0, 0x000F);
1033
		b43_ofdmtab_write16(dev, 0x0804, 0, 0x001F);
1034
		b43_ofdmtab_write16(dev, 0x0805, 0, 0x002A);
1035
		b43_ofdmtab_write16(dev, 0x0805, 0, 0x0030);
1036
		b43_ofdmtab_write16(dev, 0x0807, 0, 0x003A);
1037
1038
		b43_ofdmtab_write16(dev, 0x0000, 0, 0x0013);
1039
		b43_ofdmtab_write16(dev, 0x0000, 1, 0x0013);
1040
		b43_ofdmtab_write16(dev, 0x0000, 2, 0x0013);
1041
		b43_ofdmtab_write16(dev, 0x0000, 3, 0x0013);
1042
		b43_ofdmtab_write16(dev, 0x0000, 4, 0x0015);
1043
		b43_ofdmtab_write16(dev, 0x0000, 5, 0x0015);
1044
		b43_ofdmtab_write16(dev, 0x0000, 6, 0x0019);
1045
1046
		b43_ofdmtab_write16(dev, 0x0404, 0, 0x0003);
1047
		b43_ofdmtab_write16(dev, 0x0405, 0, 0x0003);
1048
		b43_ofdmtab_write16(dev, 0x0406, 0, 0x0007);
1049
1050
		for (i = 0; i < 16; i++)
1051
			b43_ofdmtab_write16(dev, 0x4000, i, (0x8 + i) & 0x000F);
1052
1053
		b43_ofdmtab_write16(dev, 0x3003, 0, 0x1044);
1054
		b43_ofdmtab_write16(dev, 0x3004, 0, 0x7201);
1055
		b43_ofdmtab_write16(dev, 0x3006, 0, 0x0040);
1056
		b43_ofdmtab_write16(dev, 0x3001, 0,
1057
				    (b43_ofdmtab_read16(dev, 0x3001, 0) &
1058
				     0x0010) | 0x0008);
1059
1060
		for (i = 0; i < B43_TAB_FINEFREQA_SIZE; i++)
1061
			b43_ofdmtab_write16(dev, 0x5800, i,
1062
					    b43_tab_finefreqa[i]);
1063
		for (i = 0; i < B43_TAB_NOISEA2_SIZE; i++)
1064
			b43_ofdmtab_write16(dev, 0x1800, i, b43_tab_noisea2[i]);
1065
		for (i = 0; i < B43_TAB_ROTOR_SIZE; i++)
1066
			b43_ofdmtab_write32(dev, 0x2000, i, b43_tab_rotor[i]);
1067
		b43_phy_init_noisescaletbl(dev);
1068
		for (i = 0; i < B43_TAB_RETARD_SIZE; i++)
1069
			b43_ofdmtab_write32(dev, 0x2400, i, b43_tab_retard[i]);
1070
		break;
1071
	case 3:
1072
		for (i = 0; i < 64; i++)
1073
			b43_ofdmtab_write16(dev, 0x4000, i, i);
1074
1075
		b43_ofdmtab_write16(dev, 0x3807, 0, 0x0051);
1076
1077
		b43_phy_write(dev, 0x001C, 0x0FF9);
1078
		b43_phy_write(dev, 0x0020, b43_phy_read(dev, 0x0020) & 0xFF0F);
1079
		b43_radio_write16(dev, 0x0002, 0x07BF);
1080
1081
		b43_phy_write(dev, 0x0024, 0x4680);
1082
		b43_phy_write(dev, 0x0020, 0x0003);
1083
		b43_phy_write(dev, 0x001D, 0x0F40);
1084
		b43_phy_write(dev, 0x001F, 0x1C00);
1085
		b43_phy_write(dev, 0x002A, (b43_phy_read(dev, 0x002A)
1086
					    & 0x00FF) | 0x0400);
1087
1088
		b43_ofdmtab_write16(dev, 0x3000, 1,
1089
				    (b43_ofdmtab_read16(dev, 0x3000, 1)
1090
				     & 0x0010) | 0x0008);
1091
		for (i = 0; i < B43_TAB_NOISEA3_SIZE; i++) {
1092
			b43_ofdmtab_write16(dev, 0x1800, i, b43_tab_noisea3[i]);
1093
		}
1094
		b43_phy_init_noisescaletbl(dev);
1095
		for (i = 0; i < B43_TAB_SIGMASQR_SIZE; i++) {
1096
			b43_ofdmtab_write16(dev, 0x5000, i,
1097
					    b43_tab_sigmasqr1[i]);
1098
		}
1099
1100
		b43_phy_write(dev, 0x0003, 0x1808);
1101
1102
		b43_ofdmtab_write16(dev, 0x0803, 0, 0x000F);
1103
		b43_ofdmtab_write16(dev, 0x0804, 0, 0x001F);
1104
		b43_ofdmtab_write16(dev, 0x0805, 0, 0x002A);
1105
		b43_ofdmtab_write16(dev, 0x0805, 0, 0x0030);
1106
		b43_ofdmtab_write16(dev, 0x0807, 0, 0x003A);
1107
1108
		b43_ofdmtab_write16(dev, 0x0000, 0, 0x0013);
1109
		b43_ofdmtab_write16(dev, 0x0001, 0, 0x0013);
1110
		b43_ofdmtab_write16(dev, 0x0002, 0, 0x0013);
1111
		b43_ofdmtab_write16(dev, 0x0003, 0, 0x0013);
1112
		b43_ofdmtab_write16(dev, 0x0004, 0, 0x0015);
1113
		b43_ofdmtab_write16(dev, 0x0005, 0, 0x0015);
1114
		b43_ofdmtab_write16(dev, 0x0006, 0, 0x0019);
1115
1116
		b43_ofdmtab_write16(dev, 0x0404, 0, 0x0003);
1117
		b43_ofdmtab_write16(dev, 0x0405, 0, 0x0003);
1118
		b43_ofdmtab_write16(dev, 0x0406, 0, 0x0007);
1119
801
1120
		b43_ofdmtab_write16(dev, 0x3C02, 0, 0x000F);
802
	b43_phy_write(dev, B43_PHY_CRS0,
1121
		b43_ofdmtab_write16(dev, 0x3C03, 0, 0x0014);
803
		b43_phy_read(dev, B43_PHY_CRS0) & ~B43_PHY_CRS0_EN);
1122
		break;
804
	b43_phy_write(dev, B43_PHY_OFDM(0x1B),
1123
	default:
805
		b43_phy_read(dev, B43_PHY_OFDM(0x1B)) | 0x1000);
1124
		B43_WARN_ON(1);
806
	b43_phy_write(dev, B43_PHY_OFDM(0x82),
1125
	}
807
		(b43_phy_read(dev, B43_PHY_OFDM(0x82)) & 0xF0FF) | 0x0300);
808
	b43_radio_write16(dev, 0x0009,
809
		b43_radio_read16(dev, 0x0009) | 0x0080);
810
	b43_radio_write16(dev, 0x0012,
811
		(b43_radio_read16(dev, 0x0012) & 0xFFFC) | 0x0002);
812
	b43_wa_initgains(dev);
813
	b43_phy_write(dev, B43_PHY_OFDM(0xBA), 0x3ED5);
814
	b = b43_phy_read(dev, B43_PHY_PWRDOWN);
815
	b43_phy_write(dev, B43_PHY_PWRDOWN, (b & 0xFFF8) | 0x0005);
816
	b43_radio_write16(dev, 0x0004,
817
		b43_radio_read16(dev, 0x0004) | 0x0004);
818
	for (i = 0x10; i <= 0x20; i++) {
819
		b43_radio_write16(dev, 0x0013, i);
820
		curr_s = b43_phy_read(dev, B43_PHY_OTABLEQ) & 0x00FF;
821
		if (!curr_s) {
822
			best_s = 0x0000;
823
			break;
824
		} else if (curr_s >= 0x0080)
825
			curr_s = 0x0100 - curr_s;
826
		if (curr_s < best_s)
827
			best_s = curr_s;
828
	}
829
	b43_phy_write(dev, B43_PHY_PWRDOWN, b);
830
	b43_radio_write16(dev, 0x0004,
831
		b43_radio_read16(dev, 0x0004) & 0xFFFB);
832
	b43_radio_write16(dev, 0x0013, best_s);
833
	b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC1_R1, 0, 0xFFEC);
834
	b43_phy_write(dev, B43_PHY_OFDM(0xB7), 0x1E80);
835
	b43_phy_write(dev, B43_PHY_OFDM(0xB6), 0x1C00);
836
	b43_phy_write(dev, B43_PHY_OFDM(0xB5), 0x0EC0);
837
	b43_phy_write(dev, B43_PHY_OFDM(0xB2), 0x00C0);
838
	b43_phy_write(dev, B43_PHY_OFDM(0xB9), 0x1FFF);
839
	b43_phy_write(dev, B43_PHY_OFDM(0xBB),
840
		(b43_phy_read(dev, B43_PHY_OFDM(0xBB)) & 0xF000) | 0x0053);
841
	b43_phy_write(dev, B43_PHY_OFDM61,
842
		(b43_phy_read(dev, B43_PHY_OFDM61 & 0xFE1F)) | 0x0120);
843
	b43_phy_write(dev, B43_PHY_OFDM(0x13),
844
		(b43_phy_read(dev, B43_PHY_OFDM(0x13)) & 0x0FFF) | 0x3000);
845
	b43_phy_write(dev, B43_PHY_OFDM(0x14),
846
		(b43_phy_read(dev, B43_PHY_OFDM(0x14)) & 0x0FFF) | 0x3000);
847
	b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC1, 6, 0x0017);
848
	for (i = 0; i < 6; i++)
849
		b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC1, i, 0x000F);
850
	b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC1, 0x0D, 0x000E);
851
	b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC1, 0x0E, 0x0011);
852
	b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC1, 0x0F, 0x0013);
853
	b43_phy_write(dev, B43_PHY_OFDM(0x33), 0x5030);
854
	b43_phy_write(dev, B43_PHY_CRS0,
855
		b43_phy_read(dev, B43_PHY_CRS0) | B43_PHY_CRS0_EN);
1126
}
856
}
1127
857
1128
/* Initialize APHY. This is also called for the GPHY in some cases. */
858
/* Initialize APHY. This is also called for the GPHY in some cases. */
Lines 1130-1193 static void b43_phy_inita(struct b43_wld Link Here
1130
{
860
{
1131
	struct ssb_bus *bus = dev->dev->bus;
861
	struct ssb_bus *bus = dev->dev->bus;
1132
	struct b43_phy *phy = &dev->phy;
862
	struct b43_phy *phy = &dev->phy;
1133
	u16 tval;
1134
863
1135
	might_sleep();
864
	might_sleep();
1136
865
1137
	if (phy->type == B43_PHYTYPE_A) {
866
	if (phy->rev >= 6) {
1138
		b43_phy_setupa(dev);
867
		if (phy->type == B43_PHYTYPE_A)
1139
	} else {
868
			b43_phy_write(dev, B43_PHY_OFDM(0x1B),
1140
		b43_phy_setupg(dev);
869
				b43_phy_read(dev, B43_PHY_OFDM(0x1B)) & ~0x1000);
1141
		if (phy->gmode &&
870
		if (b43_phy_read(dev, B43_PHY_ENCORE) & B43_PHY_ENCORE_EN)
1142
		    (dev->dev->bus->sprom.r1.boardflags_lo & B43_BFL_PACTRL))
871
			b43_phy_write(dev, B43_PHY_ENCORE,
1143
			b43_phy_write(dev, 0x046E, 0x03CF);
872
				b43_phy_read(dev, B43_PHY_ENCORE) | 0x0010);
1144
		return;
873
		else
874
			b43_phy_write(dev, B43_PHY_ENCORE,
875
				b43_phy_read(dev, B43_PHY_ENCORE) & ~0x1010);
1145
	}
876
	}
1146
877
1147
	b43_phy_write(dev, B43_PHY_A_CRS,
878
	b43_wa_all(dev);
1148
		      (b43_phy_read(dev, B43_PHY_A_CRS) & 0xF83C) | 0x0340);
1149
	b43_phy_write(dev, 0x0034, 0x0001);
1150
1151
	//TODO: RSSI AGC
1152
	b43_phy_write(dev, B43_PHY_A_CRS,
1153
		      b43_phy_read(dev, B43_PHY_A_CRS) | (1 << 14));
1154
	b43_radio_init2060(dev);
1155
879
1156
	if ((bus->boardinfo.vendor == SSB_BOARDVENDOR_BCM) &&
880
	if (phy->type == B43_PHYTYPE_A) {
1157
	    ((bus->boardinfo.type == SSB_BOARD_BU4306) ||
881
		if (phy->gmode && (phy->rev < 3))
1158
	     (bus->boardinfo.type == SSB_BOARD_BU4309))) {
882
			b43_phy_write(dev, 0x0034,
1159
		if (phy->lofcal == 0xFFFF) {
883
				b43_phy_read(dev, 0x0034) | 0x0001);
1160
			//TODO: LOF Cal
884
		b43_phy_rssiagc(dev, 0);
1161
			b43_radio_set_tx_iq(dev);
1162
		} else
1163
			b43_radio_write16(dev, 0x001E, phy->lofcal);
1164
	}
1165
885
1166
	b43_phy_write(dev, 0x007A, 0xF111);
886
		b43_phy_write(dev, B43_PHY_CRS0,
887
			b43_phy_read(dev, B43_PHY_CRS0) | B43_PHY_CRS0_EN);
1167
888
1168
	if (phy->cur_idle_tssi == 0) {
889
		b43_radio_init2060(dev);
1169
		b43_radio_write16(dev, 0x0019, 0x0000);
1170
		b43_radio_write16(dev, 0x0017, 0x0020);
1171
890
1172
		tval = b43_ofdmtab_read16(dev, 0x3001, 0);
891
		if ((bus->boardinfo.vendor == SSB_BOARDVENDOR_BCM) &&
1173
		if (phy->rev == 1) {
892
		    ((bus->boardinfo.type == SSB_BOARD_BU4306) ||
1174
			b43_ofdmtab_write16(dev, 0x3001, 0,
893
		     (bus->boardinfo.type == SSB_BOARD_BU4309))) {
1175
					    (b43_ofdmtab_read16(dev, 0x3001, 0)
894
			; //TODO: A PHY LO
1176
					     & 0xFF87)
1177
					    | 0x0058);
1178
		} else {
1179
			b43_ofdmtab_write16(dev, 0x3001, 0,
1180
					    (b43_ofdmtab_read16(dev, 0x3001, 0)
1181
					     & 0xFFC3)
1182
					    | 0x002C);
1183
		}
895
		}
1184
		b43_dummy_transmission(dev);
1185
		phy->cur_idle_tssi = b43_phy_read(dev, B43_PHY_A_PCTL);
1186
		b43_ofdmtab_write16(dev, 0x3001, 0, tval);
1187
896
1188
		b43_radio_set_txpower_a(dev, 0x0018);
897
		if (phy->rev >= 3)
898
			b43_phy_ww(dev);
899
900
		hardware_pctl_init_aphy(dev);
901
902
		//TODO: radar detection
903
	}
904
905
	if ((phy->type == B43_PHYTYPE_G) &&
906
	    (dev->dev->bus->sprom.boardflags_lo & B43_BFL_PACTRL)) {
907
		b43_phy_write(dev, B43_PHY_OFDM(0x6E),
908
				  (b43_phy_read(dev, B43_PHY_OFDM(0x6E))
909
				   & 0xE000) | 0x3CF);
1189
	}
910
	}
1190
	b43_shm_clear_tssi(dev);
1191
}
911
}
1192
912
1193
static void b43_phy_initb2(struct b43_wldev *dev)
913
static void b43_phy_initb2(struct b43_wldev *dev)
Lines 1286-1292 static void b43_phy_initb4(struct b43_wl Link Here
1286
	if (phy->radio_ver == 0x2050)
1006
	if (phy->radio_ver == 0x2050)
1287
		b43_phy_write(dev, 0x002A, 0x88C2);
1007
		b43_phy_write(dev, 0x002A, 0x88C2);
1288
	b43_set_txpower_g(dev, &phy->bbatt, &phy->rfatt, phy->tx_control);
1008
	b43_set_txpower_g(dev, &phy->bbatt, &phy->rfatt, phy->tx_control);
1289
	if (dev->dev->bus->sprom.r1.boardflags_lo & B43_BFL_RSSI) {
1009
	if (dev->dev->bus->sprom.boardflags_lo & B43_BFL_RSSI) {
1290
		b43_calc_nrssi_slope(dev);
1010
		b43_calc_nrssi_slope(dev);
1291
		b43_calc_nrssi_threshold(dev);
1011
		b43_calc_nrssi_threshold(dev);
1292
	}
1012
	}
Lines 1433-1439 static void b43_phy_initb6(struct b43_wl Link Here
1433
		b43_radio_write16(dev, 0x5A, 0x88);
1153
		b43_radio_write16(dev, 0x5A, 0x88);
1434
		b43_radio_write16(dev, 0x5B, 0x6B);
1154
		b43_radio_write16(dev, 0x5B, 0x6B);
1435
		b43_radio_write16(dev, 0x5C, 0x0F);
1155
		b43_radio_write16(dev, 0x5C, 0x0F);
1436
		if (dev->dev->bus->sprom.r1.boardflags_lo & B43_BFL_ALTIQ) {
1156
		if (dev->dev->bus->sprom.boardflags_lo & B43_BFL_ALTIQ) {
1437
			b43_radio_write16(dev, 0x5D, 0xFA);
1157
			b43_radio_write16(dev, 0x5D, 0xFA);
1438
			b43_radio_write16(dev, 0x5E, 0xD8);
1158
			b43_radio_write16(dev, 0x5E, 0xD8);
1439
		} else {
1159
		} else {
Lines 1525-1531 static void b43_phy_initb6(struct b43_wl Link Here
1525
		b43_phy_write(dev, 0x0062, 0x0007);
1245
		b43_phy_write(dev, 0x0062, 0x0007);
1526
		b43_radio_init2050(dev);
1246
		b43_radio_init2050(dev);
1527
		b43_lo_g_measure(dev);
1247
		b43_lo_g_measure(dev);
1528
		if (dev->dev->bus->sprom.r1.boardflags_lo & B43_BFL_RSSI) {
1248
		if (dev->dev->bus->sprom.boardflags_lo & B43_BFL_RSSI) {
1529
			b43_calc_nrssi_slope(dev);
1249
			b43_calc_nrssi_slope(dev);
1530
			b43_calc_nrssi_threshold(dev);
1250
			b43_calc_nrssi_threshold(dev);
1531
		}
1251
		}
Lines 1645-1651 static void b43_calc_loopback_gain(struc Link Here
1645
	b43_phy_write(dev, B43_PHY_RFOVERVAL,
1365
	b43_phy_write(dev, B43_PHY_RFOVERVAL,
1646
		      b43_phy_read(dev, B43_PHY_RFOVERVAL) & 0xCFFF);
1366
		      b43_phy_read(dev, B43_PHY_RFOVERVAL) & 0xCFFF);
1647
1367
1648
	if (dev->dev->bus->sprom.r1.boardflags_lo & B43_BFL_EXTLNA) {
1368
	if (dev->dev->bus->sprom.boardflags_lo & B43_BFL_EXTLNA) {
1649
		if (phy->rev >= 7) {
1369
		if (phy->rev >= 7) {
1650
			b43_phy_write(dev, B43_PHY_RFOVER,
1370
			b43_phy_write(dev, B43_PHY_RFOVER,
1651
				      b43_phy_read(dev, B43_PHY_RFOVER)
1371
				      b43_phy_read(dev, B43_PHY_RFOVER)
Lines 1812-1818 static void b43_phy_initg(struct b43_wld Link Here
1812
				       & 0x0FFF) | (phy->lo_control->
1532
				       & 0x0FFF) | (phy->lo_control->
1813
						    tx_bias << 12));
1533
						    tx_bias << 12));
1814
		}
1534
		}
1815
		if (dev->dev->bus->sprom.r1.boardflags_lo & B43_BFL_PACTRL)
1535
		if (dev->dev->bus->sprom.boardflags_lo & B43_BFL_PACTRL)
1816
			b43_phy_write(dev, B43_PHY_BASE(0x2E), 0x8075);
1536
			b43_phy_write(dev, B43_PHY_BASE(0x2E), 0x8075);
1817
		else
1537
		else
1818
			b43_phy_write(dev, B43_PHY_BASE(0x2E), 0x807F);
1538
			b43_phy_write(dev, B43_PHY_BASE(0x2E), 0x807F);
Lines 1826-1832 static void b43_phy_initg(struct b43_wld Link Here
1826
		b43_phy_write(dev, B43_PHY_LO_MASK, 0x8078);
1546
		b43_phy_write(dev, B43_PHY_LO_MASK, 0x8078);
1827
	}
1547
	}
1828
1548
1829
	if (!(dev->dev->bus->sprom.r1.boardflags_lo & B43_BFL_RSSI)) {
1549
	if (!(dev->dev->bus->sprom.boardflags_lo & B43_BFL_RSSI)) {
1830
		/* The specs state to update the NRSSI LT with
1550
		/* The specs state to update the NRSSI LT with
1831
		 * the value 0x7FFFFFFF here. I think that is some weird
1551
		 * the value 0x7FFFFFFF here. I think that is some weird
1832
		 * compiler optimization in the original driver.
1552
		 * compiler optimization in the original driver.
Lines 2036-2051 void b43_phy_xmitpower(struct b43_wldev Link Here
2036
			estimated_pwr =
1756
			estimated_pwr =
2037
			    b43_phy_estimate_power_out(dev, average);
1757
			    b43_phy_estimate_power_out(dev, average);
2038
1758
2039
			max_pwr = dev->dev->bus->sprom.r1.maxpwr_bg;
1759
			max_pwr = dev->dev->bus->sprom.maxpwr_bg;
2040
			if ((dev->dev->bus->sprom.r1.
1760
			if ((dev->dev->bus->sprom.boardflags_lo
2041
			     boardflags_lo & B43_BFL_PACTRL)
1761
			    & B43_BFL_PACTRL) && (phy->type == B43_PHYTYPE_G))
2042
			    && (phy->type == B43_PHYTYPE_G))
2043
				max_pwr -= 0x3;
1762
				max_pwr -= 0x3;
2044
			if (unlikely(max_pwr <= 0)) {
1763
			if (unlikely(max_pwr <= 0)) {
2045
				b43warn(dev->wl,
1764
				b43warn(dev->wl,
2046
					"Invalid max-TX-power value in SPROM.\n");
1765
					"Invalid max-TX-power value in SPROM.\n");
2047
				max_pwr = 60;	/* fake it */
1766
				max_pwr = 60;	/* fake it */
2048
				dev->dev->bus->sprom.r1.maxpwr_bg = max_pwr;
1767
				dev->dev->bus->sprom.maxpwr_bg = max_pwr;
2049
			}
1768
			}
2050
1769
2051
			/*TODO:
1770
			/*TODO:
Lines 2103-2109 void b43_phy_xmitpower(struct b43_wldev Link Here
2103
						    B43_TXCTL_TXMIX;
1822
						    B43_TXCTL_TXMIX;
2104
						rfatt += 2;
1823
						rfatt += 2;
2105
						bbatt += 2;
1824
						bbatt += 2;
2106
					} else if (dev->dev->bus->sprom.r1.
1825
					} else if (dev->dev->bus->sprom.
2107
						   boardflags_lo &
1826
						   boardflags_lo &
2108
						   B43_BFL_PACTRL) {
1827
						   B43_BFL_PACTRL) {
2109
						bbatt += 4 * (rfatt - 2);
1828
						bbatt += 4 * (rfatt - 2);
Lines 2179-2191 int b43_phy_init_tssi2dbm_table(struct b Link Here
2179
	s8 *dyn_tssi2dbm;
1898
	s8 *dyn_tssi2dbm;
2180
1899
2181
	if (phy->type == B43_PHYTYPE_A) {
1900
	if (phy->type == B43_PHYTYPE_A) {
2182
		pab0 = (s16) (dev->dev->bus->sprom.r1.pa1b0);
1901
		pab0 = (s16) (dev->dev->bus->sprom.pa1b0);
2183
		pab1 = (s16) (dev->dev->bus->sprom.r1.pa1b1);
1902
		pab1 = (s16) (dev->dev->bus->sprom.pa1b1);
2184
		pab2 = (s16) (dev->dev->bus->sprom.r1.pa1b2);
1903
		pab2 = (s16) (dev->dev->bus->sprom.pa1b2);
2185
	} else {
1904
	} else {
2186
		pab0 = (s16) (dev->dev->bus->sprom.r1.pa0b0);
1905
		pab0 = (s16) (dev->dev->bus->sprom.pa0b0);
2187
		pab1 = (s16) (dev->dev->bus->sprom.r1.pa0b1);
1906
		pab1 = (s16) (dev->dev->bus->sprom.pa0b1);
2188
		pab2 = (s16) (dev->dev->bus->sprom.r1.pa0b2);
1907
		pab2 = (s16) (dev->dev->bus->sprom.pa0b2);
2189
	}
1908
	}
2190
1909
2191
	if ((dev->dev->bus->chip_id == 0x4301) && (phy->radio_ver != 0x2050)) {
1910
	if ((dev->dev->bus->chip_id == 0x4301) && (phy->radio_ver != 0x2050)) {
Lines 2198-2214 int b43_phy_init_tssi2dbm_table(struct b Link Here
2198
	    pab0 != -1 && pab1 != -1 && pab2 != -1) {
1917
	    pab0 != -1 && pab1 != -1 && pab2 != -1) {
2199
		/* The pabX values are set in SPROM. Use them. */
1918
		/* The pabX values are set in SPROM. Use them. */
2200
		if (phy->type == B43_PHYTYPE_A) {
1919
		if (phy->type == B43_PHYTYPE_A) {
2201
			if ((s8) dev->dev->bus->sprom.r1.itssi_a != 0 &&
1920
			if ((s8) dev->dev->bus->sprom.itssi_a != 0 &&
2202
			    (s8) dev->dev->bus->sprom.r1.itssi_a != -1)
1921
			    (s8) dev->dev->bus->sprom.itssi_a != -1)
2203
				phy->tgt_idle_tssi =
1922
				phy->tgt_idle_tssi =
2204
				    (s8) (dev->dev->bus->sprom.r1.itssi_a);
1923
				    (s8) (dev->dev->bus->sprom.itssi_a);
2205
			else
1924
			else
2206
				phy->tgt_idle_tssi = 62;
1925
				phy->tgt_idle_tssi = 62;
2207
		} else {
1926
		} else {
2208
			if ((s8) dev->dev->bus->sprom.r1.itssi_bg != 0 &&
1927
			if ((s8) dev->dev->bus->sprom.itssi_bg != 0 &&
2209
			    (s8) dev->dev->bus->sprom.r1.itssi_bg != -1)
1928
			    (s8) dev->dev->bus->sprom.itssi_bg != -1)
2210
				phy->tgt_idle_tssi =
1929
				phy->tgt_idle_tssi =
2211
				    (s8) (dev->dev->bus->sprom.r1.itssi_bg);
1930
				    (s8) (dev->dev->bus->sprom.itssi_bg);
2212
			else
1931
			else
2213
				phy->tgt_idle_tssi = 62;
1932
				phy->tgt_idle_tssi = 62;
2214
		}
1933
		}
Lines 3114-3120 void b43_calc_nrssi_threshold(struct b43 Link Here
3114
			if (phy->radio_ver != 0x2050)
2833
			if (phy->radio_ver != 0x2050)
3115
				return;
2834
				return;
3116
			if (!
2835
			if (!
3117
			    (dev->dev->bus->sprom.r1.
2836
			    (dev->dev->bus->sprom.
3118
			     boardflags_lo & B43_BFL_RSSI))
2837
			     boardflags_lo & B43_BFL_RSSI))
3119
				return;
2838
				return;
3120
2839
Lines 3145-3151 void b43_calc_nrssi_threshold(struct b43 Link Here
3145
		}
2864
		}
3146
	case B43_PHYTYPE_G:
2865
	case B43_PHYTYPE_G:
3147
		if (!phy->gmode ||
2866
		if (!phy->gmode ||
3148
		    !(dev->dev->bus->sprom.r1.boardflags_lo & B43_BFL_RSSI)) {
2867
		    !(dev->dev->bus->sprom.boardflags_lo & B43_BFL_RSSI)) {
3149
			tmp16 = b43_nrssi_hw_read(dev, 0x20);
2868
			tmp16 = b43_nrssi_hw_read(dev, 0x20);
3150
			if (tmp16 >= 0x20)
2869
			if (tmp16 >= 0x20)
3151
				tmp16 -= 0x40;
2870
				tmp16 -= 0x40;
Lines 3667-3673 static u16 radio2050_rfover_val(struct b Link Here
3667
		}
3386
		}
3668
3387
3669
		if ((phy->rev < 7) ||
3388
		if ((phy->rev < 7) ||
3670
		    !(sprom->r1.boardflags_lo & B43_BFL_EXTLNA)) {
3389
		    !(sprom->boardflags_lo & B43_BFL_EXTLNA)) {
3671
			if (phy_register == B43_PHY_RFOVER) {
3390
			if (phy_register == B43_PHY_RFOVER) {
3672
				return 0x1B3;
3391
				return 0x1B3;
3673
			} else if (phy_register == B43_PHY_RFOVERVAL) {
3392
			} else if (phy_register == B43_PHY_RFOVERVAL) {
Lines 3707-3713 static u16 radio2050_rfover_val(struct b Link Here
3707
		}
3426
		}
3708
	} else {
3427
	} else {
3709
		if ((phy->rev < 7) ||
3428
		if ((phy->rev < 7) ||
3710
		    !(sprom->r1.boardflags_lo & B43_BFL_EXTLNA)) {
3429
		    !(sprom->boardflags_lo & B43_BFL_EXTLNA)) {
3711
			if (phy_register == B43_PHY_RFOVER) {
3430
			if (phy_register == B43_PHY_RFOVER) {
3712
				return 0x1B3;
3431
				return 0x1B3;
3713
			} else if (phy_register == B43_PHY_RFOVERVAL) {
3432
			} else if (phy_register == B43_PHY_RFOVERVAL) {
Lines 4186-4192 int b43_radio_selectchannel(struct b43_w Link Here
4186
		b43_write16(dev, B43_MMIO_CHANNEL, channel2freq_bg(channel));
3905
		b43_write16(dev, B43_MMIO_CHANNEL, channel2freq_bg(channel));
4187
3906
4188
		if (channel == 14) {
3907
		if (channel == 14) {
4189
			if (dev->dev->bus->sprom.r1.country_code ==
3908
			if (dev->dev->bus->sprom.country_code ==
4190
			    SSB_SPROM1CCODE_JAPAN)
3909
			    SSB_SPROM1CCODE_JAPAN)
4191
				b43_hf_write(dev,
3910
				b43_hf_write(dev,
4192
					     b43_hf_read(dev) & ~B43_HF_ACPR);
3911
					     b43_hf_read(dev) & ~B43_HF_ACPR);
Lines 4210-4312 int b43_radio_selectchannel(struct b43_w Link Here
4210
	return 0;
3929
	return 0;
4211
}
3930
}
4212
3931
4213
/* http://bcm-specs.sipsolutions.net/TX_Gain_Base_Band */
4214
static u16 b43_get_txgain_base_band(u16 txpower)
4215
{
4216
	u16 ret;
4217
4218
	B43_WARN_ON(txpower > 63);
4219
4220
	if (txpower >= 54)
4221
		ret = 2;
4222
	else if (txpower >= 49)
4223
		ret = 4;
4224
	else if (txpower >= 44)
4225
		ret = 5;
4226
	else
4227
		ret = 6;
4228
4229
	return ret;
4230
}
4231
4232
/* http://bcm-specs.sipsolutions.net/TX_Gain_Radio_Frequency_Power_Amplifier */
4233
static u16 b43_get_txgain_freq_power_amp(u16 txpower)
4234
{
4235
	u16 ret;
4236
4237
	B43_WARN_ON(txpower > 63);
4238
4239
	if (txpower >= 32)
4240
		ret = 0;
4241
	else if (txpower >= 25)
4242
		ret = 1;
4243
	else if (txpower >= 20)
4244
		ret = 2;
4245
	else if (txpower >= 12)
4246
		ret = 3;
4247
	else
4248
		ret = 4;
4249
4250
	return ret;
4251
}
4252
4253
/* http://bcm-specs.sipsolutions.net/TX_Gain_Digital_Analog_Converter */
4254
static u16 b43_get_txgain_dac(u16 txpower)
4255
{
4256
	u16 ret;
4257
4258
	B43_WARN_ON(txpower > 63);
4259
4260
	if (txpower >= 54)
4261
		ret = txpower - 53;
4262
	else if (txpower >= 49)
4263
		ret = txpower - 42;
4264
	else if (txpower >= 44)
4265
		ret = txpower - 37;
4266
	else if (txpower >= 32)
4267
		ret = txpower - 32;
4268
	else if (txpower >= 25)
4269
		ret = txpower - 20;
4270
	else if (txpower >= 20)
4271
		ret = txpower - 13;
4272
	else if (txpower >= 12)
4273
		ret = txpower - 8;
4274
	else
4275
		ret = txpower;
4276
4277
	return ret;
4278
}
4279
4280
static void b43_radio_set_txpower_a(struct b43_wldev *dev, u16 txpower)
4281
{
4282
	struct b43_phy *phy = &dev->phy;
4283
	u16 pamp, base, dac, t;
4284
4285
	txpower = limit_value(txpower, 0, 63);
4286
4287
	pamp = b43_get_txgain_freq_power_amp(txpower);
4288
	pamp <<= 5;
4289
	pamp &= 0x00E0;
4290
	b43_phy_write(dev, 0x0019, pamp);
4291
4292
	base = b43_get_txgain_base_band(txpower);
4293
	base &= 0x000F;
4294
	b43_phy_write(dev, 0x0017, base | 0x0020);
4295
4296
	t = b43_ofdmtab_read16(dev, 0x3000, 1);
4297
	t &= 0x0007;
4298
4299
	dac = b43_get_txgain_dac(txpower);
4300
	dac <<= 3;
4301
	dac |= t;
4302
4303
	b43_ofdmtab_write16(dev, 0x3000, 1, dac);
4304
4305
	phy->txpwr_offset = txpower;
4306
4307
	//TODO: FuncPlaceholder (Adjust BB loft cancel)
4308
}
4309
4310
void b43_radio_turn_on(struct b43_wldev *dev)
3932
void b43_radio_turn_on(struct b43_wldev *dev)
4311
{
3933
{
4312
	struct b43_phy *phy = &dev->phy;
3934
	struct b43_phy *phy = &dev->phy;
(-)linux-2.6/drivers/net/wireless/b43/phy.h (-4 / +14 lines)
Lines 27-34 struct b43_phy; Link Here
27
#define B43_PHY_PWRDOWN			B43_PHY_OFDM(0x03)	/* Powerdown */
27
#define B43_PHY_PWRDOWN			B43_PHY_OFDM(0x03)	/* Powerdown */
28
#define B43_PHY_CRSTHRES1		B43_PHY_OFDM(0x06)	/* CRS Threshold 1 */
28
#define B43_PHY_CRSTHRES1		B43_PHY_OFDM(0x06)	/* CRS Threshold 1 */
29
#define B43_PHY_LNAHPFCTL		B43_PHY_OFDM(0x1C)	/* LNA/HPF control */
29
#define B43_PHY_LNAHPFCTL		B43_PHY_OFDM(0x1C)	/* LNA/HPF control */
30
#define B43_PHY_LPFGAINCTL		B43_PHY_OFDM(0x20)	/* LPF Gain control */
30
#define B43_PHY_ADIVRELATED		B43_PHY_OFDM(0x27)	/* FIXME rename */
31
#define B43_PHY_ADIVRELATED		B43_PHY_OFDM(0x27)	/* FIXME rename */
31
#define B43_PHY_CRS0			B43_PHY_OFDM(0x29)
32
#define B43_PHY_CRS0			B43_PHY_OFDM(0x29)
33
#define  B43_PHY_CRS0_EN		0x4000
34
#define B43_PHY_PEAK_COUNT		B43_PHY_OFDM(0x30)
32
#define B43_PHY_ANTDWELL		B43_PHY_OFDM(0x2B)	/* Antenna dwell */
35
#define B43_PHY_ANTDWELL		B43_PHY_OFDM(0x2B)	/* Antenna dwell */
33
#define  B43_PHY_ANTDWELL_AUTODIV1	0x0100	/* Automatic RX diversity start antenna */
36
#define  B43_PHY_ANTDWELL_AUTODIV1	0x0100	/* Automatic RX diversity start antenna */
34
#define B43_PHY_ENCORE			B43_PHY_OFDM(0x49)	/* "Encore" (RangeMax / BroadRange) */
37
#define B43_PHY_ENCORE			B43_PHY_OFDM(0x49)	/* "Encore" (RangeMax / BroadRange) */
Lines 37-42 struct b43_phy; Link Here
37
#define B43_PHY_OFDM61			B43_PHY_OFDM(0x61)	/* FIXME rename */
40
#define B43_PHY_OFDM61			B43_PHY_OFDM(0x61)	/* FIXME rename */
38
#define  B43_PHY_OFDM61_10		0x0010	/* FIXME rename */
41
#define  B43_PHY_OFDM61_10		0x0010	/* FIXME rename */
39
#define B43_PHY_IQBAL			B43_PHY_OFDM(0x69)	/* I/Q balance */
42
#define B43_PHY_IQBAL			B43_PHY_OFDM(0x69)	/* I/Q balance */
43
#define B43_PHY_BBTXDC_BIAS		B43_PHY_OFDM(0x6B)	/* Baseband TX DC bias */
40
#define B43_PHY_OTABLECTL		B43_PHY_OFDM(0x72)	/* OFDM table control (see below) */
44
#define B43_PHY_OTABLECTL		B43_PHY_OFDM(0x72)	/* OFDM table control (see below) */
41
#define  B43_PHY_OTABLEOFF		0x03FF	/* OFDM table offset (see below) */
45
#define  B43_PHY_OTABLEOFF		0x03FF	/* OFDM table offset (see below) */
42
#define  B43_PHY_OTABLENR		0xFC00	/* OFDM table number (see below) */
46
#define  B43_PHY_OTABLENR		0xFC00	/* OFDM table number (see below) */
Lines 44-49 struct b43_phy; Link Here
44
#define B43_PHY_OTABLEI			B43_PHY_OFDM(0x73)	/* OFDM table data I */
48
#define B43_PHY_OTABLEI			B43_PHY_OFDM(0x73)	/* OFDM table data I */
45
#define B43_PHY_OTABLEQ			B43_PHY_OFDM(0x74)	/* OFDM table data Q */
49
#define B43_PHY_OTABLEQ			B43_PHY_OFDM(0x74)	/* OFDM table data Q */
46
#define B43_PHY_HPWR_TSSICTL		B43_PHY_OFDM(0x78)	/* Hardware power TSSI control */
50
#define B43_PHY_HPWR_TSSICTL		B43_PHY_OFDM(0x78)	/* Hardware power TSSI control */
51
#define B43_PHY_ADCCTL			B43_PHY_OFDM(0x7A)	/* ADC control */
52
#define B43_PHY_IDLE_TSSI		B43_PHY_OFDM(0x7B)
53
#define B43_PHY_A_TEMP_SENSE		B43_PHY_OFDM(0x7C)	/* A PHY temperature sense */
47
#define B43_PHY_NRSSITHRES		B43_PHY_OFDM(0x8A)	/* NRSSI threshold */
54
#define B43_PHY_NRSSITHRES		B43_PHY_OFDM(0x8A)	/* NRSSI threshold */
48
#define B43_PHY_ANTWRSETT		B43_PHY_OFDM(0x8C)	/* Antenna WR settle */
55
#define B43_PHY_ANTWRSETT		B43_PHY_OFDM(0x8C)	/* Antenna WR settle */
49
#define  B43_PHY_ANTWRSETT_ARXDIV	0x2000	/* Automatic RX diversity enabled */
56
#define  B43_PHY_ANTWRSETT_ARXDIV	0x2000	/* Automatic RX diversity enabled */
Lines 54-59 struct b43_phy; Link Here
54
#define B43_PHY_N1N2GAIN		B43_PHY_OFDM(0xA2)
61
#define B43_PHY_N1N2GAIN		B43_PHY_OFDM(0xA2)
55
#define B43_PHY_CLIPTHRES		B43_PHY_OFDM(0xA3)
62
#define B43_PHY_CLIPTHRES		B43_PHY_OFDM(0xA3)
56
#define B43_PHY_CLIPN1P2THRES		B43_PHY_OFDM(0xA4)
63
#define B43_PHY_CLIPN1P2THRES		B43_PHY_OFDM(0xA4)
64
#define B43_PHY_CCKSHIFTBITS_WA		B43_PHY_OFDM(0xA5)	/* CCK shiftbits workaround, FIXME rename */
65
#define B43_PHY_CCKSHIFTBITS		B43_PHY_OFDM(0xA7)	/* FIXME rename */
57
#define B43_PHY_DIVSRCHIDX		B43_PHY_OFDM(0xA8)	/* Divider search gain/index */
66
#define B43_PHY_DIVSRCHIDX		B43_PHY_OFDM(0xA8)	/* Divider search gain/index */
58
#define B43_PHY_CLIPP2THRES		B43_PHY_OFDM(0xA9)
67
#define B43_PHY_CLIPP2THRES		B43_PHY_OFDM(0xA9)
59
#define B43_PHY_CLIPP3THRES		B43_PHY_OFDM(0xAA)
68
#define B43_PHY_CLIPP3THRES		B43_PHY_OFDM(0xAA)
Lines 125-137 struct b43_phy; Link Here
125
#define B43_OFDMTAB_DC			B43_OFDMTAB(0x0E, 7)
134
#define B43_OFDMTAB_DC			B43_OFDMTAB(0x0E, 7)
126
#define B43_OFDMTAB_PWRDYN2		B43_OFDMTAB(0x0E, 12)
135
#define B43_OFDMTAB_PWRDYN2		B43_OFDMTAB(0x0E, 12)
127
#define B43_OFDMTAB_LNAGAIN		B43_OFDMTAB(0x0E, 13)
136
#define B43_OFDMTAB_LNAGAIN		B43_OFDMTAB(0x0E, 13)
128
//TODO
137
#define B43_OFDMTAB_UNKNOWN_0F		B43_OFDMTAB(0x0F, 0)	//TODO rename
138
#define B43_OFDMTAB_UNKNOWN_APHY	B43_OFDMTAB(0x0F, 7)	//TODO rename
129
#define B43_OFDMTAB_LPFGAIN		B43_OFDMTAB(0x0F, 12)
139
#define B43_OFDMTAB_LPFGAIN		B43_OFDMTAB(0x0F, 12)
130
#define B43_OFDMTAB_RSSI		B43_OFDMTAB(0x10, 0)
140
#define B43_OFDMTAB_RSSI		B43_OFDMTAB(0x10, 0)
131
//TODO
141
#define B43_OFDMTAB_UNKNOWN_11		B43_OFDMTAB(0x11, 4)	//TODO rename
132
#define B43_OFDMTAB_AGC1_R1		B43_OFDMTAB(0x13, 0)
142
#define B43_OFDMTAB_AGC1_R1		B43_OFDMTAB(0x13, 0)
133
#define B43_OFDMTAB_GAINX_R1		B43_OFDMTAB(0x14, 0)	//TODO rename
143
#define B43_OFDMTAB_GAINX_R1		B43_OFDMTAB(0x14, 0)	//TODO remove!
134
#define B43_OFDMTAB_MINSIGSQ		B43_OFDMTAB(0x14, 1)
144
#define B43_OFDMTAB_MINSIGSQ		B43_OFDMTAB(0x14, 0)
135
#define B43_OFDMTAB_AGC3_R1		B43_OFDMTAB(0x15, 0)
145
#define B43_OFDMTAB_AGC3_R1		B43_OFDMTAB(0x15, 0)
136
#define B43_OFDMTAB_WRSSI_R1		B43_OFDMTAB(0x15, 4)
146
#define B43_OFDMTAB_WRSSI_R1		B43_OFDMTAB(0x15, 4)
137
#define B43_OFDMTAB_TSSI		B43_OFDMTAB(0x15, 0)
147
#define B43_OFDMTAB_TSSI		B43_OFDMTAB(0x15, 0)
(-)linux-2.6/drivers/net/wireless/b43/tables.c (-12 / +91 lines)
Lines 3-9 Link Here
3
  Broadcom B43 wireless driver
3
  Broadcom B43 wireless driver
4
4
5
  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
5
  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
6
  Copyright (c) 2005 Stefano Brivio <st3@riseup.net>
6
  Copyright (c) 2005-2007 Stefano Brivio <stefano.brivio@polimi.it>
7
  Copyright (c) 2006, 2006 Michael Buesch <mb@bu3sch.de>
7
  Copyright (c) 2006, 2006 Michael Buesch <mb@bu3sch.de>
8
  Copyright (c) 2005 Danny van Dyk <kugelfang@gentoo.org>
8
  Copyright (c) 2005 Danny van Dyk <kugelfang@gentoo.org>
9
  Copyright (c) 2005 Andreas Jaggi <andreas.jaggi@waterwave.ch>
9
  Copyright (c) 2005 Andreas Jaggi <andreas.jaggi@waterwave.ch>
Lines 229-235 const u16 b43_tab_noisea2[] = { Link Here
229
};
229
};
230
230
231
const u16 b43_tab_noisea3[] = {
231
const u16 b43_tab_noisea3[] = {
232
	0x4C4C, 0x4C4C, 0x4C4C, 0x2D36,
232
	0x5E5E, 0x5E5E, 0x5E5E, 0x3F48,
233
	0x4C4C, 0x4C4C, 0x4C4C, 0x2D36,
233
	0x4C4C, 0x4C4C, 0x4C4C, 0x2D36,
234
};
234
};
235
235
Lines 243-248 const u16 b43_tab_noiseg2[] = { Link Here
243
	0x0000, 0x0000, 0x0000, 0x0000,
243
	0x0000, 0x0000, 0x0000, 0x0000,
244
};
244
};
245
245
246
const u16 b43_tab_noisescalea2[] = {
247
	0x6767, 0x6767, 0x6767, 0x6767, /* 0 */
248
	0x6767, 0x6767, 0x6767, 0x6767,
249
	0x6767, 0x6767, 0x6767, 0x6767,
250
	0x6767, 0x6700, 0x6767, 0x6767,
251
	0x6767, 0x6767, 0x6767, 0x6767, /* 16 */
252
	0x6767, 0x6767, 0x6767, 0x6767,
253
	0x6767, 0x6767, 0x0067,
254
};
255
256
const u16 b43_tab_noisescalea3[] = {
257
	0x2323, 0x2323, 0x2323, 0x2323, /* 0 */
258
	0x2323, 0x2323, 0x2323, 0x2323,
259
	0x2323, 0x2323, 0x2323, 0x2323,
260
	0x2323, 0x2300, 0x2323, 0x2323,
261
	0x2323, 0x2323, 0x2323, 0x2323, /* 16 */
262
	0x2323, 0x2323, 0x2323, 0x2323,
263
	0x2323, 0x2323, 0x0023,
264
};
265
246
const u16 b43_tab_noisescaleg1[] = {
266
const u16 b43_tab_noisescaleg1[] = {
247
	0x6C77, 0x5162, 0x3B40, 0x3335,	/* 0 */
267
	0x6C77, 0x5162, 0x3B40, 0x3335,	/* 0 */
248
	0x2F2D, 0x2A2A, 0x2527, 0x1F21,
268
	0x2F2D, 0x2A2A, 0x2527, 0x1F21,
Lines 254-260 const u16 b43_tab_noisescaleg1[] = { Link Here
254
};
274
};
255
275
256
const u16 b43_tab_noisescaleg2[] = {
276
const u16 b43_tab_noisescaleg2[] = {
257
	0xD8DD, 0xCBD4, 0xBCC0, 0XB6B7,	/* 0 */
277
	0xD8DD, 0xCBD4, 0xBCC0, 0xB6B7,	/* 0 */
258
	0xB2B0, 0xADAD, 0xA7A9, 0x9FA1,
278
	0xB2B0, 0xADAD, 0xA7A9, 0x9FA1,
259
	0x969B, 0x9195, 0x8F8F, 0x8A8A,
279
	0x969B, 0x9195, 0x8F8F, 0x8A8A,
260
	0x8A8A, 0x8A00, 0x8A8A, 0x8F8A,
280
	0x8A8A, 0x8A00, 0x8A8A, 0x8F8A,
Lines 307-312 const u16 b43_tab_sigmasqr2[] = { Link Here
307
	0x00DE,
327
	0x00DE,
308
};
328
};
309
329
330
const u16 b43_tab_rssiagc1[] = {
331
	0xFFF8, 0xFFF8, 0xFFF8, 0xFFF8, /* 0 */
332
	0xFFF8, 0xFFF9, 0xFFFC, 0xFFFE,
333
	0xFFF8, 0xFFF8, 0xFFF8, 0xFFF8,
334
	0xFFF8, 0xFFF8, 0xFFF8, 0xFFF8,
335
};
336
337
const u16 b43_tab_rssiagc2[] = {
338
	0x0820, 0x0820, 0x0920, 0x0C38, /* 0 */
339
	0x0820, 0x0820, 0x0820, 0x0820,
340
	0x0820, 0x0820, 0x0920, 0x0A38,
341
	0x0820, 0x0820, 0x0820, 0x0820,
342
	0x0820, 0x0820, 0x0920, 0x0A38, /* 16 */
343
	0x0820, 0x0820, 0x0820, 0x0820,
344
	0x0820, 0x0820, 0x0920, 0x0A38,
345
	0x0820, 0x0820, 0x0820, 0x0820,
346
	0x0820, 0x0820, 0x0920, 0x0A38, /* 32 */
347
	0x0820, 0x0820, 0x0820, 0x0820,
348
	0x0820, 0x0820, 0x0920, 0x0A38,
349
	0x0820, 0x0820, 0x0820, 0x0820,
350
};
351
310
static inline void assert_sizes(void)
352
static inline void assert_sizes(void)
311
{
353
{
312
	BUILD_BUG_ON(B43_TAB_ROTOR_SIZE != ARRAY_SIZE(b43_tab_rotor));
354
	BUILD_BUG_ON(B43_TAB_ROTOR_SIZE != ARRAY_SIZE(b43_tab_rotor));
Lines 317-352 static inline void assert_sizes(void) Link Here
317
	BUILD_BUG_ON(B43_TAB_NOISEA3_SIZE != ARRAY_SIZE(b43_tab_noisea3));
359
	BUILD_BUG_ON(B43_TAB_NOISEA3_SIZE != ARRAY_SIZE(b43_tab_noisea3));
318
	BUILD_BUG_ON(B43_TAB_NOISEG1_SIZE != ARRAY_SIZE(b43_tab_noiseg1));
360
	BUILD_BUG_ON(B43_TAB_NOISEG1_SIZE != ARRAY_SIZE(b43_tab_noiseg1));
319
	BUILD_BUG_ON(B43_TAB_NOISEG2_SIZE != ARRAY_SIZE(b43_tab_noiseg2));
361
	BUILD_BUG_ON(B43_TAB_NOISEG2_SIZE != ARRAY_SIZE(b43_tab_noiseg2));
320
	BUILD_BUG_ON(B43_TAB_NOISESCALEG_SIZE !=
362
	BUILD_BUG_ON(B43_TAB_NOISESCALE_SIZE !=
363
		     ARRAY_SIZE(b43_tab_noisescalea2));
364
	BUILD_BUG_ON(B43_TAB_NOISESCALE_SIZE !=
365
		     ARRAY_SIZE(b43_tab_noisescalea3));
366
	BUILD_BUG_ON(B43_TAB_NOISESCALE_SIZE !=
321
		     ARRAY_SIZE(b43_tab_noisescaleg1));
367
		     ARRAY_SIZE(b43_tab_noisescaleg1));
322
	BUILD_BUG_ON(B43_TAB_NOISESCALEG_SIZE !=
368
	BUILD_BUG_ON(B43_TAB_NOISESCALE_SIZE !=
323
		     ARRAY_SIZE(b43_tab_noisescaleg2));
369
		     ARRAY_SIZE(b43_tab_noisescaleg2));
324
	BUILD_BUG_ON(B43_TAB_NOISESCALEG_SIZE !=
370
	BUILD_BUG_ON(B43_TAB_NOISESCALE_SIZE !=
325
		     ARRAY_SIZE(b43_tab_noisescaleg3));
371
		     ARRAY_SIZE(b43_tab_noisescaleg3));
326
	BUILD_BUG_ON(B43_TAB_SIGMASQR_SIZE != ARRAY_SIZE(b43_tab_sigmasqr1));
372
	BUILD_BUG_ON(B43_TAB_SIGMASQR_SIZE != ARRAY_SIZE(b43_tab_sigmasqr1));
327
	BUILD_BUG_ON(B43_TAB_SIGMASQR_SIZE != ARRAY_SIZE(b43_tab_sigmasqr2));
373
	BUILD_BUG_ON(B43_TAB_SIGMASQR_SIZE != ARRAY_SIZE(b43_tab_sigmasqr2));
374
	BUILD_BUG_ON(B43_TAB_RSSIAGC1_SIZE != ARRAY_SIZE(b43_tab_rssiagc1));
375
	BUILD_BUG_ON(B43_TAB_RSSIAGC2_SIZE != ARRAY_SIZE(b43_tab_rssiagc2));
328
}
376
}
329
377
330
u16 b43_ofdmtab_read16(struct b43_wldev *dev, u16 table, u16 offset)
378
u16 b43_ofdmtab_read16(struct b43_wldev *dev, u16 table, u16 offset)
331
{
379
{
332
	assert_sizes();
380
	struct b43_phy *phy = &dev->phy;
381
	u16 addr;
382
383
	addr = table + offset;
384
	if (addr - 1 != phy->ofdm_addr || phy->ofdm_valid != 1) {
385
		b43_phy_write(dev, B43_PHY_OTABLECTL, addr);
386
		phy->ofdm_valid = 1;
387
	}
388
	phy->ofdm_addr = addr;
333
389
334
	b43_phy_write(dev, B43_PHY_OTABLECTL, table + offset);
335
	return b43_phy_read(dev, B43_PHY_OTABLEI);
390
	return b43_phy_read(dev, B43_PHY_OTABLEI);
391
	assert_sizes();
336
}
392
}
337
393
338
void b43_ofdmtab_write16(struct b43_wldev *dev, u16 table,
394
void b43_ofdmtab_write16(struct b43_wldev *dev, u16 table,
339
			 u16 offset, u16 value)
395
			 u16 offset, u16 value)
340
{
396
{
341
	b43_phy_write(dev, B43_PHY_OTABLECTL, table + offset);
397
	struct b43_phy *phy = &dev->phy;
398
	u16 addr;
399
400
	addr = table + offset;
401
	if (addr - 1 != phy->ofdm_addr || phy->ofdm_valid != 2) {
402
		b43_phy_write(dev, B43_PHY_OTABLECTL, addr);
403
		phy->ofdm_valid = 2;
404
	}
405
	phy->ofdm_addr = addr;
342
	b43_phy_write(dev, B43_PHY_OTABLEI, value);
406
	b43_phy_write(dev, B43_PHY_OTABLEI, value);
343
}
407
}
344
408
345
u32 b43_ofdmtab_read32(struct b43_wldev *dev, u16 table, u16 offset)
409
u32 b43_ofdmtab_read32(struct b43_wldev *dev, u16 table, u16 offset)
346
{
410
{
411
	struct b43_phy *phy = &dev->phy;
347
	u32 ret;
412
	u32 ret;
413
	u16 addr;
348
414
349
	b43_phy_write(dev, B43_PHY_OTABLECTL, table + offset);
415
	addr = table + offset;
416
	if (addr - 1 != phy->ofdm_addr || phy->ofdm_valid != 1) {
417
		b43_phy_write(dev, B43_PHY_OTABLECTL, addr);
418
		phy->ofdm_valid = 1;
419
	}
420
	phy->ofdm_addr = addr;
350
	ret = b43_phy_read(dev, B43_PHY_OTABLEQ);
421
	ret = b43_phy_read(dev, B43_PHY_OTABLEQ);
351
	ret <<= 16;
422
	ret <<= 16;
352
	ret |= b43_phy_read(dev, B43_PHY_OTABLEI);
423
	ret |= b43_phy_read(dev, B43_PHY_OTABLEI);
Lines 357-365 u32 b43_ofdmtab_read32(struct b43_wldev Link Here
357
void b43_ofdmtab_write32(struct b43_wldev *dev, u16 table,
428
void b43_ofdmtab_write32(struct b43_wldev *dev, u16 table,
358
			 u16 offset, u32 value)
429
			 u16 offset, u32 value)
359
{
430
{
360
	b43_phy_write(dev, B43_PHY_OTABLECTL, table + offset);
431
	struct b43_phy *phy = &dev->phy;
432
	u16 addr;
433
434
	addr = table + offset;
435
	if (addr - 1 != phy->ofdm_addr || phy->ofdm_valid != 2) {
436
		b43_phy_write(dev, B43_PHY_OTABLECTL, addr);
437
		phy->ofdm_valid = 2;
438
	}
439
	phy->ofdm_addr = addr;
440
361
	b43_phy_write(dev, B43_PHY_OTABLEI, value);
441
	b43_phy_write(dev, B43_PHY_OTABLEI, value);
362
	b43_phy_write(dev, B43_PHY_OTABLEQ, (value >> 16));
363
}
442
}
364
443
365
u16 b43_gtab_read(struct b43_wldev *dev, u16 table, u16 offset)
444
u16 b43_gtab_read(struct b43_wldev *dev, u16 table, u16 offset)
(-)linux-2.6/drivers/net/wireless/b43/tables.h (-3 / +9 lines)
Lines 1-9 Link Here
1
#ifndef B43_TABLES_H_
1
#ifndef B43_TABLES_H_
2
#define B43_TABLES_H_
2
#define B43_TABLES_H_
3
3
4
#define B43_TAB_ROTOR_SIZE		53
4
#define B43_TAB_ROTOR_SIZE	53
5
extern const u32 b43_tab_rotor[];
5
extern const u32 b43_tab_rotor[];
6
#define B43_TAB_RETARD_SIZE		53
6
#define B43_TAB_RETARD_SIZE	53
7
extern const u32 b43_tab_retard[];
7
extern const u32 b43_tab_retard[];
8
#define B43_TAB_FINEFREQA_SIZE	256
8
#define B43_TAB_FINEFREQA_SIZE	256
9
extern const u16 b43_tab_finefreqa[];
9
extern const u16 b43_tab_finefreqa[];
Lines 17-28 extern const u16 b43_tab_noisea3[]; Link Here
17
extern const u16 b43_tab_noiseg1[];
17
extern const u16 b43_tab_noiseg1[];
18
#define B43_TAB_NOISEG2_SIZE	8
18
#define B43_TAB_NOISEG2_SIZE	8
19
extern const u16 b43_tab_noiseg2[];
19
extern const u16 b43_tab_noiseg2[];
20
#define B43_TAB_NOISESCALEG_SIZE	27
20
#define B43_TAB_NOISESCALE_SIZE	27
21
extern const u16 b43_tab_noisescalea2[];
22
extern const u16 b43_tab_noisescalea3[];
21
extern const u16 b43_tab_noisescaleg1[];
23
extern const u16 b43_tab_noisescaleg1[];
22
extern const u16 b43_tab_noisescaleg2[];
24
extern const u16 b43_tab_noisescaleg2[];
23
extern const u16 b43_tab_noisescaleg3[];
25
extern const u16 b43_tab_noisescaleg3[];
24
#define B43_TAB_SIGMASQR_SIZE	53
26
#define B43_TAB_SIGMASQR_SIZE	53
25
extern const u16 b43_tab_sigmasqr1[];
27
extern const u16 b43_tab_sigmasqr1[];
26
extern const u16 b43_tab_sigmasqr2[];
28
extern const u16 b43_tab_sigmasqr2[];
29
#define B43_TAB_RSSIAGC1_SIZE	16
30
extern const u16 b43_tab_rssiagc1[];
31
#define B43_TAB_RSSIAGC2_SIZE	48
32
extern const u16 b43_tab_rssiagc2[];
27
33
28
#endif /* B43_TABLES_H_ */
34
#endif /* B43_TABLES_H_ */
(-)linux-2.6/drivers/net/wireless/b43/wa.c (+666 lines)
Line 0 Link Here
1
/*
2
3
  Broadcom B43 wireless driver
4
5
  PHY workarounds.
6
7
  Copyright (c) 2005-2007 Stefano Brivio <stefano.brivio@polimi.it>
8
  Copyright (c) 2005-2007 Michael Buesch <mbuesch@freenet.de>
9
10
  This program is free software; you can redistribute it and/or modify
11
  it under the terms of the GNU General Public License as published by
12
  the Free Software Foundation; either version 2 of the License, or
13
  (at your option) any later version.
14
15
  This program is distributed in the hope that it will be useful,
16
  but WITHOUT ANY WARRANTY; without even the implied warranty of
17
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18
  GNU General Public License for more details.
19
20
  You should have received a copy of the GNU General Public License
21
  along with this program; see the file COPYING.  If not, write to
22
  the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
23
  Boston, MA 02110-1301, USA.
24
25
*/
26
27
#include "b43.h"
28
#include "main.h"
29
#include "tables.h"
30
#include "phy.h"
31
#include "wa.h"
32
33
static void b43_wa_papd(struct b43_wldev *dev)
34
{
35
	u16 backup;
36
37
	backup = b43_ofdmtab_read16(dev, B43_OFDMTAB_PWRDYN2, 0);
38
	b43_ofdmtab_write16(dev, B43_OFDMTAB_PWRDYN2, 0, 7);
39
	b43_ofdmtab_write16(dev, B43_OFDMTAB_UNKNOWN_APHY, 0, 0);
40
	b43_dummy_transmission(dev);
41
	b43_ofdmtab_write16(dev, B43_OFDMTAB_PWRDYN2, 0, backup);
42
}
43
44
static void b43_wa_auxclipthr(struct b43_wldev *dev)
45
{
46
	b43_phy_write(dev, B43_PHY_OFDM(0x8E), 0x3800);
47
}
48
49
static void b43_wa_afcdac(struct b43_wldev *dev)
50
{
51
	b43_phy_write(dev, 0x0035, 0x03FF);
52
	b43_phy_write(dev, 0x0036, 0x0400);
53
}
54
55
static void b43_wa_txdc_offset(struct b43_wldev *dev)
56
{
57
	b43_ofdmtab_write16(dev, B43_OFDMTAB_DC, 0, 0x0051);
58
}
59
60
void b43_wa_initgains(struct b43_wldev *dev)
61
{
62
	struct b43_phy *phy = &dev->phy;
63
64
	b43_phy_write(dev, B43_PHY_LNAHPFCTL, 0x1FF9);
65
	b43_phy_write(dev, B43_PHY_LPFGAINCTL,
66
		b43_phy_read(dev, B43_PHY_LPFGAINCTL) & 0xFF0F);
67
	if (phy->rev <= 2)
68
		b43_ofdmtab_write16(dev, B43_OFDMTAB_LPFGAIN, 0, 0x1FBF);
69
	b43_radio_write16(dev, 0x0002, 0x1FBF);
70
71
	b43_phy_write(dev, 0x0024, 0x4680);
72
	b43_phy_write(dev, 0x0020, 0x0003);
73
	b43_phy_write(dev, 0x001D, 0x0F40);
74
	b43_phy_write(dev, 0x001F, 0x1C00);
75
	if (phy->rev <= 3)
76
		b43_phy_write(dev, 0x002A,
77
			(b43_phy_read(dev, 0x002A) & 0x00FF) | 0x0400);
78
	else if (phy->rev == 5) {
79
		b43_phy_write(dev, 0x002A,
80
			(b43_phy_read(dev, 0x002A) & 0x00FF) | 0x1A00);
81
		b43_phy_write(dev, 0x00CC, 0x2121);
82
	}
83
	if (phy->rev >= 3)
84
		b43_phy_write(dev, 0x00BA, 0x3ED5);
85
}
86
87
static void b43_wa_divider(struct b43_wldev *dev)
88
{
89
	b43_phy_write(dev, 0x002B, b43_phy_read(dev, 0x002B) & ~0x0100);
90
	b43_phy_write(dev, 0x008E, 0x58C1);
91
}
92
93
static void b43_wa_gt(struct b43_wldev *dev) /* Gain table. */
94
{
95
	if (dev->phy.rev <= 2) {
96
		b43_ofdmtab_write16(dev, B43_OFDMTAB_GAIN2, 0, 15);
97
		b43_ofdmtab_write16(dev, B43_OFDMTAB_GAIN2, 1, 31);
98
		b43_ofdmtab_write16(dev, B43_OFDMTAB_GAIN2, 2, 42);
99
		b43_ofdmtab_write16(dev, B43_OFDMTAB_GAIN2, 3, 48);
100
		b43_ofdmtab_write16(dev, B43_OFDMTAB_GAIN2, 4, 58);
101
		b43_ofdmtab_write16(dev, B43_OFDMTAB_GAIN0, 0, 19);
102
		b43_ofdmtab_write16(dev, B43_OFDMTAB_GAIN0, 1, 19);
103
		b43_ofdmtab_write16(dev, B43_OFDMTAB_GAIN0, 2, 19);
104
		b43_ofdmtab_write16(dev, B43_OFDMTAB_GAIN0, 3, 19);
105
		b43_ofdmtab_write16(dev, B43_OFDMTAB_GAIN0, 4, 21);
106
		b43_ofdmtab_write16(dev, B43_OFDMTAB_GAIN0, 5, 21);
107
		b43_ofdmtab_write16(dev, B43_OFDMTAB_GAIN0, 6, 25);
108
		b43_ofdmtab_write16(dev, B43_OFDMTAB_GAIN1, 0, 3);
109
		b43_ofdmtab_write16(dev, B43_OFDMTAB_GAIN1, 1, 3);
110
		b43_ofdmtab_write16(dev, B43_OFDMTAB_GAIN1, 2, 7);
111
	} else {
112
		b43_ofdmtab_write16(dev, B43_OFDMTAB_GAIN0, 0, 19);
113
		b43_ofdmtab_write16(dev, B43_OFDMTAB_GAIN0, 1, 19);
114
		b43_ofdmtab_write16(dev, B43_OFDMTAB_GAIN0, 2, 19);
115
		b43_ofdmtab_write16(dev, B43_OFDMTAB_GAIN0, 3, 19);
116
		b43_ofdmtab_write16(dev, B43_OFDMTAB_GAIN0, 4, 21);
117
		b43_ofdmtab_write16(dev, B43_OFDMTAB_GAIN0, 5, 21);
118
		b43_ofdmtab_write16(dev, B43_OFDMTAB_GAIN0, 6, 25);
119
	}
120
}
121
122
static void b43_wa_rssi_lt(struct b43_wldev *dev) /* RSSI lookup table */
123
{
124
	int i;
125
126
	for (i = 0; i < 8; i++)
127
		b43_ofdmtab_write16(dev, B43_OFDMTAB_RSSI, i, i + 8);
128
	for (i = 8; i < 16; i++)
129
		b43_ofdmtab_write16(dev, B43_OFDMTAB_RSSI, i, i - 8);
130
}
131
132
static void b43_wa_analog(struct b43_wldev *dev)
133
{
134
	struct b43_phy *phy = &dev->phy;
135
136
	if (phy->analog > 2) {
137
		if (phy->type == B43_PHYTYPE_A)
138
			b43_phy_write(dev, B43_PHY_PWRDOWN, 0x1808);
139
		else
140
			b43_phy_write(dev, B43_PHY_PWRDOWN, 0x1000);
141
	} else {
142
		b43_ofdmtab_write16(dev, B43_OFDMTAB_DAC, 3, 0x1044);
143
		b43_ofdmtab_write16(dev, B43_OFDMTAB_DAC, 4, 0x7201);
144
		b43_ofdmtab_write16(dev, B43_OFDMTAB_DAC, 6, 0x0040);
145
	}
146
}
147
148
static void b43_wa_dac(struct b43_wldev *dev)
149
{
150
	if (dev->phy.analog == 1)
151
		b43_ofdmtab_write16(dev, B43_OFDMTAB_DAC, 1,
152
			(b43_ofdmtab_read16(dev, B43_OFDMTAB_DAC, 1) & ~0x0034) | 0x0008);
153
	else
154
		b43_ofdmtab_write16(dev, B43_OFDMTAB_DAC, 1,
155
			(b43_ofdmtab_read16(dev, B43_OFDMTAB_DAC, 1) & ~0x0078) | 0x0010);
156
}
157
158
static void b43_wa_fft(struct b43_wldev *dev) /* Fine frequency table */
159
{
160
	int i;
161
162
	if (dev->phy.type == B43_PHYTYPE_A)
163
		for (i = 0; i < B43_TAB_FINEFREQA_SIZE; i++)
164
			b43_ofdmtab_write16(dev, B43_OFDMTAB_DACRFPABB, i, b43_tab_finefreqa[i]);
165
	else
166
		for (i = 0; i < B43_TAB_FINEFREQG_SIZE; i++)
167
			b43_ofdmtab_write16(dev, B43_OFDMTAB_DACRFPABB, i, b43_tab_finefreqg[i]);
168
}
169
170
static void b43_wa_nft(struct b43_wldev *dev) /* Noise figure table */
171
{
172
	struct b43_phy *phy = &dev->phy;
173
	int i;
174
175
	if (phy->type == B43_PHYTYPE_A) {
176
		if (phy->rev == 2)
177
			for (i = 0; i < B43_TAB_NOISEA2_SIZE; i++)
178
				b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC2, i, b43_tab_noisea2[i]);
179
		else
180
			for (i = 0; i < B43_TAB_NOISEA3_SIZE; i++)
181
				b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC2, i, b43_tab_noisea3[i]);
182
	} else {
183
		if (phy->rev == 1)
184
			for (i = 0; i < B43_TAB_NOISEG1_SIZE; i++)
185
				b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC2, i, b43_tab_noiseg1[i]);
186
		else
187
			for (i = 0; i < B43_TAB_NOISEG2_SIZE; i++)
188
				b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC2, i, b43_tab_noiseg2[i]);
189
	}
190
}
191
192
static void b43_wa_rt(struct b43_wldev *dev) /* Rotor table */
193
{
194
	int i;
195
196
	for (i = 0; i < B43_TAB_ROTOR_SIZE; i++)
197
		b43_ofdmtab_write32(dev, B43_OFDMTAB_ROTOR, i, b43_tab_rotor[i]);
198
}
199
200
static void b43_wa_nst(struct b43_wldev *dev) /* Noise scale table */
201
{
202
	struct b43_phy *phy = &dev->phy;
203
	int i;
204
205
	if (phy->type == B43_PHYTYPE_A) {
206
		if (phy->rev <= 1)
207
			for (i = 0; i < B43_TAB_NOISESCALE_SIZE; i++)
208
				b43_ofdmtab_write16(dev, B43_OFDMTAB_NOISESCALE,
209
							i, 0);
210
		else if (phy->rev == 2)
211
			for (i = 0; i < B43_TAB_NOISESCALE_SIZE; i++)
212
				b43_ofdmtab_write16(dev, B43_OFDMTAB_NOISESCALE,
213
							i, b43_tab_noisescalea2[i]);
214
		else if (phy->rev == 3)
215
			for (i = 0; i < B43_TAB_NOISESCALE_SIZE; i++)
216
				b43_ofdmtab_write16(dev, B43_OFDMTAB_NOISESCALE,
217
							i, b43_tab_noisescalea3[i]);
218
		else
219
			for (i = 0; i < B43_TAB_NOISESCALE_SIZE; i++)
220
				b43_ofdmtab_write16(dev, B43_OFDMTAB_NOISESCALE,
221
							i, b43_tab_noisescaleg3[i]);
222
	} else {
223
		if (phy->rev >= 6) {
224
			if (b43_phy_read(dev, B43_PHY_ENCORE) & B43_PHY_ENCORE_EN)
225
				for (i = 0; i < B43_TAB_NOISESCALE_SIZE; i++)
226
					b43_ofdmtab_write16(dev, B43_OFDMTAB_NOISESCALE,
227
						i, b43_tab_noisescaleg3[i]);
228
			else
229
				for (i = 0; i < B43_TAB_NOISESCALE_SIZE; i++)
230
					b43_ofdmtab_write16(dev, B43_OFDMTAB_NOISESCALE,
231
						i, b43_tab_noisescaleg2[i]);
232
		} else {
233
			for (i = 0; i < B43_TAB_NOISESCALE_SIZE; i++)
234
				b43_ofdmtab_write16(dev, B43_OFDMTAB_NOISESCALE,
235
							i, b43_tab_noisescaleg1[i]);
236
		}
237
	}
238
}
239
240
static void b43_wa_art(struct b43_wldev *dev) /* ADV retard table */
241
{
242
	int i;
243
244
	for (i = 0; i < B43_TAB_RETARD_SIZE; i++)
245
			b43_ofdmtab_write32(dev, B43_OFDMTAB_ADVRETARD,
246
				i, b43_tab_retard[i]);
247
}
248
249
static void b43_wa_txlna_gain(struct b43_wldev *dev)
250
{
251
	b43_ofdmtab_write16(dev, B43_OFDMTAB_DC, 13, 0x0000);
252
}
253
254
static void b43_wa_crs_reset(struct b43_wldev *dev)
255
{
256
	b43_phy_write(dev, 0x002C, 0x0064);
257
}
258
259
static void b43_wa_2060txlna_gain(struct b43_wldev *dev)
260
{
261
	b43_hf_write(dev, b43_hf_read(dev) |
262
			 B43_HF_2060W);
263
}
264
265
static void b43_wa_lms(struct b43_wldev *dev)
266
{
267
	b43_phy_write(dev, 0x0055,
268
		(b43_phy_read(dev, 0x0055) & 0xFFC0) | 0x0004);
269
}
270
271
static void b43_wa_mixedsignal(struct b43_wldev *dev)
272
{
273
	b43_ofdmtab_write16(dev, B43_OFDMTAB_DAC, 1, 3);
274
}
275
276
static void b43_wa_msst(struct b43_wldev *dev) /* Min sigma square table */
277
{
278
	struct b43_phy *phy = &dev->phy;
279
	int i;
280
	const u16 *tab;
281
282
	if (phy->type == B43_PHYTYPE_A) {
283
		tab = b43_tab_sigmasqr1;
284
	} else if (phy->type == B43_PHYTYPE_G) {
285
		tab = b43_tab_sigmasqr2;
286
	} else {
287
		B43_WARN_ON(1);
288
		return;
289
	}
290
291
	for (i = 0; i < B43_TAB_SIGMASQR_SIZE; i++) {
292
		b43_ofdmtab_write16(dev, B43_OFDMTAB_MINSIGSQ,
293
					i, tab[i]);
294
	}
295
}
296
297
static void b43_wa_iqadc(struct b43_wldev *dev)
298
{
299
	if (dev->phy.analog == 4)
300
		b43_ofdmtab_write16(dev, B43_OFDMTAB_DAC, 0,
301
			b43_ofdmtab_read16(dev, B43_OFDMTAB_DAC, 0) & ~0xF000);
302
}
303
304
static void b43_wa_crs_ed(struct b43_wldev *dev)
305
{
306
	struct b43_phy *phy = &dev->phy;
307
308
	if (phy->rev == 1) {
309
		b43_phy_write(dev, B43_PHY_CRSTHRES1, 0x4F19);
310
	} else if (phy->rev == 2) {
311
		b43_phy_write(dev, B43_PHY_CRSTHRES1_R1, 0x1861);
312
		b43_phy_write(dev, B43_PHY_CRSTHRES2_R1, 0x1861);
313
		b43_phy_write(dev, B43_PHY_ANTDWELL,
314
				  b43_phy_read(dev, B43_PHY_ANTDWELL)
315
				  | 0x0800);
316
	} else {
317
		b43_phy_write(dev, B43_PHY_CRSTHRES1_R1, 0x0098);
318
		b43_phy_write(dev, B43_PHY_CRSTHRES2_R1, 0x0070);
319
		b43_phy_write(dev, B43_PHY_OFDM(0xC9), 0x0080);
320
		b43_phy_write(dev, B43_PHY_ANTDWELL,
321
				  b43_phy_read(dev, B43_PHY_ANTDWELL)
322
				  | 0x0800);
323
	}
324
}
325
326
static void b43_wa_crs_thr(struct b43_wldev *dev)
327
{
328
	b43_phy_write(dev, B43_PHY_CRS0,
329
			(b43_phy_read(dev, B43_PHY_CRS0) & ~0x03C0) | 0xD000);
330
}
331
332
static void b43_wa_crs_blank(struct b43_wldev *dev)
333
{
334
	b43_phy_write(dev, B43_PHY_OFDM(0x2C), 0x005A);
335
}
336
337
static void b43_wa_cck_shiftbits(struct b43_wldev *dev)
338
{
339
	b43_phy_write(dev, B43_PHY_CCKSHIFTBITS, 0x0026);
340
}
341
342
static void b43_wa_wrssi_offset(struct b43_wldev *dev)
343
{
344
	int i;
345
346
	if (dev->phy.rev == 1) {
347
		for (i = 0; i < 16; i++) {
348
			b43_ofdmtab_write16(dev, B43_OFDMTAB_WRSSI_R1,
349
						i, 0x0020);
350
		}
351
	} else {
352
		for (i = 0; i < 32; i++) {
353
			b43_ofdmtab_write16(dev, B43_OFDMTAB_WRSSI,
354
						i, 0x0820);
355
		}
356
	}
357
}
358
359
static void b43_wa_txpuoff_rxpuon(struct b43_wldev *dev)
360
{
361
	b43_ofdmtab_write16(dev, B43_OFDMTAB_UNKNOWN_0F, 2, 15);
362
	b43_ofdmtab_write16(dev, B43_OFDMTAB_UNKNOWN_0F, 3, 20);
363
}
364
365
static void b43_wa_altagc(struct b43_wldev *dev)
366
{
367
	struct b43_phy *phy = &dev->phy;
368
369
	if (phy->rev == 1) {
370
		b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC1_R1, 0, 254);
371
		b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC1_R1, 1, 13);
372
		b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC1_R1, 2, 19);
373
		b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC1_R1, 3, 25);
374
		b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC2, 0, 0x2710);
375
		b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC2, 1, 0x9B83);
376
		b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC2, 2, 0x9B83);
377
		b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC2, 3, 0x0F8D);
378
		b43_phy_write(dev, B43_PHY_LMS, 4);
379
	} else {
380
		b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC1, 0, 254);
381
		b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC1, 1, 13);
382
		b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC1, 2, 19);
383
		b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC1, 3, 25);
384
	}
385
386
	b43_phy_write(dev, B43_PHY_CCKSHIFTBITS_WA,
387
		(b43_phy_read(dev, B43_PHY_CCKSHIFTBITS_WA) & ~0xFF00) | 0x5700);
388
	b43_phy_write(dev, B43_PHY_OFDM(0x1A),
389
		(b43_phy_read(dev, B43_PHY_OFDM(0x1A)) & ~0x007F) | 0x000F);
390
	b43_phy_write(dev, B43_PHY_OFDM(0x1A),
391
		(b43_phy_read(dev, B43_PHY_OFDM(0x1A)) & ~0x3F80) | 0x2B80);
392
	b43_phy_write(dev, B43_PHY_ANTWRSETT,
393
		(b43_phy_read(dev, B43_PHY_ANTWRSETT) & 0xF0FF) | 0x0300);
394
	b43_radio_write16(dev, 0x7A,
395
		b43_radio_read16(dev, 0x7A) | 0x0008);
396
	b43_phy_write(dev, B43_PHY_N1P1GAIN,
397
		(b43_phy_read(dev, B43_PHY_N1P1GAIN) & ~0x000F) | 0x0008);
398
	b43_phy_write(dev, B43_PHY_P1P2GAIN,
399
		(b43_phy_read(dev, B43_PHY_P1P2GAIN) & ~0x0F00) | 0x0600);
400
	b43_phy_write(dev, B43_PHY_N1N2GAIN,
401
		(b43_phy_read(dev, B43_PHY_N1N2GAIN) & ~0x0F00) | 0x0700);
402
	b43_phy_write(dev, B43_PHY_N1P1GAIN,
403
		(b43_phy_read(dev, B43_PHY_N1P1GAIN) & ~0x0F00) | 0x0100);
404
	if (phy->rev == 1) {
405
		b43_phy_write(dev, B43_PHY_N1N2GAIN,
406
				  (b43_phy_read(dev, B43_PHY_N1N2GAIN)
407
				   & ~0x000F) | 0x0007);
408
	}
409
	b43_phy_write(dev, B43_PHY_OFDM(0x88),
410
		(b43_phy_read(dev, B43_PHY_OFDM(0x88)) & ~0x00FF) | 0x001C);
411
	b43_phy_write(dev, B43_PHY_OFDM(0x88),
412
		(b43_phy_read(dev, B43_PHY_OFDM(0x88)) & ~0x3F00) | 0x0200);
413
	b43_phy_write(dev, B43_PHY_OFDM(0x96),
414
		(b43_phy_read(dev, B43_PHY_OFDM(0x96)) & ~0x00FF) | 0x001C);
415
	b43_phy_write(dev, B43_PHY_OFDM(0x89),
416
		(b43_phy_read(dev, B43_PHY_OFDM(0x89)) & ~0x00FF) | 0x0020);
417
	b43_phy_write(dev, B43_PHY_OFDM(0x89),
418
		(b43_phy_read(dev, B43_PHY_OFDM(0x89)) & ~0x3F00) | 0x0200);
419
	b43_phy_write(dev, B43_PHY_OFDM(0x82),
420
		(b43_phy_read(dev, B43_PHY_OFDM(0x82)) & ~0x00FF) | 0x002E);
421
	b43_phy_write(dev, B43_PHY_OFDM(0x96),
422
		(b43_phy_read(dev, B43_PHY_OFDM(0x96)) & ~0xFF00) | 0x1A00);
423
	b43_phy_write(dev, B43_PHY_OFDM(0x81),
424
		(b43_phy_read(dev, B43_PHY_OFDM(0x81)) & ~0x00FF) | 0x0028);
425
	b43_phy_write(dev, B43_PHY_OFDM(0x81),
426
		(b43_phy_read(dev, B43_PHY_OFDM(0x81)) & ~0xFF00) | 0x2C00);
427
	if (phy->rev == 1) {
428
		b43_phy_write(dev, B43_PHY_PEAK_COUNT, 0x092B);
429
		b43_phy_write(dev, B43_PHY_OFDM(0x1B),
430
			(b43_phy_read(dev, B43_PHY_OFDM(0x1B)) & ~0x001E) | 0x0002);
431
	} else {
432
		b43_phy_write(dev, B43_PHY_OFDM(0x1B),
433
			b43_phy_read(dev, B43_PHY_OFDM(0x1B)) & ~0x001E);
434
		b43_phy_write(dev, B43_PHY_OFDM(0x1F), 0x287A);
435
		b43_phy_write(dev, B43_PHY_LPFGAINCTL,
436
			(b43_phy_read(dev, B43_PHY_LPFGAINCTL) & ~0x000F) | 0x0004);
437
		if (phy->rev >= 6) {
438
			b43_phy_write(dev, B43_PHY_OFDM(0x22), 0x287A);
439
			b43_phy_write(dev, B43_PHY_LPFGAINCTL,
440
				(b43_phy_read(dev, B43_PHY_LPFGAINCTL) & ~0xF000) | 0x3000);
441
		}
442
	}
443
	b43_phy_write(dev, B43_PHY_DIVSRCHIDX,
444
		(b43_phy_read(dev, B43_PHY_DIVSRCHIDX) & 0x7F7F) | 0x7874);
445
	b43_phy_write(dev, B43_PHY_OFDM(0x8E), 0x1C00);
446
	if (phy->rev == 1) {
447
		b43_phy_write(dev, B43_PHY_DIVP1P2GAIN,
448
			(b43_phy_read(dev, B43_PHY_DIVP1P2GAIN) & ~0x0F00) | 0x0600);
449
		b43_phy_write(dev, B43_PHY_OFDM(0x8B), 0x005E);
450
		b43_phy_write(dev, B43_PHY_ANTWRSETT,
451
			(b43_phy_read(dev, B43_PHY_ANTWRSETT) & ~0x00FF) | 0x001E);
452
		b43_phy_write(dev, B43_PHY_OFDM(0x8D), 0x0002);
453
		b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC3_R1, 0, 0);
454
		b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC3_R1, 1, 7);
455
		b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC3_R1, 2, 16);
456
		b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC3_R1, 3, 28);
457
	} else {
458
		b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC3, 0, 0);
459
		b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC3, 1, 7);
460
		b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC3, 2, 16);
461
		b43_ofdmtab_write16(dev, B43_OFDMTAB_AGC3, 3, 28);
462
	}
463
	if (phy->rev >= 6) {
464
		b43_phy_write(dev, B43_PHY_OFDM(0x26),
465
			b43_phy_read(dev, B43_PHY_OFDM(0x26)) & ~0x0003);
466
		b43_phy_write(dev, B43_PHY_OFDM(0x26),
467
			b43_phy_read(dev, B43_PHY_OFDM(0x26)) & ~0x1000);
468
	}
469
}
470
471
static void b43_wa_tr_ltov(struct b43_wldev *dev) /* TR Lookup Table Original Values */
472
{
473
	b43_gtab_write(dev, B43_GTAB_ORIGTR, 0, 0xC480);
474
}
475
476
static void b43_wa_cpll_nonpilot(struct b43_wldev *dev)
477
{
478
	b43_ofdmtab_write16(dev, B43_OFDMTAB_UNKNOWN_11, 0, 0);
479
	b43_ofdmtab_write16(dev, B43_OFDMTAB_UNKNOWN_11, 1, 0);
480
}
481
482
static void b43_wa_rssi_adc(struct b43_wldev *dev)
483
{
484
	if (dev->phy.analog == 4)
485
		b43_phy_write(dev, 0x00DC, 0x7454);
486
}
487
488
static void b43_wa_boards_a(struct b43_wldev *dev)
489
{
490
	struct ssb_bus *bus = dev->dev->bus;
491
492
	if (bus->boardinfo.vendor == SSB_BOARDVENDOR_BCM &&
493
	    bus->boardinfo.type == SSB_BOARD_BU4306 &&
494
	    bus->boardinfo.rev < 0x30) {
495
		b43_phy_write(dev, 0x0010, 0xE000);
496
		b43_phy_write(dev, 0x0013, 0x0140);
497
		b43_phy_write(dev, 0x0014, 0x0280);
498
	} else {
499
		if (bus->boardinfo.type == SSB_BOARD_MP4318 &&
500
		    bus->boardinfo.rev < 0x20) {
501
			b43_phy_write(dev, 0x0013, 0x0210);
502
			b43_phy_write(dev, 0x0014, 0x0840);
503
		} else {
504
			b43_phy_write(dev, 0x0013, 0x0140);
505
			b43_phy_write(dev, 0x0014, 0x0280);
506
		}
507
		if (dev->phy.rev <= 4)
508
			b43_phy_write(dev, 0x0010, 0xE000);
509
		else
510
			b43_phy_write(dev, 0x0010, 0x2000);
511
		b43_ofdmtab_write16(dev, B43_OFDMTAB_DC, 1, 0x0039);
512
		b43_ofdmtab_write16(dev, B43_OFDMTAB_UNKNOWN_APHY, 7, 0x0040);
513
	}
514
}
515
516
static void b43_wa_boards_g(struct b43_wldev *dev)
517
{
518
	struct ssb_bus *bus = dev->dev->bus;
519
	struct b43_phy *phy = &dev->phy;
520
521
	if (bus->boardinfo.vendor != SSB_BOARDVENDOR_BCM ||
522
	    bus->boardinfo.type != SSB_BOARD_BU4306 ||
523
	    bus->boardinfo.rev != 0x17) {
524
		if (phy->rev < 2) {
525
			b43_ofdmtab_write16(dev, B43_OFDMTAB_GAINX_R1, 1, 0x0002);
526
			b43_ofdmtab_write16(dev, B43_OFDMTAB_GAINX_R1, 2, 0x0001);
527
		} else {
528
			b43_ofdmtab_write16(dev, B43_OFDMTAB_GAINX, 1, 0x0002);
529
			b43_ofdmtab_write16(dev, B43_OFDMTAB_GAINX, 2, 0x0001);
530
			if ((bus->sprom.boardflags_lo & B43_BFL_EXTLNA) &&
531
			    (phy->rev >= 7)) {
532
				b43_phy_write(dev, B43_PHY_EXTG(0x11),
533
					b43_phy_read(dev, B43_PHY_EXTG(0x11)) & 0xF7FF);
534
				b43_ofdmtab_write16(dev, B43_OFDMTAB_GAINX, 0x0020, 0x0001);
535
				b43_ofdmtab_write16(dev, B43_OFDMTAB_GAINX, 0x0021, 0x0001);
536
				b43_ofdmtab_write16(dev, B43_OFDMTAB_GAINX, 0x0022, 0x0001);
537
				b43_ofdmtab_write16(dev, B43_OFDMTAB_GAINX, 0x0023, 0x0000);
538
				b43_ofdmtab_write16(dev, B43_OFDMTAB_GAINX, 0x0000, 0x0000);
539
				b43_ofdmtab_write16(dev, B43_OFDMTAB_GAINX, 0x0003, 0x0002);
540
			}
541
		}
542
	}
543
	if (bus->sprom.boardflags_lo & B43_BFL_FEM) {
544
		b43_phy_write(dev, B43_PHY_GTABCTL, 0x3120);
545
		b43_phy_write(dev, B43_PHY_GTABDATA, 0xC480);
546
	}
547
}
548
549
void b43_wa_all(struct b43_wldev *dev)
550
{
551
	struct b43_phy *phy = &dev->phy;
552
553
	if (phy->type == B43_PHYTYPE_A) {
554
		switch (phy->rev) {
555
		case 2:
556
			b43_wa_papd(dev);
557
			b43_wa_auxclipthr(dev);
558
			b43_wa_afcdac(dev);
559
			b43_wa_txdc_offset(dev);
560
			b43_wa_initgains(dev);
561
			b43_wa_divider(dev);
562
			b43_wa_gt(dev);
563
			b43_wa_rssi_lt(dev);
564
			b43_wa_analog(dev);
565
			b43_wa_dac(dev);
566
			b43_wa_fft(dev);
567
			b43_wa_nft(dev);
568
			b43_wa_rt(dev);
569
			b43_wa_nst(dev);
570
			b43_wa_art(dev);
571
			b43_wa_txlna_gain(dev);
572
			b43_wa_crs_reset(dev);
573
			b43_wa_2060txlna_gain(dev);
574
			b43_wa_lms(dev);
575
			break;
576
		case 3:
577
			b43_wa_papd(dev);
578
			b43_wa_mixedsignal(dev);
579
			b43_wa_rssi_lt(dev);
580
			b43_wa_txdc_offset(dev);
581
			b43_wa_initgains(dev);
582
			b43_wa_dac(dev);
583
			b43_wa_nft(dev);
584
			b43_wa_nst(dev);
585
			b43_wa_msst(dev);
586
			b43_wa_analog(dev);
587
			b43_wa_gt(dev);
588
			b43_wa_txpuoff_rxpuon(dev);
589
			b43_wa_txlna_gain(dev);
590
			break;
591
		case 5:
592
			b43_wa_iqadc(dev);
593
		case 6:
594
			b43_wa_papd(dev);
595
			b43_wa_rssi_lt(dev);
596
			b43_wa_txdc_offset(dev);
597
			b43_wa_initgains(dev);
598
			b43_wa_dac(dev);
599
			b43_wa_nft(dev);
600
			b43_wa_nst(dev);
601
			b43_wa_msst(dev);
602
			b43_wa_analog(dev);
603
			b43_wa_gt(dev);
604
			b43_wa_txpuoff_rxpuon(dev);
605
			b43_wa_txlna_gain(dev);
606
			break;
607
		case 7:
608
			b43_wa_iqadc(dev);
609
			b43_wa_papd(dev);
610
			b43_wa_rssi_lt(dev);
611
			b43_wa_txdc_offset(dev);
612
			b43_wa_initgains(dev);
613
			b43_wa_dac(dev);
614
			b43_wa_nft(dev);
615
			b43_wa_nst(dev);
616
			b43_wa_msst(dev);
617
			b43_wa_analog(dev);
618
			b43_wa_gt(dev);
619
			b43_wa_txpuoff_rxpuon(dev);
620
			b43_wa_txlna_gain(dev);
621
			b43_wa_rssi_adc(dev);
622
		default:
623
			B43_WARN_ON(1);
624
		}
625
		b43_wa_boards_a(dev);
626
	} else if (phy->type == B43_PHYTYPE_G) {
627
		switch (phy->rev) {
628
		case 1://XXX review rev1
629
			b43_wa_crs_ed(dev);
630
			b43_wa_crs_thr(dev);
631
			b43_wa_crs_blank(dev);
632
			b43_wa_cck_shiftbits(dev);
633
			b43_wa_fft(dev);
634
			b43_wa_nft(dev);
635
			b43_wa_rt(dev);
636
			b43_wa_nst(dev);
637
			b43_wa_art(dev);
638
			b43_wa_wrssi_offset(dev);
639
			b43_wa_altagc(dev);
640
			break;
641
		case 2:
642
		case 6:
643
		case 7:
644
		case 8:
645
		case 9:
646
			b43_wa_tr_ltov(dev);
647
			b43_wa_crs_ed(dev);
648
			b43_wa_rssi_lt(dev);
649
			b43_wa_nft(dev);
650
			b43_wa_nst(dev);
651
			b43_wa_msst(dev);
652
			b43_wa_wrssi_offset(dev);
653
			b43_wa_altagc(dev);
654
			b43_wa_analog(dev);
655
			b43_wa_txpuoff_rxpuon(dev);
656
			break;
657
		default:
658
			B43_WARN_ON(1);
659
		}
660
		b43_wa_boards_g(dev);
661
	} else { /* No N PHY support so far */
662
		B43_WARN_ON(1);
663
	}
664
665
	b43_wa_cpll_nonpilot(dev);
666
}
(-)linux-2.6/drivers/net/wireless/b43/wa.h (+7 lines)
Line 0 Link Here
1
#ifndef B43_WA_H_
2
#define B43_WA_H_
3
4
void b43_wa_initgains(struct b43_wldev *dev);
5
void b43_wa_all(struct b43_wldev *dev);
6
7
#endif /* B43_WA_H_ */
(-)linux-2.6/drivers/net/wireless/b43/xmit.c (-3 / +4 lines)
Lines 5-11 Link Here
5
  Transmission (TX/RX) related functions.
5
  Transmission (TX/RX) related functions.
6
6
7
  Copyright (C) 2005 Martin Langer <martin-langer@gmx.de>
7
  Copyright (C) 2005 Martin Langer <martin-langer@gmx.de>
8
  Copyright (C) 2005 Stefano Brivio <st3@riseup.net>
8
  Copyright (C) 2005 Stefano Brivio <stefano.brivio@polimi.it>
9
  Copyright (C) 2005, 2006 Michael Buesch <mb@bu3sch.de>
9
  Copyright (C) 2005, 2006 Michael Buesch <mb@bu3sch.de>
10
  Copyright (C) 2005 Danny van Dyk <kugelfang@gentoo.org>
10
  Copyright (C) 2005 Danny van Dyk <kugelfang@gentoo.org>
11
  Copyright (C) 2005 Andreas Jaggi <andreas.jaggi@waterwave.ch>
11
  Copyright (C) 2005 Andreas Jaggi <andreas.jaggi@waterwave.ch>
Lines 294-299 static void generate_txhdr_fw4(struct b4 Link Here
294
		mac_ctl |= B43_TX4_MAC_STMSDU;
294
		mac_ctl |= B43_TX4_MAC_STMSDU;
295
	if (phy->type == B43_PHYTYPE_A)
295
	if (phy->type == B43_PHYTYPE_A)
296
		mac_ctl |= B43_TX4_MAC_5GHZ;
296
		mac_ctl |= B43_TX4_MAC_5GHZ;
297
	if (txctl->flags & IEEE80211_TXCTL_LONG_RETRY_LIMIT)
298
		mac_ctl |= B43_TX4_MAC_LONGFRAME;
297
299
298
	/* Generate the RTS or CTS-to-self frame */
300
	/* Generate the RTS or CTS-to-self frame */
299
	if ((txctl->flags & IEEE80211_TXCTL_USE_RTS_CTS) ||
301
	if ((txctl->flags & IEEE80211_TXCTL_USE_RTS_CTS) ||
Lines 342-348 static void generate_txhdr_fw4(struct b4 Link Here
342
			    b43_plcp_get_ratecode_cck(rts_rate);
344
			    b43_plcp_get_ratecode_cck(rts_rate);
343
		if (rts_rate_fb_ofdm)
345
		if (rts_rate_fb_ofdm)
344
			extra_ft |= B43_TX4_EFT_RTSFBOFDM;
346
			extra_ft |= B43_TX4_EFT_RTSFBOFDM;
345
		mac_ctl |= B43_TX4_MAC_LONGFRAME;
346
	}
347
	}
347
348
348
	/* Magic cookie */
349
	/* Magic cookie */
Lines 384-390 static s8 b43_rssi_postprocess(struct b4 Link Here
384
			else
385
			else
385
				tmp -= 3;
386
				tmp -= 3;
386
		} else {
387
		} else {
387
			if (dev->dev->bus->sprom.r1.
388
			if (dev->dev->bus->sprom.
388
			    boardflags_lo & B43_BFL_RSSI) {
389
			    boardflags_lo & B43_BFL_RSSI) {
389
				if (in_rssi > 63)
390
				if (in_rssi > 63)
390
					in_rssi = 63;
391
					in_rssi = 63;
(-)linux-2.6/drivers/net/wireless/b43legacy/b43legacy.h (-2 / +9 lines)
Lines 19-24 Link Here
19
19
20
#include "debugfs.h"
20
#include "debugfs.h"
21
#include "leds.h"
21
#include "leds.h"
22
#include "rfkill.h"
22
#include "phy.h"
23
#include "phy.h"
23
24
24
25
Lines 592-597 struct b43legacy_wl { Link Here
592
	u8 rng_initialized;
593
	u8 rng_initialized;
593
	char rng_name[30 + 1];
594
	char rng_name[30 + 1];
594
595
596
	/* The RF-kill button */
597
	struct b43legacy_rfkill rfkill;
598
595
	/* List of all wireless devices on this chip */
599
	/* List of all wireless devices on this chip */
596
	struct list_head devlist;
600
	struct list_head devlist;
597
	u8 nr_devs;
601
	u8 nr_devs;
Lines 663-670 struct b43legacy_wldev { Link Here
663
	/* Various statistics about the physical device. */
667
	/* Various statistics about the physical device. */
664
	struct b43legacy_stats stats;
668
	struct b43legacy_stats stats;
665
669
666
#define B43legacy_NR_LEDS		4
670
	/* The device LEDs. */
667
	struct b43legacy_led leds[B43legacy_NR_LEDS];
671
	struct b43legacy_led led_tx;
672
	struct b43legacy_led led_rx;
673
	struct b43legacy_led led_assoc;
674
	struct b43legacy_led led_radio;
668
675
669
	/* Reason code of the last interrupt. */
676
	/* Reason code of the last interrupt. */
670
	u32 irq_reason;
677
	u32 irq_reason;
(-)linux-2.6/drivers/net/wireless/b43legacy/ilt.c (-1 / +1 lines)
Lines 3-9 Link Here
3
  Broadcom B43legacy wireless driver
3
  Broadcom B43legacy wireless driver
4
4
5
  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
5
  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
6
		     Stefano Brivio <st3@riseup.net>
6
		     Stefano Brivio <stefano.brivio@polimi.it>
7
		     Michael Buesch <mbuesch@freenet.de>
7
		     Michael Buesch <mbuesch@freenet.de>
8
		     Danny van Dyk <kugelfang@gentoo.org>
8
		     Danny van Dyk <kugelfang@gentoo.org>
9
		     Andreas Jaggi <andreas.jaggi@waterwave.ch>
9
		     Andreas Jaggi <andreas.jaggi@waterwave.ch>
(-)linux-2.6/drivers/net/wireless/b43legacy/Kconfig (-1 / +17 lines)
Lines 34-39 config B43LEGACY_PCICORE_AUTOSELECT Link Here
34
	select SSB_DRIVER_PCICORE
34
	select SSB_DRIVER_PCICORE
35
	default y
35
	default y
36
36
37
# LED support
38
# This config option automatically enables b43legacy LEDS support,
39
# if it's possible.
40
config B43LEGACY_LEDS
41
	bool
42
	depends on B43LEGACY && MAC80211_LEDS && (LEDS_CLASS = y || LEDS_CLASS = B43LEGACY)
43
	default y
44
45
# RFKILL support
46
# This config option automatically enables b43legacy RFKILL support,
47
# if it's possible.
48
config B43LEGACY_RFKILL
49
	bool
50
	depends on B43LEGACY && (RFKILL = y || RFKILL = B43LEGACY) && RFKILL_INPUT && (INPUT_POLLDEV = y || INPUT_POLLDEV = B43LEGACY)
51
	default y
52
37
config B43LEGACY_DEBUG
53
config B43LEGACY_DEBUG
38
	bool "Broadcom 43xx-legacy debugging"
54
	bool "Broadcom 43xx-legacy debugging"
39
	depends on B43LEGACY
55
	depends on B43LEGACY
Lines 44-50 config B43LEGACY_DEBUG Link Here
44
60
45
config B43LEGACY_DMA
61
config B43LEGACY_DMA
46
	bool
62
	bool
47
	depends on B43LEGACY
63
	depends on B43LEGACY && HAS_DMA
48
64
49
config B43LEGACY_PIO
65
config B43LEGACY_PIO
50
	bool
66
	bool
(-)linux-2.6/drivers/net/wireless/b43legacy/leds.c (-238 / +177 lines)
Lines 1-13 Link Here
1
/*
1
/*
2
2
3
  Broadcom B43legacy wireless driver
3
  Broadcom B43 wireless driver
4
  LED control
4
5
5
  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
6
  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
6
		     Stefano Brivio <st3@riseup.net>
7
  Copyright (c) 2005 Stefano Brivio <stefano.brivio@polimi.it>
7
		     Michael Buesch <mb@bu3sch.de>
8
  Copyright (c) 2005-2007 Michael Buesch <mb@bu3sch.de>
8
		     Danny van Dyk <kugelfang@gentoo.org>
9
  Copyright (c) 2005 Danny van Dyk <kugelfang@gentoo.org>
9
		     Andreas Jaggi <andreas.jaggi@waterwave.ch>
10
  Copyright (c) 2005 Andreas Jaggi <andreas.jaggi@waterwave.ch>
10
  Copyright (c) 2007 Larry Finger <Larry.Finger@lwfinger.net>
11
11
12
  This program is free software; you can redistribute it and/or modify
12
  This program is free software; you can redistribute it and/or modify
13
  it under the terms of the GNU General Public License as published by
13
  it under the terms of the GNU General Public License as published by
Lines 26-298 Link Here
26
26
27
*/
27
*/
28
28
29
#include "leds.h"
30
#include "b43legacy.h"
29
#include "b43legacy.h"
31
#include "main.h"
30
#include "leds.h"
32
33
static void b43legacy_led_changestate(struct b43legacy_led *led)
34
{
35
	struct b43legacy_wldev *dev = led->dev;
36
	const int index = led->index;
37
	u16 ledctl;
38
31
39
	B43legacy_WARN_ON(!(index >= 0 && index < B43legacy_NR_LEDS));
40
	B43legacy_WARN_ON(!led->blink_interval);
41
	ledctl = b43legacy_read16(dev, B43legacy_MMIO_GPIO_CONTROL);
42
	ledctl ^= (1 << index);
43
	b43legacy_write16(dev, B43legacy_MMIO_GPIO_CONTROL, ledctl);
44
}
45
32
46
static void b43legacy_led_blink(unsigned long d)
33
static void b43legacy_led_turn_on(struct b43legacy_wldev *dev, u8 led_index,
34
			    bool activelow)
47
{
35
{
48
	struct b43legacy_led *led = (struct b43legacy_led *)d;
36
	struct b43legacy_wl *wl = dev->wl;
49
	struct b43legacy_wldev *dev = led->dev;
50
	unsigned long flags;
37
	unsigned long flags;
38
	u16 ctl;
51
39
52
	spin_lock_irqsave(&dev->wl->leds_lock, flags);
40
	spin_lock_irqsave(&wl->leds_lock, flags);
53
	if (led->blink_interval) {
41
	ctl = b43legacy_read16(dev, B43legacy_MMIO_GPIO_CONTROL);
54
		b43legacy_led_changestate(led);
42
	if (activelow)
55
		mod_timer(&led->blink_timer, jiffies + led->blink_interval);
43
		ctl &= ~(1 << led_index);
56
	}
44
	else
57
	spin_unlock_irqrestore(&dev->wl->leds_lock, flags);
45
		ctl |= (1 << led_index);
46
	b43legacy_write16(dev, B43legacy_MMIO_GPIO_CONTROL, ctl);
47
	spin_unlock_irqrestore(&wl->leds_lock, flags);
58
}
48
}
59
49
60
static void b43legacy_led_blink_start(struct b43legacy_led *led,
50
static void b43legacy_led_turn_off(struct b43legacy_wldev *dev, u8 led_index,
61
				      unsigned long interval)
51
			     bool activelow)
62
{
52
{
63
	if (led->blink_interval)
53
	struct b43legacy_wl *wl = dev->wl;
64
		return;
54
	unsigned long flags;
65
	led->blink_interval = interval;
55
	u16 ctl;
66
	b43legacy_led_changestate(led);
56
67
	led->blink_timer.expires = jiffies + interval;
57
	spin_lock_irqsave(&wl->leds_lock, flags);
68
	add_timer(&led->blink_timer);
58
	ctl = b43legacy_read16(dev, B43legacy_MMIO_GPIO_CONTROL);
59
	if (activelow)
60
		ctl |= (1 << led_index);
61
	else
62
		ctl &= ~(1 << led_index);
63
	b43legacy_write16(dev, B43legacy_MMIO_GPIO_CONTROL, ctl);
64
	spin_unlock_irqrestore(&wl->leds_lock, flags);
69
}
65
}
70
66
71
static void b43legacy_led_blink_stop(struct b43legacy_led *led, int sync)
67
/* Callback from the LED subsystem. */
68
static void b43legacy_led_brightness_set(struct led_classdev *led_dev,
69
				   enum led_brightness brightness)
72
{
70
{
71
	struct b43legacy_led *led = container_of(led_dev, struct b43legacy_led,
72
				    led_dev);
73
	struct b43legacy_wldev *dev = led->dev;
73
	struct b43legacy_wldev *dev = led->dev;
74
	const int index = led->index;
74
	bool radio_enabled;
75
	u16 ledctl;
76
75
77
	if (!led->blink_interval)
76
	/* Checking the radio-enabled status here is slightly racy,
78
		return;
77
	 * but we want to avoid the locking overhead and we don't care
79
	if (unlikely(sync))
78
	 * whether the LED has the wrong state for a second. */
80
		del_timer_sync(&led->blink_timer);
79
	radio_enabled = (dev->phy.radio_on && dev->radio_hw_enable);
81
	else
82
		del_timer(&led->blink_timer);
83
	led->blink_interval = 0;
84
80
85
	/* Make sure the LED is turned off. */
81
	if (brightness == LED_OFF || !radio_enabled)
86
	B43legacy_WARN_ON(!(index >= 0 && index < B43legacy_NR_LEDS));
82
		b43legacy_led_turn_off(dev, led->index, led->activelow);
87
	ledctl = b43legacy_read16(dev, B43legacy_MMIO_GPIO_CONTROL);
88
	if (led->activelow)
89
		ledctl |= (1 << index);
90
	else
83
	else
91
		ledctl &= ~(1 << index);
84
		b43legacy_led_turn_on(dev, led->index, led->activelow);
92
	b43legacy_write16(dev, B43legacy_MMIO_GPIO_CONTROL, ledctl);
93
}
85
}
94
86
95
static void b43legacy_led_init_hardcoded(struct b43legacy_wldev *dev,
87
static int b43legacy_register_led(struct b43legacy_wldev *dev,
96
					 struct b43legacy_led *led,
88
				  struct b43legacy_led *led,
97
					 int led_index)
89
				  const char *name, char *default_trigger,
98
{
90
				  u8 led_index, bool activelow)
99
	struct ssb_bus *bus = dev->dev->bus;
91
{
92
	int err;
93
94
	b43legacy_led_turn_off(dev, led_index, activelow);
95
	if (led->dev)
96
		return -EEXIST;
97
	if (!default_trigger)
98
		return -EINVAL;
99
	led->dev = dev;
100
	led->index = led_index;
101
	led->activelow = activelow;
102
	strncpy(led->name, name, sizeof(led->name));
103
104
	led->led_dev.name = led->name;
105
	led->led_dev.default_trigger = default_trigger;
106
	led->led_dev.brightness_set = b43legacy_led_brightness_set;
107
108
	err = led_classdev_register(dev->dev->dev, &led->led_dev);
109
	if (err) {
110
		b43legacywarn(dev->wl, "LEDs: Failed to register %s\n", name);
111
		led->dev = NULL;
112
		return err;
113
	}
114
	return 0;
115
}
100
116
101
	/* This function is called, if the behaviour (and activelow)
117
static void b43legacy_unregister_led(struct b43legacy_led *led)
102
	 * information for a LED is missing in the SPROM.
118
{
103
	 * We hardcode the behaviour values for various devices here.
119
	if (!led->dev)
104
	 * Note that the B43legacy_LED_TEST_XXX behaviour values can
120
		return;
105
	 * be used to figure out which led is mapped to which index.
121
	led_classdev_unregister(&led->led_dev);
106
	 */
122
	b43legacy_led_turn_off(led->dev, led->index, led->activelow);
107
123
	led->dev = NULL;
108
	switch (led_index) {
124
}
109
	case 0:
125
110
		led->behaviour = B43legacy_LED_ACTIVITY;
126
static void b43legacy_map_led(struct b43legacy_wldev *dev,
111
		led->activelow = 1;
127
			u8 led_index,
112
		if (bus->boardinfo.vendor == PCI_VENDOR_ID_COMPAQ)
128
			enum b43legacy_led_behaviour behaviour,
113
			led->behaviour = B43legacy_LED_RADIO_ALL;
129
			bool activelow)
130
{
131
	struct ieee80211_hw *hw = dev->wl->hw;
132
	char name[B43legacy_LED_MAX_NAME_LEN + 1];
133
134
	/* Map the b43 specific LED behaviour value to the
135
	 * generic LED triggers. */
136
	switch (behaviour) {
137
	case B43legacy_LED_INACTIVE:
138
		break;
139
	case B43legacy_LED_OFF:
140
		b43legacy_led_turn_off(dev, led_index, activelow);
141
		break;
142
	case B43legacy_LED_ON:
143
		b43legacy_led_turn_on(dev, led_index, activelow);
114
		break;
144
		break;
115
	case 1:
145
	case B43legacy_LED_ACTIVITY:
116
		led->behaviour = B43legacy_LED_RADIO_B;
146
	case B43legacy_LED_TRANSFER:
117
		if (bus->boardinfo.vendor == PCI_VENDOR_ID_ASUSTEK)
147
	case B43legacy_LED_APTRANSFER:
118
			led->behaviour = B43legacy_LED_ASSOC;
148
		snprintf(name, sizeof(name),
149
			 "b43legacy-%s:tx", wiphy_name(hw->wiphy));
150
		b43legacy_register_led(dev, &dev->led_tx, name,
151
				 ieee80211_get_tx_led_name(hw),
152
				 led_index, activelow);
153
		snprintf(name, sizeof(name),
154
			 "b43legacy-%s:rx", wiphy_name(hw->wiphy));
155
		b43legacy_register_led(dev, &dev->led_rx, name,
156
				 ieee80211_get_rx_led_name(hw),
157
				 led_index, activelow);
119
		break;
158
		break;
120
	case 2:
159
	case B43legacy_LED_RADIO_ALL:
121
		led->behaviour = B43legacy_LED_RADIO_A;
160
	case B43legacy_LED_RADIO_A:
161
	case B43legacy_LED_RADIO_B:
162
	case B43legacy_LED_MODE_BG:
163
		snprintf(name, sizeof(name),
164
			 "b43legacy-%s:radio", wiphy_name(hw->wiphy));
165
		b43legacy_register_led(dev, &dev->led_radio, name,
166
				 b43legacy_rfkill_led_name(dev),
167
				 led_index, activelow);
122
		break;
168
		break;
123
	case 3:
169
	case B43legacy_LED_WEIRD:
124
		led->behaviour = B43legacy_LED_OFF;
170
	case B43legacy_LED_ASSOC:
171
		snprintf(name, sizeof(name),
172
			 "b43legacy-%s:assoc", wiphy_name(hw->wiphy));
173
		b43legacy_register_led(dev, &dev->led_assoc, name,
174
				 ieee80211_get_assoc_led_name(hw),
175
				 led_index, activelow);
125
		break;
176
		break;
126
	default:
177
	default:
127
		B43legacy_BUG_ON(1);
178
		b43legacywarn(dev->wl, "LEDs: Unknown behaviour 0x%02X\n",
179
			behaviour);
180
		break;
128
	}
181
	}
129
}
182
}
130
183
131
int b43legacy_leds_init(struct b43legacy_wldev *dev)
184
void b43legacy_leds_init(struct b43legacy_wldev *dev)
132
{
185
{
133
	struct b43legacy_led *led;
186
	struct ssb_bus *bus = dev->dev->bus;
134
	u8 sprom[4];
187
	u8 sprom[4];
135
	int i;
188
	int i;
189
	enum b43legacy_led_behaviour behaviour;
190
	bool activelow;
136
191
137
	sprom[0] = dev->dev->bus->sprom.r1.gpio0;
192
	sprom[0] = bus->sprom.gpio0;
138
	sprom[1] = dev->dev->bus->sprom.r1.gpio1;
193
	sprom[1] = bus->sprom.gpio1;
139
	sprom[2] = dev->dev->bus->sprom.r1.gpio2;
194
	sprom[2] = bus->sprom.gpio2;
140
	sprom[3] = dev->dev->bus->sprom.r1.gpio3;
195
	sprom[3] = bus->sprom.gpio3;
141
196
142
	for (i = 0; i < B43legacy_NR_LEDS; i++) {
197
	for (i = 0; i < 4; i++) {
143
		led = &(dev->leds[i]);
198
		if (sprom[i] == 0xFF) {
144
		led->index = i;
199
			/* There is no LED information in the SPROM
145
		led->dev = dev;
200
			 * for this LED. Hardcode it here. */
146
		setup_timer(&led->blink_timer,
201
			activelow = 0;
147
			    b43legacy_led_blink,
202
			switch (i) {
148
			    (unsigned long)led);
203
			case 0:
149
204
				behaviour = B43legacy_LED_ACTIVITY;
150
		if (sprom[i] == 0xFF)
205
				activelow = 1;
151
			b43legacy_led_init_hardcoded(dev, led, i);
206
				if (bus->boardinfo.vendor == PCI_VENDOR_ID_COMPAQ)
152
		else {
207
					behaviour = B43legacy_LED_RADIO_ALL;
153
			led->behaviour = sprom[i] & B43legacy_LED_BEHAVIOUR;
208
				break;
154
			led->activelow = !!(sprom[i] &
209
			case 1:
155
					   B43legacy_LED_ACTIVELOW);
210
				behaviour = B43legacy_LED_RADIO_B;
211
				if (bus->boardinfo.vendor == PCI_VENDOR_ID_ASUSTEK)
212
					behaviour = B43legacy_LED_ASSOC;
213
				break;
214
			case 2:
215
				behaviour = B43legacy_LED_RADIO_A;
216
				break;
217
			case 3:
218
				behaviour = B43legacy_LED_OFF;
219
				break;
220
			default:
221
				B43legacy_WARN_ON(1);
222
				return;
223
			}
224
		} else {
225
			behaviour = sprom[i] & B43legacy_LED_BEHAVIOUR;
226
			activelow = !!(sprom[i] & B43legacy_LED_ACTIVELOW);
156
		}
227
		}
228
		b43legacy_map_led(dev, i, behaviour, activelow);
157
	}
229
	}
158
159
	return 0;
160
}
230
}
161
231
162
void b43legacy_leds_exit(struct b43legacy_wldev *dev)
232
void b43legacy_leds_exit(struct b43legacy_wldev *dev)
163
{
233
{
164
	struct b43legacy_led *led;
234
	b43legacy_unregister_led(&dev->led_tx);
165
	int i;
235
	b43legacy_unregister_led(&dev->led_rx);
166
236
	b43legacy_unregister_led(&dev->led_assoc);
167
	for (i = 0; i < B43legacy_NR_LEDS; i++) {
168
		led = &(dev->leds[i]);
169
		b43legacy_led_blink_stop(led, 1);
170
	}
171
	b43legacy_leds_switch_all(dev, 0);
172
}
173
174
void b43legacy_leds_update(struct b43legacy_wldev *dev, int activity)
175
{
176
	struct b43legacy_led *led;
177
	struct b43legacy_phy *phy = &dev->phy;
178
	const int transferring = (jiffies - dev->stats.last_tx)
179
				  < B43legacy_LED_XFER_THRES;
180
	int i;
181
	int turn_on;
182
	unsigned long interval = 0;
183
	u16 ledctl;
184
	unsigned long flags;
185
	bool radio_enabled = (phy->radio_on && dev->radio_hw_enable);
186
187
	spin_lock_irqsave(&dev->wl->leds_lock, flags);
188
	ledctl = b43legacy_read16(dev, B43legacy_MMIO_GPIO_CONTROL);
189
	for (i = 0; i < B43legacy_NR_LEDS; i++) {
190
		led = &(dev->leds[i]);
191
192
		turn_on = 0;
193
		switch (led->behaviour) {
194
		case B43legacy_LED_INACTIVE:
195
			continue;
196
		case B43legacy_LED_OFF:
197
			break;
198
		case B43legacy_LED_ON:
199
			turn_on = 1;
200
			break;
201
		case B43legacy_LED_ACTIVITY:
202
			turn_on = activity;
203
			break;
204
		case B43legacy_LED_RADIO_ALL:
205
			turn_on = radio_enabled;
206
			break;
207
		case B43legacy_LED_RADIO_A:
208
			break;
209
		case B43legacy_LED_RADIO_B:
210
			turn_on = radio_enabled;
211
			break;
212
		case B43legacy_LED_MODE_BG:
213
			if (phy->type == B43legacy_PHYTYPE_G && radio_enabled)
214
				turn_on = 1;
215
			break;
216
		case B43legacy_LED_TRANSFER:
217
			if (transferring)
218
				b43legacy_led_blink_start(led,
219
						B43legacy_LEDBLINK_MEDIUM);
220
			else
221
				b43legacy_led_blink_stop(led, 0);
222
			continue;
223
		case B43legacy_LED_APTRANSFER:
224
			if (b43legacy_is_mode(dev->wl,
225
						IEEE80211_IF_TYPE_AP)) {
226
				if (transferring) {
227
					interval = B43legacy_LEDBLINK_FAST;
228
					turn_on = 1;
229
				}
230
			} else {
231
				turn_on = 1;
232
				if (transferring)
233
					interval = B43legacy_LEDBLINK_FAST;
234
				else
235
					turn_on = 0;
236
			}
237
			if (turn_on)
238
				b43legacy_led_blink_start(led, interval);
239
			else
240
				b43legacy_led_blink_stop(led, 0);
241
			continue;
242
		case B43legacy_LED_WEIRD:
243
			break;
244
		case B43legacy_LED_ASSOC:
245
			turn_on = 1;
246
#ifdef CONFIG_B43LEGACY_DEBUG
247
		case B43legacy_LED_TEST_BLINKSLOW:
248
			b43legacy_led_blink_start(led, B43legacy_LEDBLINK_SLOW);
249
			continue;
250
		case B43legacy_LED_TEST_BLINKMEDIUM:
251
			b43legacy_led_blink_start(led,
252
						   B43legacy_LEDBLINK_MEDIUM);
253
			continue;
254
		case B43legacy_LED_TEST_BLINKFAST:
255
			b43legacy_led_blink_start(led, B43legacy_LEDBLINK_FAST);
256
			continue;
257
#endif /* CONFIG_B43LEGACY_DEBUG */
258
		default:
259
			B43legacy_BUG_ON(1);
260
		};
261
262
		if (led->activelow)
263
			turn_on = !turn_on;
264
		if (turn_on)
265
			ledctl |= (1 << i);
266
		else
267
			ledctl &= ~(1 << i);
268
	}
269
	b43legacy_write16(dev, B43legacy_MMIO_GPIO_CONTROL, ledctl);
270
	spin_unlock_irqrestore(&dev->wl->leds_lock, flags);
271
}
272
273
void b43legacy_leds_switch_all(struct b43legacy_wldev *dev, int on)
274
{
275
	struct b43legacy_led *led;
276
	u16 ledctl;
277
	int i;
278
	int bit_on;
279
	unsigned long flags;
280
281
	spin_lock_irqsave(&dev->wl->leds_lock, flags);
282
	ledctl = b43legacy_read16(dev, B43legacy_MMIO_GPIO_CONTROL);
283
	for (i = 0; i < B43legacy_NR_LEDS; i++) {
284
		led = &(dev->leds[i]);
285
		if (led->behaviour == B43legacy_LED_INACTIVE)
286
			continue;
287
		if (on)
288
			bit_on = led->activelow ? 0 : 1;
289
		else
290
			bit_on = led->activelow ? 1 : 0;
291
		if (bit_on)
292
			ledctl |= (1 << i);
293
		else
294
			ledctl &= ~(1 << i);
295
	}
296
	b43legacy_write16(dev, B43legacy_MMIO_GPIO_CONTROL, ledctl);
297
	spin_unlock_irqrestore(&dev->wl->leds_lock, flags);
298
}
237
}
(-)linux-2.6/drivers/net/wireless/b43legacy/leds.h (-27 / +34 lines)
Lines 1-30 Link Here
1
#ifndef B43legacy_LEDS_H_
1
#ifndef B43legacy_LEDS_H_
2
#define B43legacy_LEDS_H_
2
#define B43legacy_LEDS_H_
3
3
4
struct b43legacy_wldev;
5
6
#ifdef CONFIG_B43LEGACY_LEDS
7
4
#include <linux/types.h>
8
#include <linux/types.h>
5
#include <linux/timer.h>
9
#include <linux/leds.h>
6
10
7
11
12
#define B43legacy_LED_MAX_NAME_LEN	31
13
8
struct b43legacy_led {
14
struct b43legacy_led {
9
	u8 behaviour;
10
	bool activelow;
11
	/* Index in the "leds" array in b43legacy_wldev */
12
	u8 index;
13
	struct b43legacy_wldev *dev;
15
	struct b43legacy_wldev *dev;
14
	struct timer_list blink_timer;
16
	/* The LED class device */
15
	unsigned long blink_interval;
17
	struct led_classdev led_dev;
18
	/* The index number of the LED. */
19
	u8 index;
20
	/* If activelow is true, the LED is ON if the
21
	 * bit is switched off. */
22
	bool activelow;
23
	/* The unique name string for this LED device. */
24
	char name[B43legacy_LED_MAX_NAME_LEN + 1];
16
};
25
};
17
26
18
/* Delay between state changes when blinking in jiffies */
19
#define B43legacy_LEDBLINK_SLOW		(HZ / 1)
20
#define B43legacy_LEDBLINK_MEDIUM	(HZ / 4)
21
#define B43legacy_LEDBLINK_FAST		(HZ / 8)
22
23
#define B43legacy_LED_XFER_THRES	(HZ / 100)
24
25
#define B43legacy_LED_BEHAVIOUR		0x7F
27
#define B43legacy_LED_BEHAVIOUR		0x7F
26
#define B43legacy_LED_ACTIVELOW		0x80
28
#define B43legacy_LED_ACTIVELOW		0x80
27
enum { /* LED behaviour values */
29
/* LED behaviour values */
30
enum b43legacy_led_behaviour {
28
	B43legacy_LED_OFF,
31
	B43legacy_LED_OFF,
29
	B43legacy_LED_ON,
32
	B43legacy_LED_ON,
30
	B43legacy_LED_ACTIVITY,
33
	B43legacy_LED_ACTIVITY,
Lines 37-56 enum { /* LED behaviour values */ Link Here
37
	B43legacy_LED_WEIRD,
40
	B43legacy_LED_WEIRD,
38
	B43legacy_LED_ASSOC,
41
	B43legacy_LED_ASSOC,
39
	B43legacy_LED_INACTIVE,
42
	B43legacy_LED_INACTIVE,
40
41
	/* Behaviour values for testing.
42
	 * With these values it is easier to figure out
43
	 * the real behaviour of leds, in case the SPROM
44
	 * is missing information.
45
	 */
46
	B43legacy_LED_TEST_BLINKSLOW,
47
	B43legacy_LED_TEST_BLINKMEDIUM,
48
	B43legacy_LED_TEST_BLINKFAST,
49
};
43
};
50
44
51
int b43legacy_leds_init(struct b43legacy_wldev *dev);
45
void b43legacy_leds_init(struct b43legacy_wldev *dev);
52
void b43legacy_leds_exit(struct b43legacy_wldev *dev);
46
void b43legacy_leds_exit(struct b43legacy_wldev *dev);
53
void b43legacy_leds_update(struct b43legacy_wldev *dev, int activity);
47
54
void b43legacy_leds_switch_all(struct b43legacy_wldev *dev, int on);
48
#else /* CONFIG_B43EGACY_LEDS */
49
/* LED support disabled */
50
51
struct b43legacy_led {
52
	/* empty */
53
};
54
55
static inline void b43legacy_leds_init(struct b43legacy_wldev *dev)
56
{
57
}
58
static inline void b43legacy_leds_exit(struct b43legacy_wldev *dev)
59
{
60
}
61
#endif /* CONFIG_B43LEGACY_LEDS */
55
62
56
#endif /* B43legacy_LEDS_H_ */
63
#endif /* B43legacy_LEDS_H_ */
(-)linux-2.6/drivers/net/wireless/b43legacy/main.c (-223 / +142 lines)
Lines 3-9 Link Here
3
 *  Broadcom B43legacy wireless driver
3
 *  Broadcom B43legacy wireless driver
4
 *
4
 *
5
 *  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>
5
 *  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>
6
 *  Copyright (c) 2005 Stefano Brivio <st3@riseup.net>
6
 *  Copyright (c) 2005-2007 Stefano Brivio <stefano.brivio@polimi.it>
7
 *  Copyright (c) 2005, 2006 Michael Buesch <mb@bu3sch.de>
7
 *  Copyright (c) 2005, 2006 Michael Buesch <mb@bu3sch.de>
8
 *  Copyright (c) 2005 Danny van Dyk <kugelfang@gentoo.org>
8
 *  Copyright (c) 2005 Danny van Dyk <kugelfang@gentoo.org>
9
 *  Copyright (c) 2005 Andreas Jaggi <andreas.jaggi@waterwave.ch>
9
 *  Copyright (c) 2005 Andreas Jaggi <andreas.jaggi@waterwave.ch>
Lines 75-92 module_param_named(bad_frames_preempt, m Link Here
75
MODULE_PARM_DESC(bad_frames_preempt, "enable(1) / disable(0) Bad Frames"
75
MODULE_PARM_DESC(bad_frames_preempt, "enable(1) / disable(0) Bad Frames"
76
		 " Preemption");
76
		 " Preemption");
77
77
78
static int modparam_short_retry = B43legacy_DEFAULT_SHORT_RETRY_LIMIT;
79
module_param_named(short_retry, modparam_short_retry, int, 0444);
80
MODULE_PARM_DESC(short_retry, "Short-Retry-Limit (0 - 15)");
81
82
static int modparam_long_retry = B43legacy_DEFAULT_LONG_RETRY_LIMIT;
83
module_param_named(long_retry, modparam_long_retry, int, 0444);
84
MODULE_PARM_DESC(long_retry, "Long-Retry-Limit (0 - 15)");
85
86
static int modparam_noleds;
87
module_param_named(noleds, modparam_noleds, int, 0444);
88
MODULE_PARM_DESC(noleds, "Turn off all LED activity");
89
90
static char modparam_fwpostfix[16];
78
static char modparam_fwpostfix[16];
91
module_param_string(fwpostfix, modparam_fwpostfix, 16, 0444);
79
module_param_string(fwpostfix, modparam_fwpostfix, 16, 0444);
92
MODULE_PARM_DESC(fwpostfix, "Postfix for the firmware files to load.");
80
MODULE_PARM_DESC(fwpostfix, "Postfix for the firmware files to load.");
Lines 1217-1223 static void b43legacy_interrupt_tasklet( Link Here
1217
	u32 dma_reason[ARRAY_SIZE(dev->dma_reason)];
1205
	u32 dma_reason[ARRAY_SIZE(dev->dma_reason)];
1218
	u32 merged_dma_reason = 0;
1206
	u32 merged_dma_reason = 0;
1219
	int i;
1207
	int i;
1220
	int activity = 0;
1221
	unsigned long flags;
1208
	unsigned long flags;
1222
1209
1223
	spin_lock_irqsave(&dev->wl->irq_lock, flags);
1210
	spin_lock_irqsave(&dev->wl->irq_lock, flags);
Lines 1281-1287 static void b43legacy_interrupt_tasklet( Link Here
1281
			b43legacy_pio_rx(dev->pio.queue0);
1268
			b43legacy_pio_rx(dev->pio.queue0);
1282
		else
1269
		else
1283
			b43legacy_dma_rx(dev->dma.rx_ring0);
1270
			b43legacy_dma_rx(dev->dma.rx_ring0);
1284
		/* We intentionally don't set "activity" to 1, here. */
1285
	}
1271
	}
1286
	B43legacy_WARN_ON(dma_reason[1] & B43legacy_DMAIRQ_RX_DONE);
1272
	B43legacy_WARN_ON(dma_reason[1] & B43legacy_DMAIRQ_RX_DONE);
1287
	B43legacy_WARN_ON(dma_reason[2] & B43legacy_DMAIRQ_RX_DONE);
1273
	B43legacy_WARN_ON(dma_reason[2] & B43legacy_DMAIRQ_RX_DONE);
Lines 1290-1309 static void b43legacy_interrupt_tasklet( Link Here
1290
			b43legacy_pio_rx(dev->pio.queue3);
1276
			b43legacy_pio_rx(dev->pio.queue3);
1291
		else
1277
		else
1292
			b43legacy_dma_rx(dev->dma.rx_ring3);
1278
			b43legacy_dma_rx(dev->dma.rx_ring3);
1293
		activity = 1;
1294
	}
1279
	}
1295
	B43legacy_WARN_ON(dma_reason[4] & B43legacy_DMAIRQ_RX_DONE);
1280
	B43legacy_WARN_ON(dma_reason[4] & B43legacy_DMAIRQ_RX_DONE);
1296
	B43legacy_WARN_ON(dma_reason[5] & B43legacy_DMAIRQ_RX_DONE);
1281
	B43legacy_WARN_ON(dma_reason[5] & B43legacy_DMAIRQ_RX_DONE);
1297
1282
1298
	if (reason & B43legacy_IRQ_TX_OK) {
1283
	if (reason & B43legacy_IRQ_TX_OK)
1299
		handle_irq_transmit_status(dev);
1284
		handle_irq_transmit_status(dev);
1300
		activity = 1;
1301
		/* TODO: In AP mode, this also causes sending of powersave
1302
			 responses. */
1303
	}
1304
1285
1305
	if (!modparam_noleds)
1306
		b43legacy_leds_update(dev, activity);
1307
	b43legacy_interrupt_enable(dev, dev->irq_savedstate);
1286
	b43legacy_interrupt_enable(dev, dev->irq_savedstate);
1308
	mmiowb();
1287
	mmiowb();
1309
	spin_unlock_irqrestore(&dev->wl->irq_lock, flags);
1288
	spin_unlock_irqrestore(&dev->wl->irq_lock, flags);
Lines 1755-1761 static int b43legacy_gpio_init(struct b4 Link Here
1755
			  B43legacy_MMIO_STATUS_BITFIELD)
1734
			  B43legacy_MMIO_STATUS_BITFIELD)
1756
			  & 0xFFFF3FFF);
1735
			  & 0xFFFF3FFF);
1757
1736
1758
	b43legacy_leds_switch_all(dev, 0);
1759
	b43legacy_write16(dev, B43legacy_MMIO_GPIO_MASK,
1737
	b43legacy_write16(dev, B43legacy_MMIO_GPIO_MASK,
1760
			  b43legacy_read16(dev,
1738
			  b43legacy_read16(dev,
1761
			  B43legacy_MMIO_GPIO_MASK)
1739
			  B43legacy_MMIO_GPIO_MASK)
Lines 1767-1773 static int b43legacy_gpio_init(struct b4 Link Here
1767
		mask |= 0x0060;
1745
		mask |= 0x0060;
1768
		set |= 0x0060;
1746
		set |= 0x0060;
1769
	}
1747
	}
1770
	if (dev->dev->bus->sprom.r1.boardflags_lo & B43legacy_BFL_PACTRL) {
1748
	if (dev->dev->bus->sprom.boardflags_lo & B43legacy_BFL_PACTRL) {
1771
		b43legacy_write16(dev, B43legacy_MMIO_GPIO_MASK,
1749
		b43legacy_write16(dev, B43legacy_MMIO_GPIO_MASK,
1772
				  b43legacy_read16(dev,
1750
				  b43legacy_read16(dev,
1773
				  B43legacy_MMIO_GPIO_MASK)
1751
				  B43legacy_MMIO_GPIO_MASK)
Lines 1811-1816 void b43legacy_mac_enable(struct b43lega Link Here
1811
{
1789
{
1812
	dev->mac_suspended--;
1790
	dev->mac_suspended--;
1813
	B43legacy_WARN_ON(dev->mac_suspended < 0);
1791
	B43legacy_WARN_ON(dev->mac_suspended < 0);
1792
	B43legacy_WARN_ON(irqs_disabled());
1814
	if (dev->mac_suspended == 0) {
1793
	if (dev->mac_suspended == 0) {
1815
		b43legacy_write32(dev, B43legacy_MMIO_STATUS_BITFIELD,
1794
		b43legacy_write32(dev, B43legacy_MMIO_STATUS_BITFIELD,
1816
				  b43legacy_read32(dev,
1795
				  b43legacy_read32(dev,
Lines 1822-1827 void b43legacy_mac_enable(struct b43lega Link Here
1822
		b43legacy_read32(dev, B43legacy_MMIO_STATUS_BITFIELD);
1801
		b43legacy_read32(dev, B43legacy_MMIO_STATUS_BITFIELD);
1823
		b43legacy_read32(dev, B43legacy_MMIO_GEN_IRQ_REASON);
1802
		b43legacy_read32(dev, B43legacy_MMIO_GEN_IRQ_REASON);
1824
		b43legacy_power_saving_ctl_bits(dev, -1, -1);
1803
		b43legacy_power_saving_ctl_bits(dev, -1, -1);
1804
1805
		/* Re-enable IRQs. */
1806
		spin_lock_irq(&dev->wl->irq_lock);
1807
		b43legacy_interrupt_enable(dev, dev->irq_savedstate);
1808
		spin_unlock_irq(&dev->wl->irq_lock);
1825
	}
1809
	}
1826
}
1810
}
1827
1811
Lines 1831-1850 void b43legacy_mac_suspend(struct b43leg Link Here
1831
	int i;
1815
	int i;
1832
	u32 tmp;
1816
	u32 tmp;
1833
1817
1818
	might_sleep();
1819
	B43legacy_WARN_ON(irqs_disabled());
1834
	B43legacy_WARN_ON(dev->mac_suspended < 0);
1820
	B43legacy_WARN_ON(dev->mac_suspended < 0);
1821
1835
	if (dev->mac_suspended == 0) {
1822
	if (dev->mac_suspended == 0) {
1823
		/* Mask IRQs before suspending MAC. Otherwise
1824
		 * the MAC stays busy and won't suspend. */
1825
		spin_lock_irq(&dev->wl->irq_lock);
1826
		tmp = b43legacy_interrupt_disable(dev, B43legacy_IRQ_ALL);
1827
		spin_unlock_irq(&dev->wl->irq_lock);
1828
		b43legacy_synchronize_irq(dev);
1829
		dev->irq_savedstate = tmp;
1830
1836
		b43legacy_power_saving_ctl_bits(dev, -1, 1);
1831
		b43legacy_power_saving_ctl_bits(dev, -1, 1);
1837
		b43legacy_write32(dev, B43legacy_MMIO_STATUS_BITFIELD,
1832
		b43legacy_write32(dev, B43legacy_MMIO_STATUS_BITFIELD,
1838
				  b43legacy_read32(dev,
1833
				  b43legacy_read32(dev,
1839
				  B43legacy_MMIO_STATUS_BITFIELD)
1834
				  B43legacy_MMIO_STATUS_BITFIELD)
1840
				  & ~B43legacy_SBF_MAC_ENABLED);
1835
				  & ~B43legacy_SBF_MAC_ENABLED);
1841
		b43legacy_read32(dev, B43legacy_MMIO_GEN_IRQ_REASON);
1836
		b43legacy_read32(dev, B43legacy_MMIO_GEN_IRQ_REASON);
1842
		for (i = 10000; i; i--) {
1837
		for (i = 40; i; i--) {
1843
			tmp = b43legacy_read32(dev,
1838
			tmp = b43legacy_read32(dev,
1844
					       B43legacy_MMIO_GEN_IRQ_REASON);
1839
					       B43legacy_MMIO_GEN_IRQ_REASON);
1845
			if (tmp & B43legacy_IRQ_MAC_SUSPENDED)
1840
			if (tmp & B43legacy_IRQ_MAC_SUSPENDED)
1846
				goto out;
1841
				goto out;
1847
			udelay(1);
1842
			msleep(1);
1848
		}
1843
		}
1849
		b43legacyerr(dev->wl, "MAC suspend failed\n");
1844
		b43legacyerr(dev->wl, "MAC suspend failed\n");
1850
	}
1845
	}
Lines 1989-2015 static void b43legacy_mgmtframe_txantenn Link Here
1989
			      B43legacy_SHM_SH_PRPHYCTL, tmp);
1984
			      B43legacy_SHM_SH_PRPHYCTL, tmp);
1990
}
1985
}
1991
1986
1992
/* Returns TRUE, if the radio is enabled in hardware. */
1993
static bool b43legacy_is_hw_radio_enabled(struct b43legacy_wldev *dev)
1994
{
1995
	if (dev->phy.rev >= 3) {
1996
		if (!(b43legacy_read32(dev, B43legacy_MMIO_RADIO_HWENABLED_HI)
1997
		      & B43legacy_MMIO_RADIO_HWENABLED_HI_MASK))
1998
			return 1;
1999
	} else {
2000
		if (b43legacy_read16(dev, B43legacy_MMIO_RADIO_HWENABLED_LO)
2001
		    & B43legacy_MMIO_RADIO_HWENABLED_LO_MASK)
2002
			return 1;
2003
	}
2004
	return 0;
2005
}
2006
2007
/* This is the opposite of b43legacy_chip_init() */
1987
/* This is the opposite of b43legacy_chip_init() */
2008
static void b43legacy_chip_exit(struct b43legacy_wldev *dev)
1988
static void b43legacy_chip_exit(struct b43legacy_wldev *dev)
2009
{
1989
{
2010
	b43legacy_radio_turn_off(dev);
1990
	b43legacy_radio_turn_off(dev, 1);
2011
	if (!modparam_noleds)
1991
	b43legacy_leds_exit(dev);
2012
		b43legacy_leds_exit(dev);
2013
	b43legacy_gpio_cleanup(dev);
1992
	b43legacy_gpio_cleanup(dev);
2014
	/* firmware is released later */
1993
	/* firmware is released later */
2015
}
1994
}
Lines 2039-2047 static int b43legacy_chip_init(struct b4 Link Here
2039
	err = b43legacy_gpio_init(dev);
2018
	err = b43legacy_gpio_init(dev);
2040
	if (err)
2019
	if (err)
2041
		goto out; /* firmware is released later */
2020
		goto out; /* firmware is released later */
2021
	b43legacy_leds_init(dev);
2022
2042
	err = b43legacy_upload_initvals(dev);
2023
	err = b43legacy_upload_initvals(dev);
2043
	if (err)
2024
	if (err)
2044
		goto err_gpio_cleanup;
2025
		goto err_leds_exit;
2045
	b43legacy_radio_turn_on(dev);
2026
	b43legacy_radio_turn_on(dev);
2046
2027
2047
	b43legacy_write16(dev, 0x03E6, 0x0000);
2028
	b43legacy_write16(dev, 0x03E6, 0x0000);
Lines 2119-2126 out: Link Here
2119
	return err;
2100
	return err;
2120
2101
2121
err_radio_off:
2102
err_radio_off:
2122
	b43legacy_radio_turn_off(dev);
2103
	b43legacy_radio_turn_off(dev, 1);
2123
err_gpio_cleanup:
2104
err_leds_exit:
2105
	b43legacy_leds_exit(dev);
2124
	b43legacy_gpio_cleanup(dev);
2106
	b43legacy_gpio_cleanup(dev);
2125
	goto out;
2107
	goto out;
2126
}
2108
}
Lines 2140-2146 static void b43legacy_periodic_every120s Link Here
2140
static void b43legacy_periodic_every60sec(struct b43legacy_wldev *dev)
2122
static void b43legacy_periodic_every60sec(struct b43legacy_wldev *dev)
2141
{
2123
{
2142
	b43legacy_phy_lo_mark_all_unused(dev);
2124
	b43legacy_phy_lo_mark_all_unused(dev);
2143
	if (dev->dev->bus->sprom.r1.boardflags_lo & B43legacy_BFL_RSSI) {
2125
	if (dev->dev->bus->sprom.boardflags_lo & B43legacy_BFL_RSSI) {
2144
		b43legacy_mac_suspend(dev);
2126
		b43legacy_mac_suspend(dev);
2145
		b43legacy_calc_nrssi_slope(dev);
2127
		b43legacy_calc_nrssi_slope(dev);
2146
		b43legacy_mac_enable(dev);
2128
		b43legacy_mac_enable(dev);
Lines 2158-2270 static void b43legacy_periodic_every15se Link Here
2158
	b43legacy_phy_xmitpower(dev); /* FIXME: unless scanning? */
2140
	b43legacy_phy_xmitpower(dev); /* FIXME: unless scanning? */
2159
}
2141
}
2160
2142
2161
static void b43legacy_periodic_every1sec(struct b43legacy_wldev *dev)
2162
{
2163
	bool radio_hw_enable;
2164
2165
	/* check if radio hardware enabled status changed */
2166
	radio_hw_enable = b43legacy_is_hw_radio_enabled(dev);
2167
	if (unlikely(dev->radio_hw_enable != radio_hw_enable)) {
2168
		dev->radio_hw_enable = radio_hw_enable;
2169
		b43legacyinfo(dev->wl, "Radio hardware status changed to %s\n",
2170
		       (radio_hw_enable) ? "enabled" : "disabled");
2171
		b43legacy_leds_update(dev, 0);
2172
	}
2173
}
2174
2175
static void do_periodic_work(struct b43legacy_wldev *dev)
2143
static void do_periodic_work(struct b43legacy_wldev *dev)
2176
{
2144
{
2177
	unsigned int state;
2145
	unsigned int state;
2178
2146
2179
	state = dev->periodic_state;
2147
	state = dev->periodic_state;
2180
	if (state % 120 == 0)
2148
	if (state % 8 == 0)
2181
		b43legacy_periodic_every120sec(dev);
2149
		b43legacy_periodic_every120sec(dev);
2182
	if (state % 60 == 0)
2150
	if (state % 4 == 0)
2183
		b43legacy_periodic_every60sec(dev);
2151
		b43legacy_periodic_every60sec(dev);
2184
	if (state % 30 == 0)
2152
	if (state % 2 == 0)
2185
		b43legacy_periodic_every30sec(dev);
2153
		b43legacy_periodic_every30sec(dev);
2186
	if (state % 15 == 0)
2154
	b43legacy_periodic_every15sec(dev);
2187
		b43legacy_periodic_every15sec(dev);
2188
	b43legacy_periodic_every1sec(dev);
2189
}
2155
}
2190
2156
2191
/* Estimate a "Badness" value based on the periodic work
2157
/* Periodic work locking policy:
2192
 * state-machine state. "Badness" is worse (bigger), if the
2158
 * 	The whole periodic work handler is protected by
2193
 * periodic work will take longer.
2159
 * 	wl->mutex. If another lock is needed somewhere in the
2160
 * 	pwork callchain, it's aquired in-place, where it's needed.
2194
 */
2161
 */
2195
static int estimate_periodic_work_badness(unsigned int state)
2196
{
2197
	int badness = 0;
2198
2199
	if (state % 120 == 0) /* every 120 sec */
2200
		badness += 10;
2201
	if (state % 60 == 0) /* every 60 sec */
2202
		badness += 5;
2203
	if (state % 30 == 0) /* every 30 sec */
2204
		badness += 1;
2205
	if (state % 15 == 0) /* every 15 sec */
2206
		badness += 1;
2207
2208
#define BADNESS_LIMIT	4
2209
	return badness;
2210
}
2211
2212
static void b43legacy_periodic_work_handler(struct work_struct *work)
2162
static void b43legacy_periodic_work_handler(struct work_struct *work)
2213
{
2163
{
2214
	struct b43legacy_wldev *dev =
2164
	struct b43legacy_wldev *dev = container_of(work, struct b43legacy_wldev,
2215
			     container_of(work, struct b43legacy_wldev,
2165
					     periodic_work.work);
2216
			     periodic_work.work);
2166
	struct b43legacy_wl *wl = dev->wl;
2217
	unsigned long flags;
2218
	unsigned long delay;
2167
	unsigned long delay;
2219
	u32 savedirqs = 0;
2220
	int badness;
2221
2168
2222
	mutex_lock(&dev->wl->mutex);
2169
	mutex_lock(&wl->mutex);
2223
2170
2224
	if (unlikely(b43legacy_status(dev) != B43legacy_STAT_STARTED))
2171
	if (unlikely(b43legacy_status(dev) != B43legacy_STAT_STARTED))
2225
		goto out;
2172
		goto out;
2226
	if (b43legacy_debug(dev, B43legacy_DBG_PWORK_STOP))
2173
	if (b43legacy_debug(dev, B43legacy_DBG_PWORK_STOP))
2227
		goto out_requeue;
2174
		goto out_requeue;
2228
2175
2229
	badness = estimate_periodic_work_badness(dev->periodic_state);
2176
	do_periodic_work(dev);
2230
	if (badness > BADNESS_LIMIT) {
2231
		spin_lock_irqsave(&dev->wl->irq_lock, flags);
2232
		/* Suspend TX as we don't want to transmit packets while
2233
		 * we recalibrate the hardware. */
2234
		b43legacy_tx_suspend(dev);
2235
		savedirqs = b43legacy_interrupt_disable(dev,
2236
							  B43legacy_IRQ_ALL);
2237
		/* Periodic work will take a long time, so we want it to
2238
		 * be preemtible and release the spinlock. */
2239
		spin_unlock_irqrestore(&dev->wl->irq_lock, flags);
2240
		b43legacy_synchronize_irq(dev);
2241
2242
		do_periodic_work(dev);
2243
2244
		spin_lock_irqsave(&dev->wl->irq_lock, flags);
2245
		b43legacy_interrupt_enable(dev, savedirqs);
2246
		b43legacy_tx_resume(dev);
2247
		mmiowb();
2248
		spin_unlock_irqrestore(&dev->wl->irq_lock, flags);
2249
	} else {
2250
		/* Take the global driver lock. This will lock any operation. */
2251
		spin_lock_irqsave(&dev->wl->irq_lock, flags);
2252
2253
		do_periodic_work(dev);
2254
2177
2255
		mmiowb();
2256
		spin_unlock_irqrestore(&dev->wl->irq_lock, flags);
2257
	}
2258
	dev->periodic_state++;
2178
	dev->periodic_state++;
2259
out_requeue:
2179
out_requeue:
2260
	if (b43legacy_debug(dev, B43legacy_DBG_PWORK_FAST))
2180
	if (b43legacy_debug(dev, B43legacy_DBG_PWORK_FAST))
2261
		delay = msecs_to_jiffies(50);
2181
		delay = msecs_to_jiffies(50);
2262
	else
2182
	else
2263
		delay = round_jiffies_relative(HZ);
2183
		delay = round_jiffies_relative(HZ * 15);
2264
	queue_delayed_work(dev->wl->hw->workqueue,
2184
	queue_delayed_work(wl->hw->workqueue, &dev->periodic_work, delay);
2265
			   &dev->periodic_work, delay);
2266
out:
2185
out:
2267
	mutex_unlock(&dev->wl->mutex);
2186
	mutex_unlock(&wl->mutex);
2268
}
2187
}
2269
2188
2270
static void b43legacy_periodic_tasks_setup(struct b43legacy_wldev *dev)
2189
static void b43legacy_periodic_tasks_setup(struct b43legacy_wldev *dev)
Lines 2366-2374 static int b43legacy_rng_init(struct b43 Link Here
2366
	return err;
2285
	return err;
2367
}
2286
}
2368
2287
2369
static int b43legacy_tx(struct ieee80211_hw *hw,
2288
static int b43legacy_op_tx(struct ieee80211_hw *hw,
2370
			struct sk_buff *skb,
2289
			   struct sk_buff *skb,
2371
			struct ieee80211_tx_control *ctl)
2290
			   struct ieee80211_tx_control *ctl)
2372
{
2291
{
2373
	struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
2292
	struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
2374
	struct b43legacy_wldev *dev = wl->current_dev;
2293
	struct b43legacy_wldev *dev = wl->current_dev;
Lines 2392-2406 out: Link Here
2392
	return NETDEV_TX_OK;
2311
	return NETDEV_TX_OK;
2393
}
2312
}
2394
2313
2395
static int b43legacy_conf_tx(struct ieee80211_hw *hw,
2314
static int b43legacy_op_conf_tx(struct ieee80211_hw *hw,
2396
			     int queue,
2315
				int queue,
2397
			     const struct ieee80211_tx_queue_params *params)
2316
				const struct ieee80211_tx_queue_params *params)
2398
{
2317
{
2399
	return 0;
2318
	return 0;
2400
}
2319
}
2401
2320
2402
static int b43legacy_get_tx_stats(struct ieee80211_hw *hw,
2321
static int b43legacy_op_get_tx_stats(struct ieee80211_hw *hw,
2403
				  struct ieee80211_tx_queue_stats *stats)
2322
				     struct ieee80211_tx_queue_stats *stats)
2404
{
2323
{
2405
	struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
2324
	struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
2406
	struct b43legacy_wldev *dev = wl->current_dev;
2325
	struct b43legacy_wldev *dev = wl->current_dev;
Lines 2422-2429 out: Link Here
2422
	return err;
2341
	return err;
2423
}
2342
}
2424
2343
2425
static int b43legacy_get_stats(struct ieee80211_hw *hw,
2344
static int b43legacy_op_get_stats(struct ieee80211_hw *hw,
2426
			       struct ieee80211_low_level_stats *stats)
2345
				  struct ieee80211_low_level_stats *stats)
2427
{
2346
{
2428
	struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
2347
	struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
2429
	unsigned long flags;
2348
	unsigned long flags;
Lines 2572-2579 static int b43legacy_antenna_from_ieee80 Link Here
2572
	}
2491
	}
2573
}
2492
}
2574
2493
2575
static int b43legacy_dev_config(struct ieee80211_hw *hw,
2494
static int b43legacy_op_dev_config(struct ieee80211_hw *hw,
2576
				struct ieee80211_conf *conf)
2495
				   struct ieee80211_conf *conf)
2577
{
2496
{
2578
	struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
2497
	struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
2579
	struct b43legacy_wldev *dev;
2498
	struct b43legacy_wldev *dev;
Lines 2660-2666 static int b43legacy_dev_config(struct i Link Here
2660
					      " physically off. Press the"
2579
					      " physically off. Press the"
2661
					      " button to turn it on.\n");
2580
					      " button to turn it on.\n");
2662
		} else {
2581
		} else {
2663
			b43legacy_radio_turn_off(dev);
2582
			b43legacy_radio_turn_off(dev, 0);
2664
			b43legacyinfo(dev->wl, "Radio turned off by"
2583
			b43legacyinfo(dev->wl, "Radio turned off by"
2665
				      " software\n");
2584
				      " software\n");
2666
		}
2585
		}
Lines 2676-2712 out_unlock_mutex: Link Here
2676
	return err;
2595
	return err;
2677
}
2596
}
2678
2597
2679
static int b43legacy_dev_set_key(struct ieee80211_hw *hw,
2598
static void b43legacy_op_configure_filter(struct ieee80211_hw *hw,
2680
				 enum set_key_cmd cmd,
2599
					  unsigned int changed,
2681
				 const u8 *local_addr, const u8 *addr,
2600
					  unsigned int *fflags,
2682
				 struct ieee80211_key_conf *key)
2601
					  int mc_count,
2683
{
2602
					  struct dev_addr_list *mc_list)
2684
	struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
2685
	struct b43legacy_wldev *dev = wl->current_dev;
2686
	unsigned long flags;
2687
	int err = -EOPNOTSUPP;
2688
	DECLARE_MAC_BUF(mac);
2689
2690
	if (!dev)
2691
		return -ENODEV;
2692
	mutex_lock(&wl->mutex);
2693
	spin_lock_irqsave(&wl->irq_lock, flags);
2694
2695
	if (b43legacy_status(dev) < B43legacy_STAT_INITIALIZED) {
2696
		err = -ENODEV;
2697
	}
2698
	spin_unlock_irqrestore(&wl->irq_lock, flags);
2699
	mutex_unlock(&wl->mutex);
2700
	b43legacydbg(wl, "Using software based encryption for "
2701
		     "mac: %s\n", print_mac(mac, addr));
2702
	return err;
2703
}
2704
2705
static void b43legacy_configure_filter(struct ieee80211_hw *hw,
2706
				       unsigned int changed,
2707
				       unsigned int *fflags,
2708
				       int mc_count,
2709
				       struct dev_addr_list *mc_list)
2710
{
2603
{
2711
	struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
2604
	struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
2712
	struct b43legacy_wldev *dev = wl->current_dev;
2605
	struct b43legacy_wldev *dev = wl->current_dev;
Lines 2741-2749 static void b43legacy_configure_filter(s Link Here
2741
	spin_unlock_irqrestore(&wl->irq_lock, flags);
2634
	spin_unlock_irqrestore(&wl->irq_lock, flags);
2742
}
2635
}
2743
2636
2744
static int b43legacy_config_interface(struct ieee80211_hw *hw,
2637
static int b43legacy_op_config_interface(struct ieee80211_hw *hw,
2745
				      int if_id,
2638
					 int if_id,
2746
				      struct ieee80211_if_conf *conf)
2639
					 struct ieee80211_if_conf *conf)
2747
{
2640
{
2748
	struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
2641
	struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
2749
	struct b43legacy_wldev *dev = wl->current_dev;
2642
	struct b43legacy_wldev *dev = wl->current_dev;
Lines 3029-3034 static void b43legacy_imcfglo_timeouts_w Link Here
3029
#endif /* CONFIG_SSB_DRIVER_PCICORE */
2922
#endif /* CONFIG_SSB_DRIVER_PCICORE */
3030
}
2923
}
3031
2924
2925
/* Write the short and long frame retry limit values. */
2926
static void b43legacy_set_retry_limits(struct b43legacy_wldev *dev,
2927
				       unsigned int short_retry,
2928
				       unsigned int long_retry)
2929
{
2930
	/* The retry limit is a 4-bit counter. Enforce this to avoid overflowing
2931
	 * the chip-internal counter. */
2932
	short_retry = min(short_retry, (unsigned int)0xF);
2933
	long_retry = min(long_retry, (unsigned int)0xF);
2934
2935
	b43legacy_shm_write16(dev, B43legacy_SHM_WIRELESS, 0x0006, short_retry);
2936
	b43legacy_shm_write16(dev, B43legacy_SHM_WIRELESS, 0x0007, long_retry);
2937
}
2938
3032
/* Shutdown a wireless core */
2939
/* Shutdown a wireless core */
3033
/* Locking: wl->mutex */
2940
/* Locking: wl->mutex */
3034
static void b43legacy_wireless_core_exit(struct b43legacy_wldev *dev)
2941
static void b43legacy_wireless_core_exit(struct b43legacy_wldev *dev)
Lines 3047-3057 static void b43legacy_wireless_core_exit Link Here
3047
	cancel_work_sync(&dev->restart_work);
2954
	cancel_work_sync(&dev->restart_work);
3048
	mutex_lock(&wl->mutex);
2955
	mutex_lock(&wl->mutex);
3049
2956
2957
	mutex_unlock(&dev->wl->mutex);
2958
	b43legacy_rfkill_exit(dev);
2959
	mutex_lock(&dev->wl->mutex);
2960
3050
	b43legacy_rng_exit(dev->wl);
2961
	b43legacy_rng_exit(dev->wl);
3051
	b43legacy_pio_free(dev);
2962
	b43legacy_pio_free(dev);
3052
	b43legacy_dma_free(dev);
2963
	b43legacy_dma_free(dev);
3053
	b43legacy_chip_exit(dev);
2964
	b43legacy_chip_exit(dev);
3054
	b43legacy_radio_turn_off(dev);
2965
	b43legacy_radio_turn_off(dev, 1);
3055
	b43legacy_switch_analog(dev, 0);
2966
	b43legacy_switch_analog(dev, 0);
3056
	if (phy->dyn_tssi_tbl)
2967
	if (phy->dyn_tssi_tbl)
3057
		kfree(phy->tssi2dbm);
2968
		kfree(phy->tssi2dbm);
Lines 3153-3159 static int b43legacy_wireless_core_init( Link Here
3153
		hf |= B43legacy_HF_SYMW;
3064
		hf |= B43legacy_HF_SYMW;
3154
		if (phy->rev == 1)
3065
		if (phy->rev == 1)
3155
			hf |= B43legacy_HF_GDCW;
3066
			hf |= B43legacy_HF_GDCW;
3156
		if (sprom->r1.boardflags_lo & B43legacy_BFL_PACTRL)
3067
		if (sprom->boardflags_lo & B43legacy_BFL_PACTRL)
3157
			hf |= B43legacy_HF_OFDMPABOOST;
3068
			hf |= B43legacy_HF_OFDMPABOOST;
3158
	} else if (phy->type == B43legacy_PHYTYPE_B) {
3069
	} else if (phy->type == B43legacy_PHYTYPE_B) {
3159
		hf |= B43legacy_HF_SYMW;
3070
		hf |= B43legacy_HF_SYMW;
Lines 3162-3177 static int b43legacy_wireless_core_init( Link Here
3162
	}
3073
	}
3163
	b43legacy_hf_write(dev, hf);
3074
	b43legacy_hf_write(dev, hf);
3164
3075
3165
	/* Short/Long Retry Limit.
3076
	b43legacy_set_retry_limits(dev,
3166
	 * The retry-limit is a 4-bit counter. Enforce this to avoid overflowing
3077
				   B43legacy_DEFAULT_SHORT_RETRY_LIMIT,
3167
	 * the chip-internal counter.
3078
				   B43legacy_DEFAULT_LONG_RETRY_LIMIT);
3168
	 */
3169
	tmp = limit_value(modparam_short_retry, 0, 0xF);
3170
	b43legacy_shm_write16(dev, B43legacy_SHM_WIRELESS,
3171
			      0x0006, tmp);
3172
	tmp = limit_value(modparam_long_retry, 0, 0xF);
3173
	b43legacy_shm_write16(dev, B43legacy_SHM_WIRELESS,
3174
			      0x0007, tmp);
3175
3079
3176
	b43legacy_shm_write16(dev, B43legacy_SHM_SHARED,
3080
	b43legacy_shm_write16(dev, B43legacy_SHM_SHARED,
3177
			      0x0044, 3);
3081
			      0x0044, 3);
Lines 3219-3224 static int b43legacy_wireless_core_init( Link Here
3219
	memset(wl->mac_addr, 0, ETH_ALEN);
3123
	memset(wl->mac_addr, 0, ETH_ALEN);
3220
	b43legacy_upload_card_macaddress(dev);
3124
	b43legacy_upload_card_macaddress(dev);
3221
	b43legacy_security_init(dev);
3125
	b43legacy_security_init(dev);
3126
	b43legacy_rfkill_init(dev);
3222
	b43legacy_rng_init(wl);
3127
	b43legacy_rng_init(wl);
3223
3128
3224
	b43legacy_set_status(dev, B43legacy_STAT_INITIALIZED);
3129
	b43legacy_set_status(dev, B43legacy_STAT_INITIALIZED);
Lines 3239-3246 err_kfree_lo_control: Link Here
3239
	return err;
3144
	return err;
3240
}
3145
}
3241
3146
3242
static int b43legacy_add_interface(struct ieee80211_hw *hw,
3147
static int b43legacy_op_add_interface(struct ieee80211_hw *hw,
3243
				   struct ieee80211_if_init_conf *conf)
3148
				      struct ieee80211_if_init_conf *conf)
3244
{
3149
{
3245
	struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
3150
	struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
3246
	struct b43legacy_wldev *dev;
3151
	struct b43legacy_wldev *dev;
Lines 3279-3286 static int b43legacy_add_interface(struc Link Here
3279
	return err;
3184
	return err;
3280
}
3185
}
3281
3186
3282
static void b43legacy_remove_interface(struct ieee80211_hw *hw,
3187
static void b43legacy_op_remove_interface(struct ieee80211_hw *hw,
3283
				       struct ieee80211_if_init_conf *conf)
3188
					  struct ieee80211_if_init_conf *conf)
3284
{
3189
{
3285
	struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
3190
	struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
3286
	struct b43legacy_wldev *dev = wl->current_dev;
3191
	struct b43legacy_wldev *dev = wl->current_dev;
Lines 3304-3310 static void b43legacy_remove_interface(s Link Here
3304
	mutex_unlock(&wl->mutex);
3209
	mutex_unlock(&wl->mutex);
3305
}
3210
}
3306
3211
3307
static int b43legacy_start(struct ieee80211_hw *hw)
3212
static int b43legacy_op_start(struct ieee80211_hw *hw)
3308
{
3213
{
3309
	struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
3214
	struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
3310
	struct b43legacy_wldev *dev = wl->current_dev;
3215
	struct b43legacy_wldev *dev = wl->current_dev;
Lines 3335-3341 out_mutex_unlock: Link Here
3335
	return err;
3240
	return err;
3336
}
3241
}
3337
3242
3338
static void b43legacy_stop(struct ieee80211_hw *hw)
3243
static void b43legacy_op_stop(struct ieee80211_hw *hw)
3339
{
3244
{
3340
	struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
3245
	struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
3341
	struct b43legacy_wldev *dev = wl->current_dev;
3246
	struct b43legacy_wldev *dev = wl->current_dev;
Lines 3347-3366 static void b43legacy_stop(struct ieee80 Link Here
3347
	mutex_unlock(&wl->mutex);
3252
	mutex_unlock(&wl->mutex);
3348
}
3253
}
3349
3254
3255
static int b43legacy_op_set_retry_limit(struct ieee80211_hw *hw,
3256
					u32 short_retry_limit,
3257
					u32 long_retry_limit)
3258
{
3259
	struct b43legacy_wl *wl = hw_to_b43legacy_wl(hw);
3260
	struct b43legacy_wldev *dev;
3261
	int err = 0;
3262
3263
	mutex_lock(&wl->mutex);
3264
	dev = wl->current_dev;
3265
	if (unlikely(!dev ||
3266
		     (b43legacy_status(dev) < B43legacy_STAT_INITIALIZED))) {
3267
		err = -ENODEV;
3268
		goto out_unlock;
3269
	}
3270
	b43legacy_set_retry_limits(dev, short_retry_limit, long_retry_limit);
3271
out_unlock:
3272
	mutex_unlock(&wl->mutex);
3273
3274
	return err;
3275
}
3350
3276
3351
static const struct ieee80211_ops b43legacy_hw_ops = {
3277
static const struct ieee80211_ops b43legacy_hw_ops = {
3352
	.tx = b43legacy_tx,
3278
	.tx			= b43legacy_op_tx,
3353
	.conf_tx = b43legacy_conf_tx,
3279
	.conf_tx		= b43legacy_op_conf_tx,
3354
	.add_interface = b43legacy_add_interface,
3280
	.add_interface		= b43legacy_op_add_interface,
3355
	.remove_interface = b43legacy_remove_interface,
3281
	.remove_interface	= b43legacy_op_remove_interface,
3356
	.config = b43legacy_dev_config,
3282
	.config			= b43legacy_op_dev_config,
3357
	.config_interface = b43legacy_config_interface,
3283
	.config_interface	= b43legacy_op_config_interface,
3358
	.set_key = b43legacy_dev_set_key,
3284
	.configure_filter	= b43legacy_op_configure_filter,
3359
	.configure_filter = b43legacy_configure_filter,
3285
	.get_stats		= b43legacy_op_get_stats,
3360
	.get_stats = b43legacy_get_stats,
3286
	.get_tx_stats		= b43legacy_op_get_tx_stats,
3361
	.get_tx_stats = b43legacy_get_tx_stats,
3287
	.start			= b43legacy_op_start,
3362
	.start = b43legacy_start,
3288
	.stop			= b43legacy_op_stop,
3363
	.stop = b43legacy_stop,
3289
	.set_retry_limit	= b43legacy_op_set_retry_limit,
3364
};
3290
};
3365
3291
3366
/* Hard-reset the chip. Do not call this directly.
3292
/* Hard-reset the chip. Do not call this directly.
Lines 3498-3515 static int b43legacy_wireless_core_attac Link Here
3498
	else
3424
	else
3499
		have_bphy = 1;
3425
		have_bphy = 1;
3500
3426
3501
	/* Initialize LEDs structs. */
3502
	err = b43legacy_leds_init(dev);
3503
	if (err)
3504
		goto err_powerdown;
3505
3506
	dev->phy.gmode = (have_gphy || have_bphy);
3427
	dev->phy.gmode = (have_gphy || have_bphy);
3507
	tmp = dev->phy.gmode ? B43legacy_TMSLOW_GMODE : 0;
3428
	tmp = dev->phy.gmode ? B43legacy_TMSLOW_GMODE : 0;
3508
	b43legacy_wireless_core_reset(dev, tmp);
3429
	b43legacy_wireless_core_reset(dev, tmp);
3509
3430
3510
	err = b43legacy_phy_versioning(dev);
3431
	err = b43legacy_phy_versioning(dev);
3511
	if (err)
3432
	if (err)
3512
		goto err_leds_exit;
3433
		goto err_powerdown;
3513
	/* Check if this device supports multiband. */
3434
	/* Check if this device supports multiband. */
3514
	if (!pdev ||
3435
	if (!pdev ||
3515
	    (pdev->device != 0x4312 &&
3436
	    (pdev->device != 0x4312 &&
Lines 3535-3551 static int b43legacy_wireless_core_attac Link Here
3535
3456
3536
	err = b43legacy_validate_chipaccess(dev);
3457
	err = b43legacy_validate_chipaccess(dev);
3537
	if (err)
3458
	if (err)
3538
		goto err_leds_exit;
3459
		goto err_powerdown;
3539
	err = b43legacy_setup_modes(dev, have_bphy, have_gphy);
3460
	err = b43legacy_setup_modes(dev, have_bphy, have_gphy);
3540
	if (err)
3461
	if (err)
3541
		goto err_leds_exit;
3462
		goto err_powerdown;
3542
3463
3543
	/* Now set some default "current_dev" */
3464
	/* Now set some default "current_dev" */
3544
	if (!wl->current_dev)
3465
	if (!wl->current_dev)
3545
		wl->current_dev = dev;
3466
		wl->current_dev = dev;
3546
	INIT_WORK(&dev->restart_work, b43legacy_chip_reset);
3467
	INIT_WORK(&dev->restart_work, b43legacy_chip_reset);
3547
3468
3548
	b43legacy_radio_turn_off(dev);
3469
	b43legacy_radio_turn_off(dev, 1);
3549
	b43legacy_switch_analog(dev, 0);
3470
	b43legacy_switch_analog(dev, 0);
3550
	ssb_device_disable(dev->dev, 0);
3471
	ssb_device_disable(dev->dev, 0);
3551
	ssb_bus_may_powerdown(bus);
3472
	ssb_bus_may_powerdown(bus);
Lines 3553-3560 static int b43legacy_wireless_core_attac Link Here
3553
out:
3474
out:
3554
	return err;
3475
	return err;
3555
3476
3556
err_leds_exit:
3557
	b43legacy_leds_exit(dev);
3558
err_powerdown:
3477
err_powerdown:
3559
	ssb_bus_may_powerdown(bus);
3478
	ssb_bus_may_powerdown(bus);
3560
	return err;
3479
	return err;
Lines 3637-3648 static void b43legacy_sprom_fixup(struct Link Here
3637
	if (bus->boardinfo.vendor == PCI_VENDOR_ID_APPLE &&
3556
	if (bus->boardinfo.vendor == PCI_VENDOR_ID_APPLE &&
3638
	    bus->boardinfo.type == 0x4E &&
3557
	    bus->boardinfo.type == 0x4E &&
3639
	    bus->boardinfo.rev > 0x40)
3558
	    bus->boardinfo.rev > 0x40)
3640
		bus->sprom.r1.boardflags_lo |= B43legacy_BFL_PACTRL;
3559
		bus->sprom.boardflags_lo |= B43legacy_BFL_PACTRL;
3641
3560
3642
	/* Convert Antennagain values to Q5.2 */
3561
	/* Convert Antennagain values to Q5.2 */
3643
	if (bus->sprom.r1.antenna_gain_bg == 0xFF)
3562
	if (bus->sprom.antenna_gain_bg == 0xFF)
3644
		bus->sprom.r1.antenna_gain_bg = 2; /* if unset, use 2 dBm */
3563
		bus->sprom.antenna_gain_bg = 2; /* if unset, use 2 dBm */
3645
	bus->sprom.r1.antenna_gain_bg <<= 2;
3564
	bus->sprom.antenna_gain_bg <<= 2;
3646
}
3565
}
3647
3566
3648
static void b43legacy_wireless_exit(struct ssb_device *dev,
3567
static void b43legacy_wireless_exit(struct ssb_device *dev,
Lines 3677-3686 static int b43legacy_wireless_init(struc Link Here
3677
	hw->max_noise = -110;
3596
	hw->max_noise = -110;
3678
	hw->queues = 1; /* FIXME: hardware has more queues */
3597
	hw->queues = 1; /* FIXME: hardware has more queues */
3679
	SET_IEEE80211_DEV(hw, dev->dev);
3598
	SET_IEEE80211_DEV(hw, dev->dev);
3680
	if (is_valid_ether_addr(sprom->r1.et1mac))
3599
	if (is_valid_ether_addr(sprom->et1mac))
3681
		SET_IEEE80211_PERM_ADDR(hw, sprom->r1.et1mac);
3600
		SET_IEEE80211_PERM_ADDR(hw, sprom->et1mac);
3682
	else
3601
	else
3683
		SET_IEEE80211_PERM_ADDR(hw, sprom->r1.il0mac);
3602
		SET_IEEE80211_PERM_ADDR(hw, sprom->il0mac);
3684
3603
3685
	/* Get and initialize struct b43legacy_wl */
3604
	/* Get and initialize struct b43legacy_wl */
3686
	wl = hw_to_b43legacy_wl(hw);
3605
	wl = hw_to_b43legacy_wl(hw);
(-)linux-2.6/drivers/net/wireless/b43legacy/main.h (-1 / +1 lines)
Lines 3-9 Link Here
3
  Broadcom B43legacy wireless driver
3
  Broadcom B43legacy wireless driver
4
4
5
  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
5
  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
6
  Copyright (c) 2005 Stefano Brivio <st3@riseup.net>
6
  Copyright (c) 2005 Stefano Brivio <stefano.brivio@polimi.it>
7
  Copyright (c) 2005, 2006 Michael Buesch <mb@bu3sch.de>
7
  Copyright (c) 2005, 2006 Michael Buesch <mb@bu3sch.de>
8
  Copyright (c) 2005  Danny van Dyk <kugelfang@gentoo.org>
8
  Copyright (c) 2005  Danny van Dyk <kugelfang@gentoo.org>
9
  Copyright (c) 2005  Andreas Jaggi <andreas.jaggi@waterwave.ch>
9
  Copyright (c) 2005  Andreas Jaggi <andreas.jaggi@waterwave.ch>
(-)linux-2.6/drivers/net/wireless/b43legacy/Makefile (-12 / +17 lines)
Lines 1-14 Link Here
1
obj-$(CONFIG_B43LEGACY) += b43legacy.o
1
# b43legacy core
2
b43legacy-obj-$(CONFIG_B43LEGACY_DEBUG) += debugfs.o
2
b43legacy-y				+= main.o
3
b43legacy-y				+= ilt.o
4
b43legacy-y				+= phy.o
5
b43legacy-y				+= radio.o
6
b43legacy-y				+= sysfs.o
7
b43legacy-y				+= xmit.o
8
# b43 RFKILL button support
9
b43legacy-$(CONFIG_B43LEGACY_RFKILL)	+= rfkill.o
10
# b43legacy LED support
11
b43legacy-$(CONFIG_B43LEGACY_LEDS)	+= leds.o
12
# b43legacy debugging
13
b43legacy-$(CONFIG_B43LEGACY_DEBUG)	+= debugfs.o
14
# b43legacy DMA and PIO
15
b43legacy-$(CONFIG_B43LEGACY_DMA)	+= dma.o
16
b43legacy-$(CONFIG_B43LEGACY_PIO)	+= pio.o
3
17
4
b43legacy-obj-$(CONFIG_B43LEGACY_DMA) += dma.o
18
obj-$(CONFIG_B43LEGACY)			+= b43legacy.o
5
b43legacy-obj-$(CONFIG_B43LEGACY_PIO) += pio.o
6
19
7
b43legacy-objs := main.o \
8
		ilt.o \
9
		leds.o \
10
		phy.o \
11
		radio.o \
12
		sysfs.o \
13
		xmit.o \
14
		$(b43legacy-obj-y)
(-)linux-2.6/drivers/net/wireless/b43legacy/phy.c (-19 / +21 lines)
Lines 3-9 Link Here
3
  Broadcom B43legacy wireless driver
3
  Broadcom B43legacy wireless driver
4
4
5
  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
5
  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
6
		     Stefano Brivio <st3@riseup.net>
6
		     Stefano Brivio <stefano.brivio@polimi.it>
7
		     Michael Buesch <mbuesch@freenet.de>
7
		     Michael Buesch <mbuesch@freenet.de>
8
		     Danny van Dyk <kugelfang@gentoo.org>
8
		     Danny van Dyk <kugelfang@gentoo.org>
9
     Andreas Jaggi <andreas.jaggi@waterwave.ch>
9
     Andreas Jaggi <andreas.jaggi@waterwave.ch>
Lines 441-447 static void b43legacy_phy_inita(struct b Link Here
441
	might_sleep();
441
	might_sleep();
442
442
443
	b43legacy_phy_setupg(dev);
443
	b43legacy_phy_setupg(dev);
444
	if (dev->dev->bus->sprom.r1.boardflags_lo & B43legacy_BFL_PACTRL)
444
	if (dev->dev->bus->sprom.boardflags_lo & B43legacy_BFL_PACTRL)
445
		b43legacy_phy_write(dev, 0x046E, 0x03CF);
445
		b43legacy_phy_write(dev, 0x046E, 0x03CF);
446
}
446
}
447
447
Lines 543-549 static void b43legacy_phy_initb4(struct Link Here
543
	if (phy->radio_ver == 0x2050)
543
	if (phy->radio_ver == 0x2050)
544
		b43legacy_phy_write(dev, 0x002A, 0x88C2);
544
		b43legacy_phy_write(dev, 0x002A, 0x88C2);
545
	b43legacy_radio_set_txpower_bg(dev, 0xFFFF, 0xFFFF, 0xFFFF);
545
	b43legacy_radio_set_txpower_bg(dev, 0xFFFF, 0xFFFF, 0xFFFF);
546
	if (dev->dev->bus->sprom.r1.boardflags_lo & B43legacy_BFL_RSSI) {
546
	if (dev->dev->bus->sprom.boardflags_lo & B43legacy_BFL_RSSI) {
547
		b43legacy_calc_nrssi_slope(dev);
547
		b43legacy_calc_nrssi_slope(dev);
548
		b43legacy_calc_nrssi_threshold(dev);
548
		b43legacy_calc_nrssi_threshold(dev);
549
	}
549
	}
Lines 699-705 static void b43legacy_phy_initb6(struct Link Here
699
		b43legacy_radio_write16(dev, 0x005A, 0x0088);
699
		b43legacy_radio_write16(dev, 0x005A, 0x0088);
700
		b43legacy_radio_write16(dev, 0x005B, 0x006B);
700
		b43legacy_radio_write16(dev, 0x005B, 0x006B);
701
		b43legacy_radio_write16(dev, 0x005C, 0x000F);
701
		b43legacy_radio_write16(dev, 0x005C, 0x000F);
702
		if (dev->dev->bus->sprom.r1.boardflags_lo & 0x8000) {
702
		if (dev->dev->bus->sprom.boardflags_lo & 0x8000) {
703
			b43legacy_radio_write16(dev, 0x005D, 0x00FA);
703
			b43legacy_radio_write16(dev, 0x005D, 0x00FA);
704
			b43legacy_radio_write16(dev, 0x005E, 0x00D8);
704
			b43legacy_radio_write16(dev, 0x005E, 0x00D8);
705
		} else {
705
		} else {
Lines 797-803 static void b43legacy_phy_initb6(struct Link Here
797
		b43legacy_phy_write(dev, 0x0062, 0x0007);
797
		b43legacy_phy_write(dev, 0x0062, 0x0007);
798
		b43legacy_radio_init2050(dev);
798
		b43legacy_radio_init2050(dev);
799
		b43legacy_phy_lo_g_measure(dev);
799
		b43legacy_phy_lo_g_measure(dev);
800
		if (dev->dev->bus->sprom.r1.boardflags_lo &
800
		if (dev->dev->bus->sprom.boardflags_lo &
801
		    B43legacy_BFL_RSSI) {
801
		    B43legacy_BFL_RSSI) {
802
			b43legacy_calc_nrssi_slope(dev);
802
			b43legacy_calc_nrssi_slope(dev);
803
			b43legacy_calc_nrssi_threshold(dev);
803
			b43legacy_calc_nrssi_threshold(dev);
Lines 921-927 static void b43legacy_calc_loopback_gain Link Here
921
			    b43legacy_phy_read(dev, 0x0811) | 0x0100);
921
			    b43legacy_phy_read(dev, 0x0811) | 0x0100);
922
	b43legacy_phy_write(dev, 0x0812,
922
	b43legacy_phy_write(dev, 0x0812,
923
			    b43legacy_phy_read(dev, 0x0812) & 0xCFFF);
923
			    b43legacy_phy_read(dev, 0x0812) & 0xCFFF);
924
	if (dev->dev->bus->sprom.r1.boardflags_lo & B43legacy_BFL_EXTLNA) {
924
	if (dev->dev->bus->sprom.boardflags_lo & B43legacy_BFL_EXTLNA) {
925
		if (phy->rev >= 7) {
925
		if (phy->rev >= 7) {
926
			b43legacy_phy_write(dev, 0x0811,
926
			b43legacy_phy_write(dev, 0x0811,
927
					    b43legacy_phy_read(dev, 0x0811)
927
					    b43legacy_phy_read(dev, 0x0811)
Lines 1072-1078 static void b43legacy_phy_initg(struct b Link Here
1072
			b43legacy_phy_write(dev, 0x0036,
1072
			b43legacy_phy_write(dev, 0x0036,
1073
					    (b43legacy_phy_read(dev, 0x0036)
1073
					    (b43legacy_phy_read(dev, 0x0036)
1074
					     & 0x0FFF) | (phy->txctl2 << 12));
1074
					     & 0x0FFF) | (phy->txctl2 << 12));
1075
		if (dev->dev->bus->sprom.r1.boardflags_lo &
1075
		if (dev->dev->bus->sprom.boardflags_lo &
1076
		    B43legacy_BFL_PACTRL)
1076
		    B43legacy_BFL_PACTRL)
1077
			b43legacy_phy_write(dev, 0x002E, 0x8075);
1077
			b43legacy_phy_write(dev, 0x002E, 0x8075);
1078
		else
1078
		else
Lines 1087-1093 static void b43legacy_phy_initg(struct b Link Here
1087
		b43legacy_phy_write(dev, 0x080F, 0x8078);
1087
		b43legacy_phy_write(dev, 0x080F, 0x8078);
1088
	}
1088
	}
1089
1089
1090
	if (!(dev->dev->bus->sprom.r1.boardflags_lo & B43legacy_BFL_RSSI)) {
1090
	if (!(dev->dev->bus->sprom.boardflags_lo & B43legacy_BFL_RSSI)) {
1091
		/* The specs state to update the NRSSI LT with
1091
		/* The specs state to update the NRSSI LT with
1092
		 * the value 0x7FFFFFFF here. I think that is some weird
1092
		 * the value 0x7FFFFFFF here. I think that is some weird
1093
		 * compiler optimization in the original driver.
1093
		 * compiler optimization in the original driver.
Lines 1838-1846 void b43legacy_phy_xmitpower(struct b43l Link Here
1838
1838
1839
	estimated_pwr = b43legacy_phy_estimate_power_out(dev, average);
1839
	estimated_pwr = b43legacy_phy_estimate_power_out(dev, average);
1840
1840
1841
	max_pwr = dev->dev->bus->sprom.r1.maxpwr_bg;
1841
	max_pwr = dev->dev->bus->sprom.maxpwr_bg;
1842
1842
1843
	if ((dev->dev->bus->sprom.r1.boardflags_lo
1843
	if ((dev->dev->bus->sprom.boardflags_lo
1844
	     & B43legacy_BFL_PACTRL) &&
1844
	     & B43legacy_BFL_PACTRL) &&
1845
	    (phy->type == B43legacy_PHYTYPE_G))
1845
	    (phy->type == B43legacy_PHYTYPE_G))
1846
		max_pwr -= 0x3;
1846
		max_pwr -= 0x3;
Lines 1848-1854 void b43legacy_phy_xmitpower(struct b43l Link Here
1848
		b43legacywarn(dev->wl, "Invalid max-TX-power value in SPROM."
1848
		b43legacywarn(dev->wl, "Invalid max-TX-power value in SPROM."
1849
			"\n");
1849
			"\n");
1850
		max_pwr = 74; /* fake it */
1850
		max_pwr = 74; /* fake it */
1851
		dev->dev->bus->sprom.r1.maxpwr_bg = max_pwr;
1851
		dev->dev->bus->sprom.maxpwr_bg = max_pwr;
1852
	}
1852
	}
1853
1853
1854
	/* Use regulatory information to get the maximum power.
1854
	/* Use regulatory information to get the maximum power.
Lines 1858-1864 void b43legacy_phy_xmitpower(struct b43l Link Here
1858
	 * and 1.5 dBm (a safety factor??). The result is in Q5.2 format
1858
	 * and 1.5 dBm (a safety factor??). The result is in Q5.2 format
1859
	 * which accounts for the factor of 4 */
1859
	 * which accounts for the factor of 4 */
1860
#define REG_MAX_PWR 20
1860
#define REG_MAX_PWR 20
1861
	max_pwr = min(REG_MAX_PWR * 4 - dev->dev->bus->sprom.r1.antenna_gain_bg
1861
	max_pwr = min(REG_MAX_PWR * 4
1862
		      - dev->dev->bus->sprom.antenna_gain_bg
1862
		      - 0x6, max_pwr);
1863
		      - 0x6, max_pwr);
1863
1864
1864
	/* find the desired power in Q5.2 - power_level is in dBm
1865
	/* find the desired power in Q5.2 - power_level is in dBm
Lines 1918-1924 void b43legacy_phy_xmitpower(struct b43l Link Here
1918
				txpower = 3;
1919
				txpower = 3;
1919
				radio_attenuation += 2;
1920
				radio_attenuation += 2;
1920
				baseband_attenuation += 2;
1921
				baseband_attenuation += 2;
1921
			} else if (dev->dev->bus->sprom.r1.boardflags_lo
1922
			} else if (dev->dev->bus->sprom.boardflags_lo
1922
				   & B43legacy_BFL_PACTRL) {
1923
				   & B43legacy_BFL_PACTRL) {
1923
				baseband_attenuation += 4 *
1924
				baseband_attenuation += 4 *
1924
						     (radio_attenuation - 2);
1925
						     (radio_attenuation - 2);
Lines 2000-2008 int b43legacy_phy_init_tssi2dbm_table(st Link Here
2000
2001
2001
	B43legacy_WARN_ON(!(phy->type == B43legacy_PHYTYPE_B ||
2002
	B43legacy_WARN_ON(!(phy->type == B43legacy_PHYTYPE_B ||
2002
			  phy->type == B43legacy_PHYTYPE_G));
2003
			  phy->type == B43legacy_PHYTYPE_G));
2003
	pab0 = (s16)(dev->dev->bus->sprom.r1.pa0b0);
2004
	pab0 = (s16)(dev->dev->bus->sprom.pa0b0);
2004
	pab1 = (s16)(dev->dev->bus->sprom.r1.pa0b1);
2005
	pab1 = (s16)(dev->dev->bus->sprom.pa0b1);
2005
	pab2 = (s16)(dev->dev->bus->sprom.r1.pa0b2);
2006
	pab2 = (s16)(dev->dev->bus->sprom.pa0b2);
2006
2007
2007
	if ((dev->dev->bus->chip_id == 0x4301) && (phy->radio_ver != 0x2050)) {
2008
	if ((dev->dev->bus->chip_id == 0x4301) && (phy->radio_ver != 0x2050)) {
2008
		phy->idle_tssi = 0x34;
2009
		phy->idle_tssi = 0x34;
Lines 2013-2021 int b43legacy_phy_init_tssi2dbm_table(st Link Here
2013
	if (pab0 != 0 && pab1 != 0 && pab2 != 0 &&
2014
	if (pab0 != 0 && pab1 != 0 && pab2 != 0 &&
2014
	    pab0 != -1 && pab1 != -1 && pab2 != -1) {
2015
	    pab0 != -1 && pab1 != -1 && pab2 != -1) {
2015
		/* The pabX values are set in SPROM. Use them. */
2016
		/* The pabX values are set in SPROM. Use them. */
2016
		if ((s8)dev->dev->bus->sprom.r1.itssi_bg != 0 &&
2017
		if ((s8)dev->dev->bus->sprom.itssi_bg != 0 &&
2017
		    (s8)dev->dev->bus->sprom.r1.itssi_bg != -1)
2018
		    (s8)dev->dev->bus->sprom.itssi_bg != -1)
2018
			phy->idle_tssi = (s8)(dev->dev->bus->sprom.r1.itssi_bg);
2019
			phy->idle_tssi = (s8)(dev->dev->bus->sprom.
2020
					  itssi_bg);
2019
		else
2021
		else
2020
			phy->idle_tssi = 62;
2022
			phy->idle_tssi = 62;
2021
		dyn_tssi2dbm = kmalloc(64, GFP_KERNEL);
2023
		dyn_tssi2dbm = kmalloc(64, GFP_KERNEL);
(-)linux-2.6/drivers/net/wireless/b43legacy/phy.h (-1 / +1 lines)
Lines 3-9 Link Here
3
  Broadcom B43legacy wireless driver
3
  Broadcom B43legacy wireless driver
4
4
5
  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
5
  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
6
		     Stefano Brivio <st3@riseup.net>
6
		     Stefano Brivio <stefano.brivio@polimi.it>
7
		     Michael Buesch <mbuesch@freenet.de>
7
		     Michael Buesch <mbuesch@freenet.de>
8
		     Danny van Dyk <kugelfang@gentoo.org>
8
		     Danny van Dyk <kugelfang@gentoo.org>
9
		     Andreas Jaggi <andreas.jaggi@waterwave.ch>
9
		     Andreas Jaggi <andreas.jaggi@waterwave.ch>
(-)linux-2.6/drivers/net/wireless/b43legacy/radio.c (-13 / +16 lines)
Lines 3-9 Link Here
3
  Broadcom B43legacy wireless driver
3
  Broadcom B43legacy wireless driver
4
4
5
  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
5
  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
6
		     Stefano Brivio <st3@riseup.net>
6
		     Stefano Brivio <stefano.brivio@polimi.it>
7
		     Michael Buesch <mbuesch@freenet.de>
7
		     Michael Buesch <mbuesch@freenet.de>
8
		     Danny van Dyk <kugelfang@gentoo.org>
8
		     Danny van Dyk <kugelfang@gentoo.org>
9
		     Andreas Jaggi <andreas.jaggi@waterwave.ch>
9
		     Andreas Jaggi <andreas.jaggi@waterwave.ch>
Lines 827-833 void b43legacy_calc_nrssi_threshold(stru Link Here
827
	case B43legacy_PHYTYPE_B: {
827
	case B43legacy_PHYTYPE_B: {
828
		if (phy->radio_ver != 0x2050)
828
		if (phy->radio_ver != 0x2050)
829
			return;
829
			return;
830
		if (!(dev->dev->bus->sprom.r1.boardflags_lo &
830
		if (!(dev->dev->bus->sprom.boardflags_lo &
831
		    B43legacy_BFL_RSSI))
831
		    B43legacy_BFL_RSSI))
832
			return;
832
			return;
833
833
Lines 857-863 void b43legacy_calc_nrssi_threshold(stru Link Here
857
	}
857
	}
858
	case B43legacy_PHYTYPE_G:
858
	case B43legacy_PHYTYPE_G:
859
		if (!phy->gmode ||
859
		if (!phy->gmode ||
860
		    !(dev->dev->bus->sprom.r1.boardflags_lo &
860
		    !(dev->dev->bus->sprom.boardflags_lo &
861
		    B43legacy_BFL_RSSI)) {
861
		    B43legacy_BFL_RSSI)) {
862
			tmp16 = b43legacy_nrssi_hw_read(dev, 0x20);
862
			tmp16 = b43legacy_nrssi_hw_read(dev, 0x20);
863
			if (tmp16 >= 0x20)
863
			if (tmp16 >= 0x20)
Lines 1406-1412 static u16 b43legacy_get_812_value(struc Link Here
1406
	if (!phy->gmode)
1406
	if (!phy->gmode)
1407
		return 0;
1407
		return 0;
1408
	if (!has_loopback_gain(phy)) {
1408
	if (!has_loopback_gain(phy)) {
1409
		if (phy->rev < 7 || !(dev->dev->bus->sprom.r1.boardflags_lo
1409
		if (phy->rev < 7 || !(dev->dev->bus->sprom.boardflags_lo
1410
		    & B43legacy_BFL_EXTLNA)) {
1410
		    & B43legacy_BFL_EXTLNA)) {
1411
			switch (lpd) {
1411
			switch (lpd) {
1412
			case LPD(0, 1, 1):
1412
			case LPD(0, 1, 1):
Lines 1459-1465 static u16 b43legacy_get_812_value(struc Link Here
1459
		}
1459
		}
1460
1460
1461
		loop_or = (loop << 8) | extern_lna_control;
1461
		loop_or = (loop << 8) | extern_lna_control;
1462
		if (phy->rev >= 7 && dev->dev->bus->sprom.r1.boardflags_lo
1462
		if (phy->rev >= 7 && dev->dev->bus->sprom.boardflags_lo
1463
		    & B43legacy_BFL_EXTLNA) {
1463
		    & B43legacy_BFL_EXTLNA) {
1464
			if (extern_lna_control)
1464
			if (extern_lna_control)
1465
				loop_or |= 0x8000;
1465
				loop_or |= 0x8000;
Lines 1550-1556 u16 b43legacy_radio_init2050(struct b43l Link Here
1550
					    b43legacy_get_812_value(dev,
1550
					    b43legacy_get_812_value(dev,
1551
					    LPD(0, 1, 1)));
1551
					    LPD(0, 1, 1)));
1552
			if (phy->rev < 7 ||
1552
			if (phy->rev < 7 ||
1553
			    !(dev->dev->bus->sprom.r1.boardflags_lo
1553
			    !(dev->dev->bus->sprom.boardflags_lo
1554
			    & B43legacy_BFL_EXTLNA))
1554
			    & B43legacy_BFL_EXTLNA))
1555
				b43legacy_phy_write(dev, 0x0811, 0x01B3);
1555
				b43legacy_phy_write(dev, 0x0811, 0x01B3);
1556
			else
1556
			else
Lines 1786-1792 int b43legacy_radio_selectchannel(struct Link Here
1786
			  channel2freq_bg(channel));
1786
			  channel2freq_bg(channel));
1787
1787
1788
	if (channel == 14) {
1788
	if (channel == 14) {
1789
		if (dev->dev->bus->sprom.r1.country_code == 5)   /* JAPAN) */
1789
		if (dev->dev->bus->sprom.country_code == 5)   /* JAPAN) */
1790
			b43legacy_shm_write32(dev, B43legacy_SHM_SHARED,
1790
			b43legacy_shm_write32(dev, B43legacy_SHM_SHARED,
1791
					      B43legacy_UCODEFLAGS_OFFSET,
1791
					      B43legacy_UCODEFLAGS_OFFSET,
1792
					      b43legacy_shm_read32(dev,
1792
					      b43legacy_shm_read32(dev,
Lines 2113-2133 void b43legacy_radio_turn_on(struct b43l Link Here
2113
		B43legacy_BUG_ON(1);
2113
		B43legacy_BUG_ON(1);
2114
	}
2114
	}
2115
	phy->radio_on = 1;
2115
	phy->radio_on = 1;
2116
	b43legacy_leds_update(dev, 0);
2117
}
2116
}
2118
2117
2119
void b43legacy_radio_turn_off(struct b43legacy_wldev *dev)
2118
void b43legacy_radio_turn_off(struct b43legacy_wldev *dev, bool force)
2120
{
2119
{
2121
	struct b43legacy_phy *phy = &dev->phy;
2120
	struct b43legacy_phy *phy = &dev->phy;
2122
2121
2122
	if (!phy->radio_on && !force)
2123
		return;
2124
2123
	if (phy->type == B43legacy_PHYTYPE_G && dev->dev->id.revision >= 5) {
2125
	if (phy->type == B43legacy_PHYTYPE_G && dev->dev->id.revision >= 5) {
2124
		u16 rfover, rfoverval;
2126
		u16 rfover, rfoverval;
2125
2127
2126
		rfover = b43legacy_phy_read(dev, B43legacy_PHY_RFOVER);
2128
		rfover = b43legacy_phy_read(dev, B43legacy_PHY_RFOVER);
2127
		rfoverval = b43legacy_phy_read(dev, B43legacy_PHY_RFOVERVAL);
2129
		rfoverval = b43legacy_phy_read(dev, B43legacy_PHY_RFOVERVAL);
2128
		phy->radio_off_context.rfover = rfover;
2130
		if (!force) {
2129
		phy->radio_off_context.rfoverval = rfoverval;
2131
			phy->radio_off_context.rfover = rfover;
2130
		phy->radio_off_context.valid = 1;
2132
			phy->radio_off_context.rfoverval = rfoverval;
2133
			phy->radio_off_context.valid = 1;
2134
		}
2131
		b43legacy_phy_write(dev, B43legacy_PHY_RFOVER, rfover | 0x008C);
2135
		b43legacy_phy_write(dev, B43legacy_PHY_RFOVER, rfover | 0x008C);
2132
		b43legacy_phy_write(dev, B43legacy_PHY_RFOVERVAL,
2136
		b43legacy_phy_write(dev, B43legacy_PHY_RFOVERVAL,
2133
				    rfoverval & 0xFF73);
2137
				    rfoverval & 0xFF73);
Lines 2135-2141 void b43legacy_radio_turn_off(struct b43 Link Here
2135
		b43legacy_phy_write(dev, 0x0015, 0xAA00);
2139
		b43legacy_phy_write(dev, 0x0015, 0xAA00);
2136
	phy->radio_on = 0;
2140
	phy->radio_on = 0;
2137
	b43legacydbg(dev->wl, "Radio initialized\n");
2141
	b43legacydbg(dev->wl, "Radio initialized\n");
2138
	b43legacy_leds_update(dev, 0);
2139
}
2142
}
2140
2143
2141
void b43legacy_radio_clear_tssi(struct b43legacy_wldev *dev)
2144
void b43legacy_radio_clear_tssi(struct b43legacy_wldev *dev)
(-)linux-2.6/drivers/net/wireless/b43legacy/radio.h (-2 / +2 lines)
Lines 3-9 Link Here
3
  Broadcom B43legacy wireless driver
3
  Broadcom B43legacy wireless driver
4
4
5
  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
5
  Copyright (c) 2005 Martin Langer <martin-langer@gmx.de>,
6
		     Stefano Brivio <st3@riseup.net>
6
		     Stefano Brivio <stefano.brivio@polimi.it>
7
		     Michael Buesch <mbuesch@freenet.de>
7
		     Michael Buesch <mbuesch@freenet.de>
8
		     Danny van Dyk <kugelfang@gentoo.org>
8
		     Danny van Dyk <kugelfang@gentoo.org>
9
		     Andreas Jaggi <andreas.jaggi@waterwave.ch>
9
		     Andreas Jaggi <andreas.jaggi@waterwave.ch>
Lines 61-67 void b43legacy_radio_write16(struct b43l Link Here
61
u16 b43legacy_radio_init2050(struct b43legacy_wldev *dev);
61
u16 b43legacy_radio_init2050(struct b43legacy_wldev *dev);
62
62
63
void b43legacy_radio_turn_on(struct b43legacy_wldev *dev);
63
void b43legacy_radio_turn_on(struct b43legacy_wldev *dev);
64
void b43legacy_radio_turn_off(struct b43legacy_wldev *dev);
64
void b43legacy_radio_turn_off(struct b43legacy_wldev *dev, bool force);
65
65
66
int b43legacy_radio_selectchannel(struct b43legacy_wldev *dev, u8 channel,
66
int b43legacy_radio_selectchannel(struct b43legacy_wldev *dev, u8 channel,
67
				  int synthetic_pu_workaround);
67
				  int synthetic_pu_workaround);
(-)linux-2.6/drivers/net/wireless/b43legacy/rfkill.c (+189 lines)
Line 0 Link Here
1
/*
2
3
  Broadcom B43 wireless driver
4
  RFKILL support
5
6
  Copyright (c) 2007 Michael Buesch <mb@bu3sch.de>
7
8
  This program is free software; you can redistribute it and/or modify
9
  it under the terms of the GNU General Public License as published by
10
  the Free Software Foundation; either version 2 of the License, or
11
  (at your option) any later version.
12
13
  This program is distributed in the hope that it will be useful,
14
  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
  GNU General Public License for more details.
17
18
  You should have received a copy of the GNU General Public License
19
  along with this program; see the file COPYING.  If not, write to
20
  the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
21
  Boston, MA 02110-1301, USA.
22
23
*/
24
25
#include "rfkill.h"
26
#include "radio.h"
27
#include "b43legacy.h"
28
29
30
/* Returns TRUE, if the radio is enabled in hardware. */
31
static bool b43legacy_is_hw_radio_enabled(struct b43legacy_wldev *dev)
32
{
33
	if (dev->phy.rev >= 3) {
34
		if (!(b43legacy_read32(dev, B43legacy_MMIO_RADIO_HWENABLED_HI)
35
		      & B43legacy_MMIO_RADIO_HWENABLED_HI_MASK))
36
			return 1;
37
	} else {
38
		if (b43legacy_read16(dev, B43legacy_MMIO_RADIO_HWENABLED_LO)
39
		    & B43legacy_MMIO_RADIO_HWENABLED_LO_MASK)
40
			return 1;
41
	}
42
	return 0;
43
}
44
45
/* The poll callback for the hardware button. */
46
static void b43legacy_rfkill_poll(struct input_polled_dev *poll_dev)
47
{
48
	struct b43legacy_wldev *dev = poll_dev->private;
49
	struct b43legacy_wl *wl = dev->wl;
50
	bool enabled;
51
	bool report_change = 0;
52
53
	mutex_lock(&wl->mutex);
54
	B43legacy_WARN_ON(b43legacy_status(dev) < B43legacy_STAT_INITIALIZED);
55
	enabled = b43legacy_is_hw_radio_enabled(dev);
56
	if (unlikely(enabled != dev->radio_hw_enable)) {
57
		dev->radio_hw_enable = enabled;
58
		report_change = 1;
59
		b43legacyinfo(wl, "Radio hardware status changed to %s\n",
60
			enabled ? "ENABLED" : "DISABLED");
61
	}
62
	mutex_unlock(&wl->mutex);
63
64
	if (unlikely(report_change))
65
		input_report_key(poll_dev->input, KEY_WLAN, enabled);
66
}
67
68
/* Called when the RFKILL toggled in software.
69
 * This is called without locking. */
70
static int b43legacy_rfkill_soft_toggle(void *data, enum rfkill_state state)
71
{
72
	struct b43legacy_wldev *dev = data;
73
	struct b43legacy_wl *wl = dev->wl;
74
	int err = 0;
75
76
	if (!wl->rfkill.registered)
77
		return 0;
78
79
	mutex_lock(&wl->mutex);
80
	B43legacy_WARN_ON(b43legacy_status(dev) < B43legacy_STAT_INITIALIZED);
81
	switch (state) {
82
	case RFKILL_STATE_ON:
83
		if (!dev->radio_hw_enable) {
84
			/* No luck. We can't toggle the hardware RF-kill
85
			 * button from software. */
86
			err = -EBUSY;
87
			goto out_unlock;
88
		}
89
		if (!dev->phy.radio_on)
90
			b43legacy_radio_turn_on(dev);
91
		break;
92
	case RFKILL_STATE_OFF:
93
		if (dev->phy.radio_on)
94
			b43legacy_radio_turn_off(dev, 0);
95
		break;
96
	}
97
98
out_unlock:
99
	mutex_unlock(&wl->mutex);
100
101
	return err;
102
}
103
104
char * b43legacy_rfkill_led_name(struct b43legacy_wldev *dev)
105
{
106
	struct b43legacy_wl *wl = dev->wl;
107
108
	if (!wl->rfkill.rfkill)
109
		return NULL;
110
	return rfkill_get_led_name(wl->rfkill.rfkill);
111
}
112
113
void b43legacy_rfkill_init(struct b43legacy_wldev *dev)
114
{
115
	struct b43legacy_wl *wl = dev->wl;
116
	struct b43legacy_rfkill *rfk = &(wl->rfkill);
117
	int err;
118
119
	if (rfk->rfkill) {
120
		err = rfkill_register(rfk->rfkill);
121
		if (err) {
122
			b43legacywarn(wl, "Failed to register RF-kill button\n");
123
			goto err_free_rfk;
124
		}
125
	}
126
	if (rfk->poll_dev) {
127
		err = input_register_polled_device(rfk->poll_dev);
128
		if (err) {
129
			b43legacywarn(wl, "Failed to register RF-kill polldev\n");
130
			goto err_free_polldev;
131
		}
132
	}
133
134
	return;
135
err_free_rfk:
136
	rfkill_free(rfk->rfkill);
137
	rfk->rfkill = NULL;
138
err_free_polldev:
139
	input_free_polled_device(rfk->poll_dev);
140
	rfk->poll_dev = NULL;
141
}
142
143
void b43legacy_rfkill_exit(struct b43legacy_wldev *dev)
144
{
145
	struct b43legacy_rfkill *rfk = &(dev->wl->rfkill);
146
147
	if (rfk->poll_dev)
148
		input_unregister_polled_device(rfk->poll_dev);
149
	if (rfk->rfkill)
150
		rfkill_unregister(rfk->rfkill);
151
}
152
153
void b43legacy_rfkill_alloc(struct b43legacy_wldev *dev)
154
{
155
	struct b43legacy_wl *wl = dev->wl;
156
	struct b43legacy_rfkill *rfk = &(wl->rfkill);
157
158
	snprintf(rfk->name, sizeof(rfk->name),
159
		 "b43legacy-%s", wiphy_name(wl->hw->wiphy));
160
161
	rfk->rfkill = rfkill_allocate(dev->dev->dev, RFKILL_TYPE_WLAN);
162
	if (!rfk->rfkill) {
163
		b43legacywarn(wl, "Failed to allocate RF-kill button\n");
164
		return;
165
	}
166
	rfk->rfkill->name = rfk->name;
167
	rfk->rfkill->state = RFKILL_STATE_ON;
168
	rfk->rfkill->data = dev;
169
	rfk->rfkill->toggle_radio = b43legacy_rfkill_soft_toggle;
170
	rfk->rfkill->user_claim_unsupported = 1;
171
172
	rfk->poll_dev = input_allocate_polled_device();
173
	if (rfk->poll_dev) {
174
		rfk->poll_dev->private = dev;
175
		rfk->poll_dev->poll = b43legacy_rfkill_poll;
176
		rfk->poll_dev->poll_interval = 1000; /* msecs */
177
	} else
178
		b43legacywarn(wl, "Failed to allocate RF-kill polldev\n");
179
}
180
181
void b43legacy_rfkill_free(struct b43legacy_wldev *dev)
182
{
183
	struct b43legacy_rfkill *rfk = &(dev->wl->rfkill);
184
185
	input_free_polled_device(rfk->poll_dev);
186
	rfk->poll_dev = NULL;
187
	rfkill_free(rfk->rfkill);
188
	rfk->rfkill = NULL;
189
}
(-)linux-2.6/drivers/net/wireless/b43legacy/rfkill.h (+59 lines)
Line 0 Link Here
1
#ifndef B43legacy_RFKILL_H_
2
#define B43legacy_RFKILL_H_
3
4
struct b43legacy_wldev;
5
6
#ifdef CONFIG_B43LEGACY_RFKILL
7
8
#include <linux/rfkill.h>
9
#include <linux/workqueue.h>
10
#include <linux/input-polldev.h>
11
12
13
14
struct b43legacy_rfkill {
15
	/* The RFKILL subsystem data structure */
16
	struct rfkill *rfkill;
17
	/* The poll device for the RFKILL input button */
18
	struct input_polled_dev *poll_dev;
19
	/* Did initialization succeed? Used for freeing. */
20
	bool registered;
21
	/* The unique name of this rfkill switch */
22
	char name[sizeof("b43legacy-phy4294967295")];
23
};
24
25
/* The init function returns void, because we are not interested
26
 * in failing the b43 init process when rfkill init failed. */
27
void b43legacy_rfkill_init(struct b43legacy_wldev *dev);
28
void b43legacy_rfkill_exit(struct b43legacy_wldev *dev);
29
30
char * b43legacy_rfkill_led_name(struct b43legacy_wldev *dev);
31
32
33
#else /* CONFIG_B43LEGACY_RFKILL */
34
/* No RFKILL support. */
35
36
struct b43legacy_rfkill {
37
	/* empty */
38
};
39
40
static inline void b43legacy_rfkill_alloc(struct b43legacy_wldev *dev)
41
{
42
}
43
static inline void b43legacy_rfkill_free(struct b43legacy_wldev *dev)
44
{
45
}
46
static inline void b43legacy_rfkill_init(struct b43legacy_wldev *dev)
47
{
48
}
49
static inline void b43legacy_rfkill_exit(struct b43legacy_wldev *dev)
50
{
51
}
52
static inline char * b43legacy_rfkill_led_name(struct b43legacy_wldev *dev)
53
{
54
	return NULL;
55
}
56
57
#endif /* CONFIG_B43LEGACY_RFKILL */
58
59
#endif /* B43legacy_RFKILL_H_ */
(-)linux-2.6/drivers/net/wireless/b43legacy/xmit.c (-3 / +4 lines)
Lines 5-11 Link Here
5
  Transmission (TX/RX) related functions.
5
  Transmission (TX/RX) related functions.
6
6
7
  Copyright (C) 2005 Martin Langer <martin-langer@gmx.de>
7
  Copyright (C) 2005 Martin Langer <martin-langer@gmx.de>
8
  Copyright (C) 2005 Stefano Brivio <st3@riseup.net>
8
  Copyright (C) 2005 Stefano Brivio <stefano.brivio@polimi.it>
9
  Copyright (C) 2005, 2006 Michael Buesch <mb@bu3sch.de>
9
  Copyright (C) 2005, 2006 Michael Buesch <mb@bu3sch.de>
10
  Copyright (C) 2005 Danny van Dyk <kugelfang@gentoo.org>
10
  Copyright (C) 2005 Danny van Dyk <kugelfang@gentoo.org>
11
  Copyright (C) 2005 Andreas Jaggi <andreas.jaggi@waterwave.ch>
11
  Copyright (C) 2005 Andreas Jaggi <andreas.jaggi@waterwave.ch>
Lines 290-295 static void generate_txhdr_fw3(struct b4 Link Here
290
		mac_ctl |= B43legacy_TX4_MAC_STMSDU;
290
		mac_ctl |= B43legacy_TX4_MAC_STMSDU;
291
	if (rate_fb_ofdm)
291
	if (rate_fb_ofdm)
292
		mac_ctl |= B43legacy_TX4_MAC_FALLBACKOFDM;
292
		mac_ctl |= B43legacy_TX4_MAC_FALLBACKOFDM;
293
	if (txctl->flags & IEEE80211_TXCTL_LONG_RETRY_LIMIT)
294
		mac_ctl |= B43legacy_TX4_MAC_LONGFRAME;
293
295
294
	/* Generate the RTS or CTS-to-self frame */
296
	/* Generate the RTS or CTS-to-self frame */
295
	if ((txctl->flags & IEEE80211_TXCTL_USE_RTS_CTS) ||
297
	if ((txctl->flags & IEEE80211_TXCTL_USE_RTS_CTS) ||
Lines 335-341 static void generate_txhdr_fw3(struct b4 Link Here
335
					    len, rts_rate_fb);
337
					    len, rts_rate_fb);
336
		hdr = (struct ieee80211_hdr *)(&txhdr->rts_frame);
338
		hdr = (struct ieee80211_hdr *)(&txhdr->rts_frame);
337
		txhdr->rts_dur_fb = hdr->duration_id;
339
		txhdr->rts_dur_fb = hdr->duration_id;
338
		mac_ctl |= B43legacy_TX4_MAC_LONGFRAME;
339
	}
340
	}
340
341
341
	/* Magic cookie */
342
	/* Magic cookie */
Lines 378-384 static s8 b43legacy_rssi_postprocess(str Link Here
378
			else
379
			else
379
				tmp -= 3;
380
				tmp -= 3;
380
		} else {
381
		} else {
381
			if (dev->dev->bus->sprom.r1.boardflags_lo
382
			if (dev->dev->bus->sprom.boardflags_lo
382
			    & B43legacy_BFL_RSSI) {
383
			    & B43legacy_BFL_RSSI) {
383
				if (in_rssi > 63)
384
				if (in_rssi > 63)
384
					in_rssi = 63;
385
					in_rssi = 63;
(-)linux-2.6/drivers/net/b44.c (-4 / +4 lines)
Lines 2060-2070 static int __devinit b44_get_invariants( Link Here
2060
2060
2061
	if (sdev->bus->bustype == SSB_BUSTYPE_SSB &&
2061
	if (sdev->bus->bustype == SSB_BUSTYPE_SSB &&
2062
	    instance > 1) {
2062
	    instance > 1) {
2063
		addr = sdev->bus->sprom.r1.et1mac;
2063
		addr = sdev->bus->sprom.et1mac;
2064
		bp->phy_addr = sdev->bus->sprom.r1.et1phyaddr;
2064
		bp->phy_addr = sdev->bus->sprom.et1phyaddr;
2065
	} else {
2065
	} else {
2066
		addr = sdev->bus->sprom.r1.et0mac;
2066
		addr = sdev->bus->sprom.et0mac;
2067
		bp->phy_addr = sdev->bus->sprom.r1.et0phyaddr;
2067
		bp->phy_addr = sdev->bus->sprom.et0phyaddr;
2068
	}
2068
	}
2069
	memcpy(bp->dev->dev_addr, addr, 6);
2069
	memcpy(bp->dev->dev_addr, addr, 6);
2070
2070

Return to bug 207532