X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/2c0b4a49174edd0b00eca8e71334957f9dccee0b..1ecc7dcbd91cc4b8a756fda7a94bc51ab9c1d86e:/target/linux/ifxmips/files/drivers/char/ifxmips_ssc.c diff --git a/target/linux/ifxmips/files/drivers/char/ifxmips_ssc.c b/target/linux/ifxmips/files/drivers/char/ifxmips_ssc.c index 9f5c0047a..3742e20c7 100644 --- a/target/linux/ifxmips/files/drivers/char/ifxmips_ssc.c +++ b/target/linux/ifxmips/files/drivers/char/ifxmips_ssc.c @@ -58,16 +58,6 @@ #include #include -#ifdef SSC_FRAME_INT_ENABLE -#undef SSC_FRAME_INT_ENABLE -#endif - -#define not_yet - -#define SPI_VINETIC - - - /* allow the user to set the major device number */ static int maj = 0; @@ -78,15 +68,6 @@ static int maj = 0; */ static struct ifx_ssc_port *isp; -/* prototypes for fops */ -static ssize_t ifx_ssc_read (struct file *, char *, size_t, loff_t *); -static ssize_t ifx_ssc_write (struct file *, const char *, size_t, loff_t *); -//static unsigned int ifx_ssc_poll(struct file *, struct poll_table_struct *); -int ifx_ssc_ioctl (struct inode *, struct file *, unsigned int, - unsigned long); -int ifx_ssc_open (struct inode *, struct file *); -int ifx_ssc_close (struct inode *, struct file *); - /* other forward declarations */ static unsigned int ifx_ssc_get_kernel_clk (struct ifx_ssc_port *info); static void tx_int (struct ifx_ssc_port *); @@ -94,15 +75,6 @@ static void tx_int (struct ifx_ssc_port *); extern unsigned int ifxmips_get_fpi_hz (void); extern void mask_and_ack_ifxmips_irq (unsigned int irq_nr); -static struct file_operations ifx_ssc_fops = { - .owner = THIS_MODULE, - .read = ifx_ssc_read, - .write = ifx_ssc_write, - .ioctl = ifx_ssc_ioctl, - .open = ifx_ssc_open, - .release = ifx_ssc_close, -}; - static inline unsigned int ifx_ssc_get_kernel_clk (struct ifx_ssc_port *info) { @@ -117,49 +89,6 @@ ifx_ssc_get_kernel_clk (struct ifx_ssc_port *info) return ifxmips_get_fpi_hz () / rmc; } -#ifndef not_yet -#ifdef IFX_SSC_INT_USE_BH -/* - * This routine is used by the interrupt handler to schedule - * processing in the software interrupt portion of the driver - * (also known as the "bottom half"). This can be called any - * number of times for any channel without harm. - */ -static inline void -ifx_ssc_sched_event (struct ifx_ssc_port *info, int event) -{ - info->event |= 1 << event; /* remember what kind of event and who */ - queue_task (&info->tqueue, &tq_cyclades); /* it belongs to */ - mark_bh (CYCLADES_BH); /* then trigger event */ -} - -static void -do_softint (void *private_) -{ - struct ifx_ssc_port *info = (struct ifx_ssc_port *) private_; - - if (test_and_clear_bit (Cy_EVENT_HANGUP, &info->event)) - { - wake_up_interruptible (&info->open_wait); - info->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CALLOUT_ACTIVE); - } - - if (test_and_clear_bit (Cy_EVENT_OPEN_WAKEUP, &info->event)) - wake_up_interruptible (&info->open_wait); - - if (test_and_clear_bit (Cy_EVENT_DELTA_WAKEUP, &info->event)) - wake_up_interruptible (&info->delta_msr_wait); - - if (test_and_clear_bit (Cy_EVENT_WRITE_WAKEUP, &info->event)) - wake_up_interruptible (&tty->write_wait); -#ifdef Z_WAKE - if (test_and_clear_bit (Cy_EVENT_SHUTDOWN_WAKEUP, &info->event)) - wake_up_interruptible (&info->shutdown_wait); -#endif -} -#endif -#endif - inline static void rx_int (struct ifx_ssc_port *info) { @@ -203,7 +132,7 @@ rx_int (struct ifx_ssc_port *info) // check if transfer is complete if (info->rxbuf_ptr >= info->rxbuf_end) { - disable_irq(info->rxirq); + disable_irq(IFXMIPS_SSC_RIR); wake_up_interruptible (&info->rwait); } else if ((info->opts.modeRxTx == IFX_SSC_MODE_RX) && (readl(IFXMIPS_SSC_RXCNT) == 0)) { @@ -261,7 +190,7 @@ tx_int (struct ifx_ssc_port *info) // check if transmission complete if (info->txbuf_ptr >= info->txbuf_end) { - disable_irq(info->txirq); + disable_irq(IFXMIPS_SSC_TIR); kfree (info->txbuf); info->txbuf = NULL; } @@ -338,9 +267,9 @@ ifx_ssc_abort (struct ifx_ssc_port *info) local_irq_save (flags); - disable_irq(info->rxirq); - disable_irq(info->txirq); - disable_irq(info->errirq); + disable_irq(IFXMIPS_SSC_RIR); + disable_irq(IFXMIPS_SSC_TIR); + disable_irq(IFXMIPS_SSC_EIR); local_irq_restore (flags); @@ -368,9 +297,9 @@ ifx_ssc_abort (struct ifx_ssc_port *info) wake_up_interruptible (&info->rwait); // clear pending int's - mask_and_ack_ifxmips_irq(info->rxirq); - mask_and_ack_ifxmips_irq(info->txirq); - mask_and_ack_ifxmips_irq(info->errirq); + mask_and_ack_ifxmips_irq(IFXMIPS_SSC_RIR); + mask_and_ack_ifxmips_irq(IFXMIPS_SSC_TIR); + mask_and_ack_ifxmips_irq(IFXMIPS_SSC_EIR); // clear error flags writel(IFX_SSC_WHBSTATE_CLR_ALL_ERROR, IFXMIPS_SSC_WHBSTATE); @@ -396,7 +325,6 @@ ifx_ssc_open (struct inode *inode, struct file *filp) line = (int) inode; } else { line = MINOR (filp->f_dentry->d_inode->i_rdev); - filp->f_op = &ifx_ssc_fops; } /* don't open more minor devices than we can support */ @@ -410,9 +338,9 @@ ifx_ssc_open (struct inode *inode, struct file *filp) return -EBUSY; info->port_is_open++; - disable_irq(info->rxirq); - disable_irq(info->txirq); - disable_irq(info->errirq); + disable_irq(IFXMIPS_SSC_RIR); + disable_irq(IFXMIPS_SSC_TIR); + disable_irq(IFXMIPS_SSC_EIR); /* Flush and enable TX/RX FIFO */ writel((IFX_SSC_DEF_TXFIFO_FL << IFX_SSC_XFCON_ITL_OFFSET) | IFX_SSC_XFCON_FIFO_FLUSH | IFX_SSC_XFCON_FIFO_ENABLE, IFXMIPS_SSC_TXFCON); @@ -426,9 +354,9 @@ ifx_ssc_open (struct inode *inode, struct file *filp) writel(IFX_SSC_WHBSTATE_CLR_ALL_ERROR, IFXMIPS_SSC_WHBSTATE); // clear pending interrupts - mask_and_ack_ifxmips_irq(info->rxirq); - mask_and_ack_ifxmips_irq(info->txirq); - mask_and_ack_ifxmips_irq(info->errirq); + mask_and_ack_ifxmips_irq(IFXMIPS_SSC_RIR); + mask_and_ack_ifxmips_irq(IFXMIPS_SSC_TIR); + mask_and_ack_ifxmips_irq(IFXMIPS_SSC_EIR); writel(IFX_SSC_WHBSTATE_SET_ENABLE, IFXMIPS_SSC_WHBSTATE); @@ -518,14 +446,14 @@ ifx_ssc_read_helper (struct ifx_ssc_port *info, char *buf, size_t len, int from_ tx_int (info); if (info->txbuf_ptr < info->txbuf_end) - enable_irq(info->txirq); + enable_irq(IFXMIPS_SSC_TIR); - enable_irq(info->rxirq); + enable_irq(IFXMIPS_SSC_RIR); } else { local_irq_restore(flags); if (readl(IFXMIPS_SSC_RXCNT) & IFX_SSC_RXCNT_TODO_MASK) return -EBUSY; - enable_irq(info->rxirq); + enable_irq(IFXMIPS_SSC_RIR); if (len < IFX_SSC_RXREQ_BLOCK_SIZE) writel(len << IFX_SSC_RXREQ_RXCOUNT_OFFSET, IFXMIPS_SSC_RXREQ); else @@ -574,7 +502,7 @@ ifx_ssc_write_helper (struct ifx_ssc_port *info, const char *buf, tx_int (info); if (info->txbuf_ptr < info->txbuf_end) { - enable_irq(info->txirq); + enable_irq(IFXMIPS_SSC_TIR); } } @@ -611,7 +539,7 @@ ifx_ssc_kread (int port, char *kbuf, size_t len) ret_val = ifx_ssc_read_helper_poll (info, kbuf, len, 1); info->rxbuf = NULL; - disable_irq(info->rxirq); + disable_irq(IFXMIPS_SSC_RIR); return ret_val; } @@ -667,7 +595,7 @@ ifx_ssc_read (struct file *filp, char *ubuf, size_t len, loff_t * off) if (copy_to_user ((void *) ubuf, info->rxbuf, ret_val) != 0) ret_val = -EFAULT; - disable_irq(info->rxirq); + disable_irq(IFXMIPS_SSC_RIR); kfree (info->rxbuf); info->rxbuf = NULL; @@ -749,7 +677,6 @@ ifx_ssc_frm_control_set (struct ifx_ssc_port *info) { unsigned long tmp; - // check parameters if ((info->frm_opts.DataLength > IFX_SSC_SFCON_DATA_LENGTH_MAX) || (info->frm_opts.DataLength < 1) || (info->frm_opts.PauseLength > IFX_SSC_SFCON_PAUSE_LENGTH_MAX) @@ -1161,6 +1088,15 @@ ifx_ssc_ioctl (struct inode *inode, struct file *filp, unsigned int cmd, unsigne } EXPORT_SYMBOL(ifx_ssc_ioctl); +static struct file_operations ifx_ssc_fops = { + .owner = THIS_MODULE, + .read = ifx_ssc_read, + .write = ifx_ssc_write, + .ioctl = ifx_ssc_ioctl, + .open = ifx_ssc_open, + .release = ifx_ssc_close, +}; + int __init ifx_ssc_init (void) { @@ -1227,9 +1163,6 @@ ifx_ssc_init (void) /* values specific to SSC1 */ if (i == 0) { info->mapbase = IFXMIPS_SSC_BASE_ADDR; - info->txirq = IFXMIPS_SSC_TIR; - info->rxirq = IFXMIPS_SSC_RIR; - info->errirq = IFXMIPS_SSC_EIR; } writel(IFX_SSC_DEF_RMC << IFX_CLC_RUN_DIVIDER_OFFSET, IFXMIPS_SSC_CLC); @@ -1241,34 +1174,34 @@ ifx_ssc_init (void) // init serial framing register writel(IFX_SSC_DEF_SFCON, IFXMIPS_SSC_SFCON); - ret_val = request_irq(info->txirq, ifx_ssc_tx_int, SA_INTERRUPT, "ifx_ssc_tx", info); + ret_val = request_irq(IFXMIPS_SSC_TIR, ifx_ssc_tx_int, IRQF_DISABLED, "ifx_ssc_tx", info); if (ret_val) { - printk("%s: unable to get irq %d\n", __func__, info->txirq); + printk("%s: unable to get irq %d\n", __func__, IFXMIPS_SSC_TIR); local_irq_restore(flags); goto errout; } - ret_val = request_irq(info->rxirq, ifx_ssc_rx_int, SA_INTERRUPT, "ifx_ssc_rx", info); + ret_val = request_irq(IFXMIPS_SSC_RIR, ifx_ssc_rx_int, IRQF_DISABLED, "ifx_ssc_rx", info); if (ret_val) { - printk ("%s: unable to get irq %d\n", __func__, info->rxirq); + printk ("%s: unable to get irq %d\n", __func__, IFXMIPS_SSC_RIR); local_irq_restore (flags); goto irqerr; } - ret_val = request_irq(info->errirq, ifx_ssc_err_int, SA_INTERRUPT,"ifx_ssc_err", info); + ret_val = request_irq(IFXMIPS_SSC_EIR, ifx_ssc_err_int, IRQF_DISABLED, "ifx_ssc_err", info); if (ret_val) { - printk ("%s: unable to get irq %d\n", __func__, info->errirq); + printk ("%s: unable to get irq %d\n", __func__, IFXMIPS_SSC_EIR); local_irq_restore (flags); goto irqerr; } writel(IFX_SSC_DEF_IRNEN, IFXMIPS_SSC_IRN); - enable_irq(info->txirq); - enable_irq(info->rxirq); - enable_irq(info->errirq); + //enable_irq(IFXMIPS_SSC_TIR); + //enable_irq(IFXMIPS_SSC_RIR); + //enable_irq(IFXMIPS_SSC_EIR); local_irq_restore (flags); } @@ -1286,9 +1219,9 @@ ifx_ssc_init (void) return 0; irqerr: - free_irq(isp[0].txirq, &isp[0]); - free_irq(isp[0].rxirq, &isp[0]); - free_irq(isp[0].errirq, &isp[0]); + free_irq(IFXMIPS_SSC_TIR, &isp[0]); + free_irq(IFXMIPS_SSC_RIR, &isp[0]); + free_irq(IFXMIPS_SSC_EIR, &isp[0]); errout: kfree (isp); return (ret_val); @@ -1301,9 +1234,9 @@ ifx_ssc_cleanup_module (void) for (i = 0; i < PORT_CNT; i++) { writel(IFX_SSC_WHBSTATE_CLR_ENABLE, IFXMIPS_SSC_WHBSTATE); - free_irq(isp[i].txirq, &isp[i]); - free_irq(isp[i].rxirq, &isp[i]); - free_irq(isp[i].errirq, &isp[i]); + free_irq(IFXMIPS_SSC_TIR, &isp[i]); + free_irq(IFXMIPS_SSC_RIR, &isp[i]); + free_irq(IFXMIPS_SSC_EIR, &isp[i]); } kfree (isp); }