int fuji_bin_download(struct ois_i2c_bin_list bin_list)
{
	int rc = 0;
	int cnt = 0;
	int32_t read_value_32t;

	/* check OIS ic is alive */
	if (!fuji_ois_poll_ready(LIMIT_STATUS_POLLING)) {
		printk("%s: no reply 1\n", __func__);
		rc = OIS_INIT_I2C_ERROR;
		goto END;
	}

	/* Send command ois start dl */
	rc = RegWriteA(OIS_START_DL_ADDR, 0x00);

	while (rc < 0 && cnt < LIMIT_STATUS_POLLING) {
		usleep(2000);
		rc = RegWriteA(OIS_START_DL_ADDR, 0x00);
		cnt++;
	}

	if (rc < 0) {
		printk("%s: no reply 2\n", __func__);
		rc = OIS_INIT_I2C_ERROR;
		goto END;
	}

	/* OIS program downloading */
	rc = ois_i2c_load_and_write_bin_list(bin_list);
	if (rc < 0)
		goto END;
	
	/* Check sum value!*/
	RamRead32A( OIS_CHECK_SUM_ADDR , &read_value_32t );
	if (read_value_32t != bin_list.checksum) {
		printk("%s: error [0xF008]checksum = 0x%x, bin_checksum 0x%x\n", __func__,
			read_value_32t, bin_list.checksum);
		rc = OIS_INIT_CHECKSUM_ERROR;
		goto END;
	}

	rc = ois_i2c_load_and_write_e2prom_data(E2P_FIRST_ADDR, E2P_DATA_BYTE,
		CTL_END_ADDR_FOR_E2P_DL);
	if (rc < 0)
		goto END;

	/* Send command ois complete dl */
	RegWriteA(OIS_COMPLETE_DL_ADDR, 0x00) ;

	/* Read ois status */
	if (!fuji_ois_poll_ready(LIMIT_STATUS_POLLING)) {
		printk("%s: no reply 3\n", __func__);
		rc = OIS_INIT_TIMEOUT;
		goto END;
	}

	printk("%s, complete dl FINISHED! \n", __func__);

END:
	return rc;
}
Exemple #2
0
static int lgit2_bin_download(struct ois_i2c_bin_list bin_list)
{
    int rc = 0;
    int cnt = 0;
    int32_t read_value_32t;

    CDBG("%s\n", __func__);

    /* check OIS ic is alive */
    if (!lgit_ois_rohm_poll_ready(LIMIT_STATUS_POLLING)) {
        pr_err("%s: no reply 1\n", __func__);
        return OIS_INIT_I2C_ERROR;
    }

    /* Send command ois start dl */
    rc = reg_write_addr(OIS_START_DL_ADDR, 0x00);
    while (rc < 0 && cnt < LIMIT_STATUS_POLLING) {
        usleep(2000);
        rc = reg_write_addr(OIS_START_DL_ADDR, 0x00);
        cnt ++;
    }

    if (rc < 0) {
        pr_err("%s: no reply \n", __func__);
        return OIS_INIT_I2C_ERROR;
    }

    /* OIS program downloading */
    rc = ois_i2c_load_and_write_bin_list(bin_list);
    if (rc < 0) {
        pr_err("%s: ois program downloading error\n", __func__);
        return OIS_INIT_I2C_ERROR;
    }

    /* Check sum value!*/
    ram_read_32addr(OIS_CHECK_SUM_ADDR , &read_value_32t);
    if (read_value_32t != bin_list.checksum) {
        pr_err("%s: sum = 0x%x\n", __func__, read_value_32t);
        return OIS_INIT_I2C_ERROR;
    }

    rc = ois_i2c_load_and_write_e2prom_data(E2P_FIRST_ADDR,
                                            E2P_DATA_BYTE, CTL_END_ADDR_FOR_E2P_DL);
    if (rc < 0) {
        pr_err("%s: ois write e2prom error\n", __func__);
        return OIS_INIT_I2C_ERROR;
    }

    /* Send command ois complete dl */
    rc = reg_write_addr(OIS_COMPLETE_DL_ADDR, 0x00) ;
    if (rc < 0) {
        pr_err("%s: ois complete error\n", __func__);
        return OIS_INIT_I2C_ERROR;
    }

    /* Read ois status */
    if (!lgit_ois_rohm_poll_ready(LIMIT_STATUS_POLLING)) {
        pr_err("%s: no reply 3\n", __func__);
        return OIS_INIT_I2C_ERROR;
    }
    pr_info("%s, complete dl FINISHED!\n", __func__);
    return rc;
}