1
2
3
4
5
6
7
8#ifndef SATA_SIL3132_H
9#define SATA_SIL3132_H
10
11#define READ_CMD 0
12#define WRITE_CMD 1
13
14
15
16
17struct sil_sata {
18 char name[12];
19 void *port;
20 int lba48;
21 u16 pio;
22 u16 mwdma;
23 u16 udma;
24 struct udevice *devno;
25 int wcache;
26 int flush;
27 int flush_ext;
28 int id;
29};
30
31
32struct sata_info {
33 ulong iobase[3];
34 pci_dev_t devno;
35 int portbase;
36 int maxport;
37};
38
39
40
41
42struct sil_sge {
43 __le64 addr;
44 __le32 cnt;
45 __le32 flags;
46} __attribute__ ((aligned(8), packed));
47
48
49
50
51struct sil_prb {
52 __le16 ctrl;
53 __le16 prot;
54 __le32 rx_cnt;
55 struct sata_fis_h2d fis;
56} __attribute__ ((aligned(8), packed));
57
58struct sil_cmd_block {
59 struct sil_prb prb;
60 struct sil_sge sge;
61};
62
63enum {
64 HOST_SLOT_STAT = 0x00,
65 HOST_CTRL = 0x40,
66 HOST_IRQ_STAT = 0x44,
67 HOST_PHY_CFG = 0x48,
68 HOST_BIST_CTRL = 0x50,
69 HOST_BIST_PTRN = 0x54,
70 HOST_BIST_STAT = 0x58,
71 HOST_MEM_BIST_STAT = 0x5c,
72 HOST_FLASH_CMD = 0x70,
73
74 HOST_FLASH_DATA = 0x74,
75 HOST_TRANSITION_DETECT = 0x75,
76 HOST_GPIO_CTRL = 0x76,
77 HOST_I2C_ADDR = 0x78,
78 HOST_I2C_DATA = 0x7c,
79 HOST_I2C_XFER_CNT = 0x7e,
80 HOST_I2C_CTRL = 0x7f,
81
82
83 HOST_SSTAT_ATTN = (1 << 31),
84
85
86 HOST_CTRL_M66EN = (1 << 16),
87 HOST_CTRL_TRDY = (1 << 17),
88 HOST_CTRL_STOP = (1 << 18),
89 HOST_CTRL_DEVSEL = (1 << 19),
90 HOST_CTRL_REQ64 = (1 << 20),
91 HOST_CTRL_GLOBAL_RST = (1 << 31),
92
93
94
95
96
97 PORT_REGS_SIZE = 0x2000,
98
99 PORT_LRAM = 0x0000,
100 PORT_LRAM_SLOT_SZ = 0x0080,
101
102 PORT_PMP = 0x0f80,
103 PORT_PMP_STATUS = 0x0000,
104 PORT_PMP_QACTIVE = 0x0004,
105 PORT_PMP_SIZE = 0x0008,
106
107
108 PORT_CTRL_STAT = 0x1000,
109 PORT_CTRL_CLR = 0x1004,
110 PORT_IRQ_STAT = 0x1008,
111 PORT_IRQ_ENABLE_SET = 0x1010,
112 PORT_IRQ_ENABLE_CLR = 0x1014,
113 PORT_ACTIVATE_UPPER_ADDR = 0x101c,
114 PORT_EXEC_FIFO = 0x1020,
115 PORT_CMD_ERR = 0x1024,
116 PORT_FIS_CFG = 0x1028,
117 PORT_FIFO_THRES = 0x102c,
118
119
120 PORT_DECODE_ERR_CNT = 0x1040,
121 PORT_DECODE_ERR_THRESH = 0x1042,
122 PORT_CRC_ERR_CNT = 0x1044,
123 PORT_CRC_ERR_THRESH = 0x1046,
124 PORT_HSHK_ERR_CNT = 0x1048,
125 PORT_HSHK_ERR_THRESH = 0x104a,
126
127
128 PORT_PHY_CFG = 0x1050,
129 PORT_SLOT_STAT = 0x1800,
130 PORT_CMD_ACTIVATE = 0x1c00,
131 PORT_CONTEXT = 0x1e04,
132 PORT_EXEC_DIAG = 0x1e00,
133 PORT_PSD_DIAG = 0x1e40,
134 PORT_SCONTROL = 0x1f00,
135 PORT_SSTATUS = 0x1f04,
136 PORT_SERROR = 0x1f08,
137 PORT_SACTIVE = 0x1f0c,
138
139
140 PORT_CS_PORT_RST = (1 << 0),
141 PORT_CS_DEV_RST = (1 << 1),
142 PORT_CS_INIT = (1 << 2),
143 PORT_CS_IRQ_WOC = (1 << 3),
144 PORT_CS_CDB16 = (1 << 5),
145 PORT_CS_PMP_RESUME = (1 << 6),
146 PORT_CS_32BIT_ACTV = (1 << 10),
147 PORT_CS_PMP_EN = (1 << 13),
148 PORT_CS_RDY = (1 << 31),
149
150
151
152 PORT_IRQ_COMPLETE = (1 << 0),
153 PORT_IRQ_ERROR = (1 << 1),
154 PORT_IRQ_PORTRDY_CHG = (1 << 2),
155 PORT_IRQ_PWR_CHG = (1 << 3),
156 PORT_IRQ_PHYRDY_CHG = (1 << 4),
157 PORT_IRQ_COMWAKE = (1 << 5),
158 PORT_IRQ_UNK_FIS = (1 << 6),
159 PORT_IRQ_DEV_XCHG = (1 << 7),
160 PORT_IRQ_8B10B = (1 << 8),
161 PORT_IRQ_CRC = (1 << 9),
162 PORT_IRQ_HANDSHAKE = (1 << 10),
163 PORT_IRQ_SDB_NOTIFY = (1 << 11),
164
165 DEF_PORT_IRQ = PORT_IRQ_COMPLETE | PORT_IRQ_ERROR |
166 PORT_IRQ_PHYRDY_CHG | PORT_IRQ_DEV_XCHG |
167 PORT_IRQ_UNK_FIS | PORT_IRQ_SDB_NOTIFY,
168
169
170 PORT_IRQ_RAW_SHIFT = 16,
171 PORT_IRQ_MASKED_MASK = 0x7ff,
172 PORT_IRQ_RAW_MASK = (0x7ff << PORT_IRQ_RAW_SHIFT),
173
174
175 PORT_IRQ_STEER_SHIFT = 30,
176 PORT_IRQ_STEER_MASK = (3 << PORT_IRQ_STEER_SHIFT),
177
178
179 PORT_CERR_DEV = 1,
180 PORT_CERR_SDB = 2,
181 PORT_CERR_DATA = 3,
182 PORT_CERR_SEND = 4,
183 PORT_CERR_INCONSISTENT = 5,
184 PORT_CERR_DIRECTION = 6,
185 PORT_CERR_UNDERRUN = 7,
186 PORT_CERR_OVERRUN = 8,
187
188
189 PRB_CTRL_PROTOCOL = (1 << 0),
190 PRB_CTRL_PACKET_READ = (1 << 4),
191 PRB_CTRL_PACKET_WRITE = (1 << 5),
192 PRB_CTRL_NIEN = (1 << 6),
193 PRB_CTRL_SRST = (1 << 7),
194
195
196 PRB_PROT_PACKET = (1 << 0),
197 PRB_PROT_TCQ = (1 << 1),
198 PRB_PROT_NCQ = (1 << 2),
199 PRB_PROT_READ = (1 << 3),
200 PRB_PROT_WRITE = (1 << 4),
201 PRB_PROT_TRANSPARENT = (1 << 5),
202
203
204
205
206 SGE_TRM = (1 << 31),
207 SGE_LNK = (1 << 30),
208
209 SGE_DRD = (1 << 29),
210
211
212 CMD_ERR = 0x21,
213};
214
215#define ATA_MAX_PORTS 32
216struct sil_sata_priv {
217 int port_num;
218 struct sil_sata *sil_sata_desc[ATA_MAX_PORTS];
219};
220
221#endif
222