18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci *  FUJITSU Extended Socket Network Device driver
48c2ecf20Sopenharmony_ci *  Copyright (c) 2015 FUJITSU LIMITED
58c2ecf20Sopenharmony_ci */
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ci#ifndef FJES_REGS_H_
88c2ecf20Sopenharmony_ci#define FJES_REGS_H_
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#include <linux/bitops.h>
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#define XSCT_DEVICE_REGISTER_SIZE 0x1000
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ci/* register offset */
158c2ecf20Sopenharmony_ci/* Information registers */
168c2ecf20Sopenharmony_ci#define XSCT_OWNER_EPID     0x0000  /* Owner EPID */
178c2ecf20Sopenharmony_ci#define XSCT_MAX_EP         0x0004  /* Maximum EP */
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ci/* Device Control registers */
208c2ecf20Sopenharmony_ci#define XSCT_DCTL           0x0010  /* Device Control */
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_ci/* Command Control registers */
238c2ecf20Sopenharmony_ci#define XSCT_CR             0x0020  /* Command request */
248c2ecf20Sopenharmony_ci#define XSCT_CS             0x0024  /* Command status */
258c2ecf20Sopenharmony_ci#define XSCT_SHSTSAL        0x0028  /* Share status address Low */
268c2ecf20Sopenharmony_ci#define XSCT_SHSTSAH        0x002C  /* Share status address High */
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci#define XSCT_REQBL          0x0034  /* Request Buffer length */
298c2ecf20Sopenharmony_ci#define XSCT_REQBAL         0x0038  /* Request Buffer Address Low */
308c2ecf20Sopenharmony_ci#define XSCT_REQBAH         0x003C  /* Request Buffer Address High */
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_ci#define XSCT_RESPBL         0x0044  /* Response Buffer Length */
338c2ecf20Sopenharmony_ci#define XSCT_RESPBAL        0x0048  /* Response Buffer Address Low */
348c2ecf20Sopenharmony_ci#define XSCT_RESPBAH        0x004C  /* Response Buffer Address High */
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci/* Interrupt Control registers */
378c2ecf20Sopenharmony_ci#define XSCT_IS             0x0080  /* Interrupt status */
388c2ecf20Sopenharmony_ci#define XSCT_IMS            0x0084  /* Interrupt mask set */
398c2ecf20Sopenharmony_ci#define XSCT_IMC            0x0088  /* Interrupt mask clear */
408c2ecf20Sopenharmony_ci#define XSCT_IG             0x008C  /* Interrupt generator */
418c2ecf20Sopenharmony_ci#define XSCT_ICTL           0x0090  /* Interrupt control */
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci/* register structure */
448c2ecf20Sopenharmony_ci/* Information registers */
458c2ecf20Sopenharmony_ciunion REG_OWNER_EPID {
468c2ecf20Sopenharmony_ci	struct {
478c2ecf20Sopenharmony_ci		__le32 epid:16;
488c2ecf20Sopenharmony_ci		__le32:16;
498c2ecf20Sopenharmony_ci	} bits;
508c2ecf20Sopenharmony_ci	__le32 reg;
518c2ecf20Sopenharmony_ci};
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ciunion REG_MAX_EP {
548c2ecf20Sopenharmony_ci	struct {
558c2ecf20Sopenharmony_ci		__le32 maxep:16;
568c2ecf20Sopenharmony_ci		__le32:16;
578c2ecf20Sopenharmony_ci	} bits;
588c2ecf20Sopenharmony_ci	__le32 reg;
598c2ecf20Sopenharmony_ci};
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ci/* Device Control registers */
628c2ecf20Sopenharmony_ciunion REG_DCTL {
638c2ecf20Sopenharmony_ci	struct {
648c2ecf20Sopenharmony_ci		__le32 reset:1;
658c2ecf20Sopenharmony_ci		__le32 rsv0:15;
668c2ecf20Sopenharmony_ci		__le32 rsv1:16;
678c2ecf20Sopenharmony_ci	} bits;
688c2ecf20Sopenharmony_ci	__le32 reg;
698c2ecf20Sopenharmony_ci};
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci/* Command Control registers */
728c2ecf20Sopenharmony_ciunion REG_CR {
738c2ecf20Sopenharmony_ci	struct {
748c2ecf20Sopenharmony_ci		__le32 req_code:16;
758c2ecf20Sopenharmony_ci		__le32 err_info:14;
768c2ecf20Sopenharmony_ci		__le32 error:1;
778c2ecf20Sopenharmony_ci		__le32 req_start:1;
788c2ecf20Sopenharmony_ci	} bits;
798c2ecf20Sopenharmony_ci	__le32 reg;
808c2ecf20Sopenharmony_ci};
818c2ecf20Sopenharmony_ci
828c2ecf20Sopenharmony_ciunion REG_CS {
838c2ecf20Sopenharmony_ci	struct {
848c2ecf20Sopenharmony_ci		__le32 req_code:16;
858c2ecf20Sopenharmony_ci		__le32 rsv0:14;
868c2ecf20Sopenharmony_ci		__le32 busy:1;
878c2ecf20Sopenharmony_ci		__le32 complete:1;
888c2ecf20Sopenharmony_ci	} bits;
898c2ecf20Sopenharmony_ci	__le32 reg;
908c2ecf20Sopenharmony_ci};
918c2ecf20Sopenharmony_ci
928c2ecf20Sopenharmony_ci/* Interrupt Control registers */
938c2ecf20Sopenharmony_ciunion REG_ICTL {
948c2ecf20Sopenharmony_ci	struct {
958c2ecf20Sopenharmony_ci		__le32 automak:1;
968c2ecf20Sopenharmony_ci		__le32 rsv0:31;
978c2ecf20Sopenharmony_ci	} bits;
988c2ecf20Sopenharmony_ci	__le32 reg;
998c2ecf20Sopenharmony_ci};
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_cienum REG_ICTL_MASK {
1028c2ecf20Sopenharmony_ci	REG_ICTL_MASK_INFO_UPDATE     = 1 << 20,
1038c2ecf20Sopenharmony_ci	REG_ICTL_MASK_DEV_STOP_REQ    = 1 << 19,
1048c2ecf20Sopenharmony_ci	REG_ICTL_MASK_TXRX_STOP_REQ   = 1 << 18,
1058c2ecf20Sopenharmony_ci	REG_ICTL_MASK_TXRX_STOP_DONE  = 1 << 17,
1068c2ecf20Sopenharmony_ci	REG_ICTL_MASK_RX_DATA         = 1 << 16,
1078c2ecf20Sopenharmony_ci	REG_ICTL_MASK_ALL             = GENMASK(20, 16),
1088c2ecf20Sopenharmony_ci};
1098c2ecf20Sopenharmony_ci
1108c2ecf20Sopenharmony_cienum REG_IS_MASK {
1118c2ecf20Sopenharmony_ci	REG_IS_MASK_IS_ASSERT	= 1 << 31,
1128c2ecf20Sopenharmony_ci	REG_IS_MASK_EPID	= GENMASK(15, 0),
1138c2ecf20Sopenharmony_ci};
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_cistruct fjes_hw;
1168c2ecf20Sopenharmony_ci
1178c2ecf20Sopenharmony_ciu32 fjes_hw_rd32(struct fjes_hw *hw, u32 reg);
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ci#define wr32(reg, val) \
1208c2ecf20Sopenharmony_cido { \
1218c2ecf20Sopenharmony_ci	u8 *base = hw->base; \
1228c2ecf20Sopenharmony_ci	writel((val), &base[(reg)]); \
1238c2ecf20Sopenharmony_ci} while (0)
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ci#define rd32(reg) (fjes_hw_rd32(hw, reg))
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci#endif /* FJES_REGS_H_ */
128