Files
picomap/w6300/wizchip_conf.h

316 lines
8.9 KiB
C
Raw Normal View History

#ifndef _WIZCHIP_CONF_H_
#define _WIZCHIP_CONF_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#define W6300 6300
#ifndef _WIZCHIP_
#define _WIZCHIP_ W6300
#endif
#define _WIZCHIP_IO_MODE_NONE_ 0x0000
#define _WIZCHIP_IO_MODE_BUS_ 0x0100
#define _WIZCHIP_IO_MODE_SPI_ 0x0200
#define _WIZCHIP_IO_MODE_BUS_DIR_ (_WIZCHIP_IO_MODE_BUS_ + 1)
#define _WIZCHIP_IO_MODE_BUS_INDIR_ (_WIZCHIP_IO_MODE_BUS_ + 2)
#define _WIZCHIP_IO_MODE_SPI_VDM_ (_WIZCHIP_IO_MODE_SPI_ + 1)
#define _WIZCHIP_IO_MODE_SPI_FDM_ (_WIZCHIP_IO_MODE_SPI_ + 2)
#define _WIZCHIP_IO_MODE_SPI_5500_ (_WIZCHIP_IO_MODE_SPI_ + 3)
#define _WIZCHIP_IO_MODE_SPI_QSPI_ (_WIZCHIP_IO_MODE_SPI_ + 4)
#define _PHY_IO_MODE_PHYCR_ 0x0000
#define _PHY_IO_MODE_MII_ 0x0010
#define _PHY_IO_MODE_ _PHY_IO_MODE_MII_
#define _WIZCHIP_QSPI_MODE_ (0x02 << 6)
#define _WIZCHIP_ID_ "W6300\0"
#define _WIZCHIP_IO_MODE_ ((_WIZCHIP_IO_MODE_SPI_ & 0xff00) | (_WIZCHIP_QSPI_MODE_ & 0x00ff))
typedef uint8_t iodata_t;
typedef int16_t datasize_t;
#include "w6300.h"
#ifndef _WIZCHIP_IO_BASE_
#define _WIZCHIP_IO_BASE_ 0x00000000
#endif
#define _WIZCHIP_SOCK_NUM_ 8
typedef struct __WIZCHIP {
uint16_t if_mode;
uint8_t id[8];
struct _CRIS {
void (*_enter)(void);
void (*_exit)(void);
} CRIS;
struct _CS {
void (*_select)(void);
void (*_deselect)(void);
} CS;
union _IF {
struct {
iodata_t (*_read_data)(uint32_t AddrSel);
void (*_write_data)(uint32_t AddrSel, iodata_t wb);
void (*_read_data_buf)(uint32_t AddrSel, iodata_t* pBuf, int16_t len, uint8_t addrinc);
void (*_write_data_buf)(uint32_t AddrSel, iodata_t* pBuf, int16_t len, uint8_t addrinc);
} BUS;
struct {
uint8_t (*_read_byte)(void);
void (*_write_byte)(uint8_t wb);
void (*_read_burst)(uint8_t* pBuf, uint16_t len);
void (*_write_burst)(uint8_t* pBuf, uint16_t len);
} SPI;
struct {
void (*_read_qspi)(uint8_t opcode, uint16_t addr, uint8_t* pBuf, uint16_t len);
void (*_write_qspi)(uint8_t opcode, uint16_t addr, uint8_t* pBuf, uint16_t len);
} QSPI;
} IF;
} _WIZCHIP;
extern _WIZCHIP WIZCHIP;
typedef enum {
CW_SYS_LOCK,
CW_SYS_UNLOCK,
CW_GET_SYSLOCK,
CW_RESET_WIZCHIP,
CW_INIT_WIZCHIP,
CW_GET_INTERRUPT,
CW_CLR_INTERRUPT,
CW_SET_INTRMASK,
CW_GET_INTRMASK,
CW_SET_INTRTIME,
CW_GET_INTRTIME,
CW_SET_IEN,
CW_GET_IEN,
CW_GET_ID,
CW_GET_VER,
CW_SET_SYSCLK,
CW_GET_SYSCLK,
CW_RESET_PHY,
CW_SET_PHYCONF,
CW_GET_PHYCONF,
CW_GET_PHYSTATUS,
CW_SET_PHYPOWMODE,
CW_GET_PHYPOWMODE,
CW_GET_PHYLINK
} ctlwizchip_type;
typedef enum {
CN_SET_NETINFO,
CN_GET_NETINFO,
CN_SET_NETMODE,
CN_GET_NETMODE,
CN_SET_TIMEOUT,
CN_GET_TIMEOUT,
CN_SET_PREFER,
CN_GET_PREFER,
} ctlnetwork_type;
typedef enum {
CNS_ARP,
CNS_PING,
CNS_DAD,
CNS_SLAAC,
CNS_UNSOL_NA,
CNS_GET_PREFIX
} ctlnetservice_type;
typedef enum {
IK_PPPOE_TERMINATED = (1 << 0),
IK_DEST_UNREACH = (1 << 1),
IK_IP_CONFLICT = (1 << 2),
IK_DEST_UNREACH6 = (1 << 4),
IK_WOL = (1 << 7),
IK_NET_ALL = (0x97),
IK_SOCK_0 = (1 << 8),
IK_SOCK_1 = (1 << 9),
IK_SOCK_2 = (1 << 10),
IK_SOCK_3 = (1 << 11),
IK_SOCK_4 = (1 << 12),
IK_SOCK_5 = (1 << 13),
IK_SOCK_6 = (1 << 14),
IK_SOCK_7 = (1 << 15),
IK_SOCK_ALL = (0xFF << 8),
IK_SOCKL_TOUT = (1 << 16),
IK_SOCKL_ARP4 = (1 << 17),
IK_SOCKL_PING4 = (1 << 18),
IK_SOCKL_ARP6 = (1 << 19),
IK_SOCKL_PING6 = (1 << 20),
IK_SOCKL_NS = (1 << 21),
IK_SOCKL_RS = (1 << 22),
IK_SOCKL_RA = (1 << 23),
IK_SOCKL_ALL = (0xFF << 16),
IK_INT_ALL = (0x00FFFF97)
} intr_kind;
#define SYS_CHIP_LOCK (1<<2)
#define SYS_NET_LOCK (1<<1)
#define SYS_PHY_LOCK (1<<0)
#define SYSCLK_100MHZ 0
#define SYSCLK_25MHZ 1
#define PHY_MODE_MANUAL 0
#define PHY_MODE_AUTONEGO 1
#define PHY_MODE_TE 2
#define IPV6_ADDR_AUTO 0x00
#define IPV6_ADDR_LLA 0x02
#define IPV6_ADDR_GUA 0x03
#define PHY_CONFBY_HW 0
#define PHY_CONFBY_SW 1
#define PHY_SPEED_10 0
#define PHY_SPEED_100 1
#define PHY_DUPLEX_HALF 0
#define PHY_DUPLEX_FULL 1
#define PHY_LINK_OFF 0
#define PHY_LINK_ON 1
#define PHY_POWER_NORM 0
#define PHY_POWER_DOWN 1
typedef struct wiz_PhyConf_t {
uint8_t by;
uint8_t mode;
uint8_t speed;
uint8_t duplex;
} wiz_PhyConf;
typedef enum {
NETINFO_NONE = 0x00,
NETINFO_STATIC_V4 = 0x01,
NETINFO_STATIC_V6 = 0x02,
NETINFO_STATIC_ALL = 0x03,
NETINFO_SLAAC_V6 = 0x04,
NETINFO_DHCP_V4 = 0x10,
NETINFO_DHCP_V6 = 0x20,
NETINFO_DHCP_ALL = 0x30
} ipconf_mode;
typedef enum {
NETINFO_STATIC = 1,
NETINFO_DHCP
} dhcp_mode;
typedef struct wiz_NetInfo_t {
uint8_t mac[6];
uint8_t ip[4];
uint8_t sn[4];
uint8_t gw[4];
uint8_t lla[16];
uint8_t gua[16];
uint8_t sn6[16];
uint8_t gw6[16];
uint8_t dns[4];
uint8_t dns6[16];
ipconf_mode ipmode;
dhcp_mode dhcp;
} wiz_NetInfo;
typedef enum {
NM_IPB_V4 = (1 << 0),
NM_IPB_V6 = (1 << 1),
NM_WOL = (1 << 2),
NM_PB6_MULTI = (1 << 4),
NM_PB6_ALLNODE = (1 << 5),
NM_MR_MASK = (0x37),
NM_PPPoE = (1 << 8),
NM_DHA_SELECT = (1 << 15),
NM_MR2_MASK = (0x09 << 8),
NM_PB4_ALL = (1 << 16),
NM_TRSTB_V4 = (1 << 17),
NM_PARP_V4 = (1 << 18),
NM_UNRB_V4 = (1 << 19),
NM_NET4_MASK = (0x0F << 16),
NM_PB6_ALL = (1 << 24),
NM_TRSTB_V6 = (1 << 25),
NM_PARP_V6 = (1 << 26),
NM_UNRB_V6 = (1 << 27),
NM_NET6_MASK = (0x0F << 24),
NM_MASK_ALL = (0x0F0F0937)
} netmode_type;
typedef struct wiz_NetTimeout_t {
uint8_t s_retry_cnt;
uint16_t s_time_100us;
uint8_t sl_retry_cnt;
uint16_t sl_time_100us;
} wiz_NetTimeout;
typedef struct wiz_IPAddress_t {
uint8_t ip[16];
uint8_t len;
} wiz_IPAddress;
typedef struct wiz_Prefix_t {
uint8_t len;
uint8_t flag;
uint32_t valid_lifetime;
uint32_t preferred_lifetime;
uint8_t prefix[16];
} wiz_Prefix;
typedef struct wiz_ARP_t {
wiz_IPAddress destinfo;
uint8_t dha[6];
} wiz_ARP;
typedef struct wiz_PING_t {
uint16_t id;
uint16_t seq;
wiz_IPAddress destinfo;
} wiz_PING;
void reg_wizchip_cris_cbfunc(void(*cris_en)(void), void(*cris_ex)(void));
void reg_wizchip_cs_cbfunc(void(*cs_sel)(void), void(*cs_desel)(void));
void reg_wizchip_bus_cbfunc(iodata_t (*bus_rb)(uint32_t addr), void (*bus_wb)(uint32_t addr, iodata_t wb));
void reg_wizchip_spi_cbfunc(uint8_t (*spi_rb)(void), void (*spi_wb)(uint8_t wb));
void reg_wizchip_spiburst_cbfunc(void (*spi_rb)(uint8_t* pBuf, uint16_t len), void (*spi_wb)(uint8_t* pBuf, uint16_t len));
void reg_wizchip_qspi_cbfunc(void (*qspi_rb)(uint8_t opcode, uint16_t addr, uint8_t* pBuf, uint16_t len), void (*qspi_wb)(uint8_t opcode, uint16_t addr, uint8_t* pBuf, uint16_t len));
int8_t ctlwizchip(ctlwizchip_type cwtype, void* arg);
int8_t ctlnetwork(ctlnetwork_type cntype, void* arg);
int8_t ctlnetservice(ctlnetservice_type cnstype, void* arg);
void wizchip_sw_reset(void);
int8_t wizchip_init(uint8_t* txsize, uint8_t* rxsize);
void wizchip_clrinterrupt(intr_kind intr);
intr_kind wizchip_getinterrupt(void);
void wizchip_setinterruptmask(intr_kind intr);
intr_kind wizchip_getinterruptmask(void);
int8_t wizphy_getphylink(void);
int8_t wizphy_getphypmode(void);
void wizphy_reset(void);
void wizphy_setphyconf(wiz_PhyConf* phyconf);
void wizphy_getphyconf(wiz_PhyConf* phyconf);
void wizphy_getphystat(wiz_PhyConf* phyconf);
void wizphy_setphypmode(uint8_t pmode);
void wizchip_setnetinfo(wiz_NetInfo* pnetinfo);
void wizchip_getnetinfo(wiz_NetInfo* pnetinfo);
void wizchip_setnetmode(netmode_type netmode);
netmode_type wizchip_getnetmode(void);
void wizchip_settimeout(wiz_NetTimeout* nettime);
void wizchip_gettimeout(wiz_NetTimeout* nettime);
int8_t wizchip_arp(wiz_ARP* arp);
int8_t wizchip_ping(wiz_PING* ping);
int8_t wizchip_dad(uint8_t* ipv6);
int8_t wizchip_slaac(wiz_Prefix* prefix);
int8_t wizchip_unsolicited(void);
int8_t wizchip_getprefix(wiz_Prefix* prefix);
#ifdef __cplusplus
}
#endif
#endif