summaryrefslogtreecommitdiffstats
path: root/recipes-kernel/hdm-dim2/files/dim2_hal.h
diff options
context:
space:
mode:
authorChristian Gromm <christian.gromm@microchip.com>2015-12-16 13:42:25 +0100
committerGerrit Code Review <gerrit@172.30.200.200>2015-12-21 14:23:03 +0000
commit45e14d9435eef26cb8afb152a56d9f303192fbdd (patch)
treef070a5714a55d09479800110ba219a16c0fb9b2e /recipes-kernel/hdm-dim2/files/dim2_hal.h
parent565235cf6861f03a8d9d6b2613213509949b44d9 (diff)
recipes-kernel: add MOST driver kernel modules
This commit adds the recipes-kernel directory to the meta-agl-demo layer. It is needed to add the MOST driver to the AGL layer and have it compiled as out-of-tree modules. Change-Id: I38174a2f9a59b0424cfaf2f85f059550422f58f2 Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Diffstat (limited to 'recipes-kernel/hdm-dim2/files/dim2_hal.h')
-rw-r--r--recipes-kernel/hdm-dim2/files/dim2_hal.h116
1 files changed, 116 insertions, 0 deletions
diff --git a/recipes-kernel/hdm-dim2/files/dim2_hal.h b/recipes-kernel/hdm-dim2/files/dim2_hal.h
new file mode 100644
index 000000000..48cdd9c8c
--- /dev/null
+++ b/recipes-kernel/hdm-dim2/files/dim2_hal.h
@@ -0,0 +1,116 @@
+/*
+ * dim2_hal.h - DIM2 HAL interface
+ * (MediaLB, Device Interface Macro IP, OS62420)
+ *
+ * Copyright (C) 2015, Microchip Technology Germany II GmbH & Co. KG
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * This file is licensed under GPLv2.
+ */
+
+#ifndef _DIM2_HAL_H
+#define _DIM2_HAL_H
+
+#include <linux/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * The values below are specified in the hardware specification.
+ * So, they should not be changed until the hardware specification changes.
+ */
+enum mlb_clk_speed {
+ CLK_256FS = 0,
+ CLK_512FS = 1,
+ CLK_1024FS = 2,
+ CLK_2048FS = 3,
+ CLK_3072FS = 4,
+ CLK_4096FS = 5,
+ CLK_6144FS = 6,
+ CLK_8192FS = 7,
+};
+
+struct dim_ch_state_t {
+ bool ready; /* Shows readiness to enqueue next buffer */
+ u16 done_buffers; /* Number of completed buffers */
+};
+
+typedef int atomic_counter_t;
+
+struct int_ch_state {
+ /* changed only in interrupt context */
+ volatile atomic_counter_t request_counter;
+
+ /* changed only in task context */
+ volatile atomic_counter_t service_counter;
+
+ u8 idx1;
+ u8 idx2;
+ u8 level; /* [0..2], buffering level */
+};
+
+struct dim_channel {
+ struct int_ch_state state;
+ u8 addr;
+ u16 dbr_addr;
+ u16 dbr_size;
+ u16 packet_length; /*< Isochronous packet length in bytes. */
+ u16 bytes_per_frame; /*< Synchronous bytes per frame. */
+ u16 done_sw_buffers_number; /*< Done software buffers number. */
+};
+
+u8 dim_startup(void *dim_base_address, u32 mlb_clock);
+
+void dim_shutdown(void);
+
+bool dim_get_lock_state(void);
+
+u16 dim_norm_ctrl_async_buffer_size(u16 buf_size);
+
+u16 dim_norm_isoc_buffer_size(u16 buf_size, u16 packet_length);
+
+u16 dim_norm_sync_buffer_size(u16 buf_size, u16 bytes_per_frame);
+
+u8 dim_init_control(struct dim_channel *ch, u8 is_tx, u16 ch_address,
+ u16 max_buffer_size);
+
+u8 dim_init_async(struct dim_channel *ch, u8 is_tx, u16 ch_address,
+ u16 max_buffer_size);
+
+u8 dim_init_isoc(struct dim_channel *ch, u8 is_tx, u16 ch_address,
+ u16 packet_length);
+
+u8 dim_init_sync(struct dim_channel *ch, u8 is_tx, u16 ch_address,
+ u16 bytes_per_frame);
+
+u8 dim_destroy_channel(struct dim_channel *ch);
+
+void dim_service_irq(struct dim_channel *const *channels);
+
+u8 dim_service_channel(struct dim_channel *ch);
+
+struct dim_ch_state_t *dim_get_channel_state(struct dim_channel *ch,
+ struct dim_ch_state_t *state_ptr);
+
+bool dim_enqueue_buffer(struct dim_channel *ch, u32 buffer_addr,
+ u16 buffer_size);
+
+bool dim_detach_buffers(struct dim_channel *ch, u16 buffers_number);
+
+u32 dimcb_io_read(u32 *ptr32);
+
+void dimcb_io_write(u32 *ptr32, u32 value);
+
+void dimcb_on_error(u8 error_id, const char *error_message);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DIM2_HAL_H */