static uint8_t get_flash_status(void)
{
uint32_t word, val;
uint8_t ret;
word = readw((void *)(spi_char.mem_virt+SPI_CTRL));
word |= SPI_CTRL_SCGO; /* set cycle */
word |= SPI_CTRL_ACS; /* Enable Atomic Cycle Sequence */
word |= SPI_CTRL_SPOP;
word &= ~SPI_CTRL_COP;
word = word | SPI_CTRL_OPMENU_RDSR<<SPI_CTRL_COP_SHIFT; /* read */
word &= ~SPI_CTRL_DBC;
word = word | 0x00<<SPI_CTRL_DBC_SHIFT; /* read count=1 */
word |= SPI_CTRL_DC;
/* check the status */
val = readw((void *)(spi_char.mem_virt+SPI_STATUS));
while(val & SPI_STATUS_SCIP)
{
val = readw((void *)(spi_char.mem_virt+SPI_STATUS));/* check the status */
}
/* check the status */
val = readw((void *)(spi_char.mem_virt+SPI_STATUS));
while(val & SPI_STATUS_SCIP)
{
val = readw((void *)(spi_char.mem_virt+SPI_STATUS));/* check the status */
}
val = readl((void *)(spi_char.mem_virt+SPI_DATA0));
SPI_DBG("get_flash_status:%08x/n", val);
ret = (val&0xFF);
word = readw((void *)(spi_char.mem_virt+SPI_STATUS));
word |= SPI_STATUS_CDS; /* clear Cycle Done Status flag */
word |= SPI_STATUS_BAS; /* clear blocked flag */
writew(word, (void *)(spi_char.mem_virt+SPI_STATUS));
return (ret);
}
static uint8_t set_flash_status(uint8_t value)
{
uint32_t word, var, val;
var = value;
writel(var, (void *)(spi_char.mem_virt+SPI_DATA0));
word = readw((void *)(spi_char.mem_virt+SPI_CTRL));
word |= SPI_CTRL_SCGO; /* set cycle */
word |= SPI_CTRL_ACS; /* Enable Atomic Cycle Sequence */
word |= SPI_CTRL_SPOP;
word &= ~SPI_CTRL_COP;
word = word | SPI_CTRL_OPMENU_WRSR<<SPI_CTRL_COP_SHIFT; /* read */
word &= ~SPI_CTRL_DBC;
word = word | 0x00<<SPI_CTRL_DBC_SHIFT; /* write count=1 */
word |= SPI_CTRL_DC;
/* check the status */
val = readw((void *)(spi_char.mem_virt+SPI_STATUS));
while(val & SPI_STATUS_SCIP)
{
val = readw((void *)(spi_char.mem_virt+SPI_STATUS));/* check the status */
}
/* check the status */
val = readw((void *)(spi_char.mem_virt+SPI_STATUS));
while(val & SPI_STATUS_SCIP)
{
val = readw((void *)(spi_char.mem_virt+SPI_STATUS));/* check the status */
}
word = readw((void *)(spi_char.mem_virt+SPI_STATUS));
word |= SPI_STATUS_CDS; /* clear Cycle Done Status flag */
word |= SPI_STATUS_BAS; /* clear blocked flag */
writew(word, (void *)(spi_char.mem_virt+SPI_STATUS));
var = get_flash_status();
return (var);
}
static int is_bios_protection(void)
{
unsigned int ret;
ret = spi_char.bios_ctrl_addr & BIOS_NOPROTECTION;
return (!ret);
}
static int disable_bios_protection(void)
{
unsigned int temp;
struct pci_dev *pdev = NULL;