From patchwork Mon Jan 6 14:09:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1218172 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.b="mz7+16CA"; 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 47ry8C1yGMz9sQp for ; Tue, 7 Jan 2020 01:10:19 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 91FFA8171E; Mon, 6 Jan 2020 15:09:57 +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="mz7+16CA"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A77E38171B; Mon, 6 Jan 2020 15:09:53 +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.8 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 EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04on071d.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0d::71d]) (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 B003281708 for ; Mon, 6 Jan 2020 15:09:48 +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=VXDS7vN+mI3ZqBHfJkaaNBv+WB9hz0RiS0wa30++A5DYdfvgFqSFlJSqgR8jMKAieozMLvJcyyNKy4PStivMArTskFEkYc0Lj9z1WBIOE1lkhKPL0ST1u04OokoMAK+QSSV/q/zioVs82fe8kQSCRCl+Ou4fxOi0WiEgEHuyHIOPuZvrE7/2X+fIGz7UPl2XCHOOxU1zNGzXajL/3QZXaEIjs+RYSuT4m8lZS8Y9EsjQkVNj8+gXbC2FHfpoh9zjmhL1AgbBLZAFu8e71OjlIufTxrD8fywHqA9Ds2Kr8jKtu4P9Q9zjs44XsPOrdIb/a5mRqvQhDpkXhiNWIU02Hg== 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=v6W+DY/HhOERuSgWmQx+EL62aFPii9qgjrOX+e95cNM=; b=Ujb19JtTsSHcC8EkjZ+vil+ejINkIgskrsTKZWhpSG9sEqTxU6WKVn9WkrHWfIRArRxeu1ixi1TR8ItGntTKWGwC17OTZMPXg7vtFXLJ5bRSU2+psLm0xfrU8agDXRfDL6bV7e/C7tlv8MlW33Vio+ya1OEBHe2YVRKOmliyJQDor9D5AAcx97TE4qDtWHkhvtgdVV2eGvVdaqdlwTMB5qbRPk4aZ55xPiXoSV0FvjM8EI8QeRN8ia4cmur9zJ59jv/+6tgFh4uRG65ZA4VMq6TYKB44e0YF7UuHMBYYGpRZzCZF9uGtpIembJUByc75SmyyTX0RRic0piaQ7ycGOA== 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=v6W+DY/HhOERuSgWmQx+EL62aFPii9qgjrOX+e95cNM=; b=mz7+16CAw71xHTJTmEtrBW3mXWMWRwETl78o4Mh5Qa5DNzSt6fqaeQhrOxq/kOtNNCH867fzDsbBmymNmfoPwEfp51i4zwHnUWbhJFWgmktpvpNmNnymGzhRPn7QOz3DrT3VffbQrHs1ROFfapqXjDn+yQtJwAhQHd6k8XeZSlM= Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (20.178.126.85) by VI1PR10MB1726.EURPRD10.PROD.OUTLOOK.COM (10.165.194.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.13; Mon, 6 Jan 2020 14:09:46 +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.2602.015; Mon, 6 Jan 2020 14:09:46 +0000 Received: from prevas-ravi.prevas.se (81.216.59.226) by HE1P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.12 via Frontend Transport; Mon, 6 Jan 2020 14:09:45 +0000 From: Rasmus Villemoes To: "u-boot@lists.denx.de" Subject: [PATCH 1/4] gazerbeam: add clocks property to SPI node Thread-Topic: [PATCH 1/4] gazerbeam: add clocks property to SPI node Thread-Index: AQHVxJrzARQTqsyCWk2Bynauq6+qFg== Date: Mon, 6 Jan 2020 14:09:46 +0000 Message-ID: <20200106140931.1136-2-rasmus.villemoes@prevas.dk> References: <20200106140931.1136-1-rasmus.villemoes@prevas.dk> In-Reply-To: <20200106140931.1136-1-rasmus.villemoes@prevas.dk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::26) 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: db35a585-7fad-40e0-93ef-08d792b215b5 x-ms-traffictypediagnostic: VI1PR10MB1726: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1079; x-forefront-prvs: 0274272F87 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(346002)(136003)(366004)(396003)(376002)(39850400004)(199004)(189003)(64756008)(66446008)(66946007)(52116002)(66476007)(66556008)(6512007)(107886003)(16526019)(26005)(6506007)(4326008)(186003)(478600001)(54906003)(8676002)(316002)(71200400001)(6916009)(5660300002)(81166006)(81156014)(2906002)(8976002)(4744005)(6486002)(2616005)(956004)(36756003)(44832011)(1076003)(8936002)(86362001); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR10MB1726; 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: 8EwNpoqnCvB+cfKeFdO3SdKCJh8t79N5zIvSkDsVmBXBnRucX78yvF2LfG1WHiKoXTcPitAq/Vx8Hq23PglFyQgwwauKSnaHf2BgrbCUel36bdfUITHKDos434AKUXBDGkAr42l0iSJL+NkQaAc1T7iHfqKBqstyuL3bMw0dC4JN5fP4YuqkDUlVkcLHYOu4XPVpcCywISyGot/+XDP0etx6u3AvNuJabS67woFvVrGelf0RI6d3plTcm5N1sqGkjJsPIZ9ZP4jH4EXm1wa7OtpG5LBAEk/HCdmlSYUBPhFKFgw4Oxg6woeCxipr5xMQ+1BZYUkWjBu5fZmElHXmQKQoU/5diXH9IRpy9yMwos/aNQTCaT3uVWtnVTwHHjDBT2zcgkTsMBTFtqaM27k8AUyH+5dTz4wLuGvpZIyEw1tItsRqJZuBcc2nSb0p0fke MIME-Version: 1.0 X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: db35a585-7fad-40e0-93ef-08d792b215b5 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jan 2020 14:09:46.6217 (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: weCZVXfqMg5ryBIWxcd5X3zQPeLGEYEsQ/z6Q/GoFZs6FbBBpVetWyGn8Gj/bB+aET+L56Gv+5D7E4oXkBYpMRR/xDNAXpTcC+5XkRI7UL8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB1726 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: =?iso-8859-1?q?Klaus_Henning_S=F8rensen?= 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 Prepare for supporting setting different speeds in mpc8xxx_spi.c. Signed-off-by: Rasmus Villemoes --- arch/powerpc/dts/gdsys/mpc8308.dtsi | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/powerpc/dts/gdsys/mpc8308.dtsi b/arch/powerpc/dts/gdsys/mpc8308.dtsi index 23e7403d91..1a319e2328 100644 --- a/arch/powerpc/dts/gdsys/mpc8308.dtsi +++ b/arch/powerpc/dts/gdsys/mpc8308.dtsi @@ -17,6 +17,7 @@ /dts-v1/; #include +#include / { compatible = "fsl,mpc8308rdb"; @@ -50,6 +51,11 @@ }; }; + socclocks: clocks { + compatible = "fsl,mpc8308-clk"; + #clock-cells = <1>; + }; + board_lbc: localbus@e0005000 { #address-cells = <2>; #size-cells = <1>; @@ -173,6 +179,7 @@ reg = <0x7000 0x1000>; interrupts = <16 0x8>; interrupt-parent = <&ipic>; + clocks = <&socclocks MPC83XX_CLK_CSB>; mode = "cpu"; }; From patchwork Mon Jan 6 14:09:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1218171 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.b="TsPKOe57"; 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) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47ry873xHXz9sQp for ; Tue, 7 Jan 2020 01:10:15 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 69EFF81717; Mon, 6 Jan 2020 15:09:55 +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="TsPKOe57"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1BF3181717; Mon, 6 Jan 2020 15:09:53 +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.8 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 EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2070a.outbound.protection.outlook.com [IPv6:2a01:111:f400:7e1a::70a]) (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 415998170A for ; Mon, 6 Jan 2020 15:09:48 +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=RepUlDzAoKKX70HkrkDOr5OPwXsMvUlz8QpURKQsD3cb/t5OgVWgm6QVfBoQ+9Nohq0Zi5gh6lq3TpdzcRf8LKUJPjfl7CBMjfYgVoqRXhUtuEfuct/du3W0qDPRYe0e77ba10hb3K227mC67S4+ZSjeTd/pTQjAITPFJKoO6fcpHEJ99HACaUcoRnnewchhTsVg42LIcK1OW6rTw3ypiz7hPDOqSohtPbd2Yjjh6967Vy90PADg3n6OJIprbqbFzN/5n88BkV55FFNyco2+xhqqjV5Mx8orTXNiQPvVHplK0a+DV00GaKX2XJfCy0jpIdnIV5coVoIktbqu7AO1lg== 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=kGqeJ4Ssw64f8IMeHvv3LwyJrEiwxIVLv5qHp6V4kUg=; b=bwrzDkY7DOsdmM5NE1O+cFzaJvPqdaF/jx1fIBBii9RvBSZYxGAsrVXuupa/3+xUwDuydrmrMGk13oinTXwk4muP4exdCjpNy3I2PE94RQL5mfEjcFKdOxn1mP0qxiYCESJAIIOXOn1e0gkR5lDIRyhTpl8wE305pby0ah9Mhtj61nN0HaOxGd70Oyu1yi4ZSba81rM8S+XHRDqBM9U+q8ef8MVaSH1xeO6vTctQYW8lxScG9B12hJgApnOQxHrrWblEJy9CoCbypbCSkhYYPEsjWQRJP0R/APKzjC5Au+Cvd/GqUsWbee2gYDokzwChumqtg5Xxio5dj6RCXxdWLw== 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=kGqeJ4Ssw64f8IMeHvv3LwyJrEiwxIVLv5qHp6V4kUg=; b=TsPKOe574nKVZ2zF0WuQ79l4kT5hjcrSJxqMgGz0jsOSEZAwE5NJMmg2HltBP2mP7CsVxWrQ6LbF61Q2K0A6xEp8zkeIzhXo0tQZJcO3TPqPEWXhsdaQbYAYlSLQQiU2xZThym4d1J02GLIps8mj+Xr13jCYnvwvV6JauDNSSLY= Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (20.178.126.85) by VI1PR10MB2144.EURPRD10.PROD.OUTLOOK.COM (20.177.62.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.15; Mon, 6 Jan 2020 14:09:47 +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.2602.015; Mon, 6 Jan 2020 14:09:47 +0000 Received: from prevas-ravi.prevas.se (81.216.59.226) by HE1P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.12 via Frontend Transport; Mon, 6 Jan 2020 14:09:47 +0000 From: Rasmus Villemoes To: "u-boot@lists.denx.de" Subject: [PATCH 2/4] mpc8xxx_spi: put max_cs to use Thread-Topic: [PATCH 2/4] mpc8xxx_spi: put max_cs to use Thread-Index: AQHVxJr0Br7leptVgkKYNtF/lRXIHw== Date: Mon, 6 Jan 2020 14:09:47 +0000 Message-ID: <20200106140931.1136-3-rasmus.villemoes@prevas.dk> References: <20200106140931.1136-1-rasmus.villemoes@prevas.dk> In-Reply-To: <20200106140931.1136-1-rasmus.villemoes@prevas.dk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::26) 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: 938a064f-7f9a-448f-1ddf-08d792b2166c x-ms-traffictypediagnostic: VI1PR10MB2144: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:418; x-forefront-prvs: 0274272F87 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(346002)(136003)(366004)(39850400004)(376002)(189003)(199004)(66476007)(8676002)(64756008)(66446008)(66556008)(66946007)(54906003)(86362001)(6486002)(81166006)(81156014)(16526019)(52116002)(186003)(26005)(6506007)(316002)(4326008)(36756003)(5660300002)(71200400001)(2906002)(44832011)(6916009)(1076003)(2616005)(6512007)(107886003)(8976002)(8936002)(956004)(478600001); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR10MB2144; H:VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: WUt6wd0EZ9KVYv7GYb4FouR/4TrgBDJ9gdZ2VxYxlQy9kobnx3yyPayAhsVQ0NyNuVVff/ijP1QkqpLiMuR8rB3ZOzfLgAQPmHGbh/YAbdg6EeoPjl0/b5WS65A2kqmVO4w6PAmnBZpG43QnnUJU11fYKr4tMFNwYftOYuWYVbhWTMIZHWRGo6AnkZ5AFEgrUqjODGkMeLIxKk5V2yhmkugYwKOJR46sfuwheobnNk4B8csLrbonYladeyJFOMqNXtzavBDDWClHdo9UQuoedZPcLX42UGWAe4wX3MEKDVXzbvY9jjD/w3Mu5VQZTReMGGAVyj4hhfxkAonI2cCnQLlH4g4rti5FY8ZIH7StAHItLfw8y2WDwyp6RVXocmQHb8ypTBcvLVAe9eEmeDFW8TbNg+HAY6BDy/czyhkSXuiDmDOJFcjz3q3/xcuONtm0 MIME-Version: 1.0 X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: 938a064f-7f9a-448f-1ddf-08d792b2166c X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jan 2020 14:09:47.7091 (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: epXne2IBva1T6taLzfuPlh4D0ZxKIEtUYHoBX0Lwg/orhI2Tig1YXpJ7m0cnsDNKk3m4xoaU964pA1CTN4he05JMTzFaT3Onhz8uJRCt2HA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB2144 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: =?iso-8859-1?q?Klaus_Henning_S=F8rensen?= 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 Currently, max_cs is write-only; it's just set in mpc8xxx_spi_ofdata_to_platdata and not otherwise used. My mpc8309 was always resetting during an "sf probe 0". It turns out dm_gpio_set_dir_flags() was being called with garbage, since nothing had initialized priv->gpios[0] - our device tree used "cs-gpios" rather than "gpios", so gpio_request_list_by_name() had returned 0. That would have been a lot easier to figure out if the chip select index was sanity checked, so rename max_cs to cs_count, and reject a xfer with a too large cs index. Signed-off-by: Rasmus Villemoes --- drivers/spi/mpc8xxx_spi.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/spi/mpc8xxx_spi.c b/drivers/spi/mpc8xxx_spi.c index 1c7bf10f91..ac4d0a9bae 100644 --- a/drivers/spi/mpc8xxx_spi.c +++ b/drivers/spi/mpc8xxx_spi.c @@ -35,7 +35,7 @@ enum { struct mpc8xxx_priv { spi8xxx_t *spi; struct gpio_desc gpios[16]; - int max_cs; + int cs_count; }; static inline u32 to_prescale_mod(u32 val) @@ -74,7 +74,7 @@ static int mpc8xxx_spi_ofdata_to_platdata(struct udevice *dev) if (ret < 0) return -EINVAL; - priv->max_cs = ret; + priv->cs_count = ret; return 0; } @@ -131,6 +131,11 @@ static int mpc8xxx_spi_xfer(struct udevice *dev, uint bitlen, debug("%s: slave %s:%u dout %08X din %08X bitlen %u\n", __func__, bus->name, platdata->cs, *(uint *)dout, *(uint *)din, bitlen); + if (platdata->cs >= priv->cs_count) { + dev_err(dev, "chip select index %d too large (cs_count=%d)\n", + platdata->cs, priv->cs_count); + return -EINVAL; + } if (flags & SPI_XFER_BEGIN) mpc8xxx_spi_cs_activate(dev); From patchwork Mon Jan 6 14:09:49 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1218173 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.b="gogWPE+b"; 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 47ry8P2n1vz9sQp for ; Tue, 7 Jan 2020 01:10:29 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8BF208172E; Mon, 6 Jan 2020 15:09:59 +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="gogWPE+b"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BC92181720; Mon, 6 Jan 2020 15:09:55 +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.8 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-am5eur02on0714.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe07::714]) (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 D41B180507 for ; Mon, 6 Jan 2020 15:09:51 +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=EDu8B85OjZ6V41MxJ8HhdQUGXGFrsEmKJKQi8Sx0/Bl90V4dtD1Vw+iOfXF1Vw9jwCR7zOKNTg+sPcpHFA6sDN4w2rLWpO2WJTKQd/1KJr47Br/EkR2p+0C0uL5TA9zmublcceIiHg1SpWCX0xGnpFfEXNw4gBBxfSJfMYqsbBQz6yo40OK75V/p7DQHvp+rWhf4f0ybTCYNf+14F3cx/g2JYXetU3sxSWVaD/uv8uu0WrTfMIMlV7AClix/3o5o9lzh8GnvlNyeKqN+6cxzqTn3gEqVHR2nE9VU+5cnLEF8xrUTgy46uXutpjLeEgztjOZJ5jn5OpYcRX1BgNA/Mw== 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=UxOZ/ERe2VzH6I4Aihi73ED+Ajg5+YnsDneTSobbpr0=; b=e1p22RnfYqCxo7JPrKBaEU+ytq02BCxbXP4zMhSrRJUNOkqX4aeOM+E7E4OiOia8pphqh/sfEXgk5YMMvqimvmWKenbUd1f8w3M3V9nBehci0/EegUizoE1ThpgVpTBdTO43FhrbD7UTcawRQ0d/tmvD36WhBFnYetM9SJh24s5SuxBAHjUJ7S74PcHemfjyNF8eNDs2wYybj4leBUu24W0uT1sVKQKpAtf88HvaO1kDuEqzrytqELptmWXU6HT28bMSLyb9JA2nwZETiWATjgVuec4QbdbcQDDmZFPBqs52FSY5Y/DDsCi7EuUEY+9RI4It7IIoJeLdsxmp0/F1cA== 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=UxOZ/ERe2VzH6I4Aihi73ED+Ajg5+YnsDneTSobbpr0=; b=gogWPE+bjrGaHUj7aSunjXD/ugx3eGc4mXEIkG642MI3OQPJynrcJFDmhs4uFPpJK5xNp3gctKUqv5I0zV9zoH4oal8PN9izWU9WW6pcgjwmq5PLZi1xQCcnDfFYCuBWNlyeyqQ54RAQ72dBFEM/M+IvSlvsxrrINkJsp9bTLB0= Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (20.178.126.85) by VI1PR10MB2144.EURPRD10.PROD.OUTLOOK.COM (20.177.62.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.15; Mon, 6 Jan 2020 14:09:49 +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.2602.015; Mon, 6 Jan 2020 14:09:49 +0000 Received: from prevas-ravi.prevas.se (81.216.59.226) by HE1P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.12 via Frontend Transport; Mon, 6 Jan 2020 14:09:47 +0000 From: Rasmus Villemoes To: "u-boot@lists.denx.de" Subject: [PATCH 3/4] mpc8xxx_spi: always use 8-bit characters, don't read or write garbage Thread-Topic: [PATCH 3/4] mpc8xxx_spi: always use 8-bit characters, don't read or write garbage Thread-Index: AQHVxJr1OOXY8IKdokq3UmSevpnFwQ== Date: Mon, 6 Jan 2020 14:09:49 +0000 Message-ID: <20200106140931.1136-4-rasmus.villemoes@prevas.dk> References: <20200106140931.1136-1-rasmus.villemoes@prevas.dk> In-Reply-To: <20200106140931.1136-1-rasmus.villemoes@prevas.dk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::26) 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: aca92252-d16b-4199-7b3c-08d792b216f9 x-ms-traffictypediagnostic: VI1PR10MB2144: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:901; x-forefront-prvs: 0274272F87 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(346002)(136003)(366004)(39850400004)(376002)(189003)(199004)(66476007)(8676002)(64756008)(66446008)(66556008)(66946007)(54906003)(86362001)(6486002)(81166006)(81156014)(16526019)(52116002)(186003)(26005)(6506007)(316002)(4326008)(36756003)(5660300002)(71200400001)(2906002)(44832011)(6916009)(1076003)(66574012)(2616005)(6512007)(107886003)(8976002)(8936002)(956004)(478600001); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR10MB2144; H:VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: Qfofj8esRwbJEQJVre7G2waQ2szqOc3YZhYxQykpEwWfzikYcDZHhi++t41ROPaF6R20e3FkSENpFZiRDaI56QJB0j+ZdxVj/RRkFSRTfBvwI+QocuFDJymf5dLW+Mffl0kUI0oQSdyfThJBZhYIp5Yf5JmhqWK82kdUKeskOASWos0z5fKWNwvwNcxhQE65EwYoUp5Nar9IbPsPT1tBOaMsBS/x3cnuYxvvFGdgCET+ra+Ls0CnFyEv4L0/89nU4U79Y8V+B0tc0nrx+9rVMpwV6J0tL4CHjyxjdBE52TPSqh7VTiMHELxJbaARwfLTTwFasbQ8qQp7QqWtP2zNeUTEKbk/SACOb+QjUsfyUk8m6ODNdju+bZeZgX2dYgShXadansbMXXft3tGGjZ5wTOcLf4Ddzo0afVXsy6gO3MP5WyWEoHsTdMQOV6As96+6 Content-ID: MIME-Version: 1.0 X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: aca92252-d16b-4199-7b3c-08d792b216f9 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jan 2020 14:09:49.4090 (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: iv0ZwsGZPOyq1hqYYw6Rz74WnprUaPgmdDXvmqSvZXkuoiJm/UF7/ljK+g4GrOdx0I+SurbW69LQzZyfdLq2+wZCB6ED64mC1EPrfWiGv8k= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB2144 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: =?utf-8?q?Klaus_Henning_S=C3=B8rensen?= 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 There are a few problems with the current driver. First, it unconditionally reads from dout/writes to din whether or not those pointers are NULL. So for example a simple "sf probe" ends up writing four bytes at address 0: => md.l 0x0 8 00000000: 45454545 45454545 05050505 05050505 EEEEEEEE........ 00000010: 00000000 00000000 07070707 07070707 ................ => sf probe 0 mpc8xxx_spi_xfer: slave spi@7000:0 dout 0FB53618 din 00000000 bitlen 8 mpc8xxx_spi_xfer: slave spi@7000:0 dout 00000000 din 0FB536B8 bitlen 48 SF: Detected s25sl032p with page size 256 Bytes, erase size 64 KiB, total 4 MiB => md.l 0x0 8 00000000: ff000000 45454545 05050505 05050505 ....EEEE........ 00000010: 00000000 00000000 07070707 07070707 ................ (here I've change the first debug statement to a printf, and made it print the din/dout pointers rather than the uints they point at). Second, as we can also see above, it always writes a full 32 bits, even if a smaller amount was requested. So for example => mw.l $loadaddr 0xaabbccdd 8 => md.l $loadaddr 8 02000000: aabbccdd aabbccdd aabbccdd aabbccdd ................ 02000010: aabbccdd aabbccdd aabbccdd aabbccdd ................ => sf read $loadaddr 0x400 6 device 0 offset 0x400, size 0x6 mpc8xxx_spi_xfer: slave spi@7000:0 dout 0FB536E8 din 00000000 bitlen 40 mpc8xxx_spi_xfer: slave spi@7000:0 dout 00000000 din 02000000 bitlen 48 SF: 6 bytes @ 0x400 Read: OK => sf read 0x02000010 0x400 8 device 0 offset 0x400, size 0x8 mpc8xxx_spi_xfer: slave spi@7000:0 dout 0FB53848 din 00000000 bitlen 40 mpc8xxx_spi_xfer: slave spi@7000:0 dout 00000000 din 02000010 bitlen 64 SF: 8 bytes @ 0x400 Read: OK => md.l $loadaddr 8 02000000: 45454545 45450000 aabbccdd aabbccdd EEEEEE.......... 02000010: 45454545 45454545 aabbccdd aabbccdd EEEEEEEE........ Finally, when the bitlen is 24 mod 32 (e.g. requesting to read 3 or 7 bytes), the last three bytes and up being the wrong ones, since the driver does a full 32 bit read and then shifts the wrong byte out: => mw.l $loadaddr 0xaabbccdd 4 => md.l $loadaddr 4 02000000: aabbccdd aabbccdd aabbccdd aabbccdd ................ => sf read $loadaddr 0x444 10 device 0 offset 0x444, size 0x10 mpc8xxx_spi_xfer: slave spi@7000:0 dout 0FB536E8 din 00000000 bitlen 40 mpc8xxx_spi_xfer: slave spi@7000:0 dout 00000000 din 02000000 bitlen 128 SF: 16 bytes @ 0x444 Read: OK => md.l $loadaddr 4 02000000: 552d426f 6f742032 3031392e 30342d30 U-Boot 2019.04-0 => mw.l $loadaddr 0xaabbccdd 4 => sf read $loadaddr 0x444 0xb device 0 offset 0x444, size 0xb mpc8xxx_spi_xfer: slave spi@7000:0 dout 0FB536E8 din 00000000 bitlen 40 mpc8xxx_spi_xfer: slave spi@7000:0 dout 00000000 din 02000000 bitlen 88 SF: 11 bytes @ 0x444 Read: OK => md.l $loadaddr 4 02000000: 552d426f 6f742032 31392e00 aabbccdd U-Boot 219...... Fix all of that by always using a character size of 8, and reject transfers that are not a whole number of bytes. While it ends being more work for the CPU, we're mostly bounded by the speed of the SPI bus, and we avoid writing to the mode register in every loop. Based on work by Klaus H. Sørensen. Cc: Klaus H. Sorensen Signed-off-by: Rasmus Villemoes --- drivers/spi/mpc8xxx_spi.c | 80 +++++++++++++-------------------------- 1 file changed, 27 insertions(+), 53 deletions(-) diff --git a/drivers/spi/mpc8xxx_spi.c b/drivers/spi/mpc8xxx_spi.c index ac4d0a9bae..8ef2451411 100644 --- a/drivers/spi/mpc8xxx_spi.c +++ b/drivers/spi/mpc8xxx_spi.c @@ -27,6 +27,7 @@ enum { SPI_MODE_EN = BIT(31 - 7), /* Enable interface */ SPI_MODE_LEN_MASK = 0xf00000, + SPI_MODE_LEN_SHIFT = 20, SPI_MODE_PM_MASK = 0xf0000, SPI_COM_LST = BIT(31 - 9), @@ -43,23 +44,8 @@ static inline u32 to_prescale_mod(u32 val) return (min(val, (u32)15) << 16); } -static void set_char_len(spi8xxx_t *spi, u32 val) -{ - clrsetbits_be32(&spi->mode, SPI_MODE_LEN_MASK, (val << 20)); -} - #define SPI_TIMEOUT 1000 -static int __spi_set_speed(spi8xxx_t *spi, uint speed) -{ - /* TODO(mario.six@gdsys.cc): This only ever sets one fixed speed */ - - /* Use SYSCLK / 8 (16.67MHz typ.) */ - clrsetbits_be32(&spi->mode, SPI_MODE_PM_MASK, to_prescale_mod(1)); - - return 0; -} - static int mpc8xxx_spi_ofdata_to_platdata(struct udevice *dev) { struct mpc8xxx_priv *priv = dev_get_priv(dev); @@ -82,14 +68,22 @@ static int mpc8xxx_spi_ofdata_to_platdata(struct udevice *dev) static int mpc8xxx_spi_probe(struct udevice *dev) { struct mpc8xxx_priv *priv = dev_get_priv(dev); + spi8xxx_t *spi = priv->spi; /* * SPI pins on the MPC83xx are not muxed, so all we do is initialize * some registers */ - out_be32(&priv->spi->mode, SPI_MODE_REV | SPI_MODE_MS | SPI_MODE_EN); + out_be32(&priv->spi->mode, SPI_MODE_REV | SPI_MODE_MS); + + /* set len to 8 bits */ + setbits_be32(&spi->mode, (8 - 1) << SPI_MODE_LEN_SHIFT); - __spi_set_speed(priv->spi, 16666667); + /* TODO(mario.six@gdsys.cc): This only ever sets one fixed speed */ + /* Use SYSCLK / 8 (16.67MHz typ.) */ + clrsetbits_be32(&spi->mode, SPI_MODE_PM_MASK, to_prescale_mod(1)); + + setbits_be32(&spi->mode, SPI_MODE_EN); /* Clear all SPI events */ setbits_be32(&priv->spi->event, 0xffffffff); @@ -126,50 +120,35 @@ static int mpc8xxx_spi_xfer(struct udevice *dev, uint bitlen, struct mpc8xxx_priv *priv = dev_get_priv(bus); spi8xxx_t *spi = priv->spi; struct dm_spi_slave_platdata *platdata = dev_get_parent_platdata(dev); - u32 tmpdin = 0; - int num_blks = DIV_ROUND_UP(bitlen, 32); + u32 tmpdin = 0, tmpdout = 0, n; + const u8 *cout = dout; + u8 *cin = din; debug("%s: slave %s:%u dout %08X din %08X bitlen %u\n", __func__, - bus->name, platdata->cs, *(uint *)dout, *(uint *)din, bitlen); + bus->name, platdata->cs, (uint)dout, (uint)din, bitlen); if (platdata->cs >= priv->cs_count) { dev_err(dev, "chip select index %d too large (cs_count=%d)\n", platdata->cs, priv->cs_count); return -EINVAL; } + if (bitlen % 8) { + printf("*** spi_xfer: bitlen must be multiple of 8\n"); + return -ENOTSUPP; + } if (flags & SPI_XFER_BEGIN) mpc8xxx_spi_cs_activate(dev); /* Clear all SPI events */ setbits_be32(&spi->event, 0xffffffff); + n = bitlen / 8; - /* Handle data in 32-bit chunks */ - while (num_blks--) { - u32 tmpdout = 0; - uchar xfer_bitlen = (bitlen >= 32 ? 32 : bitlen); + /* Handle data in 8-bit chunks */ + while (n--) { ulong start; - clrbits_be32(&spi->mode, SPI_MODE_EN); - - /* Set up length for this transfer */ - - if (bitlen <= 4) /* 4 bits or less */ - set_char_len(spi, 3); - else if (bitlen <= 16) /* at most 16 bits */ - set_char_len(spi, bitlen - 1); - else /* more than 16 bits -> full 32 bit transfer */ - set_char_len(spi, 0); - - setbits_be32(&spi->mode, SPI_MODE_EN); - - /* Shift data so it's msb-justified */ - tmpdout = *(u32 *)dout >> (32 - xfer_bitlen); - - if (bitlen > 32) { - /* Set up the next iteration if sending > 32 bits */ - bitlen -= 32; - dout += 4; - } + if (cout) + tmpdout = *cout++; /* Write the data out */ out_be32(&spi->tx, tmpdout); @@ -193,11 +172,8 @@ static int mpc8xxx_spi_xfer(struct udevice *dev, uint bitlen, tmpdin = in_be32(&spi->rx); setbits_be32(&spi->event, SPI_EV_NE); - *(u32 *)din = (tmpdin << (32 - xfer_bitlen)); - if (xfer_bitlen == 32) { - /* Advance output buffer by 32 bits */ - din += 4; - } + if (cin) + *cin++ = tmpdin; /* * Only bail when we've had both NE and NF events. @@ -228,9 +204,7 @@ static int mpc8xxx_spi_xfer(struct udevice *dev, uint bitlen, static int mpc8xxx_spi_set_speed(struct udevice *dev, uint speed) { - struct mpc8xxx_priv *priv = dev_get_priv(dev); - - return __spi_set_speed(priv->spi, speed); + return 0; } static int mpc8xxx_spi_set_mode(struct udevice *dev, uint mode) From patchwork Mon Jan 6 14:09:50 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1218174 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.b="bfBE1lY7"; 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 47ry8c2kFjz9sQp for ; Tue, 7 Jan 2020 01:10:40 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C3B0D81732; Mon, 6 Jan 2020 15:10:01 +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="bfBE1lY7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1F0B28171B; Mon, 6 Jan 2020 15:09:56 +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.8 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-am5eur02on0714.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe07::714]) (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 222B28170D for ; Mon, 6 Jan 2020 15:09: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=rasmus.villemoes@prevas.dk ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hwdbF4dWidrCjVtWEYUBxTWtxIW3ApeLPNQEYT99DA4YgMi8RbRfVuhofmvoladAiLoBpRJOoeeI/Eirvs2jaO99H7zai60ut12OifUNZ+iIX+IJHdGM121XyWOG7O/QUDIX4AaQ0/nJmCpItZ89ES+RqKG47QK8Q38HNQPsPLgjQiIfbrl3jTN3riD1rXudTKzXmxAQFbZ24reeJbSHNEzDqadpHCKaoy7BtOmsnuKiHnZjOxucDnY6P2KTjiOZBY2qlx35dBgRcjjBnb8McPfeXVoUUi6e1tjGfOqPBKqhOkDLsdGMcErGVAwI6Ylc5kjXi4tGiQfrhvmV8POAMQ== 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=wM25/iXfdym5IukjPvMPhUjXPRlCxd6BOs3wuMYNOIg=; b=GNPcgIWE1221N8z6ad+Na6Vvnaa/DrpQsUfDT0EJpQpHKDHAWy6Q1rC03q9eaJ0Z5dOw+yvGPsDfN8VqabkRnNQyz9ZW823bLd55pPWKdrJf/tIUleEcqRevOJO3qPGdvzy3pqzX9rXLHqMGUMj1cLFfuabyAOAmaR188r1hTfYOM60zz9JlJEjflM+vjJYEdXQFJN6qM/MamC4LWR5VfJpo5L0j/4IN1BCXSQ8fz5PaOPLGk8APX6eNKR21jdxnurQ7VC3fev1bkqxPP0jSzOmINBNtOR3xruTeLLutZqS4deWyFikrwpjMaVSYSUMc0qzOM0viPGlRCHR9Wk3cAg== 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=wM25/iXfdym5IukjPvMPhUjXPRlCxd6BOs3wuMYNOIg=; b=bfBE1lY7SlRLx5KONcY3Koy53zxqDzE57kwYpkMhGrQgIZou8sXNuYP7DY4L8VeH1/J83eVIa/an8RYhQns1i073/B5Cq07EzFVDQ8+OL8d8hIupyfl9kVT0UD6l1NbaxKl12rm64SH07fVLeayRS5eqhNyQ/Fu+NnagDfhg1Zo= Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (20.178.126.85) by VI1PR10MB2144.EURPRD10.PROD.OUTLOOK.COM (20.177.62.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.15; Mon, 6 Jan 2020 14:09:51 +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.2602.015; Mon, 6 Jan 2020 14:09:51 +0000 Received: from prevas-ravi.prevas.se (81.216.59.226) by HE1P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2602.12 via Frontend Transport; Mon, 6 Jan 2020 14:09:49 +0000 From: Rasmus Villemoes To: "u-boot@lists.denx.de" Subject: [PATCH 4/4] mpc8xxx_spi: implement real ->set_speed Thread-Topic: [PATCH 4/4] mpc8xxx_spi: implement real ->set_speed Thread-Index: AQHVxJr1QHQEzuoVYEK4u86K+YxERQ== Date: Mon, 6 Jan 2020 14:09:50 +0000 Message-ID: <20200106140931.1136-5-rasmus.villemoes@prevas.dk> References: <20200106140931.1136-1-rasmus.villemoes@prevas.dk> In-Reply-To: <20200106140931.1136-1-rasmus.villemoes@prevas.dk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1P192CA0016.EURP192.PROD.OUTLOOK.COM (2603:10a6:3:fe::26) 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: c7be991d-5335-4586-c2de-08d792b217f8 x-ms-traffictypediagnostic: VI1PR10MB2144: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:494; x-forefront-prvs: 0274272F87 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(396003)(346002)(136003)(366004)(39850400004)(376002)(189003)(199004)(6666004)(66476007)(8676002)(64756008)(66446008)(66556008)(66946007)(54906003)(86362001)(6486002)(81166006)(81156014)(16526019)(52116002)(186003)(26005)(6506007)(316002)(4326008)(36756003)(5660300002)(71200400001)(2906002)(44832011)(6916009)(1076003)(66574012)(2616005)(6512007)(107886003)(8976002)(8936002)(956004)(478600001); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR10MB2144; H:VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A: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: 4DN063tt9MCMQgetOUfrlokZTHV9n0Uk6MPSU0qbqFy33TK9XMsrgeTPCGhmF6QFv/YVGZM+0WYmNPifrBUkXBE2cHNGvfB/3jmomu0lGQnSucSb7HH9EF1t2T62PrxwrG8J4HMq7puPCYBWXazNTciZ5ub/kFKl8kzrzPGbdDPvfO/OnUxjiVLYNRG0kN3W/F8vvqgFNDxJjTLOlkEEBB6Kkf/vmqePFcL2N7x9qR31qkDKUT0X+Eq9i5eYlh+0R8QhFmy8x3XQDIfpwRgaypCLuUFX7MHdW6SZOTUgFehZumT6IzyGwTYwwlZ+Op77si0Ve7Cx/RILLMPyMaievCfvRoZZhbutPpAedxQOSv5aqqy7xGO038PWtcB2URlPXOe/IMzWctgPcVvCwOVB94yinIS1N4C2s2dJ4TfdXdLQcAcHBys8PCHNmC+2JmGl Content-ID: <0AF62F80EDDFFC409B4D3766448750C7@EURPRD10.PROD.OUTLOOK.COM> MIME-Version: 1.0 X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: c7be991d-5335-4586-c2de-08d792b217f8 X-MS-Exchange-CrossTenant-originalarrivaltime: 06 Jan 2020 14:09:50.6623 (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: 2iRRSki3bDVkBN7htO1OGdz8jRommZ4PaXOabvOOlrhP1cjxA8flE52KlmQXAw+2APZ6uOsA6B7X7SyzO+6geCAH+SGhZCeNnV6oj5yt+os= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB2144 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: =?utf-8?q?Klaus_Henning_S=C3=B8rensen?= 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 Not all boards have the same CSB frequency, nor do every SPI slave necessarily support running at 16.7 MHz. So implement ->set_speed; that also allows using a smaller PM (i.e., 0) for slaves that do support a higher speed. Based on work by Klaus H. Sørensen. Cc: Klaus H. Sorensen Signed-off-by: Rasmus Villemoes --- drivers/spi/mpc8xxx_spi.c | 64 ++++++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 11 deletions(-) diff --git a/drivers/spi/mpc8xxx_spi.c b/drivers/spi/mpc8xxx_spi.c index 8ef2451411..1bde31ad34 100644 --- a/drivers/spi/mpc8xxx_spi.c +++ b/drivers/spi/mpc8xxx_spi.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -28,6 +29,7 @@ enum { SPI_MODE_LEN_MASK = 0xf00000, SPI_MODE_LEN_SHIFT = 20, + SPI_MODE_PM_SHIFT = 16, SPI_MODE_PM_MASK = 0xf0000, SPI_COM_LST = BIT(31 - 9), @@ -37,24 +39,19 @@ struct mpc8xxx_priv { spi8xxx_t *spi; struct gpio_desc gpios[16]; int cs_count; + ulong clk_rate; }; -static inline u32 to_prescale_mod(u32 val) -{ - return (min(val, (u32)15) << 16); -} - #define SPI_TIMEOUT 1000 static int mpc8xxx_spi_ofdata_to_platdata(struct udevice *dev) { struct mpc8xxx_priv *priv = dev_get_priv(dev); + struct clk clk; int ret; priv->spi = (spi8xxx_t *)dev_read_addr(dev); - /* TODO(mario.six@gdsys.cc): Read clock and save the value */ - ret = gpio_request_list_by_name(dev, "gpios", priv->gpios, ARRAY_SIZE(priv->gpios), GPIOD_IS_OUT | GPIOD_ACTIVE_LOW); if (ret < 0) @@ -62,6 +59,18 @@ static int mpc8xxx_spi_ofdata_to_platdata(struct udevice *dev) priv->cs_count = ret; + ret = clk_get_by_index(dev, 0, &clk); + if (ret) { + dev_err(dev, "%s: clock not defined\n", __func__); + return ret; + } + + priv->clk_rate = clk_get_rate(&clk); + if (!priv->clk_rate) { + dev_err(dev, "%s: failed to get clock rate\n", __func__); + return -EINVAL; + } + return 0; } @@ -79,10 +88,6 @@ static int mpc8xxx_spi_probe(struct udevice *dev) /* set len to 8 bits */ setbits_be32(&spi->mode, (8 - 1) << SPI_MODE_LEN_SHIFT); - /* TODO(mario.six@gdsys.cc): This only ever sets one fixed speed */ - /* Use SYSCLK / 8 (16.67MHz typ.) */ - clrsetbits_be32(&spi->mode, SPI_MODE_PM_MASK, to_prescale_mod(1)); - setbits_be32(&spi->mode, SPI_MODE_EN); /* Clear all SPI events */ @@ -204,6 +209,43 @@ static int mpc8xxx_spi_xfer(struct udevice *dev, uint bitlen, static int mpc8xxx_spi_set_speed(struct udevice *dev, uint speed) { + struct mpc8xxx_priv *priv = dev_get_priv(dev); + spi8xxx_t *spi = priv->spi; + u32 bits, mask, div16, pm; + u32 mode; + ulong clk; + + clk = priv->clk_rate; + if (clk / 64 > speed) { + div16 = SPI_MODE_DIV16; + clk /= 16; + } else { + div16 = 0; + } + pm = (clk - 1)/(4*speed) + 1; + if (pm > 16) { + dev_err(dev, "requested speed %u too small\n", speed); + return -EINVAL; + } + pm--; + + bits = div16 | (pm << SPI_MODE_PM_SHIFT); + mask = SPI_MODE_DIV16 | SPI_MODE_PM_MASK; + mode = in_be32(&spi->mode); + if ((mode & mask) != bits) { + /* Must clear mode[EN] while changing speed. */ + mode &= ~(mask | SPI_MODE_EN); + out_be32(&spi->mode, mode); + mode |= bits; + out_be32(&spi->mode, mode); + mode |= SPI_MODE_EN; + out_be32(&spi->mode, mode); + } + + debug("requested speed %u, set speed to %lu/(%s4*%u) == %lu\n", + speed, priv->clk_rate, div16 ? "16*" : "", pm + 1, + clk/(4*(pm + 1))); + return 0; }