Azure Sphere MT3620 M4 API Reference Manual
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
mhal_uart.h
1 /*
2  * (C) 2005-2020 MediaTek Inc. All rights reserved.
3  *
4  * Copyright Statement:
5  *
6  * This MT3620 driver software/firmware and related documentation
7  * ("MediaTek Software") are protected under relevant copyright laws.
8  * The information contained herein is confidential and proprietary to
9  * MediaTek Inc. ("MediaTek"). You may only use, reproduce, modify, or
10  * distribute (as applicable) MediaTek Software if you have agreed to and been
11  * bound by this Statement and the applicable license agreement with MediaTek
12  * ("License Agreement") and been granted explicit permission to do so within
13  * the License Agreement ("Permitted User"). If you are not a Permitted User,
14  * please cease any access or use of MediaTek Software immediately.
15  *
16  * BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
17  * THAT MEDIATEK SOFTWARE RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE
18  * PROVIDED TO RECEIVER ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS
19  * ANY AND ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
21  * NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
22  * RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
23  * INCORPORATED IN, OR SUPPLIED WITH MEDIATEK SOFTWARE, AND RECEIVER AGREES TO
24  * LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
25  * RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
26  * OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
27  * SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
28  * RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
29  * STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
30  * ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO MEDIATEK SOFTWARE RELEASED
31  * HEREUNDER WILL BE ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY
32  * RECEIVER TO MEDIATEK DURING THE PRECEDING TWELVE (12) MONTHS FOR SUCH
33  * MEDIATEK SOFTWARE AT ISSUE.
34  */
35 
36 #ifndef __MHAL_UART_H__
37 #define __MHAL_UART_H__
38 
39 #include "mhal_osai.h"
40 
112 typedef enum {
122 
125 typedef enum {
137 
140 typedef enum {
172 typedef int (*uart_dma_done_callback) (void *user_data);
173 
191 
193  unsigned char *tx_buf;
195  unsigned char *rx_buf;
197  dma_addr_t tx_dma;
199  dma_addr_t rx_dma;
200 
202  u32 tx_len;
204  u32 rx_len;
206  u32 tx_size;
208  u32 rx_size;
209 
213  void *user_data;
222 };
223 
231  void __iomem *base;
233  void __iomem *cg_base;
235  u32 baudrate;
246 };
258 #define UART_EPTR (1)
259 
260 #define UART_ENXIO (6)
261 
262 #define UART_EINVAL (22)
263 
264 #define UART_ETIMEDOUT (110)
265 
267 #define UART_INT_DISABLE 0x00
268 
269 #define UART_INT_RX_BUFFER_FULL 0x01
270 
271 #define UART_INT_TX_BUFFER_EMPTY 0x02
272 
273 #define UART_INT_LINE_STATUS 0x04
274 
275 #define UART_INT_SW_FLOW_CONTROL 0x20
276 
277 #define UART_INT_HW_FLOW_CONTROL_RTS 0x40
278 
279 #define UART_INT_HW_FLOW_CONTROL_CTS 0x80
280 
282 #define UART_EFR_HW_FC_DISABLE 0x00
283 
284 #define UART_EFR_HW_FC_RTS 0x40
285 
286 #define UART_EFR_HW_FC_CTS 0x80
287 
288 #define UART_EFR_HW_FC_RTS_CTS 0xC0
289 
299 #ifdef __cplusplus
300 extern "C" {
301 #endif
302 
314 
324 
334 
344 
355 
367 
379 
392 int mtk_mhal_uart_set_hw_fc(struct mtk_uart_controller *ctlr, u8 hw_fc);
393 
404 
421  u8 xon1, u8 xoff1, u8 xon2, u8 xoff2, u8 escape_data);
422 
432 int mtk_mhal_uart_set_dma(struct mtk_uart_controller *ctlr, bool enable_dma);
433 
443 
454 int mtk_mhal_uart_set_irq(struct mtk_uart_controller *ctlr, u8 int_flag);
455 
466 int mtk_mhal_uart_putc(struct mtk_uart_controller *ctlr, u8 data);
467 
477 int mtk_mhal_uart_getc(struct mtk_uart_controller *ctlr);
478 
489 
500 
511 
522 
533 
544 
555 
566 
577 
588 
599 
609 
619 
641  struct mtk_uart_controller *ctlr,
642  uart_dma_done_callback callback,
643  void *user_data);
644 
666  struct mtk_uart_controller *ctlr,
667  uart_dma_done_callback callback,
668  void *user_data);
669 
670 #ifdef __cplusplus
671 }
672 #endif
673 
683 #endif /*_MHAL_UART_H_*/
u32 rx_size
tx transfer len
Definition: mhal_uart.h:208
unsigned char * tx_buf
used for tx temp buf
Definition: mhal_uart.h:193
u32 tx_len
temp tx transfer len
Definition: mhal_uart.h:202
mhal_uart_data_len
This enum defines UART data length.
Definition: mhal_uart.h:112
int mtk_mhal_uart_set_dma(struct mtk_uart_controller *ctlr, bool enable_dma)
This function is used to set the DMA setting relative to the UART.
7 bits word length
Definition: mhal_uart.h:118
u32 baudrate
UART baudrate.
Definition: mhal_uart.h:235
Disbale parity.
Definition: mhal_uart.h:127
u32 rx_len
temp rx transfer len
Definition: mhal_uart.h:204
u8 port_num
UART controller port num.
Definition: mhal_uart.h:229
int mtk_mhal_uart_set_format(struct mtk_uart_controller *ctlr)
This function is used to set UART data format.
mhal_uart_stop_bit stop_bit
UART stop bit.
Definition: mhal_uart.h:241
int mtk_mhal_uart_sw_reset(struct mtk_uart_controller *ctlr)
This function is used to reset UART.
int mtk_mhal_uart_start_dma_tx(struct mtk_uart_controller *ctlr)
This function is used to start UART DMA TX transaction.
int mtk_mhal_uart_disable_sw_fc(struct mtk_uart_controller *ctlr)
This function is used to disable UART software flow control.
dma_addr_t rx_dma
temp rx DMA physical addr
Definition: mhal_uart.h:199
1 stop bit
Definition: mhal_uart.h:142
u8 vff_dma_mode
UART DMA mode.
Definition: mhal_uart.h:243
mhal_uart_parity parity
UART parity.
Definition: mhal_uart.h:239
6 bits word length
Definition: mhal_uart.h:116
void * user_data
user_data is used to store spis hw setting.
Definition: mhal_spis.h:788
int mtk_mhal_uart_dma_tx_config(struct mtk_uart_controller *ctlr)
This function is used to config UART DMA TX channel.
5 bits word length
Definition: mhal_uart.h:114
int mtk_mhal_uart_getc_nowait(struct mtk_uart_controller *ctlr)
This function is used to get data directly in PIO mode.
M-HAL private structure.
Definition: mhal_uart.h:186
int mtk_mhal_uart_stop_dma_rx(struct mtk_uart_controller *ctlr)
This function is used to stop UART DMA RX transaction.
void * user_data
user_data is a OS-HAL defined parameter provided by #mtk_mhal_uart_dma_done_callback_register().
Definition: mhal_uart.h:213
Interface to UART.
Definition: mhal_uart.h:227
int(* uart_dma_done_callback)(void *user_data)
This defines the callback function prototype.
Definition: mhal_uart.h:172
int mtk_mhal_uart_release_dma_tx_ch(struct mtk_uart_controller *ctlr)
This function is used to release UART DMA TX channel.
Enable space parity.
Definition: mhal_uart.h:135
mhal_uart_data_len data_bit
UART data bit.
Definition: mhal_uart.h:237
u8 dma_tx_ch
temp tx transfer len
Definition: mhal_uart.h:188
int mtk_mhal_uart_set_hw_fc(struct mtk_uart_controller *ctlr, u8 hw_fc)
This function is used to enable UART hardware flow control.
mhal_uart_parity
This enum defines UART parity parameter.
Definition: mhal_uart.h:125
uart_dma_done_callback uart_rx_dma_callback
This function is used to register user's RX DMA done callback to OS-HAL layer.
Definition: mhal_uart.h:221
2 stop bits
Definition: mhal_uart.h:144
struct mtk_uart_private * mdata
M-HAL privite structure, used by M-HAL only.
Definition: mhal_uart.h:245
u8 dma_rx_ch
temp rx transfer len
Definition: mhal_uart.h:190
int mtk_mhal_uart_enable_clk(struct mtk_uart_controller *ctlr)
This function is used to enable UART clock.
dma_addr_t tx_dma
temp tx DMA physical addr
Definition: mhal_uart.h:197
int mtk_mhal_uart_dumpreg(struct mtk_uart_controller *ctlr)
This function is used to dump UART register.
int mtk_mhal_uart_dma_tx_callback_register(struct mtk_uart_controller *ctlr, uart_dma_done_callback callback, void *user_data)
This defines the callback function prototype.
int mtk_mhal_uart_update_dma_rx_info(struct mtk_uart_controller *ctlr)
This function is used to update DMA RX information when RX fail.
void __iomem * cg_base
Clock gate base address.
Definition: mhal_uart.h:233
int mtk_mhal_uart_set_sw_fc(struct mtk_uart_controller *ctlr, u8 xon1, u8 xoff1, u8 xon2, u8 xoff2, u8 escape_data)
This function is used to configure UART software flow control.
int mtk_mhal_uart_dma_rx_callback_register(struct mtk_uart_controller *ctlr, uart_dma_done_callback callback, void *user_data)
This defines the callback function prototype.
int mtk_mhal_uart_getc(struct mtk_uart_controller *ctlr)
This function is used to get data in PIO mode.
int mtk_mhal_uart_putc(struct mtk_uart_controller *ctlr, u8 data)
This function is used to send one byte of data in PIO mode.
int mtk_mhal_uart_clear_irq_status(struct mtk_uart_controller *ctlr)
This function is used to get and clear UART IRQ.
int mtk_mhal_uart_update_dma_tx_info(struct mtk_uart_controller *ctlr)
This function is used to update DMA TX information when TX fail.
int mtk_mhal_uart_dma_rx_config(struct mtk_uart_controller *ctlr)
This function is used to config UART DMA RX channel.
int mtk_mhal_uart_release_dma_rx_ch(struct mtk_uart_controller *ctlr)
This function is used to release UART DMA RX channel.
Enable mark parity.
Definition: mhal_uart.h:133
Enable even parity.
Definition: mhal_uart.h:131
u32 tx_size
tx transfer len
Definition: mhal_uart.h:206
int mtk_mhal_uart_stop_dma_tx(struct mtk_uart_controller *ctlr)
This function is used to stop UART DMA TX transaction.
Enable odd parity.
Definition: mhal_uart.h:129
int mtk_mhal_uart_disable_clk(struct mtk_uart_controller *ctlr)
This function is used to disable UART clock.
8 bits word length
Definition: mhal_uart.h:120
void __iomem * base
UART controller base address.
Definition: mhal_uart.h:231
int mtk_mhal_uart_allocate_dma_rx_ch(struct mtk_uart_controller *ctlr)
This function is used to allocate UART DMA RX channel.
int mtk_mhal_uart_allocate_dma_tx_ch(struct mtk_uart_controller *ctlr)
This function is used to allocate UART DMA TX channel.
int mtk_mhal_uart_start_dma_rx(struct mtk_uart_controller *ctlr)
This function is used to start UART DMA RX transaction.
int mtk_mhal_uart_hw_init(struct mtk_uart_controller *ctlr)
This function is used to initialize UART port.
uart_dma_done_callback uart_tx_dma_callback
This function is used to register user's TX DMA done callback to OS-HAL layer.
Definition: mhal_uart.h:217
int mtk_mhal_uart_set_baudrate(struct mtk_uart_controller *ctlr)
This function is used to change UART baudrate.
mhal_uart_stop_bit
This enum defines stop bit length.
Definition: mhal_uart.h:140
unsigned char * rx_buf
used for rx temp buf
Definition: mhal_uart.h:195
int mtk_mhal_uart_set_irq(struct mtk_uart_controller *ctlr, u8 int_flag)
This function is used to set UART IRQ function.