From patchwork Fri Aug 9 14:40:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 170939 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp10103537ile; Fri, 9 Aug 2019 07:44:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyDiVSqL0+yGfY9AsJBkrhNjKdQpBtgyA82W5fowYQ7JPaqGvkXlim94Fy3Vv7oMft2HBTs X-Received: by 2002:a17:902:40e:: with SMTP id 14mr9233229ple.323.1565361852386; Fri, 09 Aug 2019 07:44:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565361852; cv=none; d=google.com; s=arc-20160816; b=JuOkNmfQHoKfVZL0n/4OfLM0F+P7ooJNJrxt4ugV7GknrkSi8qzk4lPbQGNz2x7Vbt PJdPETG0nCkEd5IGs+zqqbx3QBGdGJbBE+YmFh0W9g6G1PZ9nvi0xdFWwQDmfsVK8qVA +530uewKZ7/Vn/bMQ0voIWjK5jaHsCJ4vmk/x9UNRtivbO1B8md9EiJTTX5UjXChFh+C OvrKTxn5WSojl66m5COdL41FHbV0eJbCrRBX+pWRy3jusxhFJM8njLjAjGx7QwzOxRa9 DuVId+1OEg+HUuC5yaCItBOm2WV0fqQz8Ot6ZiPxlUANa/dycJzlnvTXnzvTAOLjNmbq uziA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=v2uhnx/kTHKRUG/12O0Lgcv/K2K6wy1QRYdE54NdAm4=; b=En4X3M7bJHBHXHQ41/vr1swiO//Ery3lbmXz0POycI3V3C+vRsAk1xNlPwhS/77mt0 MgXmhET2wr9RfAvaqdCz5TiB+p0LnAiqsjUJw0Zs9AlHb4goPXWt5PyuYTMnG6oO4+Uf FoPmrrsj5sb5KvxaGzPleZpqk5oMMhzWRj9nxzaRnZDf8uTzCHyNHBuPFhX/ebw403Us rnrSkvAPERYz/Ie4NK1u8oql2lOYC2o5QFEAXHPppC33bFlKgkBHAo2frZbXb5ZP6xDb tii6TW8T7u24kY6WqfxEIh5hS3aBneA7f17WtqDUW8yjjbFVuR/JYMF4buoa3PRo0hJo yVyw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v19si53517803pff.229.2019.08.09.07.44.12; Fri, 09 Aug 2019 07:44:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407131AbfHIOoL (ORCPT + 28 others); Fri, 9 Aug 2019 10:44:11 -0400 Received: from mout.kundenserver.de ([212.227.126.133]:55503 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407102AbfHIOoK (ORCPT ); Fri, 9 Aug 2019 10:44:10 -0400 Received: from threadripper.lan ([149.172.19.189]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.129]) with ESMTPA (Nemesis) id 1Mx0VH-1iG7wk0ZcR-00yNx6; Fri, 09 Aug 2019 16:43:57 +0200 From: Arnd Bergmann To: soc@kernel.org Cc: Vladimir Zapolskiy , Sylvain Lemieux , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Arnd Bergmann , "David S. Miller" , netdev@vger.kernel.org Subject: [PATCH v2 07/13] net: lpc-enet: move phy setup into platform code Date: Fri, 9 Aug 2019 16:40:33 +0200 Message-Id: <20190809144043.476786-8-arnd@arndb.de> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20190809144043.476786-1-arnd@arndb.de> References: <20190809144043.476786-1-arnd@arndb.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:npK/7O3KZV7d5O6NlWG3KNX1AMZFTWjJt5jIZxT/9Cn6I6FKIyo QtmoB26+nkmPETIXDitdSAt3MnVUpAxDnh/1ZLz+8c0KEwvBbqHnSWWDkLtfc/YRekmRqr5 U4rxDZ6QBOwqpsUrp+++R8K7fAN9D0TeE8kfbsHlLe8H0PeB8CZjVjOVT8MXhEld2he1dd2 UkoVJI9R12KVyqTHBifnQ== X-Spam-Flag: NO X-UI-Out-Filterresults: notjunk:1; V03:K0:kLcmpZsLMHg=:LoRu5U8RBYNWBdajrx2Cwj 6uByw9wEYucEAL3bs+1NpQky5IJXsvTOh30GBcLVsNnj5/OwquXE9MpMPWojycLdCkndhwz+z puWsll5zQwgM8JWIVSvq6AWJAbVRm2X4pe5oDaKtxCngVuIIA+axfdXJ0S6FbTUnb8VnSwRIz qq7v+7v038KEMCGZ35mPmHCkXfEU1cSN6ZYwbZ0efnPULIZduEpJC52N64jDVt8VisVK3ssV7 6aZtKKRmULV1uAZhzrlmFP9iq2m/I9znqHOwo0YJr7yMOEeIgUZbJKtSxQV4j+UbcZDmS8HQE LuGQwq1CMlbsrrJJ0CGqN2/mLKJxYmnbfJtnsDdp1pjp20yYDa4qMU8r6bhtgwS3/yG7zDNqK iZxDQHnl4i8x6PnGJz67MzpBbv3vmsym27A3S58cKKn6Md9UDbBI242zZ6rbizo5HJDKXJ6GI UxCWGLvITRVhAspCZCfwt+EBfFguy1dhrC9XrOF4I0VJK3M53cHCw+jPJUdCzLP0oyIMvdtkp Weh4d1hylUIKcVZqernWkqPkZorxBi3+lgfwM6I+ifN2erPkpucf3aFo3oP3Wfr9zIDsiHgRm mo7Zowpf0ldICtz3wHHRygz4UhGCgI7NWy93AvCjci6ORuvc4Ev3IYioUWqjuGJPDuxULpn4A a15PpF5qK7LDO+UcnTtvdG5ORUZbfltTMWziW0OG2VhmkxTExAwXFxEmM7eWriJ1BYH607csq 1aGj26CaWSLC6rzP2Cbj9tPr6g43e+aGnQqJxQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Setting the phy mode requires touching a platform specific register, which prevents us from building the driver without its header files. Move it into a separate function in arch/arm/mach/lpc32xx to hide the core registers from the network driver. Acked-by: Sylvain Lemieux Signed-off-by: Arnd Bergmann --- arch/arm/mach-lpc32xx/common.c | 12 ++++++++++++ drivers/net/ethernet/nxp/lpc_eth.c | 12 +----------- include/linux/soc/nxp/lpc32xx-misc.h | 5 +++++ 3 files changed, 18 insertions(+), 11 deletions(-) -- 2.20.0 diff --git a/arch/arm/mach-lpc32xx/common.c b/arch/arm/mach-lpc32xx/common.c index f648324d5fb4..a475339333c1 100644 --- a/arch/arm/mach-lpc32xx/common.c +++ b/arch/arm/mach-lpc32xx/common.c @@ -63,6 +63,18 @@ u32 lpc32xx_return_iram(void __iomem **mapbase, dma_addr_t *dmaaddr) } EXPORT_SYMBOL_GPL(lpc32xx_return_iram); +void lpc32xx_set_phy_interface_mode(phy_interface_t mode) +{ + u32 tmp = __raw_readl(LPC32XX_CLKPWR_MACCLK_CTRL); + tmp &= ~LPC32XX_CLKPWR_MACCTRL_PINS_MSK; + if (mode == PHY_INTERFACE_MODE_MII) + tmp |= LPC32XX_CLKPWR_MACCTRL_USE_MII_PINS; + else + tmp |= LPC32XX_CLKPWR_MACCTRL_USE_RMII_PINS; + __raw_writel(tmp, LPC32XX_CLKPWR_MACCLK_CTRL); +} +EXPORT_SYMBOL_GPL(lpc32xx_set_phy_interface_mode); + static struct map_desc lpc32xx_io_desc[] __initdata = { { .virtual = (unsigned long)IO_ADDRESS(LPC32XX_AHB0_START), diff --git a/drivers/net/ethernet/nxp/lpc_eth.c b/drivers/net/ethernet/nxp/lpc_eth.c index bcdd0adcfb0c..0893b77c385d 100644 --- a/drivers/net/ethernet/nxp/lpc_eth.c +++ b/drivers/net/ethernet/nxp/lpc_eth.c @@ -20,9 +20,6 @@ #include #include -#include -#include - #define MODNAME "lpc-eth" #define DRV_VERSION "1.00" @@ -1237,16 +1234,9 @@ static int lpc_eth_drv_probe(struct platform_device *pdev) dma_addr_t dma_handle; struct resource *res; int irq, ret; - u32 tmp; /* Setup network interface for RMII or MII mode */ - tmp = __raw_readl(LPC32XX_CLKPWR_MACCLK_CTRL); - tmp &= ~LPC32XX_CLKPWR_MACCTRL_PINS_MSK; - if (lpc_phy_interface_mode(dev) == PHY_INTERFACE_MODE_MII) - tmp |= LPC32XX_CLKPWR_MACCTRL_USE_MII_PINS; - else - tmp |= LPC32XX_CLKPWR_MACCTRL_USE_RMII_PINS; - __raw_writel(tmp, LPC32XX_CLKPWR_MACCLK_CTRL); + lpc32xx_set_phy_interface_mode(lpc_phy_interface_mode(dev)); /* Get platform resources */ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); diff --git a/include/linux/soc/nxp/lpc32xx-misc.h b/include/linux/soc/nxp/lpc32xx-misc.h index f232e1a1bcdc..af4f82f6cf3b 100644 --- a/include/linux/soc/nxp/lpc32xx-misc.h +++ b/include/linux/soc/nxp/lpc32xx-misc.h @@ -9,9 +9,11 @@ #define __SOC_LPC32XX_MISC_H #include +#include #ifdef CONFIG_ARCH_LPC32XX extern u32 lpc32xx_return_iram(void __iomem **mapbase, dma_addr_t *dmaaddr); +extern void lpc32xx_set_phy_interface_mode(phy_interface_t mode); #else static inline u32 lpc32xx_return_iram(void __iomem **mapbase, dma_addr_t *dmaaddr) { @@ -19,6 +21,9 @@ static inline u32 lpc32xx_return_iram(void __iomem **mapbase, dma_addr_t *dmaadd *dmaaddr = 0; return 0; } +static inline void lpc32xx_set_phy_interface_mode(phy_interface_t mode) +{ +} #endif #endif /* __SOC_LPC32XX_MISC_H */