From patchwork Sun Aug 4 11:41:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13752611 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 C92F7383A1; Sun, 4 Aug 2024 11:41:56 +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=1722771718; cv=none; b=iBFli59nXXR2uA7uCdECQ4Bq3xwBpMYgqHZNjor5DfNLIk8UQpb8zJoQaZiD7KvrX6lLWmjIcubp4gRsNzW+XkGugZH+pIZPETPAI70iYbpyrV6qZhVfSQBDJlyo0Zm2XE+n4KxDfs5YHXVG0uklPGHW/ikeLBGEROtV4sd1fsA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722771718; c=relaxed/simple; bh=5LbPMzmNGfuxlauoWeKMsm0e6brfLsdQfHcfl/8nZRs=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Un4WD6P50kjnqQPYXuuZNY7n1ZSn+oM9/kd2fp2fTBPY5JAAt72RFiLGRqJ7VBm3DkjhCEbsZn95W7baT9qBPakoQyUO3GIobc3zkuwb+PpppZdjcZUDwyowPoqh4QauDV7YYrkFPoYpwY8lTp0O9oLoVRI2L2rN9PUeULyR0+s= 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=AdvvTKi0; 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="AdvvTKi0" Received: by mail-wm1-f48.google.com with SMTP id 5b1f17b1804b1-42817f1eb1fso59065145e9.1; Sun, 04 Aug 2024 04:41:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722771715; x=1723376515; 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=AdvvTKi0Cg0RjDvGD98r6PLbeKn7Srz7tI1YVQ+SC5nWU+Li6iqvqMDla4g7Ac8FkU /yk/4b1yIYhRpI/2DhZWRO2fTABRcgpnuvFe8YPPa5lX9hH5Ouh+RHBDrCccEVw5mUSD s+8/Ia25858Vu0z2HYlEwxdmyW3DEY3GGEWUS8LaunnOM3eJ9JMirQ6N46QFCvf8LVWV m6ZmYdrfmY8Mo17BvGeN+xNg7lKTDMV3XS38jIphnvUolFYVIscw2wipZnxFQR2IsrJp JF2WtFJ0WwZcEUqIobZ6Q3Jz3OMemkKyZhOYBIYYmVATuzKA7S+llKBb5/YHdz9pJ9b0 KcKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722771715; x=1723376515; 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=VoBIBTYeFMEoMtEOkVaJ3dXDAPY/cVDFCWKZF4FBBDFCs0yzm1VZbP0Facughix1eu pjJaIzCzJEVhZiGZvY+wKVhtSpRJRn5soSZUP/4WGC8WGSVUcCDr7cL61IKfOcxos+8k Rp6/SidIQ/xWwZljQdu3rSr1ZGiqCCLsh/pfkUkAxJyMQZrQWnApZSXLIvqpyRzAEzx3 VrYqwFyf7XrUz5ksjHmN/wT8RRLD38k6U9xgz5U8LuBoiIRpWnEZDt/d0GEawiez4ZBZ +cm5kwZ1OZrMJh5kVUVwkRk9b1HDRsfslLtA0TQqMlpbDPTBOCV1vN2n8zNQZCm+yLRM BsGg== X-Forwarded-Encrypted: i=1; AJvYcCUnAfP1ZCiMKQuZmrvufmHtwvKAfB+ZE5qhWFtqLSZDJwECksHBnAb6ZHsaHTiT5Dtvf3rKhxud+Fm4Hjwg9lf6CPUsO6BgXILPn3rYBbju3Al2uy6U3X9rzjVMrFpMazLOpXHWVJItcFn7x7tXVFynOMOSZWAw29UMFbqQymzrNcCL2Q== X-Gm-Message-State: AOJu0YzhdMGUwT/SdOe+XpSXIVZfkW/a6+c8qQTaFlgVooEjWrJQMsfC MbxmdF+RpHzS16hLQzypQ1XKnFV1I6jtWKvJxBJ7z0vpZ4uKwdvj X-Google-Smtp-Source: AGHT+IEh/fFRi3lvw24ntWxbY6FWDsuqyuWXPDM5pSemyCgBJ+obg3zad+nrGbuYwnLYxI5iYfKvgQ== X-Received: by 2002:a05:600c:3b19:b0:426:61e8:fb35 with SMTP id 5b1f17b1804b1-428e6af2e9amr57295055e9.4.1722771714552; Sun, 04 Aug 2024 04:41:54 -0700 (PDT) Received: from localhost.localdomain ([109.52.148.115]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-36bbd01eff1sm6635130f8f.44.2024.08.04.04.41.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Aug 2024 04:41:54 -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 , Florian Fainelli , Thomas Bogendoerfer , Wolfram Sang , 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 1/6] dt-bindings: nvme: Document nvme-card compatible Date: Sun, 4 Aug 2024 13:41:01 +0200 Message-ID: <20240804114108.1893-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240804114108.1893-1-ansuelsmth@gmail.com> References: <20240804114108.1893-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 Sun Aug 4 11:41:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13752612 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 295B33BB21; Sun, 4 Aug 2024 11:42:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722771721; cv=none; b=MPEhiKzBVAsa3Hzkwn6QQOYubeCQOsae9/2ivTIqWneES6SQvMm9EZ0+H1AAbTwSrFM3oCRcqO83aaWikuTyfd8jorm3AFQ/SIFi3BcDYjVcYn8B61GvDZl74KDw9kc7TE5m+Vg9iGXhg4bqQNo4ZiAKXvCbxavr9WQjTKee748= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722771721; c=relaxed/simple; bh=VlA2x6zajbAExdNLQZ27s1DAMyMaLYUCzuAivJVFa1o=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KPt/43baAD/2D/sCppe1az5a3ekV1XWIuhfF8almVwtdVX0VEIuMYkZE2YIAvbzzw9BfPG7Rdthg7ALFuQaVdTDvC+ihS8XIpqdS3NNzDAwVGLbXzsHzbxdhUpU7U/e86C7awWdZkevOLlUNGS8ZS51o5p5oox0bEY9ApSKNDiI= 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=g5Hc/vaK; arc=none smtp.client-ip=209.85.221.45 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="g5Hc/vaK" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-3687fd09251so5116457f8f.0; Sun, 04 Aug 2024 04:41:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722771718; x=1723376518; 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=lOfQ6PranLoD+iROjXBHWVrWUAE8K7cRNQ5h3Vwmujo=; b=g5Hc/vaKU3g8VUAg5FfSfHdaJMBKogpUuSBwRx4NCCyD4jq9C9/xR7V1LeggL22tk9 paLJ/H0S8r7qbezfMa02v4Qgm24DM3PBW7objd+fIatb14/DIvwUXu8ec6XO0MvD6Na7 JcFTbsYYYp4YqVYtlbAHj0acIqiNxk0FCVAZ7c86TYbm7ju48t3A/jYWXoFqpPJyoRfP PfUK1QeaeRUgl2fvEHLshzBG+HcCZ6Oo8TUo69siW3uZJ7ShrzssdNJLt8LAnub0YiIF gBhNH1WydgvCDZSRYaD45zpIHkWsT3Kl0v4VWl4gZ2sC7QmGQB34jjI6kbTzojcLc7bo JOkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722771718; x=1723376518; 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=lOfQ6PranLoD+iROjXBHWVrWUAE8K7cRNQ5h3Vwmujo=; b=UUPrveV/hlB1P635Lei6JA0GciumOqdPkdw2a2mXAsdCLXuTaKVy4Nv7vVn48XTetB VKGe+GaSGNUMCjtaz39sAOCIU/BwWUMdw+64oI9aOmjsqPsJrJRwTd3x2gaYfzaHTvmW n+kbsW8mIdc3MyH/sO2PK5d0j5CNtTHSESerf3tpq2CoNKiP1vE13hVHGNZJIAvdRUca +HJerZzwGeFoqpMebkwfcJeCnNA456q4GKAxcrakkjcavN244YkTfO1QFNM41Zc/EY/m b49Ko3/mIYkkc4B4HDr/4RVr9SSfhC02wvH8+DKu6KDBFmytYzwvb8lJxl3cosIGt4GO R+sg== X-Forwarded-Encrypted: i=1; AJvYcCV5ss2szaZcLqv3IEM7mLnJbW5dwm1iRTeeOauNveK0us0e82kLl4Bh+oN1TCiUduxVPtewuLZYifDQeSdKCi+5Wng2K56XAlq0QOZkSewGzirMtRRc66fCNhA+x0cMaExG3iZDJC0MXtFXN04mIgrS1DOaP9Xz8CHEZNV4AQE+bx9fSQ== X-Gm-Message-State: AOJu0Yx1R1vo2bkFHI0WjJM05NiTdVLi9tbi1MzdDL23ahBy6cslyFg8 50BVKyzZvpLMdnIApmZOTevYWxZizuVEX6Zqd4WbvC7gFOlrb2FR X-Google-Smtp-Source: AGHT+IGmBqLkmUPrb6PVyJ646RbotoYKt7rhCLpvhXazgn9MYHBkQIQkseu8qxI4YXnyXjeT1VIzkA== X-Received: by 2002:a05:6000:a8b:b0:368:327c:372b with SMTP id ffacd0b85a97d-36bbc0dcf5fmr6441035f8f.19.1722771718267; Sun, 04 Aug 2024 04:41:58 -0700 (PDT) Received: from localhost.localdomain ([109.52.148.115]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-36bbd01eff1sm6635130f8f.44.2024.08.04.04.41.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Aug 2024 04:41:58 -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 , Florian Fainelli , Thomas Bogendoerfer , Wolfram Sang , 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 2/6] nvme: assign of_node to nvme device Date: Sun, 4 Aug 2024 13:41:02 +0200 Message-ID: <20240804114108.1893-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240804114108.1893-1-ansuelsmth@gmail.com> References: <20240804114108.1893-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 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 053d5b4909cd..b9553bb8fade 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -4651,6 +4651,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 +4772,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 Sun Aug 4 11:41:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13752613 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 6D7F53D3BF; Sun, 4 Aug 2024 11:42:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722771725; cv=none; b=FvjsnBOseUdLpIWmaJednLLALIvOTGQVFobrU2MgvB0kc4AKyz5zc2t5pSEHyk4xMt4sXdq8vFZXYiA6VWl+AhO0vh/yAiNvXBNqQ8eAm8W0QX2FStY5kLsL7y3eeqwR4znbkYhcNK3mZO0iw+7g+UKYQFCQ94LPRQOnQzo5/Rw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722771725; c=relaxed/simple; bh=0sysWhwNmnNKfHFiwRVWuNqKt3+jxEFZ3zFpJ5/W2Kg=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TBDjRlYcdNj6yGLATjBD9dbygGoZoW+PhH5VgcxKzVTMbv3W5A4k8ddWxC5MGYLW9CXlROQTQrGVJbs5WkQq59TRQOC5LAqv+6Kq/4IzwH/lj0GVSSEFvjvViChV+5d3uBA+wfzxfnZaNL6Z8/K3elG9j/lkKOU1C5HbsfQdWLk= 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=figMxNOn; arc=none smtp.client-ip=209.85.221.54 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="figMxNOn" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-3683329f787so5300229f8f.1; Sun, 04 Aug 2024 04:42:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722771722; x=1723376522; 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=figMxNOnim1w4jtmIcirC4PyDiY7Mb3DNnNGyyLTSunRBbCokjvLkCrx6NJQ3bUwrp bRnIVoGMbo73GTsjAysCDKpFzINuYCvbaYbcgg1I9Yuaoiuan4acC1q/NxhD5HZvVXab M/hLjy+/fgthTZtMS42tgsfykWYzdX74JTZfskxs2Iu5WT1Y6WJ4nPSwdO5hJCZq+Pvf 36+7otL0Rh5WDjS2A4Q8b0tA6G78ysN2tcBCykcHmLIjJyWAj5F4HT5+GgyuuqKbqfUN uvNNuuRj2J43EeUyBxssDw1LFvwVpv5AFUSwtHYWXJ8IuDUpP/mkWgJh4Wfo9jBvfTX9 9CFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722771722; x=1723376522; 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=aszmrAm/ELHpM9A5ucqpps42cjr9Yy+ETXm9e/1UIJd54wrHWP9kNqr/xqDHKapaEk EpYmBGoSb2dfPr6hlAv9f/e8Cmlp+fRUSTUYDktjBY9EO2ekpxOcfuKT2D3WQndcM4iB xPz9J6196yJqSn8z1U2ZWBaX3l4bvmzYf18Ln4l7Py1Rkb1A07IaiqeMryYMXcRBBOuh N0ktvpwEYhP3Wh8jsLiotVEGbIlNJS0klaAT2p0bsGGtNaoP894EKlshxI9R+9OqRrn+ DdggjPXrGAw/FiipWUs6xBj4EYNMGhiQJQANa7DKR68KPz/fNFbsTOKMyVuoYZwr58IH c9qg== X-Forwarded-Encrypted: i=1; AJvYcCUaCu3LN9ZG2fJUVbAY0dSKjX5MU4yR/UeYUCHf9bVR6e81V/KNWu0bw0+x3i6b2n5g2ZhToh9rj69YpWJhHt9Pvav6OG91C6Zmw5J5Eu6yK8Wr/DOqCxJW8DHIijaA3SWRzJZWTD7Lap1mtmHEugv26tbfz2l1xvL/dhFVP8/9JyQ0gA== X-Gm-Message-State: AOJu0YyT+KI1tKFtZD4y9prBEw7HuUqzEMGzttbAEIq/jleW3HK4k0WG zDyk3bWV78Biojjb/w0pfVkQGxXj4iOctOrYUOqyOQXdjuqDZ7P8 X-Google-Smtp-Source: AGHT+IGEFh9LhSO6onNwyiaQPUVg7gbETIoF2d9fushpmHT41a6bZNRtUSOPmyLpIODrXsVeGWvaOw== X-Received: by 2002:a5d:6104:0:b0:368:71bc:2b0c with SMTP id ffacd0b85a97d-36bbc0c69camr4994727f8f.10.1722771721698; Sun, 04 Aug 2024 04:42:01 -0700 (PDT) Received: from localhost.localdomain ([109.52.148.115]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-36bbd01eff1sm6635130f8f.44.2024.08.04.04.41.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Aug 2024 04:42:01 -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 , Florian Fainelli , Thomas Bogendoerfer , Wolfram Sang , 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 3/6] dt-bindings: mmc: add property for partitions node in mmc-card node Date: Sun, 4 Aug 2024 13:41:03 +0200 Message-ID: <20240804114108.1893-4-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240804114108.1893-1-ansuelsmth@gmail.com> References: <20240804114108.1893-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 Sun Aug 4 11:41:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13752614 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (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 E24E847A60; Sun, 4 Aug 2024 11:42:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722771728; cv=none; b=NVGVpXwuEmuZlVIKSNExiGOJwmVsxaX04CIt7HaZr8P9mNaA6ggpw9n+nUC43GxmQbVJGhFoPxjUu8x7iLVICVkhkK00rcIHp14/SGT/WoT5U7e3p4ec0Riul61UbjDG8Nkc1z0iq80HE9UDv9EmToR+rDtkt/qmyW1MS9GP7II= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722771728; c=relaxed/simple; bh=7eDdfGl0fYRwpTEihKkKLEsamRTy7CcjvzbmS+u4EQI=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XL5v1VI42gIZDsRAFMm/4NQy953Mjh9L4Y9OY73ahMP95dyPD7qZiT7e+zWt7Lr/syZhro95+xJi0+F7gqd/bjEM9mVMuVWQ3djfjLWuyqZy7MmLiX/U9/khDsLTS1IUp6n+4+gEQ1A7NkmnUvxRnwWffN//fQXebcLNZND3LlI= 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=Xqh0oxpl; arc=none smtp.client-ip=209.85.221.43 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="Xqh0oxpl" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-36ba3b06186so2311245f8f.2; Sun, 04 Aug 2024 04:42:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722771725; x=1723376525; 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=PGVXwGIeb7N3J4+10swQ61/JYCMx3W28Do3i6QPWuig=; b=Xqh0oxpl1lO7nVBtTPT/lVz1X1Jex5oCk9VcEkF61VIkC5EK1QxaA/9iuc1NO06Vw+ mffoI8zfI5kYeCzcH22vym0g2DO3raiFdsddmBd0dnYVRk1NUL5Wur5eq+5Msg+Qtc7q c2JNkepQlsTLOnF64fDWZC4B/NmHiV8rEXQ9gIHqnMKsJ9Pvu4s10b4kD2QoPLPYLAPg 2hi1G2w02U/VKzmiFiw4VNxgSLBYb3mWqAWLGyrjRkjs+oqMvXhVkhwO7FfXoSdFS7yt THFE+aYulD3eALveRLbEhDcxvQCjPCJUiDENN72krhBqWabGyznzvoPBM6zD1DbkkVLK 03MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722771725; x=1723376525; 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=PGVXwGIeb7N3J4+10swQ61/JYCMx3W28Do3i6QPWuig=; b=TiUNkmj3lJQGJ+cAaISWxujHndEQoEVXhjii7IgTQb1o/MbAACNr5UxoEbLi+HKkg4 7KyrXHkEwy+f/wPGEGB5CGsRytqxkXjLVMj/Sd93VSRWjA3jYZ1bEtbRNBbc596hGX3q 6VCcJRiqQfaKii3p+ri+gGlcsFXOLJBUrhbC8vBqhFJ/lRuTejwK3v+06rUZmjzvQ6pH 10WWwPwMTmr9nIyon5vp8erIub2Ct57JkjPrXOrVRNk2tD5ZaPYw0jSLLvuv7WD6HiFZ mD1KeRGRtSifkU5HJAtRA3y24NSwpp55KYxZh2aYVhi53r0b2PoTo6rLaYz1CmgGND1x C1DQ== X-Forwarded-Encrypted: i=1; AJvYcCUm7r4VyqJ5CYXAmfj2EdEmnWtLCpSODUhgFZftvneAKwbydOAXLr1pB16h6+oBt3TQ6W775Ke3p3Gi6gqaMxuN8X4ouNg09L98TJIaDEhq925gCLul+wu6iM77YkNA1h69qOSXvCtnOzjsBofam+C/TfooRMti0sBWLjixm+lKwex1xg== X-Gm-Message-State: AOJu0Yw4b9TZ3RMdSLahpmQ+CZrB0SOjNH/tfhLmK7LHVOQMh4e6GUNs eV19PSq4n0UErSwmqQ8oL2NzLOY8oBYyGuFoXixRPXRea6KNnEI1 X-Google-Smtp-Source: AGHT+IEkEsf7rgv+FK5pMw1rjBxefAm0Wya/QF5fP5oHTqQufDhgjOYXj5NRtQfw4DJZ93Td23+0cg== X-Received: by 2002:a05:6000:1faf:b0:368:d0d:a5d6 with SMTP id ffacd0b85a97d-36bbc1beb75mr5955215f8f.50.1722771724985; Sun, 04 Aug 2024 04:42:04 -0700 (PDT) Received: from localhost.localdomain ([109.52.148.115]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-36bbd01eff1sm6635130f8f.44.2024.08.04.04.42.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Aug 2024 04:42:04 -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 , Florian Fainelli , Thomas Bogendoerfer , Wolfram Sang , 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 4/6] block2mtd: attach device OF node to MTD device Date: Sun, 4 Aug 2024 13:41:04 +0200 Message-ID: <20240804114108.1893-5-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240804114108.1893-1-ansuelsmth@gmail.com> References: <20240804114108.1893-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 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/mtd/devices/block2mtd.c b/drivers/mtd/devices/block2mtd.c index b06c8dd51562..0c4ecea51717 100644 --- a/drivers/mtd/devices/block2mtd.c +++ b/drivers/mtd/devices/block2mtd.c @@ -324,6 +324,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(dev->blkdev->bd_disk); + if (ddev == &dev->blkdev->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 +346,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 +525,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 Sun Aug 4 11:41:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13752615 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (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 5094F52F74; Sun, 4 Aug 2024 11:42:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722771734; cv=none; b=lTGOS+nH9x05C2qNGBbKEtPvZ0Gdx2CAJahOAoNILtugaayVsC+Aqh8GepFOSInsowAFiFY3kBH7RNhWNm6Iv1XSWgp5QJd7mRa/8tuPVZq0PbgI7WUM6c0KXH029+nljhVdMmSmxkXvHQd+nNsbi61ODt0CfRLpZyD2E/TY13o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722771734; c=relaxed/simple; bh=370rhaxdNhI4ZAkdiwqODKZusyMGY79BtFAAsTZ015M=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=t3B6dXp/P6+XrY84S+hWo1O/ccYFxXgZFwut6rEbfNszY0i4i/6tjFLTl7G/4lcftK8PNwCHMlYPe9bP3EyiyGJd+TH3z+lBjDTdoioFJhjg6XVECjX9d9IeswktNQ3B27tWbMstz0GeE6QlLwUxe9fcHdGkHV0rWFPFtg5WwRs= 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=Junpm3Fm; arc=none smtp.client-ip=209.85.221.53 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="Junpm3Fm" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-3684e8220f9so2569120f8f.1; Sun, 04 Aug 2024 04:42:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722771731; x=1723376531; 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=HGKaaQieag+Q14DTix3aGJa4i3xg34VJO5/0gIeYwCA=; b=Junpm3FmYTrybrJM2xDBAbkMjC0t+Fk0Z3DN4bsYSINuFSPusSAbUr0pZs1M0L/iOK E6v+Ru5ezi8u0JpvC9rp5A0Aeu2act1PJ2JixRJEx01VPITUTYIglSnd2TAiuT2ABKDU GN3BDDL96WTFYzbyoMKA7nB+EzH2Z3ixLKOQQ7hK24IKMN7L7eIyeIbF1I8lgQKCaHi1 Va8U5Dd8oqY3a42cAgcfVmloxaeWxXpZ457PZeWQ8xuzS3yL5Ks8SRniFjPj8rdgsbPw VdIzMxpCNEKispAEjmvojD1sSIn9GO/p7Dz7qDPEvymos7gAXTYeoOEDX7LhNUVSKi3n izPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722771731; x=1723376531; 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=HGKaaQieag+Q14DTix3aGJa4i3xg34VJO5/0gIeYwCA=; b=jyfyrzvo6Q8e7f65McOUY52TNi5aNbbqVTI9RW4dehNA+1WGoNAzJKwtp00fBZktEC ADE1vEsH4kG7sNQjLzGKrm0cGjmMZh2sEbGI0kgYP+v+82nPrmrmIf1HXPRMhXeUTwNJ CGgax8+8jJKBFU1+QH5ohBjnBahnE3SZIuTH9Az16Thu8hUi8DcGK1puuzV1fBGkmLes T66BVgDbFDqUGeKlGXR0hKfZ2wqC88mV8ZDf1mKcR+Z9eLaGxn5yl9g1ivFFuOxv9c5k Czveqxl2/C9H4D4hZHQ73WB0V4c6Is4oJBLU7dUH3sPWEdkTEKCOXDi9oAHT9uY3AlnQ ktPw== X-Forwarded-Encrypted: i=1; AJvYcCXld3PKZVb+hmJc38hKkc+9/0lknqsjQkguJbSlp4rE+9ikXPXY6wUIq4HRfzNTS5CCMOCit4ZePPe4aNZDCgFExH0SVtcbTygGauUvup8RYAUXrhnm4R5vLXq8lZ3wVFZA1OvOTFqKLc8QwGgTKY1nwInBJ8sLPyTebdo9R2nweUPTQw== X-Gm-Message-State: AOJu0YwBym1+Zy9rIXzcMUWuL+XfXG0YmAGenZ5xTngs2UcUBgSdbVZ6 aq4HpN+tpwlJtvqV7olRmaSIpQC0i+dh7pyBsQHkzpwXlyIIX3mfkqM87A== X-Google-Smtp-Source: AGHT+IFLHuekhjS3wn/gQuthegTYTE1hpUglR72MMyu4qD76bmaYcfmhvlzvI4IbB+867YnyApqvfQ== X-Received: by 2002:a5d:59a2:0:b0:366:ee84:6a77 with SMTP id ffacd0b85a97d-36bb358463cmr8743186f8f.3.1722771730142; Sun, 04 Aug 2024 04:42:10 -0700 (PDT) Received: from localhost.localdomain ([109.52.148.115]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-36bbd01eff1sm6635130f8f.44.2024.08.04.04.42.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Aug 2024 04:42:09 -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 , Florian Fainelli , Thomas Bogendoerfer , Wolfram Sang , 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 5/6] dt-bindings: mtd: Add Documentation for Airoha fixed-partitions Date: Sun, 4 Aug 2024 13:41:05 +0200 Message-ID: <20240804114108.1893-6-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240804114108.1893-1-ansuelsmth@gmail.com> References: <20240804114108.1893-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 +++++++++++++++++++ 1 file changed, 80 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..da7879c98317 --- /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-partition + + "#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>; + }; + }; From patchwork Sun Aug 4 11:41:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13752616 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (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 A3D8855884; Sun, 4 Aug 2024 11:42:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722771737; cv=none; b=pZe7aPOiqD1dwjy6bm1L3YpI/0OK4BbvmVCk18d12M1x8aoaH8gai8MPtHYA/GiKBMiKtoTMpOhFS/j818Ivh9oBLKsjmOPkhhDs6JBdlesLh/w7SBOI8D0rt9vBBzB416UFONhCB0NQ5aEdLIf3RF4Guirb84eaZFArqZC+qdM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722771737; c=relaxed/simple; bh=lmFBhiEFLBTNsYdGWhN1b++NrZ+263IZTBSJ7kubIr0=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bM0mHbK12xv6T8hiXwhW/G0qYI7GPEJGEWaULIbM/yuNObi0mtUXzRyTBouTWMDueqiWs+xaqct0UdoO43tpi0tTbJ+QI3Q8WT60XiudFw0Y7tF3+S3gYwVbgqLmJl+RQSiUDwjP4LvEfIs8DaKYfgpHrkGhn6klxU158DpfgvQ= 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=K2uoVBSD; arc=none smtp.client-ip=209.85.221.53 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="K2uoVBSD" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-36ba3b06186so2311293f8f.2; Sun, 04 Aug 2024 04:42:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722771734; x=1723376534; 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=9UVSgx2w+2h8saQn7Nf58i+A85otGYnCOTiNQf2qOnE=; b=K2uoVBSD0ELWz0eusnK0ZRprj5Nq9upS7HNhMClNa4jAdQl3mLTwb20DxSOrCqyF2Z o+20kgR7+20Fb1afAnI0iPxgCj5hlYM2AKzT185Q2XnsWr9XIjudzX0x+yFXbLU36+4K AMwslH7C/AiTn2h9OMyXP1U74A7XtFN+DmEABusyPrskTnCzX1MM1ckiNST/hBKVIocA +h9Kr4qnmeLQONxcPq41m0EI8JNOXBQcl6qM0mbPwHPFW+eW9RvwTKqfyd/pJHG6LMXk LVbRkthjp4QmixqgUpRN1TW746eX4GH3ioD16LD8G7YChHBw8+173CuliPeaZF30yfQz Elpw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722771734; x=1723376534; 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=9UVSgx2w+2h8saQn7Nf58i+A85otGYnCOTiNQf2qOnE=; b=Z02l6aymLjUq5Nz1DFAwccsbAhlX/mfGbh+b4CeRLFzBg5qnKV4kwIuhzjfLm0SMmw nAr47jFbLvnz9piXaczaH1s9cV54hcsAkOQT+A1FdH44qR+fSEsJf2jvmPaPK31FwMfN O5fgqAzs8ptcp5uZhxSrJSYiDtS//HAA/343ULW71gukZEaVsPwUGIFADrI0ROSXhxGO WJUI6IMT06QUieeFYRzPrXGfLvyfVR1M4nMapTtT5ab8Ms/Rpzk3yaFvj/uEWGxIVP99 iFxehqze8QVOaczlw36QY9un5Q+I35J2w/7nwBlAfcEEVWwUaaqxZD5LOns8FKhKYdfM FRPw== X-Forwarded-Encrypted: i=1; AJvYcCWq/eW8QrL0P1Qb/uZbdAv1vyrVTqaH+psaiJdbA9Uvhep4SsQUzs1oZbB9saaHEVWcbMMlSKNyRxHL02SnyQRIlGZBEdQE+FciqOaYXaJ5A/N5xTvXZJbsDWDLdvBigdCSK4MU0qLm67VfsKEXuQwwNspvHFy1pDCsn1iDiUSVisxRRg== X-Gm-Message-State: AOJu0Yz0BkyetZ9RAg+nSmk9/podZ1niX4qVCOfyrA3G1bMF+C7Trjex dwEP9BFRHDflCgA3r/e/cbYtZW3mBKISPb4CFUWVQ9FC/KZodaFQ X-Google-Smtp-Source: AGHT+IGKaCDEArKFCkMRQiZKdcUjJdCjj4WZCLTvBf7YPdaEPgvS4EnneXBtmeDcGQXSLmrXmUCU+A== X-Received: by 2002:a05:6000:1faf:b0:368:d0d:a5d6 with SMTP id ffacd0b85a97d-36bbc1beb75mr5955443f8f.50.1722771733531; Sun, 04 Aug 2024 04:42:13 -0700 (PDT) Received: from localhost.localdomain ([109.52.148.115]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-36bbd01eff1sm6635130f8f.44.2024.08.04.04.42.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Aug 2024 04:42:13 -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 , Florian Fainelli , Thomas Bogendoerfer , Wolfram Sang , 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 6/6] mtd: parser: add support for Airoha parser Date: Sun, 4 Aug 2024 13:41:06 +0200 Message-ID: <20240804114108.1893-7-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240804114108.1893-1-ansuelsmth@gmail.com> References: <20240804114108.1893-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 | 56 +++++++++++++++++++++++++++++ drivers/mtd/parsers/ofpart_airoha.h | 18 ++++++++++ drivers/mtd/parsers/ofpart_core.c | 6 ++++ 5 files changed, 91 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..905df53f7716 --- /dev/null +++ b/drivers/mtd/parsers/ofpart_airoha.c @@ -0,0 +1,56 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2024 Christian Marangi + */ + +#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, }, {},