]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/lib/uart/uart_s3c2410.h
93bca29722c102dd5ad8625b55b1f7aaaf091e5d
[l4.git] / kernel / fiasco / src / lib / uart / uart_s3c2410.h
1 #ifndef L4_DRIVERS_UART_S3C2410_H__
2 #define L4_DRIVERS_UART_S3C2410_H__
3
4 #include "uart_base.h"
5
6 namespace L4
7 {
8   class Uart_s3c : public Uart
9   {
10   protected:
11     enum Uart_type
12     {
13       Type_24xx, Type_64xx, Type_s5pv210,
14     };
15
16     Uart_type type() const { return _type; }
17
18   public:
19     explicit Uart_s3c(Uart_type type) : _type(type) {}
20     bool startup(Io_register_block const *);
21     void shutdown();
22     bool change_mode(Transfer_mode m, Baud_rate r);
23     int get_char(bool blocking = true) const;
24     int char_avail() const;
25     inline void out_char(char c) const;
26     int write(char const *s, unsigned long count) const;
27     void fifo_reset();
28
29   protected:
30     virtual void ack_rx_irq() const = 0;
31     virtual void wait_for_empty_tx_fifo() const = 0;
32     virtual void wait_for_non_full_tx_fifo() const = 0;
33     virtual unsigned is_rx_fifo_non_empty() const = 0;
34
35   private:
36     Uart_type _type;
37   };
38
39   class Uart_s3c2410 : public Uart_s3c
40   {
41   public:
42     Uart_s3c2410() : Uart_s3c(Type_24xx) {}
43
44   protected:
45     void ack_rx_irq() const {}
46     void wait_for_empty_tx_fifo() const;
47     void wait_for_non_full_tx_fifo() const;
48     unsigned is_rx_fifo_non_empty() const;
49
50     void auto_flow_control(bool on);
51   };
52
53   class Uart_s3c64xx : public Uart_s3c
54   {
55   public:
56     Uart_s3c64xx() : Uart_s3c(Type_64xx) {}
57
58   protected:
59     void ack_rx_irq() const;
60     void wait_for_empty_tx_fifo() const;
61     void wait_for_non_full_tx_fifo() const;
62     unsigned is_rx_fifo_non_empty() const;
63   };
64
65   class Uart_s5pv210 : public Uart_s3c
66   {
67   public:
68     Uart_s5pv210() : Uart_s3c(Type_s5pv210) {}
69
70   protected:
71     void ack_rx_irq() const;
72     void wait_for_empty_tx_fifo() const;
73     void wait_for_non_full_tx_fifo() const;
74     unsigned is_rx_fifo_non_empty() const;
75   };
76 };
77
78 #endif