b43: fix DMA on some bugged hardware
Some hardware with 64-bit DMA uses lower address word for setting routing (translation) bit. Add workaround for such boards. Signed-off-by: Rafał Miłecki <zajec5@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
parent
04023afcce
commit
0cc9772a6b
3 changed files with 84 additions and 36 deletions
|
@ -594,6 +594,7 @@ struct b43_dma {
|
||||||
struct b43_dmaring *rx_ring;
|
struct b43_dmaring *rx_ring;
|
||||||
|
|
||||||
u32 translation; /* Routing bits */
|
u32 translation; /* Routing bits */
|
||||||
|
bool translation_in_low; /* Should translation bit go into low addr? */
|
||||||
bool parity; /* Check for parity */
|
bool parity; /* Check for parity */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -47,6 +47,38 @@
|
||||||
* into separate slots. */
|
* into separate slots. */
|
||||||
#define TX_SLOTS_PER_FRAME 2
|
#define TX_SLOTS_PER_FRAME 2
|
||||||
|
|
||||||
|
static u32 b43_dma_address(struct b43_dma *dma, dma_addr_t dmaaddr,
|
||||||
|
enum b43_addrtype addrtype)
|
||||||
|
{
|
||||||
|
u32 uninitialized_var(addr);
|
||||||
|
|
||||||
|
switch (addrtype) {
|
||||||
|
case B43_DMA_ADDR_LOW:
|
||||||
|
addr = lower_32_bits(dmaaddr);
|
||||||
|
if (dma->translation_in_low) {
|
||||||
|
addr &= ~SSB_DMA_TRANSLATION_MASK;
|
||||||
|
addr |= dma->translation;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case B43_DMA_ADDR_HIGH:
|
||||||
|
addr = upper_32_bits(dmaaddr);
|
||||||
|
if (!dma->translation_in_low) {
|
||||||
|
addr &= ~SSB_DMA_TRANSLATION_MASK;
|
||||||
|
addr |= dma->translation;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case B43_DMA_ADDR_EXT:
|
||||||
|
if (dma->translation_in_low)
|
||||||
|
addr = lower_32_bits(dmaaddr);
|
||||||
|
else
|
||||||
|
addr = upper_32_bits(dmaaddr);
|
||||||
|
addr &= SSB_DMA_TRANSLATION_MASK;
|
||||||
|
addr >>= SSB_DMA_TRANSLATION_SHIFT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return addr;
|
||||||
|
}
|
||||||
|
|
||||||
/* 32bit DMA ops. */
|
/* 32bit DMA ops. */
|
||||||
static
|
static
|
||||||
|
@ -77,10 +109,9 @@ static void op32_fill_descriptor(struct b43_dmaring *ring,
|
||||||
slot = (int)(&(desc->dma32) - descbase);
|
slot = (int)(&(desc->dma32) - descbase);
|
||||||
B43_WARN_ON(!(slot >= 0 && slot < ring->nr_slots));
|
B43_WARN_ON(!(slot >= 0 && slot < ring->nr_slots));
|
||||||
|
|
||||||
addr = (u32) (dmaaddr & ~SSB_DMA_TRANSLATION_MASK);
|
addr = b43_dma_address(&ring->dev->dma, dmaaddr, B43_DMA_ADDR_LOW);
|
||||||
addrext = (u32) (dmaaddr & SSB_DMA_TRANSLATION_MASK)
|
addrext = b43_dma_address(&ring->dev->dma, dmaaddr, B43_DMA_ADDR_EXT);
|
||||||
>> SSB_DMA_TRANSLATION_SHIFT;
|
|
||||||
addr |= ring->dev->dma.translation;
|
|
||||||
ctl = bufsize & B43_DMA32_DCTL_BYTECNT;
|
ctl = bufsize & B43_DMA32_DCTL_BYTECNT;
|
||||||
if (slot == ring->nr_slots - 1)
|
if (slot == ring->nr_slots - 1)
|
||||||
ctl |= B43_DMA32_DCTL_DTABLEEND;
|
ctl |= B43_DMA32_DCTL_DTABLEEND;
|
||||||
|
@ -170,11 +201,10 @@ static void op64_fill_descriptor(struct b43_dmaring *ring,
|
||||||
slot = (int)(&(desc->dma64) - descbase);
|
slot = (int)(&(desc->dma64) - descbase);
|
||||||
B43_WARN_ON(!(slot >= 0 && slot < ring->nr_slots));
|
B43_WARN_ON(!(slot >= 0 && slot < ring->nr_slots));
|
||||||
|
|
||||||
addrlo = (u32) (dmaaddr & 0xFFFFFFFF);
|
addrlo = b43_dma_address(&ring->dev->dma, dmaaddr, B43_DMA_ADDR_LOW);
|
||||||
addrhi = (((u64) dmaaddr >> 32) & ~SSB_DMA_TRANSLATION_MASK);
|
addrhi = b43_dma_address(&ring->dev->dma, dmaaddr, B43_DMA_ADDR_HIGH);
|
||||||
addrext = (((u64) dmaaddr >> 32) & SSB_DMA_TRANSLATION_MASK)
|
addrext = b43_dma_address(&ring->dev->dma, dmaaddr, B43_DMA_ADDR_EXT);
|
||||||
>> SSB_DMA_TRANSLATION_SHIFT;
|
|
||||||
addrhi |= ring->dev->dma.translation;
|
|
||||||
if (slot == ring->nr_slots - 1)
|
if (slot == ring->nr_slots - 1)
|
||||||
ctl0 |= B43_DMA64_DCTL0_DTABLEEND;
|
ctl0 |= B43_DMA64_DCTL0_DTABLEEND;
|
||||||
if (start)
|
if (start)
|
||||||
|
@ -658,41 +688,37 @@ static int dmacontroller_setup(struct b43_dmaring *ring)
|
||||||
int err = 0;
|
int err = 0;
|
||||||
u32 value;
|
u32 value;
|
||||||
u32 addrext;
|
u32 addrext;
|
||||||
u32 trans = ring->dev->dma.translation;
|
|
||||||
bool parity = ring->dev->dma.parity;
|
bool parity = ring->dev->dma.parity;
|
||||||
|
u32 addrlo;
|
||||||
|
u32 addrhi;
|
||||||
|
|
||||||
if (ring->tx) {
|
if (ring->tx) {
|
||||||
if (ring->type == B43_DMA_64BIT) {
|
if (ring->type == B43_DMA_64BIT) {
|
||||||
u64 ringbase = (u64) (ring->dmabase);
|
u64 ringbase = (u64) (ring->dmabase);
|
||||||
|
addrext = b43_dma_address(&ring->dev->dma, ringbase, B43_DMA_ADDR_EXT);
|
||||||
|
addrlo = b43_dma_address(&ring->dev->dma, ringbase, B43_DMA_ADDR_LOW);
|
||||||
|
addrhi = b43_dma_address(&ring->dev->dma, ringbase, B43_DMA_ADDR_HIGH);
|
||||||
|
|
||||||
addrext = ((ringbase >> 32) & SSB_DMA_TRANSLATION_MASK)
|
|
||||||
>> SSB_DMA_TRANSLATION_SHIFT;
|
|
||||||
value = B43_DMA64_TXENABLE;
|
value = B43_DMA64_TXENABLE;
|
||||||
value |= (addrext << B43_DMA64_TXADDREXT_SHIFT)
|
value |= (addrext << B43_DMA64_TXADDREXT_SHIFT)
|
||||||
& B43_DMA64_TXADDREXT_MASK;
|
& B43_DMA64_TXADDREXT_MASK;
|
||||||
if (!parity)
|
if (!parity)
|
||||||
value |= B43_DMA64_TXPARITYDISABLE;
|
value |= B43_DMA64_TXPARITYDISABLE;
|
||||||
b43_dma_write(ring, B43_DMA64_TXCTL, value);
|
b43_dma_write(ring, B43_DMA64_TXCTL, value);
|
||||||
b43_dma_write(ring, B43_DMA64_TXRINGLO,
|
b43_dma_write(ring, B43_DMA64_TXRINGLO, addrlo);
|
||||||
(ringbase & 0xFFFFFFFF));
|
b43_dma_write(ring, B43_DMA64_TXRINGHI, addrhi);
|
||||||
b43_dma_write(ring, B43_DMA64_TXRINGHI,
|
|
||||||
((ringbase >> 32) &
|
|
||||||
~SSB_DMA_TRANSLATION_MASK)
|
|
||||||
| trans);
|
|
||||||
} else {
|
} else {
|
||||||
u32 ringbase = (u32) (ring->dmabase);
|
u32 ringbase = (u32) (ring->dmabase);
|
||||||
|
addrext = b43_dma_address(&ring->dev->dma, ringbase, B43_DMA_ADDR_EXT);
|
||||||
|
addrlo = b43_dma_address(&ring->dev->dma, ringbase, B43_DMA_ADDR_LOW);
|
||||||
|
|
||||||
addrext = (ringbase & SSB_DMA_TRANSLATION_MASK)
|
|
||||||
>> SSB_DMA_TRANSLATION_SHIFT;
|
|
||||||
value = B43_DMA32_TXENABLE;
|
value = B43_DMA32_TXENABLE;
|
||||||
value |= (addrext << B43_DMA32_TXADDREXT_SHIFT)
|
value |= (addrext << B43_DMA32_TXADDREXT_SHIFT)
|
||||||
& B43_DMA32_TXADDREXT_MASK;
|
& B43_DMA32_TXADDREXT_MASK;
|
||||||
if (!parity)
|
if (!parity)
|
||||||
value |= B43_DMA32_TXPARITYDISABLE;
|
value |= B43_DMA32_TXPARITYDISABLE;
|
||||||
b43_dma_write(ring, B43_DMA32_TXCTL, value);
|
b43_dma_write(ring, B43_DMA32_TXCTL, value);
|
||||||
b43_dma_write(ring, B43_DMA32_TXRING,
|
b43_dma_write(ring, B43_DMA32_TXRING, addrlo);
|
||||||
(ringbase & ~SSB_DMA_TRANSLATION_MASK)
|
|
||||||
| trans);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
err = alloc_initial_descbuffers(ring);
|
err = alloc_initial_descbuffers(ring);
|
||||||
|
@ -700,9 +726,10 @@ static int dmacontroller_setup(struct b43_dmaring *ring)
|
||||||
goto out;
|
goto out;
|
||||||
if (ring->type == B43_DMA_64BIT) {
|
if (ring->type == B43_DMA_64BIT) {
|
||||||
u64 ringbase = (u64) (ring->dmabase);
|
u64 ringbase = (u64) (ring->dmabase);
|
||||||
|
addrext = b43_dma_address(&ring->dev->dma, ringbase, B43_DMA_ADDR_EXT);
|
||||||
|
addrlo = b43_dma_address(&ring->dev->dma, ringbase, B43_DMA_ADDR_LOW);
|
||||||
|
addrhi = b43_dma_address(&ring->dev->dma, ringbase, B43_DMA_ADDR_HIGH);
|
||||||
|
|
||||||
addrext = ((ringbase >> 32) & SSB_DMA_TRANSLATION_MASK)
|
|
||||||
>> SSB_DMA_TRANSLATION_SHIFT;
|
|
||||||
value = (ring->frameoffset << B43_DMA64_RXFROFF_SHIFT);
|
value = (ring->frameoffset << B43_DMA64_RXFROFF_SHIFT);
|
||||||
value |= B43_DMA64_RXENABLE;
|
value |= B43_DMA64_RXENABLE;
|
||||||
value |= (addrext << B43_DMA64_RXADDREXT_SHIFT)
|
value |= (addrext << B43_DMA64_RXADDREXT_SHIFT)
|
||||||
|
@ -710,19 +737,15 @@ static int dmacontroller_setup(struct b43_dmaring *ring)
|
||||||
if (!parity)
|
if (!parity)
|
||||||
value |= B43_DMA64_RXPARITYDISABLE;
|
value |= B43_DMA64_RXPARITYDISABLE;
|
||||||
b43_dma_write(ring, B43_DMA64_RXCTL, value);
|
b43_dma_write(ring, B43_DMA64_RXCTL, value);
|
||||||
b43_dma_write(ring, B43_DMA64_RXRINGLO,
|
b43_dma_write(ring, B43_DMA64_RXRINGLO, addrlo);
|
||||||
(ringbase & 0xFFFFFFFF));
|
b43_dma_write(ring, B43_DMA64_RXRINGHI, addrhi);
|
||||||
b43_dma_write(ring, B43_DMA64_RXRINGHI,
|
|
||||||
((ringbase >> 32) &
|
|
||||||
~SSB_DMA_TRANSLATION_MASK)
|
|
||||||
| trans);
|
|
||||||
b43_dma_write(ring, B43_DMA64_RXINDEX, ring->nr_slots *
|
b43_dma_write(ring, B43_DMA64_RXINDEX, ring->nr_slots *
|
||||||
sizeof(struct b43_dmadesc64));
|
sizeof(struct b43_dmadesc64));
|
||||||
} else {
|
} else {
|
||||||
u32 ringbase = (u32) (ring->dmabase);
|
u32 ringbase = (u32) (ring->dmabase);
|
||||||
|
addrext = b43_dma_address(&ring->dev->dma, ringbase, B43_DMA_ADDR_EXT);
|
||||||
|
addrlo = b43_dma_address(&ring->dev->dma, ringbase, B43_DMA_ADDR_LOW);
|
||||||
|
|
||||||
addrext = (ringbase & SSB_DMA_TRANSLATION_MASK)
|
|
||||||
>> SSB_DMA_TRANSLATION_SHIFT;
|
|
||||||
value = (ring->frameoffset << B43_DMA32_RXFROFF_SHIFT);
|
value = (ring->frameoffset << B43_DMA32_RXFROFF_SHIFT);
|
||||||
value |= B43_DMA32_RXENABLE;
|
value |= B43_DMA32_RXENABLE;
|
||||||
value |= (addrext << B43_DMA32_RXADDREXT_SHIFT)
|
value |= (addrext << B43_DMA32_RXADDREXT_SHIFT)
|
||||||
|
@ -730,9 +753,7 @@ static int dmacontroller_setup(struct b43_dmaring *ring)
|
||||||
if (!parity)
|
if (!parity)
|
||||||
value |= B43_DMA32_RXPARITYDISABLE;
|
value |= B43_DMA32_RXPARITYDISABLE;
|
||||||
b43_dma_write(ring, B43_DMA32_RXCTL, value);
|
b43_dma_write(ring, B43_DMA32_RXCTL, value);
|
||||||
b43_dma_write(ring, B43_DMA32_RXRING,
|
b43_dma_write(ring, B43_DMA32_RXRING, addrlo);
|
||||||
(ringbase & ~SSB_DMA_TRANSLATION_MASK)
|
|
||||||
| trans);
|
|
||||||
b43_dma_write(ring, B43_DMA32_RXINDEX, ring->nr_slots *
|
b43_dma_write(ring, B43_DMA32_RXINDEX, ring->nr_slots *
|
||||||
sizeof(struct b43_dmadesc32));
|
sizeof(struct b43_dmadesc32));
|
||||||
}
|
}
|
||||||
|
@ -1061,6 +1082,25 @@ static int b43_dma_set_mask(struct b43_wldev *dev, u64 mask)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Some hardware with 64-bit DMA seems to be bugged and looks for translation
|
||||||
|
* bit in low address word instead of high one.
|
||||||
|
*/
|
||||||
|
static bool b43_dma_translation_in_low_word(struct b43_wldev *dev,
|
||||||
|
enum b43_dmatype type)
|
||||||
|
{
|
||||||
|
if (type != B43_DMA_64BIT)
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
#ifdef CONFIG_B43_SSB
|
||||||
|
if (dev->dev->bus_type == B43_BUS_SSB &&
|
||||||
|
dev->dev->sdev->bus->bustype == SSB_BUSTYPE_PCI &&
|
||||||
|
!(dev->dev->sdev->bus->host_pci->is_pcie &&
|
||||||
|
ssb_read32(dev->dev->sdev, SSB_TMSHIGH) & SSB_TMSHIGH_DMA64))
|
||||||
|
return 1;
|
||||||
|
#endif
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int b43_dma_init(struct b43_wldev *dev)
|
int b43_dma_init(struct b43_wldev *dev)
|
||||||
{
|
{
|
||||||
struct b43_dma *dma = &dev->dma;
|
struct b43_dma *dma = &dev->dma;
|
||||||
|
@ -1086,6 +1126,7 @@ int b43_dma_init(struct b43_wldev *dev)
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
dma->translation_in_low = b43_dma_translation_in_low_word(dev, type);
|
||||||
|
|
||||||
dma->parity = true;
|
dma->parity = true;
|
||||||
#ifdef CONFIG_B43_BCMA
|
#ifdef CONFIG_B43_BCMA
|
||||||
|
|
|
@ -215,6 +215,12 @@ enum b43_dmatype {
|
||||||
B43_DMA_64BIT = 64,
|
B43_DMA_64BIT = 64,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum b43_addrtype {
|
||||||
|
B43_DMA_ADDR_LOW,
|
||||||
|
B43_DMA_ADDR_HIGH,
|
||||||
|
B43_DMA_ADDR_EXT,
|
||||||
|
};
|
||||||
|
|
||||||
struct b43_dmaring {
|
struct b43_dmaring {
|
||||||
/* Lowlevel DMA ops. */
|
/* Lowlevel DMA ops. */
|
||||||
const struct b43_dma_ops *ops;
|
const struct b43_dma_ops *ops;
|
||||||
|
|
Loading…
Reference in a new issue