\r
extern struct spi_fpga_port *pFpgaPort;\r
#if SPI_FPGA_TRANS_WORK\r
-extern int spi_write_work(struct spi_device *spi, const u8 *buf, size_t len);\r
+extern int spi_write_work(struct spi_device *spi, u8 *buf, size_t len);\r
#endif\r
extern unsigned int spi_in(struct spi_fpga_port *port, int reg, int type);\r
extern void spi_out(struct spi_fpga_port *port, int reg, int value, int type);\r
#define ID_SPI_FPGA_READ 2\r
struct spi_fpga_transfer\r
{\r
- const u8 *txbuf;\r
+ u8 *txbuf;\r
unsigned n_tx;\r
u8 *rxbuf;\r
unsigned n_rx;\r
struct spi_fpga_port *port =\r
container_of(work, struct spi_fpga_port, fpga_trans_work);\r
unsigned long flags;\r
- \r
+ spin_lock_irqsave(&port->work_lock, flags);\r
while (!list_empty(&port->trans_queue)) \r
{\r
+ spin_unlock_irqrestore(&port->work_lock, flags);\r
struct spi_fpga_transfer *t = NULL, *tmp;\r
list_for_each_entry_safe(t, tmp, &port->trans_queue, queue)\r
{\r
}\r
spin_lock_irqsave(&port->work_lock, flags);\r
list_del_init(&port->trans_queue);\r
- spin_unlock_irqrestore(&port->work_lock, flags);\r
- }\r
\r
+ }\r
+ spin_unlock_irqrestore(&port->work_lock, flags);\r
\r
}\r
\r
-int spi_write_work(struct spi_device *spi, const u8 *buf, size_t len)\r
+int spi_write_work(struct spi_device *spi, u8 *buf, size_t len)\r
{\r
struct spi_fpga_port *port = spi_get_drvdata(spi);\r
struct spi_fpga_transfer *t;\r
tx_buf[1] = (value>>8) & 0xff;\r
tx_buf[2] = value & 0xff;\r
if(reg_temp == UART_IER)\r
- spi_write_work(port->spi, (const u8 *)&tx_buf, sizeof(tx_buf));\r
+ spi_write_work(port->spi, tx_buf, sizeof(tx_buf));\r
else\r
spi_write(port->spi, (const u8 *)&tx_buf, sizeof(tx_buf));\r
DBG("%s,SEL_UART reg=0x%x,value=0x%x\n",__FUNCTION__,reg&0xff,value&0xffff);\r
spi_out(port,reg,len,SEL_I2C);\r
\r
#if SPI_FPGA_I2C_EVENT\r
- ret = wait_event_timeout(port->i2c.wait_r, port->i2c.interrupt == INT_I2C_READ_ACK, msecs_to_jiffies(60)); \r
+ ret = wait_event_timeout(port->i2c.wait_r, ((port->i2c.interrupt == INT_I2C_READ_ACK) || (port->i2c.interrupt == INT_I2C_READ_NACK)), msecs_to_jiffies(60)); \r
if(ret == 0)\r
{\r
printk("%s:60ms time out!\n",__FUNCTION__);\r
reg = channel|ICE_SEL_I2C_STOP;\r
spi_out(port,reg,pmsg->buf[i],SEL_I2C);\r
#if SPI_FPGA_I2C_EVENT\r
- ret = wait_event_timeout(port->i2c.wait_w, port->i2c.interrupt == INT_I2C_WRITE_ACK, msecs_to_jiffies(60));\r
+ ret = wait_event_timeout(port->i2c.wait_w, ((port->i2c.interrupt == INT_I2C_WRITE_ACK) || (port->i2c.interrupt == INT_I2C_WRITE_NACK)), msecs_to_jiffies(60));\r
if(ret == 0)\r
{\r
printk("%s:60ms time out!\n",__FUNCTION__);\r
{\r
struct tty_struct *tty = uart->tty;\r
struct spi_fpga_port *port = container_of(uart, struct spi_fpga_port, uart);\r
- unsigned int ch, flag;\r
+ unsigned char ch, flag;\r
int max_count = 1024;\r
DBG("rx:");\r
#if SPI_UART_TXRX_BUF\r
- int ret,count,stat = 0;\r
+ int ret,count,stat = *status;\r
int i = 0;\r
unsigned char buf[SPI_UART_FIFO_LEN];\r
- while (max_count >0 )\r
+ while (max_count >0)\r
{\r
- stat = spi_in(port, UART_LSR, SEL_UART);\r
if((((stat >> 8) & 0x3f) != 0) && (!(stat & UART_LSR_DR)))\r
printk("%s:warning:no receive data but count =%d \n",__FUNCTION__,((stat >> 8) & 0x3f));\r
if(!(stat & UART_LSR_DR))\r
printk("err:%s:stat=%d,fail to read uart data because of spi bus error!\n",__FUNCTION__,stat); \r
}\r
max_count -= count;\r
+ flag = TTY_NORMAL;\r
+ uart->icount.rx += count;\r
for(i=0;i<count;i++)\r
{\r
- flag = TTY_NORMAL;\r
- uart->icount.rx++;\r
ch = buf[i];\r
tty_insert_flip_char(tty, ch, flag);\r
DBG("0x%x,",ch);\r
}\r
+ tty_flip_buffer_push(tty); \r
DBG("\n");\r
} \r
\r
- tty_flip_buffer_push(tty); \r
DBG("\n");\r
\r
#else \r
static void spi_uart_close(struct tty_struct *tty, struct file * filp)\r
{\r
struct spi_uart *uart = tty->driver_data;\r
- printk("%s:LINE=%d,tty->hw_stopped=%d\n",__FUNCTION__,__LINE__,tty->hw_stopped);\r
+ DBG("%s:LINE=%d,tty->hw_stopped=%d\n",__FUNCTION__,__LINE__,tty->hw_stopped);\r
if (!uart)\r
return;\r
\r
static int spi_uart_chars_in_buffer(struct tty_struct *tty)\r
{\r
struct spi_uart *uart = tty->driver_data;\r
- printk("%s:LINE=%d,circ=%ld\n",__FUNCTION__,__LINE__,circ_chars_pending(&uart->xmit)); \r
+ DBG("%s:LINE=%d,circ=%ld\n",__FUNCTION__,__LINE__,circ_chars_pending(&uart->xmit)); \r
return uart ? circ_chars_pending(&uart->xmit) : 0;\r
}\r
\r
{\r
struct spi_uart *uart = tty->driver_data;\r
struct spi_fpga_port *port = container_of(uart, struct spi_fpga_port, uart);\r
- printk("%s:LINE=%d\n",__FUNCTION__,__LINE__);\r
+ DBG("%s:LINE=%d\n",__FUNCTION__,__LINE__);\r
uart->x_char = ch;\r
if (ch && !(uart->ier & UART_IER_THRI)) {\r
mutex_lock(&port->spi_lock);\r