From patchwork Tue Jan 28 12:04:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1230305 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.a=rsa-sha256 header.s=selector1 header.b=aeqzjRGZ; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 486QKK55wLz9sP3 for ; Tue, 28 Jan 2020 23:04:53 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 07C8881AE4; Tue, 28 Jan 2020 13:04:47 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.b="aeqzjRGZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0D381817F2; Tue, 28 Jan 2020 13:04:40 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: * X-Spam-Status: No, score=1.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, FORGED_SPF_HELO, SPF_HELO_PASS, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-am5eur03on0713.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe08::713]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C79A7817F2 for ; Tue, 28 Jan 2020 13:04:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rasmus.villemoes@prevas.dk ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KguUlUWg2IZXE9YQ5oT1igpdEehC4vyDWpfDVS6CbzuywyXnFthC1H0vbeefpKAo2l+SXXF/XcHU2Eo1bvobzODqgP1fWnFMNrKJpLq/ygEnonjV0Kj4qh4eqYiShaLPWexk/svXR251Ejgyd4h0FYoFBRMzQgjbnSZYsEGHmCZw8kjZMw2fS42en2ANQYDM+zFiC8QxhWvxUqPejjZwrbrCmBKJSwkKFABoPSUj1viMU073w+a+rUnSzfSZ7mNOhreMQsGCA5OPjiowa2fB9qIABamPxmsLEu+n0HytHsyis4nMg8vVdm9tUmtGKFGFPWreM6hqI0bk+o6Y7WvP2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4TD1aRjBit2oWwr3qv4zzfvk/WCgvJnKtFUlq/fC4yw=; b=ghvyLvzuoZUfu2HIDuvV3J/csg85dxhs+XCK7b+NeG0DtB2Dd9RTtuFrCFQLa+TNM/Co1xp8SUZWsSnsJ9dXhBMe1wtNgMythghq83hT/Tc7brMtViNnqOWKfQgtsEYwAuTV0O/v67HPXhb6mMUEpikJJg0mXcX3dHvlq0zZIlBEpj71/hUPq/qPiTKcGdsld5PXwhBVnSWT5/mn0vLgqaIkb6sVQyQvLnLG/a9ivjXUL2y+MvIKDwsGefCT4MSlgJlsrX6ZveymOEER4s2Zb+Kx1st/w6kVk2VBxBeLM7KpNEOscNtRAyp8geDjhzu5mlhdI+0HqM3NxoXBtM9niw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=prevas.dk; dmarc=pass action=none header.from=prevas.dk; dkim=pass header.d=prevas.dk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prevas.dk; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4TD1aRjBit2oWwr3qv4zzfvk/WCgvJnKtFUlq/fC4yw=; b=aeqzjRGZzkbTEIngfiLB7nlEktFs1Rk9q28n84Xh/RQzvt7eME8oJ4h8cUZMhb36TrYTxWub6YYUtP+DKiVTsmW4cWbMq54oyLq1EjuKUzwJq7+u0+ksCfiVs+SIMzsqAqsnzqSshoE0clPxptp4v32Z5YDhkDFAqo/bUYIbXhE= Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (20.178.126.85) by VI1PR10MB3295.EURPRD10.PROD.OUTLOOK.COM (52.133.247.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2665.23; Tue, 28 Jan 2020 12:04:33 +0000 Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::8175:5aa2:2870:766d]) by VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::8175:5aa2:2870:766d%6]) with mapi id 15.20.2665.026; Tue, 28 Jan 2020 12:04:33 +0000 Received: from prevas-ravi.prevas.se (81.216.59.226) by HE1PR0202CA0024.eurprd02.prod.outlook.com (2603:10a6:3:8c::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2665.21 via Frontend Transport; Tue, 28 Jan 2020 12:04:32 +0000 From: Rasmus Villemoes To: "u-boot@lists.denx.de" Subject: [PATCH resend 1/2] gpio: mpc8xxx: don't modify gpdat when setting gpio as input Thread-Topic: [PATCH resend 1/2] gpio: mpc8xxx: don't modify gpdat when setting gpio as input Thread-Index: AQHV1dMaChFFQ1lws0K8rHXh3pXETQ== Date: Tue, 28 Jan 2020 12:04:33 +0000 Message-ID: <20200128120423.16667-2-rasmus.villemoes@prevas.dk> References: <20200128120423.16667-1-rasmus.villemoes@prevas.dk> In-Reply-To: <20200128120423.16667-1-rasmus.villemoes@prevas.dk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR0202CA0024.eurprd02.prod.outlook.com (2603:10a6:3:8c::34) To VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:e1::21) x-mailer: git-send-email 2.23.0 authentication-results: spf=none (sender IP is ) smtp.mailfrom=rasmus.villemoes@prevas.dk; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [81.216.59.226] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 9fed5e41-dc5c-4498-848e-08d7a3ea3cc4 x-ms-traffictypediagnostic: VI1PR10MB3295: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:6790; x-forefront-prvs: 029651C7A1 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(366004)(199004)(189003)(8676002)(16526019)(66556008)(8976002)(81166006)(5660300002)(36756003)(26005)(6512007)(66946007)(186003)(66476007)(8936002)(1076003)(498600001)(66446008)(86362001)(64756008)(107886003)(956004)(52116002)(6916009)(2616005)(44832011)(81156014)(71200400001)(54906003)(6506007)(2906002)(4326008)(6486002)(32563001); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR10MB3295; H:VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; received-spf: None (protection.outlook.com: prevas.dk does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: wSe3BHxRz4kUJ8p1214OCjhsS1law/9zZjLdChSgRkVaNgucSG4e74oHakAZZZY/shI+WDJFh/w8ccRfvUO3qTjo9eixzlFXVDsfcOsHHSsVGM8T+d7vHVdOSSUzqc9L8mwKH+ZFPsxKFVRcApkQnI9MxGH+NCaLIGomTf/+rxMmCiex2cSOc1KwMoAL7AHg5X9WYt5DFBM7BLoG+r8M0bj3KXGNoZyAw8nrjDm6YsXWuhFmqMc2eS7RFkaq+fMlaMbu6YjVcCPyu82hfVHTkE7G0XD3vpIuWGXy/mUw/fAiU4OFYK/FAci+79ERy3JxBY1/k4uG8h88mbpsvFql103VCJD90fxzK0aMzL5gdjx9LCzZfP47VU0adG0moUPxbIUW+m5vAX2pZeaXKY81KxgRzGMBU6/iRg8vHaQlxsILIZ1kb6o+lxL0wUMnSdUSK5P1tMzKeV8TWFUIS5qX7CpCs3G3D8QG2sfk7VJwBH4= x-ms-exchange-antispam-messagedata: KipvrnfGuRSoEdBCx5GEhzU51i4moQoL3x/SdAJHxnHY0mRFhbewr7YJ1TtX+tytTOKSD1OsXz1Z2vNeaH/AlaVzhVOjFAhyHLkoBXgur8JNXR22fbuQNgaW08t4CpWz+QdtEmQjbqhtGm3tfvkcGg== MIME-Version: 1.0 X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: 9fed5e41-dc5c-4498-848e-08d7a3ea3cc4 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Jan 2020 12:04:33.5130 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: JiXRnX+gz8cgh6IkhkDE8RFqzojawnG2zqLs7LnRkjfOY1UDYtiUq/L2+mg4Ze0tS8l/8kZk32ZCai0EBpChWJLkxIDUBQLy4x40NYyWH7g= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB3295 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marek Vasut Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean Since some chips don't support reading back the value of output gpios from the gpdat register, we should not do a RMW cycle (i.e., the clrbits_be32) on the gpdat register when setting a gpio as input, as that might accidentally change the value of some other (still configured as output) gpio. The extra indirection through mpc8xxx_gpio_set_in() does not help readability, so just fold the gpdir update into mpc8xxx_gpio_direction_input(). Signed-off-by: Rasmus Villemoes --- drivers/gpio/mpc8xxx_gpio.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/drivers/gpio/mpc8xxx_gpio.c b/drivers/gpio/mpc8xxx_gpio.c index 9964d69035..5438196fe0 100644 --- a/drivers/gpio/mpc8xxx_gpio.c +++ b/drivers/gpio/mpc8xxx_gpio.c @@ -57,13 +57,6 @@ static inline u32 mpc8xxx_gpio_get_dir(struct ccsr_gpio *base, u32 mask) return in_be32(&base->gpdir) & mask; } -static inline void mpc8xxx_gpio_set_in(struct ccsr_gpio *base, u32 gpios) -{ - clrbits_be32(&base->gpdat, gpios); - /* GPDIR register 0 -> input */ - clrbits_be32(&base->gpdir, gpios); -} - static inline void mpc8xxx_gpio_set_low(struct ccsr_gpio *base, u32 gpios) { clrbits_be32(&base->gpdat, gpios); @@ -100,8 +93,11 @@ static inline void mpc8xxx_gpio_open_drain_off(struct ccsr_gpio *base, static int mpc8xxx_gpio_direction_input(struct udevice *dev, uint gpio) { struct mpc8xxx_gpio_data *data = dev_get_priv(dev); + u32 mask = gpio_mask(gpio); + + /* GPDIR register 0 -> input */ + clrbits_be32(&data->base->gpdir, mask); - mpc8xxx_gpio_set_in(data->base, gpio_mask(gpio)); return 0; }