ax88796c_spi.h (1757B)
1/* SPDX-License-Identifier: GPL-2.0-only */ 2/* 3 * Copyright (c) 2010 ASIX Electronics Corporation 4 * Copyright (c) 2020 Samsung Electronics Co., Ltd. 5 * 6 * ASIX AX88796C SPI Fast Ethernet Linux driver 7 */ 8 9#ifndef _AX88796C_SPI_H 10#define _AX88796C_SPI_H 11 12#include <linux/spi/spi.h> 13#include <linux/types.h> 14 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 23 24extern const u8 ax88796c_rx_cmd_buf[]; 25extern const u8 ax88796c_tx_cmd_buf[]; 26 27struct axspi_data { 28 struct spi_device *spi; 29 struct spi_message rx_msg; 30 struct spi_transfer spi_rx_xfer[2]; 31 u8 cmd_buf[6]; 32 u8 rx_buf[6]; 33 u8 comp; 34}; 35 36struct spi_status { 37 u16 isr; 38 u8 status; 39# define AX_STATUS_READY 0x80 40}; 41 42int axspi_read_rxq(struct axspi_data *ax_spi, void *data, int len); 43int axspi_write_txq(const struct axspi_data *ax_spi, void *data, int len); 44u16 axspi_read_reg(struct axspi_data *ax_spi, u8 reg); 45int axspi_write_reg(struct axspi_data *ax_spi, u8 reg, u16 value); 46int axspi_read_status(struct axspi_data *ax_spi, struct spi_status *status); 47int axspi_wakeup(struct axspi_data *ax_spi); 48 49static inline u16 AX_READ(struct axspi_data *ax_spi, u8 offset) 50{ 51 return axspi_read_reg(ax_spi, offset); 52} 53 54static inline int AX_WRITE(struct axspi_data *ax_spi, u16 value, u8 offset) 55{ 56 return axspi_write_reg(ax_spi, offset, value); 57} 58 59static inline int AX_READ_STATUS(struct axspi_data *ax_spi, 60 struct spi_status *status) 61{ 62 return axspi_read_status(ax_spi, status); 63} 64 65static inline int AX_WAKEUP(struct axspi_data *ax_spi) 66{ 67 return axspi_wakeup(ax_spi); 68} 69#endif