xref: /kernel/linux/linux-5.10/drivers/net/usb/sr9700.h (revision 8c2ecf20)
18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * CoreChip-sz SR9700 one chip USB 1.1 Ethernet Devices
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Author : Liu Junliang <liujunliang_ljl@163.com>
68c2ecf20Sopenharmony_ci */
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_ci#ifndef _SR9700_H
98c2ecf20Sopenharmony_ci#define	_SR9700_H
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci/* sr9700 spec. register table on Linux platform */
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci/* Network Control Reg */
148c2ecf20Sopenharmony_ci#define	SR_NCR			0x00
158c2ecf20Sopenharmony_ci#define		NCR_RST			(1 << 0)
168c2ecf20Sopenharmony_ci#define		NCR_LBK			(3 << 1)
178c2ecf20Sopenharmony_ci#define		NCR_FDX			(1 << 3)
188c2ecf20Sopenharmony_ci#define		NCR_WAKEEN		(1 << 6)
198c2ecf20Sopenharmony_ci/* Network Status Reg */
208c2ecf20Sopenharmony_ci#define	SR_NSR			0x01
218c2ecf20Sopenharmony_ci#define		NSR_RXRDY		(1 << 0)
228c2ecf20Sopenharmony_ci#define		NSR_RXOV		(1 << 1)
238c2ecf20Sopenharmony_ci#define		NSR_TX1END		(1 << 2)
248c2ecf20Sopenharmony_ci#define		NSR_TX2END		(1 << 3)
258c2ecf20Sopenharmony_ci#define		NSR_TXFULL		(1 << 4)
268c2ecf20Sopenharmony_ci#define		NSR_WAKEST		(1 << 5)
278c2ecf20Sopenharmony_ci#define		NSR_LINKST		(1 << 6)
288c2ecf20Sopenharmony_ci#define		NSR_SPEED		(1 << 7)
298c2ecf20Sopenharmony_ci/* Tx Control Reg */
308c2ecf20Sopenharmony_ci#define	SR_TCR			0x02
318c2ecf20Sopenharmony_ci#define		TCR_CRC_DIS		(1 << 1)
328c2ecf20Sopenharmony_ci#define		TCR_PAD_DIS		(1 << 2)
338c2ecf20Sopenharmony_ci#define		TCR_LC_CARE		(1 << 3)
348c2ecf20Sopenharmony_ci#define		TCR_CRS_CARE	(1 << 4)
358c2ecf20Sopenharmony_ci#define		TCR_EXCECM		(1 << 5)
368c2ecf20Sopenharmony_ci#define		TCR_LF_EN		(1 << 6)
378c2ecf20Sopenharmony_ci/* Tx Status Reg for Packet Index 1 */
388c2ecf20Sopenharmony_ci#define	SR_TSR1		0x03
398c2ecf20Sopenharmony_ci#define		TSR1_EC			(1 << 2)
408c2ecf20Sopenharmony_ci#define		TSR1_COL		(1 << 3)
418c2ecf20Sopenharmony_ci#define		TSR1_LC			(1 << 4)
428c2ecf20Sopenharmony_ci#define		TSR1_NC			(1 << 5)
438c2ecf20Sopenharmony_ci#define		TSR1_LOC		(1 << 6)
448c2ecf20Sopenharmony_ci#define		TSR1_TLF		(1 << 7)
458c2ecf20Sopenharmony_ci/* Tx Status Reg for Packet Index 2 */
468c2ecf20Sopenharmony_ci#define	SR_TSR2		0x04
478c2ecf20Sopenharmony_ci#define		TSR2_EC			(1 << 2)
488c2ecf20Sopenharmony_ci#define		TSR2_COL		(1 << 3)
498c2ecf20Sopenharmony_ci#define		TSR2_LC			(1 << 4)
508c2ecf20Sopenharmony_ci#define		TSR2_NC			(1 << 5)
518c2ecf20Sopenharmony_ci#define		TSR2_LOC		(1 << 6)
528c2ecf20Sopenharmony_ci#define		TSR2_TLF		(1 << 7)
538c2ecf20Sopenharmony_ci/* Rx Control Reg*/
548c2ecf20Sopenharmony_ci#define	SR_RCR			0x05
558c2ecf20Sopenharmony_ci#define		RCR_RXEN		(1 << 0)
568c2ecf20Sopenharmony_ci#define		RCR_PRMSC		(1 << 1)
578c2ecf20Sopenharmony_ci#define		RCR_RUNT		(1 << 2)
588c2ecf20Sopenharmony_ci#define		RCR_ALL			(1 << 3)
598c2ecf20Sopenharmony_ci#define		RCR_DIS_CRC		(1 << 4)
608c2ecf20Sopenharmony_ci#define		RCR_DIS_LONG	(1 << 5)
618c2ecf20Sopenharmony_ci/* Rx Status Reg */
628c2ecf20Sopenharmony_ci#define	SR_RSR			0x06
638c2ecf20Sopenharmony_ci#define		RSR_AE			(1 << 2)
648c2ecf20Sopenharmony_ci#define		RSR_MF			(1 << 6)
658c2ecf20Sopenharmony_ci#define		RSR_RF			(1 << 7)
668c2ecf20Sopenharmony_ci/* Rx Overflow Counter Reg */
678c2ecf20Sopenharmony_ci#define	SR_ROCR		0x07
688c2ecf20Sopenharmony_ci#define		ROCR_ROC		(0x7F << 0)
698c2ecf20Sopenharmony_ci#define		ROCR_RXFU		(1 << 7)
708c2ecf20Sopenharmony_ci/* Back Pressure Threshold Reg */
718c2ecf20Sopenharmony_ci#define	SR_BPTR		0x08
728c2ecf20Sopenharmony_ci#define		BPTR_JPT		(0x0F << 0)
738c2ecf20Sopenharmony_ci#define		BPTR_BPHW		(0x0F << 4)
748c2ecf20Sopenharmony_ci/* Flow Control Threshold Reg */
758c2ecf20Sopenharmony_ci#define	SR_FCTR		0x09
768c2ecf20Sopenharmony_ci#define		FCTR_LWOT		(0x0F << 0)
778c2ecf20Sopenharmony_ci#define		FCTR_HWOT		(0x0F << 4)
788c2ecf20Sopenharmony_ci/* rx/tx Flow Control Reg */
798c2ecf20Sopenharmony_ci#define	SR_FCR			0x0A
808c2ecf20Sopenharmony_ci#define		FCR_FLCE		(1 << 0)
818c2ecf20Sopenharmony_ci#define		FCR_BKPA		(1 << 4)
828c2ecf20Sopenharmony_ci#define		FCR_TXPEN		(1 << 5)
838c2ecf20Sopenharmony_ci#define		FCR_TXPF		(1 << 6)
848c2ecf20Sopenharmony_ci#define		FCR_TXP0		(1 << 7)
858c2ecf20Sopenharmony_ci/* Eeprom & Phy Control Reg */
868c2ecf20Sopenharmony_ci#define	SR_EPCR		0x0B
878c2ecf20Sopenharmony_ci#define		EPCR_ERRE		(1 << 0)
888c2ecf20Sopenharmony_ci#define		EPCR_ERPRW		(1 << 1)
898c2ecf20Sopenharmony_ci#define		EPCR_ERPRR		(1 << 2)
908c2ecf20Sopenharmony_ci#define		EPCR_EPOS		(1 << 3)
918c2ecf20Sopenharmony_ci#define		EPCR_WEP		(1 << 4)
928c2ecf20Sopenharmony_ci/* Eeprom & Phy Address Reg */
938c2ecf20Sopenharmony_ci#define	SR_EPAR		0x0C
948c2ecf20Sopenharmony_ci#define		EPAR_EROA		(0x3F << 0)
958c2ecf20Sopenharmony_ci#define		EPAR_PHY_ADR_MASK	(0x03 << 6)
968c2ecf20Sopenharmony_ci#define		EPAR_PHY_ADR		(0x01 << 6)
978c2ecf20Sopenharmony_ci/* Eeprom &	Phy Data Reg */
988c2ecf20Sopenharmony_ci#define	SR_EPDR		0x0D	/* 0x0D ~ 0x0E for Data Reg Low & High */
998c2ecf20Sopenharmony_ci/* Wakeup Control Reg */
1008c2ecf20Sopenharmony_ci#define	SR_WCR			0x0F
1018c2ecf20Sopenharmony_ci#define		WCR_MAGICST		(1 << 0)
1028c2ecf20Sopenharmony_ci#define		WCR_LINKST		(1 << 2)
1038c2ecf20Sopenharmony_ci#define		WCR_MAGICEN		(1 << 3)
1048c2ecf20Sopenharmony_ci#define		WCR_LINKEN		(1 << 5)
1058c2ecf20Sopenharmony_ci/* Physical Address Reg */
1068c2ecf20Sopenharmony_ci#define	SR_PAR			0x10	/* 0x10 ~ 0x15 6 bytes for PAR */
1078c2ecf20Sopenharmony_ci/* Multicast Address Reg */
1088c2ecf20Sopenharmony_ci#define	SR_MAR			0x16	/* 0x16 ~ 0x1D 8 bytes for MAR */
1098c2ecf20Sopenharmony_ci/* 0x1e unused */
1108c2ecf20Sopenharmony_ci/* Phy Reset Reg */
1118c2ecf20Sopenharmony_ci#define	SR_PRR			0x1F
1128c2ecf20Sopenharmony_ci#define		PRR_PHY_RST		(1 << 0)
1138c2ecf20Sopenharmony_ci/* Tx sdram Write Pointer Address Low */
1148c2ecf20Sopenharmony_ci#define	SR_TWPAL		0x20
1158c2ecf20Sopenharmony_ci/* Tx sdram Write Pointer Address High */
1168c2ecf20Sopenharmony_ci#define	SR_TWPAH		0x21
1178c2ecf20Sopenharmony_ci/* Tx sdram Read Pointer Address Low */
1188c2ecf20Sopenharmony_ci#define	SR_TRPAL		0x22
1198c2ecf20Sopenharmony_ci/* Tx sdram Read Pointer Address High */
1208c2ecf20Sopenharmony_ci#define	SR_TRPAH		0x23
1218c2ecf20Sopenharmony_ci/* Rx sdram Write Pointer Address Low */
1228c2ecf20Sopenharmony_ci#define	SR_RWPAL		0x24
1238c2ecf20Sopenharmony_ci/* Rx sdram Write Pointer Address High */
1248c2ecf20Sopenharmony_ci#define	SR_RWPAH		0x25
1258c2ecf20Sopenharmony_ci/* Rx sdram Read Pointer Address Low */
1268c2ecf20Sopenharmony_ci#define	SR_RRPAL		0x26
1278c2ecf20Sopenharmony_ci/* Rx sdram Read Pointer Address High */
1288c2ecf20Sopenharmony_ci#define	SR_RRPAH		0x27
1298c2ecf20Sopenharmony_ci/* Vendor ID register */
1308c2ecf20Sopenharmony_ci#define	SR_VID			0x28	/* 0x28 ~ 0x29 2 bytes for VID */
1318c2ecf20Sopenharmony_ci/* Product ID register */
1328c2ecf20Sopenharmony_ci#define	SR_PID			0x2A	/* 0x2A ~ 0x2B 2 bytes for PID */
1338c2ecf20Sopenharmony_ci/* CHIP Revision register */
1348c2ecf20Sopenharmony_ci#define	SR_CHIPR		0x2C
1358c2ecf20Sopenharmony_ci/* 0x2D --> 0xEF unused */
1368c2ecf20Sopenharmony_ci/* USB Device Address */
1378c2ecf20Sopenharmony_ci#define	SR_USBDA		0xF0
1388c2ecf20Sopenharmony_ci#define		USBDA_USBFA		(0x7F << 0)
1398c2ecf20Sopenharmony_ci/* RX packet Counter Reg */
1408c2ecf20Sopenharmony_ci#define	SR_RXC			0xF1
1418c2ecf20Sopenharmony_ci/* Tx packet Counter & USB Status Reg */
1428c2ecf20Sopenharmony_ci#define	SR_TXC_USBS		0xF2
1438c2ecf20Sopenharmony_ci#define		TXC_USBS_TXC0		(1 << 0)
1448c2ecf20Sopenharmony_ci#define		TXC_USBS_TXC1		(1 << 1)
1458c2ecf20Sopenharmony_ci#define		TXC_USBS_TXC2		(1 << 2)
1468c2ecf20Sopenharmony_ci#define		TXC_USBS_EP1RDY		(1 << 5)
1478c2ecf20Sopenharmony_ci#define		TXC_USBS_SUSFLAG	(1 << 6)
1488c2ecf20Sopenharmony_ci#define		TXC_USBS_RXFAULT	(1 << 7)
1498c2ecf20Sopenharmony_ci/* USB Control register */
1508c2ecf20Sopenharmony_ci#define	SR_USBC			0xF4
1518c2ecf20Sopenharmony_ci#define		USBC_EP3NAK		(1 << 4)
1528c2ecf20Sopenharmony_ci#define		USBC_EP3ACK		(1 << 5)
1538c2ecf20Sopenharmony_ci
1548c2ecf20Sopenharmony_ci/* Register access commands and flags */
1558c2ecf20Sopenharmony_ci#define	SR_RD_REGS		0x00
1568c2ecf20Sopenharmony_ci#define	SR_WR_REGS		0x01
1578c2ecf20Sopenharmony_ci#define	SR_WR_REG		0x03
1588c2ecf20Sopenharmony_ci#define	SR_REQ_RD_REG	(USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE)
1598c2ecf20Sopenharmony_ci#define	SR_REQ_WR_REG	(USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE)
1608c2ecf20Sopenharmony_ci
1618c2ecf20Sopenharmony_ci/* parameters */
1628c2ecf20Sopenharmony_ci#define	SR_SHARE_TIMEOUT	1000
1638c2ecf20Sopenharmony_ci#define	SR_EEPROM_LEN		256
1648c2ecf20Sopenharmony_ci#define	SR_MCAST_SIZE		8
1658c2ecf20Sopenharmony_ci#define	SR_MCAST_ADDR_FLAG	0x80
1668c2ecf20Sopenharmony_ci#define	SR_MCAST_MAX		64
1678c2ecf20Sopenharmony_ci#define	SR_TX_OVERHEAD		2	/* 2bytes header */
1688c2ecf20Sopenharmony_ci#define	SR_RX_OVERHEAD		7	/* 3bytes header + 4crc tail */
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ci#endif	/* _SR9700_H */
171