@@ -21,6 +21,7 @@ LOG_MODULE_REGISTER(qspi_nor, CONFIG_FLASH_LOG_LEVEL);
21
21
#include "flash_priv.h"
22
22
#include <nrfx_qspi.h>
23
23
#include <hal/nrf_clock.h>
24
+ #include <hal/nrf_gpio.h>
24
25
25
26
struct qspi_nor_data {
26
27
#ifdef CONFIG_MULTITHREADING
@@ -30,10 +31,8 @@ struct qspi_nor_data {
30
31
struct k_sem sem ;
31
32
/* The semaphore to indicate that transfer has completed. */
32
33
struct k_sem sync ;
33
- #if NRF52_ERRATA_122_PRESENT
34
34
/* The semaphore to control driver init/uninit. */
35
35
struct k_sem count ;
36
- #endif
37
36
#else /* CONFIG_MULTITHREADING */
38
37
/* A flag that signals completed transfer when threads are
39
38
* not enabled.
@@ -176,19 +175,10 @@ BUILD_ASSERT(DT_INST_PROP(0, address_size_32),
176
175
"After entering 4 byte addressing mode, 4 byte addressing is expected" );
177
176
#endif
178
177
178
+ static bool qspi_initialized ;
179
179
180
-
181
- #if NRF52_ERRATA_122_PRESENT
182
- #include <hal/nrf_gpio.h>
183
- static int anomaly_122_init (const struct device * dev );
184
- static void anomaly_122_uninit (const struct device * dev );
185
-
186
- #define ANOMALY_122_INIT (dev ) anomaly_122_init(dev)
187
- #define ANOMALY_122_UNINIT (dev ) anomaly_122_uninit(dev)
188
- #else
189
- #define ANOMALY_122_INIT (dev ) 0
190
- #define ANOMALY_122_UNINIT (dev )
191
- #endif
180
+ static int qspi_device_init (const struct device * dev );
181
+ static void qspi_device_uninit (const struct device * dev );
192
182
193
183
#define WORD_SIZE 4
194
184
@@ -361,23 +351,16 @@ static void qspi_handler(nrfx_qspi_evt_t event, void *p_context)
361
351
}
362
352
}
363
353
364
- #if NRF52_ERRATA_122_PRESENT
365
- static bool qspi_initialized ;
366
-
367
- static int anomaly_122_init (const struct device * dev )
354
+ static int qspi_device_init (const struct device * dev )
368
355
{
369
356
struct qspi_nor_data * dev_data = dev -> data ;
370
357
nrfx_err_t res ;
371
358
int ret = 0 ;
372
359
373
- if (!nrf52_errata_122 ()) {
374
- return 0 ;
375
- }
376
-
377
360
qspi_lock (dev );
378
361
379
- /* In multithreading, driver can call anomaly_122_init more than once
380
- * before calling anomaly_122_uninit . Keepping count, so QSPI is
362
+ /* In multithreading, driver can call qspi_device_init more than once
363
+ * before calling qspi_device_uninit . Keepping count, so QSPI is
381
364
* uninitialized only at the last call (count == 0).
382
365
*/
383
366
#ifdef CONFIG_MULTITHREADING
@@ -399,14 +382,10 @@ static int anomaly_122_init(const struct device *dev)
399
382
return ret ;
400
383
}
401
384
402
- static void anomaly_122_uninit (const struct device * dev )
385
+ static void qspi_device_uninit (const struct device * dev )
403
386
{
404
387
bool last = true;
405
388
406
- if (!nrf52_errata_122 ()) {
407
- return ;
408
- }
409
-
410
389
qspi_lock (dev );
411
390
412
391
#ifdef CONFIG_MULTITHREADING
@@ -438,8 +417,6 @@ static void anomaly_122_uninit(const struct device *dev)
438
417
439
418
qspi_unlock (dev );
440
419
}
441
- #endif /* NRF52_ERRATA_122_PRESENT */
442
-
443
420
444
421
/* QSPI send custom command.
445
422
*
@@ -629,7 +606,7 @@ static int qspi_erase(const struct device *dev, uint32_t addr, uint32_t size)
629
606
int rv = 0 ;
630
607
const struct qspi_nor_config * params = dev -> config ;
631
608
632
- rv = ANOMALY_122_INIT (dev );
609
+ rv = qspi_device_init (dev );
633
610
if (rv != 0 ) {
634
611
goto out ;
635
612
}
@@ -685,7 +662,7 @@ static int qspi_erase(const struct device *dev, uint32_t addr, uint32_t size)
685
662
qspi_trans_unlock (dev );
686
663
687
664
out :
688
- ANOMALY_122_UNINIT (dev );
665
+ qspi_device_uninit (dev );
689
666
return rv ;
690
667
}
691
668
@@ -807,12 +784,12 @@ static int qspi_read_jedec_id(const struct device *dev,
807
784
.rx_buf = & rx_buf ,
808
785
};
809
786
810
- int ret = ANOMALY_122_INIT (dev );
787
+ int ret = qspi_device_init (dev );
811
788
812
789
if (ret == 0 ) {
813
790
ret = qspi_send_cmd (dev , & cmd , false);
814
791
}
815
- ANOMALY_122_UNINIT (dev );
792
+ qspi_device_uninit (dev );
816
793
817
794
return ret ;
818
795
}
@@ -837,12 +814,12 @@ static int qspi_sfdp_read(const struct device *dev, off_t offset,
837
814
.io3_level = true,
838
815
};
839
816
840
- int ret = ANOMALY_122_INIT (dev );
817
+ int ret = qspi_device_init (dev );
841
818
nrfx_err_t res = NRFX_SUCCESS ;
842
819
843
820
if (ret != 0 ) {
844
- LOG_DBG ("ANOMALY_122_INIT : %d" , ret );
845
- ANOMALY_122_UNINIT (dev );
821
+ LOG_DBG ("qspi_device_init : %d" , ret );
822
+ qspi_device_uninit (dev );
846
823
return ret ;
847
824
}
848
825
@@ -867,7 +844,7 @@ static int qspi_sfdp_read(const struct device *dev, off_t offset,
867
844
868
845
out :
869
846
qspi_unlock (dev );
870
- ANOMALY_122_UNINIT (dev );
847
+ qspi_device_uninit (dev );
871
848
return qspi_get_zephyr_ret_code (res );
872
849
}
873
850
@@ -994,7 +971,7 @@ static int qspi_nor_read(const struct device *dev, off_t addr, void *dest,
994
971
return - EINVAL ;
995
972
}
996
973
997
- int rc = ANOMALY_122_INIT (dev );
974
+ int rc = qspi_device_init (dev );
998
975
999
976
if (rc != 0 ) {
1000
977
goto out ;
@@ -1009,7 +986,7 @@ static int qspi_nor_read(const struct device *dev, off_t addr, void *dest,
1009
986
rc = qspi_get_zephyr_ret_code (res );
1010
987
1011
988
out :
1012
- ANOMALY_122_UNINIT (dev );
989
+ qspi_device_uninit (dev );
1013
990
return rc ;
1014
991
}
1015
992
@@ -1102,7 +1079,7 @@ static int qspi_nor_write(const struct device *dev, off_t addr,
1102
1079
1103
1080
nrfx_err_t res = NRFX_SUCCESS ;
1104
1081
1105
- int rc = ANOMALY_122_INIT (dev );
1082
+ int rc = qspi_device_init (dev );
1106
1083
1107
1084
if (rc != 0 ) {
1108
1085
goto out ;
@@ -1132,7 +1109,7 @@ static int qspi_nor_write(const struct device *dev, off_t addr,
1132
1109
1133
1110
rc = qspi_get_zephyr_ret_code (res );
1134
1111
out :
1135
- ANOMALY_122_UNINIT (dev );
1112
+ qspi_device_uninit (dev );
1136
1113
return rc ;
1137
1114
}
1138
1115
@@ -1184,7 +1161,7 @@ static int qspi_nor_configure(const struct device *dev)
1184
1161
return ret ;
1185
1162
}
1186
1163
1187
- ANOMALY_122_UNINIT (dev );
1164
+ qspi_device_uninit (dev );
1188
1165
1189
1166
/* now the spi bus is configured, we can verify the flash id */
1190
1167
if (qspi_nor_read_id (dev ) != 0 ) {
@@ -1335,7 +1312,7 @@ static int qspi_nor_pm_action(const struct device *dev,
1335
1312
1336
1313
switch (action ) {
1337
1314
case PM_DEVICE_ACTION_SUSPEND :
1338
- ret = ANOMALY_122_INIT (dev );
1315
+ ret = qspi_device_init (dev );
1339
1316
if (ret < 0 ) {
1340
1317
return ret ;
1341
1318
}
@@ -1379,7 +1356,7 @@ static int qspi_nor_pm_action(const struct device *dev,
1379
1356
return ret ;
1380
1357
}
1381
1358
1382
- ANOMALY_122_UNINIT (dev );
1359
+ qspi_device_uninit (dev );
1383
1360
break ;
1384
1361
1385
1362
default :
@@ -1429,9 +1406,7 @@ static struct qspi_nor_data qspi_nor_dev_data = {
1429
1406
.trans = Z_SEM_INITIALIZER (qspi_nor_dev_data .trans , 1 , 1 ),
1430
1407
.sem = Z_SEM_INITIALIZER (qspi_nor_dev_data .sem , 1 , 1 ),
1431
1408
.sync = Z_SEM_INITIALIZER (qspi_nor_dev_data .sync , 0 , 1 ),
1432
- #if NRF52_ERRATA_122_PRESENT
1433
1409
.count = Z_SEM_INITIALIZER (qspi_nor_dev_data .count , 0 , K_SEM_MAX_LIMIT ),
1434
- #endif
1435
1410
#endif /* CONFIG_MULTITHREADING */
1436
1411
};
1437
1412
0 commit comments