forked from tostmann/w5x00
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathw5x00.h
145 lines (118 loc) · 3.31 KB
/
w5x00.h
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/****************************************************************************
*
* driver/w5x00.h
*/
#ifndef _WIZNET_W5X00_H_
#define _WIZNET_W5X00_H_
#define DRV_NAME "w5x00"
#define DRV_VERSION "2.0.0"
/* Linux OS macros and functions related */
#include <linux/init.h>
#include <linux/module.h>
#include <linux/version.h>
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
#include <linux/skbuff.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/interrupt.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <asm/atomic.h>
#include <asm/uaccess.h>
#include "regs.h"
#define W5X00_DEFAULT_PIN_RESET 27
#define W5X00_DEFAULT_PIN_INTERRUPT 18
#define W5X00_DEFAULT_SELECT 0
#define W5X00_DEFAULT_MAC {0xa4, 0x50, 0x55, 0x91, 0x97, 0x98}
#define SPI_BURST_SIZE 28 // Read/Write Burst Size (For spi_write_then_read)
/* driver information */
typedef struct _wiz_t {
u32 base;
int irq;
int pin_interrupt;
int pin_reset;
int sock[MAX_SOCK_NUM];
int nof_socks;
u8 macaddr[8];
u16 local_port;
#if 1 // 2014.03.12 sskim
struct sk_buff *tx_skb;
struct work_struct tx_work;
struct work_struct rx_work;
#endif
spinlock_t lock;
struct net_device *dev;
} wiz_t;
/*
* Information that need to be kept for each board.
*/
struct wiz_private {
struct net_device_stats stats;
wiz_t *wiz;
int s;
/* tasklet */
/* Tx control lock. This protects the transmit buffer ring
* state along with the "tx full" state of the driver. This
* means all netif_queue flow control actions are protected
* by this lock as well.
*/
spinlock_t lock;
};
/* hwtcpip driver information */
typedef struct _hwtcpip_t {
int sock_use[MAX_SOCK_NUM];
int sock_opmode[MAX_SOCK_NUM];
int sock_status[MAX_SOCK_NUM];
} hwtcpip_t;
typedef union un_l2cval {
unsigned long lVal;
unsigned char cVal[4];
}un_l2cval;
typedef union un_i2cval {
unsigned int iVal;
unsigned char cVal[2];
}un_i2cval;
/*
* wiznet ioctl interface.
*/
#define WIZNETIOCTL SIOCDEVPRIVATE
#define WZIOC_GETOID 1
#define WZIOC_SETOID 2
#define WZIOC_TEST 3
struct s_wiznet_ioctl {
unsigned long cmd;
unsigned long oid;
unsigned long len;
char *data;
};
/* base.c */
void wiz_mac_update(wiz_t *wz, u8 *mac);
void wiz_srcip_update(wiz_t *wz, u32 addr);
void wiz_subnet_update(wiz_t *wz, u32 addr);
void wiz_gateway_update(wiz_t *wz, u32 addr);
int wiz_dev_init(wiz_t *wz);
int wiz_dev_exit(wiz_t *wz);
int wiz_socket_open(wiz_t *wz, int s, int protocol, int port, int flag);
int wiz_socket_close(wiz_t *wz, int s);
/* netdrv.c */
struct net_device *wiznet_drv_create(wiz_t *wz);
void wiznet_drv_delete(struct net_device *dev);
/* dev.c */
int iinchip_netif_create(struct net_device *dev);
int iinchip_open(int s, int type, int ipproto);
int iinchip_close(int s);
int iinchip_netif_delete(struct net_device *dev);
int iinchip_send_buf(int s, unsigned char *buf, int len);
void iinchip_socket_sethwaddr(char *addr);
void iinchip_copy_to(u32 adr, const u8 *buf, ssize_t len);
void iinchip_copy_from(u32 adr, u8 *buf, ssize_t len);
int iinchip_socket_tasklet_init(int s, void (*func)(unsigned long), unsigned long data);
int iinchip_socket_interrupt_enable(int s);
int iinchip_socket_interrupt_disable(int s);
int iinchip_socket_tasklet_kill(int s);
/* debug */
#define DBFENTER
#define DBFEXIT
#endif