Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions arch/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -625,11 +625,6 @@ config ARCH_HAVE_TESTSET
bool
default n

config ARCH_HAVE_CUSTOM_TESTSET
bool
default n
select ARCH_HAVE_TESTSET

config ARCH_HAVE_THREAD_LOCAL
bool
default n
Expand Down
16 changes: 11 additions & 5 deletions arch/arm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,9 @@ config ARCH_CHIP_LC823450
select ARCH_HAVE_HEAPCHECK
select ARCH_HAVE_MULTICPU
select ARCH_HAVE_I2CRESET
select ARCH_HAVE_CUSTOM_TESTSET
select ARCH_HAVE_CUSTOM_VECTORS
select LIBC_ATOMIC_IRQ if !SMP
select LIBC_ATOMIC_HWSPINLOCK if SMP
---help---
ON Semiconductor LC823450 architectures (ARM dual Cortex-M3)

Expand Down Expand Up @@ -380,8 +382,9 @@ config ARCH_CHIP_RP2040
select ARCH_HAVE_I2CRESET
select ARM_HAVE_WFE_SEV
select ARCH_BOARD_COMMON
select ARCH_HAVE_CUSTOM_TESTSET
select ARCH_USBDEV_STALLQUEUE if USBDEV
select LIBC_ATOMIC_IRQ if !SMP
select LIBC_ATOMIC_HWSPINLOCK if SMP
---help---
Raspberry Pi RP2040 architectures (ARM dual Cortex-M0+).

Expand Down Expand Up @@ -835,8 +838,7 @@ config ARCH_CHIP_CXD56XX
select ARCH_HAVE_SDIO if MMCSD
select ARCH_HAVE_MATH_H
select ARCH_HAVE_I2CRESET
select ARCH_HAVE_CUSTOM_TESTSET
select LIBC_ARCH_ATOMIC if SMP
select ARCH_HAVE_CUSTOM_VECTORS
---help---
Sony CXD56XX (ARM Cortex-M4) architectures

Expand Down Expand Up @@ -928,7 +930,7 @@ config ARCH_CHIP_CXD32XX
bool "Sony CXD32xx"
select ARCH_CORTEXM4
select ARCH_HAVE_FPU
select LIBC_ARCH_ATOMIC
select LIBC_ATOMIC_IRQ
---help---
Sony CXD32XX (ARM Cortex-M4) architectures

Expand Down Expand Up @@ -960,6 +962,8 @@ config ARCH_ARM7TDMI
default n
select ARCH_DCACHE
select ARCH_ICACHE
select ARCH_HAVE_DEBUG
select LIBC_ATOMIC_IRQ
---help---
The Arm7TDMI-S is an excellent workhorse processor capable of a wide
array of applications. Traditionally used in mobile handsets, the
Expand Down Expand Up @@ -989,6 +993,7 @@ config ARCH_ARM926EJS
select ARCH_ICACHE
select ARCH_HAVE_MMU
select ARCH_USE_MMU
select LIBC_ATOMIC_IRQ
---help---
Arm926EJ-S is the entry point processor capable of supporting full
Operating Systems including Linux, WindowsCE, and Symbian.
Expand Down Expand Up @@ -1044,6 +1049,7 @@ config ARCH_ARMV6M
bool
default n
select ARCH_HAVE_CPUINFO
select LIBC_ATOMIC_IRQ if !LIBC_ATOMIC_HWSPINLOCK

config ARCH_CORTEXM0
bool
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/armv7-a/arm_gicv2.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static atomic_t g_gic_init_done;
#if defined(CONFIG_SMP) && CONFIG_SMP_NCPUS > 1
static void arm_gic_init_done(void)
{
atomic_fetch_or(&g_gic_init_done, 1 << this_cpu());
atomic_or(&g_gic_init_done, 1 << this_cpu());
}

static void arm_gic_wait_done(cpu_set_t cpuset)
Expand Down
8 changes: 7 additions & 1 deletion arch/arm/src/cxd56xx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ set(SRCS
cxd56_icc.c
cxd56_powermgr.c
cxd56_farapi.c
cxd56_sysctl.c)
cxd56_sysctl.c
cxd56_vectors.c
cxd56_hwspinlock.c)

if(CONFIG_SMP)
list(APPEND SRCS cxd56_cpuidlestack.c)
Expand Down Expand Up @@ -179,4 +181,8 @@ if(CONFIG_CXD56_GNSS_HEAP)
list(APPEND SRCS cxd56_gnssheap.c)
endif()

if(CONFIG_LIBC_ATOMIC_HWSPINLOCK)
list(APPEND SRCS cxd56_atomic.c)
endif()

target_sources(arch PRIVATE ${SRCS})
17 changes: 4 additions & 13 deletions arch/arm/src/cxd56xx/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1414,20 +1414,11 @@ config CXD56_GEOFENCE

endif # CXD56_GNSS

config CXD56_TESTSET
bool "Use custom testset for spinlock"
default y
depends on SMP
---help---
Use custom testset

if CXD56_TESTSET

config CXD56_TESTSET_WITH_HWSEM
bool "Use custom testset based on hardware semaphore"
config CXD56_ATOMIC_WITH_HWSEM
bool "Use atomic based on hardware semaphore"
default !CXD56_USE_SYSBUS

endif # CXD56_TESTSET
depends on SMP
select LIBC_ATOMIC_HWSPINLOCK

config CXD56_USE_SYSBUS
bool "Use the system bus for the data section"
Expand Down
6 changes: 6 additions & 0 deletions arch/arm/src/cxd56xx/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ CHIP_CSRCS += cxd56_icc.c
CHIP_CSRCS += cxd56_powermgr.c
CHIP_CSRCS += cxd56_farapi.c
CHIP_CSRCS += cxd56_sysctl.c
CHIP_CSRCS += cxd56_vectors.c
CHIP_CSRCS += cxd56_hwspinlock.c

ifeq ($(CONFIG_SMP),y)
CHIP_CSRCS += cxd56_cpuidlestack.c
Expand Down Expand Up @@ -178,3 +180,7 @@ endif
ifeq ($(CONFIG_CXD56_GNSS_HEAP),y)
CHIP_CSRCS += cxd56_gnssheap.c
endif

ifeq ($(CONFIG_LIBC_ATOMIC_HWSPINLOCK),y)
CHIP_CSRCS += cxd56_atomic.c
endif
50 changes: 50 additions & 0 deletions arch/arm/src/cxd56xx/cxd56_atomic.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/****************************************************************************
* arch/arm/src/cxd56xx/cxd56_atomic.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/hwspinlock/hwspinlock.h>

/****************************************************************************
* Pre-processor Definitions
****************************************************************************/

#define SPH_SMP 14

/****************************************************************************
* Public Data
****************************************************************************/

extern const struct hwspinlock_ops_s g_cxd56_hwspinlock_ops;

struct hwspinlock_dev_s g_atomic_hwspinlock =
{
.id = SPH_SMP,
.priority = 0,
.ops = &g_cxd56_hwspinlock_ops
};

/****************************************************************************
* Public Functions
****************************************************************************/
63 changes: 63 additions & 0 deletions arch/arm/src/cxd56xx/cxd56_hwspinlock.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/****************************************************************************
* arch/arm/src/cxd56xx/cxd56_hwspinlock.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/hwspinlock/hwspinlock.h>

#include "arm_internal.h"
#include "hardware/cxd56_sph.h"

/****************************************************************************
* Private Function Prototypes
****************************************************************************/

static bool cxd56_hwspinlock_trylock(struct hwspinlock_dev_s *dev);
static void cxd56_hwspinlock_unlock(struct hwspinlock_dev_s *dev);

/****************************************************************************
* Public Data
****************************************************************************/

const struct hwspinlock_ops_s g_cxd56_hwspinlock_ops =
{
.trylock = cxd56_hwspinlock_trylock,
.unlock = cxd56_hwspinlock_unlock
};

/****************************************************************************
* Private Functions
****************************************************************************/

static bool cxd56_hwspinlock_trylock(struct hwspinlock_dev_s *dev)
{
uint32_t sphlocked = ((up_cpu_index() + 2) << 16) | 0x1;

putreg32(REQ_LOCK, CXD56_SPH_REQ(dev->id));

return getreg32(CXD56_SPH_STS(dev->id)) == sphlocked;
}

static void cxd56_hwspinlock_unlock(struct hwspinlock_dev_s *dev)
{
putreg32(REQ_UNLOCK, CXD56_SPH_REQ(dev->id));
}
2 changes: 1 addition & 1 deletion arch/arm/src/cxd56xx/cxd56_sph.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ int cxd56_sphinitialize(const char *devname)

/* No. 0-2 and (14)-15 semaphores are reserved by other system. */

#ifdef CONFIG_CXD56_TESTSET
#ifdef CONFIG_CXD56_ATOMIC_WITH_HWSEM
for (i = 3; i < 14; i++)
#else
for (i = 3; i < 15; i++)
Expand Down
7 changes: 6 additions & 1 deletion arch/arm/src/lc823450/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ include armv7-m/Make.defs

CHIP_CSRCS = lc823450_allocateheap2.c lc823450_start.c lc823450_irq.c lc823450_timer.c
CHIP_CSRCS += lc823450_lowputc.c lc823450_serial.c lc823450_clockconfig.c
CHIP_CSRCS += lc823450_syscontrol.c lc823450_gpio.c
CHIP_CSRCS += lc823450_syscontrol.c lc823450_gpio.c lc823450_vectors.c
CHIP_CSRCS += lc823450_hwspinlock.c

# Configuration-dependent LC823450 files

Expand Down Expand Up @@ -123,3 +124,7 @@ endif
ifeq ($(CONFIG_ARM_MPU),y)
CHIP_CSRCS += lc823450_mpuinit2.c
endif

ifeq ($(CONFIG_LIBC_ATOMIC_HWSPINLOCK),y)
CHIP_CSRCS += lc823450_atomic.c
endif
50 changes: 50 additions & 0 deletions arch/arm/src/lc823450/lc823450_atomic.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/****************************************************************************
* arch/arm/src/lc823450/lc823450_atomic.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/hwspinlock/hwspinlock.h>

/****************************************************************************
* Pre-processor Definitions
****************************************************************************/

#define LC823450_MUTEX_REG 0

/****************************************************************************
* Public Data
****************************************************************************/

extern const struct hwspinlock_ops_s g_lc823450_hwspinlock_ops;

struct hwspinlock_dev_s g_atomic_hwspinlock =
{
.id = LC823450_MUTEX_REG,
.priority = 0,
.ops = &g_lc823450_hwspinlock_ops
};

/****************************************************************************
* Public Functions
****************************************************************************/
Loading
Loading