1
1
/*
2
- * Copyright (c) 2017-2018 Nordic Semiconductor ASA
2
+ * Copyright (c) 2017-2023 Nordic Semiconductor ASA
3
3
* Copyright (c) 2016 Linaro Limited
4
4
* Copyright (c) 2016 Intel Corporation
5
5
*
@@ -116,6 +116,26 @@ static inline bool is_uicr_addr_valid(off_t addr, size_t len)
116
116
#endif /* CONFIG_SOC_FLASH_NRF_UICR */
117
117
}
118
118
119
+ #if CONFIG_SOC_FLASH_NRF_UICR && IS_ENABLED (NRF91_ERRATA_7_ENABLE_WORKAROUND )
120
+ static inline void nrf91_errata_7_enter (void )
121
+ {
122
+ __disable_irq ();
123
+ }
124
+
125
+ static inline void nrf91_errata_7_exit (void )
126
+ {
127
+ __DSB ();
128
+ __enable_irq ();
129
+ }
130
+
131
+ static void nrf_buffer_read_91_uicr (void * data , off_t addr , size_t len )
132
+ {
133
+ nrf91_errata_7_enter ();
134
+ nrf_nvmc_buffer_read (data , (uint32_t )addr , len );
135
+ nrf91_errata_7_exit ();
136
+ }
137
+ #endif
138
+
119
139
static void nvmc_wait_ready (void )
120
140
{
121
141
while (!nrfx_nvmc_write_done_check ()) {
@@ -125,9 +145,11 @@ static void nvmc_wait_ready(void)
125
145
static int flash_nrf_read (const struct device * dev , off_t addr ,
126
146
void * data , size_t len )
127
147
{
148
+ const bool within_uicr = is_uicr_addr_valid (addr , len );
149
+
128
150
if (is_regular_addr_valid (addr , len )) {
129
151
addr += DT_REG_ADDR (SOC_NV_FLASH_NODE );
130
- } else if (!is_uicr_addr_valid ( addr , len ) ) {
152
+ } else if (!within_uicr ) {
131
153
LOG_ERR ("invalid address: 0x%08lx:%zu" ,
132
154
(unsigned long )addr , len );
133
155
return - EINVAL ;
@@ -137,6 +159,13 @@ static int flash_nrf_read(const struct device *dev, off_t addr,
137
159
return 0 ;
138
160
}
139
161
162
+ #if CONFIG_SOC_FLASH_NRF_UICR && IS_ENABLED (NRF91_ERRATA_7_ENABLE_WORKAROUND )
163
+ if (within_uicr ) {
164
+ nrf_buffer_read_91_uicr (data , (uint32_t )addr , len );
165
+ return 0 ;
166
+ }
167
+ #endif
168
+
140
169
nrf_nvmc_buffer_read (data , (uint32_t )addr , len );
141
170
142
171
return 0 ;
0 commit comments