From patchwork Tue Jan 28 11:10:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1230297 X-Patchwork-Delegate: mario.six@gdsys.cc 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=85.214.62.61; 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=eorWZ1Bf; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 486P6w23ytz9sNx for ; Tue, 28 Jan 2020 22:10:48 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id A463381A02; Tue, 28 Jan 2020 12:10:43 +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="eorWZ1Bf"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7282E819B8; Tue, 28 Jan 2020 12:10:41 +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 EUR02-AM5-obe.outbound.protection.outlook.com (mail-am5eur02on0724.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe07::724]) (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 6134181844 for ; Tue, 28 Jan 2020 12:10: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=ROrd0DBp+JycdzCXWFgv6A5pn7nArDse3X7qOKkO0bvHogkCF3135e8en2VP3m+e3QUYpedUtWEr7BTd5QS4lGOtpjmOu7q4phRBYWk5n8Vfu/3/771WtOZf1HF9DvDXGxeRpSzAQHxzH6CcHuScG4jrSYoT++MR7E1Wjnh+r2cn7vrapXnYVDVwJdK79mT48D2ZrUH7HYYxdsQHZ+IjW4/m34mdBg6XBlgsf5dX/sIJS+5tbs5RcF3wwRs8t7KvF1K5FbOwZyrtm0bAKF8AC6TKlLsbZz+wG0+atrH9N7JT3uRpVDV2IkWYrosjKyLGfBejS4xubvZpnKgrIPWDmQ== 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=ByjqM9Vxxho+zwyjyLBtzPEt/kch+MTvatnCS2t2/SRGKmSwJlC7E7GKGG8hDzv05PsJeF/qX67OclOw0oXiU7707Wva+h4vFRWDDmVLEFkTLIcZZz0FZScV6LpaqASIMrwzLTJZd5c3Dw35RYdQp7m4LR4FwM+X+Xj4id6XFKCODDXMeBf8yZnRSGycNIsOBDzN533muk5kl8Weric5Yr1leo3mBfqPU1hXHhiIUxtpbaiMTp7ECAHDZy3m1KYz8m0FgAHGwFSfaG74jIUtuQzjOcdwmjJIoeoRx9mTJn8ipdSUJxYEA7wcj8PU84leQxMv1iI84s49QFM1CUqtcA== 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=eorWZ1Bf7TktKMx5WwKCcmAoFbf12aNHTPtypKnc4x/L9s3WQQtrQ3kM3tbsqEcT8JJ1bWYtUR421D64bepLO+VMMYs9G7Vduvl2CpcSBDoxzrAU/NQMJUU1TXk4pTpPepc4KwdNSxKQB6shwR0l/VR4ShGbgc7RgNRyxzCNOeA= Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (20.178.126.85) by VI1PR10MB3709.EURPRD10.PROD.OUTLOOK.COM (10.186.162.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2665.22; Tue, 28 Jan 2020 11:10:30 +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 11:10:30 +0000 Received: from prevas-ravi.prevas.se (81.216.59.226) by HE1PR0701CA0054.eurprd07.prod.outlook.com (2603:10a6:3:9e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2665.14 via Frontend Transport; Tue, 28 Jan 2020 11:10:29 +0000 From: Rasmus Villemoes To: "u-boot@lists.denx.de" Subject: [PATCH 1/2] gpio: mpc8xxx: don't modify gpdat when setting gpio as input Thread-Topic: [PATCH 1/2] gpio: mpc8xxx: don't modify gpdat when setting gpio as input Thread-Index: AQHV1cuN7B7xFq1gQUG5ecP2HYLisg== Date: Tue, 28 Jan 2020 11:10:30 +0000 Message-ID: <20200128111020.15136-2-rasmus.villemoes@prevas.dk> References: <20200128111020.15136-1-rasmus.villemoes@prevas.dk> In-Reply-To: <20200128111020.15136-1-rasmus.villemoes@prevas.dk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR0701CA0054.eurprd07.prod.outlook.com (2603:10a6:3:9e::22) 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: 416db937-9de1-45d1-3fde-08d7a3e2af9d x-ms-traffictypediagnostic: VI1PR10MB3709: 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)(346002)(136003)(366004)(39850400004)(376002)(396003)(199004)(189003)(26005)(54906003)(6506007)(66476007)(66946007)(71200400001)(44832011)(956004)(2616005)(2906002)(5660300002)(66446008)(64756008)(66556008)(6666004)(8676002)(4326008)(107886003)(8936002)(81166006)(81156014)(86362001)(16526019)(478600001)(8976002)(186003)(6512007)(36756003)(316002)(6486002)(6916009)(52116002)(1076003)(32563001); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR10MB3709; 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: flOab6zqZaU+3aAGR1wZkT71X8GfyQP2n/ZkHwTVpT9Wf8mtZ6O6naeelDfw6cP7KHU9ZQHJqRd/3qWh6ao/cxbkVTLQH0Kk4QlAByAW3vt7di+KKmqv5DtdRGq2PEcqOlSRc1iSLJQPKsvQn2/XdRfGY0W+rTty8xm2OsViTXLYvxv55675fQsKjiuWaIrtrGTyh5wd/JhqytBbVF8Pxs7L4jQ/bTb/w4YSesc8YleHceTOl7lzKy5k9nN7BZQcMBx3JRBvmBl4C7+cwqk9T4v3yXUPasngmepxnXFJ3alW+kcXH4E40BrLYR0lwA7GHwADB2Ri8NjVY3KrDZGQvEOBPUJRhTSg8NF9whQldZjIAWHIQ5/BhiefpH43ZrgKMDDHN4916adBIsIQ+LtuXzqajv+B7geYWCSbRGuc5z7QPTA6Gof2jPMdh9CuF//ATIZ9rTMf1HQIMe779wL1pWN+ObL1EHoGZRuVsqYoMts= x-ms-exchange-antispam-messagedata: uo4DjRMetdgyrQ+ym2WQlnH/CK6+sGKzJxSBZriEAvUqrntzLtFE/nqvdFLfJJIWTYVMyoThrHpjyUmy0qz0wmYT8kbH/KN/kbE3OcZeF/AKU12fg9535OVhsQTvUmKJK5I1IOhDguX12xCfoBb0Tw== MIME-Version: 1.0 X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: 416db937-9de1-45d1-3fde-08d7a3e2af9d X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Jan 2020 11:10:30.2528 (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: hRhnXrjPDtilqMZAP69m8uWcLuncVEaxz5wCzSQd3q4+jgoA1FCgtMQoTr1qG/T2bmEJAUi446bJwzRrpEuUnHGgMMX3UuBdkKei8GT2USY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB3709 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 , Mario Six 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; } From patchwork Tue Jan 28 11:10:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1230299 X-Patchwork-Delegate: mario.six@gdsys.cc 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=85.214.62.61; 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=WQT6t5Ck; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (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 486P7J1r0Sz9sP6 for ; Tue, 28 Jan 2020 22:11:08 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BC5F981AB0; Tue, 28 Jan 2020 12:10:52 +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="WQT6t5Ck"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 827D181889; Tue, 28 Jan 2020 12:10:44 +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 EUR02-AM5-obe.outbound.protection.outlook.com (mail-am5eur02on0701.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe07::701]) (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 9FB0781889 for ; Tue, 28 Jan 2020 12:10:40 +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=Cyojsoyh3Q1qgLOWVQBe7apDSR22WDaPomIgloeBFcnptFZElHE475zuLcJJg5v/yMp7Q9ipdk2OS0255jkO3z5/AXVozATbS3QaV2CMVoO8/jqS7eDxV2lQdYIFohg/Ty60YCfXRYfLkbMf+ZKFxuViRzsbQxB0JZP+EUu+gAuE5WGvMD8iPNjw5uk/za+4gh8Xx79pb/4Ki/yijqsZ+gmCRbi6LTDMWx3A8lze0ZiXxX+A/3O6Ong+mE11fELyyO3gnb0e9ogigDG918S1a/2d1qvXOLt6WCc7sDwjkqPLV1CYvuomqqj4gzCS2m+LfXRlN4L8cZKhU/pZV2Joig== 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=cN7eNnnBMX5DoUlTryeWxVVCdg4UE2xV1gdXROz/5rc=; b=RedovBihS7JRVcwt0i6ncoMh28KEL09+PGk58wR/QFqj5ujsCH6G6PrKOoXYyvB7gydCG80ji3cBAX6Ta66vPztSMMoNmtBPMay4bFbgwHePACN8czR5OokeKDEvqccPeZgwlxWNdLyHti3IoNK4XLRp5BZL+IbFW1ao8kPWBdu9+8ImGLyvcLPMVgLurEerHl8kgZVFuPrmiDxoCkw1jxY5ULl8GzBE+WRXYRHeXbUO/XC/IQkPYQwB2xpHInK1Zt0BrBQiOKI0+mpTWpQhwsWuiM0A4WXiOkJx4mztGBfBQRrdse5ISYDDmciVpfNf6BGdFmi0TZ8yo7AcJhns0Q== 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=cN7eNnnBMX5DoUlTryeWxVVCdg4UE2xV1gdXROz/5rc=; b=WQT6t5CknAfErKOHNpMxUazdGp49/OFHYI2sATxkNhiw7LL+gSApwOgp+oZNlI+5Q9nQECtMvJD7JWab+pO1UMYm2mT1u8Y05Hnj17cutYZwY2Wi8Q5QLBCueiy/sDB1Xu4w372iQ+eea4TGPMXjEJsmVIegmFf/b3nwx2ATPRo= Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (20.178.126.85) by VI1PR10MB3709.EURPRD10.PROD.OUTLOOK.COM (10.186.162.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2665.22; Tue, 28 Jan 2020 11:10:31 +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 11:10:31 +0000 Received: from prevas-ravi.prevas.se (81.216.59.226) by HE1PR0701CA0054.eurprd07.prod.outlook.com (2603:10a6:3:9e::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2665.14 via Frontend Transport; Tue, 28 Jan 2020 11:10:30 +0000 From: Rasmus Villemoes To: "u-boot@lists.denx.de" Subject: [PATCH 2/2] gpio: mpc8xxx: don't do RMW on gpdat register when setting value Thread-Topic: [PATCH 2/2] gpio: mpc8xxx: don't do RMW on gpdat register when setting value Thread-Index: AQHV1cuNkqygcsloEUCG7CuEYuPjRQ== Date: Tue, 28 Jan 2020 11:10:31 +0000 Message-ID: <20200128111020.15136-3-rasmus.villemoes@prevas.dk> References: <20200128111020.15136-1-rasmus.villemoes@prevas.dk> In-Reply-To: <20200128111020.15136-1-rasmus.villemoes@prevas.dk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR0701CA0054.eurprd07.prod.outlook.com (2603:10a6:3:9e::22) 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: 29db526a-da78-45e5-3efa-08d7a3e2b020 x-ms-traffictypediagnostic: VI1PR10MB3709: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8882; x-forefront-prvs: 029651C7A1 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(136003)(366004)(39850400004)(376002)(396003)(199004)(189003)(26005)(54906003)(6506007)(66476007)(66946007)(71200400001)(44832011)(956004)(2616005)(2906002)(5660300002)(66446008)(64756008)(66556008)(8676002)(4326008)(107886003)(8936002)(81166006)(81156014)(86362001)(16526019)(478600001)(8976002)(186003)(6512007)(36756003)(316002)(6486002)(6916009)(52116002)(1076003)(32563001); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR10MB3709; 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: em9XyWDos/ed9NbwMpC7cXnpO6PIEbKkE97lqdsgcZXeP6UWYhIHUVNLktSeymNikdsxdNtewPq/HXOk96BPitihmuHFywBDwM8AdU2mGDiABkEbj6yFNrY4O9nP6VOGubQYXK4yWhb/o8wS09zfF7ChWi/EiPoKGVnZpkD0wo+sC3WvqLhdklnixYuZKXsoA4/VXqMKASS1vDX9yxVEdVYNpgsAEJKesGoUglHpVcmfXeYO1F/8loZRlx/xMKn0uo73TWNkBeScbeetnnxtl4Xw3622YSsjUP/E5jkrK8SUuhhHhn3v/UkYNMUTh5NzuwREOp3sIxNPLDGJ/1jZwItsrqbPDE4cZN+VJsoTMZfpDbClD3GiXCooOCM15mFL+6tYkDova7dThVtGXDtwM//ptCdqDgoOoH/22QSMXznrRN90wvnejfphjCTkY/IUlt/Wqsv5hGLrnPaBmbfd5H1AUrpI1rwQWBKfMPT1m7k= x-ms-exchange-antispam-messagedata: q9lHB1q5l4RyGiH8b+HzeFMyZ0rYWQy7mVv/kOmhJsDnTJfciwCPkPOGxy4P1zLN9uMgmrBFPz0F0ruRnv9yNhEhSx9L2OrRbRzlDm0rg1GaXmidsgUYagRC+b/8WioE5QjbLk40gOIoY5Dbmo2r0w== MIME-Version: 1.0 X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: 29db526a-da78-45e5-3efa-08d7a3e2b020 X-MS-Exchange-CrossTenant-originalarrivaltime: 28 Jan 2020 11:10:31.0973 (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: kmaP3CKmXbweK6iZO8QZcWPlxfc7NLvVwbPzpst7YM3ONv03kWMZdqTbYL/p8sa+jSfqp7fB6Mg9kWPG3TZVX6n33W5EO7eZfwdBrNXoYgk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB3709 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 , Mario Six 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 The driver correctly handles reading back the value of an output gpio by reading from the shadow register for output, and from gpdat for inputs. Unfortunately, when setting the value of some gpio, we do a RMW cycle on the gpdat register without taking the shadow register into account, thus accidentally setting other output gpios (at least those whose value cannot be read back) to 0 at the same time. When changing a gpio from input to output, we still need to make sure it initially has the requested value. So, the procedure is - update the shadow register - compute the new gpdir register - write the bitwise and of the shadow and new gpdir register to gpdat - write the new gpdir register Signed-off-by: Rasmus Villemoes --- drivers/gpio/mpc8xxx_gpio.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/drivers/gpio/mpc8xxx_gpio.c b/drivers/gpio/mpc8xxx_gpio.c index 5438196fe0..c5be8e673b 100644 --- a/drivers/gpio/mpc8xxx_gpio.c +++ b/drivers/gpio/mpc8xxx_gpio.c @@ -57,20 +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_low(struct ccsr_gpio *base, u32 gpios) -{ - clrbits_be32(&base->gpdat, gpios); - /* GPDIR register 1 -> output */ - setbits_be32(&base->gpdir, gpios); -} - -static inline void mpc8xxx_gpio_set_high(struct ccsr_gpio *base, u32 gpios) -{ - setbits_be32(&base->gpdat, gpios); - /* GPDIR register 1 -> output */ - setbits_be32(&base->gpdir, gpios); -} - static inline int mpc8xxx_gpio_open_drain_val(struct ccsr_gpio *base, u32 mask) { return in_be32(&base->gpodr) & mask; @@ -104,14 +90,21 @@ static int mpc8xxx_gpio_direction_input(struct udevice *dev, uint gpio) static int mpc8xxx_gpio_set_value(struct udevice *dev, uint gpio, int value) { struct mpc8xxx_gpio_data *data = dev_get_priv(dev); + struct ccsr_gpio *base = data->base; + u32 mask = gpio_mask(gpio); + u32 gpdir; if (value) { - data->dat_shadow |= gpio_mask(gpio); - mpc8xxx_gpio_set_high(data->base, gpio_mask(gpio)); + data->dat_shadow |= mask; } else { - data->dat_shadow &= ~gpio_mask(gpio); - mpc8xxx_gpio_set_low(data->base, gpio_mask(gpio)); + data->dat_shadow &= ~mask; } + + gpdir = in_be32(&base->gpdir); + gpdir |= gpio_mask(gpio); + out_be32(&base->gpdat, gpdir & data->dat_shadow); + out_be32(&base->gpdir, gpdir); + return 0; }