Mikael Starvik | dcf1310 | 2005-07-27 11:44:42 -0700 | [diff] [blame] | 1 | /* |
| 2 | * ioctl defines for synchronous serial port driver |
| 3 | * |
| 4 | * Copyright (c) 2001-2003 Axis Communications AB |
| 5 | * |
| 6 | * Author: Mikael Starvik |
| 7 | * |
| 8 | */ |
| 9 | |
| 10 | #ifndef SYNC_SERIAL_H |
| 11 | #define SYNC_SERIAL_H |
| 12 | |
| 13 | #include <linux/ioctl.h> |
| 14 | |
| 15 | #define SSP_SPEED _IOR('S', 0, unsigned int) |
| 16 | #define SSP_MODE _IOR('S', 1, unsigned int) |
| 17 | #define SSP_FRAME_SYNC _IOR('S', 2, unsigned int) |
| 18 | #define SSP_IPOLARITY _IOR('S', 3, unsigned int) |
| 19 | #define SSP_OPOLARITY _IOR('S', 4, unsigned int) |
| 20 | #define SSP_SPI _IOR('S', 5, unsigned int) |
| 21 | #define SSP_INBUFCHUNK _IOR('S', 6, unsigned int) |
Jesper Nilsson | 72e08db1 | 2010-08-04 11:30:41 +0200 | [diff] [blame] | 22 | #define SSP_INPUT _IOR('S', 7, unsigned int) |
Mikael Starvik | dcf1310 | 2005-07-27 11:44:42 -0700 | [diff] [blame] | 23 | |
| 24 | /* Values for SSP_SPEED */ |
| 25 | #define SSP150 0 |
| 26 | #define SSP300 1 |
| 27 | #define SSP600 2 |
| 28 | #define SSP1200 3 |
| 29 | #define SSP2400 4 |
| 30 | #define SSP4800 5 |
| 31 | #define SSP9600 6 |
| 32 | #define SSP19200 7 |
| 33 | #define SSP28800 8 |
| 34 | #define SSP57600 9 |
| 35 | #define SSP115200 10 |
| 36 | #define SSP230400 11 |
| 37 | #define SSP460800 12 |
| 38 | #define SSP921600 13 |
| 39 | #define SSP3125000 14 |
| 40 | #define CODEC 15 |
Jesper Nilsson | 72e08db1 | 2010-08-04 11:30:41 +0200 | [diff] [blame] | 41 | #define CODEC_f32768 16 |
Mikael Starvik | dcf1310 | 2005-07-27 11:44:42 -0700 | [diff] [blame] | 42 | |
| 43 | #define FREQ_4MHz 0 |
| 44 | #define FREQ_2MHz 1 |
| 45 | #define FREQ_1MHz 2 |
| 46 | #define FREQ_512kHz 3 |
| 47 | #define FREQ_256kHz 4 |
| 48 | #define FREQ_128kHz 5 |
| 49 | #define FREQ_64kHz 6 |
| 50 | #define FREQ_32kHz 7 |
Jesper Nilsson | 72e08db1 | 2010-08-04 11:30:41 +0200 | [diff] [blame] | 51 | /* FREQ_* with values where bit (value & 0x10) is set are */ |
| 52 | /* used for CODEC_f32768 */ |
| 53 | #define FREQ_4096kHz 16 /* CODEC_f32768 */ |
Mikael Starvik | dcf1310 | 2005-07-27 11:44:42 -0700 | [diff] [blame] | 54 | |
| 55 | /* Used by application to set CODEC divider, word rate and frame rate */ |
Jesper Nilsson | 72e08db1 | 2010-08-04 11:30:41 +0200 | [diff] [blame] | 56 | #define CODEC_VAL(freq, clk_per_sync, sync_per_frame) \ |
| 57 | ((CODEC + ((freq & 0x10) >> 4)) | (freq << 8) | \ |
| 58 | (clk_per_sync << 16) | (sync_per_frame << 28)) |
Mikael Starvik | dcf1310 | 2005-07-27 11:44:42 -0700 | [diff] [blame] | 59 | |
| 60 | /* Used by driver to extract speed */ |
| 61 | #define GET_SPEED(x) (x & 0xff) |
| 62 | #define GET_FREQ(x) ((x & 0xff00) >> 8) |
| 63 | #define GET_WORD_RATE(x) (((x & 0x0fff0000) >> 16) - 1) |
| 64 | #define GET_FRAME_RATE(x) (((x & 0xf0000000) >> 28) - 1) |
| 65 | |
| 66 | /* Values for SSP_MODE */ |
| 67 | #define MASTER_OUTPUT 0 |
| 68 | #define SLAVE_OUTPUT 1 |
| 69 | #define MASTER_INPUT 2 |
| 70 | #define SLAVE_INPUT 3 |
| 71 | #define MASTER_BIDIR 4 |
| 72 | #define SLAVE_BIDIR 5 |
| 73 | |
| 74 | /* Values for SSP_FRAME_SYNC */ |
| 75 | #define NORMAL_SYNC 1 |
| 76 | #define EARLY_SYNC 2 |
Jesper Nilsson | ca91d5b | 2007-11-29 17:26:24 +0100 | [diff] [blame] | 77 | #define SECOND_WORD_SYNC 0x40000 |
Jesper Nilsson | 72e08db1 | 2010-08-04 11:30:41 +0200 | [diff] [blame] | 78 | #define LATE_SYNC 0x80000 |
Mikael Starvik | dcf1310 | 2005-07-27 11:44:42 -0700 | [diff] [blame] | 79 | |
| 80 | #define BIT_SYNC 4 |
| 81 | #define WORD_SYNC 8 |
| 82 | #define EXTENDED_SYNC 0x10 |
| 83 | |
| 84 | #define SYNC_OFF 0x20 |
| 85 | #define SYNC_ON 0x40 |
| 86 | #define WORD_SIZE_8 0x80 |
| 87 | #define WORD_SIZE_12 0x100 |
| 88 | #define WORD_SIZE_16 0x200 |
| 89 | #define WORD_SIZE_24 0x400 |
| 90 | #define WORD_SIZE_32 0x800 |
| 91 | #define BIT_ORDER_LSB 0x1000 |
| 92 | #define BIT_ORDER_MSB 0x2000 |
| 93 | #define FLOW_CONTROL_ENABLE 0x4000 |
| 94 | #define FLOW_CONTROL_DISABLE 0x8000 |
| 95 | #define CLOCK_GATED 0x10000 |
| 96 | #define CLOCK_NOT_GATED 0x20000 |
| 97 | |
| 98 | /* Values for SSP_IPOLARITY and SSP_OPOLARITY */ |
| 99 | #define CLOCK_NORMAL 1 |
| 100 | #define CLOCK_INVERT 2 |
| 101 | #define CLOCK_INEGEDGE CLOCK_NORMAL |
| 102 | #define CLOCK_IPOSEDGE CLOCK_INVERT |
| 103 | #define FRAME_NORMAL 4 |
| 104 | #define FRAME_INVERT 8 |
| 105 | #define STATUS_NORMAL 0x10 |
| 106 | #define STATUS_INVERT 0x20 |
| 107 | |
| 108 | /* Values for SSP_SPI */ |
| 109 | #define SPI_MASTER 0 |
| 110 | #define SPI_SLAVE 1 |
| 111 | |
| 112 | /* Values for SSP_INBUFCHUNK */ |
| 113 | /* plain integer with the size of DMA chunks */ |
| 114 | |
Jesper Nilsson | 72e08db1 | 2010-08-04 11:30:41 +0200 | [diff] [blame] | 115 | /* To ensure that the timestamps are aligned with the data being read |
| 116 | * the read length MUST be a multiple of the length of the DMA buffers. |
| 117 | * |
| 118 | * Use a multiple of SSP_INPUT_CHUNK_SIZE defined below. |
| 119 | */ |
| 120 | #define SSP_INPUT_CHUNK_SIZE 256 |
| 121 | |
| 122 | /* Request struct to pass through the ioctl interface to read |
| 123 | * data with timestamps. |
| 124 | */ |
| 125 | struct ssp_request { |
| 126 | char __user *buf; /* Where to put the data. */ |
| 127 | size_t len; /* Size of buf. MUST be a multiple of */ |
| 128 | /* SSP_INPUT_CHUNK_SIZE! */ |
| 129 | struct timespec ts; /* The time the data was sampled. */ |
| 130 | }; |
| 131 | |
Mikael Starvik | dcf1310 | 2005-07-27 11:44:42 -0700 | [diff] [blame] | 132 | #endif |