Skip to content
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

Add support for the new BICR generation tools #2298

Merged
merged 33 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b84eec7
Revert "[nrf noup] dts: Select SoftDevice Controller DTS binding as d…
gmarull Nov 28, 2024
a6adabe
Revert "[nrf noup] dts: choose a crypto accelerator for entropy"
gmarull Nov 28, 2024
daaf232
Revert "[nrf fromlist] modules: nordic: nrfx: workaround MDK erratas …
gmarull Dec 9, 2024
8f18ad6
Revert "[nrf fromlist] dts: nordic: Add support for clock outputs"
gmarull Dec 16, 2024
9316a11
Revert "[nrf fromtree] soc: nordic: Introduce the nRF54L05 and nRF54L10"
gmarull Dec 9, 2024
c4931d9
Revert "[nrf noup] boards: Add non-secure target for nrf54L15dk"
gmarull Nov 28, 2024
0aee2ac
Revert "[nrf fromtree] boards: nordic: nRF54L15DK: Add basic support …
gmarull Nov 28, 2024
a2bc6ad
Revert "[nrf fromtree] nordic: Remove the nRF54H20 Engineering B"
gmarull Nov 28, 2024
ca9f670
Revert "[nrf noup] dts: nordic: Add support for BICR generation"
gmarull Nov 28, 2024
ca07583
[nrf fromtree] shell: Allow custom shell log backend implementation
nordic-krch Oct 10, 2024
2df42e9
[nrf fromtree] shell: Extract shell creation from SHELL_DEFINE
nordic-krch Oct 10, 2024
b433f17
[nrf fromtree] drivers: misc: coresight: nrf_etr: Use dmm API for the…
nordic-krch Oct 10, 2024
3607081
[nrf fromtree] drivers: misc: coresight: nrf_etr: Add support for shell
nordic-krch Oct 10, 2024
8a0f630
[nrf fromtree] soc: nordic: nrf54h: cpuapp: Don't use serial shell wh…
nordic-krch Oct 10, 2024
7066fa0
[nrf fromtree] logging: log_cmds: Enable log commands for shell with …
nordic-krch Oct 10, 2024
01cb738
[nrf fromtree] nordic: Remove the nRF54H20 Engineering B
carlescufi Oct 21, 2024
046d871
[nrf fromtree] boards: nordic: nRF54L15DK: Add basic support for the …
carlescufi Nov 6, 2024
25fa3ca
[nrf noup] boards: Add non-secure target for nrf54L15dk
tomi-font Sep 27, 2024
f7da621
[nrf fromtree] soc: nordic: Introduce the nRF54L05 and nRF54L10
carlescufi Nov 4, 2024
c869a46
[nrf fromlist] dts: nordic: Add support for clock outputs
adamkondraciuk Dec 10, 2024
a50707b
[nrf fromtree] modules: nordic: nrfx: workaround MDK erratas symbol f…
nika-nordic Dec 2, 2024
5cb0130
[nrf noup] dts: choose a crypto accelerator for entropy
joerchan Jan 16, 2023
4daa9d2
[nrf noup] dts: Select SoftDevice Controller DTS binding as default
rugeGerritsen Sep 5, 2024
c0d8b19
[nrf fromtree] drivers: clock_control: nrf: add zero-latency-isr safe…
bjarki-andreasen Dec 3, 2024
05b18d8
[nrf fromtree] drivers: clock_control: nrf: hfxo: impl zero-latency i…
bjarki-andreasen Dec 3, 2024
66f2880
[nrf fromlist] dts: bindings: misc: add nordic,nrf-bicr
gmarull Nov 8, 2024
af4a363
[nrf fromlist] dts: common: nordic: nrf54h20: define BICR node
gmarull Nov 8, 2024
fa8f1d1
[nrf fromlist] drivers: clock_control: nrf54h-hfxo: use values from BICR
gmarull Nov 7, 2024
987fb60
[nrf fromlist] drivers: clock_control: nrf54h-common: add utility to …
gmarull Nov 8, 2024
0fc5f7e
[nrf fromlist] drivers: clock_control: nrf54h-lfclk: use values from …
gmarull Nov 7, 2024
c515a18
[nrf fromlist] drivers: clock_control: nrf54h-fll16m: use values from…
gmarull Nov 8, 2024
254e637
[nrf fromlist] soc: nordic: nrf54h: add BICR generation tooling
gmarull Nov 19, 2024
dd6ea81
[nrf fromlist] boards: nrf54h20dk: add bicr.json
gmarull Nov 19, 2024
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
32 changes: 32 additions & 0 deletions boards/nordic/nrf54h20dk/bicr.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"power": {
"scheme": "VDDH_2V1_5V5"
},
"ioPortPower": {
"p1Supply": "EXTERNAL_1V8",
"p2Supply": "EXTERNAL_1V8",
"p6Supply": "EXTERNAL_1V8",
"p7Supply": "EXTERNAL_1V8",
"p9Supply": "EXTERNAL_FULL"
},
"ioPortImpedance": {
"p6ImpedanceOhms": 50,
"p7ImpedanceOhms": 50
},
"lfosc": {
"source": "LFXO",
"lfxo": {
"mode": "CRYSTAL",
"accuracyPPM": 20,
"startupTimeMs": 600,
"builtInLoadCapacitancePf": 15,
"builtInLoadCapacitors": true
}
},
"hfxo": {
"mode": "CRYSTAL",
"startupTimeUs": 850,
"builtInLoadCapacitors": true,
"builtInLoadCapacitancePf": 14
}
}
54 changes: 0 additions & 54 deletions boards/nordic/nrf54h20dk/nrf54h20dk_bicr.dtsi

This file was deleted.

5 changes: 0 additions & 5 deletions boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20-common.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,8 @@
&hfxo {
status = "okay";
accuracy-ppm = <30>;
startup-time-us = <850>;
mode = "crystal";
};

&lfxo {
status = "okay";
accuracy-ppm = <20>;
startup-time-us = <600000>;
mode = "crystal";
};
1 change: 0 additions & 1 deletion boards/nordic/nrf54h20dk/nrf54h20dk_nrf54h20_cpuapp.dts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

#include <nordic/nrf54h20_cpuapp.dtsi>
#include "nrf54h20dk_nrf54h20-common.dtsi"
#include "nrf54h20dk_bicr.dtsi"

/delete-node/ &cpurad_cpusys_ipc;
/delete-node/ &cpusec_cpurad_ipc;
Expand Down
37 changes: 37 additions & 0 deletions drivers/clock_control/clock_control_nrf2_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include "clock_control_nrf2_common.h"
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
#include <hal/nrf_bicr.h>

#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(clock_control_nrf2, CONFIG_CLOCK_CONTROL_LOG_LEVEL);
Expand All @@ -19,6 +20,8 @@ LOG_MODULE_REGISTER(clock_control_nrf2, CONFIG_CLOCK_CONTROL_LOG_LEVEL);
(idx * sizeof(array[0])) - \
offsetof(type, array[0]))

#define BICR (NRF_BICR_Type *)DT_REG_ADDR(DT_NODELABEL(bicr))

/*
* Definition of `struct clock_config_generic`.
* Used to access `clock_config_*` structures in a common way.
Expand Down Expand Up @@ -83,6 +86,40 @@ static inline uint8_t get_index_of_highest_bit(uint32_t value)
return value ? (uint8_t)(31 - __builtin_clz(value)) : 0;
}

int lfosc_get_accuracy(uint16_t *accuracy)
{
switch (nrf_bicr_lfosc_accuracy_get(BICR)) {
case NRF_BICR_LFOSC_ACCURACY_500PPM:
*accuracy = 500U;
break;
case NRF_BICR_LFOSC_ACCURACY_250PPM:
*accuracy = 250U;
break;
case NRF_BICR_LFOSC_ACCURACY_150PPM:
*accuracy = 150U;
break;
case NRF_BICR_LFOSC_ACCURACY_100PPM:
*accuracy = 100U;
break;
case NRF_BICR_LFOSC_ACCURACY_75PPM:
*accuracy = 75U;
break;
case NRF_BICR_LFOSC_ACCURACY_50PPM:
*accuracy = 50U;
break;
case NRF_BICR_LFOSC_ACCURACY_30PPM:
*accuracy = 30U;
break;
case NRF_BICR_LFOSC_ACCURACY_20PPM:
*accuracy = 20U;
break;
default:
return -EINVAL;
}

return 0;
}

int clock_config_init(void *clk_cfg, uint8_t onoff_cnt, k_work_handler_t update_work_handler)
{
struct clock_config_generic *cfg = clk_cfg;
Expand Down
10 changes: 10 additions & 0 deletions drivers/clock_control/clock_control_nrf2_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ struct clock_onoff {
struct clock_onoff onoff[_onoff_cnt]; \
}

/**
* @brief Obtain LFOSC accuracy in ppm.
*
* @param[out] accuracy Accuracy in ppm.
*
* @retval 0 On success
* @retval -EINVAL If accuracy is not configured.
*/
int lfosc_get_accuracy(uint16_t *accuracy);

/**
* @brief Initializes a clock configuration structure.
*
Expand Down
37 changes: 25 additions & 12 deletions drivers/clock_control/clock_control_nrf2_fll16m.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@
#include "clock_control_nrf2_common.h"
#include <zephyr/devicetree.h>
#include <zephyr/drivers/clock_control/nrf_clock_control.h>

#include <soc_lrcconf.h>
#include <hal/nrf_bicr.h>

#include <zephyr/logging/log.h>
LOG_MODULE_DECLARE(clock_control_nrf2, CONFIG_CLOCK_CONTROL_LOG_LEVEL);
Expand All @@ -23,26 +25,17 @@ BUILD_ASSERT(DT_NUM_INST_STATUS_OKAY(DT_DRV_COMPAT) == 1,
#define FLL16M_MODE_BYPASS 2
#define FLL16M_MODE_DEFAULT FLL16M_MODE_OPEN_LOOP

#define FLL16M_LFXO_NODE DT_INST_PHANDLE_BY_NAME(0, clocks, lfxo)
#define FLL16M_HFXO_NODE DT_INST_PHANDLE_BY_NAME(0, clocks, hfxo)

#define FLL16M_HAS_LFXO DT_NODE_HAS_STATUS_OKAY(FLL16M_LFXO_NODE)

#define FLL16M_LFXO_ACCURACY DT_PROP(FLL16M_LFXO_NODE, accuracy_ppm)
#define FLL16M_HFXO_ACCURACY DT_PROP(FLL16M_HFXO_NODE, accuracy_ppm)
#define FLL16M_OPEN_LOOP_ACCURACY DT_INST_PROP(0, open_loop_accuracy_ppm)
#define FLL16M_CLOSED_LOOP_BASE_ACCURACY DT_INST_PROP(0, closed_loop_base_accuracy_ppm)
#define FLL16M_MAX_ACCURACY FLL16M_HFXO_ACCURACY

/* Closed-loop mode uses LFXO as source if present, HFXO otherwise */
#if FLL16M_HAS_LFXO
#define FLL16M_CLOSED_LOOP_ACCURACY (FLL16M_CLOSED_LOOP_BASE_ACCURACY + FLL16M_LFXO_ACCURACY)
#else
#define FLL16M_CLOSED_LOOP_ACCURACY (FLL16M_CLOSED_LOOP_BASE_ACCURACY + FLL16M_HFXO_ACCURACY)
#endif
#define BICR (NRF_BICR_Type *)DT_REG_ADDR(DT_NODELABEL(bicr))

/* Clock options sorted from lowest to highest accuracy */
static const struct clock_options {
static struct clock_options {
uint16_t accuracy;
uint8_t mode;
} clock_options[] = {
Expand All @@ -51,7 +44,6 @@ static const struct clock_options {
.mode = FLL16M_MODE_OPEN_LOOP,
},
{
.accuracy = FLL16M_CLOSED_LOOP_ACCURACY,
.mode = FLL16M_MODE_CLOSED_LOOP,
},
{
Expand Down Expand Up @@ -233,6 +225,27 @@ static int api_get_rate_fll16m(const struct device *dev,
static int fll16m_init(const struct device *dev)
{
struct fll16m_dev_data *dev_data = dev->data;
nrf_bicr_lfosc_mode_t lfosc_mode;

clock_options[1].accuracy = FLL16M_CLOSED_LOOP_BASE_ACCURACY;

/* Closed-loop mode uses LFXO as source if present, HFXO otherwise */
lfosc_mode = nrf_bicr_lfosc_mode_get(BICR);

if (lfosc_mode != NRF_BICR_LFOSC_MODE_UNCONFIGURED &&
lfosc_mode != NRF_BICR_LFOSC_MODE_DISABLED) {
int ret;
uint16_t accuracy;

ret = lfosc_get_accuracy(&accuracy);
if (ret < 0) {
return ret;
}

clock_options[1].accuracy += accuracy;
} else {
clock_options[1].accuracy += FLL16M_HFXO_ACCURACY;
}

return clock_config_init(&dev_data->clk_cfg,
ARRAY_SIZE(dev_data->clk_cfg.onoff),
Expand Down
Loading
Loading