RTEMS 7.0-rc1
Loading...
Searching...
No Matches
ctucanfd_internal.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-2-Clause OR Apache-2.0 OR GPL-2.0-or-later */
2
11/*
12* Copyright (C) 2023-2024 Michal Lenc <michallenc@seznam.cz>
13* Implementation is based on Linux CTU CAN FD driver
14* Copyright (C) 2015-2018 Ondrej Ille <ondrej.ille@gmail.com> FEE CTU
15* Copyright (C) 2018-2021 Ondrej Ille <ondrej.ille@gmail.com> self-funded
16* Copyright (C) 2018-2019 Martin Jerabek <martin.jerabek01@gmail.com> FEE CTU
17* Copyright (C) 2018-2022 Pavel Pisa <pisa@cmp.felk.cvut.cz> FEE CTU/self-funded
18*
19* Redistribution and use in source and binary forms, with or without
20* modification, are permitted provided that the following conditions
21* are met:
22* 1. Redistributions of source code must retain the above copyright
23* notice, this list of conditions and the following disclaimer.
24* 2. Redistributions in binary form must reproduce the above copyright
25* notice, this list of conditions and the following disclaimer in the
26* documentation and/or other materials provided with the distribution.
27*
28* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
32* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38* POSSIBILITY OF SUCH DAMAGE.
39*/
40
41#ifndef __CTUCANFD_INTERNAL_H
42#define __CTUCANFD_INTERNAL_H
43
44#include <dev/can/can-queue.h>
45#include <dev/can/can-helpers.h>
46
47#include <dev/can/ctucanfd.h>
48
49#include "ctucanfd_kregs.h"
50
72};
73
85 uintptr_t base;
89 uint32_t int_ena;
93 uint32_t int_mask;
104 uint8_t txb_prio_tail[RTEMS_CAN_QUEUE_PRIO_NR];
109 uint32_t txb_order;
113 unsigned int ntxbufs;
114};
115
116static inline void ctucanfd_write32(
117 struct ctucanfd_internal *internal,
118 enum ctu_can_fd_can_registers reg,
119 uint32_t val
120)
121{
122 *( volatile uint32_t * )( internal->base + reg ) = val;
123}
124
125static inline uint32_t ctucanfd_read32(
126 struct ctucanfd_internal *internal,
127 enum ctu_can_fd_can_registers reg
128)
129{
130 return *( volatile uint32_t * )( internal->base + reg );
131}
132
133static inline void ctucanfd_write_txt_buf(
134 struct ctucanfd_internal *internal,
135 enum ctu_can_fd_can_registers buf_base,
136 uint32_t offset,
137 uint32_t val
138)
139{
140 *( volatile uint32_t * )( internal->base + buf_base + offset ) = val;
141}
142
143#define CTU_CAN_FD_ENABLED( internal ) (!!FIELD_GET( \
144 REG_MODE_ENA, \
145 ctucanfd_read32( internal, CTUCANFD_MODE ) \
146) )
147
148#endif /* __CTUCANFD_PRIV_H */
This header file is part of CAN/CAN FD bus common support. It implements functions and defines used t...
This file is part of CAN/CAN FD bus common support and implements CAN FIFOs and generic hubs/ends for...
This header file contains the implementation of CTU CAN FD controller.
#define RTEMS_CTUCANFD_NTXBUFS_MAX
This defines the maximum number of TX buffers.
Definition: ctucanfd.h:53
This represents internal CTU CAN FD structure.
Definition: ctucanfd_internal.h:81
uint32_t int_mask
This member holds the masked out interrupts.
Definition: ctucanfd_internal.h:93
uint32_t txb_order
This member holds the order in which the buffers should be scheduled for transmisison.
Definition: ctucanfd_internal.h:109
uint32_t int_ena
This member holds the enabled interrupts.
Definition: ctucanfd_internal.h:89
struct ctucanfd_txb_info txb_info[RTEMS_CTUCANFD_NTXBUFS_MAX]
This member holds the array of ctucanfd_txb_info structures.
Definition: ctucanfd_internal.h:97
uintptr_t base
Base memory address.
Definition: ctucanfd_internal.h:85
uint8_t txb_prio_tail[RTEMS_CAN_QUEUE_PRIO_NR]
This member holds tails for mapping of priority classes to bufders.
Definition: ctucanfd_internal.h:104
unsigned int ntxbufs
This member holds the number of TX buffers for given core.
Definition: ctucanfd_internal.h:113
This represents one HW transmission buffer.
Definition: ctucanfd_internal.h:54
struct rtems_can_queue_edge * edge
This holds the pointer to the edge from which the slot was acquired.
Definition: ctucanfd_internal.h:71
struct rtems_can_queue_slot * slot
This holds the pointer to the slot the buffer acquired.
Definition: ctucanfd_internal.h:63
This structure represents one direction connection from messages source ( input_ends) to message cons...
Definition: can-queue.h:231
This structure represents one CAN message slot in the CAN FIFO queue.
Definition: can-queue.h:60