Azure Sphere MT3620 M4 API Reference Manual
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
mhal_i2s.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_I2S_H__
37 #define __MHAL_I2S_H__
38 
39 #include "mhal_osai.h"
40 
213 typedef void (*i2s_dma_callback_func) (void *user_data);
214 
226 #define I2S_ELENGTH 2
227 
228 #define I2S_EPTR 1
229 
245 typedef enum {
251 
252 
258 typedef enum {
266 
267 
274 typedef enum {
282 
283 
292 typedef enum {
298 
299 
305 typedef enum {
311 
316 typedef enum {
321 } i2s_no;
328 typedef enum {
333 } i2s_fnen;
339 typedef enum {
347 
353 typedef enum {
367 
409 };
410 
411 
430 };
431 
437  /*for recording value from setting of user*/
438  hal_i2s_initial_type i2s_initial_type;
439  /* backup user config */
440  struct hal_i2s_config i2s_user_config;
441  /* backup TX DMA config */
442  struct osai_dma_config i2s_txdma_cfg;
443  /* backup RX DMA config */
444  struct osai_dma_config i2s_rxdma_cfg;
445 
446 };
447 
453 struct mtk_i2s_ctlr {
455  void __iomem *base;
463  void __iomem *i2s_tx_fifo_port;
465  void __iomem *i2s_rx_fifo_port;
467  void *mdata;
468 };
479 #ifdef __cplusplus
480 extern "C" {
481 #endif
482 
517 int mtk_mhal_i2s_cfg_type(struct mtk_i2s_ctlr *ctlr,
518  hal_i2s_initial_type i2s_initial_type);
528 int mtk_mhal_i2s_reset(struct mtk_i2s_ctlr *ctlr);
541 int mtk_mhal_i2s_clk_en(struct mtk_i2s_ctlr *ctlr, i2s_fnen en);
556 int mtk_mhal_i2s_set_config(struct mtk_i2s_ctlr *ctlr,
557  struct hal_i2s_config *config);
596  i2s_dma_callback_func callback_func);
623  i2s_dma_callback_func callback_func);
654  u32 *buffer,
655  u32 threshold,
656  u32 buffer_length);
668 int mtk_mhal_i2s_stop_tx_vfifo(struct mtk_i2s_ctlr *ctlr);
688  u32 *buffer,
689  u32 threshold,
690  u32 buffer_length);
702 int mtk_mhal_i2s_stop_rx_vfifo(struct mtk_i2s_ctlr *ctlr);
712 int mtk_mhal_i2s_enable_tx(struct mtk_i2s_ctlr *ctlr);
722 int mtk_mhal_i2s_disable_tx(struct mtk_i2s_ctlr *ctlr);
732 int mtk_mhal_i2s_enable_rx(struct mtk_i2s_ctlr *ctlr);
742 int mtk_mhal_i2s_disable_rx(struct mtk_i2s_ctlr *ctlr);
743 
756  u32 buffer_length);
769  u32 buffer_length);
779 int mtk_mhal_i2s_alloc_vfifo_ch(struct mtk_i2s_ctlr *ctlr);
780 
791 
792 #ifdef __cplusplus
793 }
794 #endif
795 
803 #endif /* __MHAL_I2S_H__ */
32000Hz
Definition: mhal_i2s.h:363
Real sample rate of I2S Rx is 1/2 of the sample rate.
Definition: mhal_i2s.h:296
I2S external mode.
Definition: mhal_i2s.h:341
int mtk_mhal_i2s_stop_tx_vfifo(struct mtk_i2s_ctlr *ctlr)
Disable the Tx VFIFO DMA transmit operation.
hal_i2s_link_bits_sample
I2S bits per sample.
Definition: mhal_i2s.h:258
I2S port is i2s0.
Definition: mhal_i2s.h:318
Function enable.
Definition: mhal_i2s.h:332
I2S configure structure.
Definition: mhal_i2s.h:416
Real sample rate of I2S Rx = sample rate.
Definition: mhal_i2s.h:294
This value means two channels.
Definition: mhal_i2s.h:309
hal_i2s_link_channel_per_sample
I2S link channel per sample.
Definition: mhal_i2s.h:245
M-HAL privite structure.
Definition: mhal_i2s.h:436
int mtk_mhal_i2s_alloc_vfifo_ch(struct mtk_i2s_ctlr *ctlr)
I2S allocate DMA channel.
int mtk_mhal_i2s_enable_audio_top(struct mtk_i2s_ctlr *ctlr)
Enable uplink FIFO and downlink FIFO of the I2S link.
hal_i2s_tx_mode
Enable or disable the right channel of I2S Tx sending the same data as the left channel of I2S Tx...
Definition: mhal_i2s.h:274
int mtk_mhal_i2s_release_vfifo_ch(struct mtk_i2s_ctlr *ctlr)
I2S release DMA channel.
hal_i2s_tx_mode tx_mode
Enable or disable the right channel of I2S Tx sending the same data as the left channel of I2S Tx...
Definition: mhal_i2s.h:424
i2s_fnen
Function enable/disable.
Definition: mhal_i2s.h:328
void * mdata
M-HAL privite structure, used by M-HAL only.
Definition: mhal_i2s.h:467
int mtk_mhal_i2s_start_tx_vfifo(struct mtk_i2s_ctlr *ctlr, u32 *buffer, u32 threshold, u32 buffer_length)
Start the Tx VFIFO DMA transmit operation.
24000Hz
Definition: mhal_i2s.h:361
i2s_no
I2S port number.
Definition: mhal_i2s.h:316
int mtk_mhal_i2s_reset(struct mtk_i2s_ctlr *ctlr)
Reset the I2S hardware.
I2S port is i2s1.
Definition: mhal_i2s.h:320
32 bits in each frame sync cycle.
Definition: mhal_i2s.h:260
int mtk_mhal_i2s_cfg_rx_dma_irq_enable(struct mtk_i2s_ctlr *ctlr, i2s_dma_callback_func callback_func)
Config Rx VFIFO DMA interrupt enable.
The right channel of Tx sends all 0.
Definition: mhal_i2s.h:276
void __iomem * i2s_tx_fifo_port
I2S TX FIFO port.
Definition: mhal_i2s.h:463
hal_i2s_channel_number
I2S channel number define.
Definition: mhal_i2s.h:305
int mtk_mhal_i2s_disable_rx(struct mtk_i2s_ctlr *ctlr)
Power off the I2S input link.
int mtk_mhal_i2s_move_rx_point(struct mtk_i2s_ctlr *ctlr, u32 buffer_length)
Move the SW point of Rx VFIFO DMA.
int mtk_mhal_i2s_disable_audio_top(struct mtk_i2s_ctlr *ctlr)
Disable the uplink FIFO and the downlink FIFO of I2S link.
void(* i2s_dma_callback_func)(void *user_data)
This defines the callback function prototype.
Definition: mhal_i2s.h:213
u8 i2s_rxdma_chnum
I2S RX DMA channel number.
Definition: mhal_i2s.h:461
hal_i2s_sample_rate
I2S sample rate define.
Definition: mhal_i2s.h:353
Function disable.
Definition: mhal_i2s.h:330
128 bits in each frame sync cycle.
Definition: mhal_i2s.h:264
struct hal_i2s_link_config i2s_in
I2S input link configuration.
Definition: mhal_i2s.h:418
hal_i2s_rx_down_rate rx_down_rate
Enable or disable the function of real sample rate of I2S Rx being 1/2 of SR, and I2S Rx will drop on...
Definition: mhal_i2s.h:429
void * user_data
User_data is an OS-HAL defined parameter provided by mtk_mhal_i2c_dma_done_callback_register().
Definition: mhal_i2c.h:266
64 bits in each frame sync cycle.
Definition: mhal_i2s.h:262
int mtk_mhal_i2s_move_tx_point(struct mtk_i2s_ctlr *ctlr, u32 buffer_length)
Move the SW point of Tx VFIFO DMA.
int mtk_mhal_i2s_stop_rx_vfifo(struct mtk_i2s_ctlr *ctlr)
Disable the Rx VFIFO DMA receive operation.
12000Hz
Definition: mhal_i2s.h:357
int mtk_mhal_i2s_set_config(struct mtk_i2s_ctlr *ctlr, struct hal_i2s_config *config)
Set the I2S configuration in detail.
i2s_no i2s_port
I2S port number.
Definition: mhal_i2s.h:457
Four channels in each frame sync cycle.
Definition: mhal_i2s.h:249
struct hal_i2s_link_config i2s_out
I2S output link configuration.
Definition: mhal_i2s.h:420
I2S internal loopback mode.
Definition: mhal_i2s.h:345
I2S external TDM mode.
Definition: mhal_i2s.h:343
int mtk_mhal_i2s_start_rx_vfifo(struct mtk_i2s_ctlr *ctlr, u32 *buffer, u32 threshold, u32 buffer_length)
Start the Rx VFIFO DMA receive operation.
int mtk_mhal_i2s_cfg_tx_dma_irq_enable(struct mtk_i2s_ctlr *ctlr, i2s_dma_callback_func callback_func)
Config Tx VFIFO DMA interrupt enable.
int mtk_mhal_i2s_cfg_tx_dma_irq_disable(struct mtk_i2s_ctlr *ctlr)
Config Tx VFIFO DMA interrupt disable.
hal_i2s_rx_down_rate
Enable or disable 2x down sample rate mode in the I2S Rx link.
Definition: mhal_i2s.h:292
hal_i2s_initial_type
This enum defines the initial type of I2S.
Definition: mhal_i2s.h:339
int mtk_mhal_i2s_clk_en(struct mtk_i2s_ctlr *ctlr, i2s_fnen en)
enable the I2S clock.
int mtk_mhal_i2s_enable_tx(struct mtk_i2s_ctlr *ctlr)
Power on the I2S the output link.
void __iomem * i2s_rx_fifo_port
I2S RX FIFO port.
Definition: mhal_i2s.h:465
8000Hz
Definition: mhal_i2s.h:355
Two channels in each frame sync cycle.
Definition: mhal_i2s.h:247
I2S control structure.
Definition: mhal_i2s.h:453
The right channel of Tx sends the same data as the left channelof I2S Tx.
Definition: mhal_i2s.h:280
int mtk_mhal_i2s_cfg_type(struct mtk_i2s_ctlr *ctlr, hal_i2s_initial_type i2s_initial_type)
Configure I2S type.
int mtk_mhal_i2s_enable_rx(struct mtk_i2s_ctlr *ctlr)
Power on the I2S input link.
int mtk_mhal_i2s_cfg_rx_dma_irq_disable(struct mtk_i2s_ctlr *ctlr)
Config Rx VFIFO DMA interrupt disable.
16000Hz
Definition: mhal_i2s.h:359
void __iomem * base
I2S port base address.
Definition: mhal_i2s.h:455
This value means one channel.
Definition: mhal_i2s.h:307
u8 i2s_txdma_chnum
I2S TX DMA channel number.
Definition: mhal_i2s.h:459
int mtk_mhal_i2s_disable_tx(struct mtk_i2s_ctlr *ctlr)
Power off the I2S output link.
48000Hz
Definition: mhal_i2s.h:365