From patchwork Thu Jun 20 06:49:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1119215 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="CmX1ByYe"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="CSeMfFEr"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45TsvD5qCfz9s5c for ; Thu, 20 Jun 2019 16:52:24 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 1D266C21DE8; Thu, 20 Jun 2019 06:51:09 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 2D5E5C21D8E; Thu, 20 Jun 2019 06:50:11 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 03D32C21DAF; Thu, 20 Jun 2019 06:49:31 +0000 (UTC) Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) by lists.denx.de (Postfix) with ESMTPS id 54ABAC21D83 for ; Thu, 20 Jun 2019 06:49:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1561013371; x=1592549371; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=0kzLnAd18MURnm71LH8FwQFamXbJmhHYV7xYCXEz8Ys=; b=CmX1ByYeZHRSb/IB9wjAw4Pm7qNGGw1wWFsE5Ko9pWeXVB9k4L6Ju36k aOc4Rdw509KPmuCMI+t5UnDwOyD71AqmQykwJgbHN3oZsZhTC0jwcUl5s b2iXp/YegftsfsTr4g8ehYv1GKd+bIMrOzxLjtRcAUUTRmx/VduBdEKY0 PW0HDfF7JLvJvnPY7dfvAsrnmGdPpBdB3mRKzEtGbtGEUF+9o1AEESnPU vAWHMNLaRpdZLWUezx1+emyoSOOQAgBidIiYxatPaZfMOph6HfuziNNn8 pfzdLVnKVWQpkRXuQ1iNlQbZQeUvh2W5Ts7uaSuFAq6tdVJVxw5j/ZWZ/ Q==; X-IronPort-AV: E=Sophos;i="5.63,395,1557158400"; d="scan'208";a="115930699" Received: from mail-dm3nam05lp2058.outbound.protection.outlook.com (HELO NAM05-DM3-obe.outbound.protection.outlook.com) ([104.47.49.58]) by ob1.hgst.iphmx.com with ESMTP; 20 Jun 2019 14:49:28 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector2-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0kzLnAd18MURnm71LH8FwQFamXbJmhHYV7xYCXEz8Ys=; b=CSeMfFEreZwU4vo/bM4ty7SrvuQVb2OovcDDKK2NpgvTJXhllLIDCmtqfxfTuP8cp7c9DqdTin5AD4NuxN2qnOzGHg6DztukuRvEfbg4whGrgK58hsfDXiOoBz3cC8LLvs16SLn/gW3eXpwweVDSYmAAag5cvnpf9fsbUniWYto= Received: from MN2PR04MB6061.namprd04.prod.outlook.com (20.178.246.15) by MN2PR04MB5966.namprd04.prod.outlook.com (20.178.249.159) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1987.13; Thu, 20 Jun 2019 06:49:26 +0000 Received: from MN2PR04MB6061.namprd04.prod.outlook.com ([fe80::84da:b4e7:4612:48b]) by MN2PR04MB6061.namprd04.prod.outlook.com ([fe80::84da:b4e7:4612:48b%7]) with mapi id 15.20.1987.014; Thu, 20 Jun 2019 06:49:26 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Lukas Auer , Simon Glass Thread-Topic: [PATCH v5 6/8] net: macb: Extend MACB driver for SiFive Unleashed board Thread-Index: AQHVJzRN1uFlrVX26E2ASSp+zHkBKg== Date: Thu, 20 Jun 2019 06:49:26 +0000 Message-ID: <20190620064753.32391-7-anup.patel@wdc.com> References: <20190620064753.32391-1-anup.patel@wdc.com> In-Reply-To: <20190620064753.32391-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: TY1PR01CA0181.jpnprd01.prod.outlook.com (2603:1096:402::33) To MN2PR04MB6061.namprd04.prod.outlook.com (2603:10b6:208:d8::15) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Anup.Patel@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [129.253.179.161] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 766c1eb4-2ea8-4c81-d266-08d6f54b6f5e x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(5600148)(711020)(4605104)(1401327)(4618075)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(2017052603328)(7193020); SRVR:MN2PR04MB5966; x-ms-traffictypediagnostic: MN2PR04MB5966: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7219; x-forefront-prvs: 0074BBE012 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6029001)(376002)(346002)(396003)(366004)(136003)(39860400002)(189003)(199004)(7416002)(8676002)(3846002)(52116002)(6506007)(386003)(5660300002)(102836004)(66476007)(6436002)(478600001)(44832011)(4326008)(26005)(2906002)(73956011)(64756008)(6116002)(66556008)(36756003)(68736007)(186003)(76176011)(99286004)(486006)(25786009)(305945005)(86362001)(14454004)(71200400001)(6486002)(6512007)(110136005)(81156014)(316002)(66446008)(7736002)(446003)(66066001)(1076003)(2616005)(256004)(53936002)(50226002)(72206003)(54906003)(81166006)(8936002)(71190400001)(11346002)(476003)(66946007); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR04MB5966; H:MN2PR04MB6061.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: TSxZhp+IEm1eFiwRWVAPqeZUn5WF/4ZOXK5ej+LuZd3knYE7QjWVrfv2ICI4rlYc5d3xsXKoos9Q/xK1ShUHDoObm+7T9oa8waSq5VJYaC/Z0Pa/ga43exoPMQ+Aejq2qOlYJ+QadioXom0G0Yhshoo/FNV6SoMj+4hd87eNymMLZH99fuaTBMQj4QrlzRJvwPPb7VszEHIAoVAQTpQBLYBeG8aaD0Tmdb1XGjE/QHE1E3Pylua9K3bie+AYyAL6iH78aWZHwyFXs89LwMWS2P4U9XuHQlxamIrdSY4Iy8/D9zDVHftSh7PzIs3LLFHDTKK1vMIPmwLs5QO9GCPwB4DaOcNz/SAnsqQWG+ghnMrSevqDVYfcokNtAhIFDWl7Y2RNBnRcdwe3Eni6mzPECVH650eRkpNZObdKdgpLLik= MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 766c1eb4-2ea8-4c81-d266-08d6f54b6f5e X-MS-Exchange-CrossTenant-originalarrivaltime: 20 Jun 2019 06:49:26.3269 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Anup.Patel@wdc.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR04MB5966 Cc: U-Boot Mailing List , Palmer Dabbelt , Joe Hershberger , Alistair Francis Subject: [U-Boot] [PATCH v5 6/8] net: macb: Extend MACB driver for SiFive Unleashed board X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The SiFive MACB ethernet has a custom TX_CLK_SEL register to select different TX clock for 1000mbps vs 10/100mbps. This patch adds SiFive MACB compatible string and extends the MACB ethernet driver to change TX clock using TX_CLK_SEL register for SiFive MACB. Signed-off-by: Anup Patel --- drivers/net/macb.c | 53 +++++++++++++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/drivers/net/macb.c b/drivers/net/macb.c index c072f99d8f..6a29ee3064 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -83,6 +83,9 @@ struct macb_dma_desc { struct macb_device { void *regs; + void *regs_sifive_gemgxl; + + bool skip_dma_config; unsigned int dma_burst_length; unsigned int rx_tail; @@ -122,7 +125,9 @@ struct macb_device { }; struct macb_config { + bool skip_dma_config; unsigned int dma_burst_length; + bool has_sifive_gemgxl; }; #ifndef CONFIG_DM_ETH @@ -486,18 +491,11 @@ static int macb_phy_find(struct macb_device *macb, const char *name) int __weak macb_linkspd_cb(struct udevice *dev, unsigned int speed) { #ifdef CONFIG_CLK + struct macb_device *macb = dev_get_priv(dev); struct clk tx_clk; ulong rate; int ret; - /* - * "tx_clk" is an optional clock source for MACB. - * Ignore if it does not exist in DT. - */ - ret = clk_get_by_name(dev, "tx_clk", &tx_clk); - if (ret) - return 0; - switch (speed) { case _10BASET: rate = 2500000; /* 2.5 MHz */ @@ -513,6 +511,26 @@ int __weak macb_linkspd_cb(struct udevice *dev, unsigned int speed) return 0; } + if (macb->regs_sifive_gemgxl) { + /* + * SiFive GEMGXL TX clock operation mode: + * + * 0 = GMII mode. Use 125 MHz gemgxlclk from PRCI in TX logic + * and output clock on GMII output signal GTX_CLK + * 1 = MII mode. Use MII input signal TX_CLK in TX logic + */ + writel(rate != 125000000, macb->regs_sifive_gemgxl); + return 0; + } + + /* + * "tx_clk" is an optional clock source for MACB. + * Ignore if it does not exist in DT. + */ + ret = clk_get_by_name(dev, "tx_clk", &tx_clk); + if (ret) + return 0; + if (tx_clk.dev) { ret = clk_set_rate(&tx_clk, rate); if (ret) @@ -701,6 +719,9 @@ static void gmac_configure_dma(struct macb_device *macb) u32 buffer_size; u32 dmacfg; + if (macb->skip_dma_config) + return; + buffer_size = 128 / RX_BUFFER_MULTIPLE; dmacfg = gem_readl(macb, DMACFG) & ~GEM_BF(RXBS, -1L); dmacfg |= GEM_BF(RXBS, buffer_size); @@ -1178,6 +1199,7 @@ static int macb_eth_probe(struct udevice *dev) struct macb_device *macb = dev_get_priv(dev); const char *phy_mode; __maybe_unused int ret; + fdt_addr_t addr; phy_mode = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), "phy-mode", NULL); @@ -1194,6 +1216,7 @@ static int macb_eth_probe(struct udevice *dev) if (!macb_config) macb_config = &default_gem_config; + macb->skip_dma_config = macb_config->skip_dma_config; macb->dma_burst_length = macb_config->dma_burst_length; #ifdef CONFIG_CLK ret = macb_enable_clk(dev); @@ -1201,6 +1224,13 @@ static int macb_eth_probe(struct udevice *dev) return ret; #endif + if (macb_config->has_sifive_gemgxl) { + addr = dev_read_addr_index(dev, 1); + if (addr == FDT_ADDR_T_NONE) + return -ENODEV; + macb->regs_sifive_gemgxl = (void __iomem *)addr; + } + _macb_eth_initialize(macb); #if defined(CONFIG_CMD_MII) || defined(CONFIG_PHYLIB) @@ -1259,6 +1289,12 @@ static const struct macb_config sama5d4_config = { .dma_burst_length = 4, }; +static const struct macb_config sifive_config = { + .skip_dma_config = true, + .dma_burst_length = 0, + .has_sifive_gemgxl = true, +}; + static const struct udevice_id macb_eth_ids[] = { { .compatible = "cdns,macb" }, { .compatible = "cdns,at91sam9260-macb" }, @@ -1266,6 +1302,7 @@ static const struct udevice_id macb_eth_ids[] = { { .compatible = "atmel,sama5d3-gem" }, { .compatible = "atmel,sama5d4-gem", .data = (ulong)&sama5d4_config }, { .compatible = "cdns,zynq-gem" }, + { .compatible = "sifive,fu540-macb", .data = (ulong)&sifive_config }, { } };