diff options
Diffstat (limited to 'bsps/powerpc/qoriq')
33 files changed, 1401 insertions, 380 deletions
diff --git a/bsps/powerpc/qoriq/btimer/btimer.c b/bsps/powerpc/qoriq/btimer/btimer.c index 47ef6eedb9..bb103faf7d 100644 --- a/bsps/powerpc/qoriq/btimer/btimer.c +++ b/bsps/powerpc/qoriq/btimer/btimer.c @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2011 embedded brains GmbH. All rights reserved. + * Copyright (c) 2011 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Obere Lagerstr. 30 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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. */ #include <rtems/btimer.h> diff --git a/bsps/powerpc/qoriq/clock/clock-config.c b/bsps/powerpc/qoriq/clock/clock-config.c index 2966636bc5..17347278f3 100644 --- a/bsps/powerpc/qoriq/clock/clock-config.c +++ b/bsps/powerpc/qoriq/clock/clock-config.c @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2011, 2017 embedded brains GmbH. All rights reserved. + * Copyright (C) 2011, 2017 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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. */ #include <rtems/timecounter.h> @@ -25,11 +38,9 @@ #include <libcpu/powerpc-utility.h> #include <bsp.h> +#include <bsp/fatal.h> #include <bsp/qoriq.h> -#include <bsp/irq.h> - -/* This is defined in dev/clock/clockimpl.h */ -static rtems_isr Clock_isr(void *arg); +#include <bsp/irq-generic.h> static struct timecounter qoriq_clock_tc; @@ -37,6 +48,9 @@ static struct timecounter qoriq_clock_tc; #define CLOCK_DRIVER_USE_ONLY_BOOT_PROCESSOR +/* This is defined in dev/clock/clockimpl.h */ +static rtems_isr Clock_isr(void *arg); + void qoriq_decrementer_dispatch(void) { PPC_SET_SPECIAL_PURPOSE_REGISTER(BOOKE_TSR, BOOKE_TSR_DIS); @@ -86,7 +100,9 @@ static volatile qoriq_pic_global_timer *const qoriq_timecounter = #define CLOCK_INTERRUPT (QORIQ_IRQ_GT_BASE + QORIQ_CLOCK_TIMER) -static void qoriq_clock_handler_install(void) +static rtems_interrupt_entry qoriq_clock_entry; + +static void qoriq_clock_handler_install(rtems_interrupt_handler handler) { rtems_status_code sc = RTEMS_SUCCESSFUL; @@ -105,18 +121,22 @@ static void qoriq_clock_handler_install(void) NULL ); if (sc != RTEMS_SUCCESSFUL) { - rtems_fatal_error_occurred(0xdeadbeef); + bsp_fatal(QORIQ_FATAL_CLOCK_INTERRUPT_SET_PRIORITY); } - sc = rtems_interrupt_handler_install( + rtems_interrupt_entry_initialize( + &qoriq_clock_entry, + handler, + NULL, + "Clock" + ); + sc = rtems_interrupt_entry_install( CLOCK_INTERRUPT, - "Clock", RTEMS_INTERRUPT_UNIQUE, - Clock_isr, - NULL + &qoriq_clock_entry ); if (sc != RTEMS_SUCCESSFUL) { - rtems_fatal_error_occurred(0xdeadbeef); + bsp_fatal(QORIQ_FATAL_CLOCK_INTERRUPT_INSTALL); } } @@ -144,8 +164,8 @@ static void qoriq_clock_initialize(void) rtems_timecounter_install(&qoriq_clock_tc); } -#define Clock_driver_support_install_isr(clock_isr) \ - qoriq_clock_handler_install() +#define Clock_driver_support_install_isr(isr) \ + qoriq_clock_handler_install(isr) #define Clock_driver_support_set_interrupt_affinity(online_processors) \ bsp_interrupt_set_affinity(CLOCK_INTERRUPT, online_processors) diff --git a/bsps/powerpc/qoriq/console/console-config.c b/bsps/powerpc/qoriq/console/console-config.c index c8f0b4119b..901ca968dd 100644 --- a/bsps/powerpc/qoriq/console/console-config.c +++ b/bsps/powerpc/qoriq/console/console-config.c @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2010, 2017 embedded brains GmbH. All rights reserved. + * Copyright (C) 2010, 2017 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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. */ #include <string.h> diff --git a/bsps/powerpc/qoriq/console/uart-bridge-master.c b/bsps/powerpc/qoriq/console/uart-bridge-master.c index 3239bb0b99..c468b05855 100644 --- a/bsps/powerpc/qoriq/console/uart-bridge-master.c +++ b/bsps/powerpc/qoriq/console/uart-bridge-master.c @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2011-2015 embedded brains GmbH. All rights reserved. + * Copyright (C) 2011, 2015 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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. */ #include <sys/stat.h> @@ -28,6 +41,7 @@ #include <bspopts.h> #include <bsp/uart-bridge.h> +#include <rtems/termiostypes.h> #define TRANSMIT_EVENT RTEMS_EVENT_13 diff --git a/bsps/powerpc/qoriq/console/uart-bridge-slave.c b/bsps/powerpc/qoriq/console/uart-bridge-slave.c index ea97bc5e83..778db75171 100644 --- a/bsps/powerpc/qoriq/console/uart-bridge-slave.c +++ b/bsps/powerpc/qoriq/console/uart-bridge-slave.c @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2011 embedded brains GmbH. All rights reserved. + * Copyright (c) 2011 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Obere Lagerstr. 30 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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. */ #include <assert.h> diff --git a/bsps/powerpc/qoriq/include/bsp.h b/bsps/powerpc/qoriq/include/bsp.h index 75bf15cefb..5d8b711098 100644 --- a/bsps/powerpc/qoriq/include/bsp.h +++ b/bsps/powerpc/qoriq/include/bsp.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2010, 2017 embedded brains GmbH. All rights reserved. + * Copyright (C) 2010, 2017 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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 LIBBSP_POWERPC_QORIQ_BSP_H diff --git a/bsps/powerpc/qoriq/include/bsp/VMEConfig.h b/bsps/powerpc/qoriq/include/bsp/VMEConfig.h new file mode 100644 index 0000000000..4bb7c0d62f --- /dev/null +++ b/bsps/powerpc/qoriq/include/bsp/VMEConfig.h @@ -0,0 +1,100 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + +/** + * @file + * + * @ingroup RTEMSBSPsPowerPCQorIQ + * + * @brief This header file provides the interfaces used by VME bus device + * drivers. + * + * Note that for the MVME2500, you need the PCIe support from libbsd for this to + * work. + */ + +/* + * Copyright (C) 2023 embedded brains GmbH & Co. KG + * + * 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 RTEMS_BSP_VME_CONFIG_H +#define RTEMS_BSP_VME_CONFIG_H + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define _VME_DRIVER_TSI148 + +/* + * Base address of the PCI that is used for the VME bridge. Value is set in + * libbsd during device discovery. + */ +extern uintptr_t bsp_vme_pcie_base_address; + +#define PCI_MEM_BASE 0 +#define PCI_DRAM_OFFSET 0 + +/* + * NOTE: shared vmeconfig.c uses hardcoded window lengths that match this layout + * + * The memory length of the PCIe controllers on the P2020 processor is + * 0x20000000. The Tsi148 registers are mapped at the bsp_vme_pcie_base_address + * with a size of 0x1000. Therefore the VME windows are arranged a bit different + * then on other BSPs. + */ +#define _VME_A32_WIN0_ON_PCI (bsp_vme_pcie_base_address + 0x10000000) +#define _VME_A24_ON_PCI (bsp_vme_pcie_base_address + 0x03000000) +#define _VME_A16_ON_PCI (bsp_vme_pcie_base_address + 0x02000000) +#define _VME_CSR_ON_PCI (bsp_vme_pcie_base_address + 0x01000000) + +/* FIXME: Make this a BSP config option */ +#define _VME_A32_WIN0_ON_VME 0x20000000 + +/* + * FIXME: The fixed QORIQ_IRQ_EXT_0 is valid for the MVME2500 board. In theory + * there should be some possibility to get that information from the device tree + * or from PCI config space. But I didn't find it anywhere. + */ +#define BSP_VME_INSTALL_IRQ_MGR(err) \ + do { \ + err = qoriq_pic_set_sense_and_polarity(\ + QORIQ_IRQ_EXT_0, \ + QORIQ_EIRQ_TRIGGER_LEVEL_LOW, \ + NULL \ + ); \ + if (err == 0) { \ + err = vmeTsi148InstallIrqMgrAlt(0, 0, QORIQ_IRQ_EXT_0, -1); \ + } \ + } while (0) + +/* Add prototypes that are in all VMEConfig.h files */ +extern int BSP_VMEInit(void); +extern int BSP_VMEIrqMgrInstall(void); +extern unsigned short (*_BSP_clear_vmebridge_errors)(int); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* RTEMS_BSP_VME_CONFIG_H */ diff --git a/bsps/powerpc/qoriq/include/bsp/intercom.h b/bsps/powerpc/qoriq/include/bsp/intercom.h index c78d4c2ab0..1217fb5a69 100644 --- a/bsps/powerpc/qoriq/include/bsp/intercom.h +++ b/bsps/powerpc/qoriq/include/bsp/intercom.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2011 embedded brains GmbH. All rights reserved. + * Copyright (c) 2011 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Obere Lagerstr. 30 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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 LIBBSP_POWERPC_QORIQ_INTERCOM_H diff --git a/bsps/powerpc/qoriq/include/bsp/irq.h b/bsps/powerpc/qoriq/include/bsp/irq.h index cd642fa00b..5eaf36ba4c 100644 --- a/bsps/powerpc/qoriq/include/bsp/irq.h +++ b/bsps/powerpc/qoriq/include/bsp/irq.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,26 +9,34 @@ */ /* - * Copyright (c) 2010-2015 embedded brains GmbH. All rights reserved. + * Copyright (C) 2010, 2015 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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 LIBBSP_POWERPC_QORIQ_IRQ_H #define LIBBSP_POWERPC_QORIQ_IRQ_H #include <bsp.h> -#include <rtems/irq.h> -#include <rtems/irq-extension.h> -#include <rtems/score/processormask.h> #ifdef __cplusplus extern "C" { @@ -266,6 +276,8 @@ extern "C" { #define QORIQ_IRQ_EXT_10 (QORIQ_IRQ_EXT_BASE + 10) #define QORIQ_IRQ_EXT_11 (QORIQ_IRQ_EXT_BASE + 11) +#define QORIQ_IRQ_IS_EXT(vector) \ + ((vector) >= QORIQ_IRQ_EXT_0 && (vector) <= QORIQ_IRQ_EXT_11) /** @} */ /** @@ -350,7 +362,23 @@ extern "C" { #define QORIQ_IRQ_GT_B_2 (QORIQ_IRQ_GT_BASE + 6) #define QORIQ_IRQ_GT_B_3 (QORIQ_IRQ_GT_BASE + 7) -#define BSP_INTERRUPT_VECTOR_COUNT (QORIQ_IRQ_GT_B_3 + 1) +#define QORIQ_INTERRUPT_SOURCE_COUNT (QORIQ_IRQ_GT_B_3 + 1) + +#define QORIQ_IS_INTERRUPT_SOURCE(vector) \ + (((rtems_vector_number) (vector)) < QORIQ_INTERRUPT_SOURCE_COUNT) + +#define QORIQ_IRQ_MSI_MULTIPLEX_BASE QORIQ_INTERRUPT_SOURCE_COUNT + +#define QORIQ_IRQ_MSI_COUNT 256 + +#define QORIQ_IRQ_MSI_INDEX(vector) ((vector) - QORIQ_IRQ_MSI_MULTIPLEX_BASE) + +#define QORIQ_IRQ_MSI_VECTOR(index) (QORIQ_IRQ_MSI_MULTIPLEX_BASE + (index)) + +#define QORIQ_IRQ_IS_MSI(vector) \ + (QORIQ_IRQ_MSI_INDEX(vector) < QORIQ_IRQ_MSI_COUNT) + +#define BSP_INTERRUPT_VECTOR_COUNT QORIQ_IRQ_MSI_VECTOR(QORIQ_IRQ_MSI_COUNT) /** @} */ @@ -380,14 +408,39 @@ rtems_status_code qoriq_pic_set_priority( int *old_priority ); -rtems_status_code bsp_interrupt_set_affinity( +rtems_status_code qoriq_pic_msi_allocate(rtems_vector_number *vector); + +rtems_status_code qoriq_pic_msi_free(rtems_vector_number vector); + +rtems_status_code qoriq_pic_msi_map( rtems_vector_number vector, - const Processor_mask *affinity + uint64_t *addr, + uint32_t *data ); -rtems_status_code bsp_interrupt_get_affinity( +typedef enum { + QORIQ_EIRQ_TRIGGER_EDGE_FALLING, + QORIQ_EIRQ_TRIGGER_EDGE_RISING, + QORIQ_EIRQ_TRIGGER_LEVEL_LOW, + QORIQ_EIRQ_TRIGGER_LEVEL_HIGH, +} qoriq_eirq_sense_and_polarity; + +/** + * @brief Change polarity and sense settings of external interrupts. + * + * NOTE: There are only very rare edge cases where you need this function. + * + * @a vector must be the vector number of an external interrupt. + * + * Use @a new_sense_and_polarity to select the new setting. If @a + * old_sense_and_polarity is not NULL, the old value is returned. + * + * @returns RTEMS_SUCCSSSFUL on sucess or other values for invalid settings. + */ +rtems_status_code qoriq_pic_set_sense_and_polarity( rtems_vector_number vector, - Processor_mask *affinity + qoriq_eirq_sense_and_polarity new_sense_and_polarity, + qoriq_eirq_sense_and_polarity *old_sense_and_polarity ); /** @} */ diff --git a/bsps/powerpc/qoriq/include/bsp/mmu.h b/bsps/powerpc/qoriq/include/bsp/mmu.h index 8c8822f901..2c51c9930a 100644 --- a/bsps/powerpc/qoriq/include/bsp/mmu.h +++ b/bsps/powerpc/qoriq/include/bsp/mmu.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2011-2015 embedded brains GmbH. All rights reserved. + * Copyright (C) 2011, 2015 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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 LIBBSP_POWERPC_QORIQ_MMU_H @@ -78,6 +91,8 @@ void qoriq_mmu_write_to_tlb1(qoriq_mmu_context *self, int first_tlb); void qoriq_mmu_change_perm(uint32_t test, uint32_t set, uint32_t clear); +int qoriq_mmu_find_free_tlb1_entry(void); + void qoriq_mmu_config(bool boot_processor, int first_tlb, int scratch_tlb); void qoriq_tlb1_write( @@ -90,6 +105,16 @@ void qoriq_tlb1_write( int tsize ); +void qoriq_mmu_adjust_and_write_to_tlb1( + int tlb, + uintptr_t begin, + uintptr_t last, + uint32_t mas1, + uint32_t mas2, + uint32_t mas3, + uint32_t mas7 +); + void qoriq_tlb1_invalidate(int esel); /** @} */ diff --git a/bsps/powerpc/qoriq/include/bsp/qoriq.h b/bsps/powerpc/qoriq/include/bsp/qoriq.h index 361dbed2f1..2cefd2e63e 100644 --- a/bsps/powerpc/qoriq/include/bsp/qoriq.h +++ b/bsps/powerpc/qoriq/include/bsp/qoriq.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2010-2015 embedded brains GmbH. All rights reserved. + * Copyright (C) 2010, 2015 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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 LIBBSP_POWERPC_QORIQ_QORIQ_H diff --git a/bsps/powerpc/qoriq/include/bsp/tsec-config.h b/bsps/powerpc/qoriq/include/bsp/tsec-config.h index 24f7e7611b..8827e159ef 100644 --- a/bsps/powerpc/qoriq/include/bsp/tsec-config.h +++ b/bsps/powerpc/qoriq/include/bsp/tsec-config.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2010 embedded brains GmbH. All rights reserved. + * Copyright (c) 2010 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Obere Lagerstr. 30 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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 LIBBSP_POWERPC_QORIQ_TSEC_CONFIG_H diff --git a/bsps/powerpc/qoriq/include/bsp/uart-bridge.h b/bsps/powerpc/qoriq/include/bsp/uart-bridge.h index 3233cf5bef..3b243fd245 100644 --- a/bsps/powerpc/qoriq/include/bsp/uart-bridge.h +++ b/bsps/powerpc/qoriq/include/bsp/uart-bridge.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,23 +9,34 @@ */ /* - * Copyright (c) 2011-2015 embedded brains GmbH. All rights reserved. + * Copyright (C) 2011, 2015 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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 LIBBSP_POWERPC_QORIQ_UART_BRIDGE_H #define LIBBSP_POWERPC_QORIQ_UART_BRIDGE_H -#include <rtems/termiostypes.h> +#include <rtems/termiosdevice.h> #include <bsp/intercom.h> diff --git a/bsps/powerpc/qoriq/include/tm27.h b/bsps/powerpc/qoriq/include/tm27.h index 5753d6b049..0c43823f0e 100644 --- a/bsps/powerpc/qoriq/include/tm27.h +++ b/bsps/powerpc/qoriq/include/tm27.h @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2010-2015 embedded brains GmbH. All rights reserved. + * Copyright (C) 2010, 2015 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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 _RTEMS_TMTEST27 @@ -27,8 +40,6 @@ #ifndef TMTESTS_TM27_H #define TMTESTS_TM27_H -#include <assert.h> - #include <libcpu/powerpc-utility.h> #include <bsp/irq.h> @@ -40,55 +51,60 @@ #define IPI_INDEX_HIGH 2 -RTEMS_INLINE_ROUTINE void Install_tm27_vector(void (*handler)(rtems_vector_number)) +static inline void Install_tm27_vector( rtems_interrupt_handler handler ) { - rtems_status_code sc; + static rtems_interrupt_entry entry_low; + static rtems_interrupt_entry entry_high; rtems_vector_number low = QORIQ_IRQ_IPI_0 + IPI_INDEX_LOW; rtems_vector_number high = QORIQ_IRQ_IPI_0 + IPI_INDEX_HIGH; - sc = rtems_interrupt_handler_install( + rtems_interrupt_entry_initialize( + &entry_low, + handler, + NULL, + "tm17 low" + ); + (void) rtems_interrupt_entry_install( low, - "tm17 low", RTEMS_INTERRUPT_UNIQUE, - (rtems_interrupt_handler) handler, - NULL + &entry_low ); - assert(sc == RTEMS_SUCCESSFUL); - sc = qoriq_pic_set_priority(low, 1, NULL); - assert(sc == RTEMS_SUCCESSFUL); + (void) qoriq_pic_set_priority(low, 1, NULL); - sc = rtems_interrupt_handler_install( + rtems_interrupt_entry_initialize( + &entry_high, + handler, + NULL, + "tm17 high" + ); + (void) rtems_interrupt_entry_install( high, - "tm17 high", RTEMS_INTERRUPT_UNIQUE, - (rtems_interrupt_handler) handler, - NULL + &entry_high ); - assert(sc == RTEMS_SUCCESSFUL); - sc = qoriq_pic_set_priority(high, 2, NULL); - assert(sc == RTEMS_SUCCESSFUL); + (void) qoriq_pic_set_priority(high, 2, NULL); } -RTEMS_INLINE_ROUTINE void qoriq_tm27_cause(uint32_t ipi_index) +static inline void qoriq_tm27_cause(uint32_t ipi_index) { uint32_t self = ppc_processor_id(); qoriq.pic.per_cpu[self].ipidr[ipi_index].reg = UINT32_C(1) << self; } -RTEMS_INLINE_ROUTINE void Cause_tm27_intr(void) +static inline void Cause_tm27_intr(void) { qoriq_tm27_cause(IPI_INDEX_LOW); } -RTEMS_INLINE_ROUTINE void Clear_tm27_intr(void) +static inline void Clear_tm27_intr(void) { /* Nothing to do */ } -RTEMS_INLINE_ROUTINE inline void Lower_tm27_intr(void) +static inline inline void Lower_tm27_intr(void) { qoriq_tm27_cause(IPI_INDEX_HIGH); } diff --git a/bsps/powerpc/qoriq/irq/irq.c b/bsps/powerpc/qoriq/irq/irq.c index 01e24998ba..96fbe4e020 100644 --- a/bsps/powerpc/qoriq/irq/irq.c +++ b/bsps/powerpc/qoriq/irq/irq.c @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,20 +9,32 @@ */ /* - * Copyright (c) 2010, 2017 embedded brains GmbH. All rights reserved. + * Copyright (C) 2010, 2017 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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. */ #include <sys/param.h> +#include <sys/bitset.h> #include <rtems.h> @@ -29,11 +43,11 @@ #include <asm/epapr_hcalls.h> #include <bsp.h> -#include <bsp/irq.h> #include <bsp/irq-generic.h> #include <bsp/vectors.h> #include <bsp/utility.h> #include <bsp/qoriq.h> +#include <rtems/score/processormaskimpl.h> #ifdef RTEMS_SMP #include <rtems/score/smpimpl.h> @@ -166,7 +180,7 @@ void bsp_interrupt_dispatch(uintptr_t exception_number) * This works only if the "has-external-proxy" property is present in the * "epapr,hv-pic" device tree node. */ - vector = PPC_SPECIAL_PURPOSE_REGISTER(FSL_EIS_EPR); + PPC_SPECIAL_PURPOSE_REGISTER(FSL_EIS_EPR, vector); if (vector != SPURIOUS) { uint32_t msr; @@ -280,6 +294,11 @@ static volatile qoriq_pic_src_cfg *get_src_cfg(rtems_vector_number vector) } } +static bool pic_is_ipi(rtems_vector_number vector) +{ + return (vector - QORIQ_IRQ_IPI_BASE) < 4; +} + rtems_status_code qoriq_pic_set_priority( rtems_vector_number vector, int new_priority, @@ -289,6 +308,10 @@ rtems_status_code qoriq_pic_set_priority( rtems_status_code sc = RTEMS_SUCCESSFUL; uint32_t old_vpr = 0; + if (QORIQ_IRQ_IS_MSI(vector)) { + return RTEMS_UNSATISFIED; + } + if (bsp_interrupt_is_valid_vector(vector)) { volatile qoriq_pic_src_cfg *src_cfg = get_src_cfg(vector); @@ -315,13 +338,78 @@ rtems_status_code qoriq_pic_set_priority( return sc; } +rtems_status_code qoriq_pic_set_sense_and_polarity( + rtems_vector_number vector, + qoriq_eirq_sense_and_polarity new_sense_and_polarity, + qoriq_eirq_sense_and_polarity *old_sense_and_polarity +) +{ + rtems_status_code sc = RTEMS_SUCCESSFUL; + uint32_t old_vpr = 0; + volatile qoriq_pic_src_cfg *src_cfg; + rtems_interrupt_lock_context lock_context; + uint32_t new_p_s = 0; + + if (!QORIQ_IRQ_IS_EXT(vector)) { + return RTEMS_UNSATISFIED; + } + + if (new_sense_and_polarity == QORIQ_EIRQ_TRIGGER_EDGE_RISING || + new_sense_and_polarity == QORIQ_EIRQ_TRIGGER_LEVEL_HIGH) { + new_p_s |= VPR_P; + } + + if (new_sense_and_polarity == QORIQ_EIRQ_TRIGGER_LEVEL_HIGH || + new_sense_and_polarity == QORIQ_EIRQ_TRIGGER_LEVEL_LOW) { + new_p_s |= VPR_S; + } + + src_cfg = get_src_cfg(vector); + + rtems_interrupt_lock_acquire(&lock, &lock_context); + old_vpr = src_cfg->vpr; + src_cfg->vpr = (old_vpr & ~(VPR_P | VPR_S)) | new_p_s; + rtems_interrupt_lock_release(&lock, &lock_context); + + if (old_sense_and_polarity != NULL) { + if ((old_vpr & VPR_P) == 0) { + if ((old_vpr & VPR_S) == 0) { + *old_sense_and_polarity = + QORIQ_EIRQ_TRIGGER_EDGE_FALLING; + } else { + *old_sense_and_polarity = + QORIQ_EIRQ_TRIGGER_LEVEL_LOW; + } + } else { + if ((old_vpr & VPR_S) == 0) { + *old_sense_and_polarity = + QORIQ_EIRQ_TRIGGER_EDGE_RISING; + } else { + *old_sense_and_polarity = + QORIQ_EIRQ_TRIGGER_LEVEL_HIGH; + } + } + } + + return sc; +} + rtems_status_code bsp_interrupt_set_affinity( rtems_vector_number vector, const Processor_mask *affinity ) { - volatile qoriq_pic_src_cfg *src_cfg = get_src_cfg(vector); + volatile qoriq_pic_src_cfg *src_cfg; + + if (pic_is_ipi(vector)) { + return RTEMS_UNSATISFIED; + } + + if (QORIQ_IRQ_IS_MSI(vector)) { + return RTEMS_UNSATISFIED; + } + src_cfg = get_src_cfg(vector); src_cfg->dr = _Processor_mask_To_uint32_t(affinity, 0); return RTEMS_SUCCESSFUL; } @@ -331,57 +419,121 @@ rtems_status_code bsp_interrupt_get_affinity( Processor_mask *affinity ) { - volatile qoriq_pic_src_cfg *src_cfg = get_src_cfg(vector); + volatile qoriq_pic_src_cfg *src_cfg; + if (pic_is_ipi(vector)) { + return RTEMS_UNSATISFIED; + } + + if (QORIQ_IRQ_IS_MSI(vector)) { + return RTEMS_UNSATISFIED; + } + + src_cfg = get_src_cfg(vector); _Processor_mask_From_uint32_t(affinity, src_cfg->dr, 0); return RTEMS_SUCCESSFUL; } -static void pic_vector_enable(rtems_vector_number vector, uint32_t msk) +static rtems_status_code pic_vector_set_mask( + rtems_vector_number vector, + uint32_t msk +) { - volatile qoriq_pic_src_cfg *src_cfg = get_src_cfg(vector); + volatile qoriq_pic_src_cfg *src_cfg; rtems_interrupt_lock_context lock_context; bsp_interrupt_assert(bsp_interrupt_is_valid_vector(vector)); + if (QORIQ_IRQ_IS_MSI(vector)) { + return RTEMS_UNSATISFIED; + } + + src_cfg = get_src_cfg(vector); rtems_interrupt_lock_acquire(&lock, &lock_context); src_cfg->vpr = (src_cfg->vpr & ~VPR_MSK) | msk; rtems_interrupt_lock_release(&lock, &lock_context); + return RTEMS_SUCCESSFUL; } rtems_status_code bsp_interrupt_get_attributes( - rtems_vector_number vector, - rtems_interrupt_attributes *attributes + rtems_vector_number vector, + rtems_interrupt_attributes *attributes ) { - return RTEMS_SUCCESSFUL; + bool is_ipi = pic_is_ipi(vector); + bool is_msi = QORIQ_IRQ_IS_MSI(vector); + + attributes->is_maskable = true; + attributes->can_enable = !is_msi; + attributes->maybe_enable = !is_msi; + attributes->can_disable = !is_msi; + attributes->maybe_disable = !is_msi; + attributes->cleared_by_acknowledge = true; + attributes->can_get_affinity = !(is_ipi || is_msi); + attributes->can_set_affinity = !(is_ipi || is_msi); + attributes->can_raise = is_ipi; + attributes->can_raise_on = is_ipi; + + if (is_msi) { + attributes->can_be_triggered_by_message = true; + attributes->trigger_signal = RTEMS_INTERRUPT_NO_SIGNAL; + } + + return RTEMS_SUCCESSFUL; } rtems_status_code bsp_interrupt_is_pending( - rtems_vector_number vector, - bool *pending + rtems_vector_number vector, + bool *pending ) { - bsp_interrupt_assert(bsp_interrupt_is_valid_vector(vector)); - bsp_interrupt_assert(pending != NULL); - *pending = false; - return RTEMS_UNSATISFIED; + volatile qoriq_pic_src_cfg *src_cfg; + + bsp_interrupt_assert(bsp_interrupt_is_valid_vector(vector)); + bsp_interrupt_assert(pending != NULL); + + if (QORIQ_IRQ_IS_MSI(vector)) { + *pending = false; + return RTEMS_SUCCESSFUL; + } + + src_cfg = get_src_cfg(vector); + *pending = (src_cfg->vpr & VPR_A) != 0; + return RTEMS_SUCCESSFUL; +} + +static void raise_on(rtems_vector_number vector, uint32_t cpu_index) +{ + rtems_vector_number ipi_index = vector - QORIQ_IRQ_IPI_BASE; + qoriq.pic.ipidr[ipi_index].reg = 1U << cpu_index; } rtems_status_code bsp_interrupt_raise(rtems_vector_number vector) { - bsp_interrupt_assert(bsp_interrupt_is_valid_vector(vector)); - return RTEMS_UNSATISFIED; + bsp_interrupt_assert(bsp_interrupt_is_valid_vector(vector)); + + if (pic_is_ipi(vector)) { + raise_on(vector, rtems_scheduler_get_processor()); + return RTEMS_SUCCESSFUL; + } + + return RTEMS_UNSATISFIED; } #if defined(RTEMS_SMP) rtems_status_code bsp_interrupt_raise_on( - rtems_vector_number vector, - uint32_t cpu_index + rtems_vector_number vector, + uint32_t cpu_index ) { - bsp_interrupt_assert(bsp_interrupt_is_valid_vector(vector)); - return RTEMS_UNSATISFIED; + bsp_interrupt_assert(bsp_interrupt_is_valid_vector(vector)); + + if (pic_is_ipi(vector)) { + raise_on(vector, cpu_index); + return RTEMS_SUCCESSFUL; + } + + return RTEMS_UNSATISFIED; } #endif @@ -392,26 +544,32 @@ rtems_status_code bsp_interrupt_clear(rtems_vector_number vector) } rtems_status_code bsp_interrupt_vector_is_enabled( - rtems_vector_number vector, - bool *enabled + rtems_vector_number vector, + bool *enabled ) { - bsp_interrupt_assert(bsp_interrupt_is_valid_vector(vector)); - bsp_interrupt_assert(enabled != NULL); - *enabled = false; - return RTEMS_UNSATISFIED; + volatile qoriq_pic_src_cfg *src_cfg; + + bsp_interrupt_assert(bsp_interrupt_is_valid_vector(vector)); + bsp_interrupt_assert(enabled != NULL); + + if (QORIQ_IRQ_IS_MSI(vector)) { + vector = QORIQ_IRQ_MSI_0 + QORIQ_IRQ_MSI_INDEX(vector) / 32; + } + + src_cfg = get_src_cfg(vector); + *enabled = (src_cfg->vpr & VPR_MSK) == 0; + return RTEMS_SUCCESSFUL; } rtems_status_code bsp_interrupt_vector_enable(rtems_vector_number vector) { - pic_vector_enable(vector, 0); - return RTEMS_SUCCESSFUL; + return pic_vector_set_mask(vector, 0); } rtems_status_code bsp_interrupt_vector_disable(rtems_vector_number vector) { - pic_vector_enable(vector, VPR_MSK); - return RTEMS_SUCCESSFUL; + return pic_vector_set_mask(vector, VPR_MSK); } void bsp_interrupt_dispatch(uintptr_t exception_number) @@ -432,11 +590,6 @@ void bsp_interrupt_dispatch(uintptr_t exception_number) } } -static bool pic_is_ipi(rtems_vector_number vector) -{ - return QORIQ_IRQ_IPI_0 <= vector && vector <= QORIQ_IRQ_IPI_3; -} - static void pic_reset(void) { qoriq.pic.gcr = GCR_RST; @@ -468,7 +621,7 @@ void bsp_interrupt_facility_initialize(void) pic_reset(); - for (i = 0; i < BSP_INTERRUPT_VECTOR_COUNT; ++i) { + for (i = 0; i < QORIQ_INTERRUPT_SOURCE_COUNT; ++i) { volatile qoriq_pic_src_cfg *src_cfg = get_src_cfg(i); src_cfg->vpr = VPR_MSK | VPR_P @@ -484,16 +637,186 @@ void bsp_interrupt_facility_initialize(void) qoriq.pic.svr = SPURIOUS; qoriq.pic.gcr = GCR_M; + /* Clear shared message signaled interrupts */ + for (i = 0; i < RTEMS_ARRAY_SIZE(qoriq.pic.msir); ++i) { + (void) qoriq.pic.msir[i].reg; + } + pic_global_timer_init(); } qoriq.pic.ctpr = 0; - for (i = 0; i < BSP_INTERRUPT_VECTOR_COUNT; ++i) { + for (i = 0; i < QORIQ_INTERRUPT_SOURCE_COUNT; ++i) { qoriq.pic.iack; qoriq.pic.eoi = 0; qoriq.pic.whoami; } } +typedef __BITSET_DEFINE(pic_msi_bitset, QORIQ_IRQ_MSI_COUNT) pic_msi_bitset; + +static pic_msi_bitset pic_msi_available = + __BITSET_T_INITIALIZER(__BITSET_FSET(__bitset_words(QORIQ_IRQ_MSI_COUNT))); + + +static uint32_t pic_msi_bitset_to_uint32_t( + const pic_msi_bitset *bitset, + uint32_t index +) +{ + long bits = bitset->__bits[index / _BITSET_BITS]; + + return (uint32_t) (bits >> (32 * ((index % _BITSET_BITS) / 32))); +} + +static void pic_msi_dispatch(void *arg) +{ + uintptr_t reg = (uintptr_t) arg; + uint32_t msir = qoriq.pic.msir[reg].reg; + + while (msir != 0) { + uint32_t index = 31 - __builtin_clz(msir); + const rtems_interrupt_entry *entry; + + msir &= ~(UINT32_C(1) << index); + entry = bsp_interrupt_entry_load_first( + QORIQ_IRQ_MSI_VECTOR(32 * reg + index) + ); + + if (entry != NULL) { + bsp_interrupt_dispatch_entries(entry); + } + } +} + +static rtems_status_code pic_msi_allocate(rtems_vector_number *vector) +{ + pic_msi_bitset *available = &pic_msi_available; + long found = __BIT_FFS(QORIQ_IRQ_MSI_COUNT, available); + rtems_vector_number index; + uint32_t subset; + + if (found == 0) { + return RTEMS_UNSATISFIED; + } + + index = (rtems_vector_number) found - 1; + subset = pic_msi_bitset_to_uint32_t(available, index); + + if (subset == 0xffffffff) { + uintptr_t reg = index / 32; + rtems_status_code sc; + + sc = rtems_interrupt_handler_install( + QORIQ_IRQ_MSI_0 + reg, + "MSI", + RTEMS_INTERRUPT_UNIQUE, + pic_msi_dispatch, + (void *) reg + ); + + if (sc != RTEMS_SUCCESSFUL) { + return sc; + } + } + + __BIT_CLR(QORIQ_IRQ_MSI_COUNT, index, available); + *vector = QORIQ_IRQ_MSI_VECTOR(index); + return RTEMS_SUCCESSFUL; +} + +static rtems_status_code pic_msi_free(rtems_vector_number vector) +{ + pic_msi_bitset *available = &pic_msi_available; + rtems_vector_number index = QORIQ_IRQ_MSI_INDEX(vector); + uint32_t subset; + + if (__BIT_ISSET(QORIQ_IRQ_MSI_COUNT, index, available)) { + return RTEMS_NOT_DEFINED; + } + + __BIT_SET(QORIQ_IRQ_MSI_COUNT, index, available); + subset = pic_msi_bitset_to_uint32_t(available, index); + + if (subset == 0xffffffff) { + uintptr_t reg = index / 32; + + return rtems_interrupt_handler_remove( + QORIQ_IRQ_MSI_0 + reg, + pic_msi_dispatch, + (void *) reg + ); + } + + return RTEMS_SUCCESSFUL; +} + +rtems_status_code qoriq_pic_msi_allocate(rtems_vector_number *vector) +{ + rtems_status_code sc; + + if (!bsp_interrupt_is_initialized()) { + return RTEMS_INCORRECT_STATE; + } + + if (vector == NULL) { + return RTEMS_INVALID_ADDRESS; + } + + if (rtems_interrupt_is_in_progress()) { + return RTEMS_CALLED_FROM_ISR; + } + + bsp_interrupt_lock(); + sc = pic_msi_allocate(vector); + bsp_interrupt_unlock(); + return sc; +} + +rtems_status_code qoriq_pic_msi_free(rtems_vector_number vector) +{ + rtems_status_code sc; + + if (!bsp_interrupt_is_initialized()) { + return RTEMS_INCORRECT_STATE; + } + + if (!QORIQ_IRQ_IS_MSI(vector) ) { + return RTEMS_INVALID_ID; + } + + if (rtems_interrupt_is_in_progress()) { + return RTEMS_CALLED_FROM_ISR; + } + + bsp_interrupt_lock(); + sc = pic_msi_free(vector); + bsp_interrupt_unlock(); + return sc; +} + +rtems_status_code qoriq_pic_msi_map( + rtems_vector_number vector, + uint64_t *addr, + uint32_t *data +) +{ + if (addr == NULL) { + return RTEMS_INVALID_ADDRESS; + } + + if (data == NULL) { + return RTEMS_INVALID_ADDRESS; + } + + if (!QORIQ_IRQ_IS_MSI(vector) ) { + return RTEMS_INVALID_ID; + } + + *addr = (uint64_t)(uintptr_t) &qoriq.pic.msiir; + *data = QORIQ_IRQ_MSI_INDEX(vector) << 24; + return RTEMS_SUCCESSFUL; +} + #endif /* QORIQ_IS_HYPERVISOR_GUEST */ diff --git a/bsps/powerpc/qoriq/mpci/intercom-mpci.c b/bsps/powerpc/qoriq/mpci/intercom-mpci.c index f0b48e589d..eb1a93e57f 100644 --- a/bsps/powerpc/qoriq/mpci/intercom-mpci.c +++ b/bsps/powerpc/qoriq/mpci/intercom-mpci.c @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2011 embedded brains GmbH. All rights reserved. + * Copyright (c) 2011 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Obere Lagerstr. 30 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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. */ #include <assert.h> diff --git a/bsps/powerpc/qoriq/mpci/intercom.c b/bsps/powerpc/qoriq/mpci/intercom.c index 7f31d38c71..ae3c2d92e9 100644 --- a/bsps/powerpc/qoriq/mpci/intercom.c +++ b/bsps/powerpc/qoriq/mpci/intercom.c @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2011 embedded brains GmbH. All rights reserved. + * Copyright (c) 2011 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Obere Lagerstr. 30 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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. */ #include <assert.h> diff --git a/bsps/powerpc/qoriq/mpci/lock.S b/bsps/powerpc/qoriq/mpci/lock.S index 4b33b4baf1..03469ecaf5 100644 --- a/bsps/powerpc/qoriq/mpci/lock.S +++ b/bsps/powerpc/qoriq/mpci/lock.S @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2011 embedded brains GmbH. All rights reserved. + * Copyright (c) 2011 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Obere Lagerstr. 30 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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. */ #include <libcpu/powerpc-utility.h> diff --git a/bsps/powerpc/qoriq/rtc/rtc-config.c b/bsps/powerpc/qoriq/rtc/rtc-config.c index 3d47a04a44..9d91c3b7ba 100644 --- a/bsps/powerpc/qoriq/rtc/rtc-config.c +++ b/bsps/powerpc/qoriq/rtc/rtc-config.c @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2010 embedded brains GmbH. All rights reserved. + * Copyright (c) 2010 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Obere Lagerstr. 30 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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. */ #include <libchip/rtc.h> diff --git a/bsps/powerpc/qoriq/start/bsp_specs b/bsps/powerpc/qoriq/start/bsp_specs deleted file mode 100644 index e69de29bb2..0000000000 --- a/bsps/powerpc/qoriq/start/bsp_specs +++ /dev/null diff --git a/bsps/powerpc/qoriq/start/bspreset.c b/bsps/powerpc/qoriq/start/bspreset.c index 26d7614719..18ba66d9e9 100644 --- a/bsps/powerpc/qoriq/start/bspreset.c +++ b/bsps/powerpc/qoriq/start/bspreset.c @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2010, 2017 embedded brains GmbH. All rights reserved. + * Copyright (C) 2010, 2017 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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. */ #include <bsp/bootcard.h> diff --git a/bsps/powerpc/qoriq/start/bsprestart.c b/bsps/powerpc/qoriq/start/bsprestart.c index 3dc9d6ffce..eefa34d6d9 100644 --- a/bsps/powerpc/qoriq/start/bsprestart.c +++ b/bsps/powerpc/qoriq/start/bsprestart.c @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2016, 2018 embedded brains GmbH. All rights reserved. + * Copyright (C) 2016, 2018 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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. */ #include <bsp.h> @@ -104,6 +117,8 @@ static void raise_restart_interrupt(void) ppc_synchronize_instructions(); } +static rtems_interrupt_entry restart_entry; + void bsp_restart(void *addr) { rtems_status_code sc; @@ -117,12 +132,16 @@ void bsp_restart(void *addr) rtems_cache_flush_multiple_data_lines(spin_table, sizeof(*spin_table)); } - sc = rtems_interrupt_handler_install( + rtems_interrupt_entry_initialize( + &restart_entry, + restart_interrupt, + addr, + "Restart" + ); + sc = rtems_interrupt_entry_install( QORIQ_IRQ_IPI_0 + RESTART_IPI_INDEX, - "Restart", RTEMS_INTERRUPT_UNIQUE, - restart_interrupt, - addr + &restart_entry ); if (sc != RTEMS_SUCCESSFUL) { bsp_fatal(QORIQ_FATAL_RESTART_INSTALL_INTERRUPT); diff --git a/bsps/powerpc/qoriq/start/bspsmp.c b/bsps/powerpc/qoriq/start/bspsmp.c index f9da7ddce1..2b85ba7a88 100644 --- a/bsps/powerpc/qoriq/start/bspsmp.c +++ b/bsps/powerpc/qoriq/start/bspsmp.c @@ -1,15 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* - * Copyright (c) 2013, 2017 embedded brains GmbH. All rights reserved. + * Copyright (C) 2013, 2017 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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. */ #include <rtems/score/smpimpl.h> @@ -105,11 +118,8 @@ static void bsp_inter_processor_interrupt(void *arg) static void setup_boot_page(void) { #ifdef QORIQ_IS_HYPERVISOR_GUEST - qoriq_mmu_context mmu_context; - - qoriq_mmu_context_init(&mmu_context); - qoriq_mmu_add( - &mmu_context, + qoriq_mmu_adjust_and_write_to_tlb1( + QORIQ_TLB1_ENTRY_COUNT - 1, 0xfffff000, 0xffffffff, 0, @@ -117,8 +127,6 @@ static void setup_boot_page(void) FSL_EIS_MAS3_SR | FSL_EIS_MAS3_SW, 0 ); - qoriq_mmu_partition(&mmu_context, 1); - qoriq_mmu_write_to_tlb1(&mmu_context, QORIQ_TLB1_ENTRY_COUNT - 1); #endif } @@ -208,17 +216,23 @@ bool _CPU_SMP_Start_processor(uint32_t cpu_index) #endif } +static rtems_interrupt_entry qoriq_ipi_entry; + void _CPU_SMP_Finalize_initialization(uint32_t cpu_count) { #ifndef QORIQ_IS_HYPERVISOR_GUEST rtems_status_code sc; - sc = rtems_interrupt_handler_install( + rtems_interrupt_entry_initialize( + &qoriq_ipi_entry, + bsp_inter_processor_interrupt, + NULL, + "IPI" + ); + sc = rtems_interrupt_entry_install( QORIQ_IRQ_IPI_0 + IPI_INDEX, - "IPI", RTEMS_INTERRUPT_UNIQUE, - bsp_inter_processor_interrupt, - NULL + &qoriq_ipi_entry ); if (sc != RTEMS_SUCCESSFUL) { bsp_fatal(QORIQ_FATAL_SMP_IPI_HANDLER_INSTALL); diff --git a/bsps/powerpc/qoriq/start/bspstart.c b/bsps/powerpc/qoriq/start/bspstart.c index 5abd651a27..01dc5c57be 100644 --- a/bsps/powerpc/qoriq/start/bspstart.c +++ b/bsps/powerpc/qoriq/start/bspstart.c @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2010, 2017 embedded brains GmbH. All rights reserved. + * Copyright (C) 2010, 2017 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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. */ #include <libfdt.h> @@ -31,7 +44,6 @@ #include <bsp.h> #include <bsp/bootcard.h> -#include <bsp/console-termios.h> #include <bsp/fatal.h> #include <bsp/fdt.h> #include <bsp/intercom.h> diff --git a/bsps/powerpc/qoriq/start/epapr_hcalls.S b/bsps/powerpc/qoriq/start/epapr_hcalls.S index b019e5d710..7f379556cf 100644 --- a/bsps/powerpc/qoriq/start/epapr_hcalls.S +++ b/bsps/powerpc/qoriq/start/epapr_hcalls.S @@ -1,15 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* - * Copyright (c) 2017 embedded brains GmbH. All rights reserved. + * Copyright (c) 2017 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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. */ #include <libcpu/powerpc-utility.h> diff --git a/bsps/powerpc/qoriq/start/l1cache.S b/bsps/powerpc/qoriq/start/l1cache.S index bee3d28123..1eb8dc0ab0 100644 --- a/bsps/powerpc/qoriq/start/l1cache.S +++ b/bsps/powerpc/qoriq/start/l1cache.S @@ -1,15 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* - * Copyright (c) 2015, 2016 embedded brains GmbH. All rights reserved. + * Copyright (C) 2015, 2016 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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. */ #include <libcpu/powerpc-utility.h> diff --git a/bsps/powerpc/qoriq/start/l2cache.S b/bsps/powerpc/qoriq/start/l2cache.S index 1c57659aa1..f470fa2f8d 100644 --- a/bsps/powerpc/qoriq/start/l2cache.S +++ b/bsps/powerpc/qoriq/start/l2cache.S @@ -1,15 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* - * Copyright (c) 2015, 2016 embedded brains GmbH. All rights reserved. + * Copyright (C) 2015, 2016 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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. */ #include <libcpu/powerpc-utility.h> diff --git a/bsps/powerpc/qoriq/start/mmu-config.c b/bsps/powerpc/qoriq/start/mmu-config.c index 0f9eb0c677..15e4a83fc4 100644 --- a/bsps/powerpc/qoriq/start/mmu-config.c +++ b/bsps/powerpc/qoriq/start/mmu-config.c @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2011, 2018 embedded brains GmbH. All rights reserved. + * Copyright (C) 2011, 2018 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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. */ #include <bsp.h> @@ -292,6 +305,92 @@ static void TEXT config_fdt_adjust(const void *fdt) } } +/* + * Each PCIe controller has a ranges attribute in the fdt like the following: + * + * ranges = <0x2000000 0x00 0xc0000000 0x00 0xc0000000 0x00 0x20000000 + * 0x1000000 0x00 0x00000000 0x00 0xffc20000 0x00 0x00010000>; + * |------PCI address------| |-CPU address-| |-----size----| + * + * In theory, some fdt-attributes should be used to find out how long the PCI + * address (#address-cells of the PCIe node), the CPU address (#address-cells of + * the parent node) and the size (#size-cells of the PCIe node) are. In our case + * the structure is fixed because the pcie root controllers are a part of the + * chip. Therefore the sizes will never change and we can assume fixed lengths. + * + * The first cell of the PCI address holds a number of flags. A detailed + * explanation can be found for example here: + * + * https://web.archive.org/web/20240109080338/https://michael2012z.medium.com/understanding-pci-node-in-fdt-769a894a13cc + * + * We are only interested in the entry with the flags 0x02000000 which basically + * means that it is a non-relocatable, non-prefetchable, not-aliased 32 bit + * memory space on the first bus. + * + * The other two cells of the PCI address are a 64 Bit address viewed from PCI + * address space. The two CPU address cells are the same 64 Bit address viewed + * from CPU address space. For our controller these two should always be the + * same (no address translation). The last two cells give a size of the memory + * region (in theory in PCI address space but it has to be the same for CPU and + * PCI). + */ +static void TEXT add_pcie_regions(qoriq_mmu_context *context, const void *fdt) +{ + int node; + + node = -1; + + while (true) { + static const size_t range_length = 7 * 4; + const void *val; + int len; + + node = fdt_node_offset_by_compatible( + fdt, + node, + "fsl,mpc8548-pcie" + ); + if (node < 0) { + break; + } + + val = fdt_getprop(fdt, node, "ranges", &len); + if (len % range_length != 0) { + continue; + } + + while (len >= range_length) { + uint32_t pci_addr_flags; + uintptr_t pci_addr; + uintptr_t cpu_addr; + uintptr_t size; + const uint32_t *cells; + + cells = val; + pci_addr_flags = fdt32_to_cpu(cells[0]); + pci_addr = fdt64_to_cpu(*(fdt64_t *)(&cells[1])); + cpu_addr = fdt64_to_cpu(*(fdt64_t *)(&cells[3])); + size = fdt64_to_cpu(*(fdt64_t *)(&cells[5])); + + if (pci_addr_flags == 0x02000000 && + pci_addr == cpu_addr) { + /* Add as I/O memory */ + qoriq_mmu_add( + context, + cpu_addr, + cpu_addr + size - 1, + 0, + FSL_EIS_MAS2_I | FSL_EIS_MAS2_G, + FSL_EIS_MAS3_SR | FSL_EIS_MAS3_SW, + 0 + ); + } + len -= range_length; + val += range_length; + } + } +} + void TEXT qoriq_mmu_config(bool boot_processor, int first_tlb, int scratch_tlb) { qoriq_mmu_context context; @@ -336,6 +435,8 @@ void TEXT qoriq_mmu_config(bool boot_processor, int first_tlb, int scratch_tlb) } } + add_pcie_regions(&context, fdt); + qoriq_mmu_partition(&context, max_count); qoriq_mmu_write_to_tlb1(&context, first_tlb); } diff --git a/bsps/powerpc/qoriq/start/mmu-tlb1.S b/bsps/powerpc/qoriq/start/mmu-tlb1.S index 1d60a0e459..380d3971bc 100644 --- a/bsps/powerpc/qoriq/start/mmu-tlb1.S +++ b/bsps/powerpc/qoriq/start/mmu-tlb1.S @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2011, 2017 embedded brains GmbH. All rights reserved. + * Copyright (C) 2011, 2017 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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. */ #include <bspopts.h> diff --git a/bsps/powerpc/qoriq/start/mmu.c b/bsps/powerpc/qoriq/start/mmu.c index 558c49618a..706c9fd293 100644 --- a/bsps/powerpc/qoriq/start/mmu.c +++ b/bsps/powerpc/qoriq/start/mmu.c @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2011, 2018 embedded brains GmbH. All rights reserved. + * Copyright (C) 2011, 2018 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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. */ #include <bsp/mmu.h> @@ -345,17 +358,20 @@ void qoriq_mmu_change_perm(uint32_t test, uint32_t set, uint32_t clear) { int i = 0; - for (i = 0; i < 16; ++i) { + for (i = 0; i < QORIQ_TLB1_ENTRY_COUNT; ++i) { uint32_t mas0 = FSL_EIS_MAS0_TLBSEL | FSL_EIS_MAS0_ESEL(i); uint32_t mas1 = 0; PPC_SET_SPECIAL_PURPOSE_REGISTER(FSL_EIS_MAS0, mas0); + ppc_synchronize_instructions(); ppc_tlbre(); + ppc_synchronize_instructions(); - mas1 = PPC_SPECIAL_PURPOSE_REGISTER(FSL_EIS_MAS1); + PPC_SPECIAL_PURPOSE_REGISTER(FSL_EIS_MAS1, mas1); if ((mas1 & FSL_EIS_MAS1_V) != 0) { uint32_t mask = 0x3ff; - uint32_t mas3 = PPC_SPECIAL_PURPOSE_REGISTER(FSL_EIS_MAS3); + uint32_t mas3; + PPC_SPECIAL_PURPOSE_REGISTER(FSL_EIS_MAS3, mas3); if ((mas3 & mask) == test) { mas3 &= ~(clear & mask); @@ -369,3 +385,51 @@ void qoriq_mmu_change_perm(uint32_t test, uint32_t set, uint32_t clear) } } } + +int qoriq_mmu_find_free_tlb1_entry(void) +{ + int i = 0; + + for (i = 0; i < QORIQ_TLB1_ENTRY_COUNT; ++i) { + uint32_t mas0 = FSL_EIS_MAS0_TLBSEL | FSL_EIS_MAS0_ESEL(i); + uint32_t mas1; + + PPC_SET_SPECIAL_PURPOSE_REGISTER(FSL_EIS_MAS0, mas0); + ppc_synchronize_instructions(); + ppc_tlbre(); + ppc_synchronize_instructions(); + + PPC_SPECIAL_PURPOSE_REGISTER(FSL_EIS_MAS1, mas1); + if ((mas1 & FSL_EIS_MAS1_V) == 0) { + return i; + } + } + + return -1; +} + +void qoriq_mmu_adjust_and_write_to_tlb1( + int tlb, + uintptr_t begin, + uintptr_t last, + uint32_t mas1, + uint32_t mas2, + uint32_t mas3, + uint32_t mas7 +) +{ + qoriq_mmu_context context; + + qoriq_mmu_context_init(&context); + qoriq_mmu_add( + &context, + begin, + last, + mas1, + mas2, + mas3, + mas7 + ); + qoriq_mmu_partition(&context, 1); + qoriq_mmu_write_to_tlb1(&context, tlb); +} diff --git a/bsps/powerpc/qoriq/start/portal.c b/bsps/powerpc/qoriq/start/portal.c index f20eaf4d28..c518e6d7d5 100644 --- a/bsps/powerpc/qoriq/start/portal.c +++ b/bsps/powerpc/qoriq/start/portal.c @@ -1,15 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* - * Copyright (c) 2016 embedded brains GmbH. All rights reserved. + * Copyright (c) 2016 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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. */ #include <bsp/qoriq.h> diff --git a/bsps/powerpc/qoriq/start/restart.S b/bsps/powerpc/qoriq/start/restart.S index 7dd9eb198d..e5b43267f5 100644 --- a/bsps/powerpc/qoriq/start/restart.S +++ b/bsps/powerpc/qoriq/start/restart.S @@ -1,15 +1,28 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /* - * Copyright (c) 2016 embedded brains GmbH. All rights reserved. + * Copyright (c) 2016 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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. */ #include <libcpu/powerpc-utility.h> diff --git a/bsps/powerpc/qoriq/start/start.S b/bsps/powerpc/qoriq/start/start.S index 1d11301cdf..9aa192a7f3 100644 --- a/bsps/powerpc/qoriq/start/start.S +++ b/bsps/powerpc/qoriq/start/start.S @@ -1,3 +1,5 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ + /** * @file * @@ -7,17 +9,28 @@ */ /* - * Copyright (c) 2010, 2017 embedded brains GmbH. All rights reserved. + * Copyright (C) 2010, 2017 embedded brains GmbH & Co. KG * - * embedded brains GmbH - * Dornierstr. 4 - * 82178 Puchheim - * Germany - * <rtems@embedded-brains.de> + * 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. * - * The license and distribution terms for this file may be - * found in the file LICENSE in this distribution or at - * http://www.rtems.org/license/LICENSE. + * 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. */ #include <rtems/score/percpu.h> |