From: Andrew Bresticker <abrestic-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
To: Giuseppe Cavallaro <peppe.cavallaro-qxv4g6HH51o@public.gmane.org>,
"David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>
Cc: netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Andrew Bresticker
<abrestic-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
Govindraj Raja
<govindraj.raja-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>,
James Hartley
<james.hartley-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
Subject: [PATCH 2/2] stmmac: Add IMG Pistachio platform glue layer
Date: Thu, 2 Apr 2015 16:46:36 -0700 [thread overview]
Message-ID: <1428018396-11270-2-git-send-email-abrestic@chromium.org> (raw)
In-Reply-To: <1428018396-11270-1-git-send-email-abrestic-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
At the moment, the only additional setup required for the DWMAC
on the IMG Pistachio SoC is to request and enable a separate gate
clock for the register interface.
Signed-off-by: Andrew Bresticker <abrestic-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Signed-off-by: Govindraj Raja <govindraj.raja-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
Cc: James Hartley <james.hartley-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org>
---
drivers/net/ethernet/stmicro/stmmac/Makefile | 3 +-
.../net/ethernet/stmicro/stmmac/dwmac-pistachio.c | 57 ++++++++++++++++++++++
.../net/ethernet/stmicro/stmmac/stmmac_platform.c | 1 +
.../net/ethernet/stmicro/stmmac/stmmac_platform.h | 1 +
4 files changed, 61 insertions(+), 1 deletion(-)
create mode 100644 drivers/net/ethernet/stmicro/stmmac/dwmac-pistachio.c
diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile
index 73c2715..8efb622 100644
--- a/drivers/net/ethernet/stmicro/stmmac/Makefile
+++ b/drivers/net/ethernet/stmicro/stmmac/Makefile
@@ -6,7 +6,8 @@ stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o ring_mode.o \
obj-$(CONFIG_STMMAC_PLATFORM) += stmmac-platform.o
stmmac-platform-objs:= stmmac_platform.o dwmac-meson.o dwmac-sunxi.o \
- dwmac-sti.o dwmac-socfpga.o dwmac-rk.o
+ dwmac-sti.o dwmac-socfpga.o dwmac-rk.o \
+ dwmac-pistachio.o
obj-$(CONFIG_STMMAC_PCI) += stmmac-pci.o
stmmac-pci-objs:= stmmac_pci.o
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-pistachio.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-pistachio.c
new file mode 100644
index 0000000..3041c99
--- /dev/null
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-pistachio.c
@@ -0,0 +1,57 @@
+/*
+ * IMG Pistachio DWMAC glue layer
+ *
+ * Copyright (C) 2015 Google, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ */
+
+#include <linux/clk.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/stmmac.h>
+
+struct pistachio_dwmac_priv_data {
+ struct clk *sys_clk;
+};
+
+static void *pistachio_dwmac_setup(struct platform_device *pdev)
+{
+ struct pistachio_dwmac_priv_data *pdata;
+
+ pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+ if (!pdata)
+ return ERR_PTR(-ENOMEM);
+
+ pdata->sys_clk = devm_clk_get(&pdev->dev, "sys");
+ if (IS_ERR(pdata->sys_clk)) {
+ dev_err(&pdev->dev, "Failed to get sys clock: %ld\n",
+ PTR_ERR(pdata->sys_clk));
+ return pdata->sys_clk;
+ }
+
+ return pdata;
+}
+
+static int pistachio_dwmac_init(struct platform_device *pdev, void *priv)
+{
+ struct pistachio_dwmac_priv_data *pdata = priv;
+
+ return clk_prepare_enable(pdata->sys_clk);
+}
+
+static void pistachio_dwmac_exit(struct platform_device *pdev, void *priv)
+{
+ struct pistachio_dwmac_priv_data *pdata = priv;
+
+ clk_disable_unprepare(pdata->sys_clk);
+}
+
+const struct stmmac_of_data pistachio_dwmac_data = {
+ .setup = pistachio_dwmac_setup,
+ .init = pistachio_dwmac_init,
+ .exit = pistachio_dwmac_exit,
+ .has_gmac = true,
+};
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index f9b42f1..d5de361 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -34,6 +34,7 @@
static const struct of_device_id stmmac_dt_ids[] = {
/* SoC specific glue layers should come before generic bindings */
{ .compatible = "rockchip,rk3288-gmac", .data = &rk3288_gmac_data},
+ { .compatible = "img,pistachio-dwmac", .data = &pistachio_dwmac_data},
{ .compatible = "amlogic,meson6-dwmac", .data = &meson6_dwmac_data},
{ .compatible = "allwinner,sun7i-a20-gmac", .data = &sun7i_gmac_data},
{ .compatible = "st,stih415-dwmac", .data = &stih4xx_dwmac_data},
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h
index 093eb99..101e635 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.h
@@ -25,5 +25,6 @@ extern const struct stmmac_of_data stih4xx_dwmac_data;
extern const struct stmmac_of_data stid127_dwmac_data;
extern const struct stmmac_of_data socfpga_gmac_data;
extern const struct stmmac_of_data rk3288_gmac_data;
+extern const struct stmmac_of_data pistachio_dwmac_data;
#endif /* __STMMAC_PLATFORM_H__ */
--
2.2.0.rc0.207.ga3a616c
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-04-02 23:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-02 23:46 [PATCH 1/2] stmmac: Add binding document for IMG Pistachio DWMAC Andrew Bresticker
[not found] ` <1428018396-11270-1-git-send-email-abrestic-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
2015-04-02 23:46 ` Andrew Bresticker [this message]
2015-04-06 20:51 ` [PATCH 2/2] stmmac: Add IMG Pistachio platform glue layer David Miller
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=1428018396-11270-2-git-send-email-abrestic@chromium.org \
--to=abrestic-f7+t8e8rja9g9huczpvpmw@public.gmane.org \
--cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=govindraj.raja-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org \
--cc=james.hartley-1AXoQHu6uovQT0dZR+AlfA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=peppe.cavallaro-qxv4g6HH51o@public.gmane.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).