1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Copyright (c) 2010 ASIX Electronics Corporation
4 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
6 * ASIX AX88796C SPI Fast Ethernet Linux driver
9 #ifndef _AX88796C_SPI_H
10 #define _AX88796C_SPI_H
12 #include <linux/spi/spi.h>
13 #include <linux/types.h>
15 /* Definition of SPI command */
16 #define AX_SPICMD_WRITE_TXQ 0x02
17 #define AX_SPICMD_READ_REG 0x03
18 #define AX_SPICMD_READ_STATUS 0x05
19 #define AX_SPICMD_READ_RXQ 0x0B
20 #define AX_SPICMD_BIDIR_WRQ 0xB2
21 #define AX_SPICMD_WRITE_REG 0xD8
22 #define AX_SPICMD_EXIT_PWD 0xAB
24 extern const u8 ax88796c_rx_cmd_buf
[];
25 extern const u8 ax88796c_tx_cmd_buf
[];
28 struct spi_device
*spi
;
29 struct spi_message rx_msg
;
30 struct spi_transfer spi_rx_xfer
[2];
39 # define AX_STATUS_READY 0x80
42 int axspi_read_rxq(struct axspi_data
*ax_spi
, void *data
, int len
);
43 int axspi_write_txq(const struct axspi_data
*ax_spi
, void *data
, int len
);
44 u16
axspi_read_reg(struct axspi_data
*ax_spi
, u8 reg
);
45 int axspi_write_reg(struct axspi_data
*ax_spi
, u8 reg
, u16 value
);
46 int axspi_read_status(struct axspi_data
*ax_spi
, struct spi_status
*status
);
47 int axspi_wakeup(struct axspi_data
*ax_spi
);
49 static inline u16
AX_READ(struct axspi_data
*ax_spi
, u8 offset
)
51 return axspi_read_reg(ax_spi
, offset
);
54 static inline int AX_WRITE(struct axspi_data
*ax_spi
, u16 value
, u8 offset
)
56 return axspi_write_reg(ax_spi
, offset
, value
);
59 static inline int AX_READ_STATUS(struct axspi_data
*ax_spi
,
60 struct spi_status
*status
)
62 return axspi_read_status(ax_spi
, status
);
65 static inline int AX_WAKEUP(struct axspi_data
*ax_spi
)
67 return axspi_wakeup(ax_spi
);