aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/n230/n230_fw_host_iface.h
blob: 0391af0d98710f6e9e2adbde5f94d83921009f52 (plain)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//
// Copyright 2014 Ettus Research LLC
//
// 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 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program.  If not, see <http://www.gnu.org/licenses/>.
//

#ifndef INCLUDED_N230_FW_HOST_IFACE_H
#define INCLUDED_N230_FW_HOST_IFACE_H

#include <stdint.h>

/*!
 * Structs and constants for N230 communication between firmware and host.
 * This header is shared by the firmware and host code.
 * Therefore, this header may only contain valid C code.
 */
#ifdef __cplusplus
extern "C" {
#endif

//--------------------------------------------------
// Ethernet related
//
#define N230_DEFAULT_ETH0_MAC    {0x00, 0x50, 0xC2, 0x85, 0x3f, 0xff}
#define N230_DEFAULT_ETH1_MAC    {0x00, 0x50, 0xC2, 0x85, 0x3f, 0x33}
#define N230_DEFAULT_ETH0_IP     (192 << 24 | 168 << 16 | 10  << 8  | 2 << 0)
#define N230_DEFAULT_ETH1_IP     (192 << 24 | 168 << 16 | 20  << 8  | 2 << 0)
#define N230_DEFAULT_ETH0_MASK   (255 << 24 | 255 << 16 | 255 << 8  | 0 << 0)
#define N230_DEFAULT_ETH1_MASK   (255 << 24 | 255 << 16 | 255 << 8  | 0 << 0)
#define N230_DEFAULT_GATEWAY     (192 << 24 | 168 << 16 | 10  << 8  | 1 << 0)

#define N230_FW_COMMS_UDP_PORT        49152
#define N230_FW_COMMS_CVITA_PORT      49153
#define N230_FW_COMMS_FLASH_PROG_PORT 49154
//
//--------------------------------------------------

//--------------------------------------------------
// Memory shared with host
//
#define N230_FW_HOST_SHMEM_BASE_ADDR      0x10000
#define N230_FW_HOST_SHMEM_RW_BASE_ADDR   0x1000C
#define N230_FW_HOST_SHMEM_NUM_WORDS      (sizeof(n230_host_shared_mem_data_t)/sizeof(uint32_t))

#define N230_FW_HOST_SHMEM_MAX_ADDR  \
    (N230_FW_HOST_SHMEM_BASE_ADDR + ((N230_FW_HOST_SHMEM_NUM_WORDS - 1) * sizeof(uint32_t)))

#define N230_FW_HOST_SHMEM_OFFSET(member) \
    (N230_FW_HOST_SHMEM_BASE_ADDR + ((uint32_t)offsetof(n230_host_shared_mem_data_t, member)))

//The shared memory block can only be accessed on 32-bit boundaries
typedef struct {    //All fields must be 32-bit wide to avoid packing directives
    //Read-Only fields (N230_FW_HOST_SHMEM_BASE_ADDR)
    uint32_t fw_compat_num;     //Compat number must be at offset 0
    uint32_t fw_version_hash;
    uint32_t claim_status;

    //Read-Write fields (N230_FW_HOST_SHMEM_RW_BASE_ADDR)
    uint32_t scratch;
    uint32_t claim_time;
    uint32_t claim_src;
} n230_host_shared_mem_data_t;

typedef union
{
    uint32_t                    buff[N230_FW_HOST_SHMEM_NUM_WORDS];
    n230_host_shared_mem_data_t   data;
} n230_host_shared_mem_t;

#define N230_FW_PRODUCT_ID        1
#define N230_FW_COMPAT_NUM_MAJOR  32
#define N230_FW_COMPAT_NUM_MINOR  0
#define N230_FW_COMPAT_NUM        (((N230_FW_COMPAT_NUM_MAJOR & 0xFF) << 16) | (N230_FW_COMPAT_NUM_MINOR & 0xFFFF))
//
//--------------------------------------------------

//--------------------------------------------------
// Flash read-write interface for host
//
#define N230_FLASH_COMM_FLAGS_ACK           0x00000001
#define N230_FLASH_COMM_FLAGS_CMD_MASK      0x00000FF0
#define N230_FLASH_COMM_FLAGS_ERROR_MASK    0xFF000000

#define N230_FLASH_COMM_CMD_READ_NV_DATA    0x00000010
#define N230_FLASH_COMM_CMD_WRITE_NV_DATA   0x00000020
#define N230_FLASH_COMM_CMD_READ_FPGA       0x00000030
#define N230_FLASH_COMM_CMD_WRITE_FPGA      0x00000040
#define N230_FLASH_COMM_CMD_ERASE_FPGA      0x00000050

#define N230_FLASH_COMM_ERR_PKT_ERROR       0x80000000
#define N230_FLASH_COMM_ERR_CMD_ERROR       0x40000000
#define N230_FLASH_COMM_ERR_SIZE_ERROR      0x20000000

#define N230_FLASH_COMM_MAX_PAYLOAD_SIZE    128

typedef struct
{
    uint32_t flags;
    uint32_t seq;
    uint32_t offset;
    uint32_t size;
    uint8_t data[N230_FLASH_COMM_MAX_PAYLOAD_SIZE];
} n230_flash_prog_t;
//
//--------------------------------------------------

#define N230_HW_REVISION_COMPAT 1
#define N230_HW_REVISION_MIN    1


#define N230_CLAIMER_TIMEOUT_IN_MS        2000

#ifdef __cplusplus
}
#endif

#endif /* INCLUDED_N230_FW_HOST_IFACE_H */