ADD DM9051 ETHERNET DRIVER
Subsystems (3)
v18 cover ADD DM9051 ETHERNET DRIVER
DM9051 is a spi interface chip,
need cs/mosi/miso/clock with an interrupt gpio pin
Joseph CHAMG (2):
dt-bindings: net: Add Davicom dm9051 SPI ethernet controller
net: Add dm9051 driver
.../bindings/net/davicom,dm9051.yaml | 62 + drivers/net/ethernet/davicom/Kconfig | 31 + drivers/net/ethernet/davicom/Makefile | 1 + drivers/net/ethernet/davicom/dm9051.c | 1256 +++++++++++++++++ drivers/net/ethernet/davicom/dm9051.h | 162 +++ 5 files changed, 1512 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/davicom,dm9051.yaml create mode 100644 drivers/net/ethernet/davicom/dm9051.c create mode 100644 drivers/net/ethernet/davicom/dm9051.h
base-commit: 9d922f5df53844228b9f7c62f2593f4f06c0b69b
Signature · 1 line
2.20.1
PATCH v18 1/2 dt-bindings: net: Add Davicom dm9051 SPI ethernet controller
This is a new yaml base data file for configure davicom dm9051 with device tree
--- .../bindings/net/davicom,dm9051.yaml | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/davicom,dm9051.yaml
Documentation/devicetree/bindings/net/davicom,dm9051.yaml new file +62 -0
@@ -0,0 +1,62 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/net/davicom,dm9051.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Davicom DM9051 SPI Ethernet Controller + +maintainers: + - Joseph CHANG <[email protected]> + +description: | + The DM9051 is a fully integrated and cost-effective low pin count single + chip Fast Ethernet controller with a Serial Peripheral Interface (SPI). + +allOf: + - $ref: ethernet-controller.yaml# + +properties: + compatible: + const: davicom,dm9051 + + reg: + maxItems: 1 + + spi-max-frequency: + maximum: 45000000 + + interrupts: + maxItems: 1 + + local-mac-address: true + + mac-address: true + +required: + - compatible + - reg + - spi-max-frequency + - interrupts + +additionalProperties: false + +examples: + # Raspberry Pi platform + - | + /* for Raspberry Pi with pin control stuff for GPIO irq */ + #include <dt-bindings/interrupt-controller/irq.h> + #include <dt-bindings/gpio/gpio.h> + spi { + #address-cells = <1>; + #size-cells = <0>; + + ethernet@0 { + compatible = "davicom,dm9051"; + reg = <0>; /* spi chip select */ + local-mac-address = [00 00 00 00 00 00]; + interrupt-parent = <&gpio>; + interrupts = <26 IRQ_TYPE_LEVEL_LOW>; + spi-max-frequency = <31200000>; + }; + };
Signature · 1 line
2.20.1
PATCH v18 2/2 net: Add dm9051 driver
In reply to Joseph CHAMGAdd davicom dm9051 spi ethernet driver, The driver work for the device platform which has the spi master
---
Cc: Jakub Kicinski <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: Leon Romanovsky <[email protected]>
Cc: andy Shevchenko <[email protected]>
v1-v4
Test ok with raspberry pi 2 and pi 4
v5
swapped to phylib for phy connection tasks
v6
remove the redundant code that phylib has support
v7
read/write registers must return error code to the caller
v8
not parmanently set MAC by .ndo_set_mac_address
v9
improve the registers read/write so that error code return as far as possible up the call stack.
v10
use regmap APIs for SPI and MDIO
v11
use regmap_read_poll_timeout
use corresponding regmap APIs, i.e. SPI, MDIO
v12
use mdiobus API instead of regmap MDIO APIs
v13
Simply all regmap APIs return value checked
Clear the fifo reset report
Eliminate redundant comments
Comment that DM9051_GPR register bit 0 function for power-up the internal phy, if this bit is updated from 1 to 0, then the whole dm9051 chip registers could not be accessed within 1 ms, so that has mdelay(1) to wait 1 ms
v14
To eliminate touching PHY registers, instead take advantage of phy_start to have it
Make neat to be readable exactly
v15
Process the mac address function to be exactly right Re-arrange functions for better style
Handle to auto negotiation to be right procedure
v16
Let netif_wake_queue at the bottom of dm9051_open
Add draining tx queue in dm9051_stop
v17
Chnage from kthread_work to work_struct
v18
Clean the code with suitable macro, correctly using phy_device and to be a reasonable interrupt service routine
drivers/net/ethernet/davicom/Kconfig | 31 + drivers/net/ethernet/davicom/Makefile | 1 + drivers/net/ethernet/davicom/dm9051.c | 1256 +++++++++++++++++++++++++ drivers/net/ethernet/davicom/dm9051.h | 162 ++++ 4 files changed, 1450 insertions(+) create mode 100644 drivers/net/ethernet/davicom/dm9051.c create mode 100644 drivers/net/ethernet/davicom/dm9051.h
drivers/net/ethernet/davicom/Kconfig +31 -0
@@ -3,6 +3,19 @@ # Davicom device configuration # +config NET_VENDOR_DAVICOM + bool "Davicom devices" + default y + help + If you have a network (Ethernet) card belonging to this class, say Y. + + Note that the answer to this question doesn't directly affect the + kernel: saying N will just cause the configurator to skip all + the questions about Davicom devices. If you say Y, you will be asked + for your specific card in the following selections. + +if NET_VENDOR_DAVICOM + config DM9000 tristate "DM9000 support" depends on ARM || MIPS || COLDFIRE || NIOS2 || COMPILE_TEST
@@ -22,3 +35,21 @@ config DM9000_FORCE_SIMPLE_PHY_POLL bit to determine if the link is up or down instead of the more costly MII PHY reads. Note, this will not work if the chip is operating with an external PHY. + +config DM9051 + tristate "DM9051 SPI support" + depends on SPI + select CRC32 + select MDIO + select PHYLIB + select REGMAP_SPI + help + Support for DM9051 SPI chipset. + + To compile this driver as a module, choose M here. The module + will be called dm9051. + + The SPI mode for the host's SPI master to access DM9051 is mode + 0 on the SPI bus. + +endif # NET_VENDOR_DAVICOM
drivers/net/ethernet/davicom/Makefile +1 -0
@@ -4,3 +4,4 @@ # obj-$(CONFIG_DM9000) += dm9000.o +obj-$(CONFIG_DM9051) += dm9051.o
drivers/net/ethernet/davicom/dm9051.c new file +1256 -0
1,256 lines not on this page · raw message
drivers/net/ethernet/davicom/dm9051.h new file +162 -0
162 lines not on this page · raw message
Signature · 1 line
2.20.1
kernel test robot
build botRe: [PATCH v18, 2/2] net: Add dm9051 driver
Thank you for the patch! Perhaps something to improve:
Hi Joseph,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on 9d922f5df53844228b9f7c62f2593f4f06c0b69b]
url: https://github.com/0day-ci/linux/commits/Joseph-CHAMG/ADD-DM9051-ETHERNET-DRIVER/20220207-171932 base: 9d922f5df53844228b9f7c62f2593f4f06c0b69b config: h8300-allyesconfig (https://download.01.org/0day-ci/archive/20220207/202202071930.jk46Rzon-lkp(a)intel.com/config) compiler: h8300-linux-gcc (GCC) 11.2.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/95377dabb7803b784249b3b649966e0567e380de
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Joseph-CHAMG/ADD-DM9051-ETHERNET-DRIVER/20220207-171932
git checkout 95377dabb7803b784249b3b649966e0567e380de
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=h8300 SHELL=/bin/bash drivers/net/ethernet/davicom/
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
In file included from include/linux/kernel.h:11,
from include/linux/skbuff.h:13,
from include/linux/if_ether.h:19,
from include/linux/etherdevice.h:20,
from drivers/net/ethernet/davicom/dm9051.c:7:
include/linux/scatterlist.h: In function 'sg_set_buf':
include/asm-generic/page.h:89:51: warning: ordered comparison of pointer with null pointer [-Wextra]
89 | #define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
| ^~
include/linux/compiler.h:78:45: note: in definition of macro 'unlikely'
78 | # define unlikely(x) __builtin_expect(!!(x), 0)
| ^
include/linux/scatterlist.h:143:9: note: in expansion of macro 'BUG_ON'
143 | BUG_ON(!virt_addr_valid(buf));
| ^~~~~~
include/linux/scatterlist.h:143:17: note: in expansion of macro 'virt_addr_valid'
143 | BUG_ON(!virt_addr_valid(buf));
| ^~~~~~~~~~~~~~~
In file included from include/linux/etherdevice.h:21,
from drivers/net/ethernet/davicom/dm9051.c:7:
drivers/net/ethernet/davicom/dm9051.c: In function 'dm9051_rxctl_delay':
>> drivers/net/ethernet/davicom/dm9051.c:930:42: warning: format '%d' expects argument of type 'int', but argument 6 has type 'long unsigned int' [-Wformat=]
930 | netif_err(db, drv, ndev, "%s: error %d bulk writing reg %02x, len %d\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
931 | __func__, result, DM9051_PAR, sizeof(ndev->dev_addr));
| ~~~~~~~~~~~~~~~~~~~~~~
| |
| long unsigned int
include/linux/netdevice.h:5079:37: note: in definition of macro 'netif_level'
5079 | netdev_##level(dev, fmt, ##args); \
| ^~~
drivers/net/ethernet/davicom/dm9051.c:930:17: note: in expansion of macro 'netif_err'
930 | netif_err(db, drv, ndev, "%s: error %d bulk writing reg %02x, len %d\n",
| ^~~~~~~~~
drivers/net/ethernet/davicom/dm9051.c:930:84: note: format string is defined here
930 | netif_err(db, drv, ndev, "%s: error %d bulk writing reg %02x, len %d\n",
| ~^
| |
| int
| %ldvim +930 drivers/net/ethernet/davicom/dm9051.c
918
919 static void dm9051_rxctl_delay(struct work_struct *work)
920 {
921 struct board_info *db = container_of(work, struct board_info, rxctrl_work);
922 struct net_device *ndev = db->ndev;
923 int result;
924
925 mutex_lock(&db->spi_lockm);
926
927 result = regmap_bulk_write(db->regmap_dmbulk, DM9051_PAR, ndev->dev_addr,
928 sizeof(ndev->dev_addr));
929 if (result < 0) {
> 930 netif_err(db, drv, ndev, "%s: error %d bulk writing reg %02x, len %d\n",
931 __func__, result, DM9051_PAR, sizeof(ndev->dev_addr));
932 goto out_unlock;
933 }
934
935 dm9051_set_recv(db);
936
937 /* To has mutex unlock and return from this function if regmap function fail
938 */
939 out_unlock:
940 mutex_unlock(&db->spi_lockm);
941 }
942
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Jakub Kicinski
maintainerRe: [PATCH v18, 2/2] net: Add dm9051 driver
In reply to Joseph CHAMGQuoted 4 lines · On Mon, 7 Feb 2022 17:09:06 +0800 Joseph CHAMG wrote:
Add davicom dm9051 spi ethernet driver, The driver work for the device platform which has the spi master
Signed-off-by Joseph CHAMG <[email protected]>
In file included from include/linux/etherdevice.h:21,
from drivers/net/ethernet/davicom/dm9051.c:7:
drivers/net/ethernet/davicom/dm9051.c: In function ‘dm9051_rxctl_delay’:
drivers/net/ethernet/davicom/dm9051.c:930:42: warning: format ‘%d’ expects argument of type ‘int’, but argument 6 has type ‘long unsigned int’ [-Wformat=]
930 | netif_err(db, drv, ndev, "%s: error %d bulk writing reg %02x, len %d\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
931 | __func__, result, DM9051_PAR, sizeof(ndev->dev_addr));
| ~~~~~~~~~~~~~~~~~~~~~~
| |
| long unsigned intinclude/linux/netdevice.h:5107:37: note: in definition of macro ‘netif_level’
5107 | netdev_##level(dev, fmt, ##args); \
| ^~~drivers/net/ethernet/davicom/dm9051.c:930:17: note: in expansion of macro ‘netif_err’
930 | netif_err(db, drv, ndev, "%s: error %d bulk writing reg %02x, len %d\n",
| ^~~~~~~~~
drivers/net/ethernet/davicom/dm9051.c:930:84: note: format string is defined here
930 | netif_err(db, drv, ndev, "%s: error %d bulk writing reg %02x, len %d\n",
| ~^
| |
| int
| %ldRe: [PATCH v18, 1/2] dt-bindings: net: Add Davicom dm9051 SPI ethernet controller
In reply to Joseph CHAMGQuoted 10 lines · Joseph CHAMG
This is a new yaml base data file for configure davicom dm9051 with device tree
Cc Rob Herring <[email protected]>Signed-off-by Joseph CHAMG <[email protected]>--- .../bindings/net/davicom,dm9051.yaml | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/davicom,dm9051.yaml