@@ -167,7 +167,11 @@ static int uart_npcx_rx_fifo_available(const struct device *dev)
167
167
struct uart_reg * const inst = config -> inst ;
168
168
169
169
/* True if at least one byte is in the Rx FIFO */
170
+ #if defined(CONFIG_UART_NPCX_FIFO_EX )
171
+ return inst -> URXFLV != 0 ;
172
+ #else
170
173
return IS_BIT_SET (inst -> UFRSTS , NPCX_UFRSTS_RFIFO_NEMPTY_STS );
174
+ #endif
171
175
}
172
176
173
177
static void uart_npcx_dis_all_tx_interrupts (const struct device * dev )
@@ -176,8 +180,12 @@ static void uart_npcx_dis_all_tx_interrupts(const struct device *dev)
176
180
struct uart_reg * const inst = config -> inst ;
177
181
178
182
/* Disable all Tx interrupts */
183
+ #if defined(CONFIG_UART_NPCX_FIFO_EX )
184
+ inst -> UICTRL &= ~BIT (NPCX_UICTRL_ETI );
185
+ #else
179
186
inst -> UFTCTL &= ~(BIT (NPCX_UFTCTL_TEMPTY_LVL_EN ) | BIT (NPCX_UFTCTL_TEMPTY_EN ) |
180
187
BIT (NPCX_UFTCTL_NXMIP_EN ));
188
+ #endif
181
189
}
182
190
183
191
static void uart_npcx_clear_rx_fifo (const struct device * dev )
@@ -201,7 +209,11 @@ static int uart_npcx_tx_fifo_ready(const struct device *dev)
201
209
struct uart_reg * const inst = config -> inst ;
202
210
203
211
/* True if the Tx FIFO is not completely full */
212
+ #if defined(CONFIG_UART_NPCX_FIFO_EX )
213
+ return inst -> UTXFLV != NPCK_SZ_UART_FIFO ;
214
+ #else
204
215
return !(GET_FIELD (inst -> UFTSTS , NPCX_UFTSTS_TEMPTY_LVL ) == 0 );
216
+ #endif
205
217
}
206
218
207
219
static int uart_npcx_fifo_fill (const struct device * dev , const uint8_t * tx_data , int size )
@@ -246,30 +258,44 @@ static void uart_npcx_irq_tx_enable(const struct device *dev)
246
258
{
247
259
const struct uart_npcx_config * const config = dev -> config ;
248
260
struct uart_reg * const inst = config -> inst ;
261
+
262
+ #if defined(CONFIG_UART_NPCX_FIFO_EX )
263
+ inst -> UICTRL |= BIT (NPCX_UICTRL_ETI );
264
+ #else
249
265
struct uart_npcx_data * data = dev -> data ;
250
266
k_spinlock_key_t key = k_spin_lock (& data -> lock );
251
267
252
268
inst -> UFTCTL |= BIT (NPCX_UFTCTL_TEMPTY_EN );
253
269
k_spin_unlock (& data -> lock , key );
270
+ #endif
254
271
}
255
272
256
273
static void uart_npcx_irq_tx_disable (const struct device * dev )
257
274
{
258
275
const struct uart_npcx_config * const config = dev -> config ;
259
276
struct uart_reg * const inst = config -> inst ;
277
+
278
+ #if defined(CONFIG_UART_NPCX_FIFO_EX )
279
+ inst -> UICTRL &= ~(BIT (NPCX_UICTRL_ETI ));
280
+ #else
260
281
struct uart_npcx_data * data = dev -> data ;
261
282
k_spinlock_key_t key = k_spin_lock (& data -> lock );
262
283
263
284
inst -> UFTCTL &= ~(BIT (NPCX_UFTCTL_TEMPTY_EN ));
264
285
k_spin_unlock (& data -> lock , key );
286
+ #endif
265
287
}
266
288
267
289
static bool uart_npcx_irq_tx_is_enabled (const struct device * dev )
268
290
{
269
291
const struct uart_npcx_config * const config = dev -> config ;
270
292
struct uart_reg * const inst = config -> inst ;
271
293
294
+ #if defined(CONFIG_UART_NPCX_FIFO_EX )
295
+ return IS_BIT_SET (inst -> UICTRL , NPCX_UICTRL_ETI );
296
+ #else
272
297
return IS_BIT_SET (inst -> UFTCTL , NPCX_UFTCTL_TEMPTY_EN );
298
+ #endif
273
299
}
274
300
275
301
static int uart_npcx_irq_tx_ready (const struct device * dev )
@@ -283,31 +309,47 @@ static int uart_npcx_irq_tx_complete(const struct device *dev)
283
309
struct uart_reg * const inst = config -> inst ;
284
310
285
311
/* Tx FIFO is empty or last byte is sending */
312
+ #if defined(CONFIG_UART_NPCX_FIFO_EX )
313
+ return inst -> UTXFLV == 0 ;
314
+ #else
286
315
return IS_BIT_SET (inst -> UFTSTS , NPCX_UFTSTS_NXMIP );
316
+ #endif
287
317
}
288
318
289
319
static void uart_npcx_irq_rx_enable (const struct device * dev )
290
320
{
291
321
const struct uart_npcx_config * const config = dev -> config ;
292
322
struct uart_reg * const inst = config -> inst ;
293
323
324
+ #if defined(CONFIG_UART_NPCX_FIFO_EX )
325
+ inst -> UICTRL |= BIT (NPCX_UICTRL_ERI );
326
+ #else
294
327
inst -> UFRCTL |= BIT (NPCX_UFRCTL_RNEMPTY_EN );
328
+ #endif
295
329
}
296
330
297
331
static void uart_npcx_irq_rx_disable (const struct device * dev )
298
332
{
299
333
const struct uart_npcx_config * const config = dev -> config ;
300
334
struct uart_reg * const inst = config -> inst ;
301
335
336
+ #if defined(CONFIG_UART_NPCX_FIFO_EX )
337
+ inst -> UICTRL &= ~(BIT (NPCX_UICTRL_ERI ));
338
+ #else
302
339
inst -> UFRCTL &= ~(BIT (NPCX_UFRCTL_RNEMPTY_EN ));
340
+ #endif
303
341
}
304
342
305
343
static bool uart_npcx_irq_rx_is_enabled (const struct device * dev )
306
344
{
307
345
const struct uart_npcx_config * const config = dev -> config ;
308
346
struct uart_reg * const inst = config -> inst ;
309
347
348
+ #if defined(CONFIG_UART_NPCX_FIFO_EX )
349
+ return IS_BIT_SET (inst -> UICTRL , NPCX_UICTRL_ERI );
350
+ #else
310
351
return IS_BIT_SET (inst -> UFRCTL , NPCX_UFRCTL_RNEMPTY_EN );
352
+ #endif
311
353
}
312
354
313
355
static int uart_npcx_irq_rx_ready (const struct device * dev )
@@ -895,6 +937,7 @@ static void uart_npcx_isr(const struct device *dev)
895
937
}
896
938
#endif
897
939
940
+ #if !defined(CONFIG_UART_NPCX_FIFO_EX )
898
941
#if defined(CONFIG_PM ) || defined(CONFIG_UART_ASYNC_API )
899
942
if (IS_BIT_SET (inst -> UFTCTL , NPCX_UFTCTL_NXMIP_EN ) &&
900
943
IS_BIT_SET (inst -> UFTSTS , NPCX_UFTSTS_NXMIP )) {
@@ -915,6 +958,7 @@ static void uart_npcx_isr(const struct device *dev)
915
958
#endif
916
959
}
917
960
#endif
961
+ #endif
918
962
}
919
963
#endif
920
964
@@ -1060,8 +1104,12 @@ static int uart_npcx_init(const struct device *dev)
1060
1104
1061
1105
/* Initialize UART FIFO if mode is interrupt driven */
1062
1106
#if defined(CONFIG_UART_INTERRUPT_DRIVEN ) || defined(CONFIG_UART_ASYNC_API )
1107
+ #if defined(CONFIG_UART_NPCX_FIFO_EX )
1108
+ inst -> UFCTRL |= BIT (NPCK_FIFO_EN );
1109
+ #else
1063
1110
/* Enable the UART FIFO mode */
1064
1111
inst -> UMDSL |= BIT (NPCX_UMDSL_FIFO_MD );
1112
+ #endif
1065
1113
1066
1114
/* Disable all UART tx FIFO interrupts */
1067
1115
uart_npcx_dis_all_tx_interrupts (dev );
0 commit comments