162306a36Sopenharmony_ci/*
262306a36Sopenharmony_ci * This file is subject to the terms and conditions of the GNU General Public
362306a36Sopenharmony_ci * License.  See the file "COPYING" in the main directory of this archive
462306a36Sopenharmony_ci * for more details.
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * Copyright (C) 2004, 2005 MIPS Technologies, Inc.  All rights reserved.
762306a36Sopenharmony_ci * Copyright (C) 2013 Imagination Technologies Ltd.
862306a36Sopenharmony_ci */
962306a36Sopenharmony_ci#ifndef __ASM_RTLX_H_
1062306a36Sopenharmony_ci#define __ASM_RTLX_H_
1162306a36Sopenharmony_ci
1262306a36Sopenharmony_ci#include <irq.h>
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ci#define RTLX_MODULE_NAME "rtlx"
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#define LX_NODE_BASE 10
1762306a36Sopenharmony_ci
1862306a36Sopenharmony_ci#define MIPS_CPU_RTLX_IRQ 0
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci#define RTLX_VERSION 2
2162306a36Sopenharmony_ci#define RTLX_xID 0x12345600
2262306a36Sopenharmony_ci#define RTLX_ID (RTLX_xID | RTLX_VERSION)
2362306a36Sopenharmony_ci#define RTLX_BUFFER_SIZE 2048
2462306a36Sopenharmony_ci#define RTLX_CHANNELS 8
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci#define RTLX_CHANNEL_STDIO	0
2762306a36Sopenharmony_ci#define RTLX_CHANNEL_DBG	1
2862306a36Sopenharmony_ci#define RTLX_CHANNEL_SYSIO	2
2962306a36Sopenharmony_ci
3062306a36Sopenharmony_civoid rtlx_starting(int vpe);
3162306a36Sopenharmony_civoid rtlx_stopping(int vpe);
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ciint rtlx_open(int index, int can_sleep);
3462306a36Sopenharmony_ciint rtlx_release(int index);
3562306a36Sopenharmony_cissize_t rtlx_read(int index, void __user *buff, size_t count);
3662306a36Sopenharmony_cissize_t rtlx_write(int index, const void __user *buffer, size_t count);
3762306a36Sopenharmony_ciunsigned int rtlx_read_poll(int index, int can_sleep);
3862306a36Sopenharmony_ciunsigned int rtlx_write_poll(int index);
3962306a36Sopenharmony_ci
4062306a36Sopenharmony_ciint __init rtlx_module_init(void);
4162306a36Sopenharmony_civoid __exit rtlx_module_exit(void);
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_civoid _interrupt_sp(void);
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ciextern struct vpe_notifications rtlx_notify;
4662306a36Sopenharmony_ciextern const struct file_operations rtlx_fops;
4762306a36Sopenharmony_ciextern void (*aprp_hook)(void);
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_cienum rtlx_state {
5062306a36Sopenharmony_ci	RTLX_STATE_UNUSED = 0,
5162306a36Sopenharmony_ci	RTLX_STATE_INITIALISED,
5262306a36Sopenharmony_ci	RTLX_STATE_REMOTE_READY,
5362306a36Sopenharmony_ci	RTLX_STATE_OPENED
5462306a36Sopenharmony_ci};
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ciextern struct chan_waitqueues {
5762306a36Sopenharmony_ci	wait_queue_head_t rt_queue;
5862306a36Sopenharmony_ci	wait_queue_head_t lx_queue;
5962306a36Sopenharmony_ci	atomic_t in_open;
6062306a36Sopenharmony_ci	struct mutex mutex;
6162306a36Sopenharmony_ci} channel_wqs[RTLX_CHANNELS];
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci/* each channel supports read and write.
6462306a36Sopenharmony_ci   linux (vpe0) reads lx_buffer and writes rt_buffer
6562306a36Sopenharmony_ci   SP (vpe1) reads rt_buffer and writes lx_buffer
6662306a36Sopenharmony_ci*/
6762306a36Sopenharmony_cistruct rtlx_channel {
6862306a36Sopenharmony_ci	enum rtlx_state rt_state;
6962306a36Sopenharmony_ci	enum rtlx_state lx_state;
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ci	int buffer_size;
7262306a36Sopenharmony_ci
7362306a36Sopenharmony_ci	/* read and write indexes per buffer */
7462306a36Sopenharmony_ci	int rt_write, rt_read;
7562306a36Sopenharmony_ci	char *rt_buffer;
7662306a36Sopenharmony_ci
7762306a36Sopenharmony_ci	int lx_write, lx_read;
7862306a36Sopenharmony_ci	char *lx_buffer;
7962306a36Sopenharmony_ci};
8062306a36Sopenharmony_ci
8162306a36Sopenharmony_ciextern struct rtlx_info {
8262306a36Sopenharmony_ci	unsigned long id;
8362306a36Sopenharmony_ci	enum rtlx_state state;
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci	struct rtlx_channel channel[RTLX_CHANNELS];
8662306a36Sopenharmony_ci} *rtlx;
8762306a36Sopenharmony_ci#endif /* __ASM_RTLX_H_ */
88