12
12
#include <string.h>
13
13
14
14
#include <driverlib/flash.h>
15
- #include <driverlib/vims.h>
16
15
17
16
#define DT_DRV_COMPAT ti_cc23x0_flash_controller
18
17
#define SOC_NV_FLASH_NODE DT_INST(0, soc_nv_flash)
@@ -40,44 +39,9 @@ static int flash_cc23x0_init(const struct device *dev)
40
39
return 0 ;
41
40
}
42
41
43
- static void flash_cc23x0_cache_restore (uint32_t vims_mode )
44
- {
45
- while (VIMSModeGet (VIMS_BASE ) == VIMS_MODE_CHANGING ) {
46
- ;
47
- }
48
-
49
- /* Restore VIMS mode and line buffers */
50
- if (vims_mode != VIMS_MODE_DISABLED ) {
51
- VIMSModeSafeSet (VIMS_BASE , vims_mode , true);
52
- }
53
-
54
- VIMSLineBufEnable (VIMS_BASE );
55
- }
56
-
57
- static uint32_t flash_cc23x0_cache_disable (void )
58
- {
59
- uint32_t vims_mode ;
60
-
61
- /* VIMS and both line buffers should be off during flash update */
62
- VIMSLineBufDisable (VIMS_BASE );
63
-
64
- while (VIMSModeGet (VIMS_BASE ) == VIMS_MODE_CHANGING ) {
65
- ;
66
- }
67
-
68
- /* Save current VIMS mode for restoring it later */
69
- vims_mode = VIMSModeGet (VIMS_BASE );
70
- if (vims_mode != VIMS_MODE_DISABLED ) {
71
- VIMSModeSafeSet (VIMS_BASE , VIMS_MODE_DISABLED , true);
72
- }
73
-
74
- return vims_mode ;
75
- }
76
-
77
42
static int flash_cc23x0_erase (const struct device * dev , off_t offs , size_t size )
78
43
{
79
44
struct flash_cc23x0_data * data = dev -> data ;
80
- uint32_t vims_mode ;
81
45
unsigned int key ;
82
46
int i ;
83
47
int rc = 0 ;
@@ -96,7 +60,6 @@ static int flash_cc23x0_erase(const struct device *dev, off_t offs, size_t size)
96
60
return - EACCES ;
97
61
}
98
62
99
- vims_mode = flash_cc23x0_cache_disable ();
100
63
/*
101
64
* Disable all interrupts to prevent flash read, from TI's TRF:
102
65
*
@@ -121,16 +84,13 @@ static int flash_cc23x0_erase(const struct device *dev, off_t offs, size_t size)
121
84
122
85
irq_unlock (key );
123
86
124
- flash_cc23x0_cache_restore (vims_mode );
125
-
126
87
k_sem_give (& data -> mutex );
127
88
return rc ;
128
89
}
129
90
130
91
static int flash_cc23x0_write (const struct device * dev , off_t offs , const void * data , size_t size )
131
92
{
132
93
struct flash_cc23x0_data * flash_data = dev -> data ;
133
- uint32_t vims_mode ;
134
94
unsigned int key ;
135
95
int rc = 0 ;
136
96
@@ -159,8 +119,6 @@ static int flash_cc23x0_write(const struct device *dev, off_t offs, const void *
159
119
return - EACCES ;
160
120
}
161
121
162
- vims_mode = flash_cc23x0_cache_disable ();
163
-
164
122
key = irq_lock ();
165
123
166
124
while (FlashCheckFsmForReady () != FAPI_STATUS_FSM_READY ) {
@@ -174,8 +132,6 @@ static int flash_cc23x0_write(const struct device *dev, off_t offs, const void *
174
132
175
133
irq_unlock (key );
176
134
177
- flash_cc23x0_cache_restore (vims_mode );
178
-
179
135
k_sem_give (& flash_data -> mutex );
180
136
181
137
return rc ;
0 commit comments