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