- UID
- 1029342
- 性别
- 男
|
/* fill pre opcode */
addr = base + SPI_PREOP;
val = readw((void *)(spi_char.mem_virt+SPI_PREOP));
SPI_DBG("before init, SPI_PREOOP=%08x/n", val);
val = SPI_WR_ENABLE | (SPI_WSR_ENABLE << 8);
writew(val, (void *)addr);
val = readw((void *)(spi_char.mem_virt+SPI_PREOP));
SPI_DBG("after init, SPI_PREOP=%08x/n", val);
/* disable Atomic Cycle Sequence */
val = readw((void *)(spi_char.mem_virt+SPI_CTRL));
val &= ~SPI_CTRL_ACS;
val &= ~SPI_CTRL_SPOP;
writew(val, (void*)(spi_char.mem_virt+SPI_CTRL));
}
loff_t spi_lseek(struct file *filp, loff_t off, int whence)
{
loff_t newpos;
switch (whence)
{
case 0: /* SEEK_SET */
newpos = off;
break;
case 1: /* SEEK_CUR */
newpos = spi_char.fp + off;
break;
case 2: /* SEEK_END */
newpos = spi_char.fp + off;
break;
default: /* cant't happen */
return (-EINVAL);
break;
}
if(newpos < 0 || newpos >= SPI_FLASH_SIZE)
{
return (-EINVAL);
}
spi_char.fp = newpos;
return (newpos);
}
// Linux file operations
struct file_operations file_ops =
{
.owner = THIS_MODULE,
.read = spi_read,
.write = spi_write,
.llseek = spi_lseek,
.open = spi_open,
.release = spi_release,
.ioctl = spi_ioctl,
}; |
|