![]() |
|
|||
File indexing completed on 2025-05-11 08:23:43
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /* 0004 * SPICTRL SPI Driver interface. 0005 * 0006 * COPYRIGHT (c) 2009. 0007 * Cobham Gaisler AB. 0008 * 0009 * Redistribution and use in source and binary forms, with or without 0010 * modification, are permitted provided that the following conditions 0011 * are met: 0012 * 1. Redistributions of source code must retain the above copyright 0013 * notice, this list of conditions and the following disclaimer. 0014 * 2. Redistributions in binary form must reproduce the above copyright 0015 * notice, this list of conditions and the following disclaimer in the 0016 * documentation and/or other materials provided with the distribution. 0017 * 0018 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0019 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0020 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0021 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0022 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0023 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0024 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0025 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0026 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0027 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0028 * POSSIBILITY OF SUCH DAMAGE. 0029 */ 0030 0031 #ifndef __SPICTRL_H__ 0032 #define __SPICTRL_H__ 0033 0034 #ifdef __cplusplus 0035 extern "C" { 0036 #endif 0037 0038 extern void spictrl_register_drv (void); 0039 0040 /*** REGISTER LAYOUT ***/ 0041 struct spictrl_regs { 0042 volatile unsigned int capability; /* 0x00 */ 0043 volatile unsigned int resv[7]; /* 0x04 */ 0044 volatile unsigned int mode; /* 0x20 */ 0045 volatile unsigned int event; /* 0x24 */ 0046 volatile unsigned int mask; /* 0x28 */ 0047 volatile unsigned int command; /* 0x2c */ 0048 volatile unsigned int tx; /* 0x30 */ 0049 volatile unsigned int rx; /* 0x34 */ 0050 volatile unsigned int slvsel; /* 0x38 */ 0051 volatile unsigned int am_slvsel; /* 0x3c */ 0052 volatile unsigned int am_cfg; /* 0x40 */ 0053 volatile unsigned int am_period; /* 0x44 */ 0054 int reserved0[2]; 0055 volatile unsigned int am_mask[4]; /* 0x50-0x5C */ 0056 int reserved1[(0x200-0x60)/4]; 0057 volatile unsigned int am_tx[128]; /* 0x200-0x3FC */ 0058 volatile unsigned int am_rx[128]; /* 0x400-0x5FC */ 0059 }; 0060 0061 /* -- About automated periodic transfer mode -- 0062 * 0063 * Core must support this feature. 0064 * 0065 * The SPI core must be configured in periodic mode before 0066 * writing the data into the transfer FIFO which will be used 0067 * mutiple times in different transfers, it will also make 0068 * the receive FIFO to be updated. 0069 * 0070 * In periodic mode the following sequence is performed, 0071 * 1. start() 0072 * 2. ioctl(CONFIG, &config) - Enable periodic mode 0073 * 3. set_address() 0074 * 4. write() - Fills TX FIFO, this has some constraints 0075 * 5. ioctl(START) - Starts the periodic transmission of the TX FIFO 0076 * 6. read() - Read one response of the tranistted data. It will 0077 * hang until data is available. If hanging is not an 0078 * options use ioctl(STATUS) 0079 * 7. go back to 6. 0080 * 0081 * 8. ioctl(STOP) - Stop to set up a new periodic or normal transfer 0082 * 9. stop() 0083 * 0084 * Note that the the read length must equal the total write length. 0085 */ 0086 0087 /* Custom SPICTRL driver ioctl commands */ 0088 #define SPICTRL_IOCTL_PERIOD_START 5000 /* Start automated periodic transfer mode */ 0089 #define SPICTRL_IOCTL_PERIOD_STOP 5001 /* Stop to SPI core from doing periodic transfers */ 0090 #define SPICTRL_IOCTL_CONFIG 5002 /* Configure Periodic transfer mode (before calling write() and START) */ 0091 #define SPICTRL_IOCTL_STATUS 5003 /* Get status */ 0092 0093 #define SPICTRL_IOCTL_PERIOD_READ 5005 /* Write transmit registers and mask register 0094 * (only in automatic periodic mode) 0095 * Note that it is probably prefferred to read 0096 * the received words using the read() using 0097 * operations instead. 0098 */ 0099 #define SPICTRL_IOCTL_PERIOD_WRITE 5006 /* Read receive registers and mask register 0100 * (only in automatic periodic mode) */ 0101 #define SPICTRL_IOCTL_REGS 5007 /* Get SPICTRL Register */ 0102 0103 /* SPICTRL_IOCTL_CONFIG argument */ 0104 struct spictrl_ioctl_config { 0105 int clock_gap; /* Clock GAP between */ 0106 unsigned int flags; /* Normal mode flags */ 0107 int periodic_mode; /* 1=Enables Automated periodic transfers if supported by hardware */ 0108 unsigned int period; /* Number of clocks between automated transfers are started */ 0109 unsigned int period_flags; /* Options */ 0110 unsigned int period_slvsel; /* Slave Select when transfer is not active, default is 0xffffffff */ 0111 }; 0112 #define SPICTRL_FLAGS_TAC 0x10 0113 0114 #define SPICTRL_PERIOD_FLAGS_ERPT 0x80 /* Trigger start-period from external signal */ 0115 #define SPICTRL_PERIOD_FLAGS_SEQ 0x40 0116 #define SPICTRL_PERIOD_FLAGS_STRICT 0x20 0117 #define SPICTRL_PERIOD_FLAGS_OVTB 0x10 0118 #define SPICTRL_PERIOD_FLAGS_OVDB 0x08 0119 #define SPICTRL_PERIOD_FLAGS_ASEL 0x04 0120 #define SPICTRL_PERIOD_FLAGS_EACT 0x01 0121 0122 /* SPICTRL_IOCTL_PERIOD_READ and SPICTRL_IOCTL_PERIOD_WRITE Argument data structure 0123 * 0124 * Note that the order of reading the mask registers are different for read/write 0125 * operation. See options notes. 0126 */ 0127 struct spictrl_period_io { 0128 int options; /* READ: bit0=Read Mask Registers into masks[]. 0129 * bit1=Read Receive registers according to masks[] 0130 * (after reading masks). 0131 * 0132 * WRITE: bit0=Update Mask accoring to masks[]. 0133 * bit1=Update Transmit registers according to masks[]. 0134 * (before reading masks) 0135 */ 0136 unsigned int masks[4]; 0137 0138 void *data; /* Data read sequentially according to masks[] bit. */ 0139 }; 0140 0141 #ifdef __cplusplus 0142 } 0143 #endif 0144 0145 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |