can: move drivers from cpukit to bsps/shared

Move CAN controllers from cputik to bsps/shared directory. This will
allow to use BSP level interface which may be needed for some
controllers. Generic CAN stack implementation is still kept in the
original directory as this shoudl be independent from the low level
driver interface.

Signed-off-by: Michal Lenc <michallenc@seznam.cz>
This commit is contained in:
Michal Lenc
2026-07-02 18:33:01 -05:00
committed by Kinsey Moore
parent 641f589b37
commit 5ebf57e2af
13 changed files with 8 additions and 6 deletions
+55
View File
@@ -0,0 +1,55 @@
/* SPDX-License-Identifier: BSD-2-Clause OR Apache-2.0 OR GPL-2.0-or-later */
/**
* @file
*
* @ingroup CANVirtual
*
* @brief This file provides definitions for virtual CAN chip.
*
* Implementation is based on original LinCAN - Linux CAN bus driver
* Part of OrtCAN project https://ortcan.sourceforge.net/
*/
/*
* Copyright (C) 2023-2024 Michal Lenc <michallenc@seznam.cz>
* Copyright (C) 2002-2009 DCE FEE CTU Prague
* Copyright (C) 2002-2024 Pavel Pisa <pisa@cmp.felk.cvut.cz>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef __DEV_CAN_CAN_VIRTUAL_H
#define __DEV_CAN_CAN_VIRTUAL_H
#define CAN_VIRTUAL_TYPE "virtual"
struct rtems_can_chip;
/**
* @brief This function initializes the virtual CAN controller
*
* @return Pointer to CAN chip structure on success, NULL otherwise.
*/
struct rtems_can_chip *rtems_can_virtual_initialize( void );
#endif /* __DEV_CAN_CAN_VIRTUAL_H */
+86
View File
@@ -0,0 +1,86 @@
/* SPDX-License-Identifier: BSD-2-Clause OR Apache-2.0 OR GPL-2.0-or-later */
/**
* @file
*
* @ingroup CTUCANFD
*
* @brief This header file contains the implementation of CTU CAN FD
* controller.
*/
/*
* Copyright (C) 2023-2024 Michal Lenc <michallenc@seznam.cz>
* Implementation is based on Linux CTU CAN FD driver
* Copyright (C) 2015-2018 Ondrej Ille <ondrej.ille@gmail.com> FEE CTU
* Copyright (C) 2018-2021 Ondrej Ille <ondrej.ille@gmail.com> self-funded
* Copyright (C) 2018-2019 Martin Jerabek <martin.jerabek01@gmail.com> FEE CTU
* Copyright (C) 2018-2022 Pavel Pisa <pisa@cmp.felk.cvut.cz> FEE CTU/self-funded
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _DEV_CAN_CTUCANFD_H
#define _DEV_CAN_CTUCANFD_H
/**
* @brief This defines the maximum number of TX buffers.
*
* This is the maximum number of HW buffers that can be implemented to any
* CTU CAN FD core. The user can use this as an argument to initialization
* function @ref rtems_can_ctucanfd_initialize and the function automatically
* limits the used buffers based on the used core.
*/
#define RTEMS_CTUCANFD_NTXBUFS_MAX ( 8 )
struct rtems_can_chip;
/**
* @brief This function initializes the CTU CAN FD controller.
*
* This is an entry point for CTU CAN FD controller initialization. This
* function allocates generic CAN and CTU CAN FD related structures, sets
* default values and initializes the resources (interrupt handler, semaphore.
* worker thread).
*
* @param addr CTU CAN FD code base address.
* @param irq Interrupt number
* @param worker_priotiry The priority of TX/RX worker thread
* @param ntxbufs Number of TX hardware buffers to be used.
* The function automatically limits the maximum HW buffers based on the
* used core. You can use @ref RTEMS_CTUCANFD_NTXBUFS_MAX to setup maximum
* available buffers.
* @param irq_option RTEMS_INTERRUPT_SHARED or RTEMS_INTERRUPT_UNIQUE
* @param can_clk_rate CAN clock rate.
*
* @return Pointer to CAN chip structure on success, NULL otherwise.
*/
struct rtems_can_chip *rtems_can_ctucanfd_initialize(
uintptr_t addr,
rtems_vector_number irq,
rtems_task_priority worker_priority,
unsigned int ntxbufs,
rtems_option irq_option,
unsigned long can_clk_rate
);
#endif /* _DEV_CAN_CTUCANFD_H */
+96
View File
@@ -0,0 +1,96 @@
/* SPDX-License-Identifier: BSD-2-Clause OR Apache-2.0 OR GPL-2.0-or-later */
/**
* @file
*
* @ingroup SJA1000
*
* @brief This header file contains the implementation of SJA1000 controller.
*/
/*
* Copyright (C) 2025-2026 Michal Lenc <michallenc@seznam.cz> self-funded
* Copyright (C) 2025-2026 Pavel Pisa <pisa@cmp.felk.cvut.cz> self-funded
* Implementation is based on Linux CTU CAN FD driver
* Copyright (C) 2015-2018 Ondrej Ille <ondrej.ille@gmail.com> FEE CTU
* Copyright (C) 2018-2021 Ondrej Ille <ondrej.ille@gmail.com> self-funded
* Copyright (C) 2018-2019 Martin Jerabek <martin.jerabek01@gmail.com> FEE CTU
* Copyright (C) 2018-2022 Pavel Pisa <pisa@cmp.felk.cvut.cz> FEE CTU/self-funded
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _DEV_CAN_SJA1000_H
#define _DEV_CAN_SJA1000_H
struct rtems_can_chip;
/**
* @brief SJA1000 chip register mapping specification
*/
#define RTEMS_SJA1000_HW_REG_SPAN_MASK ( 3 )
/**
* @brief SJA1000 chip register mapping one byte each
*/
#define RTEMS_SJA1000_HW_REG_SPAN_1 ( 0 )
/**
* @brief SJA1000 chip register mapping with span 2 bytes
*/
#define RTEMS_SJA1000_HW_REG_SPAN_2 ( 1 )
/**
* @brief SJA1000 chip register mapping with span 4 bytes
*/
#define RTEMS_SJA1000_HW_REG_SPAN_4 ( 2 )
/**
* @brief SJA1000 chip register mapping into CPU I/O space
*/
#define RTEMS_SJA1000_HW_REG_IO_PORT ( 0x100 )
/**
* @brief This function initializes the SJA1000 controller.
*
* This is an entry point for SJA1000 controller initialization. This
* function allocates generic CAN and SJA1000 related structures, sets
* default values and initializes the resources (interrupt handler, semaphore.
* worker thread).
*
* @param addr SJA1000 controller base address.
* @param hw_options SJA1000 controller hardware options for register
* mapping.
* @param irq Interrupt number.
* @param worker_priotiry The priority of TX/RX worker thread.
* @param irq_option RTEMS_INTERRUPT_SHARED or RTEMS_INTERRUPT_UNIQUE.
* @param can_clk_rate CAN clock rate.
*
* @return Pointer to CAN chip structure on success, NULL otherwise.
*/
struct rtems_can_chip *rtems_can_sja1000_initialize(
uintptr_t addr,
unsigned int hw_options,
rtems_vector_number irq,
rtems_task_priority worker_priority,
rtems_option irq_option,
unsigned long can_clk_rate
);
#endif /* _DEV_CAN_SJA1000_H */