ADD DM9051 ETHERNET DRIVER
Subsystems (3)
v2 cover ADD DM9051 ETHERNET DRIVER
DM9051 is a spi interface ethernet controller chip Fewer connect pins to CPU compare to DM9000.
It need only cs/mosi/miso/clock and an interrupt gpio pin
JosephCHANG (2):
yaml: Add dm9051 SPI network yaml file
net: Add DM9051 driver
.../bindings/net/davicom,dm9051.yaml | 62 ++ drivers/net/ethernet/davicom/Kconfig | 30 + drivers/net/ethernet/davicom/Makefile | 1 + drivers/net/ethernet/davicom/dm9051.c | 967 ++++++++++++++++++ drivers/net/ethernet/davicom/dm9051.h | 248 +++++ 5 files changed, 1308 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 v2 1/2 yaml: Add dm9051 SPI network yaml file
For support davicom dm9051 device tree config
--- .../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 + +required: + - compatible + - reg + - spi-max-frequency + - interrupts + +additionalProperties: false + +examples: + - | + /* for Raspberry Pi with pin control stuff for GPIO irq */ + spi { + #address-cells = <1>; + #size-cells = <0>; + dm9051@0 { + compatible = "davicom,dm9051"; + reg = <0>; /* spi chip select */ + pinctrl-names = "default"; + pinctrl-0 = <ð_int_pins>; + interrupt-parent = <&gpio>; + interrupts = <26 IRQ_TYPE_LEVEL_LOW>; + spi-max-frequency = <31200000>; + }; + }; + gpio { + eth_int_pins { + brcm,pins = <26>; + brcm,function = <0>; /* in */ + brcm,pull = <0>; /* none */ + }; + };
Signature · 1 line
2.20.1
PATCH v2 2/2 net: Add DM9051 driver
In reply to JosephCHANGAdd davicom dm9051 SPI ethernet driver. The driver work with dts for:
- spi bus number
- spi chip select
- spi clock frequency
- interrupt gpio pin
- interrupt polarity fixed as low
Test OK with Rpi 2 and Rpi 4. Max spi speed is 31200000.
--- drivers/net/ethernet/davicom/Kconfig | 30 + drivers/net/ethernet/davicom/Makefile | 1 + drivers/net/ethernet/davicom/dm9051.c | 967 ++++++++++++++++++++++++++ drivers/net/ethernet/davicom/dm9051.h | 248 +++++++ 4 files changed, 1246 insertions(+) create mode 100644 drivers/net/ethernet/davicom/dm9051.c create mode 100644 drivers/net/ethernet/davicom/dm9051.h
drivers/net/ethernet/davicom/Kconfig +30 -0
@@ -3,6 +3,20 @@ # Davicom device configuration # +config NET_VENDOR_DAVICOM + bool "Davicom devices" + depends on ARM || MIPS || COLDFIRE || NIOS2 || COMPILE_TEST || SPI + 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 +36,19 @@ 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 MII + 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 +967 -0
967 lines not on this page · raw message
drivers/net/ethernet/davicom/dm9051.h new file +248 -0
248 lines not on this page · raw message
Signature · 1 line
2.20.1
Re: [PATCH v2, 2/2] net: Add DM9051 driver
Quoted 10 lines · JosephCHANG
Add davicom dm9051 SPI ethernet driver. The driver work with dts for:
- spi bus number
- spi chip select
- spi clock frequency
- interrupt gpio pin
- interrupt polarity fixed as lowTest OK with Rpi 2 and Rpi 4. Max spi speed is 31200000.
Please don't do this type of formatting, where you added extra indentations without reason.
Quoted 75 lines
Signed-off-by JosephCHANG <[email protected]>[Submit v1 has Reported-by: kernel test robot <[email protected]>]--- drivers/net/ethernet/davicom/Kconfig | 30 + drivers/net/ethernet/davicom/Makefile | 1 + drivers/net/ethernet/davicom/dm9051.c | 967 ++++++++++++++++++++++++++ drivers/net/ethernet/davicom/dm9051.h | 248 +++++++ 4 files changed, 1246 insertions(+) create mode 100644 drivers/net/ethernet/davicom/dm9051.c create mode 100644 drivers/net/ethernet/davicom/dm9051.hdrivers/net/ethernet/davicom/Kconfig +30
-0@@ -3,6 +3,20 @@ # Davicom device configuration # +config NET_VENDOR_DAVICOM + bool "Davicom devices" + depends on ARM || MIPS || COLDFIRE || NIOS2 || COMPILE_TEST || SPI + 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 +36,19 @@ 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 MII + 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_DAVICOMdrivers/net/ethernet/davicom/Makefile +1
-0@@ -4,3 +4,4 @@ # obj-$(CONFIG_DM9000) += dm9000.o +obj-$(CONFIG_DM9051) += dm9051.odrivers/net/ethernet/davicom/dm9051.c new file +3
-0@@ -0,0 +1,967 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* +* Ethernet driver for the Davicom DM9051 chip.
drivers/net/ethernet/davicom/dm9051.c line 13
Quoted 10 lines
drivers/net/ethernet/davicom/dm9051.c new file +10
-0+* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details.
Please don't add license text. The SPDX line is more than enough.
Quoted 21 lines
drivers/net/ethernet/davicom/dm9051.c new file +21
-0+* +* Copyright 2021 Davicom Semiconductor,Inc. +* http://www.davicom.com.tw/ +* Joseph CHANG <[email protected]> +* 20211110b, Total 933 lines +*/ + +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/netdevice.h> +#include <linux/etherdevice.h> +#include <linux/interrupt.h> +#include <linux/skbuff.h> +#include <linux/spinlock.h> +#include <linux/cache.h> +#include <linux/crc32.h> +#include <linux/mii.h> +#include <linux/ethtool.h> +#include <linux/delay.h> +#include <linux/irq.h> +#include <linux/slab.h>
drivers/net/ethernet/davicom/dm9051.c line 44
Quoted 10 lines
drivers/net/ethernet/davicom/dm9051.c new file +10
-0+#include <linux/gpio.h> +#include <linux/iopoll.h> +#include <linux/of_gpio.h> +#include <linux/spi/spi.h> + +#include "dm9051.h" + +#define DRV_PRODUCT_NAME "dm9051" +#define DRV_VERSION_CODE DM_VERSION(5, 0, 5) //(VER5.0.0= 0x050000) +#define DRV_VERSION_DATE "20211209" //(update)"
Two points.
1. Try to avoid vertical alignment. It adds churn when backporting.
2. Don't add DRV_VERSION_CODE and DRV_VERSION_DATE. It is useless in upstream kernel.
drivers/net/ethernet/davicom/dm9051.c line 56
Quoted 12 lines
drivers/net/ethernet/davicom/dm9051.c new file +12
-0+ +/* spi-spi_sync, low level code */ +static int burst_xfer (struct board_info *db,u8 cmdphase,u8 *txb,u8 *rxb,unsigned int len) +{ +struct device *dev = &db->spidev->dev; +int ret =0 ; + + db->cmd[0 ] = cmdphase; + db->spi_xfer2[0 ].tx_buf = &db->cmd[0 ]; + db->spi_xfer2[0 ].rx_buf =NULL ; + db->spi_xfer2[0 ].len =1 ; +if (!rxb) {//write
"//"is C++ coding style, which is also in C99 standard. Is it ok to use such comment style in netdev?
<...>
drivers/net/ethernet/davicom/dm9051.c line 244
Quoted 1 line
drivers/net/ethernet/davicom/dm9051.c new file +1
-0+//rcr_reg_start(db, db->rcr_all); //rx enable later
I spotted many commented functions. They shouldn't be part of submission.
<...>
drivers/net/ethernet/davicom/dm9051.c line 617
Quoted 12 lines
drivers/net/ethernet/davicom/dm9051.c new file +12
-0+static void dm_msg_open (struct net_device *ndev) +{ +struct board_info *db =netdev_priv (ndev); +struct device *dev = &db->spidev->dev; + +snprintf (db->DRV_VERSION,sizeof (db->DRV_VERSION),"%s_V%d.%d.%d_date_%s" , +DRV_PRODUCT_NAME , (DRV_VERSION_CODE >>16 &0xff ), + (DRV_VERSION_CODE >>8 &0xff ), + (DRV_VERSION_CODE &0xff ), +DRV_VERSION_DATE ); +dev_info (dev,"version: %s\n" , db->DRV_VERSION); +}
This should go.
<...>
drivers/net/ethernet/davicom/dm9051.c line 7
Quoted 9 lines
drivers/net/ethernet/davicom/dm9051.c new file +8
-0+++ b/drivers/net/ethernet/davicom/dm9051.h@@ -0,0 +1,248 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* +* Copyright 2021 Davicom Semiconductor,Inc. +* http://www.davicom.com.tw +* 2014/03/11 Joseph CHANG v1.0 Create +* 2021/10/26 Joseph CHANG v5.0.1 Update +* 2021/12/09 Joseph CHANG v5.0.5 Update
It is new file, there is no value in off-tree history.
drivers/net/ethernet/davicom/dm9051.c line 13
Quoted 6 lines
drivers/net/ethernet/davicom/dm9051.c new file +6
-0+* +* DM9051 register definitions +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 as +* published by the Free Software Foundation.
No need.
<...>
drivers/net/ethernet/davicom/dm9051.c line 18
Quoted 5 lines
drivers/net/ethernet/davicom/dm9051.c new file +5
-0+#define DM9051_PIDL 0x2A +#define DM9051_PIDH 0x2B +#define DM9051_SMCR 0x2F +#define DM9051_ATCR 0x30 +#define DM9051_SPIBCR 0x38
Please be consistent.
Thanks
Rob Herring
maintainerRe: [PATCH v2, 1/2] yaml: Add dm9051 SPI network yaml file
In reply to JosephCHANGQuoted 8 lines · JosephCHANG
For support davicom dm9051 device tree config
Signed-off-by JosephCHANG <[email protected]>--- .../bindings/net/davicom,dm9051.yaml | 62 +++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/davicom,dm9051.yaml
My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):
yamllint warnings/errors:
dtschema/dtc warnings/errors:
Error: Documentation/devicetree/bindings/net/davicom,dm9051.example.dts:29.34-35 syntax error FATAL ERROR: Unable to parse input tree
make[1]: *** [scripts/Makefile.lib:373: Documentation/devicetree/bindings/net/davicom,dm9051.example.dt.yaml] Error 1 make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1413: dt_binding_check] Error 2
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/patch/1565710
This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.
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.