Skip to content
Draft
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
1 change: 1 addition & 0 deletions arch/arm/src/rp2040/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ CHIP_CSRCS += rp2040_pio.c
CHIP_CSRCS += rp2040_clock.c
CHIP_CSRCS += rp2040_xosc.c
CHIP_CSRCS += rp2040_pll.c
CHIP_CSRCS += rp2040_syscfg.c

ifeq ($(CONFIG_SMP),y)
CHIP_CSRCS += rp2040_cpustart.c
Expand Down
52 changes: 52 additions & 0 deletions arch/arm/src/rp2040/hardware/rp2040_syscfg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/****************************************************************************
* arch/arm/src/rp2040/hardware/rp2040_syscfg.h
*
* 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.
*
****************************************************************************/

#ifndef __ARCH_ARM_SRC_RP2040_HARDWARE_RP2040_SYSCFG_H
#define __ARCH_ARM_SRC_RP2040_HARDWARE_RP2040_SYSCFG_H

/****************************************************************************
* Included Files
****************************************************************************/

#include "hardware/rp2040_memorymap.h"

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

/* Register offsets *********************************************************/

#define RP2040_SYSCFG_PROC_CONFIG_OFFSET (0x00000008) /* Configuration for processors. */

/* Register definitions *****************************************************/

#define RP2040_SYSCFG_PROC_CONFIG (RP2040_SYSCFG_BASE + RP2040_SYSCFG_PROC_CONFIG_OFFSET)

/* Register bit definitions *************************************************/

#define RP2040_SYSCFG_PROC_CONFIG_MASK (0xff000003)
#define RP2040_SYSCFG_PROC_CONFIG_PROC1_DAP_INSTID_SHIFT (28)
#define RP2040_SYSCFG_PROC_CONFIG_PROC1_DAP_INSTID_MASK (0xf << RP2040_SYSCFG_PROC_CONFIG_PROC1_DAP_INSTID_SHIFT)
#define RP2040_SYSCFG_PROC_CONFIG_PROC0_DAP_INSTID_SHIFT (24)
#define RP2040_SYSCFG_PROC_CONFIG_PROC0_DAP_INSTID_MASK (0xf << RP2040_SYSCFG_PROC_CONFIG_PROC0_DAP_INSTID_SHIFT)

#endif /* __ARCH_ARM_SRC_RP2040_HARDWARE_RP2040_SYSCFG_H */
82 changes: 82 additions & 0 deletions arch/arm/src/rp2040/rp2040_syscfg.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/****************************************************************************
* arch/arm/src/rp2040/rp2040_syscfg.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/config.h>

#include <stdint.h>
#include <assert.h>
#include <debug.h>

#include <nuttx/arch.h>

#include <arch/board/board.h>

#include "arm_internal.h"
#include "chip.h"

#include "rp2040_syscfg.h"
#include "hardware/rp2040_syscfg.h"

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

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

/****************************************************************************
* Name: rp2040_set_proc_dap_instid
*
* Description:
* Configure proc{0,1} DAP instance ID.
* Recommend that this is NOT changed until you require debug access in
* multichip environment. WARNING: do not set to 15 as this is reserved for
* RescueDP.
*
****************************************************************************/

void rp2040_set_proc_dap_instid(uint8_t proc, uint8_t dap_instid)
{
/* Proc number must be either 0 or 1 */

ASSERT(proc <= 1);
const uint32_t shift = (proc == 0)
? RP2040_SYSCFG_PROC_CONFIG_PROC0_DAP_INSTID_SHIFT
: RP2040_SYSCFG_PROC_CONFIG_PROC1_DAP_INSTID_SHIFT;
const uint32_t mask = (proc == 0)
? RP2040_SYSCFG_PROC_CONFIG_PROC0_DAP_INSTID_MASK
: RP2040_SYSCFG_PROC_CONFIG_PROC1_DAP_INSTID_MASK;

/* ID must be 4 bits and different from 15 (0xf) */

ASSERT(dap_instid < 0xf);

/* Set the configurable ID bits */

clrbits_reg32(mask, RP2040_SYSCFG_PROC_CONFIG);
setbits_reg32(dap_instid << shift, RP2040_SYSCFG_PROC_CONFIG);
}
78 changes: 78 additions & 0 deletions arch/arm/src/rp2040/rp2040_syscfg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/****************************************************************************
* arch/arm/src/rp2040/rp2040_syscfg.h
*
* 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.
*
****************************************************************************/

#ifndef __ARCH_ARM_SRC_RP2040_RP2040_SYSCFG_H
#define __ARCH_ARM_SRC_RP2040_RP2040_SYSCFG_H

/****************************************************************************
* Included Files
****************************************************************************/

#include <nuttx/config.h>
#include <stdint.h>

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

/****************************************************************************
* Public Types
****************************************************************************/

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

#ifndef __ASSEMBLY__

#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif

/****************************************************************************
* Public Function Prototypes
****************************************************************************/

/****************************************************************************
* Name: rp2040_set_proc0_dap_instid
*
* Description:
* Configure proc1 DAP instance ID.
* Recommend that this is NOT changed until you require debug access in
* multichip environment. WARNING: do not set to 15 as this is reserved
* for RescueDP.
*
****************************************************************************/

void rp2040_set_proc_dap_instid(uint8_t proc, uint8_t dap_instid);

#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_ARM_SRC_RP2040_RP2040_SYSCFG_H */
Loading