Пример #1
0
/**
 * imx_bbu_write_fcb - Write FCB and DBBT raw data to the device
 * @mtd: The mtd Nand device
 * @block: The block to write to
 * @fcb_raw_page: The raw FCB data
 * @dbbt_data_page: The DBBT data
 *
 * This function writes the FCB/DBBT data to the block given in @block
 * to the Nand device. The FCB data has to be given in the raw flash
 * layout, already with ecc data supplied.
 *
 * return: 0 on success or a negative error code otherwise.
 */
static int imx_bbu_write_fcb(struct mtd_info *mtd, int block, void *fcb_raw_page,
			     void *dbbt_data_page)
{
	struct dbbt_block *dbbt;
	int ret;
	int retries = 0;
	uint32_t *n_bad_blocksp = dbbt_data_page + 0x4;
again:
	dbbt = xzalloc(mtd->writesize);

	dbbt->Checksum = 0;
	dbbt->FingerPrint = 0x54424244;
	dbbt->Version = 0x01000000;
	if (dbbt_data_page)
		dbbt->DBBTNumOfPages = 1;
	if (cpu_is_mx28())
		imx28_dbbt_create(dbbt, *n_bad_blocksp);

	ret = mtd_peb_erase(mtd, block);
	if (ret)
		return ret;

	ret = raw_write_page(mtd, fcb_raw_page, block * mtd->erasesize);
	if (ret) {
		pr_err("Writing FCB on block %d failed with %s\n",
		       block, strerror(-ret));
		goto out;
	}

	ret = mtd_peb_write(mtd, (void *)dbbt, block, mtd->writesize,
			    mtd->writesize);
	if (ret < 0) {
		pr_err("Writing DBBT header on block %d failed with %s\n",
		       block, strerror(-ret));
		goto out;
	}

	if (dbbt_data_page) {
		ret = mtd_peb_write(mtd, dbbt_data_page, block, mtd->writesize * 5,
				    mtd->writesize);
		if (ret < 0) {
			pr_err("Writing DBBT on block %d failed with %s\n",
			       block, strerror(-ret));
			goto out;
		}
	}

	ret = 0;
out:
	free(dbbt);

	if (ret == -EBADMSG) {
		ret = mtd_peb_torture(mtd, block);

		if (!ret && retries++ < 3)
			goto again;
	}

	return ret;
}
Пример #2
0
static int
utp_ioctl(struct inode *inode, struct file *file,
	      unsigned int cmd, unsigned long arg)
{
	int cpu_id = 0;
	switch (cmd) {
	case UTP_GET_CPU_ID:
/* Currently, it only supports below SoC for manufacture tool
 * The naming rule
 * 1. The numberic for SoC string
 * 2. If there is next SoC version, and the corresponding utp
 * operation will be differ, then, need to add '1' next to SoC
 * name. Such as the next 50 SoC version is: cpu_is = 501
 */
#ifdef CONFIG_ARCH_MXS
		if (cpu_is_mx23())
			cpu_id = 23;
		else if (cpu_is_mx28())
			cpu_id = 28;
#endif
#ifdef CONFIG_ARCH_MXC
		if (cpu_is_mx25())
			cpu_id = 25;
		else if (cpu_is_mx35())
			cpu_id = 35;
		else if (cpu_is_mx51())
			cpu_id = 51;
		else if (cpu_is_mx53())
			cpu_id = 53;
		else if (cpu_is_mx50())
			cpu_id = 50;
#endif
		return put_user(cpu_id, (int __user *)arg);
	default:
		return -ENOIOCTLCMD;
	}
}