]> sigrok.org Git - libsigrok.git/blame - src/hardware/fx2lafw/dslogic.h
fx2lafw/dslogic: Imported FPGA config mode flags
[libsigrok.git] / src / hardware / fx2lafw / dslogic.h
CommitLineData
b9d53092
BV
1/*
2 * This file is part of the libsigrok project.
3 *
4 * Copyright (C) 2013 Bert Vermeulen <bert@biot.com>
5 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
6fcf3f0a 21#ifndef LIBSIGROK_HARDWARE_FX2LAFW_DSLOGIC_H
22#define LIBSIGROK_HARDWARE_FX2LAFW_DSLOGIC_H
23
b9d53092
BV
24/* Modified protocol commands & flags used by DSLogic */
25#define DS_CMD_GET_FW_VERSION 0xb0
26#define DS_CMD_GET_REVID_VERSION 0xb1
6fcf3f0a 27#define DS_CMD_START 0xb2
9d71f815
JH
28#define DS_CMD_CONFIG 0xb3
29#define DS_CMD_SETTING 0xb4
30#define DS_CMD_CONTROL 0xb5
31#define DS_CMD_STATUS 0xb6
32#define DS_CMD_STATUS_INFO 0xb7
33#define DS_CMD_WR_REG 0xb8
34#define DS_CMD_WR_NVM 0xb9
35#define DS_CMD_RD_NVM 0xba
36#define DS_CMD_RD_NVM_PRE 0xbb
37#define DS_CMD_GET_HW_INFO 0xbc
b9d53092 38
6fcf3f0a 39#define DS_NUM_TRIGGER_STAGES 16
40#define DS_START_FLAGS_STOP (1 << 7)
41#define DS_START_FLAGS_CLK_48MHZ (1 << 6)
42#define DS_START_FLAGS_SAMPLE_WIDE (1 << 5)
62974b23 43#define DS_START_FLAGS_MODE_LA (1 << 4)
b9d53092 44
ac0facf4
JH
45#define DS_ADDR_COMB 0x68
46#define DS_ADDR_EEWP 0x70
47#define DS_ADDR_VTH 0x78
48
9803346f
UH
49#define DS_MAX_LOGIC_DEPTH SR_MHZ(16)
50#define DS_MAX_LOGIC_SAMPLERATE SR_MHZ(100)
a9a9bfaa 51
cf398cc0
JH
52#define DS_MODE_TRIG_EN (1 << 0)
53#define DS_MODE_CLK_TYPE (1 << 1)
54#define DS_MODE_CLK_EDGE (1 << 2)
55#define DS_MODE_RLE_MODE (1 << 3)
56#define DS_MODE_DSO_MODE (1 << 4)
57#define DS_MODE_HALF_MODE (1 << 5)
58#define DS_MODE_QUAR_MODE (1 << 6)
59#define DS_MODE_ANALOG_MODE (1 << 7)
60#define DS_MODE_FILTER (1 << 8)
61#define DS_MODE_INSTANT (1 << 9)
62#define DS_MODE_STRIG_MODE (1 << 11)
63#define DS_MODE_STREAM_MODE (1 << 12)
64#define DS_MODE_LPB_TEST (1 << 13)
65#define DS_MODE_EXT_TEST (1 << 14)
66#define DS_MODE_INT_TEST (1 << 15)
67
b9d53092
BV
68enum dslogic_operation_modes {
69 DS_OP_NORMAL,
70 DS_OP_INTERNAL_TEST,
71 DS_OP_EXTERNAL_TEST,
72 DS_OP_LOOPBACK_TEST,
73};
74
9803346f
UH
75enum {
76 DS_VOLTAGE_RANGE_18_33_V, /* 1.8V and 3.3V logic */
77 DS_VOLTAGE_RANGE_5_V, /* 5V logic */
3fc3fbe4
DA
78};
79
9803346f 80enum {
d9a58763 81 DS_EDGE_RISING,
9803346f 82 DS_EDGE_FALLING,
d9a58763
DA
83};
84
b9d53092
BV
85struct dslogic_version {
86 uint8_t major;
87 uint8_t minor;
88};
89
90struct dslogic_mode {
91 uint8_t flags;
92 uint8_t sample_delay_h;
93 uint8_t sample_delay_l;
94};
95
96struct dslogic_trigger_pos {
97 uint32_t real_pos;
98 uint32_t ram_saddr;
4237fbca
DA
99 uint32_t remain_cnt;
100 uint8_t first_block[500];
b9d53092
BV
101};
102
103/*
104 * The FPGA is configured with TLV tuples. Length is specified as the
105 * number of 16-bit words, and the (type, length) header is in some
106 * cases padded with 0xffff.
107 */
108#define _DS_CFG(variable, wordcnt) ((variable << 8) | wordcnt)
109#define _DS_CFG_PAD(variable, wordcnt) ((_DS_CFG(variable, wordcnt) << 16) | 0xffff)
3f0ff412 110#define DS_CFG_START 0xf5a5f5a5
6fcf3f0a 111#define DS_CFG_MODE _DS_CFG(0, 1)
b9d53092
BV
112#define DS_CFG_DIVIDER _DS_CFG_PAD(1, 2)
113#define DS_CFG_COUNT _DS_CFG_PAD(3, 2)
114#define DS_CFG_TRIG_POS _DS_CFG_PAD(5, 2)
115#define DS_CFG_TRIG_GLB _DS_CFG(7, 1)
116#define DS_CFG_TRIG_ADP _DS_CFG_PAD(10, 2)
117#define DS_CFG_TRIG_SDA _DS_CFG_PAD(12, 2)
118#define DS_CFG_TRIG_MASK0 _DS_CFG_PAD(16, 16)
119#define DS_CFG_TRIG_MASK1 _DS_CFG_PAD(17, 16)
120#define DS_CFG_TRIG_VALUE0 _DS_CFG_PAD(20, 16)
121#define DS_CFG_TRIG_VALUE1 _DS_CFG_PAD(21, 16)
122#define DS_CFG_TRIG_EDGE0 _DS_CFG_PAD(24, 16)
123#define DS_CFG_TRIG_EDGE1 _DS_CFG_PAD(25, 16)
124#define DS_CFG_TRIG_COUNT0 _DS_CFG_PAD(28, 16)
125#define DS_CFG_TRIG_COUNT1 _DS_CFG_PAD(29, 16)
126#define DS_CFG_TRIG_LOGIC0 _DS_CFG_PAD(32, 16)
127#define DS_CFG_TRIG_LOGIC1 _DS_CFG_PAD(33, 16)
3f0ff412 128#define DS_CFG_END 0xfa5afa5a
b9d53092
BV
129
130struct dslogic_fpga_config {
131 uint32_t sync;
132 uint16_t mode_header;
133 uint16_t mode;
134 uint32_t divider_header;
135 uint32_t divider;
136 uint32_t count_header;
137 uint32_t count;
138 uint32_t trig_pos_header;
139 uint32_t trig_pos;
140 uint16_t trig_glb_header;
141 uint16_t trig_glb;
142 uint32_t trig_adp_header;
143 uint32_t trig_adp;
144 uint32_t trig_sda_header;
145 uint32_t trig_sda;
146 uint32_t trig_mask0_header;
147 uint16_t trig_mask0[DS_NUM_TRIGGER_STAGES];
148 uint32_t trig_mask1_header;
149 uint16_t trig_mask1[DS_NUM_TRIGGER_STAGES];
150 uint32_t trig_value0_header;
151 uint16_t trig_value0[DS_NUM_TRIGGER_STAGES];
152 uint32_t trig_value1_header;
153 uint16_t trig_value1[DS_NUM_TRIGGER_STAGES];
154 uint32_t trig_edge0_header;
155 uint16_t trig_edge0[DS_NUM_TRIGGER_STAGES];
156 uint32_t trig_edge1_header;
157 uint16_t trig_edge1[DS_NUM_TRIGGER_STAGES];
158 uint32_t trig_count0_header;
159 uint16_t trig_count0[DS_NUM_TRIGGER_STAGES];
160 uint32_t trig_count1_header;
161 uint16_t trig_count1[DS_NUM_TRIGGER_STAGES];
162 uint32_t trig_logic0_header;
163 uint16_t trig_logic0[DS_NUM_TRIGGER_STAGES];
164 uint32_t trig_logic1_header;
165 uint16_t trig_logic1[DS_NUM_TRIGGER_STAGES];
166 uint32_t end_sync;
167};
168
8e2d6c9d
DE
169SR_PRIV int dslogic_fpga_firmware_upload(const struct sr_dev_inst *sdi,
170 const char *name);
171SR_PRIV int dslogic_start_acquisition(const struct sr_dev_inst *sdi);
172SR_PRIV int dslogic_stop_acquisition(const struct sr_dev_inst *sdi);
173SR_PRIV int dslogic_fpga_configure(const struct sr_dev_inst *sdi);
3fc3fbe4 174SR_PRIV int dslogic_set_vth(const struct sr_dev_inst *sdi, double vth);
9803346f 175SR_PRIV int dslogic_get_number_of_transfers(struct dev_context *devc);
6fcf3f0a 176
177#endif