\r
int rx_enabled; /* if we should rx chars */\r
\r
+ int irq_pin;\r
int irq; /* irq assigned to the bu92747 */\r
\r
int minor; /* minor number */\r
struct work_struct work;\r
/* set to 1 to make the workhandler exit as soon as possible */\r
int force_end_work;\r
+ \r
int open_flag;\r
/* need to know we are suspending to avoid deadlock on workqueue */\r
int suspending;\r
static u8 g_receive_buf[BU92725GUW_FIFO_SIZE];\r
\r
#if 0\r
-#define BU92747_IRDA_DBG(x...) printk(x)\r
+#define IRDA_DBG_FUNC(x...) printk(x)\r
+#else\r
+#define IRDA_DBG_FUNC(x...)\r
+#endif\r
+\r
+#if 0\r
+#define IRDA_DBG_RECV(x...) printk(x)\r
#else\r
-#define BU92747_IRDA_DBG(x...)\r
+#define IRDA_DBG_RECV(x...)\r
#endif\r
\r
+#if 1\r
+#define IRDA_DBG_SENT(x...) printk(x)\r
+#else\r
+#define IRDA_DBG_SENT(x...)\r
+#endif\r
\r
/* race on startup&shutdown, mutex lock with CIR driver */\r
static DEFINE_MUTEX(irda_cir_lock);\r
return -1;\r
\r
f->frame_length[f->iWrite] = length;\r
- //printk("add one frame, length=%ld\n", f->frame_length[f->iWrite]);\r
f->iCount++;\r
- //printk("now frame iCount=%d\n", f->iCount);\r
- f->iWrite = (f->iWrite+1) % MAX_FRAME_NUM;\r
- //printk("now frame iWrite=%d\n", f->iWrite);\r
- \r
+ f->iWrite = (f->iWrite+1) % MAX_FRAME_NUM; \r
\r
return 0;\r
}\r
return -1;\r
\r
*length = f->frame_length[f->iRead];\r
- //printk("read one frame, length=%ld\n", *length);\r
f->iCount--;\r
- //printk("now frame iCount=%d\n", f->iCount);\r
f->iRead = (f->iRead+1) % MAX_FRAME_NUM;\r
- //printk("now frame iRead=%d\n", f->iRead);\r
\r
return 0;\r
}\r
//unsigned int ch, flag;\r
int len;\r
struct tty_struct *tty = s->port.state->port.tty;\r
- BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
+ IRDA_DBG_FUNC("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
\r
if (s->rx_enabled == 0) {\r
BU92725GUW_clr_fifo();\r
//printk("\n");\r
#else\r
if (len > 0) {\r
+ IRDA_DBG_RECV("line %d, enter %s, receive %d data........\n", __LINE__, __func__, len);\r
tty_insert_flip_string(tty, g_receive_buf, len);\r
s->port.icount.rx += len;\r
}\r
//int i;\r
struct circ_buf *xmit = &s->port.state->xmit;\r
int len = uart_circ_chars_pending(xmit);\r
- printk("line %d, enter %s, sending %d data\n", __LINE__, __FUNCTION__, len);\r
+ IRDA_DBG_SENT("line %d, enter %s, sending %d data\n", __LINE__, __FUNCTION__, len);\r
\r
if (IS_FIR(s)) {\r
- //printk("fir sending.....\n");\r
irda_hw_tx_enable_irq(BU92725GUW_FIR);\r
}\r
else { \r
- //printk("sir sending.....\n");\r
irda_hw_tx_enable_irq(BU92725GUW_SIR);\r
}\r
-\r
- //BU92747_IRDA_DBG("data:\n");\r
- //for (i=0; i<len; i++) {\r
- //BU92747_IRDA_DBG("%d ", xmit->buf[xmit->tail+i]);\r
- //}\r
- //BU92747_IRDA_DBG("\n");\r
\r
if (len>0) { \r
s->tx_empty = 0;\r
struct bu92747_port *s = container_of(w, struct bu92747_port, work);\r
struct circ_buf *xmit = &s->port.state->xmit;\r
\r
- printk("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
+ IRDA_DBG_SENT("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
\r
if (!s->force_end_work && !freezing(current)) {\r
- //BU92725GUW_dump_register();\r
-\r
if (!uart_circ_empty(xmit) && !uart_tx_stopped(&s->port)) {\r
if (s->tx_empty)\r
bu92747_irda_do_tx(s);\r
struct rev_frame_length *f = &(s->rev_frames);\r
\r
irq_src = irda_hw_get_irqsrc();\r
- printk("[%s][%d], 0x%x\n",__FUNCTION__,__LINE__, irq_src);\r
+ IRDA_DBG_RECV("[%s][%d], 0x%x\n",__FUNCTION__,__LINE__, irq_src);\r
\r
/* error */\r
if (irq_src & (REG_INT_CRC | REG_INT_OE | REG_INT_FE\r
| REG_INT_AC | REG_INT_DECE | REG_INT_RDOE | REG_INT_DEX)) {\r
- printk("[%s][%d]: do err\n", __FUNCTION__, __LINE__);\r
- //BU92725GUW_dump_register();\r
+ printk("[%s][%d]: do err, REG_EIR = 0x%x\n", __FUNCTION__, __LINE__, irq_src);\r
BU92725GUW_clr_fifo();\r
BU92725GUW_reset();\r
if ((BU92725GUW_SEND==irda_hw_get_mode())\r
spin_lock(&s->data_lock);\r
if (add_frame_length(f, s->cur_frame_length) == 0) {\r
s->cur_frame_length = 0;\r
- //atomic_set(&(s->data_ready), 1);\r
- //wake_up(&(s->data_ready_wq) );\r
}\r
else {\r
- printk("line %d: FIR frame length buf full......\n", __LINE__); \r
+ printk("func %s,line %d: FIR frame length buf full......\n", __FUNCTION__, __LINE__); \r
}\r
spin_unlock(&s->data_lock);\r
}\r
\r
/* error */\r
if (irq_src & REG_INT_TO) {\r
- BU92747_IRDA_DBG("[%s][%d]: do timeout err\n", __FUNCTION__, __LINE__);\r
- //BU92725GUW_dump_register();\r
+ printk("[%s][%d]: do timeout err\n", __FUNCTION__, __LINE__);\r
BU92725GUW_clr_fifo();\r
BU92725GUW_reset();\r
if ((BU92725GUW_SEND==irda_hw_get_mode())\r
s->tx_empty = 1;\r
}\r
}\r
-\r
+ \r
return IRQ_HANDLED;\r
}\r
\r
\r
static void bu92747_irda_stop_tx(struct uart_port *port)\r
{\r
- BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
+ IRDA_DBG_FUNC("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
}\r
\r
static void bu92747_irda_start_tx(struct uart_port *port)\r
struct bu92747_port *s = container_of(port,\r
struct bu92747_port,\r
port);\r
- BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
+ IRDA_DBG_FUNC("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
\r
//wait for start cmd\r
if (IS_FIR(s))\r
struct bu92747_port,\r
port);\r
\r
- BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
+ IRDA_DBG_FUNC("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
\r
s->rx_enabled = 0;\r
-\r
- bu92747_irda_dowork(s);\r
}\r
\r
static unsigned int bu92747_irda_tx_empty(struct uart_port *port)\r
struct bu92747_port,\r
port);\r
\r
- BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
+ IRDA_DBG_FUNC("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
\r
/* may not be truly up-to-date */\r
- //bu92747_irda_dowork(s);\r
return s->tx_empty;\r
}\r
\r
struct bu92747_port,\r
port);\r
\r
- BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
+ IRDA_DBG_FUNC("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
\r
return s->port.type == PORT_IRDA ? "BU92747" : NULL;\r
}\r
\r
static void bu92747_irda_release_port(struct uart_port *port)\r
{\r
- BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
+ IRDA_DBG_FUNC("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
}\r
\r
static void bu92747_irda_config_port(struct uart_port *port, int flags)\r
struct bu92747_port,\r
port);\r
\r
- BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
+ IRDA_DBG_FUNC("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
\r
if (flags & UART_CONFIG_TYPE)\r
s->port.type = PORT_IRDA;\r
{\r
int ret = -EINVAL;\r
\r
- BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
+ IRDA_DBG_FUNC("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
\r
if (ser->type == PORT_UNKNOWN || ser->type == PORT_IRDA)\r
ret = 0;\r
port);\r
struct rev_frame_length *f = &(s->rev_frames);\r
\r
- BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
+ printk("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
\r
if (s->suspending)\r
return;\r
}\r
\r
spin_lock(&s->data_lock);\r
- //atomic_set(&(s->data_ready), 0);\r
frame_length_buf_clear(f);\r
s->cur_frame_length = 0;\r
spin_unlock(&s->data_lock);\r
char b[32];\r
struct rev_frame_length *f = &(s->rev_frames);\r
\r
- BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
+ printk("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
\r
s->rx_enabled = 1;\r
\r
s->force_end_work = 0;\r
\r
sprintf(b, "bu92747_irda-%d", s->minor);\r
- s->workqueue = create_freezeable_workqueue(b);\r
+ s->workqueue = create_rt_workqueue(b);\r
if (!s->workqueue) {\r
dev_warn(s->dev, "cannot create workqueue\n");\r
bu92747_unlock();\r
}\r
INIT_WORK(&s->work, bu92747_irda_work);\r
\r
- //atomic_set(&(s->data_ready), 0);\r
-\r
if (request_irq(s->irq, bu92747_irda_irq,\r
- IRQ_TYPE_LEVEL_LOW, "bu92747_irda", s) < 0) {\r
+ IRQF_TRIGGER_LOW, "bu92747_irda", s) < 0) {\r
dev_warn(s->dev, "cannot allocate irq %d\n", s->irq);\r
s->irq = 0;\r
destroy_workqueue(s->workqueue);\r
\r
static int bu92747_irda_request_port(struct uart_port *port)\r
{\r
- BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
+ IRDA_DBG_FUNC("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
return 0;\r
}\r
\r
static void bu92747_irda_break_ctl(struct uart_port *port, int break_state)\r
{\r
- BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
+ IRDA_DBG_FUNC("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
}\r
\r
static unsigned int bu92747_irda_get_mctrl(struct uart_port *port)\r
\r
static void bu92747_irda_set_mctrl(struct uart_port *port, unsigned int mctrl)\r
{\r
- BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
+ IRDA_DBG_FUNC("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
}\r
\r
static void\r
unsigned cflag;\r
struct tty_struct *tty = s->port.state->port.tty;\r
\r
- BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
+ IRDA_DBG_FUNC("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
if (!tty)\r
return;\r
\r
case 115200:\r
case 4000000:\r
if (s->baud!=baud) {\r
+ //printk("func %s:irda set baudrate %d........\n", __FUNCTION__, baud);\r
irda_hw_set_speed(baud);\r
s->baud = baud;\r
+ s->tx_empty = 1;\r
}\r
break;\r
\r
{\r
struct rev_frame_length *f = &(s->rev_frames);\r
unsigned long len = 0;\r
-#if 0\r
- wait_event_interruptible_timeout(s->data_ready_wq, \r
- atomic_read(&(s->data_ready) ),\r
- msecs_to_jiffies(1000) );\r
- if ( 0 == atomic_read(&(s->data_ready)) ) {\r
- printk("waiting 'data_ready_wq' timed out.");\r
- return -1;\r
- }\r
-#endif\r
+\r
spin_lock(&s->data_lock);\r
if (get_frame_length(f, &len) != 0) {\r
- printk("line %d: FIR data not ready......\n", __LINE__);\r
+ IRDA_DBG_RECV("func %s, line %d: FIR data not ready......\n", __FUNCTION__, __LINE__);\r
len = 0;\r
- //atomic_set(&(s->data_ready), 0);\r
}\r
spin_unlock(&s->data_lock);\r
\r
void __user *argp = (void __user *)arg;\r
unsigned long len = 0;\r
int ret = 0;\r
- BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
+ IRDA_DBG_FUNC("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
\r
switch (cmd) {\r
case TTYIR_GETLENGTH:\r
int i, retval;\r
struct irda_info *platdata = pdev->dev.platform_data;\r
\r
- BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
+ IRDA_DBG_FUNC("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
if (!platdata) {\r
dev_warn(&pdev->dev, "no platform data info\n");\r
return -1;\r
return -ENOMEM;\r
}\r
bu92747s[i]->dev = &pdev->dev;\r
+ bu92747s[i]->irq_pin = platdata->intr_pin;\r
bu92747s[i]->irq = gpio_to_irq(platdata->intr_pin);\r
if (platdata->iomux_init)\r
platdata->iomux_init();\r
if (bu92747s[i]->pdata->irda_pwr_ctl)\r
bu92747s[i]->pdata->irda_pwr_ctl(0);\r
\r
- //init_waitqueue_head(&(bu92747s[i]->data_ready_wq));\r
-\r
spin_lock_init(&(bu92747s[i]->data_lock));\r
\r
mutex_unlock(&bu92747s_lock);\r
struct bu92747_port *s = dev_get_drvdata(&pdev->dev);\r
int i;\r
\r
- BU92747_IRDA_DBG("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
+ IRDA_DBG_FUNC("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
mutex_lock(&bu92747s_lock);\r
\r
/* find out the index for the chip we are removing */\r
if (s->open_flag) {\r
printk("line %d, enter %s \n", __LINE__, __FUNCTION__);\r
disable_irq(s->irq);\r
-\r
+ cancel_work_sync(&s->work);\r
s->suspending = 1;\r
uart_suspend_port(&bu92747_irda_uart_driver, &s->port);\r
\r
uart_resume_port(&bu92747_irda_uart_driver, &s->port);\r
s->suspending = 0;\r
\r
- enable_irq(s->irq);\r
-\r
if (!s->tx_empty)\r
s->tx_empty = 1;\r
- \r
+ enable_irq(s->irq);\r
if (s->workqueue && !IS_FIR(s))\r
bu92747_irda_dowork(s);\r
}\r