lin
2025-08-21 57113df3a0e2be01232281fad9a5f2c060567981
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
 * drivers/spi/spi-slave-protocol.h
 *
 * Copyright (C) 2019 - Reuuimlla Limited
 * Yihuasheng <yihuasheng@allwinnertech.com>
 *
 * SUNXI SPI Slave Protocol Definition
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 */
 
/*
#define HEAD_LENGTH
#define OP_MASK        0
#define ADDR_MASK_0    1
#define ADDR_MASK_1    2
#define ADDR_MASK_2    3
#define LENGTH_MASK_0    4
#define LENGTH_MASK_1    5
#define LENGTH_MASK_2    6
#define SUNXI_OP_WRITE    0x01
#define SUNXI_OP_READ    0x03
*/
 
#define HEAD_LEN 5
#define PKT_MAX_LEN 0x40
#define STATUS_LEN 0x01
 
#define STATUS_WRITABLE 0x02
#define STATUS_NOTWRITABLE 0x03
#define STATUS_READABLE 0x04
 
#define OP_MASK        0
#define ADDR_MASK_0    1
#define ADDR_MASK_1    2
#define ADDR_MASK_2    3
#define LENGTH_MASK    4
#define SUNXI_OP_WRITE    0x01
#define SUNXI_OP_READ    0x03
 
 
 
struct sunxi_spi_slave_head {
   int op_code;
   int addr;
   int len;
};
 
struct device_data {
   unsigned char *tx_buf, *rx_buf;
   unsigned char len; /* max len is 64 */
};
 
struct sunxi_slave {
   struct sunxi_spi_slave_head *head;
   struct device_data *data;
   struct device_data *(*set_up_txdata)(struct sunxi_spi_slave_head *head);
};