static int cyttsp_exit_bl_mode(struct cyttsp *ts) { int error; u8 bl_cmd[sizeof(bl_command)]; memcpy(bl_cmd, bl_command, sizeof(bl_command)); if (ts->pdata->bl_keys) memcpy(&bl_cmd[sizeof(bl_command) - CY_NUM_BL_KEYS], ts->pdata->bl_keys, CY_NUM_BL_KEYS); error = ttsp_write_block_data(ts, CY_REG_BASE, sizeof(bl_cmd), bl_cmd); if (error) return error; msleep(CY_DELAY_DFLT); error = cyttsp_load_bl_regs(ts); if (error) return error; if (GET_BOOTLOADERMODE(ts->bl_data.bl_status)) return -EIO; return 0; }
static int cyttsp_set_operational_mode(struct cyttsp *ts) { struct cyttsp_xydata xy_data; int retval; int tries; u8 cmd = CY_OPERATE_MODE; retval = ttsp_write_block_data(ts, CY_REG_BASE, sizeof(cmd), &cmd); if (retval < 0) return retval; /* wait for TTSP Device to complete switch to Operational mode */ tries = 0; do { msleep(CY_DELAY_DFLT); retval = ttsp_read_block_data(ts, CY_REG_BASE, sizeof(xy_data), &(xy_data)); } while (!((retval == 0) && (xy_data.act_dist == CY_ACT_DIST_DFLT)) && (tries++ < CY_DELAY_MAX)); dev_dbg(ts->dev, "%s: check op ready tries=%d ret=%d dist=%02X\n", __func__, tries, retval, xy_data.act_dist); return retval; }
static int cyttsp_act_dist_setup(struct cyttsp *ts) { u8 act_dist_setup = ts->pdata->act_dist; return ttsp_write_block_data(ts, CY_REG_ACT_DIST, sizeof(act_dist_setup), &act_dist_setup); }
static int cyttsp_act_dist_setup(struct cyttsp *ts) { u8 act_dist_setup = ts->act_dist; /* Init gesture; active distance setup */ return ttsp_write_block_data(ts, CY_REG_ACT_DIST, sizeof(act_dist_setup), &act_dist_setup); }
static int cyttsp_act_dist_setup(struct cyttsp *ts) { int retval; u8 act_dist_setup; /* Init gesture; active distance setup */ act_dist_setup = ts->platform_data->act_dist; retval = ttsp_write_block_data(ts, CY_REG_ACT_DIST, sizeof(act_dist_setup), &act_dist_setup); return retval; }
static int cyttsp_hndshk(struct cyttsp *ts, u8 hst_mode) { int retval; u8 cmd; cmd = hst_mode & CY_HNDSHK_BIT ? hst_mode & ~CY_HNDSHK_BIT : hst_mode | CY_HNDSHK_BIT; retval = ttsp_write_block_data(ts, CY_REG_BASE, sizeof(cmd), (u8 *)&cmd); return retval; }
static int cyttsp_exit_bl_mode(struct cyttsp *ts) { int retval; int tries; u8 bl_cmd[sizeof(bl_command)]; memcpy(bl_cmd, bl_command, sizeof(bl_command)); if (ts->platform_data->bl_keys) memcpy(&bl_cmd[sizeof(bl_command) - CY_NUM_BL_KEYS], ts->platform_data->bl_keys, sizeof(bl_command)); dev_dbg(ts->dev, "%s: bl_cmd= " "%02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n", __func__, bl_cmd[0], bl_cmd[1], bl_cmd[2], bl_cmd[3], bl_cmd[4], bl_cmd[5], bl_cmd[6], bl_cmd[7], bl_cmd[8], bl_cmd[9], bl_cmd[10]); retval = ttsp_write_block_data(ts, CY_REG_BASE, sizeof(bl_cmd), (void *)bl_cmd); if (retval < 0) return retval; /* wait for TTSP Device to complete switch to Operational mode */ tries = 0; do { msleep(CY_DELAY_DFLT); retval = cyttsp_load_bl_regs(ts); } while (!((retval == 0) && !GET_BOOTLOADERMODE(ts->bl_data.bl_status)) && (tries++ < CY_DELAY_MAX)); dev_dbg(ts->dev, "%s: check bl ready tries=%d ret=%d stat=%02X\n", __func__, tries, retval, ts->bl_data.bl_status); if (retval < 0) return retval; else if (GET_BOOTLOADERMODE(ts->bl_data.bl_status)) return -ENODEV; else return 0; }
static int cyttsp_soft_reset(struct cyttsp *ts) { int retval; u8 cmd = CY_SOFT_RESET_MODE; retval = ttsp_write_block_data(ts, CY_REG_BASE, sizeof(cmd), &cmd); if (retval < 0) return retval; /* wait for interrupt to set ready completion */ INIT_COMPLETION(ts->bl_ready); retval = wait_for_completion_interruptible_timeout(&ts->bl_ready, msecs_to_jiffies(CY_DELAY_DFLT * CY_DELAY_MAX)); if (retval > 0) retval = 0; return retval; }
static int cyttsp_set_sysinfo_regs(struct cyttsp *ts) { int retval = 0; if (ts->pdata->act_intrvl != CY_ACT_INTRVL_DFLT || ts->pdata->tch_tmout != CY_TCH_TMOUT_DFLT || ts->pdata->lp_intrvl != CY_LP_INTRVL_DFLT) { u8 intrvl_ray[] = { ts->pdata->act_intrvl, ts->pdata->tch_tmout, ts->pdata->lp_intrvl }; retval = ttsp_write_block_data(ts, CY_REG_ACT_INTRVL, sizeof(intrvl_ray), intrvl_ray); msleep(CY_DELAY_DFLT); } return retval; }
static int cyttsp_set_sysinfo_mode(struct cyttsp *ts) { int retval; int tries; u8 cmd = CY_SYSINFO_MODE; memset(&(ts->sysinfo_data), 0, sizeof(struct cyttsp_sysinfo_data)); /* switch to sysinfo mode */ retval = ttsp_write_block_data(ts, CY_REG_BASE, sizeof(cmd), &cmd); if (retval < 0) return retval; /* read sysinfo registers */ tries = 0; do { msleep(CY_DELAY_DFLT); retval = ttsp_read_block_data(ts, CY_REG_BASE, sizeof(ts->sysinfo_data), &(ts->sysinfo_data)); } while (!((retval == 0) && !((ts->sysinfo_data.tts_verh == 0) && (ts->sysinfo_data.tts_verl == 0))) && (tries++ < CY_DELAY_MAX)); dev_dbg(ts->dev, "%s: check sysinfo ready tries=%d ret=%d\n", __func__, tries, retval); dev_info(ts->dev, "%s: tv=%02X%02X ai=0x%02X%02X " "av=0x%02X%02X ci=0x%02X%02X%02X\n", "cyttsp", ts->sysinfo_data.tts_verh, ts->sysinfo_data.tts_verl, ts->sysinfo_data.app_idh, ts->sysinfo_data.app_idl, ts->sysinfo_data.app_verh, ts->sysinfo_data.app_verl, ts->sysinfo_data.cid[0], ts->sysinfo_data.cid[1], ts->sysinfo_data.cid[2]); return retval; }
static int cyttsp_set_sysinfo_regs(struct cyttsp *ts) { int retval = 0; if (ts->platform_data->act_intrvl != CY_ACT_INTRVL_DFLT || ts->platform_data->tch_tmout != CY_TCH_TMOUT_DFLT || ts->platform_data->lp_intrvl != CY_LP_INTRVL_DFLT) { u8 intrvl_ray[3]; intrvl_ray[0] = ts->platform_data->act_intrvl; intrvl_ray[1] = ts->platform_data->tch_tmout; intrvl_ray[2] = ts->platform_data->lp_intrvl; /* set intrvl registers */ retval = ttsp_write_block_data(ts, CY_REG_ACT_INTRVL, sizeof(intrvl_ray), intrvl_ray); msleep(CY_DELAY_DFLT); } return retval; }
static int ttsp_send_command(struct cyttsp *ts, u8 cmd) { return ttsp_write_block_data(ts, CY_REG_BASE, sizeof(cmd), &cmd); }