Example #1
0
static int arg_off_size(int argc, char *argv[],
	uint64_t chipsize,
	uint64_t *off,
	uint64_t *size)
{
	if (argc >= 1) {
		if (!(str2longlong(argv[0], (unsigned long long *)off))) {
			aml_nand_dbg("'%s' is not a number", argv[0]);
			return -1;
		}
	} else
		*off = 0;

	if (argc >= 2) {
		if (!(str2longlong(argv[1], (unsigned long long *)size))) {
			aml_nand_dbg("'%s' is not a number", argv[1]);
			return -1;
		}
	} else
		*size = chipsize - *off;

	if (*size == chipsize)
		aml_nand_dbg("whole chip/dev");
	else
		aml_nand_dbg("offset 0x%llx, size 0x%llx", *off, *size);

	return 0;
}
int roomboot_nand_read(struct amlnand_phydev *phydev)
{	
	struct amlnand_chip *aml_chip = (struct amlnand_chip *)phydev->priv;	
	struct phydev_ops *devops = &(phydev->ops);
	struct hw_controller *controller = &(aml_chip->controller); 
	struct chip_operation *operation = &(aml_chip->operation);	
	struct chip_ops_para *ops_para = &(aml_chip->ops_para);

	uint64_t offset , write_len;
	unsigned char * buffer;
	int ret = 0;
	int oob_set = 0;

	offset = devops->addr;
	write_len = devops->len;
	buffer = devops->datbuf;
	
	memset(devops, 0x0, sizeof(struct phydev_ops));
	devops->addr = offset;
	devops->len = write_len;
	devops->datbuf = buffer;		
	devops->oobbuf = NULL;
	devops->mode = NAND_HW_ECC;
	if(controller->oob_mod) {
		oob_set = controller->oob_mod;
		NFC_CLR_OOB_MODE(3<<26);
		controller->oob_mod =0;
	}
	
	amlnand_get_device(aml_chip, CHIP_READING);
	ret = read_uboot(phydev);
	if(ret < 0){
		aml_nand_dbg("nand read failed at %llx",devops->addr);
	}
	amlnand_release_device(aml_chip);
	if(oob_set) {
		controller->oob_mod =oob_set;
		NFC_SET_OOB_MODE(3<<26);
	}
	return ret ;
}
Example #3
0
int amlnand_get_partition_table(void)
{	
	int ret=0;

	if(part_table == NULL){
		aml_nand_msg("part_table from ACS is NULL, do not init nand");
		return -NAND_FAILED;
	}
	
	amlnand_config = aml_nand_malloc(MAX_NAND_PART_NUM * sizeof(struct amlnf_partition));
	if(!amlnand_config){
		aml_nand_dbg("amlnand_config: malloc failed!");
		ret = -NAND_MALLOC_FAILURE;
	}
	
	//show_partition_table();

	memcpy(amlnand_config, part_table, (MAX_NAND_PART_NUM * sizeof(struct amlnf_partition)));
	
	return ret;
}
Example #4
0
int aml_key_init(struct amlnand_chip *aml_chip)
{
	int ret = 0;
	meson_key *key_ptr = NULL;
	aml_keybox_provider_t *provider; 
	
	key_ptr = aml_nand_malloc(CONFIG_KEYSIZE);
	if (key_ptr == NULL){
		aml_nand_msg("nand malloc for key_ptr failed");
		ret = -1;
		goto exit_error0;
	}
	memset(key_ptr,0x0,CONFIG_KEYSIZE);
	aml_nand_dbg("nand key: nand_key_probe. ");

	ret = amlnand_info_init(aml_chip, (unsigned char *)&(aml_chip->nand_key),(unsigned char *)key_ptr,(unsigned char *)KEY_INFO_HEAD_MAGIC, CONFIG_KEYSIZE);
	if(ret < 0){
		aml_nand_msg("invalid nand key\n");
	}
	
	aml_chip_key = aml_chip;
	nand_provider.priv=aml_chip_key;	

	provider = aml_keybox_provider_get(nand_provider.name); 
	if(provider){ 
		return ret; 
	} 
	
	ret = aml_keybox_provider_register(&nand_provider); 
	if(ret){ 
		BUG(); 
	} 
	
exit_error0:
	if(key_ptr){
		aml_nand_free(key_ptr);
		key_ptr =NULL;
	}
	return ret;
}
Example #5
0
int aml_secure_init(struct amlnand_chip *aml_chip)
{
	int ret = 0;
	unsigned char *secure_ptr = NULL;
	
	secure_ptr = aml_nand_malloc(CONFIG_SECURE_SIZE);
	if (secure_ptr == NULL){
		aml_nand_msg("nand malloc for secure_ptr failed");
		ret = -1;
		goto exit_error0;
	}
	memset(secure_ptr,0x0,CONFIG_SECURE_SIZE);
	aml_nand_dbg("nand secure: nand_secure_probe. ");
	
	ret = amlnand_info_init(aml_chip, (unsigned char *)(&aml_chip->nand_secure),secure_ptr,(unsigned char *)SECURE_INFO_HEAD_MAGIC, CONFIG_SECURE_SIZE);
	if(ret < 0){
		aml_nand_msg("invalid nand secure_ptr\n");
		ret = -1;
		goto exit_error0;
	}

#if 0
	aml_nand_msg("nand secure debug :: save secure again !!!!");
	ret = amlnand_save_info_by_name( aml_chip,&(aml_chip->nand_secure),secure_ptr, SECURE_INFO_HEAD_MAGIC,CONFIG_SECURE_SIZE);
	if(ret < 0){
		aml_nand_msg("nand save default secure_ptr failed aigain!!");
	}

#endif
	
	aml_chip_secure = aml_chip;

exit_error0:
	if(secure_ptr){
		aml_nand_free(secure_ptr);
		secure_ptr =NULL;
	}
	return ret;
}