Path: blob/master/arch/mn10300/kernel/mn10300-serial-low.S
10817 views
###############################################################################1#2# Virtual DMA driver for MN10300 serial ports3#4# Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.5# Written by David Howells ([email protected])6#7# This program is free software; you can redistribute it and/or8# modify it under the terms of the GNU General Public Licence9# as published by the Free Software Foundation; either version10# 2 of the Licence, or (at your option) any later version.11#12###############################################################################13#include <linux/sys.h>14#include <linux/linkage.h>15#include <asm/page.h>16#include <asm/smp.h>17#include <asm/cpu-regs.h>18#include <asm/frame.inc>19#include <asm/timer-regs.h>20#include <proc/cache.h>21#include <unit/timex.h>22#include "mn10300-serial.h"2324#define SCxCTR 0x0025#define SCxICR 0x0426#define SCxTXB 0x0827#define SCxRXB 0x0928#define SCxSTR 0x0c29#define SCxTIM 0x0d3031.text3233###############################################################################34#35# serial port interrupt virtual DMA entry point36# - intended to run at interrupt priority 1 (not affected by local_irq_disable)37#38###############################################################################39.balign L1_CACHE_BYTES40ENTRY(mn10300_serial_vdma_interrupt)41# or EPSW_IE,psw # permit overriding by42# debugging interrupts43movm [d2,d3,a2,a3,exreg0],(sp)4445movhu (IAGR),a2 # see if which interrupt is46# pending47and IAGR_GN,a248add a2,a249add mn10300_serial_int_tbl,a25051mov (a2+),a352mov (__iobase,a3),e253mov (a2),a254jmp (a2)5556###############################################################################57#58# serial port receive interrupt virtual DMA entry point59# - intended to run at interrupt priority 1 (not affected by local_irq_disable)60# - stores data/status byte pairs in the ring buffer61# - induces a scheduler tick timer interrupt when done, which we then subvert62# on entry:63# A3 struct mn10300_serial_port *64# E2 I/O port base65#66###############################################################################67ENTRY(mn10300_serial_vdma_rx_handler)68mov (__rx_icr,a3),e369mov GxICR_DETECT,d270movbu d2,(e3) # ACK the interrupt71movhu (e3),d2 # flush7273mov (__rx_inp,a3),d374mov d3,a275add 2,d376and MNSC_BUFFER_SIZE-1,d377mov (__rx_outp,a3),d278cmp d3,d279beq mnsc_vdma_rx_overflow8081mov (__rx_buffer,a3),d282add d2,a283movhu (SCxSTR,e2),d284movbu d2,(1,a2)85movbu (SCxRXB,e2),d286movbu d2,(a2)87mov d3,(__rx_inp,a3)88bset MNSCx_RX_AVAIL,(__intr_flags,a3)8990mnsc_vdma_rx_done:91mov (__tm_icr,a3),a292mov GxICR_LEVEL_6|GxICR_ENABLE|GxICR_REQUEST|GxICR_DETECT,d293movhu d2,(a2) # request a slow interrupt94movhu (a2),d2 # flush9596movm (sp),[d2,d3,a2,a3,exreg0]97rti9899mnsc_vdma_rx_overflow:100bset MNSCx_RX_OVERF,(__intr_flags,a3)101bra mnsc_vdma_rx_done102103###############################################################################104#105# serial port transmit interrupt virtual DMA entry point106# - intended to run at interrupt priority 1 (not affected by local_irq_disable)107# - retrieves data bytes from the ring buffer and passes them to the serial port108# - induces a scheduler tick timer interrupt when done, which we then subvert109# A3 struct mn10300_serial_port *110# E2 I/O port base111#112###############################################################################113.balign L1_CACHE_BYTES114ENTRY(mn10300_serial_vdma_tx_handler)115mov (__tx_icr,a3),e3116mov GxICR_DETECT,d2117movbu d2,(e3) # ACK the interrupt118movhu (e3),d2 # flush119120btst 0x01,(__tx_break,a3) # handle transmit break request121bne mnsc_vdma_tx_break122123movbu (SCxSTR,e2),d2 # don't try and transmit a char if the124# buffer is not empty125btst SC01STR_TBF,d2 # (may have tried to jumpstart)126bne mnsc_vdma_tx_noint127128movbu (__tx_xchar,a3),d2 # handle hi-pri XON/XOFF129or d2,d2130bne mnsc_vdma_tx_xchar131132mov (__uart_state,a3),a2 # see if the TTY Tx queue has anything in it133mov (__xmit_tail,a2),d3134mov (__xmit_head,a2),d2135cmp d3,d2136beq mnsc_vdma_tx_empty137138mov (__xmit_buffer,a2),d2 # get a char from the buffer and139# transmit it140movbu (d3,d2),d2141movbu d2,(SCxTXB,e2) # Tx142143inc d3 # advance the buffer pointer144and __UART_XMIT_SIZE-1,d3145mov (__xmit_head,a2),d2146mov d3,(__xmit_tail,a2)147148sub d3,d2 # see if we've written everything149beq mnsc_vdma_tx_empty150151and __UART_XMIT_SIZE-1,d2 # see if we just made a hole152cmp __UART_XMIT_SIZE-2,d2153beq mnsc_vdma_tx_made_hole154155mnsc_vdma_tx_done:156mov (__tm_icr,a3),a2157mov GxICR_LEVEL_6|GxICR_ENABLE|GxICR_REQUEST|GxICR_DETECT,d2158movhu d2,(a2) # request a slow interrupt159movhu (a2),d2 # flush160161mnsc_vdma_tx_noint:162movm (sp),[d2,d3,a2,a3,exreg0]163rti164165mnsc_vdma_tx_empty:166mov +(NUM2GxICR_LEVEL(CONFIG_MN10300_SERIAL_IRQ_LEVEL)|GxICR_DETECT),d2167movhu d2,(e3) # disable the interrupt168movhu (e3),d2 # flush169170bset MNSCx_TX_EMPTY,(__intr_flags,a3)171bra mnsc_vdma_tx_done172173mnsc_vdma_tx_break:174movhu (SCxCTR,e2),d2 # turn on break mode175or SC01CTR_BKE,d2176movhu d2,(SCxCTR,e2)177mov +(NUM2GxICR_LEVEL(CONFIG_MN10300_SERIAL_IRQ_LEVEL)|GxICR_DETECT),d2178movhu d2,(e3) # disable transmit interrupts on this179# channel180movhu (e3),d2 # flush181bra mnsc_vdma_tx_noint182183mnsc_vdma_tx_xchar:184bclr 0xff,(__tx_xchar,a3)185movbu d2,(SCxTXB,e2)186bra mnsc_vdma_tx_done187188mnsc_vdma_tx_made_hole:189bset MNSCx_TX_SPACE,(__intr_flags,a3)190bra mnsc_vdma_tx_done191192193