L4Re Operating System Framework – Interface and Usage Documentation
Loading...
Searching...
No Matches
uart_s3c2410.h
1/* SPDX-License-Identifier: GPL-2.0-only OR License-Ref-kk-custom */
2/*
3 * Copyright (C) 2023 Kernkonzept GmbH.
4 */
5/*
6 * (c) 2009-2012 Adam Lackorzynski <adam@os.inf.tu-dresden.de>
7 * economic rights: Technische Universität Dresden (Germany)
8 *
9 * This file is part of TUD:OS and distributed under the terms of the
10 * GNU General Public License 2.
11 * Please see the COPYING-GPL-2 file for details.
12 */
13#pragma once
14
15#include "uart_base.h"
16
17namespace L4
18{
19 class Uart_s3c : public Uart
20 {
21 protected:
22 enum Uart_type
23 {
24 Type_24xx, Type_64xx, Type_s5pv210,
25 };
26
27 Uart_type type() const { return _type; }
28
29 public:
30 explicit Uart_s3c(Uart_type type) : _type(type) {}
31 explicit Uart_s3c(Uart_type type, unsigned /*base_rate*/) : _type(type) {}
32 bool startup(Io_register_block const *) override;
33 void shutdown() override;
34 bool change_mode(Transfer_mode m, Baud_rate r) override;
35 int get_char(bool blocking = true) const override;
36 int char_avail() const override;
37 int tx_avail() const;
38 void wait_tx_done() const;
39 inline void out_char(char c) const;
40 int write(char const *s, unsigned long count,
41 bool blocking = true) const override;
42 void fifo_reset();
43
44 protected:
45 virtual void ack_rx_irq() const = 0;
46 virtual void wait_for_empty_tx_fifo() const = 0;
47 virtual unsigned is_rx_fifo_non_empty() const = 0;
48 virtual unsigned is_tx_fifo_not_full() const = 0;
49
50 private:
51 Uart_type _type;
52 };
53
54 class Uart_s3c2410 : public Uart_s3c
55 {
56 public:
57 Uart_s3c2410() : Uart_s3c(Type_24xx) {}
58 explicit Uart_s3c2410(unsigned base_rate) : Uart_s3c(Type_24xx, base_rate) {}
59
60 protected:
61 void ack_rx_irq() const override {}
62 void wait_for_empty_tx_fifo() const override;
63 unsigned is_rx_fifo_non_empty() const override;
64 unsigned is_tx_fifo_not_full() const override;
65
66 void auto_flow_control(bool on);
67 };
68
69 class Uart_s3c64xx : public Uart_s3c
70 {
71 public:
72 Uart_s3c64xx() : Uart_s3c(Type_64xx) {}
73 explicit Uart_s3c64xx(unsigned base_rate) : Uart_s3c(Type_64xx, base_rate) {}
74
75 protected:
76 void ack_rx_irq() const override;
77 void wait_for_empty_tx_fifo() const override;
78 unsigned is_rx_fifo_non_empty() const override;
79 unsigned is_tx_fifo_not_full() const override;
80 };
81
82 class Uart_s5pv210 : public Uart_s3c
83 {
84 public:
85 Uart_s5pv210() : Uart_s3c(Type_s5pv210) {}
86 explicit Uart_s5pv210(unsigned base_rate) : Uart_s3c(Type_s5pv210, base_rate) {}
87
88 protected:
89 void ack_rx_irq() const override;
90 void wait_for_empty_tx_fifo() const override;
91 unsigned is_rx_fifo_non_empty() const override;
92 unsigned is_tx_fifo_not_full() const override;
93 };
94};
L4 low-level kernel interface.