linux/drivers/mtd/parsers/bcm63xxpart.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * BCM63XX CFE image tag parser
 *
 * Copyright © 2006-2008  Florian Fainelli <[email protected]>
 *			  Mike Albon <[email protected]>
 * Copyright © 2009-2010  Daniel Dickinson <[email protected]>
 * Copyright © 2011-2013  Jonas Gorski <[email protected]>
 */

#define pr_fmt(fmt)

#include <linux/bcm963xx_nvram.h>
#include <linux/bcm963xx_tag.h>
#include <linux/crc32.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/sizes.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/mtd/mtd.h>
#include <linux/mtd/partitions.h>
#include <linux/of.h>

#ifdef CONFIG_MIPS
#include <asm/bootinfo.h>
#include <asm/fw/cfe/cfe_api.h>
#endif /* CONFIG_MIPS */

#define BCM963XX_CFE_BLOCK_SIZE

#define BCM963XX_CFE_MAGIC_OFFSET
#define BCM963XX_CFE_VERSION_OFFSET
#define BCM963XX_NVRAM_OFFSET

/* Ensure strings read from flash structs are null terminated */
#define STR_NULL_TERMINATE(x)

static inline int bcm63xx_detect_cfe(void)
{}

static int bcm63xx_read_nvram(struct mtd_info *master,
	struct bcm963xx_nvram *nvram)
{}

static const char * const bcm63xx_cfe_part_types[] =;

static int bcm63xx_parse_cfe_nor_partitions(struct mtd_info *master,
	const struct mtd_partition **pparts, struct bcm963xx_nvram *nvram)
{}

static int bcm63xx_parse_cfe_partitions(struct mtd_info *master,
					const struct mtd_partition **pparts,
					struct mtd_part_parser_data *data)
{
	struct bcm963xx_nvram *nvram = NULL;
	int ret;

	if (!bcm63xx_detect_cfe())
		return -EINVAL;

	nvram = vzalloc(sizeof(*nvram));
	if (!nvram)
		return -ENOMEM;

	ret = bcm63xx_read_nvram(master, nvram);
	if (ret)
		goto out;

	if (!mtd_type_is_nand(master))
		ret = bcm63xx_parse_cfe_nor_partitions(master, pparts, nvram);
	else
		ret = -EINVAL;

out:
	vfree(nvram);
	return ret;
};

static const struct of_device_id parse_bcm63xx_cfe_match_table[] =;
MODULE_DEVICE_TABLE(of, parse_bcm63xx_cfe_match_table);

static struct mtd_part_parser bcm63xx_cfe_parser =;
module_mtd_part_parser();

MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_AUTHOR();
MODULE_DESCRIPTION();