]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/lib/uart/arm/uart_imx.h
update
[l4.git] / kernel / fiasco / src / lib / uart / arm / uart_imx.h
1 /*
2  * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>
3  *     economic rights: Technische Universität Dresden (Germany)
4  *
5  * This file is part of TUD:OS and distributed under the terms of the
6  * GNU General Public License 2.
7  * Please see the COPYING-GPL-2 file for details.
8  */
9 #ifndef L4_CXX_UART_imx_H__
10 #define L4_CXX_UART_imx_H__
11
12 #include "uart_base.h"
13
14 namespace L4
15 {
16   class Uart_imx : public Uart
17   {
18   public:
19     enum platform_type { Type_imx21, Type_imx35, Type_imx51 };
20     Uart_imx(int rx_irq, int tx_irq, enum platform_type type)
21        : Uart(rx_irq, tx_irq), _base(~0UL), _type(type) {}
22     bool startup(unsigned long base);
23     void shutdown();
24     bool enable_rx_irq(bool enable = true);
25     bool enable_tx_irq(bool enable = true);
26     bool change_mode(Transfer_mode m, Baud_rate r);
27     int get_char(bool blocking = true) const;
28     int char_avail() const;
29     inline void out_char(char c) const;
30     int write(char const *s, unsigned long count) const;
31
32   private:
33     unsigned long _base;
34     enum platform_type _type;
35
36     inline unsigned long rd(unsigned long reg) const;
37     inline void wr(unsigned long reg, unsigned long val) const;
38   };
39
40   class Uart_imx21 : public Uart_imx
41   {
42   public:
43     Uart_imx21(int rx_irq, int tx_irq)
44        : Uart_imx(rx_irq, tx_irq, Type_imx21) {}
45   };
46
47   class Uart_imx35 : public Uart_imx
48   {
49   public:
50     Uart_imx35(int rx_irq, int tx_irq)
51        : Uart_imx(rx_irq, tx_irq, Type_imx35) {}
52   };
53
54   class Uart_imx51 : public Uart_imx
55   {
56   public:
57     Uart_imx51(int rx_irq, int tx_irq)
58        : Uart_imx(rx_irq, tx_irq, Type_imx51) {}
59   };
60 };
61
62 #endif