Example #1
0
File: cfam.c Project: shenki/pdbg
static int cfam_hmfsi_probe(struct pdbg_target *target)
{
	struct fsi *fsi = target_to_fsi(target);
	struct pdbg_target *fsi_parent = target->parent;
	uint32_t value, port;
	int rc;

	/* Enable the port in the upstream control register */
	port = dt_prop_get_u32(target, "port");
	fsi_read(fsi_parent, 0x3404, &value);
	value |= 1 << (31 - port);
	if ((rc = fsi_write(fsi_parent, 0x3404, value))) {
		PR_ERROR("Unable to enable HMFSI port %d\n", port);
		return rc;
	}

	if ((rc = fsi_read(&fsi->target, 0xc09, &value)))
		return rc;

	fsi->chip_type = get_chip_type(value);

	PR_DEBUG("Found chip type %x\n", fsi->chip_type);
	if (fsi->chip_type == CHIP_UNKNOWN)
		return -1;

	return 0;
}
Example #2
0
File: cfam.c Project: shenki/pdbg
static int fsi2pib_getscom(struct pib *pib, uint64_t addr, uint64_t *value)
{
	uint32_t result;

	usleep(FSI2PIB_RELAX);

	/* Get scom works by putting the address in FSI_CMD_REG and
	 * reading the result from FST_DATA[01]_REG. */
	CHECK_ERR(fsi_write(&pib->target, FSI_CMD_REG, addr));
	CHECK_ERR(fsi_read(&pib->target, FSI_DATA0_REG, &result));
	*value = ((uint64_t) result) << 32;
	CHECK_ERR(fsi_read(&pib->target, FSI_DATA1_REG, &result));
	*value |= result;

	return 0;
}
Example #3
0
File: cfam.c Project: shenki/pdbg
static int cfam_hmfsi_read(struct fsi *fsi, uint32_t addr, uint32_t *data)
{
	struct pdbg_target *parent_fsi = pdbg_target_require_parent("fsi", &fsi->target);

	addr += dt_get_address(&fsi->target, 0, NULL);

	return fsi_read(parent_fsi, addr, data);
}
Example #4
0
//2 <sparam>=0, check & start calib if not calibrated
//2 <sparam>=1, force to start calib
int 		TSCalibAppMsgHandler(t_sparam sparam, t_lparam lparam)
{
	t_TSCalibData *glob;
	int ret = EBADPARM;
	
	t_TsdInterface *vtbl;
	char *model = NULL;
	gboolean force = *((gboolean*)lparam);
	
	vtbl = ams_query_interface("tsd");
	if(vtbl && vtbl->GetModel)
		model = vtbl->GetModel();
	if(vtbl == NULL || model == 0 || *model == 0 || vtbl->StartCalib == NULL){
		return SUCCESS;
	}
	
	glob = MALLOC(sizeof(t_TSCalibData));
	memset(glob, 0, sizeof(t_TSCalibData));
	app_set_data(glob);
	
	glob->vtbl = vtbl;
	if(vtbl->Init)vtbl->Init();
	if(vtbl->Wakeup)vtbl->Wakeup();
	
	if(force == FALSE){
		int fd = fsi_open(TS_CALIB_FILE, _O_RDONLY, _S_IREAD);
		if(fd < 0){
			goto start_calib;
		}
		if(fsi_read(fd, &glob->points, sizeof(glob->points)) != sizeof(glob->points)){
			fsi_close(fd);
			goto start_calib;
		}
		fsi_close(fd);
		if(vtbl->StartCalib){
			glob->points.n--;
			if(vtbl->StartCalib(&gs_calib_const, &glob->points) == FALSE){
				goto start_calib;
			}
		}
		ret = SUCCESS;
		goto out;
	}
start_calib:
	amos_set_tscalib(TRUE);
	glob->points.n = 0;
	glob->gdi = lcd_create_gdi();
	if(wnd_show(wnd_create(tscalib_WndMsgHandler, FALSE, 0)))
		ret = app_loop(NULL);
out:	
	amos_set_tscalib(FALSE);
	if(glob){
		g_object_unref(glob->gdi);
		FREE(glob);
	}
	return ret;
}