Skip to contentSkip to conversation

dt-bindings: vendor-prefixes: Add asix prefix

PATCH Applied Łukasz Stelmach 2 participants 5 messages Oct 20, 2021 – Oct 21, 2021 1 message not in the archive

Subsystems (5)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): CGME20211020182427eucas1p1f8409613d882d8247bc3c014c8219b84@eucas1p1.samsung.com

Łukasz Stelmach

author maintainer
#1 lore raw

v17 cover AX88796C SPI Ethernet Adapter

This is a driver for AX88796C Ethernet Adapter connected in SPI mode as found on ARTIK5 evaluation board. The driver has been ported from a v3.10.9 vendor kernel for ARTIK5 board.

Changes in v17:
- marked no_regs_list as const
- added myself as MODULE_AUTHOR()
- rearranged locking in ax88796c_close() to prevent race condition in case ax88796c_work() wakes the queue after trasmission.

Changes in v16:
- rebased onto net-next 5.15-rc2 (7fec4d39198b)

Changes in v15:
- rebased onto net-next 5.14-rc2 (268ca4129d8d)
- added explicit cast of le16_to_cpus() argument to u16* (reported by: kernel test robot <[email protected]>)
- removed invalid and superfluous call to u64_stats_init() (reported by: Jakub Kicinski <[email protected]>)

Changes in v14:
- rebased onto net-next 5.14-rc1 (0d6835ffe50c)

Changes in v13:
- rebased onto net-next (ebbf5fcb94a7)
- minor fix: use u64_stats_update_{begin_irqsave,end_irqrestore}
- minor fix: initialize the syncp lock

Changes in v12:
- rebased to net-next-5.13
- added missing spaces after commas
- corrected indentation

Changes in v11:
- changed stat counters to 64-bit
- replaced WARN_ON(!mutex_is_locked()) with lockdep_assert_held()
- replaced ax88796c_free_skb_queue() with __skb_queue_purge()
- added cancel_work_sync() for ax_work
- removed unused fields of struct skb_data
- replaced MAX() with max() from minmax.h
- rebased to net-next (resend)

Changes in v10:
- removed unused variable

Changes in v9:
- used pskb_extend_head()
- used ethtool private flags instead of tunables to switch SPI compression
- changed
- alloc_skb() to netdev_alloc(skb)
- __pskb_trim() to pskb_trim()
- removed:
- chages to skb->truesize
- unnecessary casting to short
- return f() in a void function
- IRQF_SHARED flags
- unnecessary memset(0) of kzalloc()ed buffer
- unused endiannes detection
- unnecessary __packed attribute for some structures
- added:
- temporary variable in AX_WRITE/READ sequences
- missin mutex_unlock() in error paths
- axspi_read_reg() returns a constant value in case of an error

Changes in v8:
- fixed the entry in MAINTAINERS
- removed unnecessary netif_err()
- changed netif_rx() to netif_rx_ni() for code running in a process context
- added explicit type casting for ~BIT()

Changes in v7:
- removed duplicate code
- moved a constant buffer definition away from a header file

Changes in v6:
- fixed typos in Kconfig
- checked argument value in ax88796c_set_tunable
- updated tags in commit messages

Changes in v5:
- coding style (local variable declarations)
- added spi0 node in the DT binding example and removed interrupt-parent
- removed comp module parameter
- added CONFIG_SPI_AX88796C_COMPRESSION option to set the initial state of SPI compression
- introduced new ethtool tunable "spi-compression" to control SPI transfer compression
- removed unused fields in struct ax88796c_device
- switched from using buffers allocated on stack for SPI transfers to DMA safe ones embedded in struct ax_spi and allocated with kmalloc()

Changes in v4:
- fixed compilation problems in asix,ax88796c.yaml and in ax88796c_main.c introduced in v3

Changes in v3:
- modify vendor-prefixes.yaml in a separate patch
- fix several problems in the dt binding
- removed unnecessary descriptions and properties
- changed the order of entries
- fixed problems with missing defines in the example
- change (1 << N) to BIT(N), left a few (0 << N)
- replace ax88796c_get_link(), ax88796c_get_link_ksettings(), ax88796c_set_link_ksettings(), ax88796c_nway_reset(), ax88796c_set_mac_address() with appropriate kernel functions.
- disable PHY auto-polling in MAC and use PHYLIB to track the state of PHY and configure MAC
- propagate return values instead of returning constants in several places
- add WARN_ON() for unlocked mutex
- remove local work queue and use the system_wq
- replace phy_connect_direct() with phy_connect() and move devm_register_netdev() to the end of ax88796c_probe() (Unlike phy_connect_direct() phy_connect() does not crash if the network device isn't registered yet.)
- remove error messages on ENOMEM
- move free_irq() to the end of ax88796c_close() to avoid race condition
- implement flow-control

Changes in v2:
- use phylib
- added DT bindings
- moved #includes to *.c files
- used mutex instead of a semaphore for locking
- renamed some constants
- added error propagation for several functions
- used ethtool for dumping registers
- added control over checksum offloading
- remove vendor specific PM
- removed macaddr module parameter and added support for reading a MAC address from platform data (e.g. DT)
- removed dependency on SPI from NET_VENDOR_ASIX
- added an entry in the MAINTAINERS file
- simplified logging with appropriate netif_* and netdev_* helpers
- lots of style fixes

Łukasz Stelmach (3):
dt-bindings: vendor-prefixes: Add asix prefix
dt-bindings: net: Add bindings for AX88796C SPI Ethernet Adapter
net: ax88796c: ASIX AX88796C SPI Ethernet Adapter Driver

 .../bindings/net/asix,ax88796c.yaml           |   73 ++
 .../devicetree/bindings/vendor-prefixes.yaml  |    2 +
 MAINTAINERS                                   |    6 +
 drivers/net/ethernet/Kconfig                  |    1 +
 drivers/net/ethernet/Makefile                 |    1 +
 drivers/net/ethernet/asix/Kconfig             |   35 +
 drivers/net/ethernet/asix/Makefile            |    6 +
 drivers/net/ethernet/asix/ax88796c_ioctl.c    |  239 ++++
 drivers/net/ethernet/asix/ax88796c_ioctl.h    |   26 +
 drivers/net/ethernet/asix/ax88796c_main.c     | 1163 +++++++++++++++++
 drivers/net/ethernet/asix/ax88796c_main.h     |  568 ++++++++
 drivers/net/ethernet/asix/ax88796c_spi.c      |  115 ++
 drivers/net/ethernet/asix/ax88796c_spi.h      |   69 +
 13 files changed, 2304 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/asix,ax88796c.yaml
 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
Signature · 1 line
2.30.2
author maintainer
#2 lore raw

PATCH v17 1/3 dt-bindings: vendor-prefixes: Add asix prefix

Add the prefix for ASIX Electronics Corporation.

---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
index a867f7102c35..e2eb0c738f3a 100644
@@ -131,6 +131,8 @@ patternProperties:
     description: Asahi Kasei Corp.
   "^asc,.*":
     description: All Sensors Corporation
+  "^asix,.*":
+    description: ASIX Electronics Corporation
   "^aspeed,.*":
     description: ASPEED Technology Inc.
   "^asus,.*":
Signature · 1 line
2.30.2
author maintainer
#3 lore raw

PATCH v17 2/3 dt-bindings: net: Add bindings for AX88796C SPI Ethernet Adapter

In reply to Łukasz Stelmach

Add bindings for AX88796C SPI Ethernet Adapter.

---
 .../bindings/net/asix,ax88796c.yaml           | 73 +++++++++++++++++++
 1 file changed, 73 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/asix,ax88796c.yaml
Documentation/devicetree/bindings/net/asix,ax88796c.yaml new file +73 -0
new file mode 100644
index 000000000000..699ebf452479
@@ -0,0 +1,73 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/asix,ax88796c.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ASIX AX88796C SPI Ethernet Adapter
+
+maintainers:
+  - Łukasz Stelmach <[email protected]>
+
+description: |
+  ASIX AX88796C is an Ethernet controller with a built in PHY. This
+  describes SPI mode of the chip.
+
+  The node for this driver must be a child node of an SPI controller,
+  hence all mandatory properties described in
+  ../spi/spi-controller.yaml must be specified.
+
+allOf:
+  - $ref: ethernet-controller.yaml#
+
+properties:
+  compatible:
+    const: asix,ax88796c
+
+  reg:
+    maxItems: 1
+
+  spi-max-frequency:
+    maximum: 40000000
+
+  interrupts:
+    maxItems: 1
+
+  reset-gpios:
+    description:
+      A GPIO line handling reset of the chip. As the line is active low,
+      it should be marked GPIO_ACTIVE_LOW.
+    maxItems: 1
+
+  local-mac-address: true
+
+  mac-address: true
+
+required:
+  - compatible
+  - reg
+  - spi-max-frequency
+  - interrupts
+  - reset-gpios
+
+additionalProperties: false
+
+examples:
+  # Artik5 eval board
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/gpio/gpio.h>
+    spi0 {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        ethernet@0 {
+            compatible = "asix,ax88796c";
+            reg = <0x0>;
+            local-mac-address = [00 00 00 00 00 00]; /* Filled in by a bootloader */
+            interrupt-parent = <&gpx2>;
+            interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
+            spi-max-frequency = <40000000>;
+            reset-gpios = <&gpe0 2 GPIO_ACTIVE_LOW>;
+        };
+    };
Signature · 1 line
2.30.2
author maintainer
#4 lore raw

PATCH v17 3/3 net: ax88796c: ASIX AX88796C SPI Ethernet Adapter Driver

In reply to Łukasz Stelmach

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.

---
 MAINTAINERS                                |    6 +
 drivers/net/ethernet/Kconfig               |    1 +
 drivers/net/ethernet/Makefile              |    1 +
 drivers/net/ethernet/asix/Kconfig          |   35 +
 drivers/net/ethernet/asix/Makefile         |    6 +
 drivers/net/ethernet/asix/ax88796c_ioctl.c |  239 ++++
 drivers/net/ethernet/asix/ax88796c_ioctl.h |   26 +
 drivers/net/ethernet/asix/ax88796c_main.c  | 1163 ++++++++++++++++++++
 drivers/net/ethernet/asix/ax88796c_main.h  |  568 ++++++++++
 drivers/net/ethernet/asix/ax88796c_spi.c   |  115 ++
 drivers/net/ethernet/asix/ax88796c_spi.h   |   69 ++
 11 files changed, 2229 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
MAINTAINERS +6 -0
index 7f4615336fa5..bd6d4fc09f68 100644
@@ -2893,6 +2893,12 @@ S:	Maintained
 F:	Documentation/hwmon/asc7621.rst
 F:	drivers/hwmon/asc7621.c
 
+ASIX AX88796C SPI ETHERNET ADAPTER
+M:	Łukasz Stelmach <[email protected]>
+S:	Maintained
+F:	Documentation/devicetree/bindings/net/asix,ax88796c.yaml
+F:	drivers/net/ethernet/asix/ax88796c_*
+
 ASPEED PINCTRL DRIVERS
 M:	Andrew Jeffery <[email protected]>
 L:	[email protected] (moderated for non-subscribers)
drivers/net/ethernet/Kconfig +1 -0
index d796684ec9ca..41e8092a387b 100644
@@ -33,6 +33,7 @@ source "drivers/net/ethernet/apm/Kconfig"
 source "drivers/net/ethernet/apple/Kconfig"
 source "drivers/net/ethernet/aquantia/Kconfig"
 source "drivers/net/ethernet/arc/Kconfig"
+source "drivers/net/ethernet/asix/Kconfig"
 source "drivers/net/ethernet/atheros/Kconfig"
 source "drivers/net/ethernet/broadcom/Kconfig"
 source "drivers/net/ethernet/brocade/Kconfig"
drivers/net/ethernet/Makefile +1 -0
index aaa5078cd7d1..fdd8c6c17451 100644
@@ -19,6 +19,7 @@ obj-$(CONFIG_NET_XGENE) += apm/
 obj-$(CONFIG_NET_VENDOR_APPLE) += apple/
 obj-$(CONFIG_NET_VENDOR_AQUANTIA) += aquantia/
 obj-$(CONFIG_NET_VENDOR_ARC) += arc/
+obj-$(CONFIG_NET_VENDOR_ASIX) += asix/
 obj-$(CONFIG_NET_VENDOR_ATHEROS) += atheros/
 obj-$(CONFIG_NET_VENDOR_CADENCE) += cadence/
 obj-$(CONFIG_NET_VENDOR_BROADCOM) += broadcom/
drivers/net/ethernet/asix/Kconfig new file +35 -0
new file mode 100644
index 000000000000..eed02453314c
@@ -0,0 +1,35 @@
+#
+# Asix network device configuration
+#
+
+config NET_VENDOR_ASIX
+	bool "Asix devices"
+	default y
+	help
+	  If you have a network (Ethernet, non-USB, not NE2000 compatible)
+	  interface based on a chip from ASIX, say Y.
+
+if NET_VENDOR_ASIX
+
+config SPI_AX88796C
+	tristate "Asix AX88796C-SPI support"
+	select PHYLIB
+	depends on SPI
+	depends on GPIOLIB
+	help
+	  Say Y here if you intend to use ASIX AX88796C attached in SPI mode.
+
+config SPI_AX88796C_COMPRESSION
+	bool "SPI transfer compression"
+	default n
+	depends on SPI_AX88796C
+	help
+	  Say Y here to enable SPI transfer compression. It saves up
+	  to 24 dummy cycles during each transfer which may noticeably
+	  speed up short transfers. This sets the default value that is
+	  inherited by network interfaces during probe. It can be
+	  changed at run time via spi-compression ethtool tunable.
+
+	  If unsure say N.
+
+endif # NET_VENDOR_ASIX
drivers/net/ethernet/asix/Makefile new file +6 -0
new file mode 100644
index 000000000000..0bfbbb042634
@@ -0,0 +1,6 @@
+#
+# Makefile for the Asix network device drivers.
+#
+
+obj-$(CONFIG_SPI_AX88796C) += ax88796c.o
+ax88796c-y := ax88796c_main.o ax88796c_ioctl.o ax88796c_spi.o
drivers/net/ethernet/asix/ax88796c_ioctl.c new file +239 -0

239 lines not on this page · raw message

drivers/net/ethernet/asix/ax88796c_ioctl.h new file +26 -0
new file mode 100644
index 000000000000..34d2a7dcc5ef
@@ -0,0 +1,26 @@
+/* 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_IOCTL_H
+#define _AX88796C_IOCTL_H
+
+#include <linux/ethtool.h>
+#include <linux/netdevice.h>
+
+#include "ax88796c_main.h"
+
+extern const struct ethtool_ops ax88796c_ethtool_ops;
+
+bool ax88796c_check_power(const struct ax88796c_device *ax_local);
+bool ax88796c_check_power_and_wake(struct ax88796c_device *ax_local);
+void ax88796c_set_power_saving(struct ax88796c_device *ax_local, u8 ps_level);
+int ax88796c_mdio_read(struct mii_bus *mdiobus, int phy_id, int loc);
+int ax88796c_mdio_write(struct mii_bus *mdiobus, int phy_id, int loc, u16 val);
+int ax88796c_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
+
+#endif
drivers/net/ethernet/asix/ax88796c_main.c new file +1163 -0

1,163 lines not on this page · raw message

drivers/net/ethernet/asix/ax88796c_main.h new file +568 -0

568 lines not on this page · raw message

drivers/net/ethernet/asix/ax88796c_spi.c new file +115 -0

115 lines not on this page · raw message

drivers/net/ethernet/asix/ax88796c_spi.h new file +69 -0

69 lines not on this page · raw message

Signature · 1 line
2.30.2
#5 lore raw

Re: [PATCH net-next v17 0/3] AX88796C SPI Ethernet Adapter

In reply to Łukasz Stelmach
This series was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Quoted 11 lines · On Wed, 20 Oct 2021 20:24:19 +0200 you wrote:

This is a driver for AX88796C Ethernet Adapter connected in SPI mode as found on ARTIK5 evaluation board. The driver has been ported from a v3.10.9 vendor kernel for ARTIK5 board.

Changes in v17:
- marked no_regs_list as const
- added myself as MODULE_AUTHOR()
- rearranged locking in ax88796c_close() to prevent race condition in case ax88796c_work() wakes the queue after trasmission.

[...]

Here is the summary with links:
- [net-next,v17,1/3] dt-bindings: vendor-prefixes: Add asix prefix

    https://git.kernel.org/netdev/net-next/c/4def0acb63ce
  - [net-next,v17,2/3] dt-bindings: net: Add bindings for AX88796C SPI Ethernet Adapter
    https://git.kernel.org/netdev/net-next/c/b13c7a88a7b6
  - [net-next,v17,3/3] net: ax88796c: ASIX AX88796C SPI Ethernet Adapter Driver
    https://git.kernel.org/netdev/net-next/c/a97c69ba4f30

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html