Skip to contentSkip to conversation

ARM: defconfig: Enable ax88796c driver

PATCH Applied Łukasz Stelmach 4 participants 13 messages Nov 3, 2020 – Nov 6, 2020 1 message not in the archive

Subsystems (7)

v5 of 17 Applied Latest is v17 →

lore
Share & tools
lore

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

Łukasz Stelmach

author maintainer
#1 lore raw

v5 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 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 controll 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 (5):
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
ARM: dts: exynos: Add Ethernet to Artik 5 board
ARM: defconfig: Enable ax88796c driver

 .../bindings/net/asix,ax88796c.yaml           |   73 ++
 .../devicetree/bindings/vendor-prefixes.yaml  |    2 +
 MAINTAINERS                                   |    6 +
 arch/arm/boot/dts/exynos3250-artik5-eval.dts  |   29 +
 arch/arm/configs/exynos_defconfig             |    2 +
 arch/arm/configs/multi_v7_defconfig           |    2 +
 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    |  235 ++++
 drivers/net/ethernet/asix/ax88796c_ioctl.h    |   26 +
 drivers/net/ethernet/asix/ax88796c_main.c     | 1132 +++++++++++++++++
 drivers/net/ethernet/asix/ax88796c_main.h     |  561 ++++++++
 drivers/net/ethernet/asix/ax88796c_spi.c      |  109 ++
 drivers/net/ethernet/asix/ax88796c_spi.h      |   70 +
 include/uapi/linux/ethtool.h                  |    1 +
 net/ethtool/common.c                          |    1 +
 18 files changed, 2292 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 · 7 lines
2.26.2


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author maintainer
#2 lore raw

PATCH v5 1/5 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 2735be1a8470..ce3b3f6c9728 100644
@@ -117,6 +117,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.26.2
author maintainer
#3 lore raw

PATCH v5 2/5 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.26.2
maintainer Reviewed-by on v5 2/5
#4 lore raw

Re: [PATCH v5 2/5] dt-bindings: net: Add bindings for AX88796C SPI Ethernet Adapter

Quoted 8 lines · Ł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
maintainer Acked-by on v5 2/5
#5 lore raw

Re: [PATCH v5 2/5] dt-bindings: net: Add bindings for AX88796C SPI Ethernet Adapter

In reply to Łukasz Stelmach
Quoted 8 lines · Ł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

I assume bindings will go with the driver to the net. I applied only ARM-specific bits.

Best regards,
Krzysztof

author maintainer
#6 lore raw

PATCH v5 3/5 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 |  235 ++++
 drivers/net/ethernet/asix/ax88796c_ioctl.h |   26 +
 drivers/net/ethernet/asix/ax88796c_main.c  | 1132 ++++++++++++++++++++
 drivers/net/ethernet/asix/ax88796c_main.h  |  561 ++++++++++
 drivers/net/ethernet/asix/ax88796c_spi.c   |  109 ++
 drivers/net/ethernet/asix/ax88796c_spi.h   |   70 ++
 include/uapi/linux/ethtool.h               |    1 +
 net/ethtool/common.c                       |    1 +
 13 files changed, 2184 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 14b8ec0bb58b..930dc859d4f7 100644
@@ -2812,6 +2812,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,ax99706c-spi.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 de50e8b9e656..f3b218e45ea5 100644
@@ -32,6 +32,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/aurora/Kconfig"
 source "drivers/net/ethernet/broadcom/Kconfig"
drivers/net/ethernet/Makefile +1 -0
index f8f38dcb5f8a..9eb368d93607 100644
@@ -18,6 +18,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_AURORA) += aurora/
 obj-$(CONFIG_NET_VENDOR_CADENCE) += cadence/
drivers/net/ethernet/asix/Kconfig new file +35 -0
new file mode 100644
index 000000000000..6211814b0446
@@ -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 noticably
+	  speed up short transfers. This sets the default value that is
+	  inherited by network interfecase during probe. It can be
+	  changed in 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 +235 -0

235 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 +1132 -0

1,132 lines not on this page · raw message

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

561 lines not on this page · raw message

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

109 lines not on this page · raw message

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

70 lines not on this page · raw message

include/uapi/linux/ethtool.h +1 -0
index 9ca87bc73c44..f7621c3a938e 100644
@@ -221,6 +221,7 @@ enum tunable_id {
 	ETHTOOL_RX_COPYBREAK,
 	ETHTOOL_TX_COPYBREAK,
 	ETHTOOL_PFC_PREVENTION_TOUT, /* timeout in msecs */
+	ETHTOOL_SPI_COMPRESSION,     /* SPI transfer compression */
 	/*
 	 * Add your fresh new tunable attribute above and remember to update
 	 * tunable_strings[] in net/core/ethtool.c
net/ethtool/common.c +1 -0
index 24036e3055a1..bd49f83d7daa 100644
@@ -83,6 +83,7 @@ tunable_strings[__ETHTOOL_TUNABLE_COUNT][ETH_GSTRING_LEN] = {
 	[ETHTOOL_RX_COPYBREAK]	= "rx-copybreak",
 	[ETHTOOL_TX_COPYBREAK]	= "tx-copybreak",
 	[ETHTOOL_PFC_PREVENTION_TOUT] = "pfc-prevention-tout",
+	[ETHTOOL_SPI_COMPRESSION] = "spi-compression",
 };
 
 const char
Signature · 1 line
2.26.2
maintainer
#7 lore raw

Re: [PATCH v5 3/5] net: ax88796c: ASIX AX88796C SPI Ethernet Adapter Driver

drivers/net/ethernet/asix/Kconfig line 30

Quoted 9 lines
drivers/net/ethernet/asix/Kconfig new file +9 -0
+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 noticably
+	  speed up short transfers. This sets the default value that is
+	  inherited by network interfecase during probe. It can be

interface

drivers/net/ethernet/asix/Kconfig line 31

Quoted 1 line
drivers/net/ethernet/asix/Kconfig new file +1 -0
+	  changed in run time via spi-compression ethtool tunable.

changed _at_ run time...

drivers/net/ethernet/asix/ax88796c_ioctl.c line 142

Quoted 12 lines
drivers/net/ethernet/asix/ax88796c_ioctl.c new file +12 -0
+static int
+ax88796c_set_tunable(struct net_device *ndev, const struct ethtool_tunable *tuna,
+		     const void *data)
+{
+	struct ax88796c_device *ax_local = to_ax88796c_device(ndev);
+
+	switch (tuna->id) {
+	case ETHTOOL_SPI_COMPRESSION:
+		if (netif_running(ndev))
+			return -EBUSY;
+		ax_local->capabilities &= ~AX_CAP_COMP;
+		ax_local->capabilities |= *(u32 *)data ? AX_CAP_COMP : 0;

You should probably validate here that data is 0 or 1. That is what ax88796c_get_tunable() will return.

It seems like this controls two hardware bits:

SPICR_RCEN | SPICR_QCEN

Maybe at some point it would make sense to allow these bits to be set individually? If you never validate the tunable, you cannot make use of other values to control the bits individually.

Andrew

author maintainer
#8 lore raw

Re: [PATCH v5 3/5] net: ax88796c: ASIX AX88796C SPI Ethernet Adapter Driver

Quoted 12 lines · when Andrew Lunn

drivers/net/ethernet/asix/Kconfig line 30

Quoted 9 lines
drivers/net/ethernet/asix/Kconfig new file +9 -0
+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 noticably
+	  speed up short transfers. This sets the default value that is
+	  inherited by network interfecase during probe. It can be

interface

Done.

Quoted 4 lines

drivers/net/ethernet/asix/Kconfig line 31

Quoted 1 line
drivers/net/ethernet/asix/Kconfig new file +1 -0
+	  changed in run time via spi-compression ethtool tunable.

changed _at_ run time...

Done.

Quoted 16 lines

drivers/net/ethernet/asix/ax88796c_ioctl.c line 142

Quoted 12 lines
drivers/net/ethernet/asix/ax88796c_ioctl.c new file +12 -0
+static int
+ax88796c_set_tunable(struct net_device *ndev, const struct ethtool_tunable *tuna,
+		     const void *data)
+{
+	struct ax88796c_device *ax_local = to_ax88796c_device(ndev);
+
+	switch (tuna->id) {
+	case ETHTOOL_SPI_COMPRESSION:
+		if (netif_running(ndev))
+			return -EBUSY;
+		ax_local->capabilities &= ~AX_CAP_COMP;
+		ax_local->capabilities |= *(u32 *)data ? AX_CAP_COMP : 0;

You should probably validate here that data is 0 or 1. That is what ax88796c_get_tunable() will return.

Quoted 7 lines

It seems like this controls two hardware bits:

SPICR_RCEN | SPICR_QCEN

Maybe at some point it would make sense to allow these bits to be set individually? If you never validate the tunable, you cannot make use of other values to control the bits individually.

Good point. What is your recommendation for the userland facing interface, so that future changes will be least disruptive?

ax_local->capabilities |= ((*(u32 *)data) & SPICR_RCEN) ? AX_CAP_COMP : 0;

or rather

ax_local->capabilities |= ((*(u32 *)data) & (SPICR_RCEN | SPICR_QCEN)) ? AX_CAP_COMP : 0;

and possibly in the future (or now) split it into

ax_local->capabilities |= ((*(u32 *)data) & SPICR_RCEN) ? AX_CAP_COMP_R : 0; ax_local->capabilities |= ((*(u32 *)data) & SPICR_QCEN) ? AX_CAP_COMP_Q : 0;

(and appropriate masking abve and proper handling in ax88796c_soft_reset()).

Kind regards

Signature · 3 lines
Łukasz Stelmach
Samsung R&D Institute Poland
Samsung Electronics
maintainer
#9 lore raw

Re: [PATCH v5 3/5] net: ax88796c: ASIX AX88796C SPI Ethernet Adapter Driver

Quoted 18 lines
Quoted 18 lines

drivers/net/ethernet/asix/ax88796c_ioctl.c line 142

Quoted 12 lines
drivers/net/ethernet/asix/ax88796c_ioctl.c new file +12 -0
+static int
+ax88796c_set_tunable(struct net_device *ndev, const struct ethtool_tunable *tuna,
+		     const void *data)
+{
+	struct ax88796c_device *ax_local = to_ax88796c_device(ndev);
+
+	switch (tuna->id) {
+	case ETHTOOL_SPI_COMPRESSION:
+		if (netif_running(ndev))
+			return -EBUSY;
+		ax_local->capabilities &= ~AX_CAP_COMP;
+		ax_local->capabilities |= *(u32 *)data ? AX_CAP_COMP : 0;

You should probably validate here that data is 0 or 1. That is what ax88796c_get_tunable() will return.

It seems like this controls two hardware bits:

Quoted 8 lines
Quoted 5 lines

SPICR_RCEN | SPICR_QCEN

Maybe at some point it would make sense to allow these bits to be set individually? If you never validate the tunable, you cannot make use of other values to control the bits individually.

Good point. What is your recommendation for the userland facing interface, so that future changes will be least disruptive?

I would KISS and just validate data is 0 or 1, and leave it at that. That then later gives you the option to have other values, if that is ever interesting.

Andrew

author maintainer
#10 lore raw

PATCH v5 4/5 ARM: dts: exynos: Add Ethernet to Artik 5 board

In reply to Łukasz Stelmach

Add node for ax88796c ethernet chip.

---
 arch/arm/boot/dts/exynos3250-artik5-eval.dts | 29 ++++++++++++++++++++
 1 file changed, 29 insertions(+)
arch/arm/boot/dts/exynos3250-artik5-eval.dts +29 -0
index 20446a846a98..a91e09a7d3fa 100644
@@ -37,3 +37,32 @@ &mshc_2 {
 &serial_2 {
 	status = "okay";
 };
+
+&spi_0 {
+	status = "okay";
+	cs-gpios = <&gpx3 4 GPIO_ACTIVE_LOW>, <0>;
+
+	assigned-clocks = <&cmu CLK_MOUT_MPLL>, <&cmu CLK_DIV_MPLL_PRE>,
+		<&cmu CLK_MOUT_SPI0>, <&cmu CLK_DIV_SPI0>,
+		<&cmu CLK_DIV_SPI0_PRE>, <&cmu CLK_SCLK_SPI0>;
+	assigned-clock-parents =
+		<&cmu CLK_FOUT_MPLL>,    /* for: CLK_MOUT_MPLL */
+		<&cmu CLK_MOUT_MPLL>,	 /* for: CLK_DIV_MPLL_PRE */
+		<&cmu CLK_DIV_MPLL_PRE>, /* for: CLK_MOUT_SPI0 */
+		<&cmu CLK_MOUT_SPI0>,    /* for: CLK_DIV_SPI0 */
+		<&cmu CLK_DIV_SPI0>,     /* for: CLK_DIV_SPI0_PRE */
+		<&cmu CLK_DIV_SPI0_PRE>; /* for: CLK_SCLK_SPI0 */
+
+	ethernet@0 {
+		compatible = "asix,ax88796c";
+		reg = <0x0>;
+		local-mac-address = [00 00 00 00 00 00]; /* Filled in by a boot-loader */
+		interrupt-parent = <&gpx2>;
+		interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
+		spi-max-frequency = <40000000>;
+		reset-gpios = <&gpe0 2 GPIO_ACTIVE_LOW>;
+		controller-data {
+			samsung,spi-feedback-delay = <2>;
+		};
+	};
+};
Signature · 1 line
2.26.2
maintainer Applied
#11 lore raw

Re: [PATCH v5 4/5] ARM: dts: exynos: Add Ethernet to Artik 5 board

Quoted 6 lines · Łukasz Stelmach

Add node for ax88796c ethernet chip.

---
 arch/arm/boot/dts/exynos3250-artik5-eval.dts | 29 ++++++++++++++++++++
 1 file changed, 29 insertions(+)

Thanks, applied.

Best regards,
Krzysztof

author maintainer
#12 lore raw

PATCH v5 5/5 ARM: defconfig: Enable ax88796c driver

In reply to Łukasz Stelmach

Enable ax88796c driver for the ethernet chip on Exynos3250-based ARTIK5 boards.

---
 arch/arm/configs/exynos_defconfig   | 2 ++
 arch/arm/configs/multi_v7_defconfig | 2 ++
 2 files changed, 4 insertions(+)
arch/arm/configs/exynos_defconfig +2 -0
index cf82c9d23a08..1ee902d01eef 100644
@@ -107,6 +107,8 @@ CONFIG_MD=y
 CONFIG_BLK_DEV_DM=y
 CONFIG_DM_CRYPT=m
 CONFIG_NETDEVICES=y
+CONFIG_NET_VENDOR_ASIX=y
+CONFIG_SPI_AX88796C=y
 CONFIG_SMSC911X=y
 CONFIG_USB_RTL8150=m
 CONFIG_USB_RTL8152=y
arch/arm/configs/multi_v7_defconfig +2 -0
index e731cdf7c88c..dad53846f58f 100644
@@ -243,6 +243,8 @@ CONFIG_SATA_HIGHBANK=y
 CONFIG_SATA_MV=y
 CONFIG_SATA_RCAR=y
 CONFIG_NETDEVICES=y
+CONFIG_NET_VENDOR_ASIX=y
+CONFIG_SPI_AX88796C=m
 CONFIG_VIRTIO_NET=y
 CONFIG_B53_SPI_DRIVER=m
 CONFIG_B53_MDIO_DRIVER=m
Signature · 7 lines
2.26.2


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
maintainer Applied
#13 lore raw
Quoted 7 lines · Łukasz Stelmach

Enable ax88796c driver for the ethernet chip on Exynos3250-based ARTIK5 boards.

---
 arch/arm/configs/exynos_defconfig   | 2 ++
 arch/arm/configs/multi_v7_defconfig | 2 ++

Thanks, applied.

Best regards,
Krzysztof