]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/lib/uart/uart_s3c2410.h
update
[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     struct Save_block
71     {
72       unsigned ulcon;
73       unsigned ucon;
74       unsigned ufcon;
75       unsigned umcon;
76       unsigned ubrdiv;
77       unsigned ufracval;
78       unsigned uintp;
79       unsigned uintsp;
80       unsigned uintm;
81     };
82
83     void save(Save_block *) const;
84     void restore(Save_block const *) const;
85
86   protected:
87     void ack_rx_irq() const;
88     void wait_for_empty_tx_fifo() const;
89     void wait_for_non_full_tx_fifo() const;
90     unsigned is_rx_fifo_non_empty() const;
91   };
92 };
93
94 #endif