From 85e8536fbe7f7544b26eaaedc4daa26641be49f0 Mon Sep 17 00:00:00 2001 From: zouboan Date: Tue, 16 Jul 2024 21:24:01 +0800 Subject: [PATCH] zcu111: add support for board led --- .../zynq-mpsoc/zcu111/configs/nsh/defconfig | 1 - .../arm64/zynq-mpsoc/zcu111/include/board.h | 42 ++++++++++ boards/arm64/zynq-mpsoc/zcu111/src/Makefile | 4 + boards/arm64/zynq-mpsoc/zcu111/src/zcu111.h | 14 ++++ .../zynq-mpsoc/zcu111/src/zcu111_autoleds.c | 81 +++++++++++++++++++ .../zynq-mpsoc/zcu111/src/zcu111_boardinit.c | 5 +- 6 files changed, 145 insertions(+), 2 deletions(-) create mode 100644 boards/arm64/zynq-mpsoc/zcu111/src/zcu111_autoleds.c diff --git a/boards/arm64/zynq-mpsoc/zcu111/configs/nsh/defconfig b/boards/arm64/zynq-mpsoc/zcu111/configs/nsh/defconfig index 2eafe59f17..f49d030838 100644 --- a/boards/arm64/zynq-mpsoc/zcu111/configs/nsh/defconfig +++ b/boards/arm64/zynq-mpsoc/zcu111/configs/nsh/defconfig @@ -5,7 +5,6 @@ # You can then do "make savedefconfig" to generate a new defconfig file that includes your # modifications. # -# CONFIG_ARCH_LEDS is not set # CONFIG_DEBUG_OPT_UNUSED_SECTIONS is not set CONFIG_ARCH="arm64" CONFIG_ARCH_ARM64=y diff --git a/boards/arm64/zynq-mpsoc/zcu111/include/board.h b/boards/arm64/zynq-mpsoc/zcu111/include/board.h index a652b6e4ef..4932c5cef7 100644 --- a/boards/arm64/zynq-mpsoc/zcu111/include/board.h +++ b/boards/arm64/zynq-mpsoc/zcu111/include/board.h @@ -31,4 +31,46 @@ * Pre-processor Definitions ****************************************************************************/ +/* LED definitions **********************************************************/ + +/* The ZCU111 PL has only one MIO LEDs, Others LED connected to PL. + * + * If CONFIG_ARCH_LEDS is not defined, then the user can control the LEDs in + * any way. The following definitions are used to access individual LEDs. + */ + +/* LED index values for use with board_userled() */ + +#define BOARD_LED1 0 +#define BOARD_NLEDS 1 + +/* LED bits for use with board_userled_all() */ + +#define BOARD_LED1_BIT (1 << BOARD_LED1) + +/* If CONFIG_ARCH_LEDs is defined, then NuttX will control the LED on board + * The following definitions describe how NuttX controls the LED: + * + * SYMBOL Meaning LED1 state + * ------------------ ----------------------- ---------- + * LED_STARTED NuttX has been started OFF + * LED_HEAPALLOCATE Heap has been allocated OFF + * LED_IRQSENABLED Interrupts enabled OFF + * LED_STACKCREATED Idle stack created ON + * LED_INIRQ In an interrupt No change + * LED_SIGNAL In a signal handler No change + * LED_ASSERTION An assertion failed No change + * LED_PANIC The system has crashed Blinking + * LED_IDLE STM32 is is sleep mode Not used + */ + +#define LED_STARTED 0 +#define LED_HEAPALLOCATE 0 +#define LED_IRQSENABLED 0 +#define LED_STACKCREATED 1 +#define LED_INIRQ 2 +#define LED_SIGNAL 2 +#define LED_ASSERTION 2 +#define LED_PANIC 1 + #endif /* __BOARDS_ARM64_ZYNQ_MPSOC_ZCU111_INCLUDE_BOARD_H */ diff --git a/boards/arm64/zynq-mpsoc/zcu111/src/Makefile b/boards/arm64/zynq-mpsoc/zcu111/src/Makefile index efa6c65ab4..d59058840d 100644 --- a/boards/arm64/zynq-mpsoc/zcu111/src/Makefile +++ b/boards/arm64/zynq-mpsoc/zcu111/src/Makefile @@ -23,6 +23,10 @@ include $(TOPDIR)/Make.defs CSRCS = zcu111_boardinit.c CSRCS += zcu111_appinit.c +ifeq ($(CONFIG_ARCH_LEDS),y) +CSRCS += zcu111_autoleds.c +endif + ifeq ($(CONFIG_ETC_ROMFS),y) RCSRCS = etc/init.d/rc.sysinit etc/init.d/rcS endif diff --git a/boards/arm64/zynq-mpsoc/zcu111/src/zcu111.h b/boards/arm64/zynq-mpsoc/zcu111/src/zcu111.h index 7f5445e288..57ff7b1e34 100644 --- a/boards/arm64/zynq-mpsoc/zcu111/src/zcu111.h +++ b/boards/arm64/zynq-mpsoc/zcu111/src/zcu111.h @@ -27,6 +27,20 @@ #include #include +#include "zynq_mio.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Configuration ************************************************************/ + +/* LEDs *********************************************************************/ + +/* Green LED on MIO23 */ + +#define LED_DS50 23 + #ifndef __ASSEMBLY__ /**************************************************************************** diff --git a/boards/arm64/zynq-mpsoc/zcu111/src/zcu111_autoleds.c b/boards/arm64/zynq-mpsoc/zcu111/src/zcu111_autoleds.c new file mode 100644 index 0000000000..404b317463 --- /dev/null +++ b/boards/arm64/zynq-mpsoc/zcu111/src/zcu111_autoleds.c @@ -0,0 +1,81 @@ +/**************************************************************************** + * boards/arm64/zynq-mpsoc/zcu111/src/zcu111_autoleds.c + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +#include +#include + +#include "chip.h" +#include "arm64_internal.h" +#include "zcu111.h" + +#if defined(CONFIG_ARCH_LEDS) + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: board_autoled_initialize + ****************************************************************************/ + +void board_autoled_initialize(void) +{ + /* Configure LED GPIOs for output */ + + zynq_mio_setdirpin(LED_DS50, 1); + zynq_mio_setoutenpin(LED_DS50, 1); + zynq_mio_writepin(LED_DS50, false); +} + +/**************************************************************************** + * Name: board_autoled_on + ****************************************************************************/ + +void board_autoled_on(int led) +{ + if (led == BOARD_LED1) + { + zynq_mio_writepin(LED_DS50, true); + } +} + +/**************************************************************************** + * Name: board_autoled_off + ****************************************************************************/ + +void board_autoled_off(int led) +{ + if (led == BOARD_LED1) + { + zynq_mio_writepin(LED_DS50, false); + } +} + +#endif /* CONFIG_ARCH_LEDS */ diff --git a/boards/arm64/zynq-mpsoc/zcu111/src/zcu111_boardinit.c b/boards/arm64/zynq-mpsoc/zcu111/src/zcu111_boardinit.c index 957a897737..5caadf5930 100644 --- a/boards/arm64/zynq-mpsoc/zcu111/src/zcu111_boardinit.c +++ b/boards/arm64/zynq-mpsoc/zcu111/src/zcu111_boardinit.c @@ -76,10 +76,13 @@ void zynq_memory_initialize(void) void zynq_board_initialize(void) { + /* resets the GPIO module by writing reset values to all registers */ + + zynq_mio_initialize(); #ifdef CONFIG_ARCH_LEDS /* Configure on-board LEDs if LED support has been selected. */ - /* board_autoled_initialize(); */ + board_autoled_initialize(); #endif }