From 218aa63af340bbb530f64be8aa1b9f597bbca3e6 Mon Sep 17 00:00:00 2001 From: raiden00pl Date: Mon, 22 May 2023 14:02:19 +0200 Subject: [PATCH] boards/nrf53: introduce common folder This is an initial step towards moving common logic for NRF53 boards into one place. At this point, only initialization of the TIMER has been moved. --- boards/Kconfig | 3 + boards/arm/nrf53/common/Kconfig | 4 ++ boards/arm/nrf53/common/Makefile | 33 +++++++++++ boards/arm/nrf53/common/include/nrf53_timer.h | 55 +++++++++++++++++++ boards/arm/nrf53/common/src/Make.defs | 31 +++++++++++ boards/arm/nrf53/common/src/nrf53_timer.c | 55 +++++++++++++++++++ .../src/{Makefile => Make.defs} | 6 +- .../nrf5340-dk/configs/timer_cpuapp/defconfig | 1 + .../nrf5340-dk/src/{Makefile => Make.defs} | 12 ++-- boards/arm/nrf53/nrf5340-dk/src/nrf5340-dk.h | 12 ---- .../arm/nrf53/nrf5340-dk/src/nrf53_bringup.c | 4 ++ .../thingy53/src/{Makefile => Make.defs} | 6 +- 12 files changed, 198 insertions(+), 24 deletions(-) create mode 100644 boards/arm/nrf53/common/Kconfig create mode 100644 boards/arm/nrf53/common/Makefile create mode 100644 boards/arm/nrf53/common/include/nrf53_timer.h create mode 100644 boards/arm/nrf53/common/src/Make.defs create mode 100644 boards/arm/nrf53/common/src/nrf53_timer.c rename boards/arm/nrf53/nrf5340-audio-dk/src/{Makefile => Make.defs} (84%) rename boards/arm/nrf53/nrf5340-dk/src/{Makefile => Make.defs} (87%) rename boards/arm/nrf53/thingy53/src/{Makefile => Make.defs} (85%) diff --git a/boards/Kconfig b/boards/Kconfig index b78a54b538..1f1bde8acf 100644 --- a/boards/Kconfig +++ b/boards/Kconfig @@ -4012,6 +4012,9 @@ endif if ARCH_CHIP_NRF52 source "boards/arm/nrf52/common/Kconfig" endif +if ARCH_CHIP_NRF53 +source "boards/arm/nrf53/common/Kconfig" +endif endif config BOARD_CRASHDUMP diff --git a/boards/arm/nrf53/common/Kconfig b/boards/arm/nrf53/common/Kconfig new file mode 100644 index 0000000000..ce537d0af2 --- /dev/null +++ b/boards/arm/nrf53/common/Kconfig @@ -0,0 +1,4 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# \ No newline at end of file diff --git a/boards/arm/nrf53/common/Makefile b/boards/arm/nrf53/common/Makefile new file mode 100644 index 0000000000..804b4e86b6 --- /dev/null +++ b/boards/arm/nrf53/common/Makefile @@ -0,0 +1,33 @@ +############################################################################# +# boards/arm/nrf53/common/Makefile +# +# 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. +# +############################################################################# + +include $(TOPDIR)/Make.defs + +include board/Make.defs +include src/Make.defs + +DEPPATH += --dep-path board +DEPPATH += --dep-path src + +include $(TOPDIR)/boards/Board.mk + +ARCHSRCDIR = $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src +BOARDDIR = $(ARCHSRCDIR)$(DELIM)board +CFLAGS += $(shell $(INCDIR) "$(CC)" $(BOARDDIR)$(DELIM)include) diff --git a/boards/arm/nrf53/common/include/nrf53_timer.h b/boards/arm/nrf53/common/include/nrf53_timer.h new file mode 100644 index 0000000000..e3930b1e90 --- /dev/null +++ b/boards/arm/nrf53/common/include/nrf53_timer.h @@ -0,0 +1,55 @@ +/**************************************************************************** + * boards/arm/nrf53/common/include/nrf53_timer.h + * + * 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. + * + ****************************************************************************/ + +#ifndef __BOARDS_ARM_NRF53_COMMON_INCLUDE_NRF53_TIMER_H +#define __BOARDS_ARM_NRF53_COMMON_INCLUDE_NRF53_TIMER_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +/**************************************************************************** + * Public Functions Prototypes + ****************************************************************************/ + +/**************************************************************************** + * Name: nrf53_timer_driver_setup + * + * Description: + * Configure the timer driver. + * + * Input Parameters: + * devpath - The full path to the timer device. This should be of the + * form /dev/timer0 + * timer - The timer's number. + * + * Returned Value: + * Zero (OK) is returned on success; A negated errno value is returned + * to indicate the nature of any failure. + * + ****************************************************************************/ + +int nrf53_timer_driver_setup(const char *devpath, int timer); + +#endif /* __BOARDS_ARM_NRF53_COMMON_INCLUDE_NRF53_TIMER_H */ diff --git a/boards/arm/nrf53/common/src/Make.defs b/boards/arm/nrf53/common/src/Make.defs new file mode 100644 index 0000000000..6799653b81 --- /dev/null +++ b/boards/arm/nrf53/common/src/Make.defs @@ -0,0 +1,31 @@ +############################################################################# +# boards/arm/nrf53/common/src/Make.defs +# +# 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. +# +############################################################################# + +ifeq ($(CONFIG_ARCH_BOARD_COMMON),y) + +ifeq ($(CONFIG_NRF53_TIMER),y) + CSRCS += nrf53_timer.c +endif + +DEPPATH += --dep-path src +VPATH += :src +CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)src) + +endif diff --git a/boards/arm/nrf53/common/src/nrf53_timer.c b/boards/arm/nrf53/common/src/nrf53_timer.c new file mode 100644 index 0000000000..6d96a866ff --- /dev/null +++ b/boards/arm/nrf53/common/src/nrf53_timer.c @@ -0,0 +1,55 @@ +/**************************************************************************** + * boards/arm/nrf53/common/src/nrf53_timer.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 "nrf53_tim_lowerhalf.h" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: nrf53_timer_driver_setup + * + * Description: + * Configure the timer driver. + * + * Input Parameters: + * devpath - The full path to the timer device. This should be of the + * form /dev/timer0 + * timer - The timer's number. + * + * Returned Value: + * Zero (OK) is returned on success; A negated errno value is returned + * to indicate the nature of any failure. + * + ****************************************************************************/ + +int nrf53_timer_driver_setup(const char *devpath, int timer) +{ + return nrf53_timer_initialize(devpath, timer); +} diff --git a/boards/arm/nrf53/nrf5340-audio-dk/src/Makefile b/boards/arm/nrf53/nrf5340-audio-dk/src/Make.defs similarity index 84% rename from boards/arm/nrf53/nrf5340-audio-dk/src/Makefile rename to boards/arm/nrf53/nrf5340-audio-dk/src/Make.defs index b3608c8888..7251f9103f 100644 --- a/boards/arm/nrf53/nrf5340-audio-dk/src/Makefile +++ b/boards/arm/nrf53/nrf5340-audio-dk/src/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# boards/arm/nrf53/nrf5340-audio-dk/src/Makefile +# boards/arm/nrf53/nrf5340-audio-dk/src/Make.defs # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -32,4 +32,6 @@ else CSRCS += nrf53_userleds.c endif -include $(TOPDIR)/boards/Board.mk +DEPPATH += --dep-path board +VPATH += :board +CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board) diff --git a/boards/arm/nrf53/nrf5340-dk/configs/timer_cpuapp/defconfig b/boards/arm/nrf53/nrf5340-dk/configs/timer_cpuapp/defconfig index 08e45c141b..b62b12a7a1 100644 --- a/boards/arm/nrf53/nrf5340-dk/configs/timer_cpuapp/defconfig +++ b/boards/arm/nrf53/nrf5340-dk/configs/timer_cpuapp/defconfig @@ -10,6 +10,7 @@ # CONFIG_STANDARD_SERIAL is not set CONFIG_ARCH="arm" CONFIG_ARCH_BOARD="nrf5340-dk" +CONFIG_ARCH_BOARD_COMMON=y CONFIG_ARCH_BOARD_NRF5340_DK=y CONFIG_ARCH_CHIP="nrf53" CONFIG_ARCH_CHIP_NRF5340=y diff --git a/boards/arm/nrf53/nrf5340-dk/src/Makefile b/boards/arm/nrf53/nrf5340-dk/src/Make.defs similarity index 87% rename from boards/arm/nrf53/nrf5340-dk/src/Makefile rename to boards/arm/nrf53/nrf5340-dk/src/Make.defs index 0b4d1b1546..b3806842f7 100644 --- a/boards/arm/nrf53/nrf5340-dk/src/Makefile +++ b/boards/arm/nrf53/nrf5340-dk/src/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# boards/arm/nrf53/nrf5340-dk/src/Makefile +# boards/arm/nrf53/nrf5340-dk/src/Make.defs # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -40,12 +40,6 @@ ifeq ($(CONFIG_ARCH_BUTTONS),y) CSRCS += nrf53_buttons.c endif -ifeq ($(CONFIG_TIMER),y) -ifeq ($(CONFIG_NRF53_TIMER),y) -CSRCS += nrf53_timer.c -endif -endif - ifeq ($(CONFIG_PWM),y) CSRCS += nrf53_pwm.c endif @@ -54,4 +48,6 @@ ifeq ($(CONFIG_ADC),y) CSRCS += nrf53_adc.c endif -include $(TOPDIR)/boards/Board.mk +DEPPATH += --dep-path board +VPATH += :board +CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board) diff --git a/boards/arm/nrf53/nrf5340-dk/src/nrf5340-dk.h b/boards/arm/nrf53/nrf5340-dk/src/nrf5340-dk.h index afd2a147a9..4b0b0ecef7 100644 --- a/boards/arm/nrf53/nrf5340-dk/src/nrf5340-dk.h +++ b/boards/arm/nrf53/nrf5340-dk/src/nrf5340-dk.h @@ -94,18 +94,6 @@ int nrf53_bringup(void); -/**************************************************************************** - * Name: nrf53_timer_driver_setup - * - * Description: - * Initialize TIMER driver. - * - ****************************************************************************/ - -#ifdef CONFIG_TIMER -int nrf53_timer_driver_setup(const char *devpath, int timer); -#endif - /**************************************************************************** * Name: nrf53_pwm_setup * diff --git a/boards/arm/nrf53/nrf5340-dk/src/nrf53_bringup.c b/boards/arm/nrf53/nrf5340-dk/src/nrf53_bringup.c index e684a53587..c706eadd13 100644 --- a/boards/arm/nrf53/nrf5340-dk/src/nrf53_bringup.c +++ b/boards/arm/nrf53/nrf5340-dk/src/nrf53_bringup.c @@ -56,6 +56,10 @@ # include "nrf53_rptun.h" #endif +#ifdef CONFIG_TIMER +# include "nrf53_timer.h" +#endif + #include "nrf5340-dk.h" /**************************************************************************** diff --git a/boards/arm/nrf53/thingy53/src/Makefile b/boards/arm/nrf53/thingy53/src/Make.defs similarity index 85% rename from boards/arm/nrf53/thingy53/src/Makefile rename to boards/arm/nrf53/thingy53/src/Make.defs index 28d2b1211a..29515ecd21 100644 --- a/boards/arm/nrf53/thingy53/src/Makefile +++ b/boards/arm/nrf53/thingy53/src/Make.defs @@ -1,5 +1,5 @@ ############################################################################ -# boards/arm/nrf53/thingy53/src/Makefile +# boards/arm/nrf53/thingy53/src/Make.defs # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with @@ -34,4 +34,6 @@ ifeq ($(CONFIG_ARCH_BUTTONS),y) CSRCS += nrf53_buttons.c endif -include $(TOPDIR)/boards/Board.mk +DEPPATH += --dep-path board +VPATH += :board +CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)arch$(DELIM)$(CONFIG_ARCH)$(DELIM)src$(DELIM)board$(DELIM)board)