2 * dim2_hal.h - DIM2 HAL interface
3 * (MediaLB, Device Interface Macro IP, OS62420)
5 * Copyright (C) 2015, Microchip Technology Germany II GmbH & Co. KG
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * This file is licensed under GPLv2.
18 #include <linux/types.h>
25 * The values below are specified in the hardware specification.
26 * So, they should not be changed until the hardware specification changes.
39 struct dim_ch_state_t
{
40 bool ready
; /* Shows readiness to enqueue next buffer */
41 u16 done_buffers
; /* Number of completed buffers */
44 typedef int atomic_counter_t
;
47 /* changed only in interrupt context */
48 volatile atomic_counter_t request_counter
;
50 /* changed only in task context */
51 volatile atomic_counter_t service_counter
;
55 u8 level
; /* [0..2], buffering level */
59 struct int_ch_state state
;
63 u16 packet_length
; /*< Isochronous packet length in bytes. */
64 u16 bytes_per_frame
; /*< Synchronous bytes per frame. */
65 u16 done_sw_buffers_number
; /*< Done software buffers number. */
68 u8
dim_startup(void *dim_base_address
, u32 mlb_clock
);
70 void dim_shutdown(void);
72 bool DIM_GetLockState(void);
74 u16
DIM_NormCtrlAsyncBufferSize(u16 buf_size
);
76 u16
DIM_NormIsocBufferSize(u16 buf_size
, u16 packet_length
);
78 u16
DIM_NormSyncBufferSize(u16 buf_size
, u16 bytes_per_frame
);
80 u8
DIM_InitControl(struct dim_channel
*ch
, u8 is_tx
, u16 ch_address
,
83 u8
DIM_InitAsync(struct dim_channel
*ch
, u8 is_tx
, u16 ch_address
,
86 u8
DIM_InitIsoc(struct dim_channel
*ch
, u8 is_tx
, u16 ch_address
,
89 u8
DIM_InitSync(struct dim_channel
*ch
, u8 is_tx
, u16 ch_address
,
92 u8
DIM_DestroyChannel(struct dim_channel
*ch
);
94 void DIM_ServiceIrq(struct dim_channel
*const *channels
);
96 u8
DIM_ServiceChannel(struct dim_channel
*ch
);
98 struct dim_ch_state_t
*DIM_GetChannelState(struct dim_channel
*ch
,
99 struct dim_ch_state_t
*dim_ch_state_ptr
);
101 bool DIM_EnqueueBuffer(struct dim_channel
*ch
, u32 buffer_addr
,
104 bool dim_detach_buffers(struct dim_channel
*ch
, u16 buffers_number
);
106 u32
DIMCB_IoRead(u32
*ptr32
);
108 void DIMCB_IoWrite(u32
*ptr32
, u32 value
);
110 void DIMCB_OnError(u8 error_id
, const char *error_message
);
116 #endif /* _DIM2_HAL_H */