コード例 #1
0
static void ambauart_break_ctl(struct uart_port *port, int break_state)
{
	unsigned int lcr;

	lcr = UART_GET_LCR(port);
	if (break_state == -1)
		lcr |= KS8695_UART_LINEC_BRK;
	else
		lcr &= ~KS8695_UART_LINEC_BRK;
	UART_PUT_LCR(port, lcr);
}
コード例 #2
0
ファイル: bfin_5xx.c プロジェクト: johnny/CobraDroidBeta
/*
 * Interrupts are always disabled.
 */
static void bfin_serial_break_ctl(struct uart_port *port, int break_state)
{
	struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
	u16 lcr = UART_GET_LCR(uart);
	if (break_state)
		lcr |= SB;
	else
		lcr &= ~SB;
	UART_PUT_LCR(uart, lcr);
	SSYNC();
}
コード例 #3
0
static void ks8695uart_shutdown(struct uart_port *port)
{
	
	free_irq(KS8695_IRQ_UART_RX, port);
	free_irq(KS8695_IRQ_UART_TX, port);
	free_irq(KS8695_IRQ_UART_MODEM_STATUS, port);
	free_irq(KS8695_IRQ_UART_LINE_STATUS, port);

	
	UART_PUT_LCR(port, UART_GET_LCR(port) & ~URLC_URSBC);
	UART_PUT_FCR(port, UART_GET_FCR(port) & ~URFC_URFE);
}
コード例 #4
0
ファイル: serial_ks8695.c プロジェクト: AppEngine/linux-2.6
static void ks8695uart_break_ctl(struct uart_port *port, int break_state)
{
	unsigned int lcr;

	lcr = UART_GET_LCR(port);

	if (break_state == -1)
		lcr |= URLC_URSBC;
	else
		lcr &= ~URLC_URSBC;

	UART_PUT_LCR(port, lcr);
}
コード例 #5
0
ファイル: serial_ks8695.c プロジェクト: AppEngine/linux-2.6
static void ks8695uart_shutdown(struct uart_port *port)
{
	/*
	 * Free the interrupt
	 */
	free_irq(KS8695_IRQ_UART_RX, port);
	free_irq(KS8695_IRQ_UART_TX, port);
	free_irq(KS8695_IRQ_UART_MODEM_STATUS, port);
	free_irq(KS8695_IRQ_UART_LINE_STATUS, port);

	/* disable break condition and fifos */
	UART_PUT_LCR(port, UART_GET_LCR(port) & ~URLC_URSBC);
	UART_PUT_FCR(port, UART_GET_FCR(port) & ~URFC_URFE);
}
コード例 #6
0
static void ambauart_shutdown(struct uart_port *port)
{
#if DEBUG
       printk("ambauart_shutdown\n");
#endif
        /*
         * disable all interrupts, disable the port
         */

        UART_PUT_IER(port, UART_GET_IER(port) & 0xFFFFF0FF);

        /* disable break condition and fifos */
        UART_PUT_LCR(port, UART_GET_LCR(port) & ~KS8695_UART_LINEC_BRK);
        UART_PUT_FCR(port, UART_GET_FCR(port) & ~KS8695_UART_FIFO_FEN);

        free_irq(KS8695_INT_UART_RX, port);
        free_irq(KS8695_INT_UART_TX, port);
        free_irq(KS8695_INT_UART_MODEMS, port);
        free_irq(KS8695_INT_UART_LINE_ERR, port);
}
コード例 #7
0
ファイル: serial_ks8695.c プロジェクト: AppEngine/linux-2.6
static void ks8695uart_set_termios(struct uart_port *port, struct ktermios *termios, struct ktermios *old)
{
	unsigned int lcr, fcr = 0;
	unsigned long flags;
	unsigned int baud, quot;

	/*
	 * Ask the core to calculate the divisor for us.
	 */
	baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
	quot = uart_get_divisor(port, baud);

	switch (termios->c_cflag & CSIZE) {
	case CS5:
		lcr = URCL_5;
		break;
	case CS6:
		lcr = URCL_6;
		break;
	case CS7:
		lcr = URCL_7;
		break;
	default:
		lcr = URCL_8;
		break;
	}

	/* stop bits */
	if (termios->c_cflag & CSTOPB)
		lcr |= URLC_URSB;

	/* parity */
	if (termios->c_cflag & PARENB) {
		if (termios->c_cflag & CMSPAR) {	/* Mark or Space parity */
			if (termios->c_cflag & PARODD)
				lcr |= URPE_MARK;
			else
				lcr |= URPE_SPACE;
		}
		else if (termios->c_cflag & PARODD)
			lcr |= URPE_ODD;
		else
			lcr |= URPE_EVEN;
	}

	if (port->fifosize > 1)
		fcr = URFC_URFRT_8 | URFC_URTFR | URFC_URRFR | URFC_URFE;

	spin_lock_irqsave(&port->lock, flags);

	/*
	 * Update the per-port timeout.
	 */
	uart_update_timeout(port, termios->c_cflag, baud);

	port->read_status_mask = URLS_URROE;
	if (termios->c_iflag & INPCK)
		port->read_status_mask |= (URLS_URFE | URLS_URPE);
	if (termios->c_iflag & (BRKINT | PARMRK))
		port->read_status_mask |= URLS_URBI;

	/*
	 * Characters to ignore
	 */
	port->ignore_status_mask = 0;
	if (termios->c_iflag & IGNPAR)
		port->ignore_status_mask |= (URLS_URFE | URLS_URPE);
	if (termios->c_iflag & IGNBRK) {
		port->ignore_status_mask |= URLS_URBI;
		/*
		 * If we're ignoring parity and break indicators,
		 * ignore overruns too (for real raw support).
		 */
		if (termios->c_iflag & IGNPAR)
			port->ignore_status_mask |= URLS_URROE;
	}

	/*
	 * Ignore all characters if CREAD is not set.
	 */
	if ((termios->c_cflag & CREAD) == 0)
		port->ignore_status_mask |= UART_DUMMY_LSR_RX;

	/* first, disable everything */
	if (UART_ENABLE_MS(port, termios->c_cflag))
		ks8695uart_enable_ms(port);
	else
		ks8695uart_disable_ms(port);

	/* Set baud rate */
	UART_PUT_BRDR(port, quot);

	UART_PUT_LCR(port, lcr);
	UART_PUT_FCR(port, fcr);

	spin_unlock_irqrestore(&port->lock, flags);
}
コード例 #8
0
static int bfin_sir_set_speed(struct bfin_sir_port *port, int speed)
{
	int ret = -EINVAL;
	unsigned int quot;
	unsigned short val, lsr, lcr;
	static int utime;
	int count = 10;

	lcr = WLS(8);

	switch (speed) {
	case 9600:
	case 19200:
	case 38400:
	case 57600:
	case 115200:

		/*
		 * IRDA is not affected by anomaly 05000230, so there is no
		 * need to tweak the divisor like he UART driver (which will
		 * slightly speed up the baud rate on us).
		 */
		quot = (port->clk + (8 * speed)) / (16 * speed);

		do {
			udelay(utime);
			lsr = UART_GET_LSR(port);
		} while (!(lsr & TEMT) && count--);

		/* The useconds for 1 bits to transmit */
		utime = 1000000 / speed + 1;

		/* Clear UCEN bit to reset the UART state machine
		 * and control registers
		 */
		val = UART_GET_GCTL(port);
		val &= ~UCEN;
		UART_PUT_GCTL(port, val);

		/* Set DLAB in LCR to Access THR RBR IER */
		UART_SET_DLAB(port);
		SSYNC();

		UART_PUT_DLL(port, quot & 0xFF);
		UART_PUT_DLH(port, (quot >> 8) & 0xFF);
		SSYNC();

		/* Clear DLAB in LCR */
		UART_CLEAR_DLAB(port);
		SSYNC();

		UART_PUT_LCR(port, lcr);

		val = UART_GET_GCTL(port);
		val |= UCEN;
		UART_PUT_GCTL(port, val);

		ret = 0;
		break;
	default:
		printk(KERN_WARNING "bfin_sir: Invalid speed %d\n", speed);
		break;
	}

	val = UART_GET_GCTL(port);
	/* If not add the 'RPOLC', we can't catch the receive interrupt.
	 * It's related with the HW layout and the IR transiver.
	 */
	val |= IREN | RPOLC;
	UART_PUT_GCTL(port, val);
	return ret;
}
コード例 #9
0
static void ssauart_change_speed (struct uart_port *port, u_int cflag, u_int iflag, u_int quot)
{
   u_int lcr_h;
   unsigned long flags;

#if DEBUG
   printk("ssauart_set_cflag(0x%x) called\n", cflag);
#endif
   /* byte size and parity */
   switch (cflag & CSIZE) {
   case CS5: lcr_h = UART_LCR_WLEN5; break;
   case CS6: lcr_h = UART_LCR_WLEN6; break;
   case CS7: lcr_h = UART_LCR_WLEN7; break;
   default:  lcr_h = UART_LCR_WLEN8; break; // CS8
   }
   if (cflag & CSTOPB)
       lcr_h |= UART_LCR_STOP;
   if (cflag & PARENB) {
       lcr_h |= UART_LCR_PARITY;
   }

   local_irq_save(flags);

   port->read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR;
   if (iflag & INPCK)
       port->read_status_mask |= UART_LSR_FE | UART_LSR_PE;
   if (iflag & (BRKINT | PARMRK))
       port->read_status_mask |= UART_LSR_BI;

   /*
    * Characters to ignore
    */
   port->ignore_status_mask = 0;
   if (iflag & IGNPAR)
       port->ignore_status_mask |= UART_LSR_PE | UART_LSR_FE;
   if (iflag & IGNBRK) {
       port->ignore_status_mask |= UART_LSR_BI;
       /*
        * If we're ignore parity and break indicators, ignore
        * overruns too.  (For real raw support).
        */
       if (iflag & IGNPAR)
          port->ignore_status_mask |= UART_LSR_OE;
   }

   /*
    * !!! ignore all characters if CREAD is not set
    */
   if ((cflag & CREAD) == 0)
      port->ignore_status_mask |= UART_LSR_DR;

   /* Turn on DLAB */
   UART_PUT_LCR(port, UART_GET_LCR(port) | UART_LCR_DLAB);

   /* Set baud rate */
   UART_PUT_DLM(port, ((quot & 0xff00) >> 8));
   UART_PUT_DLL(port, (quot & 0xff));

   /* Turn off DLAB */
   UART_PUT_LCR(port, UART_GET_LCR(port) & ~UART_LCR_DLAB);

   local_irq_restore(flags);
}
コード例 #10
0
static void ambauart_change_speed(struct uart_port *port, u_int cflag, u_int iflag, u_int quot)
{
	u_int lcr, old_ier, fcr=0;
	unsigned long flags;

#if DEBUG
	printk("ambauart_set_cflag(0x%x) called\n", cflag);
#endif
	//printk("ambauart_change_speed\n");
	/* byte size and parity */
	switch (cflag & CSIZE) {
	case CS5: lcr = KS8695_UART_LINEC_WLEN5; break;
	case CS6: lcr = KS8695_UART_LINEC_WLEN6; break;
	case CS7: lcr = KS8695_UART_LINEC_WLEN7; break;
	default:  lcr = KS8695_UART_LINEC_WLEN8; break; // CS8
	}
	if (cflag & CSTOPB)
		lcr |= KS8695_UART_LINEC_STP2;
	if (cflag & PARENB) {
		lcr |= KS8695_UART_LINEC_PEN;
		if (!(cflag & PARODD))
			lcr |= KS8695_UART_LINEC_EPS;
	}
	if (port->fifosize > 1)
		fcr = KS8695_UART_FIFO_TRIG04 | KS8695_UART_FIFO_TXRST | KS8695_UART_FIFO_RXRST | KS8695_UART_FIFO_FEN;

	port->read_status_mask = KS8695_UART_LINES_OE;
	if (iflag & INPCK)
		port->read_status_mask |= (KS8695_UART_LINES_FE | KS8695_UART_LINES_PE);
	if (iflag & (BRKINT | PARMRK))
		port->read_status_mask |= KS8695_UART_LINES_BE;

	/*
	 * Characters to ignore
	 */
	port->ignore_status_mask = 0;
	if (iflag & IGNPAR)
		port->ignore_status_mask |= (KS8695_UART_LINES_FE | KS8695_UART_LINES_PE);
	if (iflag & IGNBRK) {
		port->ignore_status_mask |= KS8695_UART_LINES_BE;
		/*
		 * If we're ignoring parity and break indicators,
		 * ignore overruns too (for real raw support).
		 */
		if (iflag & IGNPAR)
			port->ignore_status_mask |= KS8695_UART_LINES_OE;
	}

	/*
	 * Ignore all characters if CREAD is not set.
	 */
	if ((cflag & CREAD) == 0)
		port->ignore_status_mask |= UART_DUMMY_LSR_RX;

	/* first, disable everything */
	save_flags(flags); cli();
	old_ier = UART_GET_IER(port);
	UART_PUT_IER(port, old_ier & 0xFFFFF0FF);
	old_ier &= ~KS8695_INT_ENABLE_MODEM;

	if ((port->flags & ASYNC_HARDPPS_CD) ||
	    (cflag & CRTSCTS) || !(cflag & CLOCAL))
		old_ier |= KS8695_INT_ENABLE_MODEM;


	/* Set baud rate */
	//	UART_PUT_BRDR(port, port->uartclk / quot); 
	UART_PUT_BRDR(port, 0x28B); 

	UART_PUT_LCR(port, lcr);
	UART_PUT_FCR(port, fcr);
	UART_PUT_IER(port, old_ier & 0xFFFFFEFF);

	restore_flags(flags);
}
コード例 #11
0
ファイル: bfin_5xx.c プロジェクト: johnny/CobraDroidBeta
static void
bfin_serial_set_termios(struct uart_port *port, struct ktermios *termios,
		   struct ktermios *old)
{
	struct bfin_serial_port *uart = (struct bfin_serial_port *)port;
	unsigned long flags;
	unsigned int baud, quot;
	unsigned short val, ier, lcr = 0;

	switch (termios->c_cflag & CSIZE) {
	case CS8:
		lcr = WLS(8);
		break;
	case CS7:
		lcr = WLS(7);
		break;
	case CS6:
		lcr = WLS(6);
		break;
	case CS5:
		lcr = WLS(5);
		break;
	default:
		printk(KERN_ERR "%s: word lengh not supported\n",
			__func__);
	}

	if (termios->c_cflag & CSTOPB)
		lcr |= STB;
	if (termios->c_cflag & PARENB)
		lcr |= PEN;
	if (!(termios->c_cflag & PARODD))
		lcr |= EPS;
	if (termios->c_cflag & CMSPAR)
		lcr |= STP;

	port->read_status_mask = OE;
	if (termios->c_iflag & INPCK)
		port->read_status_mask |= (FE | PE);
	if (termios->c_iflag & (BRKINT | PARMRK))
		port->read_status_mask |= BI;

	/*
	 * Characters to ignore
	 */
	port->ignore_status_mask = 0;
	if (termios->c_iflag & IGNPAR)
		port->ignore_status_mask |= FE | PE;
	if (termios->c_iflag & IGNBRK) {
		port->ignore_status_mask |= BI;
		/*
		 * If we're ignoring parity and break indicators,
		 * ignore overruns too (for real raw support).
		 */
		if (termios->c_iflag & IGNPAR)
			port->ignore_status_mask |= OE;
	}

	baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
	quot = uart_get_divisor(port, baud);
	spin_lock_irqsave(&uart->port.lock, flags);

	UART_SET_ANOMALY_THRESHOLD(uart, USEC_PER_SEC / baud * 15);

	/* Disable UART */
	ier = UART_GET_IER(uart);
	UART_DISABLE_INTS(uart);

	/* Set DLAB in LCR to Access DLL and DLH */
	UART_SET_DLAB(uart);

	UART_PUT_DLL(uart, quot & 0xFF);
	UART_PUT_DLH(uart, (quot >> 8) & 0xFF);
	SSYNC();

	/* Clear DLAB in LCR to Access THR RBR IER */
	UART_CLEAR_DLAB(uart);

	UART_PUT_LCR(uart, lcr);

	/* Enable UART */
	UART_ENABLE_INTS(uart, ier);

	val = UART_GET_GCTL(uart);
	val |= UCEN;
	UART_PUT_GCTL(uart, val);

	/* Port speed changed, update the per-port timeout. */
	uart_update_timeout(port, termios->c_cflag, baud);

	spin_unlock_irqrestore(&uart->port.lock, flags);
}
コード例 #12
0
static void ks8695uart_set_termios(struct uart_port *port, struct ktermios *termios, struct ktermios *old)
{
	unsigned int lcr, fcr = 0;
	unsigned long flags;
	unsigned int baud, quot;

	
	baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
	quot = uart_get_divisor(port, baud);

	switch (termios->c_cflag & CSIZE) {
	case CS5:
		lcr = URCL_5;
		break;
	case CS6:
		lcr = URCL_6;
		break;
	case CS7:
		lcr = URCL_7;
		break;
	default:
		lcr = URCL_8;
		break;
	}

	
	if (termios->c_cflag & CSTOPB)
		lcr |= URLC_URSB;

	
	if (termios->c_cflag & PARENB) {
		if (termios->c_cflag & CMSPAR) {	
			if (termios->c_cflag & PARODD)
				lcr |= URPE_MARK;
			else
				lcr |= URPE_SPACE;
		}
		else if (termios->c_cflag & PARODD)
			lcr |= URPE_ODD;
		else
			lcr |= URPE_EVEN;
	}

	if (port->fifosize > 1)
		fcr = URFC_URFRT_8 | URFC_URTFR | URFC_URRFR | URFC_URFE;

	spin_lock_irqsave(&port->lock, flags);

	
	uart_update_timeout(port, termios->c_cflag, baud);

	port->read_status_mask = URLS_URROE;
	if (termios->c_iflag & INPCK)
		port->read_status_mask |= (URLS_URFE | URLS_URPE);
	if (termios->c_iflag & (BRKINT | PARMRK))
		port->read_status_mask |= URLS_URBI;

	
	port->ignore_status_mask = 0;
	if (termios->c_iflag & IGNPAR)
		port->ignore_status_mask |= (URLS_URFE | URLS_URPE);
	if (termios->c_iflag & IGNBRK) {
		port->ignore_status_mask |= URLS_URBI;
		
		if (termios->c_iflag & IGNPAR)
			port->ignore_status_mask |= URLS_URROE;
	}

	
	if ((termios->c_cflag & CREAD) == 0)
		port->ignore_status_mask |= UART_DUMMY_LSR_RX;

	
	if (UART_ENABLE_MS(port, termios->c_cflag))
		ks8695uart_enable_ms(port);
	else
		ks8695uart_disable_ms(port);

	
	UART_PUT_BRDR(port, quot);

	UART_PUT_LCR(port, lcr);
	UART_PUT_FCR(port, fcr);

	spin_unlock_irqrestore(&port->lock, flags);
}