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