Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

bcma: update core (en|dis)abling functions

Broadocm updated their code, this may be needed for newer hardware or
some corner cases.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

authored by

Rafał Miłecki and committed by
John W. Linville
972da7ec 55fee98a

+25 -3
+25 -3
drivers/bcma/core.c
··· 9 9 #include <linux/export.h> 10 10 #include <linux/bcma/bcma.h> 11 11 12 + static bool bcma_core_wait_value(struct bcma_device *core, u16 reg, u32 mask, 13 + u32 value, int timeout) 14 + { 15 + unsigned long deadline = jiffies + timeout; 16 + u32 val; 17 + 18 + do { 19 + val = bcma_aread32(core, reg); 20 + if ((val & mask) == value) 21 + return true; 22 + cpu_relax(); 23 + udelay(10); 24 + } while (!time_after_eq(jiffies, deadline)); 25 + 26 + bcma_warn(core->bus, "Timeout waiting for register 0x%04X!\n", reg); 27 + 28 + return false; 29 + } 30 + 12 31 bool bcma_core_is_enabled(struct bcma_device *core) 13 32 { 14 33 if ((bcma_aread32(core, BCMA_IOCTL) & (BCMA_IOCTL_CLK | BCMA_IOCTL_FGC)) ··· 44 25 if (bcma_aread32(core, BCMA_RESET_CTL) & BCMA_RESET_CTL_RESET) 45 26 return; 46 27 47 - bcma_awrite32(core, BCMA_IOCTL, flags); 48 - bcma_aread32(core, BCMA_IOCTL); 49 - udelay(10); 28 + bcma_core_wait_value(core, BCMA_RESET_ST, ~0, 0, 300); 50 29 51 30 bcma_awrite32(core, BCMA_RESET_CTL, BCMA_RESET_CTL_RESET); 52 31 bcma_aread32(core, BCMA_RESET_CTL); 53 32 udelay(1); 33 + 34 + bcma_awrite32(core, BCMA_IOCTL, flags); 35 + bcma_aread32(core, BCMA_IOCTL); 36 + udelay(10); 54 37 } 55 38 EXPORT_SYMBOL_GPL(bcma_core_disable); 56 39 ··· 64 43 bcma_aread32(core, BCMA_IOCTL); 65 44 66 45 bcma_awrite32(core, BCMA_RESET_CTL, 0); 46 + bcma_aread32(core, BCMA_RESET_CTL); 67 47 udelay(1); 68 48 69 49 bcma_awrite32(core, BCMA_IOCTL, (BCMA_IOCTL_CLK | flags));