Example #1
0
void mmc_read_partition_table(uint8_t arg)
{
	void *dev;
	uint8_t lun = 0;
	uint8_t max_luns;

	dev = target_mmc_device();

	if(!target_mmc_device())
	{
		max_luns = ufs_get_num_of_luns((struct ufs_dev*)dev);

		ASSERT(max_luns);

		for(lun = arg; lun < max_luns; lun++)
		{
			mmc_set_lun(lun);

			if(partition_read_table())
			{
				dprintf(CRITICAL, "Error reading the partition table info for lun %d\n", lun);
			}
		}
		mmc_set_lun(0);
	}
	else
	{
		if(partition_read_table())
		{
			dprintf(CRITICAL, "Error reading the partition table info\n");
		}
	}
}
static int mdss_dsi_dfps_store_pll_codes(struct msm_panel_info *pinfo)
{
	int ret = NO_ERROR;
	int index;
	unsigned long long ptn;

	index = partition_get_index("splash");
	if (index == INVALID_PTN) {
		dprintf(INFO, "%s: splash partition table not found\n", __func__);
		ret = NO_ERROR;
		goto store_err;
	}

	ptn = partition_get_offset(index);
	if (ptn == 0) {
		dprintf(CRITICAL, "ERROR: splash Partition invalid offset\n");
		ret = ERROR;
		goto store_err;
	}

	mmc_set_lun(partition_get_lun(index));

	ret = mmc_write(ptn, sizeof(uint32_t), &pinfo->dfps);
	if (ret)
		dprintf(CRITICAL, "mmc write failed!\n");

store_err:
	return ret;
}
Example #3
0
static int emmc_get_recovery_msg(struct recovery_message *in)
{
	char *ptn_name = "misc";
	unsigned long long ptn = 0;
	unsigned int size;
	int index = INVALID_PTN;

	size = mmc_get_device_blocksize();
	index = partition_get_index((const char *) ptn_name);
	if (index < 0)
	{
		dprintf(CRITICAL, "%s: Partition not found\n", ptn_name);
		return -1;
	}

	ptn = partition_get_offset(index);
	mmc_set_lun(partition_get_lun(index));
	if(ptn == 0) {
		dprintf(CRITICAL,"partition %s doesn't exist\n",ptn_name);
		return -1;
	}
	if (mmc_read(ptn , (unsigned int*)in, size)) {
		dprintf(CRITICAL,"mmc read failure %s %d\n",ptn_name, size);
		return -1;
	}

	return 0;
}
Example #4
0
static int read_misc(unsigned page_offset, void *buf, unsigned size)
{
	const char *ptn_name = "misc";
	uint32_t pagesize = get_page_size();
	unsigned offset;

	if (size == 0 || buf == NULL)
		return -1;

	offset = page_offset * pagesize;

	if (target_is_emmc_boot())
	{
		int index;
		unsigned long long ptn;
		unsigned long long ptn_size;

		index = partition_get_index(ptn_name);
		if (index == INVALID_PTN)
		{
			dprintf(CRITICAL, "No '%s' partition found\n", ptn_name);
			return -1;
		}

		ptn = partition_get_offset(index);
		ptn_size = partition_get_size(index);

		mmc_set_lun(partition_get_lun(index));

		if (ptn_size < offset + size)
		{
			dprintf(CRITICAL, "Read request out of '%s' boundaries\n",
					ptn_name);
			return -1;
		}

		if (mmc_read(ptn + offset, (unsigned int *)buf, size))
		{
			dprintf(CRITICAL, "Reading MMC failed\n");
			return -1;
		}
	}
	else
	{
		dprintf(CRITICAL, "Misc partition not supported for NAND targets.\n");
		return -1;
	}

	return 0;
}
Example #5
0
static int emmc_set_recovery_msg(struct recovery_message *out)
{
	char *ptn_name = "misc";
	unsigned long long ptn = 0;
	unsigned int size = ROUND_TO_PAGE(sizeof(*out),511);
	unsigned char data[size];
	int index = INVALID_PTN;

	index = partition_get_index((const char *) ptn_name);
	ptn = partition_get_offset(index);
	mmc_set_lun(partition_get_lun(index));
	if(ptn == 0) {
		dprintf(CRITICAL,"partition %s doesn't exist\n",ptn_name);
		return -1;
	}
	memcpy(data, out, sizeof(*out));
	if (mmc_write(ptn , size, (unsigned int*)data)) {
		dprintf(CRITICAL,"mmc write failure %s %d\n",ptn_name, sizeof(*out));
		return -1;
	}
	return 0;
}
static int mdss_dsi_dfps_get_stored_pll_codes(struct msm_panel_info *pinfo)
{
	int ret = NO_ERROR;
	int index;
	unsigned long long ptn;
	uint32_t blocksize;
	struct dfps_info *dfps;

	index = partition_get_index("splash");
	if (index == INVALID_PTN) {
		dprintf(INFO, "%s: splash partition table not found\n", __func__);
		ret = NO_ERROR;
		goto splash_err;
	}

	ptn = partition_get_offset(index);
	if (ptn == 0) {
		dprintf(CRITICAL, "ERROR: splash Partition invalid offset\n");
		ret = ERROR;
		goto splash_err;
	}

	mmc_set_lun(partition_get_lun(index));

	blocksize = mmc_get_device_blocksize();
	if (blocksize == 0) {
		dprintf(CRITICAL, "ERROR:splash Partition invalid blocksize\n");
		ret = ERROR;
		goto splash_err;
	}

	dfps = (struct dfps_info *)memalign(CACHE_LINE, ROUNDUP(PAGE_SIZE,
			CACHE_LINE));
	if (!dfps) {
		dprintf(CRITICAL, "ERROR:splash Partition invalid memory\n");
		ret = ERROR;
		goto splash_err;
	}

	if (mmc_read(ptn, (uint32_t *) dfps, blocksize)) {
		dprintf(CRITICAL, "mmc read splash failure%d\n", PAGE_SIZE);
		ret = ERROR;
		free(dfps);
		goto splash_err;
	}

	dprintf(SPEW, "enable=%d cnt=%d\n", dfps->panel_dfps.enabled,
		dfps->panel_dfps.frame_rate_cnt);

	if (!dfps->panel_dfps.enabled || dfps->panel_dfps.frame_rate_cnt >
		DFPS_MAX_FRAME_RATE) {
		ret = ERROR;
		free(dfps);
		goto splash_err;
	}

	pinfo->dfps = *dfps;
	free(dfps);

splash_err:
	return ret;
}
int write_misc(unsigned page_offset, void *buf, unsigned size)
{
	const char *ptn_name = "misc";
	void *scratch_addr = target_get_scratch_address();
	unsigned offset;
	unsigned aligned_size;

	if (size == 0 || buf == NULL || scratch_addr == NULL)
		return -1;

	if (target_is_emmc_boot())
	{
		int index;
		unsigned long long ptn;
		unsigned long long ptn_size;

		index = partition_get_index(ptn_name);
		if (index == INVALID_PTN)
		{
			dprintf(CRITICAL, "No '%s' partition found\n", ptn_name);
			return -1;
		}

		ptn = partition_get_offset(index);
		ptn_size = partition_get_size(index);

		offset = page_offset * BLOCK_SIZE;
		aligned_size = ROUND_TO_PAGE(size, (unsigned)BLOCK_SIZE - 1);
		if (ptn_size < offset + aligned_size)
		{
			dprintf(CRITICAL, "Write request out of '%s' boundaries\n",
					ptn_name);
			return -1;
		}

		if (scratch_addr != buf)
			memcpy(scratch_addr, buf, size);

		/* Set Lun for misc partition */
		mmc_set_lun(partition_get_lun(index));

		if (mmc_write(ptn + offset, aligned_size, (unsigned int *)scratch_addr))
		{
			dprintf(CRITICAL, "Writing MMC failed\n");
			return -1;
		}
	}
	else
	{
		struct ptentry *ptn;
		struct ptable *ptable;
		unsigned pagesize = flash_page_size();

		ptable = flash_get_ptable();
		if (ptable == NULL)
		{
			dprintf(CRITICAL, "Partition table not found\n");
			return -1;
		}

		ptn = ptable_find(ptable, ptn_name);
		if (ptn == NULL)
		{
			dprintf(CRITICAL, "No '%s' partition found\n", ptn_name);
			return -1;
		}

		offset = page_offset * pagesize;
		aligned_size = ROUND_TO_PAGE(size, pagesize - 1);
		if (ptn->length < offset + aligned_size)
		{
			dprintf(CRITICAL, "Write request out of '%s' boundaries\n",
					ptn_name);
			return -1;
		}

		if (scratch_addr != buf)
			memcpy(scratch_addr, buf, size);
		if (flash_write(ptn, offset, scratch_addr, aligned_size)) {
			dprintf(CRITICAL, "Writing flash failed\n");
			return -1;
		}
	}

	return 0;
}