From patchwork Tue Feb 11 15:20:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1236347 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=J9/KCdc9; 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 48H61c0p1Wz9sP7 for ; Wed, 12 Feb 2020 02:21:24 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id B9495816A9; Tue, 11 Feb 2020 16:20:44 +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="J9/KCdc9"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 7DD0F8175D; Tue, 11 Feb 2020 16:20:32 +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=0.9 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-HE1-obe.outbound.protection.outlook.com (mail-he1eur02on0714.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe05::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 DF5F981720 for ; Tue, 11 Feb 2020 16:20:24 +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=JGGxAIGpFJ99wKU82BmUwyvcaU4RlMHSEwd47I3/SrPmkaFQrio05PyUrY9BZeKS5T2US/2xoU2tFoFOegLo/1KYVjkO1GfslFDFrvI1Q+RSdFYiGCIIgLZPNNogx+sSDWyAw+P9VZxplKcwcePIydNfdq4eXV8pcPDKqDF964LdIRA7gOwZfe0GpAdi1gFif2L8BT5HWjlOEKAAUUQoeORSZ8LHT2lHcsbysZkeriErawu6sC5jyc+XWVGiQbgWTjW0K87k85AqT2uydtHr9szjpqpaVgGa51ML8huHvpzZIBxVbT51dyVfNzu2oyv4OIC+1xGscp3t746w81+G6Q== 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=/A6JjdWn+Z/Gks0lNw2mi9+ZVhBKXNMPpvYwty2Jxtc=; b=Im+51ge8cTQyXxlNddyExZUd99U+i6Ur/x8HrUb2oYhSG9KaiQ3pujHi/xsYAu0Sy08j6yoMr+uLoFE5H7Lof5xsl0WGVw3UvdpAOBFkWgeZYZL0NRaMYaZUD86oQ29hblzQ4Hw9omps6bPXCvjkalVyk+90anjGg37ppsoKSyeYkaE406oqQFlKwFrLCTTBGmNh5SBP08gqpz9GPH/ttTI5NFFOTunTyw5uzsGPjKSUwKTIn/WOGi6ADPTk1BxRMDmUciBlvq7wC9EF7WuoiJHZbs23eam/tB9aHkKQgZFCXdYF88JFwW1qBmBpilf/MbTCJQTnC+BydBzqbAGDjg== 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=/A6JjdWn+Z/Gks0lNw2mi9+ZVhBKXNMPpvYwty2Jxtc=; b=J9/KCdc9gmpKCd3vLysg+rRbYAw99HJ+Jy2LcZsrMmRgYf+Xd0+5LSGJcXqboZDx1E9kUHf8HKOlgqbNXa1rbtHefJvF48buHgzAV6FWPVpqkd/UdGquDaDCBBge1eDKUhFAV+rbWhFqFDKwhVW0Yzg7JzNbIZaqdjFJecFFKxQ= Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (20.178.126.85) by VI1PR10MB2141.EURPRD10.PROD.OUTLOOK.COM (20.177.58.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.25; Tue, 11 Feb 2020 15:20:22 +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.2707.030; Tue, 11 Feb 2020 15:20:22 +0000 Received: from prevas-ravi.prevas.se (81.216.59.226) by HE1PR05CA0209.eurprd05.prod.outlook.com (2603:10a6:3:f9::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.23 via Frontend Transport; Tue, 11 Feb 2020 15:20:21 +0000 From: Rasmus Villemoes To: "u-boot@lists.denx.de" Subject: [PATCH resend 1/5] gpio/mpc83xx_spisel_boot.c: gpio driver for SPISEL_BOOT signal Thread-Topic: [PATCH resend 1/5] gpio/mpc83xx_spisel_boot.c: gpio driver for SPISEL_BOOT signal Thread-Index: AQHV4O7HwL1I2YxJCkmRWdLGSkWCXg== Date: Tue, 11 Feb 2020 15:20:22 +0000 Message-ID: <20200211151947.26091-2-rasmus.villemoes@prevas.dk> References: <20200211151947.26091-1-rasmus.villemoes@prevas.dk> In-Reply-To: <20200211151947.26091-1-rasmus.villemoes@prevas.dk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR05CA0209.eurprd05.prod.outlook.com (2603:10a6:3:f9::33) 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: 712693cc-9afe-49fe-e0f1-08d7af05e967 x-ms-traffictypediagnostic: VI1PR10MB2141: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1923; x-forefront-prvs: 0310C78181 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(346002)(396003)(366004)(39850400004)(136003)(199004)(189003)(36756003)(316002)(186003)(16526019)(71200400001)(2906002)(478600001)(956004)(2616005)(6486002)(26005)(6506007)(86362001)(6916009)(81156014)(81166006)(52116002)(6512007)(4326008)(8976002)(107886003)(5660300002)(1076003)(54906003)(44832011)(8676002)(8936002)(66946007)(66556008)(66446008)(64756008)(66476007); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR10MB2141; 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: ogylcSvHwY1pvJBdhJAclzcRKE8jixRS3LENwdjFh8vXzH1udZW69QGl3wklCXIYK0A2BWeZWKMYzD8VXOY6jxJ3z3DaJZ1VP8BEDMd7YMl7scVT/x6ImDWKYtewU7XosGGNfY84JFwdxwnOGXckD6hW7B98gRj9IoahbV2werTzGjm26zvgy+dJUVVZKeLDGZmj9mZZCXPUopxenA/fkmJCqlteqhcuXUL0X8GdniXmEfKOaNPs43c5Uevl9LZfNHIxUhgvn9kroTbD/vo6b8C/wJPg+DuxxTuC2+mtNt9oXarbyotqrfWTSEo/MRNCNkpaFdk70ldRohFrkPOjgFQG7uBbXP1lTkkwgD0h+BjSNgbB9h/k8jmS0yKhszASARNNBmZ9fctkmBE28j7xP0ze2c7QRssTJcOrEI00nVIvV6zqADIwe9EqqEsaObej x-ms-exchange-antispam-messagedata: CPXkmjdAZaB6XA1kuMK5zp1pwBygyUmd1naYg6hQF6t2pZ8b9PAOKPy6E9DdYEH1OuyOUG75/Y1rByJa2NAgmOGqwa63eE6w6lMBhmjahqTuz1VSHJo9m9YaH9cWEMxxT3MHhEwbKKCv9XkQz9UxDw== MIME-Version: 1.0 X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: 712693cc-9afe-49fe-e0f1-08d7af05e967 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Feb 2020 15:20:22.3799 (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: /hdghB5BcxHuaEWQf/htoJDpt6AMTZLf2/l7XxrTgJ2fcEByXnc3KTWwT1ruUL6/glWGJxz8AA/blFMOy/zg9gFAgZ/rGK0T8C6f1o7mEW8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB2141 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.102.1 at phobos.denx.de X-Virus-Status: Clean From: "Klaus H. Sorensen" Some SoCs in the mpc83xx family, e.g. mpc8309, have a dedicated spi chip select, SPISEL_BOOT, that is used by the boot code to boot from flash. This chip select will typically be used to select a SPI boot flash. The SPISEL_BOOT signal is controlled by a single bit in the SPI_CS register. Implement a gpio driver for the spi chip select register. This allows a spi driver capable of using gpios as chip select, to bind a chip select to SPISEL_BOOT. It may be a little odd to do this as a GPIO driver, since the signal is neither GP or I, but it is quite convenient to present it to the spi driver that way. The alternative it to teach mpc8xxx_spi to handle the SPISEL_BOOT signal itself (that is how it's done in the linux kernel, see commit 69b921acae8a) Signed-off-by: Klaus H. Sorensen Signed-off-by: Rasmus Villemoes --- .../gpio/fsl,mpc83xx-spisel-boot.txt | 22 +++ drivers/gpio/Kconfig | 8 + drivers/gpio/Makefile | 1 + drivers/gpio/mpc83xx_spisel_boot.c | 148 ++++++++++++++++++ 4 files changed, 179 insertions(+) create mode 100644 doc/device-tree-bindings/gpio/fsl,mpc83xx-spisel-boot.txt create mode 100644 drivers/gpio/mpc83xx_spisel_boot.c diff --git a/doc/device-tree-bindings/gpio/fsl,mpc83xx-spisel-boot.txt b/doc/device-tree-bindings/gpio/fsl,mpc83xx-spisel-boot.txt new file mode 100644 index 0000000000..52d8bb0a5c --- /dev/null +++ b/doc/device-tree-bindings/gpio/fsl,mpc83xx-spisel-boot.txt @@ -0,0 +1,22 @@ +MPC83xx SPISEL_BOOT gpio controller + +Provide access to MPC83xx SPISEL_BOOT signal as a gpio to allow it to be +easily bound as a SPI controller chip select. + +The SPISEL_BOOT signal is always an output. + +Required properties: + +- compatible: must be "fsl,mpc83xx-spisel-boot" or "fsl,mpc8309-spisel-boot". +- reg: must point to the SPI_CS register in the SoC register map. +- ngpios: number of gpios provided by driver, normally 1. + +Example: + + spisel_boot: spisel_boot@14c { + compatible = "fsl,mpc8309-spisel-boot"; + reg = <0x14c 0x04>; + #gpio-cells = <2>; + device_type = "gpio"; + ngpios = <1>; + }; diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig index c1ad5d64a3..73fdb8cb3b 100644 --- a/drivers/gpio/Kconfig +++ b/drivers/gpio/Kconfig @@ -383,6 +383,14 @@ config MPC8XXX_GPIO value setting, the open-drain feature, which can configure individual GPIOs to work as open-drain outputs, is supported. +config MPC83XX_SPISEL_BOOT + bool "Freescale MPC83XX SPISEL_BOOT driver" + depends on DM_GPIO && ARCH_MPC830X + help + GPIO driver to set/clear dedicated SPISEL_BOOT output on MPC83XX. + + This pin is typically used as spi chip select to a spi nor flash. + config MT7621_GPIO bool "MediaTek MT7621 GPIO driver" depends on DM_GPIO && SOC_MT7628 diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile index ccc49e2eb0..bbeec30431 100644 --- a/drivers/gpio/Makefile +++ b/drivers/gpio/Makefile @@ -38,6 +38,7 @@ obj-$(CONFIG_DM644X_GPIO) += da8xx_gpio.o obj-$(CONFIG_ALTERA_PIO) += altera_pio.o obj-$(CONFIG_MPC83XX_GPIO) += mpc83xx_gpio.o obj-$(CONFIG_MPC8XXX_GPIO) += mpc8xxx_gpio.o +obj-$(CONFIG_MPC83XX_SPISEL_BOOT) += mpc83xx_spisel_boot.o obj-$(CONFIG_SH_GPIO_PFC) += sh_pfc.o obj-$(CONFIG_OMAP_GPIO) += omap_gpio.o obj-$(CONFIG_DB8500_GPIO) += db8500_gpio.o diff --git a/drivers/gpio/mpc83xx_spisel_boot.c b/drivers/gpio/mpc83xx_spisel_boot.c new file mode 100644 index 0000000000..c7b08404d9 --- /dev/null +++ b/drivers/gpio/mpc83xx_spisel_boot.c @@ -0,0 +1,148 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * (C) Copyright 2019 DEIF A/S + * + * GPIO driver to set/clear SPISEL_BOOT pin on mpc83xx. + */ + +#include +#include +#include +#include + +struct mpc83xx_spisel_boot { + u32 __iomem *spi_cs; + ulong addr; + uint gpio_count; + ulong type; +}; + +static u32 gpio_mask(uint gpio) +{ + return (1U << (31 - (gpio))); +} + +static int mpc83xx_spisel_boot_direction_input(struct udevice *dev, uint gpio) +{ + return -EINVAL; +} + +static int mpc83xx_spisel_boot_set_value(struct udevice *dev, uint gpio, int value) +{ + struct mpc83xx_spisel_boot *data = dev_get_priv(dev); + + debug("%s: gpio=%d, value=%u, gpio_mask=0x%08x\n", __func__, + gpio, value, gpio_mask(gpio)); + + if (value) + setbits_be32(data->spi_cs, gpio_mask(gpio)); + else + clrbits_be32(data->spi_cs, gpio_mask(gpio)); + + return 0; +} + +static int mpc83xx_spisel_boot_direction_output(struct udevice *dev, uint gpio, int value) +{ + return 0; +} + +static int mpc83xx_spisel_boot_get_value(struct udevice *dev, uint gpio) +{ + struct mpc83xx_spisel_boot *data = dev_get_priv(dev); + + return !!(in_be32(data->spi_cs) & gpio_mask(gpio)); +} + +static int mpc83xx_spisel_boot_get_function(struct udevice *dev, uint gpio) +{ + return GPIOF_OUTPUT; +} + +#if CONFIG_IS_ENABLED(OF_CONTROL) +static int mpc83xx_spisel_boot_ofdata_to_platdata(struct udevice *dev) +{ + struct mpc8xxx_gpio_plat *plat = dev_get_platdata(dev); + fdt_addr_t addr; + u32 reg[2]; + + dev_read_u32_array(dev, "reg", reg, 2); + addr = dev_translate_address(dev, reg); + + plat->addr = addr; + plat->size = reg[1]; + plat->ngpios = dev_read_u32_default(dev, "ngpios", 1); + + return 0; +} +#endif + +static int mpc83xx_spisel_boot_platdata_to_priv(struct udevice *dev) +{ + struct mpc83xx_spisel_boot *priv = dev_get_priv(dev); + struct mpc8xxx_gpio_plat *plat = dev_get_platdata(dev); + unsigned long size = plat->size; + ulong driver_data = dev_get_driver_data(dev); + + if (size == 0) + size = 0x04; + + priv->addr = plat->addr; + priv->spi_cs = map_sysmem(plat->addr, size); + + if (!priv->spi_cs) + return -ENOMEM; + + priv->gpio_count = plat->ngpios; + + priv->type = driver_data; + + return 0; +} + +static int mpc83xx_spisel_boot_probe(struct udevice *dev) +{ + struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); + struct mpc83xx_spisel_boot *data = dev_get_priv(dev); + char name[32], *str; + + mpc83xx_spisel_boot_platdata_to_priv(dev); + + snprintf(name, sizeof(name), "MPC@%lx_", data->addr); + str = strdup(name); + + if (!str) + return -ENOMEM; + + uc_priv->bank_name = str; + uc_priv->gpio_count = data->gpio_count; + + return 0; +} + +static const struct dm_gpio_ops mpc83xx_spisel_boot_ops = { + .direction_input = mpc83xx_spisel_boot_direction_input, + .direction_output = mpc83xx_spisel_boot_direction_output, + .get_value = mpc83xx_spisel_boot_get_value, + .set_value = mpc83xx_spisel_boot_set_value, + .get_function = mpc83xx_spisel_boot_get_function, +}; + +static const struct udevice_id mpc83xx_spisel_boot_ids[] = { + { .compatible = "fsl,mpc8309-spisel-boot" }, + { .compatible = "fsl,mpc83xx-spisel-boot" }, + { /* sentinel */ } +}; + +U_BOOT_DRIVER(spisel_boot_mpc83xx) = { + .name = "spisel_boot_mpc83xx", + .id = UCLASS_GPIO, + .ops = &mpc83xx_spisel_boot_ops, +#if CONFIG_IS_ENABLED(OF_CONTROL) + .ofdata_to_platdata = mpc83xx_spisel_boot_ofdata_to_platdata, + .platdata_auto_alloc_size = sizeof(struct mpc8xxx_gpio_plat), + .of_match = mpc83xx_spisel_boot_ids, +#endif + .probe = mpc83xx_spisel_boot_probe, + .priv_auto_alloc_size = sizeof(struct mpc83xx_spisel_boot), +}; From patchwork Tue Feb 11 15:20:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1236348 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=OAp53fbb; 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 48H61s23mrz9sP7 for ; Wed, 12 Feb 2020 02:21:37 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7053581782; Tue, 11 Feb 2020 16:20: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="OAp53fbb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A88798175F; Tue, 11 Feb 2020 16:20:36 +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=0.9 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-HE1-obe.outbound.protection.outlook.com (mail-he1eur02on0714.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe05::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 98106815B4 for ; Tue, 11 Feb 2020 16:20:25 +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=Ogx5cjUnA9F9y56DdELndwp+1mqG3yItD68orZ/O30md5Ap0Cqo0tRTkss2JPNgJOSt2y5OSPupQeHxcWhcBglbJg/T3gUgy79lYlWl0bH5iUFQT526FnORl4h7rG+IK/mkaWuiGANWErCdIQdYxTi8cpsz4a3dpj3BEStBYfufUIpazH7u8eo9GjT8yarPCNOAH5GSW4zpmLxWXTCFWSX1bArA0xD9A+IuozD9EyfuTEv9d9C2ghSpcxgCNo7mxzP9ShFTxzZNglbuNACT3W+KcvLvi2fSq0/Gl6M+1whpLmCRDyjrLGtKjSEC+0pxClKy/veOwSy+hEr+n0Y4rOQ== 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=RX21mQKc8BxS59wyWoZFf9+NOGGKSSCFKETFYiHlGitiqpNQmCJZbfZ7M1jUw/iaNixqeJMeGq+klY3xgP6O2FLHhScGisBKd20G52j/sXfPw0+wB66UfnL0ge0FovrQKhrCUmBlgRroYhMfQx76N2jpTog7P9KHc+W7ZaUV3xisXDcBId9H+NKMY5cCvWAFDFGolXESFqxaAfve3RMhIiBw46fj1BGUVqOmz22v+fdz9oKbWzZJ1ByHLxDQ7kNiSsb3D0xdMKqOKKudMWeYaX2k9YR37X6wdH/mykVHj5Y//KB+rPp6aP9WotqWByJ8CpEKvVVwmAIDOYnE06isbg== 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=OAp53fbbQ56Ypki9ArZEKZ585gz6IckmS3tF7Xqcsq4sNWFHvEaF2MM1YXKfCZVZAfJ2kdWkeLz49z5HtA2I5yCZmZpetMCvhxwpHHy0aQ9o9QOkH+VjWuu1q4DCN8TZ0g/RJCvmlN3UgTT6eaMiz7Pw1fUP4N5o4XsD7uiA4qY= Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (20.178.126.85) by VI1PR10MB2141.EURPRD10.PROD.OUTLOOK.COM (20.177.58.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.25; Tue, 11 Feb 2020 15:20:23 +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.2707.030; Tue, 11 Feb 2020 15:20:23 +0000 Received: from prevas-ravi.prevas.se (81.216.59.226) by HE1PR05CA0209.eurprd05.prod.outlook.com (2603:10a6:3:f9::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.23 via Frontend Transport; Tue, 11 Feb 2020 15:20:22 +0000 From: Rasmus Villemoes To: "u-boot@lists.denx.de" Subject: [PATCH resend 2/5] gazerbeam: add clocks property to SPI node Thread-Topic: [PATCH resend 2/5] gazerbeam: add clocks property to SPI node Thread-Index: AQHV4O7H+ep0+Jac5UCpR3wdQeJNDQ== Date: Tue, 11 Feb 2020 15:20:23 +0000 Message-ID: <20200211151947.26091-3-rasmus.villemoes@prevas.dk> References: <20200211151947.26091-1-rasmus.villemoes@prevas.dk> In-Reply-To: <20200211151947.26091-1-rasmus.villemoes@prevas.dk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR05CA0209.eurprd05.prod.outlook.com (2603:10a6:3:f9::33) 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: 1e6919e3-5d72-4bd8-8dbd-08d7af05e9ec x-ms-traffictypediagnostic: VI1PR10MB2141: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:1079; x-forefront-prvs: 0310C78181 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(346002)(396003)(366004)(39850400004)(136003)(199004)(189003)(36756003)(316002)(186003)(16526019)(71200400001)(2906002)(478600001)(956004)(2616005)(6486002)(26005)(6506007)(4744005)(86362001)(6916009)(81156014)(81166006)(52116002)(6512007)(4326008)(8976002)(107886003)(5660300002)(1076003)(54906003)(44832011)(8676002)(8936002)(66946007)(66556008)(66446008)(64756008)(66476007); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR10MB2141; 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: e3w/5A1wmigDBnl0qoYu8Bo1LTHz4SYJVySL2hzwt/88AWyMr5CCh34vITdWyNqEyHudYcQbW4kRKpRpp8XAjNgfYk6gnG/jg/xX16x/GExEnkohg1vm4D8nkqM1tpMpcAgek+dPd+n/Kssf0gG9i6WE0PUmCikeZd2Vj0wkC7stpj0x4H44Zk63lFXHrxphbElAbETNguyeVwdkQtgEaijNxaOBOh96jDF9Zpm1B+3L6h36ueNmKpxCVf810jCp9Cb4wJq+s1pqYCodhTn454Vaohfx12LisgFy6UiEaWB7dq9buvDDjTnwUPK11NmzxPBkrnhFq3ZUGX+9rLR4mUvtg0+TBmeM7kjf0+Bm6byJJmqTBlEEoZH7z6U26bg/LunuzyWskYlzkilG3VONMVtugL1dbU6w4Z3WBizwydIWQbgpNeLJ6BR7F+dfV8yd x-ms-exchange-antispam-messagedata: H4HZsg+Q7jNHfOImE20UCPPvCI5zw/RgtCAX8BrurZDH2FiizHoYc3PMI59MOZMEG1efPaanRk5PcYYVcvczPMhcUlwQgJHzsBsDbKwhJFRkhIV6Wos90tXhWXOTxeGH7qOYtp99HZZYyRoZ9hHshg== MIME-Version: 1.0 X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: 1e6919e3-5d72-4bd8-8dbd-08d7af05e9ec X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Feb 2020 15:20:23.2644 (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: m4GsFQyvrn4VSz9H029dYVVdMRECLIybYpsTr7LFnYYgfNmi50DVCc1zKbs5s1KaX0SyOf/y6dqdZlR+Oe/YrvhcCHBQGobL2sv8GgkaHfE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB2141 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.102.1 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 Tue Feb 11 15:20:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1236349 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=E0pUKbyH; 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 48H6251Df8z9sRQ for ; Wed, 12 Feb 2020 02:21:49 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 25053816FF; Tue, 11 Feb 2020 16:20:54 +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="E0pUKbyH"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 326D8816BA; Tue, 11 Feb 2020 16:20:37 +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=0.9 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-HE1-obe.outbound.protection.outlook.com (mail-he1eur02on0714.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe05::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 0C7278172D for ; Tue, 11 Feb 2020 16:20:26 +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=bwrYsVM5YNJL3Wmnl8eGGsygdcdIVAk5DmEGWTRov5OOrFf+bRz+Wy4Diz9nQHQ+Qu0u+Dx2OkLpFsiEJ4CmFDdM2l4yN90dvzEUUg9THGLkh0th7zSkHvHkSz6nAV00hJnUJ3JroRS+yr9tL+IUdeSWSITeId3Zgpt39bJ6y+43NHkHRV8Wp72onr+YAu9/2vM0g/S1pCWSptd5zPmeuSzUz4QcZdP28nx9DHB+Uh21vbe34pegPBEVy4w0SMFqW1vVfOb+27aqfpeWQd8Nvzb07vJg7GavulE0ilygaia4L9sXwDjtROQMhTCOZb0MQfBZ0CCEShxw93VT7oCyug== 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=mhzLxLPwUmnF3As+2hqEokddSMnjK0b7E7BkeHnmhlSS/C6LTm24tZv//KEELRsUMuFUbaFKuQfwc9j6HWoC9QVzFFDmWiwiwMV6h7q5wpIU1C5BG6HNbBnrr/8t44bl01IccAWVYoDJjYe9n02rTuqfZJw3/ycmx/kXbrS2BGRO70EKRFZo7fiOnzN6yOxuoTtnkT2agpnLb+Y+1Uhc+KoFCq1XBeVNRLe57MEy8WAqQs7I8KbCTA3fe7jcosQtqDuPpefQq0/DnVEBDIxMwN5xu1csiZvcDadpunRBFQdWYLMra3SGRv1A4T6+Eg/OegG5SCX/WNHLAf47y9Rm2A== 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=E0pUKbyH30GBFfjmYjl0XqiZEwIBW+GbZDQvcy/eXu+H/3hg9YatOF71egYErk0VFD5r/IsMy/MnLnEj8FP47h8kydtmxs7mYd/f3X7kemXmuGFK1tVt1aQd62g7MTfG9OoHC6NshT8Z93wL6+igZVPnb+7vV6Zwj/vce2pxToI= Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (20.178.126.85) by VI1PR10MB2141.EURPRD10.PROD.OUTLOOK.COM (20.177.58.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.25; Tue, 11 Feb 2020 15:20:24 +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.2707.030; Tue, 11 Feb 2020 15:20:24 +0000 Received: from prevas-ravi.prevas.se (81.216.59.226) by HE1PR05CA0209.eurprd05.prod.outlook.com (2603:10a6:3:f9::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.23 via Frontend Transport; Tue, 11 Feb 2020 15:20:23 +0000 From: Rasmus Villemoes To: "u-boot@lists.denx.de" Subject: [PATCH resend 3/5] mpc8xxx_spi: put max_cs to use Thread-Topic: [PATCH resend 3/5] mpc8xxx_spi: put max_cs to use Thread-Index: AQHV4O7If59bg/EzIkGsCSst2VAbSw== Date: Tue, 11 Feb 2020 15:20:24 +0000 Message-ID: <20200211151947.26091-4-rasmus.villemoes@prevas.dk> References: <20200211151947.26091-1-rasmus.villemoes@prevas.dk> In-Reply-To: <20200211151947.26091-1-rasmus.villemoes@prevas.dk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR05CA0209.eurprd05.prod.outlook.com (2603:10a6:3:f9::33) 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: 1df116d3-b9b1-4cbb-7b25-08d7af05ea77 x-ms-traffictypediagnostic: VI1PR10MB2141: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:418; x-forefront-prvs: 0310C78181 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(346002)(396003)(366004)(39850400004)(136003)(199004)(189003)(36756003)(316002)(186003)(16526019)(71200400001)(2906002)(478600001)(956004)(2616005)(6486002)(26005)(6506007)(86362001)(6916009)(81156014)(81166006)(52116002)(6512007)(4326008)(8976002)(107886003)(5660300002)(1076003)(54906003)(44832011)(8676002)(8936002)(66946007)(66556008)(66446008)(64756008)(66476007); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR10MB2141; 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: dIs/v4xLxsKHsqGKQNM0dYdVtQD2/r7Lc9Lplp3yOCFb3NILtT9UDPlTHMXseWvTd4Ga1DvVxlfURS582yg6al8x2E4AYXwkpRxKwfbiw2aWOf6aIsgpkR88dr/MhyV3HqXn4DbnyFmg1+n1OhiAQSNsHpLongC+MEIhr/jvrHZm3LWvUWO2haBqrM6Gu8v7JlGAOhHekjLAdic17/Q5xUpssM6zLig3GIa0bxikfz+v/NTiIQJODN3hJu8g7nCLwJCjrBdW6MJxMz9aEoII4nTfePhZyC8uyoZ4pZrMeisJvkizAy6q8YcSLIGsjPryp2SbLd2uAcdAN9nmfBiQvZOJ0ymmWyn+Kw6w8Q4LG5N16BtJUFjHhVmOxsb/8pDvzb4UAzJKzTXJE5ZrPpu7jIZKBfi61aUdlETBzYpPbhSKVXpDRbCf3HZC+EN39NCN x-ms-exchange-antispam-messagedata: OJPatLltDf3NjrcceBrioij/ZW8CyvzWbyMvkEQsRB37sWK1i9AlnU6o+8hNwABhk+59k3ZKJ2ydPTZJwV+1O6b1WABsZrQZOsaq2c08RjkFu1JVUIonQHN6pDLUgGLclUVam795Q1ZsCC4xgiKGTg== MIME-Version: 1.0 X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: 1df116d3-b9b1-4cbb-7b25-08d7af05ea77 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Feb 2020 15:20:24.1499 (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: FR42Gan90/miCJhlGSuIeAW2ZrpBFyOWs7Cl5OQIBB4/HZyNakfztJQLrFsvGMJFIOF9euH5oknzSnOSFiCE8zmOb6KceS0XTal6x0Bbs3Y= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB2141 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.102.1 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 Tue Feb 11 15:20:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1236351 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=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=Hh5rJuVP; 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 48H62X2Sx5z9sRQ for ; Wed, 12 Feb 2020 02:22:12 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8B2BC81720; Tue, 11 Feb 2020 16:21:04 +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="Hh5rJuVP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3ED22816FF; Tue, 11 Feb 2020 16:20:37 +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=0.9 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-HE1-obe.outbound.protection.outlook.com (mail-he1eur02on0714.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe05::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 CB4758172F for ; Tue, 11 Feb 2020 16:20:26 +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=I1KeXrrdwmYdPXSDM5EGaDP/d1K+FAerf3+nHBI3nBPcnFhe04uTdVTiIARQXNpr7uR5KYH+I6iYzBn7RmR1p4BbPbp62egVhWGw95yF2U5mOPUMoUhbQWadwoxZMxrlX87P8+b0krPyqEV/tg36p9oAQgQzcCScBUZbv3pkvAUb2j8cymu+r1sCrnkNMVvsRFrGXYobZqhbVBx0HNSvpuWuq3OWJiUbnRwom8sc0JZJWgF496hk5rFOs10mHv80ff0O3OWa3y2xLbYAJ29ySdu/3cwoHsZU1Ve40txIAafjCv4D5GDTJs4h9Gud/GuPR3WvfTGodfu+bTcCYbqqmw== 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=K43T3H9iV4JTSGGCfTbzkMYEm9ntekrjLwrADMMgRkM+ZD46ks2Ilkvo+ToclltAFVM5PDk5CD4Ho91+jYKGjtHMjVGvNYI2ESDbO5MQav3XfYoIgjPDLFSW4OW3MB9MZ1ohutUfsdEAu03Q2i47wj0avhZB5m7ugzoJHTH2JlGeZLHJ/nfKCQZssxoLhNyLgPhqIGFFinuaM6ItVsSayr6crDFEm6QtRSuMbVqnbiujtRnGs7UNNacoEFcSANHuF/6WJm1Nv2dQqdYjGB1YiNREp1UK7LhmBpPRW0sVN7MW3NhdPkmzp5FDVjZxeIeTaqnUfKe7bezTU0ni7b3TVQ== 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=Hh5rJuVPqtEVDFmJhCZl61b2rpTT8xF84iD4M2jRWUVAYvMBL+5L03H80H71fiGRUOrZGqmKMwiQzmCZC9XM5Cmx/V1pxh+VWoCOy5j6zBykXB4XvbmtldTqKKI9es9BDJZnSmg+eB38Q31ckJhc3F9+ieBM4IAdNYoB3zzTWL4= Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (20.178.126.85) by VI1PR10MB2141.EURPRD10.PROD.OUTLOOK.COM (20.177.58.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.25; Tue, 11 Feb 2020 15:20:25 +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.2707.030; Tue, 11 Feb 2020 15:20:25 +0000 Received: from prevas-ravi.prevas.se (81.216.59.226) by HE1PR05CA0209.eurprd05.prod.outlook.com (2603:10a6:3:f9::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.23 via Frontend Transport; Tue, 11 Feb 2020 15:20:24 +0000 From: Rasmus Villemoes To: "u-boot@lists.denx.de" Subject: [PATCH resend 4/5] mpc8xxx_spi: always use 8-bit characters, don't read or write garbage Thread-Topic: [PATCH resend 4/5] mpc8xxx_spi: always use 8-bit characters, don't read or write garbage Thread-Index: AQHV4O7I8Gap+Lp8i0ySU21oSl3TKQ== Date: Tue, 11 Feb 2020 15:20:25 +0000 Message-ID: <20200211151947.26091-5-rasmus.villemoes@prevas.dk> References: <20200211151947.26091-1-rasmus.villemoes@prevas.dk> In-Reply-To: <20200211151947.26091-1-rasmus.villemoes@prevas.dk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR05CA0209.eurprd05.prod.outlook.com (2603:10a6:3:f9::33) 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: f7d9852c-3f45-4ff0-8f93-08d7af05eb02 x-ms-traffictypediagnostic: VI1PR10MB2141: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:901; x-forefront-prvs: 0310C78181 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(346002)(396003)(366004)(39850400004)(136003)(199004)(189003)(36756003)(316002)(186003)(16526019)(71200400001)(2906002)(478600001)(956004)(2616005)(6486002)(26005)(6506007)(86362001)(6916009)(81156014)(81166006)(52116002)(6512007)(4326008)(8976002)(107886003)(5660300002)(66574012)(1076003)(54906003)(44832011)(8676002)(8936002)(66946007)(66556008)(66446008)(64756008)(66476007); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR10MB2141; 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: 8KEqKsmHY6u8RBSs6DZp+Nxtm3/6w7o7eZHBUDlRBNPv/FrNze/n6+BgTccARMwpd7BOKm6xh5moTmQ5b27XR5qhqYe3ft9XCZACj7Z6Ude0p73lOIC9J0IFRbS3nl3t8niDoSM/yHR6f4r0tq0yrADJQl+F/3ol2/Llf2wAAPOMUEwW8cohiDWK2Ur0nWxBlIHGWcEY/ZcgozHRPDTU1IyrCPAwLUSS9gZkes4tVOtTq2CVcykHBYkgJXqwHYMM5Ov65wAQbTFIjSealqxA/06g2XhTTDp8530ZmqEXQMAnoVjEnHI8I+jgQ7h7Wkv/8JUgQYZOg0mW3FOJLlDiRR29LE9uUvcvbCZg0jzpUjpTP4Ni4ejorOKAqWprnuhGdQjhbiHZyWgda88J076JCeQ8j0XD8WMyklbATLF6bSu9GHJpbE5M7uibU5LbUY8H x-ms-exchange-antispam-messagedata: jKI+l0oVXvPb4WRdE+OQmheil+Pfgaumc8a94H1Sc3Iw6+Wr+bQrCyOJjzkn5QtbIjWCVq6L77dirUDxSuc3h13zm/MYP+JjzNK6BCAMgQYiTKy8XQpsiCiN98KIJ9myvMb6NcTmzZrwRx7oZeKU7A== Content-ID: <6C70CD3A03A1D74080C0C653651F2206@EURPRD10.PROD.OUTLOOK.COM> MIME-Version: 1.0 X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: f7d9852c-3f45-4ff0-8f93-08d7af05eb02 X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Feb 2020 15:20:25.0664 (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: 8d2DiopqRpBTrK2ieHjRJ7b+E2HSEMCVanwvRXp7/ZH3t5UArB97Pu+eaxOcDKb+uWbVfSmNdTG5ocinpPgxedu3I4V6tq6bckchJESRZ7c= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB2141 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.102.1 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 Tue Feb 11 15:20:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1236350 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=SXbLAfFL; 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 48H62J6PjDz9sRR for ; Wed, 12 Feb 2020 02:22:00 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4418781795; Tue, 11 Feb 2020 16:20:58 +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="SXbLAfFL"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 6BBD48172D; Tue, 11 Feb 2020 16:20:38 +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=0.9 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-HE1-obe.outbound.protection.outlook.com (mail-he1eur02on0714.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe05::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 55C4781758 for ; Tue, 11 Feb 2020 16:20:28 +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=Qt9C4WfDrXRR1oCmAuj1bRBEPXxnB45sm/EZ0l2Fp6msnx8t1uGiOHaO2rexFT+IeDHPzSJqTI5/OYbX7J9dNYUmKfXcdm/5fIUvr4lyfdhfwrA3U2Yxj9WhIRZi1M1BT/T2bR3dBD0fMSKZ1xSXkTVKIq6ohJcB4a2B57zsJRMuxTDEwnp5JOKi9cs6A0cUNFnNfD5XRqlPoYOBknMBZxSd6DmDvEO0om0Lju5/25fEwwCVY0xwJKXESQmtqonn38+CVvyeQqYUTFBT9KSQbulsk9erbtXOcN0vz0cACXVd2i841wEdKiM859eCgshPyP5n0m+TZpL+NrewiYhCzg== 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=WRFXfQV65PZGwOGCRCAtu/zvkQOOO+bKNSQrSKgPtHLp7kG9p1ipoa+go5Hw28E84afIlGSTIX9qhW+9IieAOaFOvwMk8H80Ox4r6iIpvz7Bd3OI2zO0sgGq1MdyKRnTco2btcLEAloZvhzXrXcZl+qWseP/qNWSwmgyC+uF2tmwfEzdBeQ6g0Jgi42t6cktBkQZjivh2PtHw6C9ZTRx/Q5AFAWCu3y1IgNH4YQW2bdhVcz11d/1+8ezvUFgUnFOgesodq5cwR30HG7WdE5FoAFGc39oZZho++75Kb26TWaxNV5Giw7I5SEJhmGfSIF0ygDlwNeCLGPAwOVAd28bGQ== 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=SXbLAfFLOFSIJeZia5KQZH+qzKHuqrR0pYNIwk3pAdWPhhl3inaFBsCxbnX0SMGiCeZSCqotwNM2NS+5Ee14hKvdJ9JB5mPCIt+fZvooVgkkGfnmg4P091KMQGijw4Ee2eFwPa1hvcdI59zop6MQce3NzTHl0ohr/qQmLmu7TVA= Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (20.178.126.85) by VI1PR10MB2141.EURPRD10.PROD.OUTLOOK.COM (20.177.58.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.25; Tue, 11 Feb 2020 15:20:26 +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.2707.030; Tue, 11 Feb 2020 15:20:26 +0000 Received: from prevas-ravi.prevas.se (81.216.59.226) by HE1PR05CA0209.eurprd05.prod.outlook.com (2603:10a6:3:f9::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2707.23 via Frontend Transport; Tue, 11 Feb 2020 15:20:25 +0000 From: Rasmus Villemoes To: "u-boot@lists.denx.de" Subject: [PATCH resend 5/5] mpc8xxx_spi: implement real ->set_speed Thread-Topic: [PATCH resend 5/5] mpc8xxx_spi: implement real ->set_speed Thread-Index: AQHV4O7JdKrF9rQwl06EajynPd/PMQ== Date: Tue, 11 Feb 2020 15:20:25 +0000 Message-ID: <20200211151947.26091-6-rasmus.villemoes@prevas.dk> References: <20200211151947.26091-1-rasmus.villemoes@prevas.dk> In-Reply-To: <20200211151947.26091-1-rasmus.villemoes@prevas.dk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR05CA0209.eurprd05.prod.outlook.com (2603:10a6:3:f9::33) 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: e3ff89b1-1db9-4ead-f21e-08d7af05eb8d x-ms-traffictypediagnostic: VI1PR10MB2141: x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:494; x-forefront-prvs: 0310C78181 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(376002)(346002)(396003)(366004)(39850400004)(136003)(199004)(189003)(36756003)(316002)(186003)(16526019)(71200400001)(2906002)(478600001)(956004)(2616005)(6486002)(26005)(6506007)(86362001)(6916009)(81156014)(81166006)(52116002)(6512007)(4326008)(8976002)(107886003)(5660300002)(66574012)(1076003)(54906003)(44832011)(8676002)(8936002)(66946007)(66556008)(66446008)(64756008)(66476007); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR10MB2141; 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: 2Pt2i2+Pjo8YcdnGxl4SM29aEXCXkfDbUy8yD7Zc9gFk/Dgdl7WCN310PrEurXOxsudcYu12tR/NrP2pEpyQi0kcPPLPTm2y5WaLWUKqnzaMiU6i8nHn8PVMvElDqVIMIuyf9+qsINjYmwVaB/jcsxvYwQ5F1mPiAam7E7McEIe0SLTrqIztknE+Of/F7aQMovUEOcQwlwrHtYp89YEwiYcibXOP4DGSN3DQ1Wg8EWOIDTc/0K3tJyFg0Oj7kOftw9fiE1UEqQa20MM0L50Z375Jbo8yT61gg60utSF1sQYQESnubeXaxElblXIG0SzWPC3h3YudP9SwSp89unHuggdjuSbZ0U4oXDPlZLiwTo3y63RMXsYV05KnIz8Q0bdSM4JQKcX0qMwcpLPsqyBZNsGcfaKtrV/05LklwvYObAE1INF493TUV8wQ5SXSGSSW x-ms-exchange-antispam-messagedata: SiUUIJGEhVZAsDywAj0RobSnjWbmyfEaOlzqhaNNyQyz2yrI9DxAznwyFF6o0tAu/Oos/oH9TQCJVHJ3YP0dFn4atZxJDM6J5FSuV8hPr+1s+cKwzaZVvXcQgAtbGLHLT5V2ImSBAbAHN+ADXoWWvA== Content-ID: MIME-Version: 1.0 X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: e3ff89b1-1db9-4ead-f21e-08d7af05eb8d X-MS-Exchange-CrossTenant-originalarrivaltime: 11 Feb 2020 15:20:25.9429 (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: Ny4YyaA/XnT9KKIEDrkJpGnM5zxaXyLKeg+E6IEWNWuF9scTF3KX06X16O0wITG8PbEVaL8+pbD7JfKgB8DVd6JhZk1X80HuQonj3DnrU8Q= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB2141 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.102.1 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; }