From patchwork Wed Sep 29 11:54:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zev Weiss X-Patchwork-Id: 12525323 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3C535C433F5 for ; Wed, 29 Sep 2021 11:58:07 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0B3C861409 for ; Wed, 29 Sep 2021 11:58:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0B3C861409 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bewilderbeest.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=KnW8WQ8ojL9wbTdtw1Dj2B4eg+P7jlhQ58Y+hJoNf20=; b=UEUTeknY8BXAnZ LXqTKRsDc6wpIkhy93+w/eP7bMS0D6tfDftMndw00PKXfbAEdwmIXdU/ePQ4E8n4tyBvBE1En6xGq iXZGOXob0Fy47Iwx1UY3SiarGJFQqBmAX212HL/5bYPULcIGFN1uZYM8lMMPAJNQVzBP27P5+2z9C qkrnxjn30Jnl4m0Bz8O7GtMdegltT6yXQ2DdkYkp+qOWLmySqDw1je7b/lNMWNdVKHGYYPvt6X+RS NmPz846mC+QavTUmqkMgEqzqfgLdk6TNbD2sgv6GjZPob5DgeUHLpNQ6hkNqIsryMsHTpyqaUmhGP kULUCnelNhanzGpABtvg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVYBs-00AuSu-K3; Wed, 29 Sep 2021 11:56:00 +0000 Received: from thorn.bewilderbeest.net ([2605:2700:0:5::4713:9cab]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVYAM-00AtwX-4d; Wed, 29 Sep 2021 11:54:29 +0000 Received: from hatter.bewilderbeest.net (71-212-29-146.tukw.qwest.net [71.212.29.146]) (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) (Authenticated sender: zev) by thorn.bewilderbeest.net (Postfix) with ESMTPSA id 5AD49C20; Wed, 29 Sep 2021 04:54:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bewilderbeest.net; s=thorn; t=1632916465; bh=gWhuqV+M1Tlbi05phPKIzczuXxjec79mm6Htp3ec2Fc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TPHBvzSoAHCSQnD3bL2UL4TNhvWQeplNlEAzdi66LW/EUSsZHaD8j+grZQ+lI2rPL eCkgGN+VYhA8AV5DkC4Shr4g/Hu70PSi+JCPV/MV1HNEtnkphvooWRgWmWSiRA5E23 67EO2AZnjt3cdiI2zXmGhZBitG81BlaRm1fHmeno= From: Zev Weiss To: openbmc@lists.ozlabs.org Cc: Greg Kroah-Hartman , Jeremy Kerr , Joel Stanley , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Zev Weiss , Tudor Ambarus , Michael Walle , Pratyush Yadav , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Andrew Jeffery , linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/6] mtd: spi-nor: aspeed: Refactor registration/unregistration Date: Wed, 29 Sep 2021 04:54:05 -0700 Message-Id: <20210929115409.21254-4-zev@bewilderbeest.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210929115409.21254-1-zev@bewilderbeest.net> References: <20210929115409.21254-1-zev@bewilderbeest.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210929_045426_262506_EDAB36C5 X-CRM114-Status: GOOD ( 21.28 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org We now have separate functions for registering and unregistering individual flash chips, instead of the entire controller. This is a preparatory step for allowing userspace to request that a specific chip be attached or detached at runtime. Signed-off-by: Zev Weiss --- drivers/mtd/spi-nor/controllers/aspeed-smc.c | 73 ++++++++++++-------- 1 file changed, 45 insertions(+), 28 deletions(-) diff --git a/drivers/mtd/spi-nor/controllers/aspeed-smc.c b/drivers/mtd/spi-nor/controllers/aspeed-smc.c index 7225870e8b18..3c153104a905 100644 --- a/drivers/mtd/spi-nor/controllers/aspeed-smc.c +++ b/drivers/mtd/spi-nor/controllers/aspeed-smc.c @@ -107,9 +107,10 @@ struct aspeed_smc_controller { const struct aspeed_smc_info *info; /* type info of controller */ void __iomem *regs; /* controller registers */ void __iomem *ahb_base; /* per-chip windows resource */ + struct resource *ahb_res; /* resource for AHB address space */ u32 ahb_window_size; /* full mapping window size */ - struct aspeed_smc_chip *chips[]; /* pointers to attached chips */ + struct aspeed_smc_chip *chips[]; /* pointers to connected chips */ }; /* @@ -399,15 +400,24 @@ static ssize_t aspeed_smc_write_user(struct spi_nor *nor, loff_t to, return len; } +static int aspeed_smc_unregister_chip(struct aspeed_smc_chip *chip) +{ + return mtd_device_unregister(&chip->nor.mtd); +} + static int aspeed_smc_unregister(struct aspeed_smc_controller *controller) { struct aspeed_smc_chip *chip; - int n; + int n, ret; for (n = 0; n < controller->info->nce; n++) { chip = controller->chips[n]; - if (chip) - mtd_device_unregister(&chip->nor.mtd); + if (chip) { + ret = aspeed_smc_unregister_chip(chip); + if (ret) + dev_warn(controller->dev, "failed to unregister CS%d: %d\n", + n, ret); + } } return 0; @@ -756,14 +766,39 @@ static const struct spi_nor_controller_ops aspeed_smc_controller_ops = { .write = aspeed_smc_write_user, }; -static int aspeed_smc_setup_flash(struct aspeed_smc_controller *controller, - struct device_node *np, struct resource *r) +static int aspeed_smc_register_chip(struct aspeed_smc_chip *chip) { - const struct spi_nor_hwcaps hwcaps = { + static const struct spi_nor_hwcaps hwcaps = { .mask = SNOR_HWCAPS_READ | SNOR_HWCAPS_READ_FAST | SNOR_HWCAPS_PP, }; + int ret; + + ret = aspeed_smc_chip_setup_init(chip, chip->controller->ahb_res); + if (ret) + goto out; + + /* + * TODO: Add support for Dual and Quad SPI protocols attach when board + * support is present as determined by of property. + */ + ret = spi_nor_scan(&chip->nor, NULL, &hwcaps); + if (ret) + goto out; + + ret = aspeed_smc_chip_setup_finish(chip); + if (ret) + goto out; + + ret = mtd_device_register(&chip->nor.mtd, NULL, 0); +out: + return ret; +} + +static int aspeed_smc_setup_flash(struct aspeed_smc_controller *controller, + struct device_node *np, struct resource *r) +{ const struct aspeed_smc_info *info = controller->info; struct device *dev = controller->dev; struct device_node *child; @@ -773,7 +808,6 @@ static int aspeed_smc_setup_flash(struct aspeed_smc_controller *controller, for_each_available_child_of_node(np, child) { struct aspeed_smc_chip *chip; struct spi_nor *nor; - struct mtd_info *mtd; /* This driver does not support NAND or NOR flash devices. */ if (!of_device_is_compatible(child, "jedec,spi-nor")) @@ -810,35 +844,17 @@ static int aspeed_smc_setup_flash(struct aspeed_smc_controller *controller, chip->cs = cs; nor = &chip->nor; - mtd = &nor->mtd; nor->dev = dev; nor->priv = chip; spi_nor_set_flash_node(nor, child); nor->controller_ops = &aspeed_smc_controller_ops; - ret = aspeed_smc_chip_setup_init(chip, r); - if (ret) - break; - - /* - * TODO: Add support for Dual and Quad SPI protocols - * attach when board support is present as determined - * by of property. - */ - ret = spi_nor_scan(nor, NULL, &hwcaps); - if (ret) - break; - - ret = aspeed_smc_chip_setup_finish(chip); - if (ret) - break; + controller->chips[cs] = chip; - ret = mtd_device_register(mtd, NULL, 0); + ret = aspeed_smc_register_chip(chip); if (ret) break; - - controller->chips[cs] = chip; } if (ret) { @@ -881,6 +897,7 @@ static int aspeed_smc_probe(struct platform_device *pdev) return PTR_ERR(controller->regs); res = platform_get_resource(pdev, IORESOURCE_MEM, 1); + controller->ahb_res = res; controller->ahb_base = devm_ioremap_resource(dev, res); if (IS_ERR(controller->ahb_base)) return PTR_ERR(controller->ahb_base); From patchwork Wed Sep 29 11:54:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zev Weiss X-Patchwork-Id: 12525331 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B281C433F5 for ; Wed, 29 Sep 2021 11:59:25 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E19F96124A for ; Wed, 29 Sep 2021 11:59:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E19F96124A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bewilderbeest.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=G5y6lFwN43EJX8/ONhyi4liqQAMLpOXTWi9eTtpXE2Y=; b=SiQA69oKeznUsY op4uzfY0xdknCzd7txlm3IDE9G0isyA//i5+zy9InGPu0ZvNjVAJoFxhVRS+dULgIqBCycMn8/AMq HBzusn+EBG+i1R6+M7KZNxL0aOK8yiEwkGIRodL+NvWBjWY5Sx+78Ysa2XbTvSx/u6YDG5BJ5dmDe ufHDtHIn1zWXy1DGOqoube8CjO/5dTUHe3h6QDWQ3zXV4QjlZ7q+9Gu7iBVl4MAGEFFq2cmWqFzVo l0MIFMw1hRk5jVlgvHNOuflLnD/MNSbgPvQQL+zPIht11g9sHgQ0G919rk10ftZto0Y5aiDQ4pJkl KetievGt1GZmKuh1s57w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVYD9-00Auu5-F6; Wed, 29 Sep 2021 11:57:20 +0000 Received: from thorn.bewilderbeest.net ([2605:2700:0:5::4713:9cab]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVYAP-00Atyc-1I; Wed, 29 Sep 2021 11:54:30 +0000 Received: from hatter.bewilderbeest.net (71-212-29-146.tukw.qwest.net [71.212.29.146]) (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) (Authenticated sender: zev) by thorn.bewilderbeest.net (Postfix) with ESMTPSA id 716C3C53; Wed, 29 Sep 2021 04:54:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bewilderbeest.net; s=thorn; t=1632916468; bh=R1j5OVnuaawARx/Lb+7fwJs4wNisTGf3IZegQlGAoXI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HH/p5S6hIH7hSeX9tW5puYJY+vGYxS34mcVMsTAgDy7++ub7A3jZ4QaCh0Eprp3qU joAq/DCFX+t1h2e2LUCYdtsPSrw36FErbV1vTgKxuFPuOS5/FWOYOPbNqSy+g1SbyW K8eZWPDr/29Fh6fJAd5JWm0QFX+Rh9FinrBtpD+Y= From: Zev Weiss To: openbmc@lists.ozlabs.org Cc: Greg Kroah-Hartman , Jeremy Kerr , Joel Stanley , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Zev Weiss , Andrew Jeffery , Tudor Ambarus , Michael Walle , Pratyush Yadav , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org Subject: [PATCH 4/6] mtd: spi-nor: aspeed: Allow attaching & detaching chips at runtime Date: Wed, 29 Sep 2021 04:54:06 -0700 Message-Id: <20210929115409.21254-5-zev@bewilderbeest.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210929115409.21254-1-zev@bewilderbeest.net> References: <20210929115409.21254-1-zev@bewilderbeest.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210929_045429_133699_5466D275 X-CRM114-Status: GOOD ( 22.77 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org There are now two new sysfs attributes, attach_chip and detach_chip, into which a chip select number can be written to attach or detach the corresponding chip. Signed-off-by: Zev Weiss --- .../ABI/stable/sysfs-driver-aspeed-smc | 17 +++ drivers/mtd/spi-nor/controllers/aspeed-smc.c | 101 +++++++++++++++++- 2 files changed, 115 insertions(+), 3 deletions(-) create mode 100644 Documentation/ABI/stable/sysfs-driver-aspeed-smc diff --git a/Documentation/ABI/stable/sysfs-driver-aspeed-smc b/Documentation/ABI/stable/sysfs-driver-aspeed-smc new file mode 100644 index 000000000000..871b4d65ccb2 --- /dev/null +++ b/Documentation/ABI/stable/sysfs-driver-aspeed-smc @@ -0,0 +1,17 @@ +What: /sys/bus/platform/drivers/aspeed-smc/*/attach_chip +Date: September 2021 +Contact: Zev Weiss +Description: A chip select number may be written into this file to + request that the corresponding chip be attached by the + driver. +Users: OpenBMC. Proposed changes should be mailed to + openbmc@lists.ozlabs.org + +What: /sys/bus/platform/drivers/aspeed-smc/*/detach_chip +Date: September 2021 +Contact: Zev Weiss +Description: A chip select number may be written into this file to + request that the corresponding chip be detached by the + driver. +Users: OpenBMC. Proposed changes should be mailed to + openbmc@lists.ozlabs.org diff --git a/drivers/mtd/spi-nor/controllers/aspeed-smc.c b/drivers/mtd/spi-nor/controllers/aspeed-smc.c index 3c153104a905..da49192a8220 100644 --- a/drivers/mtd/spi-nor/controllers/aspeed-smc.c +++ b/drivers/mtd/spi-nor/controllers/aspeed-smc.c @@ -91,6 +91,7 @@ struct aspeed_smc_controller; struct aspeed_smc_chip { int cs; + bool attached; struct aspeed_smc_controller *controller; void __iomem *ctl; /* control register */ void __iomem *ahb_base; /* base of chip window */ @@ -402,7 +403,15 @@ static ssize_t aspeed_smc_write_user(struct spi_nor *nor, loff_t to, static int aspeed_smc_unregister_chip(struct aspeed_smc_chip *chip) { - return mtd_device_unregister(&chip->nor.mtd); + int ret = -ENOENT; + mutex_lock(&chip->controller->mutex); + if (chip->attached) { + ret = mtd_device_unregister(&chip->nor.mtd); + if (!ret) + chip->attached = false; + } + mutex_unlock(&chip->controller->mutex); + return ret; } static int aspeed_smc_unregister(struct aspeed_smc_controller *controller) @@ -412,7 +421,7 @@ static int aspeed_smc_unregister(struct aspeed_smc_controller *controller) for (n = 0; n < controller->info->nce; n++) { chip = controller->chips[n]; - if (chip) { + if (chip && chip->attached) { ret = aspeed_smc_unregister_chip(chip); if (ret) dev_warn(controller->dev, "failed to unregister CS%d: %d\n", @@ -775,6 +784,13 @@ static int aspeed_smc_register_chip(struct aspeed_smc_chip *chip) }; int ret; + mutex_lock(&chip->controller->mutex); + + if (chip->attached) { + ret = -EEXIST; + goto out; + } + ret = aspeed_smc_chip_setup_init(chip, chip->controller->ahb_res); if (ret) goto out; @@ -792,7 +808,12 @@ static int aspeed_smc_register_chip(struct aspeed_smc_chip *chip) goto out; ret = mtd_device_register(&chip->nor.mtd, NULL, 0); + if (ret) + goto out; + + chip->attached = true; out: + mutex_unlock(&chip->controller->mutex); return ret; } @@ -865,6 +886,72 @@ static int aspeed_smc_setup_flash(struct aspeed_smc_controller *controller, return ret; } +static inline struct aspeed_smc_controller *to_aspeed_smc_controller(struct device *dev) +{ + struct platform_device *pdev = container_of(dev, struct platform_device, dev); + return platform_get_drvdata(pdev); +} + +static ssize_t attach_chip_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + unsigned long cs; + struct aspeed_smc_controller *controller; + struct aspeed_smc_chip *chip; + ssize_t ret = kstrtoul(buf, 0, &cs); + if (ret) + return ret; + + controller = to_aspeed_smc_controller(dev); + if (cs >= controller->info->nce) + return -EINVAL; + + chip = controller->chips[cs]; + + if (!chip) + return -ENODEV; + + ret = aspeed_smc_register_chip(chip); + + return ret ? ret : count; +} +static DEVICE_ATTR_WO(attach_chip); + +static ssize_t detach_chip_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) +{ + unsigned long cs; + struct aspeed_smc_controller *controller; + struct aspeed_smc_chip *chip; + ssize_t ret = kstrtoul(buf, 0, &cs); + if (ret) + return ret; + + controller = to_aspeed_smc_controller(dev); + if (cs >= controller->info->nce) + return -EINVAL; + + chip = controller->chips[cs]; + + if (!chip) + return -ENODEV; + + ret = aspeed_smc_unregister_chip(chip); + + return ret ? ret : count; +} +static DEVICE_ATTR_WO(detach_chip); + +static struct attribute *aspeed_smc_sysfs_attrs[] = { + &dev_attr_attach_chip.attr, + &dev_attr_detach_chip.attr, + NULL, +}; + +static const struct attribute_group aspeed_smc_sysfs_attr_group = { + .attrs = aspeed_smc_sysfs_attrs, +}; + static int aspeed_smc_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -905,8 +992,16 @@ static int aspeed_smc_probe(struct platform_device *pdev) controller->ahb_window_size = resource_size(res); ret = aspeed_smc_setup_flash(controller, np, res); - if (ret) + if (ret) { dev_err(dev, "Aspeed SMC probe failed %d\n", ret); + return ret; + } + + ret = devm_device_add_group(dev, &aspeed_smc_sysfs_attr_group); + if (ret) { + dev_err(dev, "Failed to create sysfs files\n"); + aspeed_smc_unregister(controller); + } return ret; } From patchwork Wed Sep 29 11:54:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zev Weiss X-Patchwork-Id: 12525333 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27BCEC433EF for ; Wed, 29 Sep 2021 12:01:31 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id EDFD96124A for ; Wed, 29 Sep 2021 12:01:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EDFD96124A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bewilderbeest.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cfwGSw0aaSveziKJRUq9k0RzYlXLPuEeIJN+S4g4XE8=; b=Q2yBFTWrcLXoQ8 b5xv+P8H67kFYV9fyePLAXPddDVlNF61xkXDq6LIoFhj0oD9nR7990YSbOIBjXSyh0JXeTBWoM3OG 3HveYwBB0wc32C9aUU2sS1yufajOjIf9SPj4SzKrB2yai4Ylzg3m8HNBiW8NrIgnmthNAY39D+RSC jYsx/c6EB4uc3Q108nI07cKP04AaD6hcPMa84/agAMGdqHjg5/wJrVm/hYrjzEOHZifmbPqoyfy4/ qIYXcX5jh8HRkyk0pItaqcOogg3rWShTlTxBBMkxQLucEjY3iKo0rmdTipccJpOf9xjtIsMuXR3hc fd7K2eCT4M9TjBNS9BCQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVYF2-00AvbZ-TU; Wed, 29 Sep 2021 11:59:17 +0000 Received: from thorn.bewilderbeest.net ([2605:2700:0:5::4713:9cab]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVYAQ-00Atzb-Ge; Wed, 29 Sep 2021 11:54:32 +0000 Received: from hatter.bewilderbeest.net (71-212-29-146.tukw.qwest.net [71.212.29.146]) (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) (Authenticated sender: zev) by thorn.bewilderbeest.net (Postfix) with ESMTPSA id E8698C81; Wed, 29 Sep 2021 04:54:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bewilderbeest.net; s=thorn; t=1632916470; bh=Y009K+RO8RDHvkwOXnnVGdcXcV27deDObF+gK4oQAV0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e1JR3ccgRHn33ud6tMgC1CMeeRisKIlAAgrBRm7eb6hSGpyGrdolKwcy7HVnjgYQk PNAz2XS/8sH8jKzNjRq3hHsPjLgkukc3El2ZdjBfGCg1RbDxoUuzgZfUkDPi+piwd/ RC1TN5yznTetYwWE5qOhl0+22V/KcVmBL31QXIEc= From: Zev Weiss To: openbmc@lists.ozlabs.org Cc: Greg Kroah-Hartman , Jeremy Kerr , Joel Stanley , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Zev Weiss , Tudor Ambarus , Michael Walle , Pratyush Yadav , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Andrew Jeffery , linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/6] mtd: spi-nor: aspeed: Don't automatically attach reserved chips Date: Wed, 29 Sep 2021 04:54:07 -0700 Message-Id: <20210929115409.21254-6-zev@bewilderbeest.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210929115409.21254-1-zev@bewilderbeest.net> References: <20210929115409.21254-1-zev@bewilderbeest.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210929_045430_601407_ABA5B8A0 X-CRM114-Status: GOOD ( 15.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org With this change, any flash chips under the controller that are marked with a DT status of "reserved" will be created, but not automatically attached. Userspace can later request that they be attached using the attach_chip sysfs file. This is to accommodate situations where a chip may be (for example) shared with another controller external to the SoC and require userspace to arbitrate access to it prior to actually attaching it. (such as a firmware SPI flash shared between a BMC and the host system). Signed-off-by: Zev Weiss --- drivers/mtd/spi-nor/controllers/aspeed-smc.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/mtd/spi-nor/controllers/aspeed-smc.c b/drivers/mtd/spi-nor/controllers/aspeed-smc.c index da49192a8220..328b008fafb2 100644 --- a/drivers/mtd/spi-nor/controllers/aspeed-smc.c +++ b/drivers/mtd/spi-nor/controllers/aspeed-smc.c @@ -826,10 +826,14 @@ static int aspeed_smc_setup_flash(struct aspeed_smc_controller *controller, unsigned int cs; int ret = -ENODEV; - for_each_available_child_of_node(np, child) { + for_each_child_of_node(np, child) { struct aspeed_smc_chip *chip; struct spi_nor *nor; + /* Skip disabled nodes, but include reserved ones for later attachment */ + if (!of_device_is_available(child) && !of_device_is_reserved(child)) + continue; + /* This driver does not support NAND or NOR flash devices. */ if (!of_device_is_compatible(child, "jedec,spi-nor")) continue; @@ -873,6 +877,9 @@ static int aspeed_smc_setup_flash(struct aspeed_smc_controller *controller, controller->chips[cs] = chip; + if (of_device_is_reserved(child)) + continue; + ret = aspeed_smc_register_chip(chip); if (ret) break; From patchwork Wed Sep 29 11:54:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zev Weiss X-Patchwork-Id: 12525335 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9AA05C433EF for ; Wed, 29 Sep 2021 12:02:50 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 6DDAD613D1 for ; Wed, 29 Sep 2021 12:02:50 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6DDAD613D1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=bewilderbeest.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=DOXchE2D9jAtceUcEglECJvwUE4wlxSm7pmkgvzDksI=; b=hXZj0Pw2WLccQ0 MvPy9UKlQlS6qoi/G5UUv1PidAbao2u+sQsfkEoQNlrxdaNDHqCxXcfEJBz1cgWaSVFeGYxC8+Hs4 IXqS+3tncPPvKL8SdtqZEufo1/cyAz8A6LWxS5leZ69H3qbIMARUg4ywBtJpLKf7Mmujup7fx/KIf 7M2FLLMd19/4l0XUjKx06XqLJ2TyQfPxwftSEvNZqyakRRAxLtW8W1+cs2rwmbChyzi+YTCzpICGw a0fYMgLtq15D7KuTbDZr5IT9lM6bDjZfexyeImG4jIK2TzMDkMo85hrSCJDc49iqBGW0Ho3qAFKqK UO+u6VdlE3obolq3W59g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVYG6-00Avwk-7K; Wed, 29 Sep 2021 12:00:22 +0000 Received: from thorn.bewilderbeest.net ([71.19.156.171]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mVYAS-00Atzv-Q0 for linux-arm-kernel@lists.infradead.org; Wed, 29 Sep 2021 11:54:34 +0000 Received: from hatter.bewilderbeest.net (71-212-29-146.tukw.qwest.net [71.212.29.146]) (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) (Authenticated sender: zev) by thorn.bewilderbeest.net (Postfix) with ESMTPSA id 87F68C85; Wed, 29 Sep 2021 04:54:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bewilderbeest.net; s=thorn; t=1632916470; bh=8ZmLBz7D/sbq84QJ7vQOxYGraYtGThjNvOcKVo+RF4o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gZgRjbpv0EC0S8V6wVnuUrHB5EN8Kfa4AFQZWHAkb5f5F/Xz8UtB18GhLfgYS1rh5 w0H9GjeVe/tPLZ/i1gucxKd3zp6DisjwE002E7lZNvgCjWkrnzKMf8dMiujx8cku4x 4YQOmo/egYbTKBldqdgY4iIZn/42OhmBn8z6w7dU= From: Zev Weiss To: openbmc@lists.ozlabs.org Cc: Greg Kroah-Hartman , Jeremy Kerr , Joel Stanley , =?utf-8?q?C=C3=A9dric_Le_Goater?= , Zev Weiss , Rob Herring , Andrew Jeffery , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-aspeed@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/6] ARM: dts: aspeed: Add e3c246d4i BIOS flash device Date: Wed, 29 Sep 2021 04:54:08 -0700 Message-Id: <20210929115409.21254-7-zev@bewilderbeest.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210929115409.21254-1-zev@bewilderbeest.net> References: <20210929115409.21254-1-zev@bewilderbeest.net> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210929_045432_901321_322397F9 X-CRM114-Status: GOOD ( 11.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Signed-off-by: Zev Weiss --- .../arm/boot/dts/aspeed-bmc-asrock-e3c246d4i.dts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/arch/arm/boot/dts/aspeed-bmc-asrock-e3c246d4i.dts b/arch/arm/boot/dts/aspeed-bmc-asrock-e3c246d4i.dts index 9b4cf5ebe6d5..456f4de53869 100644 --- a/arch/arm/boot/dts/aspeed-bmc-asrock-e3c246d4i.dts +++ b/arch/arm/boot/dts/aspeed-bmc-asrock-e3c246d4i.dts @@ -68,6 +68,22 @@ flash@0 { }; }; +&spi1 { + status = "okay"; + pinctrl-names = "default"; + pinctrl-0 = <&pinctrl_spi1_default>; + flash@0 { + /* + * The BIOS SPI flash is shared with the host via an + * external mux, and is not accessible by the BMC by + * default (hence "reserved" rather than "okay"). + */ + status = "reserved"; + label = "bios"; + m25p,fast-read; + }; +}; + &uart5 { status = "okay"; };