From patchwork Tue Mar 25 23:34:40 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dinh Nguyen X-Patchwork-Id: 3891361 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0F18E9F2B6 for ; Tue, 25 Mar 2014 23:39:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EC0A22012E for ; Tue, 25 Mar 2014 23:39:44 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BF97220158 for ; Tue, 25 Mar 2014 23:39:43 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WSavE-0005J0-Ee; Tue, 25 Mar 2014 23:38:21 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WSauw-0006Sh-Qc; Tue, 25 Mar 2014 23:38:02 +0000 Received: from mail-by2on0111.outbound.protection.outlook.com ([207.46.100.111] helo=na01-by2-obe.outbound.protection.outlook.com) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WSauJ-0006Oc-7C for linux-arm-kernel@lists.infradead.org; Tue, 25 Mar 2014 23:37:29 +0000 Received: from BL2FFO11FD046.protection.gbl (10.173.160.34) by BL2FFO11HUB032.protection.gbl (10.173.161.56) with Microsoft SMTP Server (TLS) id 15.0.908.10; Tue, 25 Mar 2014 23:36:58 +0000 Received: from SJ-ITEXEDGE02.altera.priv.altera.com (66.35.236.232) by BL2FFO11FD046.mail.protection.outlook.com (10.173.161.208) with Microsoft SMTP Server (TLS) id 15.0.908.10 via Frontend Transport; Tue, 25 Mar 2014 23:36:57 +0000 Received: from sj-mail01.altera.com (137.57.1.6) by SJ-ITEXEDGE02.altera.priv.altera.com (66.35.236.232) with Microsoft SMTP Server id 8.3.342.0; Tue, 25 Mar 2014 16:23:54 -0700 Received: from linux-builds1.altera.com (linux-builds1.altera.com [137.57.188.114]) by sj-mail01.altera.com (8.13.7+Sun/8.13.7) with ESMTP id s2PNargB018949; Tue, 25 Mar 2014 16:36:55 -0700 (PDT) From: To: , , , Subject: [PATCH 1/3] net: stmmac: improve binding and fix build Date: Tue, 25 Mar 2014 18:34:40 -0500 Message-ID: <1395790482-3957-2-git-send-email-dinguyen@altera.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1395790482-3957-1-git-send-email-dinguyen@altera.com> References: <1395790482-3957-1-git-send-email-dinguyen@altera.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: =?us-ascii?Q?CIP:66.35.236.232; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(1001?= =?us-ascii?Q?9001)(6009001)(458001)(199002)(189002)(74706001)(83072002)(9?= =?us-ascii?Q?2566001)(92726001)(83322001)(53416003)(19580405001)(76482001?= =?us-ascii?Q?)(86152002)(76786001)(77156001)(56776001)(77096001)(74876001?= =?us-ascii?Q?)(2201001)(47446002)(85852003)(74502001)(74662001)(36756003)?= =?us-ascii?Q?(63696002)(54316002)(19580395003)(47776003)(20776003)(518560?= =?us-ascii?Q?01)(79102001)(76796001)(6806004)(81686001)(85306002)(5976600?= =?us-ascii?Q?1)(46102001)(81816001)(53806001)(77982001)(44976005)(8154200?= =?us-ascii?Q?1)(56816005)(89996001)(90146001)(87936001)(84676001)(6581600?= =?us-ascii?Q?1)(88136002)(62966002)(33646001)(80976001)(94316002)(9494600?= =?us-ascii?Q?1)(97736001)(97336001)(31966008)(49866001)(47976001)(9867600?= =?us-ascii?Q?1)(50986001)(97186001)(81342001)(69226001)(95666003)(8728600?= =?us-ascii?Q?1)(50466002)(87266001)(80022001)(50226001)(48376002)(4773600?= =?us-ascii?Q?1)(93916002)(93516002)(93136001)(86362001)(74366001)(9541600?= =?us-ascii?Q?1)(4396001); DIR:OUT; SFP:1102; SCL:1; SRVR:BL2FFO11HUB032; H:SJ-?= =?us-ascii?Q?ITEXEDGE02.altera.priv.altera.com; FPR:A2BCD744.A23295CD.92FA?= =?us-ascii?Q?7B3B.86E4E273.2057A; MLV:sfv; PTR:InfoDomainNonexistent; A:1; MX?= =?us-ascii?Q?:1;LANG:en;?= X-OriginatorOrg: altera.onmicrosoft.com X-Forefront-PRVS: 01613DFDC8 Received-SPF: SoftFail (: domain of transitioning altera.com discourages use of 66.35.236.232 as permitted sender) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140325_193723_560149_CEBDE30A X-CRM114-Status: GOOD ( 21.51 ) X-Spam-Score: -1.9 (-) Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, pawel.moll@arm.com, srinivas.kandagatla@st.com, netdev@vger.kernel.org, ijc+devicetree@hellion.org.uk, robh+dt@kernel.org, arm@kernel.org, Dinh Nguyen , galak@codeaurora.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.6 required=5.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Dinh Nguyen The new stmmac front-end for socfpga caused build failures for modular drivers, e.g. 'make allmodconfig', which prompted me to look closer into it. I found that both the DT binding and the implementation of the driver are rather nonstandard and do things very different from the other SoC specific glue drivers for stmmac. This puts things back in order, hopefully fixing all the important issues: * Added a new DWMAC_SOCFPGA Kconfig symbol to control compilation of this driver * Removed code related to scanning the DT nodes that are no longer there. * Replaced platform_driver and module stuff with call from main stmmac driver. * Removed bogus of_machine_is_compatible("altr,socfpga-vt")) check that should be handled through separate compatible properties of the dwmac node itself. This aligns the socfpga stmmac front-end to the sunxi and sti platforms. Signed-off-by: Arnd Bergmann Signed-off-by: Dinh Nguyen --- drivers/net/ethernet/stmicro/stmmac/Kconfig | 10 +++ drivers/net/ethernet/stmicro/stmmac/Makefile | 2 +- .../net/ethernet/stmicro/stmmac/dwmac-socfpga.c | 73 +++----------------- drivers/net/ethernet/stmicro/stmmac/stmmac.h | 1 + .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 3 + 5 files changed, 24 insertions(+), 65 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/Kconfig b/drivers/net/ethernet/stmicro/stmmac/Kconfig index f2d7c70..f8d5112 100644 --- a/drivers/net/ethernet/stmicro/stmmac/Kconfig +++ b/drivers/net/ethernet/stmicro/stmmac/Kconfig @@ -26,6 +26,16 @@ config STMMAC_PLATFORM If unsure, say N. +config DWMAC_SOCFPGA + bool "SOCFPGA dwmac support" + depends on STMMAC_PLATFORM && MFD_SYSCON && (ARCH_SOCFPGA || COMPILE_TEST) + help + Support for ethernet controller on Altera SOCFPGA + + This selects the Altera SOCFGA SoC glue layer support + for the stmmac device driver. This driver is used for + arria5 and cyclone5 FPGA SoCs. + config DWMAC_SUNXI bool "Allwinner GMAC support" depends on STMMAC_PLATFORM && ARCH_SUNXI diff --git a/drivers/net/ethernet/stmicro/stmmac/Makefile b/drivers/net/ethernet/stmicro/stmmac/Makefile index fd5e48d..18695eb 100644 --- a/drivers/net/ethernet/stmicro/stmmac/Makefile +++ b/drivers/net/ethernet/stmicro/stmmac/Makefile @@ -1,9 +1,9 @@ obj-$(CONFIG_STMMAC_ETH) += stmmac.o -stmmac-$(CONFIG_ARCH_SOCFPGA) += dwmac-socfpga.o stmmac-$(CONFIG_STMMAC_PLATFORM) += stmmac_platform.o stmmac-$(CONFIG_STMMAC_PCI) += stmmac_pci.o stmmac-$(CONFIG_DWMAC_SUNXI) += dwmac-sunxi.o stmmac-$(CONFIG_DWMAC_STI) += dwmac-sti.o +stmmac-$(CONFIG_DWMAC_SOCFPGA) += dwmac-socfpga.o stmmac-objs:= stmmac_main.o stmmac_ethtool.o stmmac_mdio.o ring_mode.o \ chain_mode.o dwmac_lib.o dwmac1000_core.o dwmac1000_dma.o \ dwmac100_core.o dwmac100_dma.o enh_desc.o norm_desc.o \ diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c index c7f034b..f27336c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c @@ -40,30 +40,16 @@ struct socfpga_dwmac { u32 reg_offset; struct device *dev; struct regmap *sys_mgr_base_addr; - struct device_node *dwmac_np; }; static int socfpga_dwmac_parse_data(struct socfpga_dwmac *dwmac, struct device *dev) { struct device_node *np = dev->of_node; - struct device_node *stmmac_np; struct regmap *sys_mgr_base_addr; u32 reg_offset; int ret; - stmmac_np = of_get_next_available_child(np, NULL); - if (!stmmac_np) { - dev_info(dev, "No dwmac node found\n"); - return -EINVAL; - } - - if (!of_device_is_compatible(stmmac_np, "snps,dwmac")) { - dev_info(dev, "dwmac node isn't compatible with snps,dwmac\n"); - return -EINVAL; - } - - dwmac->interface = of_get_phy_mode(stmmac_np); - of_node_put(stmmac_np); + dwmac->interface = of_get_phy_mode(np); sys_mgr_base_addr = syscon_regmap_lookup_by_phandle(np, "altr,sysmgr-syscon"); if (IS_ERR(sys_mgr_base_addr)) { @@ -79,7 +65,6 @@ static int socfpga_dwmac_parse_data(struct socfpga_dwmac *dwmac, struct device * dwmac->reg_offset = reg_offset; dwmac->sys_mgr_base_addr = sys_mgr_base_addr; - dwmac->dwmac_np = stmmac_np; dwmac->dev = dev; return 0; @@ -92,9 +77,6 @@ static int socfpga_dwmac_setup(struct socfpga_dwmac *dwmac) u32 reg_offset = dwmac->reg_offset; u32 ctrl, val, shift = 0; - if (of_machine_is_compatible("altr,socfpga-vt")) - return 0; - switch (phymode) { case PHY_INTERFACE_MODE_RGMII: val = SYSMGR_EMACGRP_CTRL_PHYSEL_ENUM_RGMII; @@ -116,68 +98,31 @@ static int socfpga_dwmac_setup(struct socfpga_dwmac *dwmac) return 0; } -static int socfpga_dwmac_probe(struct platform_device *pdev) +static void *socfpga_dwmac_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct device_node *node = dev->of_node; - int ret = -ENOMEM; + int ret; struct socfpga_dwmac *dwmac; dwmac = devm_kzalloc(dev, sizeof(*dwmac), GFP_KERNEL); if (!dwmac) - return -ENOMEM; + return ERR_PTR(-ENOMEM); ret = socfpga_dwmac_parse_data(dwmac, dev); if (ret) { dev_err(dev, "Unable to parse OF data\n"); - return ret; + return ERR_PTR(ret); } ret = socfpga_dwmac_setup(dwmac); if (ret) { dev_err(dev, "couldn't setup SoC glue (%d)\n", ret); - return ret; - } - - if (node) { - ret = of_platform_populate(node, NULL, NULL, dev); - if (ret) { - dev_err(dev, "failed to add dwmac core\n"); - return ret; - } - } else { - dev_err(dev, "no device node, failed to add dwmac core\n"); - return -ENODEV; + return ERR_PTR(ret); } - platform_set_drvdata(pdev, dwmac); - - return 0; + return dwmac; } -static int socfpga_dwmac_remove(struct platform_device *pdev) -{ - return 0; -} - -static const struct of_device_id socfpga_dwmac_match[] = { - { .compatible = "altr,socfpga-stmmac" }, - {}, -}; -MODULE_DEVICE_TABLE(of, socfpga_dwmac_match); - -static struct platform_driver socfpga_dwmac_driver = { - .probe = socfpga_dwmac_probe, - .remove = socfpga_dwmac_remove, - .driver = { - .name = "socfpga-dwmac", - .of_match_table = of_match_ptr(socfpga_dwmac_match), - }, +const struct stmmac_of_data socfpga_gmac_data = { + .setup = socfpga_dwmac_probe, }; - -module_platform_driver(socfpga_dwmac_driver); - -MODULE_ALIAS("platform:socfpga-dwmac"); -MODULE_AUTHOR("Dinh Nguyen "); -MODULE_LICENSE("GPL v2"); -MODULE_DESCRIPTION("Altera SOCFPGA DWMAC Glue Layer"); diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h index f9e60d7..cd2f6a1 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h @@ -136,6 +136,7 @@ extern const struct stmmac_of_data sun7i_gmac_data; #ifdef CONFIG_DWMAC_STI extern const struct stmmac_of_data sti_gmac_data; #endif +extern const struct stmmac_of_data socfpga_gmac_data; extern struct platform_driver stmmac_pltfr_driver; static inline int stmmac_register_platform(void) { diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c index c61bc72b..8894697 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c @@ -38,6 +38,9 @@ static const struct of_device_id stmmac_dt_ids[] = { { .compatible = "st,stih416-dwmac", .data = &sti_gmac_data}, { .compatible = "st,stih127-dwmac", .data = &sti_gmac_data}, #endif +#ifdef CONFIG_DWMAC_SOCFPGA + { .compatible = "altr,socfpga-stmmac", .data = &socfpga_gmac_data }, +#endif /* SoC specific glue layers should come before generic bindings */ { .compatible = "st,spear600-gmac"}, { .compatible = "snps,dwmac-3.610"},