From: Marc Kleine-Budde <mkl@pengutronix.de>
To: "Łukasz Stelmach" <l.stelmach@samsung.com>,
"Andrew Lunn" <andrew@lunn.ch>,
jim.cromie@gmail.com, "Heiner Kallweit" <hkallweit1@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
"Jakub Kicinski" <kuba@kernel.org>,
"Rob Herring" <robh+dt@kernel.org>,
"Kukjin Kim" <kgene@kernel.org>,
"Krzysztof Kozlowski" <krzk@kernel.org>,
"Russell King" <linux@armlinux.org.uk>,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-samsung-soc@vger.kernel.org
Cc: "Marek Szyprowski" <m.szyprowski@samsung.com>,
"Bartłomiej Żolnierkiewicz" <b.zolnierkie@samsung.com>
Subject: Re: [PATCH v4 3/5] net: ax88796c: ASIX AX88796C SPI Ethernet Adapter Driver
Date: Thu, 29 Oct 2020 18:27:33 +0100 [thread overview]
Message-ID: <69bc0b01-4f97-8c7c-7504-bbcf9c504efa@pengutronix.de> (raw)
In-Reply-To: <20201028214012.9712-4-l.stelmach@samsung.com>
[-- Attachment #1.1: Type: text/plain, Size: 7549 bytes --]
On 10/28/20 10:40 PM, Łukasz Stelmach wrote:
> 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.
>
> [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>
> ---
> MAINTAINERS | 6 +
> drivers/net/ethernet/Kconfig | 1 +
> drivers/net/ethernet/Makefile | 1 +
> drivers/net/ethernet/asix/Kconfig | 22 +
> drivers/net/ethernet/asix/Makefile | 6 +
> drivers/net/ethernet/asix/ax88796c_ioctl.c | 197 ++++
> drivers/net/ethernet/asix/ax88796c_ioctl.h | 26 +
> drivers/net/ethernet/asix/ax88796c_main.c | 1144 ++++++++++++++++++++
> drivers/net/ethernet/asix/ax88796c_main.h | 578 ++++++++++
> drivers/net/ethernet/asix/ax88796c_spi.c | 111 ++
> drivers/net/ethernet/asix/ax88796c_spi.h | 69 ++
> 11 files changed, 2161 insertions(+)
> create mode 100644 drivers/net/ethernet/asix/Kconfig
> create mode 100644 drivers/net/ethernet/asix/Makefile
> create mode 100644 drivers/net/ethernet/asix/ax88796c_ioctl.c
> create mode 100644 drivers/net/ethernet/asix/ax88796c_ioctl.h
> create mode 100644 drivers/net/ethernet/asix/ax88796c_main.c
> create mode 100644 drivers/net/ethernet/asix/ax88796c_main.h
> create mode 100644 drivers/net/ethernet/asix/ax88796c_spi.c
> create mode 100644 drivers/net/ethernet/asix/ax88796c_spi.h
[...]
> +enum watchdog_state {
> + chk_link = 0,
> + chk_cable,
> + ax_nop,
> +};
> +
> +struct ax88796c_device {
> + struct resource *addr_res; /* resources found */
> + struct resource *addr_req; /* resources requested */
> + struct resource *irq_res;
> +
> + struct spi_device *spi;
> + struct net_device *ndev;
> + struct net_device_stats stats;
> +
> + struct timer_list watchdog;
> + enum watchdog_state w_state;
> + size_t w_ticks;
are these used?
> +
> + struct work_struct ax_work;
> +
> + struct mutex spi_lock; /* device access */
> +
> + struct sk_buff_head tx_wait_q;
> +
> + struct axspi_data ax_spi;
> +
> + struct mii_bus *mdiobus;
> + struct phy_device *phydev;
> +
> + int msg_enable;
> +
> + u16 seq_num;
> +
> + u8 multi_filter[AX_MCAST_FILTER_SIZE];
> +
> + int link;
> + int speed;
> + int duplex;
> + int pause;
> + int asym_pause;
> + int flowctrl;
> + #define AX_FC_NONE 0
> + #define AX_FC_RX BIT(0)
> + #define AX_FC_TX BIT(1)
> + #define AX_FC_ANEG BIT(2)
> +
> + unsigned long capabilities;
> + #define AX_CAP_DMA BIT(0)
> + #define AX_CAP_COMP BIT(1)
> + #define AX_CAP_BIDIR BIT(2)
> +
> + u8 plat_endian;
> + #define PLAT_LITTLE_ENDIAN 0
> + #define PLAT_BIG_ENDIAN 1
> +
> + unsigned long flags;
> + #define EVENT_INTR BIT(0)
> + #define EVENT_TX BIT(1)
> + #define EVENT_SET_MULTI BIT(2)
> +
> +};
> +
> +#define to_ax88796c_device(ndev) ((struct ax88796c_device *)netdev_priv(ndev))
> +
> +enum skb_state {
> + illegal = 0,
> + tx_done,
> + rx_done,
> + rx_err,
> +};
> +
> +struct skb_data {
> + enum skb_state state;
> + struct net_device *ndev;
> + struct sk_buff *skb;
> + size_t len;
> + dma_addr_t phy_addr;
unused?
[...]
> diff --git a/drivers/net/ethernet/asix/ax88796c_spi.c b/drivers/net/ethernet/asix/ax88796c_spi.c
> new file mode 100644
> index 000000000000..1a20bbeb4dc1
> --- /dev/null
> +++ b/drivers/net/ethernet/asix/ax88796c_spi.c
> @@ -0,0 +1,111 @@
> +// 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
> + */
> +
> +#define pr_fmt(fmt) "ax88796c: " fmt
> +
> +#include <linux/string.h>
> +#include <linux/spi/spi.h>
> +
> +#include "ax88796c_spi.h"
> +
> +/* driver bus management functions */
> +int axspi_wakeup(const struct axspi_data *ax_spi)
> +{
> + u8 tx_buf;
> + int ret;
> +
> + tx_buf = AX_SPICMD_EXIT_PWD; /* OP */
> + ret = spi_write(ax_spi->spi, &tx_buf, 1);
spi_write() needs a DMA safe buffer.
> + if (ret)
> + dev_err(&ax_spi->spi->dev, "%s() failed: ret = %d\n", __func__, ret);
> + return ret;
> +}
> +
> +int axspi_read_status(const struct axspi_data *ax_spi, struct spi_status *status)
> +{
> + u8 tx_buf;
> + int ret;
> +
> + /* OP */
> + tx_buf = AX_SPICMD_READ_STATUS;
> + ret = spi_write_then_read(ax_spi->spi, &tx_buf, 1, (u8 *)&status, 3);
> + if (ret)
> + dev_err(&ax_spi->spi->dev, "%s() failed: ret = %d\n", __func__, ret);
> + else
> + le16_to_cpus(&status->isr);
> +
> + return ret;
> +}
> +
> +int axspi_read_rxq(struct axspi_data *ax_spi, void *data, int len)
> +{
> + struct spi_transfer *xfer = ax_spi->spi_rx_xfer;
> + int ret;
> +
> + memcpy(ax_spi->cmd_buf, rx_cmd_buf, 5);
> +
> + xfer->tx_buf = ax_spi->cmd_buf;
> + xfer->rx_buf = NULL;
> + xfer->len = ax_spi->comp ? 2 : 5;
> + xfer->bits_per_word = 8;
> + spi_message_add_tail(xfer, &ax_spi->rx_msg);
> +
> + xfer++;
> + xfer->rx_buf = data;
> + xfer->tx_buf = NULL;
> + xfer->len = len;
> + xfer->bits_per_word = 8;
> + spi_message_add_tail(xfer, &ax_spi->rx_msg);
> + ret = spi_sync(ax_spi->spi, &ax_spi->rx_msg);
> + if (ret)
> + dev_err(&ax_spi->spi->dev, "%s() failed: ret = %d\n", __func__, ret);
> +
> + return ret;
> +}
> +
> +int axspi_write_txq(const struct axspi_data *ax_spi, void *data, int len)
> +{
> + return spi_write(ax_spi->spi, data, len);
> +}
> +
> +u16 axspi_read_reg(const struct axspi_data *ax_spi, u8 reg)
> +{
> + u8 tx_buf[4];
> + u16 rx_buf = 0;
> + int ret;
> + int len = ax_spi->comp ? 3 : 4;
> +
> + tx_buf[0] = 0x03; /* OP code read register */
> + tx_buf[1] = reg; /* register address */
> + tx_buf[2] = 0xFF; /* dumy cycle */
> + tx_buf[3] = 0xFF; /* dumy cycle */
> + ret = spi_write_then_read(ax_spi->spi, tx_buf, len, (u8 *)&rx_buf, 2);
> + if (ret)
> + dev_err(&ax_spi->spi->dev, "%s() failed: ret = %d\n", __func__, ret);
> + else
> + le16_to_cpus(&rx_buf);
> +
> + return rx_buf;
> +}
> +
> +int axspi_write_reg(const struct axspi_data *ax_spi, u8 reg, u16 value)
> +{
> + u8 tx_buf[4];
> + int ret;
> +
> + tx_buf[0] = AX_SPICMD_WRITE_REG; /* OP code read register */
> + tx_buf[1] = reg; /* register address */
> + tx_buf[2] = value;
> + tx_buf[3] = value >> 8;
> +
> + ret = spi_write(ax_spi->spi, tx_buf, 4);
I think you need DMA safe mem for spi_write().
Marc
--
Pengutronix e.K. | Marc Kleine-Budde |
Embedded Linux | https://www.pengutronix.de |
Vertretung West/Dortmund | Phone: +49-231-2826-924 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2020-10-29 17:36 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20201028214017eucas1p21a93b489acce80ff8a2fd1adfc9c1649@eucas1p2.samsung.com>
2020-10-28 21:40 ` [PATCH v4 0/5] AX88796C SPI Ethernet Adapter Łukasz Stelmach
[not found] ` <CGME20201028214016eucas1p1257ca6d0eacfbb97a42d97a5e45e0370@eucas1p1.samsung.com>
2020-10-28 21:40 ` [PATCH v4 1/5] dt-bindings: vendor-prefixes: Add asix prefix Łukasz Stelmach
[not found] ` <CGME20201028214017eucas1p251d5bd9f5f9db68da4ccefe8ee5e7c13@eucas1p2.samsung.com>
2020-10-28 21:40 ` [PATCH v4 2/5] dt-bindings: net: Add bindings for AX88796C SPI Ethernet Adapter Łukasz Stelmach
2020-10-29 15:28 ` Rob Herring
2020-10-29 17:06 ` Marc Kleine-Budde
[not found] ` <CGME20201029200708eucas1p1f00cdaf2c217056427dcd08f9d0d8bc9@eucas1p1.samsung.com>
2020-10-29 20:06 ` Lukasz Stelmach
[not found] ` <CGME20201028214016eucas1p19d2049a4edb4461b2424358e206dc59c@eucas1p1.samsung.com>
2020-10-28 21:40 ` [PATCH v4 3/5] net: ax88796c: ASIX AX88796C SPI Ethernet Adapter Driver Łukasz Stelmach
2020-10-29 0:31 ` Andrew Lunn
[not found] ` <CGME20201029131011eucas1p1194c5614ca8f5d3835f888c8d1c09fa1@eucas1p1.samsung.com>
2020-10-29 13:09 ` Lukasz Stelmach
[not found] ` <CGME20201029203142eucas1p138b7a69cf72e5ad0b1ecd8134adcbccf@eucas1p1.samsung.com>
2020-10-29 20:31 ` Lukasz Stelmach
2020-10-29 21:06 ` Andrew Lunn
2020-10-29 17:27 ` Marc Kleine-Budde [this message]
[not found] ` <CGME20201029230203eucas1p1d496586b195f2c01f1e5f69739c5ddfe@eucas1p1.samsung.com>
2020-10-29 23:01 ` Lukasz Stelmach
[not found] ` <CGME20201028214017eucas1p193f14480d56dfc49f07f27e4e7933ca5@eucas1p1.samsung.com>
2020-10-28 21:40 ` [PATCH v4 4/5] ARM: dts: exynos: Add Ethernet to Artik 5 board Łukasz Stelmach
[not found] ` <CGME20201028214017eucas1p16bc64d4596386177f4060689a6443098@eucas1p1.samsung.com>
2020-10-28 21:40 ` [PATCH v4 5/5] ARM: defconfig: Enable ax88796c driver Łukasz Stelmach
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=69bc0b01-4f97-8c7c-7504-bbcf9c504efa@pengutronix.de \
--to=mkl@pengutronix.de \
--cc=andrew@lunn.ch \
--cc=b.zolnierkie@samsung.com \
--cc=davem@davemloft.net \
--cc=devicetree@vger.kernel.org \
--cc=hkallweit1@gmail.com \
--cc=jim.cromie@gmail.com \
--cc=kgene@kernel.org \
--cc=krzk@kernel.org \
--cc=kuba@kernel.org \
--cc=l.stelmach@samsung.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=m.szyprowski@samsung.com \
--cc=netdev@vger.kernel.org \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).