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>
22 * The values below are specified in the hardware specification.
23 * So, they should not be changed until the hardware specification changes.
36 struct dim_ch_state_t {
37 bool ready; /* Shows readiness to enqueue next buffer */
38 u16 done_buffers; /* Number of completed buffers */
42 /* changed only in interrupt context */
43 volatile int request_counter;
45 /* changed only in task context */
46 volatile int service_counter;
50 u8 level; /* [0..2], buffering level */
54 struct int_ch_state state;
58 u16 packet_length; /*< Isochronous packet length in bytes. */
59 u16 bytes_per_frame; /*< Synchronous bytes per frame. */
60 u16 done_sw_buffers_number; /*< Done software buffers number. */
63 u8 dim_startup(struct dim2_regs __iomem *dim_base_address, u32 mlb_clock,
66 void dim_shutdown(void);
68 bool dim_get_lock_state(void);
70 u16 dim_norm_ctrl_async_buffer_size(u16 buf_size);
72 u16 dim_norm_isoc_buffer_size(u16 buf_size, u16 packet_length);
74 u16 dim_norm_sync_buffer_size(u16 buf_size, u16 bytes_per_frame);
76 u8 dim_init_control(struct dim_channel *ch, u8 is_tx, u16 ch_address,
79 u8 dim_init_async(struct dim_channel *ch, u8 is_tx, u16 ch_address,
82 u8 dim_init_isoc(struct dim_channel *ch, u8 is_tx, u16 ch_address,
85 u8 dim_init_sync(struct dim_channel *ch, u8 is_tx, u16 ch_address,
88 u8 dim_destroy_channel(struct dim_channel *ch);
90 void dim_service_mlb_int_irq(void);
92 void dim_service_ahb_int_irq(struct dim_channel *const *channels);
94 u8 dim_service_channel(struct dim_channel *ch);
96 struct dim_ch_state_t *dim_get_channel_state(struct dim_channel *ch,
97 struct dim_ch_state_t *state_ptr);
99 u16 dim_dbr_space(struct dim_channel *ch);
101 bool dim_enqueue_buffer(struct dim_channel *ch, u32 buffer_addr,
104 bool dim_detach_buffers(struct dim_channel *ch, u16 buffers_number);
106 u32 dimcb_io_read(u32 __iomem *ptr32);
108 void dimcb_io_write(u32 __iomem *ptr32, u32 value);
110 void dimcb_on_error(u8 error_id, const char *error_message);
112 #endif /* _DIM2_HAL_H */