a97c69ba4f
ASIX AX88796[1] is a versatile ethernet adapter chip, that can be connected to a CPU with a 8/16-bit bus or with an SPI. This driver supports SPI connection. The driver has been ported from the vendor kernel for ARTIK5[2] boards. Several changes were made to adapt it to the current kernel which include: + updated DT configuration, + clock configuration moved to DT, + new timer, ethtool and gpio APIs, + dev_* instead of pr_* and custom printk() wrappers, + removed awkward vendor power managemtn. + introduced ethtool tunable to control SPI compression [1] https://www.asix.com.tw/products.php?op=pItemdetail&PItemID=104;65;86&PLine=65 [2] https://git.tizen.org/cgit/profile/common/platform/kernel/linux-3.10-artik/ The other ax88796 driver is for NE2000 compatible AX88796L chip. These chips are not compatible. Hence, two separate drivers are required. Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
70 lines
1.7 KiB
C
70 lines
1.7 KiB
C
/* SPDX-License-Identifier: GPL-2.0-only */
|
|
/*
|
|
* Copyright (c) 2010 ASIX Electronics Corporation
|
|
* Copyright (c) 2020 Samsung Electronics Co., Ltd.
|
|
*
|
|
* ASIX AX88796C SPI Fast Ethernet Linux driver
|
|
*/
|
|
|
|
#ifndef _AX88796C_SPI_H
|
|
#define _AX88796C_SPI_H
|
|
|
|
#include <linux/spi/spi.h>
|
|
#include <linux/types.h>
|
|
|
|
/* Definition of SPI command */
|
|
#define AX_SPICMD_WRITE_TXQ 0x02
|
|
#define AX_SPICMD_READ_REG 0x03
|
|
#define AX_SPICMD_READ_STATUS 0x05
|
|
#define AX_SPICMD_READ_RXQ 0x0B
|
|
#define AX_SPICMD_BIDIR_WRQ 0xB2
|
|
#define AX_SPICMD_WRITE_REG 0xD8
|
|
#define AX_SPICMD_EXIT_PWD 0xAB
|
|
|
|
extern const u8 ax88796c_rx_cmd_buf[];
|
|
extern const u8 ax88796c_tx_cmd_buf[];
|
|
|
|
struct axspi_data {
|
|
struct spi_device *spi;
|
|
struct spi_message rx_msg;
|
|
struct spi_transfer spi_rx_xfer[2];
|
|
u8 cmd_buf[6];
|
|
u8 rx_buf[6];
|
|
u8 comp;
|
|
};
|
|
|
|
struct spi_status {
|
|
u16 isr;
|
|
u8 status;
|
|
# define AX_STATUS_READY 0x80
|
|
};
|
|
|
|
int axspi_read_rxq(struct axspi_data *ax_spi, void *data, int len);
|
|
int axspi_write_txq(const struct axspi_data *ax_spi, void *data, int len);
|
|
u16 axspi_read_reg(struct axspi_data *ax_spi, u8 reg);
|
|
int axspi_write_reg(struct axspi_data *ax_spi, u8 reg, u16 value);
|
|
int axspi_read_status(struct axspi_data *ax_spi, struct spi_status *status);
|
|
int axspi_wakeup(struct axspi_data *ax_spi);
|
|
|
|
static inline u16 AX_READ(struct axspi_data *ax_spi, u8 offset)
|
|
{
|
|
return axspi_read_reg(ax_spi, offset);
|
|
}
|
|
|
|
static inline int AX_WRITE(struct axspi_data *ax_spi, u16 value, u8 offset)
|
|
{
|
|
return axspi_write_reg(ax_spi, offset, value);
|
|
}
|
|
|
|
static inline int AX_READ_STATUS(struct axspi_data *ax_spi,
|
|
struct spi_status *status)
|
|
{
|
|
return axspi_read_status(ax_spi, status);
|
|
}
|
|
|
|
static inline int AX_WAKEUP(struct axspi_data *ax_spi)
|
|
{
|
|
return axspi_wakeup(ax_spi);
|
|
}
|
|
#endif
|