Re: [PATCHv3 2/3] net: socionext: Add Synquacer NetSec driver
> +static int netsec_register_mdio(struct netsec_priv *priv, u32 phy_addr) > +{ > + struct mii_bus *bus; > + int ret; > + > + bus = devm_mdiobus_alloc(priv->dev); > + if (!bus) > + return -ENOMEM; > + > + snprintf(bus->id, MII_BUS_ID_SIZE, "%s", dev_name(priv->dev)); > + bus->priv = priv; > + bus->name = "SNI NETSEC MDIO"; > + bus->read = netsec_phy_read; > + bus->write = netsec_phy_write; > + bus->parent = priv->dev; > + priv->mii_bus = bus; > + > + if (dev_of_node(priv->dev)) { > + struct device_node *parent = dev_of_node(priv->dev); > + struct device_node *child_node, *mdio_node = NULL; > + > + for_each_child_of_node(parent, child_node) { > + if (of_device_is_compatible(child_node, > + "socionext,snq-mdio")) { Just use of_get_child_by_name(parent, "mdio"); Andrew
Re: [PATCHv3 2/3] net: socionext: Add Synquacer NetSec driver
On Thu, Dec 21, 2017 at 12:43:40PM +, Ard Biesheuvel wrote: > Hi Jassi, Hi Ard Please trim emails when you reply. It was not easy to find your comment, i'm assuming there was only one, and that i did not miss others. Andrew
Re: [PATCHv3 2/3] net: socionext: Add Synquacer NetSec driver
Hi Jassi, On 21 December 2017 at 12:11,wrote: > From: Jassi Brar > > This driver adds support for Socionext "netsec" IP Gigabit > Ethernet + PHY IP used in the Synquacer SC2A11 SoC. > > Signed-off-by: Ard Biesheuvel > Signed-off-by: Jassi Brar > --- > drivers/net/ethernet/Kconfig|1 + > drivers/net/ethernet/Makefile |1 + > drivers/net/ethernet/socionext/Kconfig | 29 + > drivers/net/ethernet/socionext/Makefile |1 + > drivers/net/ethernet/socionext/netsec.c | 1849 > +++ > 5 files changed, 1881 insertions(+) > create mode 100644 drivers/net/ethernet/socionext/Kconfig > create mode 100644 drivers/net/ethernet/socionext/Makefile > create mode 100644 drivers/net/ethernet/socionext/netsec.c > > diff --git a/drivers/net/ethernet/Kconfig b/drivers/net/ethernet/Kconfig > index c604213..d50519e 100644 > --- a/drivers/net/ethernet/Kconfig > +++ b/drivers/net/ethernet/Kconfig > @@ -170,6 +170,7 @@ source "drivers/net/ethernet/sis/Kconfig" > source "drivers/net/ethernet/sfc/Kconfig" > source "drivers/net/ethernet/sgi/Kconfig" > source "drivers/net/ethernet/smsc/Kconfig" > +source "drivers/net/ethernet/socionext/Kconfig" > source "drivers/net/ethernet/stmicro/Kconfig" > source "drivers/net/ethernet/sun/Kconfig" > source "drivers/net/ethernet/tehuti/Kconfig" > diff --git a/drivers/net/ethernet/Makefile b/drivers/net/ethernet/Makefile > index 39f62733..6cf5ade 100644 > --- a/drivers/net/ethernet/Makefile > +++ b/drivers/net/ethernet/Makefile > @@ -82,6 +82,7 @@ obj-$(CONFIG_SFC) += sfc/ > obj-$(CONFIG_SFC_FALCON) += sfc/falcon/ > obj-$(CONFIG_NET_VENDOR_SGI) += sgi/ > obj-$(CONFIG_NET_VENDOR_SMSC) += smsc/ > +obj-$(CONFIG_NET_VENDOR_SOCIONEXT) += socionext/ > obj-$(CONFIG_NET_VENDOR_STMICRO) += stmicro/ > obj-$(CONFIG_NET_VENDOR_SUN) += sun/ > obj-$(CONFIG_NET_VENDOR_TEHUTI) += tehuti/ > diff --git a/drivers/net/ethernet/socionext/Kconfig > b/drivers/net/ethernet/socionext/Kconfig > new file mode 100644 > index 000..4601c2f > --- /dev/null > +++ b/drivers/net/ethernet/socionext/Kconfig > @@ -0,0 +1,29 @@ > +# > +# Socionext Network device configuration > +# > + > +config NET_VENDOR_SOCIONEXT > + bool "Socionext 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 > + the questions about Socionext cards. If you say Y, you will be asked > + for your specific card in the following questions. > + > +if NET_VENDOR_SOCIONEXT > + > +config SNI_NETSEC > + tristate "NETSEC Driver Support" > + depends on ARCH_SYNQUACER && OF > + select PHYLIB > + select MII > +help > + Enable to add support for the SocioNext NetSec Gigabit Ethernet > + controller + PHY, as found on the Synquacer SC2A11 SoC > + > + To compile this driver as a module, choose M here: the module will > be > + called netsec. If unsure, say N. > + > +endif # NET_VENDOR_SOCIONEXT > diff --git a/drivers/net/ethernet/socionext/Makefile > b/drivers/net/ethernet/socionext/Makefile > new file mode 100644 > index 000..9505923 > --- /dev/null > +++ b/drivers/net/ethernet/socionext/Makefile > @@ -0,0 +1 @@ > +obj-$(CONFIG_SNI_NETSEC) += netsec.o > diff --git a/drivers/net/ethernet/socionext/netsec.c > b/drivers/net/ethernet/socionext/netsec.c > new file mode 100644 > index 000..9a9b699 > --- /dev/null > +++ b/drivers/net/ethernet/socionext/netsec.c > @@ -0,0 +1,1849 @@ > +// SPDX-License-Identifier: GPL-2.0 > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#include > +#include > + > +#define NETSEC_REG_SOFT_RST0x104 > +#define NETSEC_REG_COM_INIT0x120 > + > +#define NETSEC_REG_TOP_STATUS 0x200 > +#define NETSEC_IRQ_RX BIT(1) > +#define NETSEC_IRQ_TX BIT(0) > + > +#define NETSEC_REG_TOP_INTEN 0x204 > +#define NETSEC_REG_INTEN_SET 0x234 > +#define NETSEC_REG_INTEN_CLR 0x238 > + > +#define NETSEC_REG_NRM_TX_STATUS 0x400 > +#define NETSEC_REG_NRM_TX_INTEN0x404 > +#define NETSEC_REG_NRM_TX_INTEN_SET0x428 > +#define NETSEC_REG_NRM_TX_INTEN_CLR0x42c > +#define NRM_TX_ST_NTOWNR BIT(17) > +#define NRM_TX_ST_TR_ERR BIT(16) > +#define NRM_TX_ST_TXDONE BIT(15) > +#define NRM_TX_ST_TMREXP BIT(14) > + > +#define NETSEC_REG_NRM_RX_STATUS 0x440 > +#define NETSEC_REG_NRM_RX_INTEN0x444 > +#define NETSEC_REG_NRM_RX_INTEN_SET0x468 > +#define NETSEC_REG_NRM_RX_INTEN_CLR0x46c >
[PATCHv3 2/3] net: socionext: Add Synquacer NetSec driver
From: Jassi BrarThis driver adds support for Socionext "netsec" IP Gigabit Ethernet + PHY IP used in the Synquacer SC2A11 SoC. Signed-off-by: Ard Biesheuvel Signed-off-by: Jassi Brar --- drivers/net/ethernet/Kconfig|1 + drivers/net/ethernet/Makefile |1 + drivers/net/ethernet/socionext/Kconfig | 29 + drivers/net/ethernet/socionext/Makefile |1 + drivers/net/ethernet/socionext/netsec.c | 1849 +++ 5 files changed, 1881 insertions(+) create mode 100644 drivers/net/ethernet/socionext/Kconfig create mode 100644 drivers/net/ethernet/socionext/Makefile create mode 100644 drivers/net/ethernet/socionext/netsec.c diff --git a/drivers/net/ethernet/Kconfig b/drivers/net/ethernet/Kconfig index c604213..d50519e 100644 --- a/drivers/net/ethernet/Kconfig +++ b/drivers/net/ethernet/Kconfig @@ -170,6 +170,7 @@ source "drivers/net/ethernet/sis/Kconfig" source "drivers/net/ethernet/sfc/Kconfig" source "drivers/net/ethernet/sgi/Kconfig" source "drivers/net/ethernet/smsc/Kconfig" +source "drivers/net/ethernet/socionext/Kconfig" source "drivers/net/ethernet/stmicro/Kconfig" source "drivers/net/ethernet/sun/Kconfig" source "drivers/net/ethernet/tehuti/Kconfig" diff --git a/drivers/net/ethernet/Makefile b/drivers/net/ethernet/Makefile index 39f62733..6cf5ade 100644 --- a/drivers/net/ethernet/Makefile +++ b/drivers/net/ethernet/Makefile @@ -82,6 +82,7 @@ obj-$(CONFIG_SFC) += sfc/ obj-$(CONFIG_SFC_FALCON) += sfc/falcon/ obj-$(CONFIG_NET_VENDOR_SGI) += sgi/ obj-$(CONFIG_NET_VENDOR_SMSC) += smsc/ +obj-$(CONFIG_NET_VENDOR_SOCIONEXT) += socionext/ obj-$(CONFIG_NET_VENDOR_STMICRO) += stmicro/ obj-$(CONFIG_NET_VENDOR_SUN) += sun/ obj-$(CONFIG_NET_VENDOR_TEHUTI) += tehuti/ diff --git a/drivers/net/ethernet/socionext/Kconfig b/drivers/net/ethernet/socionext/Kconfig new file mode 100644 index 000..4601c2f --- /dev/null +++ b/drivers/net/ethernet/socionext/Kconfig @@ -0,0 +1,29 @@ +# +# Socionext Network device configuration +# + +config NET_VENDOR_SOCIONEXT + bool "Socionext 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 + the questions about Socionext cards. If you say Y, you will be asked + for your specific card in the following questions. + +if NET_VENDOR_SOCIONEXT + +config SNI_NETSEC + tristate "NETSEC Driver Support" + depends on ARCH_SYNQUACER && OF + select PHYLIB + select MII +help + Enable to add support for the SocioNext NetSec Gigabit Ethernet + controller + PHY, as found on the Synquacer SC2A11 SoC + + To compile this driver as a module, choose M here: the module will be + called netsec. If unsure, say N. + +endif # NET_VENDOR_SOCIONEXT diff --git a/drivers/net/ethernet/socionext/Makefile b/drivers/net/ethernet/socionext/Makefile new file mode 100644 index 000..9505923 --- /dev/null +++ b/drivers/net/ethernet/socionext/Makefile @@ -0,0 +1 @@ +obj-$(CONFIG_SNI_NETSEC) += netsec.o diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c new file mode 100644 index 000..9a9b699 --- /dev/null +++ b/drivers/net/ethernet/socionext/netsec.c @@ -0,0 +1,1849 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#define NETSEC_REG_SOFT_RST0x104 +#define NETSEC_REG_COM_INIT0x120 + +#define NETSEC_REG_TOP_STATUS 0x200 +#define NETSEC_IRQ_RX BIT(1) +#define NETSEC_IRQ_TX BIT(0) + +#define NETSEC_REG_TOP_INTEN 0x204 +#define NETSEC_REG_INTEN_SET 0x234 +#define NETSEC_REG_INTEN_CLR 0x238 + +#define NETSEC_REG_NRM_TX_STATUS 0x400 +#define NETSEC_REG_NRM_TX_INTEN0x404 +#define NETSEC_REG_NRM_TX_INTEN_SET0x428 +#define NETSEC_REG_NRM_TX_INTEN_CLR0x42c +#define NRM_TX_ST_NTOWNR BIT(17) +#define NRM_TX_ST_TR_ERR BIT(16) +#define NRM_TX_ST_TXDONE BIT(15) +#define NRM_TX_ST_TMREXP BIT(14) + +#define NETSEC_REG_NRM_RX_STATUS 0x440 +#define NETSEC_REG_NRM_RX_INTEN0x444 +#define NETSEC_REG_NRM_RX_INTEN_SET0x468 +#define NETSEC_REG_NRM_RX_INTEN_CLR0x46c +#define NRM_RX_ST_RC_ERR BIT(16) +#define NRM_RX_ST_PKTCNT BIT(15) +#define NRM_RX_ST_TMREXP BIT(14) + +#define NETSEC_REG_PKT_CMD_BUF 0xd0 + +#define NETSEC_REG_CLK_EN 0x100 + +#define NETSEC_REG_PKT_CTRL0x140 + +#define NETSEC_REG_DMA_TMR_CTRL