Skip to content

Commit 50c3781

Browse files
committed
soc: renesas: rx: Update OFS value in vects.c using Kconfig
OFS values setting for RXv1/RXv2 will be defined in SOC Kconfig and set in vects.c file Signed-off-by: Quy Tran <[email protected]>
1 parent 18941b9 commit 50c3781

File tree

4 files changed

+114
-66
lines changed

4 files changed

+114
-66
lines changed

arch/rx/core/vects.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
#include <zephyr/irq.h>
99
#include <kswap.h>
1010
#include <zephyr/tracing/tracing.h>
11-
#include <zephyr/drivers/clock_control/renesas_rx_cgc.h>
11+
#include <ofsm.h>
1212

1313
typedef void (*fp)(void);
1414
extern void _start(void);
@@ -19,20 +19,22 @@ extern void z_rx_irq_exit(void);
1919
#define CONFIG_GEN_IRQ_START_VECTOR 0
2020
#endif
2121

22+
#ifndef SOC_RX_MDE
23+
#define SOC_RX_MDE (0xFFFFFFFFUL)
24+
#endif
25+
#ifndef SOC_RX_OFS0
26+
#define SOC_RX_OFS0 (0xFFFFFFFFUL)
27+
#endif
28+
#ifndef SOC_RX_OFS1
29+
#define SOC_RX_OFS1 (0xFFFFFFFFUL)
30+
#endif
31+
2232
#define EXVECT_SECT __attribute__((section(".exvectors")))
2333
#define RVECT_SECT __attribute__((section(".rvectors")))
2434
#define FVECT_SECT __attribute__((section(".fvectors")))
2535

2636
#define __ISR__ __attribute__((interrupt, naked))
2737

28-
#define SET_OFS1_HOCO_BITS(reg, freq) \
29-
((reg) & ~(0b11 << 12)) | ((((freq) == 24000000 ? 0b10 \
30-
: (freq) == 32000000 ? 0b11 \
31-
: (freq) == 48000000 ? 0b01 \
32-
: (freq) == 64000000 ? 0b00 \
33-
: 0b11) \
34-
<< 12))
35-
3638
static ALWAYS_INLINE void REGISTER_SAVE(void)
3739
{
3840
__asm volatile(
@@ -430,12 +432,10 @@ INT_DEMUX(255);
430432
const void *FixedVectors[] FVECT_SECT = {
431433
/* 0x00-0x4c: Reserved, must be 0xff (according to e2 studio example) */
432434
/* Reserved for OFSM */
435+
(fp)SOC_RX_MDE,
433436
(fp)0xFFFFFFFF,
434-
(fp)0xFFFFFFFF,
435-
(fp)(SET_OFS1_HOCO_BITS(
436-
0xFFFFFFFF,
437-
(RX_CGC_PROP_HAS_STATUS_OKAY_OR(DT_NODELABEL(hoco), clock_frequency, 32000000)))),
438-
(fp)0xFFFFFFFF,
437+
(fp)SOC_RX_OFS1,
438+
(fp)SOC_RX_OFS0,
439439
/* Reserved area */
440440
(fp)0xFFFFFFFF,
441441
(fp)0xFFFFFFFF,
@@ -490,10 +490,10 @@ const FVECT_SECT void *resetVector = _start;
490490
*/
491491
const void *ExceptVectors[] EXVECT_SECT = {
492492
/* 0x00-0x4c: Reserved, must be 0xff (according to e2 studio example) */
493+
(fp)SOC_RX_MDE,
493494
(fp)0xFFFFFFFF,
494-
(fp)0xFFFFFFFF,
495-
(fp)0xFFFFFFFF,
496-
(fp)0xFFFFFFFF,
495+
(fp)SOC_RX_OFS1,
496+
(fp)SOC_RX_OFS0,
497497
(fp)0xFFFFFFFF,
498498
(fp)0xFFFFFFFF,
499499
(fp)0xFFFFFFFF,

soc/renesas/rx/rx130/ofsm.c

Lines changed: 0 additions & 49 deletions
This file was deleted.

soc/renesas/rx/rx130/ofsm.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (c) 2025 Renesas Electronics Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/**
8+
* @brief Option setting header file for Renesas RX130
9+
*/
10+
11+
/*
12+
* Option-Setting Memory for the RX. This region of memory (located in flash)
13+
* determines the state of the MCU after reset and can not be changed on runtime
14+
*
15+
* All registers are set to 0xffffffff by default, which are "safe" settings.
16+
* Please refer to the Renesas RX Group User's Manual before changing any of
17+
* the values as some changes can be permanent or lock access to the device.
18+
*
19+
* Address range: 0xFFFFFF80 to 0xFFFFFF8F
20+
*/
21+
22+
/* Endian Select Register (MDE) at 0xFFFFFF80
23+
*
24+
* b2 to b0: endian select between (0 0 0) for big endian and (1 1 1) for little
25+
* endian. Set this according to __BYTE_ORDER__ (cf. include\toolchain\gcc.h)
26+
*
27+
* all other bits are reserved and have to be set to 1
28+
*/
29+
#define SOC_RX_MDE (0xFFFFFFFFUL) /* little endian */
30+
31+
/* Option Function Select Register 0 (OFS0)
32+
* This section sets the IWDT (Independent Watchdog Timer) behavior immediately after reset
33+
* by programming the OFS0 register. When enabled, IWDT starts counting automatically
34+
* starts after a reset.
35+
*/
36+
#define SOC_RX_OFS0 (0xFFFFFFFFUL)
37+
38+
/* Option Function Select Register 1 (OFS1) (Voltage detection and HOCO)
39+
*/
40+
#define SOC_RX_OFS1 (0xFFFFFFFFUL)

soc/renesas/rx/rx261/ofsm.h

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright (c) 2025 Renesas Electronics Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
/**
8+
* @brief Option setting header file for Renesas RX261
9+
*/
10+
11+
#include <zephyr/devicetree.h>
12+
13+
/*
14+
* Option-Setting Memory for the RX. This region of memory (located in flash)
15+
* determines the state of the MCU after reset and can not be changed on runtime
16+
*
17+
* All registers are set to 0xffffffff by default, which are "safe" settings.
18+
* Please refer to the Renesas RX Group User's Manual before changing any of
19+
* the values as some changes can be permanent or lock access to the device.
20+
*
21+
* Address range: 0xFFFFFF80 to 0xFFFFFF8F
22+
*/
23+
24+
/* Endian Select Register (MDE) at 0xFFFFFF80
25+
*
26+
* b2 to b0: endian select between (0 0 0) for big endian and (1 1 1) for little
27+
* endian. Set this according to __BYTE_ORDER__ (cf. include\toolchain\gcc.h)
28+
*
29+
* all other bits are reserved and have to be set to 1
30+
*/
31+
#define SOC_RX_MDE (0xFFFFFFFFUL) /* little endian */
32+
33+
/* Option Function Select Register 0 (OFS0)
34+
* This section sets the IWDT (Independent Watchdog Timer) behavior immediately after reset
35+
* by programming the OFS0 register. When enabled, IWDT starts counting automatically
36+
* starts after a reset.
37+
*/
38+
#define SOC_RX_OFS0 (0xFFFFFFFFUL)
39+
40+
/* Option Function Select Register 1 (OFS1) (Voltage detection and HOCO)
41+
*/
42+
43+
#define RX_HOCO_FREQ DT_PROP(DT_NODELABEL(hoco), clock_frequency)
44+
45+
#if (RX_HOCO_FREQ == 24000000)
46+
#define SOC_OFS1_HOCO 0b10
47+
#elif (RX_HOCO_FREQ == 32000000)
48+
#define SOC_OFS1_HOCO 0b11
49+
#elif (RX_HOCO_FREQ == 48000000)
50+
#define SOC_OFS1_HOCO 0b01
51+
#elif (RX_HOCO_FREQ == 64000000)
52+
#define SOC_OFS1_HOCO 0b00
53+
#else
54+
#error "Unsupported HOCO clock frequency (must be 24/32/48/64 MHz)"
55+
#endif
56+
57+
#define SOC_RX_OFS1 ((SOC_OFS1_HOCO << 12) | 0xFFFFCFFFUL)

0 commit comments

Comments
 (0)