arch/arm64: add timer initialization for the secondary CPUs.

This commit added timer initialization for the secondary CPUs.

Signed-off-by: ouyangxiangzhen <ouyangxiangzhen@xiaomi.com>
This commit is contained in:
ouyangxiangzhen
2025-05-30 19:56:54 +08:00
committed by GUIDINGLI
parent 0b34c167e5
commit 932f890267
27 changed files with 50 additions and 473 deletions

View File

@@ -19,7 +19,7 @@
# the License.
#
# ##############################################################################
set(SRCS a527_boot.c a527_serial.c a527_timer.c)
set(SRCS a527_boot.c a527_serial.c)
if(CONFIG_ARCH_EARLY_PRINT)
list(APPEND SRCS a527_lowputc.S)

View File

@@ -23,7 +23,7 @@
include common/Make.defs
# C Source Files specific to SoC
CHIP_CSRCS = a527_boot.c a527_serial.c a527_timer.c
CHIP_CSRCS = a527_boot.c a527_serial.c
ifeq ($(CONFIG_ARCH_EARLY_PRINT),y)
CHIP_ASRCS = a527_lowputc.S

View File

@@ -1,37 +0,0 @@
/****************************************************************************
* arch/arm64/src/a527/a527_timer.c
*
* SPDX-License-Identifier: Apache-2.0
*
* 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 <nuttx/timers/arch_alarm.h>
#include "arm64_arch_timer.h"
/****************************************************************************
* Public Functions
****************************************************************************/
void up_timer_initialize(void)
{
up_alarm_set_lowerhalf(arm64_oneshot_initialize());
}

View File

@@ -23,7 +23,7 @@
include common/Make.defs
# Allwinner A64 specific C source files
CHIP_CSRCS = a64_boot.c a64_pio.c a64_serial.c a64_twi.c a64_timer.c
CHIP_CSRCS = a64_boot.c a64_pio.c a64_serial.c a64_twi.c
ifeq ($(CONFIG_A64_DE),y)
CHIP_CSRCS += a64_de.c

View File

@@ -1,43 +0,0 @@
/****************************************************************************
* arch/arm64/src/a64/a64_timer.c
*
* SPDX-License-Identifier: Apache-2.0
*
* 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 <nuttx/timers/arch_alarm.h>
#include "arm64_arch_timer.h"
/****************************************************************************
* Public Functions
****************************************************************************/
void up_timer_initialize(void)
{
up_alarm_set_lowerhalf(arm64_oneshot_initialize());
}
void arm64_timer_secondary_init(void)
{
arm64_oneshot_secondary_init();
}

View File

@@ -20,8 +20,7 @@
# BCM2711 specific C source files
set(SRCS bcm2711_boot.c bcm2711_mailbox.c bcm2711_serial.c bcm2711_gpio.c
bcm2711_timer.c)
set(SRCS bcm2711_boot.c bcm2711_mailbox.c bcm2711_serial.c bcm2711_gpio.c)
# Early boot logging

View File

@@ -26,7 +26,6 @@ CHIP_CSRCS += bcm2711_boot.c
CHIP_CSRCS += bcm2711_mailbox.c
CHIP_CSRCS += bcm2711_serial.c
CHIP_CSRCS += bcm2711_gpio.c
CHIP_CSRCS += bcm2711_timer.c
# Early boot logging

View File

@@ -1,41 +0,0 @@
/****************************************************************************
* arch/arm64/src/bcm2711/bcm2711_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 <nuttx/timers/arch_alarm.h>
#include "arm64_arch_timer.h"
/****************************************************************************
* Public Functions
****************************************************************************/
void up_timer_initialize(void)
{
up_alarm_set_lowerhalf(arm64_oneshot_initialize());
}
void arm64_timer_secondary_init(void)
{
arm64_oneshot_secondary_init();
}

View File

@@ -79,7 +79,7 @@ struct arm64_oneshot_lowerhalf_s
};
/****************************************************************************
* Private Functions
* Inline Functions
****************************************************************************/
static inline void arm64_arch_timer_set_compare(uint64_t value)
@@ -172,6 +172,10 @@ static inline uint64_t arm64_arch_tick2cnt(uint64_t ticks, uint64_t freq)
return count;
}
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: arm64_arch_timer_compare_isr
*
@@ -357,6 +361,28 @@ static int arm64_tick_current(struct oneshot_lowerhalf_s *lower,
return OK;
}
/****************************************************************************
* Name: arm64_oneshot_initialize_per_cpu
*
* Description:
* Initialize the ARM generic timer for secondary CPUs.
*
* Returned Value:
* None
*
****************************************************************************/
static void arm64_oneshot_initialize_per_cpu(void)
{
/* Enable int */
up_enable_irq(ARM_ARCH_TIMER_IRQ);
/* Start timer */
arm64_arch_timer_enable(true);
}
/****************************************************************************
* Private Data
****************************************************************************/
@@ -415,31 +441,19 @@ struct oneshot_lowerhalf_s *arm64_oneshot_initialize(void)
irq_attach(ARM_ARCH_TIMER_IRQ,
arm64_arch_timer_compare_isr, priv);
arm64_oneshot_secondary_init();
arm64_oneshot_initialize_per_cpu();
tmrinfo("oneshot_initialize ok %p \n", &priv->lh);
return &priv->lh;
}
/****************************************************************************
* Name: arm64_arch_timer_secondary_init
*
* Description:
* Initialize the ARM generic timer for secondary CPUs.
*
* Returned Value:
* None
*
****************************************************************************/
void arm64_oneshot_secondary_init(void)
void up_timer_initialize(void)
{
/* Enable int */
up_enable_irq(ARM_ARCH_TIMER_IRQ);
/* Start timer */
arm64_arch_timer_enable(true);
up_alarm_set_lowerhalf(arm64_oneshot_initialize());
}
void arm64_timer_secondary_init(void)
{
arm64_oneshot_initialize_per_cpu();
}

View File

@@ -34,6 +34,7 @@
* Public Function Prototypes
****************************************************************************/
#ifdef CONFIG_ONESHOT
/****************************************************************************
* Name: arm64_oneshot_initialize
*
@@ -48,18 +49,6 @@
****************************************************************************/
struct oneshot_lowerhalf_s *arm64_oneshot_initialize(void);
/****************************************************************************
* Name: arm64_oneshot_secondary_init
*
* Description:
* Initialize the ARM generic timer for secondary CPUs.
*
* Returned Value:
* None
*
****************************************************************************/
void arm64_oneshot_secondary_init(void);
#endif
#endif /* __ARCH_ARM64_SRC_COMMON_ARM64_ARCH_TIMER_H */

View File

@@ -17,7 +17,7 @@
# the License.
#
# ##############################################################################
set(SRCS fvp_boot.c fvp_serial.c fvp_timer.c)
set(SRCS fvp_boot.c fvp_serial.c)
if(CONFIG_ARCH_EARLY_PRINT)
list(APPEND SRCS fvp_lowputc.S)

View File

@@ -23,7 +23,7 @@
include common/Make.defs
# fvp-specific C source files
CHIP_CSRCS = fvp_boot.c fvp_serial.c fvp_timer.c
CHIP_CSRCS = fvp_boot.c fvp_serial.c
ifeq ($(CONFIG_ARCH_EARLY_PRINT),y)
CHIP_ASRCS += fvp_lowputc.S

View File

@@ -1,43 +0,0 @@
/****************************************************************************
* arch/arm64/src/fvp-v8r/fvp_timer.c
*
* SPDX-License-Identifier: Apache-2.0
*
* 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 <nuttx/timers/arch_alarm.h>
#include "arm64_arch_timer.h"
/****************************************************************************
* Public Functions
****************************************************************************/
void up_timer_initialize(void)
{
up_alarm_set_lowerhalf(arm64_oneshot_initialize());
}
void arm64_timer_secondary_init(void)
{
arm64_oneshot_secondary_init();
}

View File

@@ -19,7 +19,7 @@
# the License.
#
# ##############################################################################
set(SRCS goldfish_boot.c goldfish_serial.c goldfish_timer.c)
set(SRCS goldfish_boot.c goldfish_serial.c)
if(CONFIG_RTC_PL031)
list(APPEND SRCS goldfish_rtc.c)

View File

@@ -23,7 +23,7 @@
include common/Make.defs
# qemu-specific C source files
CHIP_CSRCS = goldfish_boot.c goldfish_serial.c goldfish_timer.c
CHIP_CSRCS = goldfish_boot.c goldfish_serial.c
ifeq ($(CONFIG_RTC_PL031),y)
CHIP_CSRCS += goldfish_rtc.c

View File

@@ -1,43 +0,0 @@
/****************************************************************************
* arch/arm64/src/goldfish/goldfish_timer.c
*
* SPDX-License-Identifier: Apache-2.0
*
* 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 <nuttx/timers/arch_alarm.h>
#include "arm64_arch_timer.h"
/****************************************************************************
* Public Functions
****************************************************************************/
void up_timer_initialize(void)
{
up_alarm_set_lowerhalf(arm64_oneshot_initialize());
}
void arm64_timer_secondary_init(void)
{
arm64_oneshot_secondary_init();
}

View File

@@ -24,7 +24,7 @@ include common/Make.defs
# i.MX8-specific C source files
CHIP_CSRCS = imx8_boot.c imx8_timer.c
CHIP_CSRCS = imx8_boot.c
ifeq ($(CONFIG_ARCH_CHIP_IMX8_QUADMAX),y)
CHIP_CSRCS += imx8qm_serial.c

View File

@@ -1,43 +0,0 @@
/****************************************************************************
* arch/arm64/src/imx8/imx8_timer.c
*
* SPDX-License-Identifier: Apache-2.0
*
* 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 <nuttx/timers/arch_alarm.h>
#include "arm64_arch_timer.h"
/****************************************************************************
* Public Functions
****************************************************************************/
void up_timer_initialize(void)
{
up_alarm_set_lowerhalf(arm64_oneshot_initialize());
}
void arm64_timer_secondary_init(void)
{
arm64_oneshot_secondary_init();
}

View File

@@ -28,7 +28,7 @@ endif
# i.MX9-specific C source files
CHIP_CSRCS = imx9_boot.c imx9_timer.c
CHIP_CSRCS = imx9_boot.c
ifeq ($(CONFIG_ARCH_CHIP_IMX93),y)
CHIP_CSRCS += imx9_ccm.c imx9_gpio.c

View File

@@ -1,43 +0,0 @@
/****************************************************************************
* arch/arm64/src/imx9/imx9_timer.c
*
* SPDX-License-Identifier: Apache-2.0
*
* 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 <nuttx/timers/arch_alarm.h>
#include "arm64_arch_timer.h"
/****************************************************************************
* Public Functions
****************************************************************************/
void up_timer_initialize(void)
{
up_alarm_set_lowerhalf(arm64_oneshot_initialize());
}
void arm64_timer_secondary_init(void)
{
arm64_oneshot_secondary_init();
}

View File

@@ -19,7 +19,7 @@
# the License.
#
# ##############################################################################
set(SRCS qemu_boot.c qemu_serial.c qemu_timer.c)
set(SRCS qemu_boot.c qemu_serial.c)
if(CONFIG_ARCH_EARLY_PRINT)
list(APPEND SRCS qemu_lowputc.S)

View File

@@ -25,8 +25,6 @@ include common/Make.defs
# qemu-specific C source files
CHIP_CSRCS = qemu_boot.c qemu_serial.c
CHIP_CSRCS += qemu_timer.c
ifeq ($(CONFIG_ARCH_EARLY_PRINT),y)
CHIP_ASRCS = qemu_lowputc.S
endif

View File

@@ -1,43 +0,0 @@
/****************************************************************************
* arch/arm64/src/qemu/qemu_timer.c
*
* SPDX-License-Identifier: Apache-2.0
*
* 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 <nuttx/timers/arch_alarm.h>
#include "arm64_arch_timer.h"
/****************************************************************************
* Public Functions
****************************************************************************/
void up_timer_initialize(void)
{
up_alarm_set_lowerhalf(arm64_oneshot_initialize());
}
void arm64_timer_secondary_init(void)
{
arm64_oneshot_secondary_init();
}

View File

@@ -23,7 +23,7 @@
include common/Make.defs
# Rockchip RK3399 specific C source files
CHIP_CSRCS = rk3399_boot.c rk3399_serial.c rk3399_timer.c
CHIP_CSRCS = rk3399_boot.c rk3399_serial.c
ifeq ($(CONFIG_ARCH_EARLY_PRINT),y)
CHIP_ASRCS = rk3399_lowputc.S

View File

@@ -1,43 +0,0 @@
/****************************************************************************
* arch/arm64/src/rk3399/rk3399_timer.c
*
* SPDX-License-Identifier: Apache-2.0
*
* 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 <nuttx/timers/arch_alarm.h>
#include "arm64_arch_timer.h"
/****************************************************************************
* Public Functions
****************************************************************************/
void up_timer_initialize(void)
{
up_alarm_set_lowerhalf(arm64_oneshot_initialize());
}
void arm64_timer_secondary_init(void)
{
arm64_oneshot_secondary_init();
}

View File

@@ -23,7 +23,7 @@
include common/Make.defs
# Rockchip zynq mpsoc specific C source files
CHIP_CSRCS = zynq_boot.c zynq_serial.c zynq_mio.c zynq_timer.c zynq_pll.c
CHIP_CSRCS = zynq_boot.c zynq_serial.c zynq_mio.c zynq_pll.c
ifeq ($(CONFIG_ARCH_EARLY_PRINT),y)
CHIP_ASRCS = zynq_lowputc.S

View File

@@ -1,43 +0,0 @@
/****************************************************************************
* arch/arm64/src/zynq-mpsoc/zynq_timer.c
*
* SPDX-License-Identifier: Apache-2.0
*
* 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 <nuttx/timers/arch_alarm.h>
#include "arm64_arch_timer.h"
/****************************************************************************
* Public Functions
****************************************************************************/
void up_timer_initialize(void)
{
up_alarm_set_lowerhalf(arm64_oneshot_initialize());
}
void arm64_timer_secondary_init(void)
{
arm64_oneshot_secondary_init();
}