L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
uart_s3c2410.h
1/*
2 * Copyright (C) 2009-2012 Technische Universität Dresden.
3 * Copyright (C) 2023-2024 Kernkonzept GmbH.
4 * Author(s): Adam Lackorzynski <adam@os.inf.tu-dresden.de>
5 *
6 * License: see LICENSE.spdx (in this directory or the directories above)
7 */
8#pragma once
9
10#include "uart_base.h"
11
12namespace L4 {
13
14class Uart_s3c : public Uart
15{
16protected:
17 enum Uart_type
18 {
19 Type_24xx, Type_64xx, Type_s5pv210,
20 };
21
22 Uart_type type() const { return _type; }
23
24public:
25 explicit Uart_s3c(Uart_type type) : _type(type) {}
26 explicit Uart_s3c(Uart_type type, unsigned /*base_rate*/) : _type(type) {}
27 bool startup(Io_register_block const *) override;
28 void shutdown() override;
29 bool change_mode(Transfer_mode m, Baud_rate r) override;
30 int tx_avail() const;
31 void wait_tx_done() const;
32 inline void out_char(char c) const;
33 int write(char const *s, unsigned long count,
34 bool blocking = true) const override;
35 void fifo_reset();
36
37 int char_avail() const override;
38 int get_char(bool blocking = true) const override;
39
40protected:
41 virtual void ack_rx_irq() const = 0;
42 virtual void wait_for_empty_tx_fifo() const = 0;
43 virtual unsigned is_rx_fifo_non_empty() const = 0;
44 virtual unsigned is_tx_fifo_not_full() const = 0;
45
46private:
47 Uart_type _type;
48};
49
50class Uart_s3c2410 : public Uart_s3c
51{
52public:
53 Uart_s3c2410() : Uart_s3c(Type_24xx) {}
54 explicit Uart_s3c2410(unsigned base_rate) : Uart_s3c(Type_24xx, base_rate) {}
55
56protected:
57 void ack_rx_irq() const override {}
58 void wait_for_empty_tx_fifo() const override;
59 unsigned is_rx_fifo_non_empty() const override;
60 unsigned is_tx_fifo_not_full() const override;
61
62 void auto_flow_control(bool on);
63};
64
65class Uart_s3c64xx : public Uart_s3c
66{
67public:
68 Uart_s3c64xx() : Uart_s3c(Type_64xx) {}
69 explicit Uart_s3c64xx(unsigned base_rate) : Uart_s3c(Type_64xx, base_rate) {}
70
71protected:
72 void ack_rx_irq() const override;
73 void wait_for_empty_tx_fifo() const override;
74 unsigned is_rx_fifo_non_empty() const override;
75 unsigned is_tx_fifo_not_full() const override;
76};
77
78class Uart_s5pv210 : public Uart_s3c
79{
80public:
81 Uart_s5pv210() : Uart_s3c(Type_s5pv210) {}
82 explicit Uart_s5pv210(unsigned base_rate) : Uart_s3c(Type_s5pv210, base_rate) {}
83
84protected:
85 void ack_rx_irq() const override;
86 void wait_for_empty_tx_fifo() const override;
87 unsigned is_rx_fifo_non_empty() const override;
88 unsigned is_tx_fifo_not_full() const override;
89};
90
91} // namespace L4
Uart driver abstraction.
Definition uart_base.h:21
virtual void shutdown()=0
Terminate the UART driver.
virtual int char_avail() const =0
Check if there is at least one character available for reading from the UART.
L4 low-level kernel interface.