From patchwork Tue Aug 6 11:41:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 817890 Received: from mail-wm1-f48.google.com (mail-wm1-f48.google.com [209.85.128.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 100ED1C379B; Tue, 6 Aug 2024 11:41:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722944491; cv=none; b=qWM0NQO+UVj03WZSIwfWJYyZva32876u51+Odmf/vnvh9FWpQXElmnriU+okkKTIkwlUBN078ndWc6bOlW7Bwa/AQo4KL38Rvusb5VydaGnSZD4LazfwD+6FwgShrKnPw6oBbZEsr7D/dUCo7DkFisSywcyHciHIa2ArJjHuAkY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722944491; c=relaxed/simple; bh=5LbPMzmNGfuxlauoWeKMsm0e6brfLsdQfHcfl/8nZRs=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PcnY/LcRZHlIXbkwDmOj8s0Jd04thTFnx4TQCU5a+QK9AxT/7bShSre4n4/dXy1LA0KlWr1LoDFJGspUqtdGkjCJynemKwPs6a/C4ygVIZ5XcrG8E/s8LlJhNn8F1bd0lnZMDF1vdM4h2C8zZxoQiEQVeri+bQJM0ZWtrBGDsoI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=SfYlrGrv; arc=none smtp.client-ip=209.85.128.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SfYlrGrv" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-428ec6c190eso4174025e9.1; Tue, 06 Aug 2024 04:41:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722944488; x=1723549288; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=N4Tqx/xl+do4nmfv0ZFIXdX55krJHtI/dy8e3uyNR1Y=; b=SfYlrGrv9pOqbDSGHmgF4N5PrTk48HWGv2flq8QJdvaGbbX7YBTro1ZCkiVgBSCw9E +8y/CaA+JXDfNOLE0oC0oNHLszUjRp+qyuUWzTFPj+6Y8NB2lj6Wpj85uAgidYWNhYAl qJQR7/wRWQypwA1x8eWetAEotB6MAwxoDcnP5JWQGeCLTr6WOd4xhWFFBgzxM73URpdE y72lbp5XAFSt+VwOTm+vmrw8v6p1ynDZv3D5Zl5DaV3EEvNTzqseZo9Cmr/Q7rpRz7Qd dvcDjx7QcwBmDRuMvqQYbkEHdz74hSgq72t0uauo6MvbKq6Gsta2inPWqstJXGO5imNT heIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722944488; x=1723549288; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=N4Tqx/xl+do4nmfv0ZFIXdX55krJHtI/dy8e3uyNR1Y=; b=eEk8RvPyd39thDwTnz8bkCDWixE3aBlLX0ZiQfFk40U8XbPzOX9yMIThW36kN2a2qt cjJk9R7IyVReylhDe2BsAOIe3627KeUcBdEJIShHAoh7Bbsvd6fK4pTQphKLjNmTQKZW jXXz/mkA+I5pDkRqMl3X50eVdOR1JVz5KSLkLbB7o4T8scgC8MQXEHX/82XP8pwk9Dkh 1UdBRb+9Altd/voe5F87cngvvsmLsIG0uEb+8CysjQZddKdF/QyPlh+ebjMAG+4g4KgR I0shgBsBlGsUx8fonO4/prLnJwP544AuUwGf01/FcvglC9GccFnBHdQokfre4U0Xl9Pf CWrA== X-Forwarded-Encrypted: i=1; AJvYcCVfc4qKFFTTsgsf2iVDB0aGVnFxH1pe6q2Hg47pSSglRGWiF2RdWLDzglRiRVE4j63pKFyIr15EAi8mQ48iOAV1/dLWQhEVAL/PcaZWfYGPocVP6eKB26AO+6A2DAa434tgRCLsJpEhkANUXTIvLUV63LMI/P/VOnnc/98l/ZH8HxSB8A== X-Gm-Message-State: AOJu0YxuPHLwJhrgSbvc5w7XFIN2nPeU0+FLzBvi3NrO0Woqn7Z36Ebr RrArElpGkkZJFibXf5aiV+7WzLi1Pxwao+3Gwrp+kib3s61PEY1w X-Google-Smtp-Source: AGHT+IG9k8L6rRkA1Va2sD8UO032mLhZSWZwsxwXlldLySXDGaw0sRlChwet0LU+bpg2jQOFstrw/Q== X-Received: by 2002:a05:600c:4f0c:b0:426:6099:6eaa with SMTP id 5b1f17b1804b1-428e6b7c61emr101771725e9.26.1722944488151; Tue, 06 Aug 2024 04:41:28 -0700 (PDT) Received: from localhost.localdomain (host-87-6-196-30.retail.telecomitalia.it. [87.6.196.30]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-428e6e7cce6sm176105845e9.31.2024.08.06.04.41.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Aug 2024 04:41:27 -0700 (PDT) From: Christian Marangi To: Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Joern Engel , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Christian Marangi , Wolfram Sang , Florian Fainelli , Thomas Bogendoerfer , linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-nvme@lists.infradead.org Subject: [PATCH v3 1/6] dt-bindings: nvme: Document nvme-card compatible Date: Tue, 6 Aug 2024 13:41:11 +0200 Message-ID: <20240806114118.17198-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806114118.17198-1-ansuelsmth@gmail.com> References: <20240806114118.17198-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Document new nvme-card compatible to permit defining fixed-partition in DT by the use of the block2mtd module to use block devices as MTD. Signed-off-by: Christian Marangi --- .../devicetree/bindings/nvme/nvme-card.yaml | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 Documentation/devicetree/bindings/nvme/nvme-card.yaml diff --git a/Documentation/devicetree/bindings/nvme/nvme-card.yaml b/Documentation/devicetree/bindings/nvme/nvme-card.yaml new file mode 100644 index 000000000000..20e9a877fac4 --- /dev/null +++ b/Documentation/devicetree/bindings/nvme/nvme-card.yaml @@ -0,0 +1,78 @@ +# SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/nvme/nvme-card.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NVME Card + +maintainers: + - Christian Marangi + +description: | + This documents describes the devicetree bindings for a NVME controller + child node describing a nvme-card. + +properties: + compatible: + const: nvme-card + + partitions: + $ref: /schemas/mtd/partitions/partitions.yaml + +required: + - compatible + +additionalProperties: false + +examples: + - | + pcie { + #address-cells = <3>; + #size-cells = <2>; + + bridge@0,0 { + reg = <0x00000000 0 0 0 0>; + #address-cells = <3>; + #size-cells = <2>; + ranges; + + nvme@1,0 { + compatible = "pci144d,a809"; + + reg = <0x00010000 0 0 0 0>; + #address-cells = <1>; + #size-cells = <1>; + + card { + compatible = "nvme-card"; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + bootloader@0 { + label = "bootloader"; + reg = <0x00000000 0x00080000>; + }; + + tclinux@80000 { + label = "tclinux"; + reg = <0x00080000 0x02800000>; + }; + + tclinux_slave@2880000 { + label = "tclinux_slave"; + reg = <0x02880000 0x02800000>; + }; + + rootfs_data@5080000 { + label = "rootfs_data"; + reg = <0x5080000 0x00800000>; + }; + }; + }; + }; + }; + }; From patchwork Tue Aug 6 11:41:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 817280 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E69EA1C3F2C; Tue, 6 Aug 2024 11:41:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722944493; cv=none; b=N8roDKo0EDHum8QCwnSgex9CyONs1a2MVpXVXzHZ5v/v4XVUmT7TJ+MZPzqtIdcOO0hXdVGAIt9LxRyv2JtFRwIgFGFSXF5E/3xpqfnNr8MpmMxMYRJwmrtN1slqV8Ne7YUsmwz3cdbnbsKbDLeMiUFv2clw+wuAOhA19jHROgk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722944493; c=relaxed/simple; bh=P6tl98PPpFGrbbFj5w75g3BxJxNbMlbPQduy4dlyBE0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mT9xtADyxo+rSieiy+/iGEANAfliY8MplwjCrbrdOyZTq6PRQFNQOpuuK6ZRJle9tAW6fsSaGimp+KyhDtkywctQFYsrO23VZY66Cumnmq9JbVEMZ+8kCZPnPSOQnCtBAkFnkE9oPvfbjpIhSGQZ+D6GPbcbQJQHj23l+fFrqXs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=IlsxkO35; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IlsxkO35" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4281ca54fd3so3160305e9.2; Tue, 06 Aug 2024 04:41:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722944490; x=1723549290; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=NJElgdSeo7tFBhUWI5Y2VGkmcaarTUGB2bJhxj7nOts=; b=IlsxkO35R39MJI3q2cdhscPqaXtUIF8NJR9IKamgR+h+NkdpvrpY5+ZE9Lx4rDAbK8 MiStfcMssn/tW432x2crwMHx98OSHGTLnpEPDCdpdXXcF9PxiK5OyhjF2cV9ZAwFZpFA l3KKscn0YpeMhLlHGtz/U/psVFoSZdWnwRu4UbwgE2CJDF2NXRMiRaEK3fKmPcKCEExD 1gXoTcg0fbLZov3LZT4M6wnIp1+4DKD5H5DPY6EzWlHeSpbJr39yDJYMHjhMNZcUGjIx RVfYMAuzr/dfqfC+s9mZou4q5GRAgvM18R3EVw+4HQaoUB91tPQGdD7CeH658RiZL+F+ AIpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722944490; x=1723549290; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NJElgdSeo7tFBhUWI5Y2VGkmcaarTUGB2bJhxj7nOts=; b=A4e5fhDYv/8cWPNDs4oCRIquAUcL83cwVtPxqgfAmxbipCBLsE9/1MrHnPun+yjiYI SyaNsH4jZzk4opbvu6wrMnKqISHGEspZPqThwPL21dWt3i0kEe0gcvMxVFcTV+ZMw36L Ylx9rRX0uzIMopP5RpHI2Ih/AR1dNRxl/exZVXyrmj87s+i0D2nJ2K4mHZoMgQhpMakp Fi0XcU/3AblAbE20tGq0oR3U5KKKnLBHv4IiI1nqLPr4VSahnoNSAiGoGWZVk7nJvSnW 0bdqRKXp5qpAbHF39UxCiNgDnadAb2it43i1pQgI76A8YYHVmo/NspcWtZvptHxqy+ok Odcg== X-Forwarded-Encrypted: i=1; AJvYcCVq6T+roemixXKMJXh4Q0i1LqFKDSkQX6e0d8QQiVMu0KR5Y1wUxSxhxFCuVnLUUBklBsGBno7hZgc5ci/9LximnrFKnRYOwLWGEO9UG5znIC2raEwKpn6AhEsJZVD1t072sDTx4ypaw3YnC79S84YOmHkcaMJekKqh54du536F6cm1jA== X-Gm-Message-State: AOJu0Yw+dHxoM5W6m3E3PwNMJk2AZ1rGQuC8740woqWdywOOBv+xgY5F S8ZSfK2UOilqU/5gXiYGTKAQc6e7U+h0ByQWOo2ftk+kzHHAroif X-Google-Smtp-Source: AGHT+IHsLBFQO+J/lS62zM2qc6hKgOhyDSFxfwIUq3wJKk0pA9FyD5Jiwj6/3xBLV/JtPtreeeXWCw== X-Received: by 2002:a05:600c:4e87:b0:426:60b8:d8ba with SMTP id 5b1f17b1804b1-428e6b7cab3mr105454325e9.28.1722944490056; Tue, 06 Aug 2024 04:41:30 -0700 (PDT) Received: from localhost.localdomain (host-87-6-196-30.retail.telecomitalia.it. [87.6.196.30]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-428e6e7cce6sm176105845e9.31.2024.08.06.04.41.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Aug 2024 04:41:29 -0700 (PDT) From: Christian Marangi To: Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Joern Engel , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Christian Marangi , Wolfram Sang , Florian Fainelli , Thomas Bogendoerfer , linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-nvme@lists.infradead.org Subject: [PATCH v3 2/6] nvme: assign of_node to nvme device Date: Tue, 6 Aug 2024 13:41:12 +0200 Message-ID: <20240806114118.17198-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806114118.17198-1-ansuelsmth@gmail.com> References: <20240806114118.17198-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Introduce support for a dedicated node for a nvme card. This will be a subnode of the nvme controller node that will have the "nvme-card" compatible. This follow a similar implementation done for mmc where the specific mmc card have a dedicated of_node. This can be used for scenario where block2mtd module is used to declare partition in DT and block2mtd is called on the root block of the nvme card, permitting the usage of fixed-partition parser or alternative ones. Signed-off-by: Christian Marangi --- drivers/nvme/host/core.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 053d5b4909cd..344523274d1b 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -4651,6 +4652,7 @@ void nvme_uninit_ctrl(struct nvme_ctrl *ctrl) nvme_hwmon_exit(ctrl); nvme_fault_inject_fini(&ctrl->fault_inject); dev_pm_qos_hide_latency_tolerance(ctrl->device); + of_node_put(ctrl->device->of_node); cdev_device_del(&ctrl->cdev, ctrl->device); nvme_put_ctrl(ctrl); } @@ -4771,6 +4773,8 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev, else ctrl->device->groups = nvme_dev_attr_groups; ctrl->device->release = nvme_free_ctrl; + ctrl->device->of_node = of_get_compatible_child(ctrl->dev->of_node, + "nvme-card"); dev_set_drvdata(ctrl->device, ctrl); return ret; From patchwork Tue Aug 6 11:41:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 817889 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2DC181C461B; Tue, 6 Aug 2024 11:41:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722944495; cv=none; b=eKFBsZGviOX54W6k9f6KG27sUV+1RyktWZ4axuvwdBqwC1mGKLXU1dP77pGXGmVJGZVOv1aSVvIO7RVplhAbyD8Ub7rhXRgnK/v7jPSEfl+auC1chCFH9oqnZ7cPLw7YZuBUSotYg0RLYaLxOix1XJ4LweoX5R9Ds/OS04MthnI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722944495; c=relaxed/simple; bh=0sysWhwNmnNKfHFiwRVWuNqKt3+jxEFZ3zFpJ5/W2Kg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UOXqt5ZfaA/DcCQGkjNkgp5Mt6/C7UXS9FSJ+9Hebzc9H8swC0XZlbOIjE9EAYNlhgZY4iMOhzWWiKmXkzDLJXHpvhW2D57J7g37gdn6rmQ/KaCOXl8ThvqLU6su8ZlIoxQXnmp8eSmwRWXbBMVNWqun/322TUVGSyRxK/GjxjY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=YVO514SC; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YVO514SC" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-428e3129851so3317085e9.3; Tue, 06 Aug 2024 04:41:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722944492; x=1723549292; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=zJtL0MfF3HGZoWE7QS0/OcrDoRKxdV59VhkJ0rmXwsw=; b=YVO514SCcXQcVb+A5DWSR3SKze1Z5TYuxyUkV4w+sElvFaJ6Y/RGCcNzIYfBQmHvtr /XiaOLX5XMm9pUz3Ws9JfOYduIxpLj2wdzAy9EsfceHYtYS4tuo5gfqRAFtmbNIvrwki j7B+VkpRLxMXy3oLmcdt0O93P5rBY0hsWTyZOR1mFTHB5OvTaS1Ifgqe4m7dOniSoora Ltjq2Hge4GCTEVqV2tZb/Jh58SvmOr7vPjLhpp/I5jHCetwd8HH/2AkNAXA99ucPXPfr ThdSh+1NCxnQ+skEuC0/O2SlHNxQ0WDQHl18VzBrpLnqgXCcphWPIecPQU0CZyMuRy9A Xe6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722944492; x=1723549292; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zJtL0MfF3HGZoWE7QS0/OcrDoRKxdV59VhkJ0rmXwsw=; b=bHcM0TnP1fnEfksEhqQDL6KGkfZq3pVRqA1jKdgoOQcYiCISpEzWU+NJWHDpAVr2UE /+sE1Qfu0RmYhGg9aLR+4XUKGPMAAYHKQUldNG7Yfs7KW/RwveelboWXNKqiwREG8WRH Ouz58z9ADVtI0xpBO/1rLWNq5Azhoe4b2G/oCo7noH6VqssZi5UCFpkr0VvW8uz8OMPL n0tAxY3XV/qCnQ6pGNjqnH5qgh3cjAc5jF6mICwwLh7I6hLruF3f2A1Tq8Ezj+Zh9fZj tehIKFR793WN5LHBcPVi0snZe2tD0R63GXaQTMqnt/J3IZImc0VhbXUP7QaljIiewbTo sOCQ== X-Forwarded-Encrypted: i=1; AJvYcCWr39QD4inqM+FM06jjfV0IMrtvlHfie7tXicH1YELUijLGvj5mTqzYRjKlPQCm8+r6N47fTdtr+fG2BOpFRiILoFmgjVeac2KUOotkuVg5a5p/We88mZ8Lxzvjb4ybVyj//u59oPb1tf1l+rDZxSBupudZF0b/O7PwSdPFAPO4HWwv2A== X-Gm-Message-State: AOJu0YywnK3dNwS3VgR9S6tpyDlQWPHdJ6Pusypb50/2EDaZM1dicg1C BcbJKTrbD9SLpoQX+7bsUZZie7mWWcRGZbn6+AgfC9F7CSRZR7yv X-Google-Smtp-Source: AGHT+IEtsLb9ubCDZAG9HKspu+Ejg5Bny2dpdCF+3riHPRWpHuMWqRmG9LivPX6D4Zet1J/ot/MWyg== X-Received: by 2002:a05:600c:1d89:b0:426:6a5e:73c5 with SMTP id 5b1f17b1804b1-428e6b92d50mr97449265e9.37.1722944492093; Tue, 06 Aug 2024 04:41:32 -0700 (PDT) Received: from localhost.localdomain (host-87-6-196-30.retail.telecomitalia.it. [87.6.196.30]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-428e6e7cce6sm176105845e9.31.2024.08.06.04.41.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Aug 2024 04:41:31 -0700 (PDT) From: Christian Marangi To: Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Joern Engel , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Christian Marangi , Wolfram Sang , Florian Fainelli , Thomas Bogendoerfer , linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-nvme@lists.infradead.org Subject: [PATCH v3 3/6] dt-bindings: mmc: add property for partitions node in mmc-card node Date: Tue, 6 Aug 2024 13:41:13 +0200 Message-ID: <20240806114118.17198-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806114118.17198-1-ansuelsmth@gmail.com> References: <20240806114118.17198-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add property for defining partitions node in mmc-card node to define partitions in DT by the use of the block2mtd module to use block devices as MTD. Signed-off-by: Christian Marangi --- .../devicetree/bindings/mmc/mmc-card.yaml | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/Documentation/devicetree/bindings/mmc/mmc-card.yaml b/Documentation/devicetree/bindings/mmc/mmc-card.yaml index fd347126449a..0f32d24417bc 100644 --- a/Documentation/devicetree/bindings/mmc/mmc-card.yaml +++ b/Documentation/devicetree/bindings/mmc/mmc-card.yaml @@ -26,6 +26,9 @@ properties: Use this to indicate that the mmc-card has a broken hpi implementation, and that hpi should not be used. + partitions: + $ref: /schemas/mtd/partitions/partitions.yaml + required: - compatible - reg @@ -45,4 +48,41 @@ examples: }; }; + mmc1 { + #address-cells = <1>; + #size-cells = <0>; + + card@0 { + compatible = "mmc-card"; + reg = <0>; + broken-hpi; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + bootloader@0 { + label = "bootloader"; + reg = <0x00000000 0x00080000>; + }; + + tclinux@80000 { + label = "tclinux"; + reg = <0x00080000 0x02800000>; + }; + + tclinux_slave@2880000 { + label = "tclinux_slave"; + reg = <0x02880000 0x02800000>; + }; + + rootfs_data@5080000 { + label = "rootfs_data"; + reg = <0x5080000 0x00800000>; + }; + }; + }; + }; + ... From patchwork Tue Aug 6 11:41:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 817279 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB6191C4630; Tue, 6 Aug 2024 11:41:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722944497; cv=none; b=tzQqGwVcxHt6XZv6IT0j6MfPvHJlKZ5PJHGaK0iQcj+4UL9uanPdSePVHUyacjZkAmkXJCCV6qMiCn+KH4y+jMRN1lmkzNdSopynnZ+f//ErwJD/xh2kyU3cYPIU0/M+1uNfHiTqG16kn1RqZmQQL+Q0IHX0eMPwbZWEAZX5Ijk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722944497; c=relaxed/simple; bh=i39wCXbk/q1Tvo8ZjWFPqjdA9TSVJhHTaL2sBpHLfj4=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=knWqNWVpGWBMD6+i0GQofRQDIKHIGiRiaeDVfpIjbvR0b0IOL9LOKdu/1K35ic/1SuagdIUFo/wuTqoihHTa52bqYfOlE7Kx7jN3bsJMyReFsIplf1kzX0L5AHZ0Ms3i03Dn3pQnc22WAZri181Iotz8viDAizL9gw//FZemYyc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Y6qXVGCD; arc=none smtp.client-ip=209.85.128.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Y6qXVGCD" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4281d812d3eso4948805e9.3; Tue, 06 Aug 2024 04:41:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722944494; x=1723549294; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=1AwITVf2WPGSBxmw93SjsOJVEu1oqZyIKeUGfTrfzs4=; b=Y6qXVGCDVaPQDmaoH3htnVPpYMIUS+pstp7tL5ZAL6xZrGrZXENeioPiPXliGNrfr7 aO178VVzXP9F32rYPH4uosBgzjzZDER6HSOoFKUFYBC8JIzS/9yVNRCQkLNvLgfH0mgp cmlv3vJhRQpThO8A40W+4VKdVIoevRjW5v3aJQftpORprVbr9YxagrQI6X7MsL3T8iBl xvKoz1/19frZ6xYzEgpWTte/jTQnQUkGi7lahQeCYuOQQejFvp9xeYtd3FUCD5IjRSxs Vt0iNVRTz5ypu0wL5KgFis9V0LJtR2eIO9U5cg201ROElCfNzTjti60rX6tpnBUhTnfN gkDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722944494; x=1723549294; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1AwITVf2WPGSBxmw93SjsOJVEu1oqZyIKeUGfTrfzs4=; b=ouztzby5yx1uW9eJcYuzFDmuANRjxVs+/zZmd2GogkP8qroQuVurdzluTOk0ss4Fgc zmFg/ZFbpVJM18oOYFBllID068nwFNsXGuPspMGkxDovduy8r54jD4/JCJH4n0IbxmzF Nidvn/l+EhJgYmInE2HkWYWU2Tf9wgygOoo6aGy8/MU1tiarDZ6mZ+giKqCOICgAiwhu WZ0e4ICIdwVpYsbFIYXgKLKy1sJTEkWhtrErWf2ZNYSUZfqoyyML+/QtDx7R7LepBqsy NJpZKNUg4pklBAbzroY25L604N64jyXolrgTpIQP4Tl5H10asHkTq2nTS0l2nZnswLcH GU6Q== X-Forwarded-Encrypted: i=1; AJvYcCWtMScHijpRtHqizPm0x122D4mqAx3q5EumqfAORAfto1lTMXROQueqVhwVYFYnmgdRuyvyWqA/0MOivr8GkMszq1x9OUCM3wC7+qB61BySja9uNQSOvj+NY9jb3ckF8asMLMX9RAeq2Juwb9Yz+bpgEyQhzzEHkpKgvA2OKw7gMkhC/g== X-Gm-Message-State: AOJu0YwS+fHQFwji5AFnln2NLilaQD/anEi3DfCRux68K5JnO3T1YEjP 2vMm2I+kAs3MfEOtAhhtg1GP6WsxpS7IN133KlzDwYjfu8SSH1M8 X-Google-Smtp-Source: AGHT+IFGVYMjIkc1rf+t9JbyTCPhrBWsc7Ju4jzCOzjNnzD1sS+oEYPY0w7XNI1EwLNMTIC2ME3gng== X-Received: by 2002:a05:600c:4752:b0:426:6fd2:e14b with SMTP id 5b1f17b1804b1-428e6b0274emr117918275e9.11.1722944493977; Tue, 06 Aug 2024 04:41:33 -0700 (PDT) Received: from localhost.localdomain (host-87-6-196-30.retail.telecomitalia.it. [87.6.196.30]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-428e6e7cce6sm176105845e9.31.2024.08.06.04.41.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Aug 2024 04:41:33 -0700 (PDT) From: Christian Marangi To: Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Joern Engel , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Christian Marangi , Wolfram Sang , Florian Fainelli , Thomas Bogendoerfer , linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-nvme@lists.infradead.org Subject: [PATCH v3 4/6] block2mtd: attach device OF node to MTD device Date: Tue, 6 Aug 2024 13:41:14 +0200 Message-ID: <20240806114118.17198-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806114118.17198-1-ansuelsmth@gmail.com> References: <20240806114118.17198-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Attach device OF node to MTD device if defined and the root blockdev is being used to add support for partitions defined in DT node. This permits the usage of fixed-partition or alternative parser with the use of block2mtd module. Signed-off-by: Christian Marangi --- drivers/mtd/devices/block2mtd.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c index b06c8dd51562..8ff9787edc24 100644 --- a/drivers/mtd/devices/block2mtd.c +++ b/drivers/mtd/devices/block2mtd.c @@ -265,6 +265,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size, struct file *bdev_file; struct block_device *bdev; struct block2mtd_dev *dev; + struct device *ddev; loff_t size; char *name; @@ -324,6 +325,15 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size, dev->mtd.priv = dev; dev->mtd.owner = THIS_MODULE; + /* + * Check if we are using root blockdev. + * If it's the case, connect the MTD of_node to the ddev parent + * to support providing partition in DT node. + */ + ddev = disk_to_dev(bdev->bd_disk); + if (ddev == &bdev->bd_device) + dev->mtd.dev.of_node = of_node_get(ddev->parent->of_node); + if (mtd_device_register(&dev->mtd, NULL, 0)) { /* Device didn't get added, so free the entry */ goto err_destroy_mutex; @@ -337,6 +347,7 @@ static struct block2mtd_dev *add_device(char *devname, int erase_size, return dev; err_destroy_mutex: + of_node_put(dev->mtd.dev.of_node); mutex_destroy(&dev->write_mutex); err_free_block2mtd: block2mtd_free_device(dev); @@ -515,6 +526,7 @@ static void block2mtd_exit(void) struct block2mtd_dev *dev = list_entry(pos, typeof(*dev), list); block2mtd_sync(&dev->mtd); mtd_device_unregister(&dev->mtd); + of_node_put(dev->mtd.dev.of_node); mutex_destroy(&dev->write_mutex); pr_info("mtd%d: [%s] removed\n", dev->mtd.index, From patchwork Tue Aug 6 11:41:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 817888 Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2BC1A1C579C; Tue, 6 Aug 2024 11:41:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722944499; cv=none; b=B8N+Z44rfm1WMnMofk1dO1sElgrX0NBdHhZ/1ntoPsyWl/AEAHkSX0aXkRw05IPALQnT2aGLgSxCdpZn1RYAAk7MCfHGWvySFwn/R7R0HClai9PUpDeZlDMH4+KO+TTIHdvW0jDmrQJ5IkP0yWsB81O0I8P2vrBOEFeuokdi4Ds= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722944499; c=relaxed/simple; bh=6IE7tvskZW59pVR1UJxmlFcac0npVXGRA3ZaUx+Dgm0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=M+GAHdhR/gC6mOVdg4ua4ZHNmODy8oFsx46HCJ+oGs/gAkXYZsL1/JebWdlWouKNbGrmAqfo8PlfG/K2grnnCOkWej0GGx00CW3BjW21pgGqFmrpVUhcj5NAlr0ARgAR/io/dpJGzFZS0XXXmr1k/9VpTe+ZHJxgyRePZrmmQJg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZxDiEFBi; arc=none smtp.client-ip=209.85.208.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZxDiEFBi" Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2eeb1ba040aso8326581fa.1; Tue, 06 Aug 2024 04:41:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722944496; x=1723549296; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=5xBEuESArl0fBfjXYsEhDBEbTfGt9gI5ouD6sU73/GU=; b=ZxDiEFBiYr60G1lZIoU9mV5HkZjaYv9DCC4niatclRHkTZzm8WIlp2frltmSzsS5ZO OvTZRgoWd/J3O43XFNr0873WGvf04ctPSRkn60aNNPhOKckpNdi+XdOip0m/aw28fFLv 1HgrvDAQ6U5LHaKYMGVDCJDPmC5TRb05b3pyKcAYrc5y8LSNHoQGodQDv4Z2EKdHWCGT JmspYIE3BiBBQPE4j/r02JHWHCGzfGdbFTXP5RYLZ/CQpZuk7H2EmJp+kCRFDpaXbYv4 S2Rqp+sMzAXvBiOdJFbRuFyuYwD/XFvaIhedqTYzB+HLNv1HMcvl5A7jyKDZ6sNPcHd0 Ommg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722944496; x=1723549296; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=5xBEuESArl0fBfjXYsEhDBEbTfGt9gI5ouD6sU73/GU=; b=h3HHF/IMh7jr/fwINjwqMftVlvZneaUH5q6Jc5HbkWINvPIYL+y/coJuBQZpx16An+ /wh7+cmy4h1/qRdFUhj4tzV49BgSLUwjZzWA3i+LqKrDlEF84Vy0T0rHtRpiNu3RXisp 7K7PPK0YR8kBAtE3Uwp2yFOc3FVwuBoj5FqyNUJQKS9p79DVUc+xazwiNHL+dujVbs9b oMvHLeEvWgcyRkqm1vDsz62CA8GBsZNVqnZ/cDivaWd5/WAGH3DsLk3uEHbFjbdpNH7m lu88YfxfgnavgC5JaGXMT1PuJy1yFHhqQZntqulFihPZVzQ9vqXsALx1EXo6JIvV6yvk mHHQ== X-Forwarded-Encrypted: i=1; AJvYcCWNJc77c97WaVq1dS/FaQUO8YO9ipx2VX/u0rN7gVScgVy9DwI6XsYT2174YWkjOULF102xtxCfIF0PAHPw3mDqP0r0b1DqRBQMMpgyUyrmL6hj6zCnDhfEGp94HE0RFodiOPY6vr1PZH3VbHnYluxUxg1/O3+gfv5u39x1PzQrYvAQcg== X-Gm-Message-State: AOJu0Yxc+ZzhB6a6iKIXXhvZBK+rjMgvSJWjnRzv2xvzhfSMPQu5I8pe YxZhwH91hQN9ZBaC3BN70GjDWrjo7fRMLCc2BwE3xsCEbpgpq4xG X-Google-Smtp-Source: AGHT+IGEw7FbfFGV4bGUwud7W+/31hW0KginGDZdKiOUFG09QuHWu6Nsg6YcjdixER72oYD5wUIGqQ== X-Received: by 2002:a2e:999a:0:b0:2ef:2f19:a8b3 with SMTP id 38308e7fff4ca-2f15ab049f2mr102072831fa.41.1722944495774; Tue, 06 Aug 2024 04:41:35 -0700 (PDT) Received: from localhost.localdomain (host-87-6-196-30.retail.telecomitalia.it. [87.6.196.30]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-428e6e7cce6sm176105845e9.31.2024.08.06.04.41.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Aug 2024 04:41:35 -0700 (PDT) From: Christian Marangi To: Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Joern Engel , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Christian Marangi , Wolfram Sang , Florian Fainelli , Thomas Bogendoerfer , linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-nvme@lists.infradead.org Subject: [PATCH v3 5/6] dt-bindings: mtd: Add Documentation for Airoha fixed-partitions Date: Tue, 6 Aug 2024 13:41:15 +0200 Message-ID: <20240806114118.17198-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806114118.17198-1-ansuelsmth@gmail.com> References: <20240806114118.17198-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add Documentation for Airoha fixed-partitions compatibles. Airoha based SoC declare a dedicated partition at the end of the flash to store calibration and device specific data, in addition to fixed partitions. The offset of this special partition is not well defined as it depends on flash bad block management that might require reserving additional space at the end of the flash. This binding allows defining all fixed partitions and marking the last one to detect the correct offset. Signed-off-by: Christian Marangi --- .../partitions/airoha,fixed-partitions.yaml | 80 +++++++++++++++++++ .../bindings/mtd/partitions/partitions.yaml | 1 + 2 files changed, 81 insertions(+) create mode 100644 Documentation/devicetree/bindings/mtd/partitions/airoha,fixed-partitions.yaml diff --git a/Documentation/devicetree/bindings/mtd/partitions/airoha,fixed-partitions.yaml b/Documentation/devicetree/bindings/mtd/partitions/airoha,fixed-partitions.yaml new file mode 100644 index 000000000000..8d7221561f51 --- /dev/null +++ b/Documentation/devicetree/bindings/mtd/partitions/airoha,fixed-partitions.yaml @@ -0,0 +1,80 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mtd/partitions/airoha,fixed-partitions.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Airoha SoC partitioning + +description: | + Airoha based SoC declare a dedicated partition at the end of the flash to + store calibration and device specific data, in addition to fixed partitions. + The offset of this special partition is not well defined as it depends on + flash bad block management that might require reserving additional space at the + end of the flash. + + This binding allows defining all fixed partitions and marking the last one to + detect the correct offset. + +maintainers: + - Christian Marangi + +select: false + +properties: + compatible: + const: airoha,fixed-partitions + + "#address-cells": + enum: [ 1, 2 ] + + "#size-cells": + enum: [ 1, 2 ] + +patternProperties: + "^partition@[0-9a-f]+$": + $ref: partition.yaml# + properties: + compatible: + const: airoha,dynamic-art + unevaluatedProperties: false + +required: + - "#address-cells" + - "#size-cells" + +additionalProperties: false + +examples: + - | + partitions { + compatible = "airoha,fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "bootloader"; + reg = <0x00000000 0x00080000>; + }; + + partition@80000 { + label = "tclinux"; + reg = <0x00080000 0x02800000>; + }; + + partition@2880000 { + label = "tclinux_slave"; + reg = <0x02880000 0x02800000>; + }; + + partition@5080000 { + label = "rootfs_data"; + reg = <0x5080000 0x00800000>; + }; + + partition@ffffffff { + compatible = "airoha,dynamic-art"; + label = "art"; + reg = <0xffffffff 0x00300000>; + }; + }; diff --git a/Documentation/devicetree/bindings/mtd/partitions/partitions.yaml b/Documentation/devicetree/bindings/mtd/partitions/partitions.yaml index 1dda2c80747b..ec254e03adf0 100644 --- a/Documentation/devicetree/bindings/mtd/partitions/partitions.yaml +++ b/Documentation/devicetree/bindings/mtd/partitions/partitions.yaml @@ -14,6 +14,7 @@ maintainers: - Miquel Raynal oneOf: + - $ref: airoha,fixed-partitions.yaml - $ref: arm,arm-firmware-suite.yaml - $ref: brcm,bcm4908-partitions.yaml - $ref: brcm,bcm947xx-cfe-partitions.yaml From patchwork Tue Aug 6 11:41:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 817278 Received: from mail-lj1-f178.google.com (mail-lj1-f178.google.com [209.85.208.178]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC34F1C5799; Tue, 6 Aug 2024 11:41:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722944501; cv=none; b=A73yMFk/FevaBkrTJ16ypyQ6QKE4XrN2W5GtIbFv5ZA0enQCwdkYTaNWdfHK6U+dhSo5T6kOEuDVNeFkYDYy7E+Pqt60wSHFM58fCDqonyv1hAJelLTaID8/OfZBglhXtB6X9xdJzI0C/4BGIsBQatmOJh0hpbKtu/IKu4kIMho= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722944501; c=relaxed/simple; bh=Ax4BMVXvqmSBg6QIo8pDEUgQHsze4QAEeW6gBsTEWoc=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Qq84FO1SSa5u7qyRY2DsqmSfwmqpUi/PF2jPcMH8yvuSF2yxfTNFCHMq8MkYH8jYRZ8sNDNnjQYnN7LcQCWkwDxL+gV5qmtPPuPJqSVBgXuK6qyhAYSgphGkMtm9+4qHo9x90V03j6Ez3kLVPrDAyks2VybYbvOEBFJbhMwSZRw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ldJorYTP; arc=none smtp.client-ip=209.85.208.178 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ldJorYTP" Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2f15dd0b489so7931791fa.3; Tue, 06 Aug 2024 04:41:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722944498; x=1723549298; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=W8UY9azmTjhPunDkBNM5W4aID9KMi7XRKzM/JmHz9bA=; b=ldJorYTPD6tkP93nPFSWrq0adRgJhIV91WYQlgQ5HOcZIU6Zu/YANt1P5H4hCUAyMO 5wmxe+nQdFe1AD5+ckxKtijVFD96wDcqSkaX5JRhmT4Oiz95kqaoAAl8zLXKQUNrmBRK E/2aN6KZ4KchIp1LdJ1UAGQnbuWiKhw/152UbV07QPkQJgxQAQMrT2RWmoRU/7AkSCsb pO/q5cHfnCamosxBd1m0ipkGntodEGwnkx3u8KAMcXwJquR19UJzbQUhvekTCRe2tp6U ONU0S80v9LwEbCGCRxRs72hCkPG7UfFq0fgUomO6r2kuflJ+4oDZLw/pJk3OepbtwvbD /Ekg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722944498; x=1723549298; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=W8UY9azmTjhPunDkBNM5W4aID9KMi7XRKzM/JmHz9bA=; b=fBBVe8oVxrizvuutufDPlS13GW42OuDe7s5WsQ0PY74w8ri3PGIROJcD1kNyyajIIi nMsdicsZG0cUg1oTElBgdXC3FgyfjVH7AORFXPIdkS5MX1jxi4Sk0DeFiNyzv75iIJxq 0XWtND6nb4W7i0Qs/eEzkjahGWmtJlGk24SPqvYrovwP46rF8OXJYonnTXwA1i8JTV1t afQbH5rL3U32Qc4OBFrFhIDB5VCJLIM5ZzUr7HDumRQuwIsOvVXpJQKJ9bDdDdzeZzSN Ftd9GTYNFRNC3YeBSVDALb/Y58VCDTpI1EdeqVld3424mvONXffIzme9RUjKkWV0uzxT x9NQ== X-Forwarded-Encrypted: i=1; AJvYcCVBP4AjyydmEm3LxD5pM6UAVXgkhL8g5ysGuZkl1nRcx5dddzjOSARjScIarrN6mkE5XwJDYMo6vfwFfp6aEFZ91wfzb6evenHOK3bHzf0ymD8u4dn3YqcSy870CgI/JHzpd5j325aZyEupEZ3r8bdX7Ql+h/nnYUlrcTBbFbEF4lJgZg== X-Gm-Message-State: AOJu0YzWKLtjs8iobRpmWy7MD7DTXMFEK5LdbfrHLqjzgUuRNvCa+p3t k5e6RBM9Mch23+GeL6sHz6zbyabcEpDALtokS7qADKI2fAMv34Fi X-Google-Smtp-Source: AGHT+IGx9JpvtWSSJNncxBn64nyf6VX1HlPIDvZrqJFY+6GFP8Hs6JdctNgOCKrCUWNgRJKHapbLMA== X-Received: by 2002:a2e:8747:0:b0:2ef:2061:8bf5 with SMTP id 38308e7fff4ca-2f15ab27c85mr88378811fa.40.1722944497625; Tue, 06 Aug 2024 04:41:37 -0700 (PDT) Received: from localhost.localdomain (host-87-6-196-30.retail.telecomitalia.it. [87.6.196.30]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-428e6e7cce6sm176105845e9.31.2024.08.06.04.41.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Aug 2024 04:41:37 -0700 (PDT) From: Christian Marangi To: Ulf Hansson , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Joern Engel , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Christian Marangi , Wolfram Sang , Florian Fainelli , Thomas Bogendoerfer , linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org, linux-nvme@lists.infradead.org Subject: [PATCH v3 6/6] mtd: parser: add support for Airoha parser Date: Tue, 6 Aug 2024 13:41:16 +0200 Message-ID: <20240806114118.17198-7-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240806114118.17198-1-ansuelsmth@gmail.com> References: <20240806114118.17198-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-mmc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add support for Airoha parser based on a post parse ofpart function. Airoha partition table follow normal fixed-partition implementation with a special implementation for the ART partition. This is always the last partition and is placed from the end of the flash - the partition size. To enable this special implementation for ART partition, the relevant node require the "airoha,dynamic-art" compatible. With that declared, offset value is ignored and real offset is updated with the calculated value. Due to usage of specific bad block management driver, the MTD size might vary hence the ART partition offset needs to be dynamically parsed and can't be declared statically. Signed-off-by: Christian Marangi --- drivers/mtd/parsers/Kconfig | 10 +++++ drivers/mtd/parsers/Makefile | 1 + drivers/mtd/parsers/ofpart_airoha.c | 57 +++++++++++++++++++++++++++++ drivers/mtd/parsers/ofpart_airoha.h | 18 +++++++++ drivers/mtd/parsers/ofpart_core.c | 6 +++ 5 files changed, 92 insertions(+) create mode 100644 drivers/mtd/parsers/ofpart_airoha.c create mode 100644 drivers/mtd/parsers/ofpart_airoha.h diff --git a/drivers/mtd/parsers/Kconfig b/drivers/mtd/parsers/Kconfig index da03ab6efe04..d6c53aa16ea6 100644 --- a/drivers/mtd/parsers/Kconfig +++ b/drivers/mtd/parsers/Kconfig @@ -72,6 +72,16 @@ config MTD_OF_PARTS flash memory node, as described in Documentation/devicetree/bindings/mtd/mtd.yaml. +config MTD_OF_PARTS_AIROHA + bool "Airoha EN7815 partitioning support" + depends on MTD_OF_PARTS && (ARCH_AIROHA || COMPILE_TEST) + default ARCH_AIROHA + help + This provides partitions parser for Airoha EN7815 family devices + that can have dynamic "ART" partition at the end of the flash. + It takes care of finding the correct offset and update property + with it. + config MTD_OF_PARTS_BCM4908 bool "BCM4908 partitioning support" depends on MTD_OF_PARTS && (ARCH_BCMBCA || COMPILE_TEST) diff --git a/drivers/mtd/parsers/Makefile b/drivers/mtd/parsers/Makefile index 9b00c62b837a..d67f9b4d39ac 100644 --- a/drivers/mtd/parsers/Makefile +++ b/drivers/mtd/parsers/Makefile @@ -5,6 +5,7 @@ obj-$(CONFIG_MTD_BRCM_U_BOOT) += brcm_u-boot.o obj-$(CONFIG_MTD_CMDLINE_PARTS) += cmdlinepart.o obj-$(CONFIG_MTD_OF_PARTS) += ofpart.o ofpart-y += ofpart_core.o +ofpart-$(CONFIG_MTD_OF_PARTS_AIROHA) += ofpart_airoha.o ofpart-$(CONFIG_MTD_OF_PARTS_BCM4908) += ofpart_bcm4908.o ofpart-$(CONFIG_MTD_OF_PARTS_LINKSYS_NS)+= ofpart_linksys_ns.o obj-$(CONFIG_MTD_PARSER_IMAGETAG) += parser_imagetag.o diff --git a/drivers/mtd/parsers/ofpart_airoha.c b/drivers/mtd/parsers/ofpart_airoha.c new file mode 100644 index 000000000000..5e2cc7b6376b --- /dev/null +++ b/drivers/mtd/parsers/ofpart_airoha.c @@ -0,0 +1,57 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2024 Christian Marangi + */ + +#include +#include +#include + +#include "ofpart_airoha.h" + +int airoha_partitions_post_parse(struct mtd_info *mtd, + struct mtd_partition *parts, + int nr_parts) +{ + struct mtd_partition *part; + int len, a_cells, s_cells; + struct device_node *pp; + struct property *prop; + const __be32 *reg; + __be32 *new_reg; + + part = &parts[nr_parts - 1]; + pp = part->of_node; + + /* Skip if ART partition have a valid offset instead of a dynamic one */ + if (!of_device_is_compatible(pp, "airoha,dynamic-art")) + return 0; + + /* ART partition is set at the end of flash - size */ + part->offset = mtd->size - part->size; + + /* Update the offset with the new calculate value in DT */ + prop = kzalloc(sizeof(*prop), GFP_KERNEL); + if (!prop) + return -ENOMEM; + + /* Reg already validated by fixed-partition parser */ + reg = of_get_property(pp, "reg", &len); + + /* Fixed partition */ + a_cells = of_n_addr_cells(pp); + s_cells = of_n_size_cells(pp); + + prop->name = "reg"; + prop->length = (a_cells + s_cells) * sizeof(__be32); + prop->value = kmemdup(reg, (a_cells + s_cells) * sizeof(__be32), + GFP_KERNEL); + new_reg = prop->value; + memset(new_reg, 0, a_cells * sizeof(__be32)); + new_reg[a_cells - 1] = cpu_to_be32(part->offset); + if (a_cells > 1) + new_reg[0] = cpu_to_be32(part->offset >> 32); + of_update_property(pp, prop); + + return 0; +} diff --git a/drivers/mtd/parsers/ofpart_airoha.h b/drivers/mtd/parsers/ofpart_airoha.h new file mode 100644 index 000000000000..3e8a8456c13a --- /dev/null +++ b/drivers/mtd/parsers/ofpart_airoha.h @@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __OFPART_AIROHA_H +#define __OFPART_AIROHA_H + +#ifdef CONFIG_MTD_OF_PARTS_AIROHA +int airoha_partitions_post_parse(struct mtd_info *mtd, + struct mtd_partition *parts, + int nr_parts); +#else +static inline int airoha_partitions_post_parse(struct mtd_info *mtd, + struct mtd_partition *parts, + int nr_parts) +{ + return -EOPNOTSUPP; +} +#endif + +#endif diff --git a/drivers/mtd/parsers/ofpart_core.c b/drivers/mtd/parsers/ofpart_core.c index e7b8e9d0a910..9e078636d158 100644 --- a/drivers/mtd/parsers/ofpart_core.c +++ b/drivers/mtd/parsers/ofpart_core.c @@ -16,6 +16,7 @@ #include #include +#include "ofpart_airoha.h" #include "ofpart_bcm4908.h" #include "ofpart_linksys_ns.h" @@ -23,6 +24,10 @@ struct fixed_partitions_quirks { int (*post_parse)(struct mtd_info *mtd, struct mtd_partition *parts, int nr_parts); }; +static struct fixed_partitions_quirks airoha_partitions_quirks = { + .post_parse = airoha_partitions_post_parse, +}; + static struct fixed_partitions_quirks bcm4908_partitions_quirks = { .post_parse = bcm4908_partitions_post_parse, }; @@ -192,6 +197,7 @@ static const struct of_device_id parse_ofpart_match_table[] = { /* Generic */ { .compatible = "fixed-partitions" }, /* Customized */ + { .compatible = "airoha,fixed-partitions", .data = &airoha_partitions_quirks, }, { .compatible = "brcm,bcm4908-partitions", .data = &bcm4908_partitions_quirks, }, { .compatible = "linksys,ns-partitions", .data = &linksys_ns_partitions_quirks, }, {},