Commit b14f1674 authored by Arend van Spriel's avatar Arend van Spriel Committed by John W. Linville

brcm80211: smac: use bcma core access function in srom.c

The code in srom.c now uses the core access function provided by
BCMA so no need to pass __iomem pointer any longer.
Reviewed-by: default avatarPieter-Paul Giesberts <pieterpg@broadcom.com>
Reviewed-by: default avatarAlwin Beukers <alwin@broadcom.com>
Signed-off-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarFranky Lin <frankyl@broadcom.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 373c78e1
...@@ -725,7 +725,7 @@ static struct si_info *ai_doattach(struct si_info *sii, ...@@ -725,7 +725,7 @@ static struct si_info *ai_doattach(struct si_info *sii,
goto exit; goto exit;
/* Init nvram from sprom/otp if they exist */ /* Init nvram from sprom/otp if they exist */
if (srom_var_init(&sii->pub, cc)) if (srom_var_init(&sii->pub))
goto exit; goto exit;
ai_nvram_process(sii); ai_nvram_process(sii);
......
...@@ -586,17 +586,6 @@ static const struct brcms_sromvar perpath_pci_sromvars[] = { ...@@ -586,17 +586,6 @@ static const struct brcms_sromvar perpath_pci_sromvars[] = {
* shared between devices. */ * shared between devices. */
static u8 brcms_srom_crc8_table[CRC8_TABLE_SIZE]; static u8 brcms_srom_crc8_table[CRC8_TABLE_SIZE];
static u8 __iomem *
srom_window_address(struct si_pub *sih, u8 __iomem *curmap)
{
if (ai_get_ccrev(sih) < 32)
return curmap + PCI_BAR0_SPROM_OFFSET;
if (ai_get_cccaps(sih) & CC_CAP_SROM)
return curmap + PCI_16KB0_CCREGS_OFFSET + CC_SROM_OTP;
return NULL;
}
static uint mask_shift(u16 mask) static uint mask_shift(u16 mask)
{ {
uint i; uint i;
...@@ -779,17 +768,27 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, struct list_head *var_list) ...@@ -779,17 +768,27 @@ _initvars_srom_pci(u8 sromrev, u16 *srom, struct list_head *var_list)
* Return 0 on success, nonzero on error. * Return 0 on success, nonzero on error.
*/ */
static int static int
sprom_read_pci(struct si_pub *sih, u8 __iomem *sprom, uint wordoff, sprom_read_pci(struct si_pub *sih, u16 *buf, uint nwords, bool check_crc)
u16 *buf, uint nwords, bool check_crc)
{ {
int err = 0; int err = 0;
uint i; uint i;
u8 *bbuf = (u8 *)buf; /* byte buffer */ u8 *bbuf = (u8 *)buf; /* byte buffer */
uint nbytes = nwords << 1; uint nbytes = nwords << 1;
struct bcma_device *core;
uint sprom_offset;
/* determine core to read */
if (ai_get_ccrev(sih) < 32) {
core = ai_findcore(sih, BCMA_CORE_80211, 0);
sprom_offset = PCI_BAR0_SPROM_OFFSET;
} else {
core = ai_findcore(sih, BCMA_CORE_CHIPCOMMON, 0);
sprom_offset = CHIPCREGOFFS(sromotp);
}
/* read the sprom in bytes */ /* read the sprom in bytes */
for (i = 0; i < nbytes; i++) for (i = 0; i < nbytes; i++)
bbuf[i] = readb(sprom+i); bbuf[i] = bcma_read8(core, sprom_offset+i);
if (buf[0] == 0xffff) if (buf[0] == 0xffff)
/* /*
...@@ -851,10 +850,9 @@ static int otp_read_pci(struct si_pub *sih, u16 *buf, uint nwords) ...@@ -851,10 +850,9 @@ static int otp_read_pci(struct si_pub *sih, u16 *buf, uint nwords)
* Initialize nonvolatile variable table from sprom. * Initialize nonvolatile variable table from sprom.
* Return 0 on success, nonzero on error. * Return 0 on success, nonzero on error.
*/ */
static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap) int srom_var_init(struct si_pub *sih)
{ {
u16 *srom; u16 *srom;
u8 __iomem *sromwindow;
u8 sromrev = 0; u8 sromrev = 0;
u32 sr; u32 sr;
int err = 0; int err = 0;
...@@ -866,12 +864,9 @@ static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap) ...@@ -866,12 +864,9 @@ static int initvars_srom_pci(struct si_pub *sih, void __iomem *curmap)
if (!srom) if (!srom)
return -ENOMEM; return -ENOMEM;
sromwindow = srom_window_address(sih, curmap);
crc8_populate_lsb(brcms_srom_crc8_table, SROM_CRC8_POLY); crc8_populate_lsb(brcms_srom_crc8_table, SROM_CRC8_POLY);
if (ai_is_sprom_available(sih)) { if (ai_is_sprom_available(sih)) {
err = sprom_read_pci(sih, sromwindow, 0, srom, err = sprom_read_pci(sih, srom, SROM4_WORDS, true);
SROM4_WORDS, true);
if (err == 0) if (err == 0)
/* srom read and passed crc */ /* srom read and passed crc */
...@@ -921,21 +916,6 @@ void srom_free_vars(struct si_pub *sih) ...@@ -921,21 +916,6 @@ void srom_free_vars(struct si_pub *sih)
kfree(entry); kfree(entry);
} }
} }
/*
* Initialize local vars from the right source for this platform.
* Return 0 on success, nonzero on error.
*/
int srom_var_init(struct si_pub *sih, void __iomem *curmap)
{
uint len;
len = 0;
if (curmap != NULL)
return initvars_srom_pci(sih, curmap);
return -EINVAL;
}
/* /*
* Search the name=value vars for a specific one and return its value. * Search the name=value vars for a specific one and return its value.
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
#include "types.h" #include "types.h"
/* Prototypes */ /* Prototypes */
extern int srom_var_init(struct si_pub *sih, void __iomem *curmap); extern int srom_var_init(struct si_pub *sih);
extern void srom_free_vars(struct si_pub *sih); extern void srom_free_vars(struct si_pub *sih);
extern int srom_read(struct si_pub *sih, uint bus, void *curmap, extern int srom_read(struct si_pub *sih, uint bus, void *curmap,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment