diff mbox series

[v2,6/6] mtd: parser: add support for Airoha parser

Message ID 20240804174414.18171-7-ansuelsmth@gmail.com
State Superseded
Headers show
Series mtd: improve block2mtd + airoha parser | expand

Commit Message

Christian Marangi Aug. 4, 2024, 5:44 p.m. UTC
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 <ansuelsmth@gmail.com>
---
 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

Comments

kernel test robot Aug. 4, 2024, 10:41 p.m. UTC | #1
Hi Christian,

kernel test robot noticed the following build errors:

[auto build test ERROR on robh/for-next]
[also build test ERROR on linus/master v6.11-rc1 next-20240802]
[cannot apply to mtd/mtd/next mtd/mtd/fixes]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/dt-bindings-nvme-Document-nvme-card-compatible/20240805-014740
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
patch link:    https://lore.kernel.org/r/20240804174414.18171-7-ansuelsmth%40gmail.com
patch subject: [PATCH v2 6/6] mtd: parser: add support for Airoha parser
config: arm-randconfig-003-20240805 (https://download.01.org/0day-ci/archive/20240805/202408050650.ScFbLl34-lkp@intel.com/config)
compiler: clang version 20.0.0git (https://github.com/llvm/llvm-project 423aec6573df4424f90555468128e17073ddc69e)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240805/202408050650.ScFbLl34-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408050650.ScFbLl34-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/mtd/parsers/ofpart_airoha.c:33:9: error: call to undeclared function 'kzalloc'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
      33 |         prop = kzalloc(sizeof(*prop), GFP_KERNEL);
         |                ^
>> drivers/mtd/parsers/ofpart_airoha.c:33:7: error: incompatible integer to pointer conversion assigning to 'struct property *' from 'int' [-Wint-conversion]
      33 |         prop = kzalloc(sizeof(*prop), GFP_KERNEL);
         |              ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   2 errors generated.


vim +/kzalloc +33 drivers/mtd/parsers/ofpart_airoha.c

    10	
    11	int airoha_partitions_post_parse(struct mtd_info *mtd,
    12					 struct mtd_partition *parts,
    13					 int nr_parts)
    14	{
    15		struct mtd_partition *part;
    16		int len, a_cells, s_cells;
    17		struct device_node *pp;
    18		struct property *prop;
    19		const __be32 *reg;
    20		__be32 *new_reg;
    21	
    22		part = &parts[nr_parts - 1];
    23		pp = part->of_node;
    24	
    25		/* Skip if ART partition have a valid offset instead of a dynamic one */
    26		if (!of_device_is_compatible(pp, "airoha,dynamic-art"))
    27			return 0;
    28	
    29		/* ART partition is set at the end of flash - size */
    30		part->offset = mtd->size - part->size;
    31	
    32		/* Update the offset with the new calculate value in DT */
  > 33		prop = kzalloc(sizeof(*prop), GFP_KERNEL);
kernel test robot Aug. 4, 2024, 10:52 p.m. UTC | #2
Hi Christian,

kernel test robot noticed the following build errors:

[auto build test ERROR on robh/for-next]
[also build test ERROR on linus/master v6.11-rc1 next-20240802]
[cannot apply to mtd/mtd/next mtd/mtd/fixes]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/dt-bindings-nvme-Document-nvme-card-compatible/20240805-014740
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
patch link:    https://lore.kernel.org/r/20240804174414.18171-7-ansuelsmth%40gmail.com
patch subject: [PATCH v2 6/6] mtd: parser: add support for Airoha parser
config: xtensa-allyesconfig (https://download.01.org/0day-ci/archive/20240805/202408050612.Ya1m6REu-lkp@intel.com/config)
compiler: xtensa-linux-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240805/202408050612.Ya1m6REu-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202408050612.Ya1m6REu-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/mtd/parsers/ofpart_airoha.c: In function 'airoha_partitions_post_parse':
   drivers/mtd/parsers/ofpart_airoha.c:33:16: error: implicit declaration of function 'kzalloc' [-Wimplicit-function-declaration]
      33 |         prop = kzalloc(sizeof(*prop), GFP_KERNEL);
         |                ^~~~~~~
>> drivers/mtd/parsers/ofpart_airoha.c:33:14: error: assignment to 'struct property *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
      33 |         prop = kzalloc(sizeof(*prop), GFP_KERNEL);
         |              ^


vim +33 drivers/mtd/parsers/ofpart_airoha.c

    10	
    11	int airoha_partitions_post_parse(struct mtd_info *mtd,
    12					 struct mtd_partition *parts,
    13					 int nr_parts)
    14	{
    15		struct mtd_partition *part;
    16		int len, a_cells, s_cells;
    17		struct device_node *pp;
    18		struct property *prop;
    19		const __be32 *reg;
    20		__be32 *new_reg;
    21	
    22		part = &parts[nr_parts - 1];
    23		pp = part->of_node;
    24	
    25		/* Skip if ART partition have a valid offset instead of a dynamic one */
    26		if (!of_device_is_compatible(pp, "airoha,dynamic-art"))
    27			return 0;
    28	
    29		/* ART partition is set at the end of flash - size */
    30		part->offset = mtd->size - part->size;
    31	
    32		/* Update the offset with the new calculate value in DT */
  > 33		prop = kzalloc(sizeof(*prop), GFP_KERNEL);
Christian Marangi Aug. 5, 2024, 2:54 a.m. UTC | #3
On Mon, Aug 05, 2024 at 06:52:04AM +0800, kernel test robot wrote:
> Hi Christian,
> 
> kernel test robot noticed the following build errors:
> 
> [auto build test ERROR on robh/for-next]
> [also build test ERROR on linus/master v6.11-rc1 next-20240802]
> [cannot apply to mtd/mtd/next mtd/mtd/fixes]
> [If your patch is applied to the wrong git tree, kindly drop us a note.
> And when submitting patch, we suggest to use '--base' as documented in
> https://git-scm.com/docs/git-format-patch#_base_tree_information]
> 
> url:    https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/dt-bindings-nvme-Document-nvme-card-compatible/20240805-014740
> base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
> patch link:    https://lore.kernel.org/r/20240804174414.18171-7-ansuelsmth%40gmail.com
> patch subject: [PATCH v2 6/6] mtd: parser: add support for Airoha parser
> config: xtensa-allyesconfig (https://download.01.org/0day-ci/archive/20240805/202408050612.Ya1m6REu-lkp@intel.com/config)
> compiler: xtensa-linux-gcc (GCC) 14.1.0
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240805/202408050612.Ya1m6REu-lkp@intel.com/reproduce)
> 
> If you fix the issue in a separate patch/commit (i.e. not just a new version of
> the same patch/commit), kindly add following tags
> | Reported-by: kernel test robot <lkp@intel.com>
> | Closes: https://lore.kernel.org/oe-kbuild-all/202408050612.Ya1m6REu-lkp@intel.com/
> 
> All errors (new ones prefixed by >>):
> 
>    drivers/mtd/parsers/ofpart_airoha.c: In function 'airoha_partitions_post_parse':
>    drivers/mtd/parsers/ofpart_airoha.c:33:16: error: implicit declaration of function 'kzalloc' [-Wimplicit-function-declaration]
>       33 |         prop = kzalloc(sizeof(*prop), GFP_KERNEL);
>          |                ^~~~~~~
> >> drivers/mtd/parsers/ofpart_airoha.c:33:14: error: assignment to 'struct property *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
>       33 |         prop = kzalloc(sizeof(*prop), GFP_KERNEL);
>          |              ^
> 
> 
> vim +33 drivers/mtd/parsers/ofpart_airoha.c
> 
>     10	
>     11	int airoha_partitions_post_parse(struct mtd_info *mtd,
>     12					 struct mtd_partition *parts,
>     13					 int nr_parts)
>     14	{
>     15		struct mtd_partition *part;
>     16		int len, a_cells, s_cells;
>     17		struct device_node *pp;
>     18		struct property *prop;
>     19		const __be32 *reg;
>     20		__be32 *new_reg;
>     21	
>     22		part = &parts[nr_parts - 1];
>     23		pp = part->of_node;
>     24	
>     25		/* Skip if ART partition have a valid offset instead of a dynamic one */
>     26		if (!of_device_is_compatible(pp, "airoha,dynamic-art"))
>     27			return 0;
>     28	
>     29		/* ART partition is set at the end of flash - size */
>     30		part->offset = mtd->size - part->size;
>     31	
>     32		/* Update the offset with the new calculate value in DT */
>   > 33		prop = kzalloc(sizeof(*prop), GFP_KERNEL);
> 
> -- 
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki

Mhhh somehow I can't repro this with instructions?
Philip Li Aug. 6, 2024, 9:23 a.m. UTC | #4
On Mon, Aug 05, 2024 at 04:54:45AM +0200, Christian Marangi wrote:
> On Mon, Aug 05, 2024 at 06:52:04AM +0800, kernel test robot wrote:
> > Hi Christian,
> > 
> > kernel test robot noticed the following build errors:
> > 
> > [auto build test ERROR on robh/for-next]
> > [also build test ERROR on linus/master v6.11-rc1 next-20240802]
> > [cannot apply to mtd/mtd/next mtd/mtd/fixes]
> > [If your patch is applied to the wrong git tree, kindly drop us a note.
> > And when submitting patch, we suggest to use '--base' as documented in
> > https://git-scm.com/docs/git-format-patch#_base_tree_information]
> > 
> > url:    https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/dt-bindings-nvme-Document-nvme-card-compatible/20240805-014740
> > base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
> > patch link:    https://lore.kernel.org/r/20240804174414.18171-7-ansuelsmth%40gmail.com
> > patch subject: [PATCH v2 6/6] mtd: parser: add support for Airoha parser
> > config: xtensa-allyesconfig (https://download.01.org/0day-ci/archive/20240805/202408050612.Ya1m6REu-lkp@intel.com/config)
> > compiler: xtensa-linux-gcc (GCC) 14.1.0
> > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240805/202408050612.Ya1m6REu-lkp@intel.com/reproduce)
> > 
> > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > the same patch/commit), kindly add following tags
> > | Reported-by: kernel test robot <lkp@intel.com>
> > | Closes: https://lore.kernel.org/oe-kbuild-all/202408050612.Ya1m6REu-lkp@intel.com/
> > 
> > All errors (new ones prefixed by >>):
> > 
> >    drivers/mtd/parsers/ofpart_airoha.c: In function 'airoha_partitions_post_parse':
> >    drivers/mtd/parsers/ofpart_airoha.c:33:16: error: implicit declaration of function 'kzalloc' [-Wimplicit-function-declaration]
> >       33 |         prop = kzalloc(sizeof(*prop), GFP_KERNEL);
> >          |                ^~~~~~~
> > >> drivers/mtd/parsers/ofpart_airoha.c:33:14: error: assignment to 'struct property *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
> >       33 |         prop = kzalloc(sizeof(*prop), GFP_KERNEL);
> >          |              ^
> > 
> > 
> > vim +33 drivers/mtd/parsers/ofpart_airoha.c
> > 
> >     10	
> >     11	int airoha_partitions_post_parse(struct mtd_info *mtd,
> >     12					 struct mtd_partition *parts,
> >     13					 int nr_parts)
> >     14	{
> >     15		struct mtd_partition *part;
> >     16		int len, a_cells, s_cells;
> >     17		struct device_node *pp;
> >     18		struct property *prop;
> >     19		const __be32 *reg;
> >     20		__be32 *new_reg;
> >     21	
> >     22		part = &parts[nr_parts - 1];
> >     23		pp = part->of_node;
> >     24	
> >     25		/* Skip if ART partition have a valid offset instead of a dynamic one */
> >     26		if (!of_device_is_compatible(pp, "airoha,dynamic-art"))
> >     27			return 0;
> >     28	
> >     29		/* ART partition is set at the end of flash - size */
> >     30		part->offset = mtd->size - part->size;
> >     31	
> >     32		/* Update the offset with the new calculate value in DT */
> >   > 33		prop = kzalloc(sizeof(*prop), GFP_KERNEL);
> > 
> > -- 
> > 0-DAY CI Kernel Test Service
> > https://github.com/intel/lkp-tests/wiki
> 
> Mhhh somehow I can't repro this with instructions?

Hi Ansuel, would you mind sharing the steps of reproduce? I can reproduce this with steps
described in the repro link [1]

[1] https://download.01.org/0day-ci/archive/20240805/202408050612.Ya1m6REu-lkp@intel.com/reproduce

> -- 
> 	Ansuel
>
Christian Marangi Aug. 6, 2024, 11:32 a.m. UTC | #5
On Tue, Aug 06, 2024 at 05:23:43PM +0800, Philip Li wrote:
> On Mon, Aug 05, 2024 at 04:54:45AM +0200, Christian Marangi wrote:
> > On Mon, Aug 05, 2024 at 06:52:04AM +0800, kernel test robot wrote:
> > > Hi Christian,
> > > 
> > > kernel test robot noticed the following build errors:
> > > 
> > > [auto build test ERROR on robh/for-next]
> > > [also build test ERROR on linus/master v6.11-rc1 next-20240802]
> > > [cannot apply to mtd/mtd/next mtd/mtd/fixes]
> > > [If your patch is applied to the wrong git tree, kindly drop us a note.
> > > And when submitting patch, we suggest to use '--base' as documented in
> > > https://git-scm.com/docs/git-format-patch#_base_tree_information]
> > > 
> > > url:    https://github.com/intel-lab-lkp/linux/commits/Christian-Marangi/dt-bindings-nvme-Document-nvme-card-compatible/20240805-014740
> > > base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
> > > patch link:    https://lore.kernel.org/r/20240804174414.18171-7-ansuelsmth%40gmail.com
> > > patch subject: [PATCH v2 6/6] mtd: parser: add support for Airoha parser
> > > config: xtensa-allyesconfig (https://download.01.org/0day-ci/archive/20240805/202408050612.Ya1m6REu-lkp@intel.com/config)
> > > compiler: xtensa-linux-gcc (GCC) 14.1.0
> > > reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240805/202408050612.Ya1m6REu-lkp@intel.com/reproduce)
> > > 
> > > If you fix the issue in a separate patch/commit (i.e. not just a new version of
> > > the same patch/commit), kindly add following tags
> > > | Reported-by: kernel test robot <lkp@intel.com>
> > > | Closes: https://lore.kernel.org/oe-kbuild-all/202408050612.Ya1m6REu-lkp@intel.com/
> > > 
> > > All errors (new ones prefixed by >>):
> > > 
> > >    drivers/mtd/parsers/ofpart_airoha.c: In function 'airoha_partitions_post_parse':
> > >    drivers/mtd/parsers/ofpart_airoha.c:33:16: error: implicit declaration of function 'kzalloc' [-Wimplicit-function-declaration]
> > >       33 |         prop = kzalloc(sizeof(*prop), GFP_KERNEL);
> > >          |                ^~~~~~~
> > > >> drivers/mtd/parsers/ofpart_airoha.c:33:14: error: assignment to 'struct property *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
> > >       33 |         prop = kzalloc(sizeof(*prop), GFP_KERNEL);
> > >          |              ^
> > > 
> > > 
> > > vim +33 drivers/mtd/parsers/ofpart_airoha.c
> > > 
> > >     10	
> > >     11	int airoha_partitions_post_parse(struct mtd_info *mtd,
> > >     12					 struct mtd_partition *parts,
> > >     13					 int nr_parts)
> > >     14	{
> > >     15		struct mtd_partition *part;
> > >     16		int len, a_cells, s_cells;
> > >     17		struct device_node *pp;
> > >     18		struct property *prop;
> > >     19		const __be32 *reg;
> > >     20		__be32 *new_reg;
> > >     21	
> > >     22		part = &parts[nr_parts - 1];
> > >     23		pp = part->of_node;
> > >     24	
> > >     25		/* Skip if ART partition have a valid offset instead of a dynamic one */
> > >     26		if (!of_device_is_compatible(pp, "airoha,dynamic-art"))
> > >     27			return 0;
> > >     28	
> > >     29		/* ART partition is set at the end of flash - size */
> > >     30		part->offset = mtd->size - part->size;
> > >     31	
> > >     32		/* Update the offset with the new calculate value in DT */
> > >   > 33		prop = kzalloc(sizeof(*prop), GFP_KERNEL);
> > > 
> > > -- 
> > > 0-DAY CI Kernel Test Service
> > > https://github.com/intel/lkp-tests/wiki
> > 
> > Mhhh somehow I can't repro this with instructions?
> 
> Hi Ansuel, would you mind sharing the steps of reproduce? I can reproduce this with steps
> described in the repro link [1]
> 
> [1] https://download.01.org/0day-ci/archive/20240805/202408050612.Ya1m6REu-lkp@intel.com/reproduce
>

Hi, thanks for confirming that. Manage to repro, just had dirty
build-dir and config wasn't correctly applying.
diff mbox series

Patch

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 <ansuelsmth@gmail.com>
+ */
+
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+
+#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 <linux/slab.h>
 #include <linux/mtd/partitions.h>
 
+#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, },
 	{},