From patchwork Sat Mar 4 01:09:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iyappan Subramanian X-Patchwork-Id: 9603731 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 41EF260414 for ; Sat, 4 Mar 2017 01:11:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 389BC28614 for ; Sat, 4 Mar 2017 01:11:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1D7C428617; Sat, 4 Mar 2017 01:11:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 95C9128614 for ; Sat, 4 Mar 2017 01:11:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=gj+iy2sXehwTFlR9mW9Knbd5JWzWYbeIjAsQl123RYs=; b=ptRC+IIrZDAsCtkuS7wvU3dtug cuNiosZoLO2JbW5CNMjoZkM76q4p+C2tsZksSbqbEZzhiNuqUxwEhwJnJcDcw3OwWoMs1mlfSe9cE K0NMk1iTQ1tVIz1wHtJY/mbDcBsL0SqzLB1Ms3lYT9+nCAaoXYfJnEvIqfVB+PX9TDS1+JtErgkN4 WeHRAieRFiy5KjqNlysxGjkMDuLpcIE0y+SDu+yduOpvr4ItvN2s1/NNQrVuwKNbULrV6AzNLoNHq VNH+/D8w2+JZ7/34VjQaTkd4MsA7dOx+UzUujLGYVAXHA991aA5o+P3gK04J1Y5em+LSUQFkR56os 4T3hIRvA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cjyDr-0006tQ-OE; Sat, 04 Mar 2017 01:10:59 +0000 Received: from mail-pg0-x22a.google.com ([2607:f8b0:400e:c05::22a]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1cjyC1-0004Xp-8a for linux-arm-kernel@lists.infradead.org; Sat, 04 Mar 2017 01:09:08 +0000 Received: by mail-pg0-x22a.google.com with SMTP id s67so49131073pgb.3 for ; Fri, 03 Mar 2017 17:08:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=apm.com; s=apm; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=LXNkQv7sYpWcXg5KIO9bDXPDZ8RHDtMWktd+VpOj2Gg=; b=pUZP6P6ILKkx0JHpd9rtNILQF6W3wGMUKMhvTyYjLXhn+DWhwavGdPHW5IyxfRq6ve re6ggcSzGXCmFmWvCDN4hairj8PSoVEIbW5TBRMTyTIqTjln36T02NH7abuespfQVmGu SWyHApGAsCKL5DtEjpvp7SOce7jEyxJ5PBh2M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=LXNkQv7sYpWcXg5KIO9bDXPDZ8RHDtMWktd+VpOj2Gg=; b=slpGEXrd/nQKKxIrT4Fy5qbmOUAkll74IhGbHbUFRtTRNEhS7YsMGNbjOTq1PXzdH/ cMi8pSe7no3GQnJjChhu09O/J2+Qm81XLzRbg4RQvHsrJpn5hvhPrDwq7NnfQskp69mi sQknrLd2ENfhKDOOuNhKx47d5APZhHYO7o8ih2FPbC2WA9g1EKSoyNx4YhqPCgTK5t9L Y7yyZkEkMBKZF2cOPtwUguZeyz+0G1pYUzbpH/MpE5BlVtjlX8hPmVvvbEvcsOBTb/x1 IbWOZ6JylzlCcpZoZqRtpffuQn992H3GlHF0JTYyLBEMq4lQUAN6UyhXuyjOOHPirmv0 mcpQ== X-Gm-Message-State: AMke39kfObWAQwDirjrrG3lpqAq4ZVXK07pgR3HKxOXhL7dt/KyhU34gMil5tUs7/nnoQrck X-Received: by 10.99.209.85 with SMTP id c21mr6504980pgj.147.1488589724087; Fri, 03 Mar 2017 17:08:44 -0800 (PST) Received: from isubrama-dev.amcc.com ([206.80.4.98]) by smtp.gmail.com with ESMTPSA id x21sm25197190pgf.15.2017.03.03.17.08.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 03 Mar 2017 17:08:43 -0800 (PST) From: Iyappan Subramanian To: davem@davemloft.net, netdev@vger.kernel.org, andrew@lunn.ch, f.fainelli@gmail.com, David.Laight@aculab.com Subject: [PATCH v3 net-next 3/6] drivers: net: xgene-v2: Add ethernet hardware configuration Date: Fri, 3 Mar 2017 17:09:29 -0800 Message-Id: <1488589773-28055-4-git-send-email-isubramanian@apm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1488589773-28055-1-git-send-email-isubramanian@apm.com> References: <1488589773-28055-1-git-send-email-isubramanian@apm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170303_170905_419448_DB9D0F91 X-CRM114-Status: GOOD ( 14.52 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kchudgar@apm.com, patches@apm.com, linux-arm-kernel@lists.infradead.org, Iyappan Subramanian MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds functions to configure ethernet hardware. Signed-off-by: Iyappan Subramanian Signed-off-by: Keyur Chudgar --- drivers/net/ethernet/apm/xgene-v2/enet.c | 71 ++++++++++++++++++++++++++++++++ drivers/net/ethernet/apm/xgene-v2/enet.h | 43 +++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 drivers/net/ethernet/apm/xgene-v2/enet.c create mode 100644 drivers/net/ethernet/apm/xgene-v2/enet.h diff --git a/drivers/net/ethernet/apm/xgene-v2/enet.c b/drivers/net/ethernet/apm/xgene-v2/enet.c new file mode 100644 index 0000000..b49edee --- /dev/null +++ b/drivers/net/ethernet/apm/xgene-v2/enet.c @@ -0,0 +1,71 @@ +/* + * Applied Micro X-Gene SoC Ethernet v2 Driver + * + * Copyright (c) 2017, Applied Micro Circuits Corporation + * Author(s): Iyappan Subramanian + * Keyur Chudgar + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include "main.h" + +void xge_wr_csr(struct xge_pdata *pdata, u32 offset, u32 val) +{ + void __iomem *addr = pdata->resources.base_addr + offset; + + iowrite32(val, addr); +} + +u32 xge_rd_csr(struct xge_pdata *pdata, u32 offset) +{ + void __iomem *addr = pdata->resources.base_addr + offset; + + return ioread32(addr); +} + +int xge_port_reset(struct net_device *ndev) +{ + struct xge_pdata *pdata = netdev_priv(ndev); + + xge_wr_csr(pdata, ENET_SRST, 0x3); + xge_wr_csr(pdata, ENET_SRST, 0x2); + xge_wr_csr(pdata, ENET_SRST, 0x0); + + xge_wr_csr(pdata, ENET_SHIM, DEVM_ARAUX_COH | DEVM_AWAUX_COH); + + return 0; +} + +static void xge_traffic_resume(struct net_device *ndev) +{ + struct xge_pdata *pdata = netdev_priv(ndev); + + xge_wr_csr(pdata, CFG_FORCE_LINK_STATUS_EN, 1); + xge_wr_csr(pdata, FORCE_LINK_STATUS, 1); + + xge_wr_csr(pdata, CFG_LINK_AGGR_RESUME, 1); + xge_wr_csr(pdata, RX_DV_GATE_REG, 1); +} + +int xge_port_init(struct net_device *ndev) +{ + struct xge_pdata *pdata = netdev_priv(ndev); + + pdata->phy_speed = SPEED_1000; + xge_mac_init(pdata); + xge_traffic_resume(ndev); + + return 0; +} diff --git a/drivers/net/ethernet/apm/xgene-v2/enet.h b/drivers/net/ethernet/apm/xgene-v2/enet.h new file mode 100644 index 0000000..40371cf --- /dev/null +++ b/drivers/net/ethernet/apm/xgene-v2/enet.h @@ -0,0 +1,43 @@ +/* + * Applied Micro X-Gene SoC Ethernet v2 Driver + * + * Copyright (c) 2017, Applied Micro Circuits Corporation + * Author(s): Iyappan Subramanian + * Keyur Chudgar + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __XGENE_ENET_V2_ENET_H__ +#define __XGENE_ENET_V2_ENET_H__ + +#define ENET_CLKEN 0xc008 +#define ENET_SRST 0xc000 +#define ENET_SHIM 0xc010 +#define CFG_MEM_RAM_SHUTDOWN 0xd070 +#define BLOCK_MEM_RDY 0xd074 + +#define DEVM_ARAUX_COH BIT(19) +#define DEVM_AWAUX_COH BIT(3) + +#define CFG_FORCE_LINK_STATUS_EN 0x229c +#define FORCE_LINK_STATUS 0x22a0 +#define CFG_LINK_AGGR_RESUME 0x27c8 +#define RX_DV_GATE_REG 0x2dfc + +void xge_wr_csr(struct xge_pdata *pdata, u32 offset, u32 val); +u32 xge_rd_csr(struct xge_pdata *pdata, u32 offset); +int xge_port_reset(struct net_device *ndev); + +#endif /* __XGENE_ENET_V2_ENET__H__ */