All of lore.kernel.org
 help / color / mirror / Atom feed
From: Amit Singh Tomar <amittomer25@gmail.com>
To: u-boot@lists.denx.de
Subject: [PATCH v3 18/21] net: designware: s700: Add glue code for S700 mac
Date: Sat, 25 Jan 2020 17:53:00 +0530	[thread overview]
Message-ID: <1579954983-11329-19-git-send-email-amittomer25@gmail.com> (raw)
In-Reply-To: <1579954983-11329-1-git-send-email-amittomer25@gmail.com>

This patchs adds glue logic to enable designware mac present on
Action Semi based S700 SoC, Configures SoC specific bits.

It has been tested on Cubieboard7.

Signed-off-by: Amit Singh Tomar <amittomer25@gmail.com>
---
Changes since v2:
        * Newly added patch, not there in v2/v1.
---
 arch/arm/include/asm/arch-owl/regs_s700.h |  6 +++
 drivers/net/Kconfig                       |  7 ++++
 drivers/net/Makefile                      |  1 +
 drivers/net/dwmac_s700.c                  | 66 +++++++++++++++++++++++++++++++
 4 files changed, 80 insertions(+)
 create mode 100644 drivers/net/dwmac_s700.c

diff --git a/arch/arm/include/asm/arch-owl/regs_s700.h b/arch/arm/include/asm/arch-owl/regs_s700.h
index a0bd737..b4ed719 100644
--- a/arch/arm/include/asm/arch-owl/regs_s700.h
+++ b/arch/arm/include/asm/arch-owl/regs_s700.h
@@ -53,4 +53,10 @@
 #define CMU_CVBSPLL		(0x00B8)
 #define CMU_SSTSCLK		(0x00C0)
 
+#define GPIO_MFP_PWM		(0xE01B0000)
+#define MFP_CTL0		(GPIO_MFP_PWM + 0x40)
+#define MFP_CTL1		(GPIO_MFP_PWM + 0x44)
+#define MFP_CTL2		(GPIO_MFP_PWM + 0x48)
+#define MFP_CTL3		(GPIO_MFP_PWM + 0x4C)
+
 #endif
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
index 01d087f..6a5ecf8 100644
--- a/drivers/net/Kconfig
+++ b/drivers/net/Kconfig
@@ -218,6 +218,13 @@ config ETH_DESIGNWARE_SOCFPGA
 	  Altera system manager to correctly interface with the PHY.
 	  This code handles those SoC specifics.
 
+config ETH_DESIGNWARE_S700
+        bool "Actins S700 glue driver for Synopsys Designware Ethernet MAC"
+        depends on DM_ETH && ETH_DESIGNWARE
+        help
+          This provides glue layer to use Synopsys Designware Ethernet MAC
+          present on Actions S700 SoC.
+
 config ETHOC
 	bool "OpenCores 10/100 Mbps Ethernet MAC"
 	help
diff --git a/drivers/net/Makefile b/drivers/net/Makefile
index 3099183..b8e766b 100644
--- a/drivers/net/Makefile
+++ b/drivers/net/Makefile
@@ -17,6 +17,7 @@ obj-$(CONFIG_CS8900) += cs8900.o
 obj-$(CONFIG_TULIP) += dc2114x.o
 obj-$(CONFIG_ETH_DESIGNWARE) += designware.o
 obj-$(CONFIG_ETH_DESIGNWARE_SOCFPGA) += dwmac_socfpga.o
+obj-$(CONFIG_ETH_DESIGNWARE_S700) += dwmac_s700.o
 obj-$(CONFIG_DRIVER_DM9000) += dm9000x.o
 obj-$(CONFIG_DNET) += dnet.o
 obj-$(CONFIG_E1000) += e1000.o
diff --git a/drivers/net/dwmac_s700.c b/drivers/net/dwmac_s700.c
new file mode 100644
index 0000000..a5d544e
--- /dev/null
+++ b/drivers/net/dwmac_s700.c
@@ -0,0 +1,66 @@
+// SPDX-License-Identifier: GPL-2.0+
+/*
+ * Copyright (C) 2020 Amit Singh Tomar <amittomer25@gmail.com>
+ *
+ * Actions DWMAC specific glue layer
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <dm.h>
+#include <clk.h>
+#include <phy.h>
+#include <regmap.h>
+#include <reset.h>
+#include <syscon.h>
+#include "designware.h"
+#include <asm/arch-owl/regs_s700.h>
+
+/* pin control for MAC */
+#define RMII_TXD01_MFP_CTL0		(0x0 << 16)
+#define RMII_RXD01_MFP_CTL0		(0x0 << 8)
+#define RMII_TXEN_TXER_MFP_CTL0		(0x0 << 13)
+#define RMII_REF_CLK_MFP_CTL0		(0x0 << 6)
+#define CLKO_25M_EN_MFP_CTL3		BIT(30)
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static void dwmac_board_setup(void)
+{
+	clrbits_le32(MFP_CTL0, (RMII_TXD01_MFP_CTL0 | RMII_RXD01_MFP_CTL0 |
+		     RMII_TXEN_TXER_MFP_CTL0 | RMII_REF_CLK_MFP_CTL0));
+
+	setbits_le32(MFP_CTL3, CLKO_25M_EN_MFP_CTL3);
+}
+
+static int dwmac_s700_probe(struct udevice *dev)
+{
+	dwmac_board_setup();
+
+	/* This is undocumented, phy interface select register */
+	writel(0x4, 0xe024c0a0);
+
+	return designware_eth_probe(dev);
+}
+
+static int dwmac_s700_ofdata_to_platdata(struct udevice *dev)
+{
+	return designware_eth_ofdata_to_platdata(dev);
+}
+
+static const struct udevice_id dwmac_s700_ids[] = {
+	{.compatible = "actions,s700-ethernet"},
+	{ }
+};
+
+U_BOOT_DRIVER(dwmac_s700) = {
+	.name   = "dwmac_s700",
+	.id     = UCLASS_ETH,
+	.of_match = dwmac_s700_ids,
+	.ofdata_to_platdata = dwmac_s700_ofdata_to_platdata,
+	.probe  = dwmac_s700_probe,
+	.ops    = &designware_eth_ops,
+	.priv_auto_alloc_size = sizeof(struct dw_eth_dev),
+	.platdata_auto_alloc_size = sizeof(struct eth_pdata),
+	.flags = DM_FLAG_ALLOC_PRIV_DMA,
+};
-- 
2.7.4

  parent reply	other threads:[~2020-01-25 12:23 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-25 12:22 [PATCH v3 00/21] Actions S700 SoC support Amit Singh Tomar
2020-01-25 12:22 ` [PATCH v3 01/21] arm: actions: Add common framework for Actions Owl Semi SoCs Amit Singh Tomar
2020-02-23 17:13   ` Manivannan Sadhasivam
2020-01-25 12:22 ` [PATCH v3 02/21] arm: actions: rename sysmap-s900 to sysmap-owl Amit Singh Tomar
2020-02-23 17:15   ` Manivannan Sadhasivam
2020-01-25 12:22 ` [PATCH v3 03/21] clk: actions: Add common clock driver Amit Singh Tomar
2020-02-23 17:25   ` Manivannan Sadhasivam
2020-03-03  8:23     ` Amit Tomer
2020-03-03 10:20     ` Andre Przywara
2020-03-03 10:38       ` Amit Tomer
2020-01-25 12:22 ` [PATCH v3 04/21] arm: add support Actions Semi S700 Amit Singh Tomar
2020-02-23 17:27   ` Manivannan Sadhasivam
2020-01-25 12:22 ` [PATCH v3 05/21] arm: actions: add S700 SoC device tree Amit Singh Tomar
2020-02-23 17:29   ` Manivannan Sadhasivam
2020-01-25 12:22 ` [PATCH v3 06/21] actions:s700: add u-boot specific dts file Amit Singh Tomar
2020-02-23 17:32   ` Manivannan Sadhasivam
2020-01-25 12:22 ` [PATCH v3 07/21] arm: dts: sync dts for Action Semi S900 Amit Singh Tomar
2020-02-23 17:34   ` Manivannan Sadhasivam
2020-01-25 12:22 ` [PATCH v3 08/21] actions: s900: add u-boot specific dts file Amit Singh Tomar
2020-02-23 17:37   ` Manivannan Sadhasivam
2020-01-25 12:22 ` [PATCH v3 09/21] arm: dts: Use consistent name "CLK_ETHERNET" for the Ethernet clock binding Amit Singh Tomar
2020-02-23 17:38   ` Manivannan Sadhasivam
2020-02-24 14:37     ` Andre Przywara
2020-02-24 14:48       ` Manivannan Sadhasivam
2020-03-03  8:28       ` Amit Tomer
2020-01-25 12:22 ` [PATCH v3 10/21] serial: actions: add uart support for s700 Amit Singh Tomar
2020-02-23 17:39   ` Manivannan Sadhasivam
2020-01-25 12:22 ` [PATCH v3 11/21] arm: add Cubieboard7 board support Amit Singh Tomar
2020-02-23 17:41   ` Manivannan Sadhasivam
2020-01-25 12:22 ` [PATCH v3 12/21] actions: add Cubieboard7 README Amit Singh Tomar
2020-02-11 15:54   ` Tom Rini
2020-01-25 12:22 ` [PATCH v3 13/21] net: phy: realtek: Add support for RTL8201F PHY module Amit Singh Tomar
2020-01-25 12:22 ` [PATCH v3 14/21] net: phy: realtek: Introduce PHY_RTL8201F_S700_RMII_TIMINGS to adjust rx/tx timings Amit Singh Tomar
2020-01-25 12:22 ` [PATCH v3 15/21] reset: add driver for generic reset controllers Amit Singh Tomar
2020-02-23 17:45   ` Manivannan Sadhasivam
2020-02-24 14:52   ` Andre Przywara
2020-03-03 10:21   ` Andre Przywara
2020-01-25 12:22 ` [PATCH v3 16/21] arm: dts: s700: add node for reset controller Amit Singh Tomar
2020-01-25 12:22 ` [PATCH v3 17/21] owl: Kconfig: Enable dm reset and generic reset Amit Singh Tomar
2020-01-25 12:23 ` Amit Singh Tomar [this message]
2020-01-25 12:23 ` [PATCH v3 19/21] arm: dts: s700: add node for ethernet controller Amit Singh Tomar
2020-01-25 12:23 ` [PATCH v3 20/21] owl: Kconfig: Enable dm eth for OWL platform Amit Singh Tomar
2020-01-25 12:23 ` [PATCH v3 21/21] configs: Enable mac and phy configs Amit Singh Tomar
2020-02-11 16:05 ` [PATCH v3 00/21] Actions S700 SoC support Manivannan Sadhasivam
2020-02-13 11:09   ` Amit Tomer
2020-02-23 17:51 ` Manivannan Sadhasivam

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1579954983-11329-19-git-send-email-amittomer25@gmail.com \
    --to=amittomer25@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.