Skip to contentSkip to conversation

dt-bindings: vendor-prefixes: Add asix prefix

PATCH Superseded Łukasz Stelmach 5 participants 15 messages Oct 21, 2020 – Oct 26, 2020 1 message not in the archive

Subsystems (6)

v3 of 17 Superseded Latest is v17 →

lore
Share & tools
lore

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

Łukasz Stelmach

author maintainer
#1 lore raw

v3 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 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           |   69 +
 .../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             |   22 +
 drivers/net/ethernet/asix/Makefile            |    6 +
 drivers/net/ethernet/asix/ax88796c_ioctl.c    |  197 +++
 drivers/net/ethernet/asix/ax88796c_ioctl.h    |   27 +
 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 +
 16 files changed, 2266 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.26.2
author maintainer
#2 lore raw

PATCH v3 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
#5 lore raw

PATCH v3 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           | 69 +++++++++++++++++++
 1 file changed, 69 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/asix,ax88796c.yaml
Documentation/devicetree/bindings/net/asix,ax88796c.yaml new file +69 -0
new file mode 100644
index 000000000000..6c4c49fcad66
@@ -0,0 +1,69 @@
+# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/net/asix,ax88796c-spi.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
+  - interrupt-parrent
+  - reset-gpios
+
+additionalProperties: false
+
+examples:
+  # Artik5 eval board
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/interrupt-controller/gpio.h>
+    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 v3 2/5
#6 lore raw

Re: [PATCH v3 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           | 69 +++++++++++++++++++
 1 file changed, 69 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/asix,ax88796c.yaml

Best regards,
Krzysztof

maintainer
#7 lore raw

Re: [PATCH v3 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           | 69 +++++++++++++++++++
 1 file changed, 69 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/asix,ax88796c.yaml

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
./Documentation/devicetree/bindings/net/asix,ax88796c.yaml: $id: relative path/filename doesn't match actual path or filename

	expected: http://devicetree.org/schemas/net/asix,ax88796c.yaml#
Documentation/devicetree/bindings/net/asix,ax88796c.example.dts:20:18: fatal error: dt-bindings/interrupt-controller/gpio.h: No such file or directory
   20 |         #include <dt-bindings/interrupt-controller/gpio.h>
      |                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

compilation terminated.
make[1]: *** [scripts/Makefile.lib:342: Documentation/devicetree/bindings/net/asix,ax88796c.example.dt.yaml] Error 1 make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1366: dt_binding_check] Error 2

See https://patchwork.ozlabs.org/patch/1385812

The base for the patch is generally the last rc1. Any dependencies should be noted.

If you already ran 'make dt_binding_check' and didn't see the above error(s), then make sure 'yamllint' is installed and dt-schema is up to date:

pip3 install dtschema --upgrade

Please check and re-submit.

#8 lore raw

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

Quoted 12 lines · Rob Herring
Quoted 8 lines · Łukasz Stelmach

Add bindings for AX88796C SPI Ethernet Adapter.

---
 .../bindings/net/asix,ax88796c.yaml           | 69 +++++++++++++++++++
 1 file changed, 69 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/asix,ax88796c.yaml
Quoted 8 lines

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

dtschema/dtc warnings/errors:
./Documentation/devicetree/bindings/net/asix,ax88796c.yaml: $id: relative path/filename doesn't match actual path or filename

        expected: http://devicetree.org/schemas/net/asix,ax88796c.yaml#

Documentation/devicetree/bindings/net/asix,ax88796c.example.dts:20:18: fatal error: dt-bindings/interrupt-controller/gpio.h: No such file or directory

Łukasz,

So you really did not compile/test these patches... It's the second build failure in the patchset. All sent patches should at least be compiled on the latest kernel, if you cannot test them. However this patchset should be testable - Artik5 should boot on mainline kernel

Best regards,
Krzysztof

author maintainer
#9 lore raw

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

Quoted 17 lines · when Krzysztof Kozlowski
Quoted 16 lines · Rob Herring
Quoted 8 lines · Łukasz Stelmach

Add bindings for AX88796C SPI Ethernet Adapter.

---
 .../bindings/net/asix,ax88796c.yaml           | 69 +++++++++++++++++++
 1 file changed, 69 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/net/asix,ax88796c.yaml

My bot found errors running 'make dt_binding_check' on your patch:

yamllint warnings/errors:

Quoted 8 lines
Quoted 8 lines

dtschema/dtc warnings/errors:
./Documentation/devicetree/bindings/net/asix,ax88796c.yaml: $id:
relative path/filename doesn't match actual path or filename
expected:
https://protect2.fireeye.com/v1/url?k=b676d09f-eb1194b9-b6775bd0-0cc47a31384a-e1cc7da4db18c501&q=1&e=ea7ae062-8c39-4ee3-82fa-37d28062f086&u=http%3A%2F%2Fdevicetree.org%2Fschemas%2Fnet%2Fasix%2Cax88796c.yaml%23
Documentation/devicetree/bindings/net/asix,ax88796c.example.dts:20:18:
fatal error: dt-bindings/interrupt-controller/gpio.h: No such file or directory

Fixed.

Quoted 6 lines

Łukasz,

So you really did not compile/test these patches... It's the second build failure in the patchset. All sent patches should at least be compiled on the latest kernel, if you cannot test them. However this patchset should be testable - Artik5 should boot on mainline kernel

Yes, I messed up a bit. I made moved some code around without changing it just before sending and I didn't run dt_binding_check. My fault, I am sorry.

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

PATCH v3 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.

[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          |   22 +
 drivers/net/ethernet/asix/Makefile         |    6 +
 drivers/net/ethernet/asix/ax88796c_ioctl.c |  197 ++++
 drivers/net/ethernet/asix/ax88796c_ioctl.h |   27 +
 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, 2162 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 +22 -0
new file mode 100644
index 000000000000..bc21c11bd9de
@@ -0,0 +1,22 @@
+#
+# 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.
+
+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 +197 -0

197 lines not on this page · raw message

drivers/net/ethernet/asix/ax88796c_ioctl.h new file +27 -0
new file mode 100644
index 000000000000..d478981bf995
@@ -0,0 +1,27 @@
+/* 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);
+void ax88796c_set_csums(struct ax88796c_device *ax_local);
+int ax88796c_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
+
+#endif
drivers/net/ethernet/asix/ax88796c_main.c new file +1144 -0

1,144 lines not on this page · raw message

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

578 lines not on this page · raw message

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

111 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.26.2
#11 lore raw

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

I love your patch! Perhaps something to improve:

Hi "Łukasz,

I love your patch! Perhaps something to improve:

[auto build test WARNING on robh/for-next]
[also build test WARNING on arm/for-next net-next/master net/master linus/master sparc-next/master v5.9 next-20201021] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/ukasz-Stelmach/AX88796C-SPI-Ethernet-Adapter/20201022-055114
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
config: sparc-allyesconfig (attached as .config)
compiler: sparc64-linux-gcc (GCC) 9.3.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/ad76ebe329affe7e5e8c1438f38ffe3bbf3a7083
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review ukasz-Stelmach/AX88796C-SPI-Ethernet-Adapter/20201022-055114 git checkout ad76ebe329affe7e5e8c1438f38ffe3bbf3a7083
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=sparc

If you fix the issue, kindly add following tag as appropriate

All warnings (new ones prefixed by >>):

drivers/net/ethernet/asix/ax88796c_main.c:758:13: error: static declaration of 'ax88796c_set_csums' follows non-static declaration

     758 | static void ax88796c_set_csums(struct ax88796c_device *ax_local)
         |             ^~~~~~~~~~~~~~~~~~
   In file included from drivers/net/ethernet/asix/ax88796c_main.c:12:
   drivers/net/ethernet/asix/ax88796c_ioctl.h:24:6: note: previous declaration of 'ax88796c_set_csums' was here
      24 | void ax88796c_set_csums(struct ax88796c_device *ax_local);
         |      ^~~~~~~~~~~~~~~~~~
   drivers/net/ethernet/asix/ax88796c_main.c: In function 'ax88796c_probe':
>> drivers/net/ethernet/asix/ax88796c_main.c:978:32: warning: conversion from 'long unsigned int' to 'u32' {aka 'unsigned int'} changes value from '18446744073709486079' to '4294901759' [-Woverflow]
     978 |  ax_local->mdiobus->phy_mask = ~BIT(AX88796C_PHY_ID);
         |                                ^
   In file included from drivers/net/ethernet/asix/ax88796c_main.h:15,
                    from drivers/net/ethernet/asix/ax88796c_main.c:11:
   At top level:
   drivers/net/ethernet/asix/ax88796c_spi.h:24:17: warning: 'rx_cmd_buf' defined but not used [-Wunused-const-variable=]
      24 | static const u8 rx_cmd_buf[5] = {AX_SPICMD_READ_RXQ, 0xFF, 0xFF, 0xFF, 0xFF};
         |                 ^~~~~~~~~~

vim +978 drivers/net/ethernet/asix/ax88796c_main.c

943
944 static int ax88796c_probe(struct spi_device *spi)
945 {
946 struct net_device *ndev;
947 struct ax88796c_device *ax_local;
948 char phy_id[MII_BUS_ID_SIZE + 3];
949 int ret;
950 u16 temp;
951
952 ndev = devm_alloc_etherdev(&spi->dev, sizeof(*ax_local));
953 if (!ndev)
954 return -ENOMEM;
955
956 SET_NETDEV_DEV(ndev, &spi->dev);
957
958 ax_local = to_ax88796c_device(ndev);
959 memset(ax_local, 0, sizeof(*ax_local));
960
961 dev_set_drvdata(&spi->dev, ax_local);
962 ax_local->spi = spi;
963 ax_local->ax_spi.spi = spi;
964
965 ax_local->ndev = ndev;
966 ax_local->capabilities |= comp ? AX_CAP_COMP : 0;
967 ax_local->msg_enable = msg_enable;
968 mutex_init(&ax_local->spi_lock);
969
970 ax_local->mdiobus = devm_mdiobus_alloc(&spi->dev);
971 if (!ax_local->mdiobus)
972 return -ENOMEM;
973
974 ax_local->mdiobus->priv = ax_local;
975 ax_local->mdiobus->read = ax88796c_mdio_read;
976 ax_local->mdiobus->write = ax88796c_mdio_write;
977 ax_local->mdiobus->name = "ax88976c-mdiobus";

 > 978		ax_local->mdiobus->phy_mask = ~BIT(AX88796C_PHY_ID);

979 ax_local->mdiobus->parent = &spi->dev;
980
981 snprintf(ax_local->mdiobus->id, MII_BUS_ID_SIZE,
982 "ax88796c-%s.%u", dev_name(&spi->dev), spi->chip_select);
983
984 ret = devm_mdiobus_register(&spi->dev, ax_local->mdiobus);
985 if (ret < 0) {
986 dev_err(&spi->dev, "Could not register MDIO bus\n");
987 return ret;
988 }
989
990 if (netif_msg_probe(ax_local)) {
991 dev_info(&spi->dev, "AX88796C-SPI Configuration:\n");
992 dev_info(&spi->dev, " Compression : %s\n",
993 ax_local->capabilities & AX_CAP_COMP ? "ON" : "OFF");
994 }
995
996 ndev->irq = spi->irq;
997 ndev->netdev_ops = &ax88796c_netdev_ops;
998 ndev->ethtool_ops = &ax88796c_ethtool_ops;
999 ndev->hw_features |= NETIF_F_HW_CSUM | NETIF_F_RXCSUM;
1000 ndev->features |= NETIF_F_HW_CSUM | NETIF_F_RXCSUM;
1001 ndev->hard_header_len += (TX_OVERHEAD + 4);
1002
1003 mutex_lock(&ax_local->spi_lock);
1004
1005 /* ax88796c gpio reset */
1006 ax88796c_hard_reset(ax_local);
1007
1008 /* Reset AX88796C */
1009 ret = ax88796c_soft_reset(ax_local);
1010 if (ret < 0) {
1011 ret = -ENODEV;
1012 goto err;
1013 }
1014 /* Check board revision */
1015 temp = AX_READ(&ax_local->ax_spi, P2_CRIR);
1016 if ((temp & 0xF) != 0x0) {
1017 dev_err(&spi->dev, "spi read failed: %d\n", temp);
1018 ret = -ENODEV;
1019 goto err;
1020 }
1021
1022 temp = AX_READ(&ax_local->ax_spi, P0_BOR);
1023 if (temp == 0x1234) {
1024 ax_local->plat_endian = PLAT_LITTLE_ENDIAN;
1025 } else {
1026 AX_WRITE(&ax_local->ax_spi, 0xFFFF, P0_BOR);
1027 ax_local->plat_endian = PLAT_BIG_ENDIAN;
1028 }
1029
1030 /*Reload EEPROM*/
1031 ax88796c_reload_eeprom(ax_local);
1032
1033 ax88796c_load_mac_addr(ndev);
1034
1035 if (netif_msg_probe(ax_local))
1036 dev_info(&spi->dev,
1037 "irq %d, MAC addr %02X:%02X:%02X:%02X:%02X:%02X\n",
1038 ndev->irq,
1039 ndev->dev_addr[0], ndev->dev_addr[1],
1040 ndev->dev_addr[2], ndev->dev_addr[3],
1041 ndev->dev_addr[4], ndev->dev_addr[5]);
1042
1043 /* Disable power saving */
1044 AX_WRITE(&ax_local->ax_spi, (AX_READ(&ax_local->ax_spi, P0_PSCR)
1045 & PSCR_PS_MASK) | PSCR_PS_D0, P0_PSCR);
1046
1047 mutex_unlock(&ax_local->spi_lock);
1048
1049 INIT_WORK(&ax_local->ax_work, ax88796c_work);
1050
1051 skb_queue_head_init(&ax_local->tx_wait_q);
1052
1053 snprintf(phy_id, MII_BUS_ID_SIZE + 3, PHY_ID_FMT,
1054 ax_local->mdiobus->id, AX88796C_PHY_ID);
1055 ax_local->phydev = phy_connect(ax_local->ndev, phy_id,
1056 ax88796c_handle_link_change,
1057 PHY_INTERFACE_MODE_MII);
1058 if (IS_ERR(ax_local->phydev)) {
1059 ret = PTR_ERR(ax_local->phydev);
1060 goto err;
1061 }
1062 ax_local->phydev->irq = PHY_POLL;
1063
1064 ret = devm_register_netdev(&spi->dev, ndev);
1065 if (ret) {
1066 dev_err(&spi->dev, "failed to register a network device\n");
1067 goto err_phy_dis;
1068 }
1069
1070 netif_info(ax_local, probe, ndev, "%s %s registered\n",
1071 dev_driver_string(&spi->dev),
1072 dev_name(&spi->dev));
1073 phy_attached_info(ax_local->phydev);
1074
1075 return 0;
1076
1077 err_phy_dis:
1078 phy_disconnect(ax_local->phydev);
1079 err:
1080 return ret;
1081 }
1082

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#12 lore raw

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

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

Quoted 7 lines

[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.

coś zaszalałeś, jak dobry koreański kod - push bez kompilacji ;)

drivers/net/ethernet/asix/ax88796c_main.c:758:13: error: static declaration of ‘ax88796c_set_csums’ follows non-static declaration
 static void ax88796c_set_csums(struct ax88796c_device *ax_local) ^
In file included from drivers/net/ethernet/asix/ax88796c_main.c:12:0:
drivers/net/ethernet/asix/ax88796c_ioctl.h:24:6: note: previous declaration of ‘ax88796c_set_csums’ was here
 void ax88796c_set_csums(struct ax88796c_device *ax_local);
      ^
scripts/Makefile.build:283: recipe for target 'drivers/net/ethernet/asix/ax88796c_main.o' failed
make[4]: *** [drivers/net/ethernet/asix/ax88796c_main.o] Error 1 scripts/Makefile.build:500: recipe for target 'drivers/net/ethernet/asix' failed
make[3]: *** [drivers/net/ethernet/asix] Error 2 scripts/Makefile.build:500: recipe for target 'drivers/net/ethernet' failed make[2]: *** [drivers/net/ethernet] Error 2 scripts/Makefile.build:500: recipe for target 'drivers/net' failed make[1]: *** [drivers/net] Error 2

Quoted 1 line

...

Best regards

Signature · 2 lines
Marek Szyprowski, PhD
Samsung R&D Institute Poland
author maintainer
#13 lore raw

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

Quoted 36 lines · when Marek Szyprowski
Quoted 14 lines · Ł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.

Quoted 7 lines

[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.

coś zaszalałeś, jak dobry koreański kod - push bez kompilacji ;)

drivers/net/ethernet/asix/ax88796c_main.c:758:13: error: static declaration of ‘ax88796c_set_csums’ follows non-static declaration
 static void ax88796c_set_csums(struct ax88796c_device *ax_local) ^
In file included from drivers/net/ethernet/asix/ax88796c_main.c:12:0:
drivers/net/ethernet/asix/ax88796c_ioctl.h:24:6: note: previous declaration of ‘ax88796c_set_csums’ was here
 void ax88796c_set_csums(struct ax88796c_device *ax_local); ^
scripts/Makefile.build:283: recipe for target 'drivers/net/ethernet/asix/ax88796c_main.o' failed

Quoted 8 lines

make[4]: *** [drivers/net/ethernet/asix/ax88796c_main.o] Error 1 scripts/Makefile.build:500: recipe for target 'drivers/net/ethernet/asix' failed
make[3]: *** [drivers/net/ethernet/asix] Error 2 scripts/Makefile.build:500: recipe for target 'drivers/net/ethernet' failed make[2]: *** [drivers/net/ethernet] Error 2 scripts/Makefile.build:500: recipe for target 'drivers/net' failed make[1]: *** [drivers/net] Error 2

Fixed. Thanks.

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

PATCH v3 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
author maintainer
#15 lore raw

PATCH v3 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 · 1 line
2.26.2