From patchwork Tue Jun 25 04:15:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1121786 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="ip44OKj4"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="X1S/DACx"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45XtH74BRVz9s3C for ; Tue, 25 Jun 2019 14:20:03 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 39A57C21D72; Tue, 25 Jun 2019 04:18:06 +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 0DDEDC21D83; Tue, 25 Jun 2019 04:17:11 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 25F65C21C57; Tue, 25 Jun 2019 04:15:53 +0000 (UTC) Received: from esa5.hgst.iphmx.com (esa5.hgst.iphmx.com [216.71.153.144]) by lists.denx.de (Postfix) with ESMTPS id 455A5C21E08 for ; Tue, 25 Jun 2019 04:15:44 +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=1561436145; x=1592972145; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=9j4LqrmSSNgWbXTLL1y6sYzBNiXdQ2ueQ4/qMKCG1KY=; b=ip44OKj4tFKfOMdo9EXDj/owqo9ZQlEq3vYRpxLhQpzWBeuYuBWLXf6N eAEqBT9t/3Nipa6ovUpvqVEGZh1VYxg0SSsoE4nAu39sgCBfC9b3SRrxk ALOZhf7BH3DhWWAeD9SASVDeNDg8hZb1j8/BTM/PGySEjw+TT0svOs4Bt MABcuyNuG30IOkR/v5Q5aEWO4LsbI2rW7+HHqAB5bujcT4DFZP2ijTvds 1xZ5C8c9Ed7MmInYp+GMorpyOEMrokOU9AIp7OMy+/UUiqm83TB23gejj QZa5U/2drrhf5ju8JVfTmPPVxt83lOFp2Q01Q0OUufQmporoOlInggbNs A==; X-IronPort-AV: E=Sophos;i="5.63,413,1557158400"; d="scan'208";a="112660570" Received: from mail-bn3nam01lp2056.outbound.protection.outlook.com (HELO NAM01-BN3-obe.outbound.protection.outlook.com) ([104.47.33.56]) by ob1.hgst.iphmx.com with ESMTP; 25 Jun 2019 12:15:43 +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=9j4LqrmSSNgWbXTLL1y6sYzBNiXdQ2ueQ4/qMKCG1KY=; b=X1S/DACxvEnDMX2rcNtCporvjrbBql5uoJ7r3gqPBKo+hJ27D7QiWaqTxcXOazl0d3uHCnFG9lNe1k9Mlv+pDEIaxPxCz42+Z/UYA8UFVCxdwwEToJDyhn1Gi79lbRwpkyCUsOPUdjw1PeNiSqTTgiqW7Z4yBQdJyu8GKnW+Czs= Received: from MN2PR04MB6061.namprd04.prod.outlook.com (20.178.246.15) by MN2PR04MB6944.namprd04.prod.outlook.com (10.186.147.200) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2008.16; Tue, 25 Jun 2019 04:15:42 +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.2008.014; Tue, 25 Jun 2019 04:15:42 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Lukas Auer , Simon Glass Thread-Topic: [PATCH v8 9/9] net: macb: Fix check for little-endian system in gmac_configure_dma() Thread-Index: AQHVKwyndSW1qSMDe0qMmOgmL0lYiQ== Date: Tue, 25 Jun 2019 04:15:42 +0000 Message-ID: <20190625041429.29929-10-anup.patel@wdc.com> References: <20190625041429.29929-1-anup.patel@wdc.com> In-Reply-To: <20190625041429.29929-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: MAXPR0101CA0049.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:e::11) 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: da8d841b-ed70-4505-de5a-08d6f923c957 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:MN2PR04MB6944; x-ms-traffictypediagnostic: MN2PR04MB6944: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:216; x-forefront-prvs: 0079056367 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(376002)(136003)(396003)(366004)(39860400002)(199004)(189003)(476003)(7416002)(66476007)(71190400001)(66946007)(71200400001)(64756008)(66446008)(5660300002)(73956011)(2906002)(66556008)(1076003)(50226002)(36756003)(52116002)(66066001)(76176011)(99286004)(305945005)(7736002)(6506007)(386003)(102836004)(68736007)(8676002)(8936002)(81156014)(81166006)(86362001)(6486002)(4326008)(44832011)(6436002)(14454004)(2616005)(110136005)(26005)(256004)(25786009)(446003)(6116002)(3846002)(54906003)(53936002)(486006)(11346002)(478600001)(316002)(72206003)(6512007)(186003); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR04MB6944; H:MN2PR04MB6061.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 4/Ct/vmeUsdj734WXFvu4Ad8114K8UZWdh9L9pYRVS+3J0DWbRi3RI3WR8StEhg8XeVHjckKgGCaiQQFbOVEqbug1thVFx+FU/8mnDakNcnYPVOvROhPQhc5XoAGtYMSHCOFjPMTLiVLKeaNu1GKVjRxjmaHZoXZ6OGpe8qwyvm7UzP4cFU3Y6oZgITgQM471czROALKrXwi6pZn8Huq/pxbQJBTpUqWUP5XBB9BqJYNWrT+/go0lWPy4WGMyba0RtNYqpVCuxUu3i/uJ+41EeVJTTAqayxCUZ3zH4jUL2oVnPgHnVraPnlS8XNp/yJP/LBhA0f0IOCSlZJ74V0dk8kJlTpXtXV4wlkHNpZ8YNb4Ef7YBf7VzPHfliZCLdVTUgbqKgCiGiLydxiIfVMcrURLlVyvAs0jFDnOGodKdX4= MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: da8d841b-ed70-4505-de5a-08d6f923c957 X-MS-Exchange-CrossTenant-originalarrivaltime: 25 Jun 2019 04:15:42.1721 (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: MN2PR04MB6944 Cc: U-Boot Mailing List , Palmer Dabbelt , Joe Hershberger , Alistair Francis Subject: [U-Boot] [PATCH v8 9/9] net: macb: Fix check for little-endian system in gmac_configure_dma() 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" Instead of depending on CONFIG_SYS_LITTLE_ENDIAN, we check at runtime whether underlying system is little-endian or big-endian. This way we are not dependent on any U-Boot specific OR compiler specific macro to check system endianness. Signed-off-by: Anup Patel Reviewed-by: Bin Meng Reviewed-By: Ramon Fried --- drivers/net/macb.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/net/macb.c b/drivers/net/macb.c index 7fedb9ae0e..942d469572 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c @@ -85,6 +85,8 @@ struct macb_device { void *regs; void *regs1; + bool is_big_endian; + const struct macb_config*config; unsigned int rx_tail; @@ -739,11 +741,10 @@ static void gmac_configure_dma(struct macb_device *macb) dmacfg |= GEM_BIT(TXPBMS) | GEM_BF(RXBMS, -1L); dmacfg &= ~GEM_BIT(ENDIA_PKT); -#ifdef CONFIG_SYS_LITTLE_ENDIAN - dmacfg &= ~GEM_BIT(ENDIA_DESC); -#else + if (macb->is_big_endian) dmacfg |= GEM_BIT(ENDIA_DESC); /* CPU in big endian */ -#endif + else + dmacfg &= ~GEM_BIT(ENDIA_DESC); dmacfg &= ~GEM_BIT(ADDR64); gem_writel(macb, DMACFG, dmacfg); @@ -1230,6 +1231,9 @@ static int macb_eth_probe(struct udevice *dev) macb->regs = (void *)pdata->iobase; + macb->is_big_endian = (cpu_to_be32(0x12345678) == 0x12345678) ? + true : false; + macb->config = (struct macb_config *)dev_get_driver_data(dev); if (!macb->config) macb->config = &default_gem_config;