From patchwork Sun Jan 25 15:49:19 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Kuske X-Patchwork-Id: 5701911 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id D2DF6C058D for ; Sun, 25 Jan 2015 15:52:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 12C5720148 for ; Sun, 25 Jan 2015 15:52:16 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (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 8868720160 for ; Sun, 25 Jan 2015 15:52:14 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YFPSP-0001by-2J; Sun, 25 Jan 2015 15:50:37 +0000 Received: from mail-wg0-x234.google.com ([2a00:1450:400c:c00::234]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YFPRe-0008OQ-Rs for linux-arm-kernel@lists.infradead.org; Sun, 25 Jan 2015 15:49:51 +0000 Received: by mail-wg0-f52.google.com with SMTP id y19so5197548wgg.11 for ; Sun, 25 Jan 2015 07:49:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=qm5sAdR+7sFdgyykAW64qi/eIVn9UCqlQ5gx+sAZOE0=; b=fRx09/Z1kcqUhT96H2Dyjf7nOWab8UQCoTBgJec4lHPlcEsKrURanGrnBQbSqjI0KH xIAbxgvHderzIKJW+5MUwsIK/9H29pJv3fD9F1Z8VqUuEBjt4Dy7jt6vyV9jqsuLbDXU zXghmharufjTOQSUbAyQocJ23wkhmf7frL7WxVwpGeJx5PPk6Wo8OfvPkAAZy6I2jjUM S0gHV8CfuVpN3wq1dwEHqQxef8ql4AJ6bPI+JpqNrP80lyC7Z+ujjMjwp6PrPMZCmIwN uGhdIF7oodrZf4BEbU+r2mJyrW6ubIzb/rp40jLXYy3Z3LdX6hGMeohUshUd83mUBkEo /YBQ== X-Received: by 10.194.85.106 with SMTP id g10mr34392948wjz.39.1422200968630; Sun, 25 Jan 2015 07:49:28 -0800 (PST) Received: from jens-lin.localdomain (p5B2EA102.dip0.t-ipconnect.de. [91.46.161.2]) by mx.google.com with ESMTPSA id h8sm10241190wiy.4.2015.01.25.07.49.27 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 25 Jan 2015 07:49:28 -0800 (PST) From: Jens Kuske To: Maxime Ripard , Lee Jones , netdev@vger.kernel.org Subject: [PATCH 3/3] net: allwinner: sun4i-emac: fix emac SRAM mapping Date: Sun, 25 Jan 2015 16:49:19 +0100 Message-Id: <1422200959-1717-4-git-send-email-jenskuske@gmail.com> X-Mailer: git-send-email 2.2.2 In-Reply-To: <1422200959-1717-1-git-send-email-jenskuske@gmail.com> References: <1422200959-1717-1-git-send-email-jenskuske@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150125_074951_096277_C2922074 X-CRM114-Status: GOOD ( 11.86 ) X-Spam-Score: -0.8 (/) Cc: devicetree@vger.kernel.org, Chen-Yu Tsai , linux-sunxi@googlegroups.com, linux-arm-kernel@lists.infradead.org, Jens Kuske X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 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.1 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID, T_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 The EMAC needs SRAM block A3_A4 being mapped to EMAC peripheral to work. This is done by the bootloader most of the time, but U-Boot Falcon Mode, for example, skips emac initialization and SRAM would stay mapped to the CPU. Signed-off-by: Jens Kuske --- drivers/net/ethernet/allwinner/Kconfig | 1 + drivers/net/ethernet/allwinner/sun4i-emac.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/drivers/net/ethernet/allwinner/Kconfig b/drivers/net/ethernet/allwinner/Kconfig index d8d95d4..508a288 100644 --- a/drivers/net/ethernet/allwinner/Kconfig +++ b/drivers/net/ethernet/allwinner/Kconfig @@ -28,6 +28,7 @@ config SUN4I_EMAC select MII select PHYLIB select MDIO_SUN4I + select MFD_SYSCON ---help--- Support for Allwinner A10 EMAC ethernet driver. diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c index 1fcd556..86c891d 100644 --- a/drivers/net/ethernet/allwinner/sun4i-emac.c +++ b/drivers/net/ethernet/allwinner/sun4i-emac.c @@ -18,6 +18,8 @@ #include #include #include +#include +#include #include #include #include @@ -28,6 +30,7 @@ #include #include #include +#include #include "sun4i-emac.h" @@ -78,6 +81,7 @@ struct emac_board_info { struct phy_device *phy_dev; struct device_node *phy_node; + struct regmap *sc; unsigned int link; unsigned int speed; unsigned int duplex; @@ -862,6 +866,18 @@ static int emac_probe(struct platform_device *pdev) goto out; } + /* Map SRAM_A3_A4 to EMAC */ + db->sc = syscon_regmap_lookup_by_compatible( + "allwinner,sun4i-a10-syscon"); + if (IS_ERR(db->sc)) { + dev_err(&pdev->dev, "failed to find syscon regmap\n"); + ret = PTR_ERR(db->sc); + goto out; + } + + regmap_update_bits(db->sc, SUN4I_SC1, SUN4I_SC1_SRAM_A3_A4_MAP_MASK, + SUN4I_SC1_SRAM_A3_A4_MAP_EMAC); + /* Read MAC-address from DT */ mac_addr = of_get_mac_address(np); if (mac_addr) @@ -910,7 +926,9 @@ out: static int emac_remove(struct platform_device *pdev) { struct net_device *ndev = platform_get_drvdata(pdev); + struct emac_board_info *db = netdev_priv(ndev); + regmap_update_bits(db->sc, SUN4I_SC1, SUN4I_SC1_SRAM_A3_A4_MAP_MASK, 0); unregister_netdev(ndev); free_netdev(ndev);