Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 1 | /* |
Steven J. Hill | 5792bf6 | 2014-01-01 16:35:32 +0100 | [diff] [blame] | 2 | * This file is subject to the terms and conditions of the GNU General Public |
| 3 | * License. See the file "COPYING" in the main directory of this archive |
| 4 | * for more details. |
| 5 | * |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 6 | * Copyright (C) 2004, 2005 MIPS Technologies, Inc. All rights reserved. |
Deng-Cheng Zhu | 2c973ef | 2014-01-01 16:26:46 +0100 | [diff] [blame] | 7 | * Copyright (C) 2013 Imagination Technologies Ltd. |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 8 | */ |
Vegard Nossum | 2cc3c0b | 2008-05-27 17:27:28 +0200 | [diff] [blame] | 9 | #ifndef __ASM_RTLX_H_ |
Ralf Baechle | 2600990 | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 10 | #define __ASM_RTLX_H_ |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 11 | |
Atsushi Nemoto | 97dcb82 | 2007-01-08 02:14:29 +0900 | [diff] [blame] | 12 | #include <irq.h> |
| 13 | |
Deng-Cheng Zhu | 2c973ef | 2014-01-01 16:26:46 +0100 | [diff] [blame] | 14 | #define RTLX_MODULE_NAME "rtlx" |
| 15 | |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 16 | #define LX_NODE_BASE 10 |
| 17 | |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 18 | #define MIPS_CPU_RTLX_IRQ 0 |
| 19 | |
Ralf Baechle | 2600990 | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 20 | #define RTLX_VERSION 2 |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 21 | #define RTLX_xID 0x12345600 |
| 22 | #define RTLX_ID (RTLX_xID | RTLX_VERSION) |
Deng-Cheng Zhu | 2c973ef | 2014-01-01 16:26:46 +0100 | [diff] [blame] | 23 | #define RTLX_BUFFER_SIZE 2048 |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 24 | #define RTLX_CHANNELS 8 |
| 25 | |
Ralf Baechle | 2600990 | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 26 | #define RTLX_CHANNEL_STDIO 0 |
| 27 | #define RTLX_CHANNEL_DBG 1 |
| 28 | #define RTLX_CHANNEL_SYSIO 2 |
Ralf Baechle | afc4841 | 2005-10-31 00:30:39 +0000 | [diff] [blame] | 29 | |
Deng-Cheng Zhu | 2c973ef | 2014-01-01 16:26:46 +0100 | [diff] [blame] | 30 | void rtlx_starting(int vpe); |
| 31 | void rtlx_stopping(int vpe); |
| 32 | |
| 33 | int rtlx_open(int index, int can_sleep); |
| 34 | int rtlx_release(int index); |
| 35 | ssize_t rtlx_read(int index, void __user *buff, size_t count); |
| 36 | ssize_t rtlx_write(int index, const void __user *buffer, size_t count); |
| 37 | unsigned int rtlx_read_poll(int index, int can_sleep); |
| 38 | unsigned int rtlx_write_poll(int index); |
| 39 | |
| 40 | int __init rtlx_module_init(void); |
| 41 | void __exit rtlx_module_exit(void); |
| 42 | |
| 43 | void _interrupt_sp(void); |
| 44 | |
| 45 | extern struct vpe_notifications rtlx_notify; |
| 46 | extern const struct file_operations rtlx_fops; |
| 47 | extern void (*aprp_hook)(void); |
Ralf Baechle | 2600990 | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 48 | |
| 49 | enum rtlx_state { |
Kevin D. Kissell | 1928cc8 | 2008-04-16 15:32:22 +0200 | [diff] [blame] | 50 | RTLX_STATE_UNUSED = 0, |
Ralf Baechle | 2600990 | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 51 | RTLX_STATE_INITIALISED, |
| 52 | RTLX_STATE_REMOTE_READY, |
| 53 | RTLX_STATE_OPENED |
| 54 | }; |
| 55 | |
Deng-Cheng Zhu | 2c973ef | 2014-01-01 16:26:46 +0100 | [diff] [blame] | 56 | extern struct chan_waitqueues { |
| 57 | wait_queue_head_t rt_queue; |
| 58 | wait_queue_head_t lx_queue; |
| 59 | atomic_t in_open; |
| 60 | struct mutex mutex; |
| 61 | } channel_wqs[RTLX_CHANNELS]; |
Ralf Baechle | afc4841 | 2005-10-31 00:30:39 +0000 | [diff] [blame] | 62 | |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 63 | /* each channel supports read and write. |
Deng-Cheng Zhu | 2c973ef | 2014-01-01 16:26:46 +0100 | [diff] [blame] | 64 | linux (vpe0) reads lx_buffer and writes rt_buffer |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 65 | SP (vpe1) reads rt_buffer and writes lx_buffer |
| 66 | */ |
Ralf Baechle | afc4841 | 2005-10-31 00:30:39 +0000 | [diff] [blame] | 67 | struct rtlx_channel { |
Ralf Baechle | 2600990 | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 68 | enum rtlx_state rt_state; |
| 69 | enum rtlx_state lx_state; |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 70 | |
| 71 | int buffer_size; |
| 72 | |
| 73 | /* read and write indexes per buffer */ |
| 74 | int rt_write, rt_read; |
| 75 | char *rt_buffer; |
| 76 | |
| 77 | int lx_write, lx_read; |
| 78 | char *lx_buffer; |
Ralf Baechle | afc4841 | 2005-10-31 00:30:39 +0000 | [diff] [blame] | 79 | }; |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 80 | |
Deng-Cheng Zhu | 2c973ef | 2014-01-01 16:26:46 +0100 | [diff] [blame] | 81 | extern struct rtlx_info { |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 82 | unsigned long id; |
Ralf Baechle | 2600990 | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 83 | enum rtlx_state state; |
Deng-Cheng Zhu | da615cf | 2014-01-01 16:29:03 +0100 | [diff] [blame] | 84 | int ap_int_pending; /* Status of 0 or 1 for CONFIG_MIPS_CMP only */ |
Ralf Baechle | e01402b | 2005-07-14 15:57:16 +0000 | [diff] [blame] | 85 | |
| 86 | struct rtlx_channel channel[RTLX_CHANNELS]; |
Deng-Cheng Zhu | 2c973ef | 2014-01-01 16:26:46 +0100 | [diff] [blame] | 87 | } *rtlx; |
Ralf Baechle | 2600990 | 2006-04-05 09:45:45 +0100 | [diff] [blame] | 88 | #endif /* __ASM_RTLX_H_ */ |