Skip to content

RP2040 basic support (draft) #33172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions soc/arm/raspberrypi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# SPDX-License-Identifier: Apache-2.0

add_subdirectory(${SOC_SERIES})
16 changes: 16 additions & 0 deletions soc/arm/raspberrypi/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Raspberry Pi (RP) MCU line

# Copyright (c) 2021 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

config SOC_FAMILY_RASPBERRY_PI
bool

if SOC_FAMILY_RASPBERRY_PI
config SOC_FAMILY
string
default "raspberry_pi_rp"

source "soc/arm/raspberry_pi/*/Kconfig.soc"

endif # SOC_FAMILY_RASPBERRY_PI
10 changes: 10 additions & 0 deletions soc/arm/raspberrypi/Kconfig.defconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Raspberry Pi (RP) MCU line

# Copyright (c) 2021 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

if SOC_FAMILY_RASPBERRY_PI

source "soc/arm/raspberry_pi/*/Kconfig.defconfig.series"

endif # SOC_FAMILY_RASPBERRY_PI
6 changes: 6 additions & 0 deletions soc/arm/raspberrypi/Kconfig.soc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Raspberry Pi (RP) MCU line

# Copyright (c) 2021 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

source "soc/arm/raspberry_pi/*/Kconfig.series"
12 changes: 12 additions & 0 deletions soc/arm/raspberrypi/rp20/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SPDX-License-Identifier: Apache-2.0

zephyr_library()

zephyr_library_sources(
soc.c
)

zephyr_library_include_directories(
${ZEPHYR_BASE}/kernel/include
${ZEPHYR_BASE}/arch/arm/include
)
8 changes: 8 additions & 0 deletions soc/arm/raspberrypi/rp20/Kconfig.defconfig.rp2040
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# # Raspberry Pi RP2040 MCU

# Copyright (c) 2021 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

config SOC
default "rp2040"
depends on SOC_RP2040
16 changes: 16 additions & 0 deletions soc/arm/raspberrypi/rp20/Kconfig.defconfig.series
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Raspberry Pi RP20XX MCU line

# Copyright (c) 2021 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

if SOC_SERIES_RP20XX

source "soc/arm/raspberry_pi/rp20/Kconfig.defconfig.rp20*"

config SOC_SERIES
default "rp2040"

config NUM_IRQS
default 26

endif # SOC_SERIES_RP20XX
16 changes: 16 additions & 0 deletions soc/arm/raspberrypi/rp20/Kconfig.series
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Raspberry Pi RP20XX MCU line

# Copyright (c) 2021 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

config SOC_SERIES_RP20XX
bool "Raspberry Pi RP20 series MCU"
select ARM
select CPU_CORTEX_M0_PLUS
select CPU_CORTEX_M_HAS_SYSTICK
select CPU_CORTEX_M_HAS_VTOR
select CPU_HAS_ARM_MPU
select SOC_FAMILY_RASPBERRY_PI
select XIP
help
Enable support for Raspberry Pi RP20 MCU series
13 changes: 13 additions & 0 deletions soc/arm/raspberrypi/rp20/Kconfig.soc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Raspberry Pi RP20XX MCU line

# Copyright (c) 2021 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

choice
prompt "RP20xx MCU Selection"
depends on SOC_SERIES_RP20XX

config SOC_RP2040
bool "Raspberry Pi RP2040"

endchoice
9 changes: 9 additions & 0 deletions soc/arm/raspberrypi/rp20/linker.ld
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/* linker.ld - Linker command/script file */

/*
* Copyright (c) 2014 Wind River Systems, Inc.
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <arch/arm/aarch32/cortex_m/scripts/linker.ld>
60 changes: 60 additions & 0 deletions soc/arm/raspberrypi/rp20/soc.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* Copyright (c) 2021 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

/**
* @file
* @brief System/hardware module for Raspberry Pi RP2040 family processor
*
* This module provides routines to initialize and support board-level hardware
* for the Raspberry Pi RP2040 family processor.
*/

#include <kernel.h>
#include <init.h>
#include <logging/log.h>

#ifdef CONFIG_RUNTIME_NMI
extern void z_arm_nmi_init(void);
#define NMI_INIT() z_arm_nmi_init()
#else
#define NMI_INIT()
#endif

//#include <system_nrf51.h>
#define LOG_LEVEL CONFIG_SOC_LOG_LEVEL
LOG_MODULE_REGISTER(soc);

/* Overrides the weak ARM implementation:
Set general purpose retention register and reboot */
void sys_arch_reboot(int type)
{
NVIC_SystemReset();
}

static int raspberry_pi_rp2040_init(const struct device *arg)
{
uint32_t key;

ARG_UNUSED(arg);

key = irq_lock();

/* Install default handler that simply resets the CPU
* if configured in the kernel, NOP otherwise
*/
NMI_INIT();

irq_unlock(key);

return 0;
}

void z_platform_init(void)
{
SystemInit();
}

SYS_INIT(raspberry_pi_rp2040_init, PRE_KERNEL_1, 0);
16 changes: 16 additions & 0 deletions soc/arm/raspberrypi/rp20/soc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/*
* Copyright (c) 2016 Linaro Limited
*
* SPDX-License-Identifier: Apache-2.0
*/

/**
* @file SoC configuration macros for the Raspberry Pi RP2040 family processors
*/

#ifndef _RASPBERRY_PI_RP2040_SOC_H_
#define _RASPBERRY_PI_RP2040_SOC_H_

#include "../soc_rp_common.h"

#endif /* _RASPBERRY_PI_RP2040_SOC_H_ */