mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-09 21:59:12 -04:00
focaltech_0_flash_mmi: Add sys entries for moto FW update
moto touch firmware update need some sys entries to accomplish this work Add those entries. Change-Id: Ib6789e04ba888f9ee53b7cbc00abe981b8f707c8 Signed-off-by: haojl2 <haojl2@motorola.com> Reviewed-on: https://gerrit.mot.com/1346254 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Jun Weng <wengjun1@motorola.com> Reviewed-by: Jianqi Yang <yangj@motorola.com> Submit-Approved: Jira Key Reviewed-on: https://gerrit.mot.com/1356397
This commit is contained in:
parent
485e090b13
commit
e257b23ca8
6 changed files with 236 additions and 8220 deletions
|
|
@ -186,7 +186,7 @@
|
|||
/*
|
||||
* auto upgrade
|
||||
*/
|
||||
#define FTS_AUTO_UPGRADE_EN 1
|
||||
#define FTS_AUTO_UPGRADE_EN 0
|
||||
|
||||
/*
|
||||
* auto upgrade for lcd cfg
|
||||
|
|
|
|||
|
|
@ -160,6 +160,7 @@ struct fts_ts_data {
|
|||
int fw_is_running; /* confirm fw is running when using spi:default 0 */
|
||||
bool suspended;
|
||||
bool fw_loading;
|
||||
bool force_reflash;
|
||||
bool irq_disabled;
|
||||
bool power_disabled;
|
||||
bool glove_mode;
|
||||
|
|
@ -256,6 +257,7 @@ int fts_fw_resume(void);
|
|||
int fts_fw_recovery(void);
|
||||
int fts_upgrade_bin(char *fw_name, bool force);
|
||||
int fts_enter_test_environment(bool test_state);
|
||||
int fts_fw_update_vendor_name(const char* name);
|
||||
|
||||
/* Other */
|
||||
int fts_reset_proc(int hdelayms);
|
||||
|
|
|
|||
|
|
@ -520,6 +520,24 @@ static ssize_t fts_hw_reset_store(
|
|||
return -EPERM;
|
||||
}
|
||||
|
||||
static ssize_t reset_store(
|
||||
struct device *dev,
|
||||
struct device_attribute *attr, const char *buf, size_t count)
|
||||
{
|
||||
struct input_dev *input_dev = fts_data->input_dev;
|
||||
|
||||
if ('1' != buf[0]) {
|
||||
pr_err("Invalid argument for reset\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mutex_lock(&input_dev->mutex);
|
||||
fts_reset_proc(0);
|
||||
mutex_unlock(&input_dev->mutex);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/* fts_irq interface */
|
||||
static ssize_t fts_irq_show(
|
||||
struct device *dev, struct device_attribute *attr, char *buf)
|
||||
|
|
@ -550,6 +568,31 @@ static ssize_t fts_irq_store(
|
|||
return count;
|
||||
}
|
||||
|
||||
static ssize_t drv_irq_show(
|
||||
struct device *dev, struct device_attribute *attr, char *buf)
|
||||
{
|
||||
return scnprintf(buf, PAGE_SIZE, "%s\n",
|
||||
fts_data->irq_disabled? "DISABLED" : "ENABLED");
|
||||
}
|
||||
|
||||
static ssize_t drv_irq_store(
|
||||
struct device *dev,
|
||||
struct device_attribute *attr, const char *buf, size_t count)
|
||||
{
|
||||
struct input_dev *input_dev = fts_data->input_dev;
|
||||
|
||||
mutex_lock(&input_dev->mutex);
|
||||
if (FTS_SYSFS_ECHO_ON(buf)) {
|
||||
FTS_INFO("enable irq");
|
||||
fts_irq_enable();
|
||||
} else if (FTS_SYSFS_ECHO_OFF(buf)) {
|
||||
FTS_INFO("disable irq");
|
||||
fts_irq_disable();
|
||||
}
|
||||
mutex_unlock(&input_dev->mutex);
|
||||
return count;
|
||||
}
|
||||
|
||||
/* fts_boot_mode interface */
|
||||
static ssize_t fts_bootmode_store(
|
||||
struct device *dev,
|
||||
|
|
@ -591,6 +634,26 @@ static ssize_t fts_bootmode_show(
|
|||
return count;
|
||||
}
|
||||
|
||||
|
||||
static ssize_t fts_poweron_show(struct device *dev, struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct fts_ts_data *data = fts_data;
|
||||
struct input_dev *input_dev = data->input_dev;
|
||||
bool val;
|
||||
|
||||
mutex_lock(&input_dev->mutex);
|
||||
val = data->power_disabled;
|
||||
mutex_unlock(&input_dev->mutex);
|
||||
|
||||
return scnprintf(buf, PAGE_SIZE, "%d\n", val == false);
|
||||
}
|
||||
|
||||
|
||||
static ssize_t fts_productinfo_show(struct device *dev, struct device_attribute *attr, char *buf)
|
||||
{
|
||||
return scnprintf(buf, PAGE_SIZE, "%s\n", FTS_CHIP_NAME);
|
||||
}
|
||||
|
||||
/* fts_tpfwver interface */
|
||||
static ssize_t fts_tpfwver_show(
|
||||
struct device *dev, struct device_attribute *attr, char *buf)
|
||||
|
|
@ -625,6 +688,32 @@ static ssize_t fts_tpfwver_store(
|
|||
return -EPERM;
|
||||
}
|
||||
|
||||
static ssize_t buildid_show(
|
||||
struct device *dev, struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct fts_ts_data *ts_data = fts_data;
|
||||
struct input_dev *input_dev = ts_data->input_dev;
|
||||
ssize_t num_read_chars = 0;
|
||||
u8 fwver = 0;
|
||||
|
||||
mutex_lock(&input_dev->mutex);
|
||||
|
||||
#if FTS_ESDCHECK_EN
|
||||
fts_esdcheck_proc_busy(1);
|
||||
#endif
|
||||
fts_read_reg(FTS_REG_FW_VER, &fwver);
|
||||
#if FTS_ESDCHECK_EN
|
||||
fts_esdcheck_proc_busy(0);
|
||||
#endif
|
||||
if ((fwver == 0xFF) || (fwver == 0x00))
|
||||
num_read_chars = snprintf(buf, PAGE_SIZE, "get tp fw version fail!\n");
|
||||
else
|
||||
num_read_chars = snprintf(buf, PAGE_SIZE, "0000-%02x\n", fwver);
|
||||
|
||||
mutex_unlock(&input_dev->mutex);
|
||||
return num_read_chars;
|
||||
}
|
||||
|
||||
/* fts_rw_reg */
|
||||
static ssize_t fts_tprwreg_show(
|
||||
struct device *dev, struct device_attribute *attr, char *buf)
|
||||
|
|
@ -923,6 +1012,63 @@ static ssize_t fts_fwforceupg_store(
|
|||
return count;
|
||||
}
|
||||
|
||||
static ssize_t forcereflash_store(struct device *dev,
|
||||
struct device_attribute *attr, const char *buf, size_t count)
|
||||
{
|
||||
unsigned int input;
|
||||
|
||||
if (kstrtouint(buf, 10, &input) != 0)
|
||||
return -EINVAL;
|
||||
|
||||
fts_data->force_reflash = (input == 0) ? false : true;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t flashprog_show(struct device *dev, struct device_attribute *attr, char *buf)
|
||||
{
|
||||
return scnprintf(buf, PAGE_SIZE, "%d\n", (fts_data->fw_loading) ? 1 : 0);
|
||||
}
|
||||
|
||||
static ssize_t doreflash_store(struct device *dev,
|
||||
struct device_attribute *attr, const char *buf, size_t count)
|
||||
{
|
||||
char fwname[FILE_NAME_LENGTH];
|
||||
char prefix[FILE_NAME_LENGTH] = "focaltech";
|
||||
char template[FILE_NAME_LENGTH];
|
||||
struct input_dev *input_dev = fts_data->input_dev;
|
||||
|
||||
if (count > FILE_NAME_LENGTH) {
|
||||
FTS_ERROR("%s: FW filename is too long\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!fts_data->force_reflash) {
|
||||
if (strncmp(buf, prefix, strnlen(prefix, sizeof(prefix)))) {
|
||||
FTS_ERROR("%s: FW does not belong to Focaltech\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
snprintf(template, sizeof(template), "-%s-", FTS_CHIP_NAME);
|
||||
if (!strnstr(buf + strnlen(prefix, sizeof(prefix)), template, count)) {
|
||||
FTS_ERROR("%s: FW does not belong to %s\n", __func__, FTS_CHIP_NAME);
|
||||
return -EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
memset(fwname, 0, sizeof(fwname));
|
||||
snprintf(fwname, PAGE_SIZE, "%s", buf);
|
||||
fwname[count - 1] = '\0';
|
||||
|
||||
mutex_lock(&input_dev->mutex);
|
||||
fts_fw_update_vendor_name(fwname);
|
||||
fts_fw_recovery();
|
||||
mutex_unlock(&input_dev->mutex);
|
||||
fts_data->force_reflash = false;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/* fts_driver_info interface */
|
||||
static ssize_t fts_driverinfo_show(
|
||||
struct device *dev, struct device_attribute *attr, char *buf)
|
||||
|
|
@ -1102,6 +1248,14 @@ static DEVICE_ATTR(fts_irq, S_IRUGO | S_IWUSR, fts_irq_show, fts_irq_store);
|
|||
static DEVICE_ATTR(fts_boot_mode, S_IRUGO | S_IWUSR, fts_bootmode_show, fts_bootmode_store);
|
||||
static DEVICE_ATTR(fts_touch_point, S_IRUGO | S_IWUSR, fts_tpbuf_show, fts_tpbuf_store);
|
||||
static DEVICE_ATTR(fts_log_level, S_IRUGO | S_IWUSR, fts_log_level_show, fts_log_level_store);
|
||||
static DEVICE_ATTR(drv_irq, S_IRUGO | S_IWUSR, drv_irq_show, drv_irq_store);
|
||||
static DEVICE_ATTR(reset, S_IWUSR | S_IWGRP, NULL, reset_store);
|
||||
static DEVICE_ATTR(buildid, S_IRUGO, buildid_show, NULL);
|
||||
static DEVICE_ATTR(forcereflash, S_IWUSR | S_IWGRP, NULL, forcereflash_store);
|
||||
static DEVICE_ATTR(flashprog, S_IRUGO, flashprog_show, NULL);
|
||||
static DEVICE_ATTR(doreflash, S_IWUSR | S_IWGRP, NULL, doreflash_store);
|
||||
static DEVICE_ATTR(poweron, S_IRUGO, fts_poweron_show, NULL);
|
||||
static DEVICE_ATTR(productinfo, S_IRUGO, fts_productinfo_show, NULL);
|
||||
|
||||
/* add your attr in here*/
|
||||
static struct attribute *fts_attributes[] = {
|
||||
|
|
@ -1116,6 +1270,14 @@ static struct attribute *fts_attributes[] = {
|
|||
&dev_attr_fts_boot_mode.attr,
|
||||
&dev_attr_fts_touch_point.attr,
|
||||
&dev_attr_fts_log_level.attr,
|
||||
&dev_attr_drv_irq.attr,
|
||||
&dev_attr_reset.attr,
|
||||
&dev_attr_buildid.attr,
|
||||
&dev_attr_forcereflash.attr,
|
||||
&dev_attr_flashprog.attr,
|
||||
&dev_attr_doreflash.attr,
|
||||
&dev_attr_poweron.attr,
|
||||
&dev_attr_productinfo.attr,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
*****************************************************************************/
|
||||
#define FTS_FW_REQUEST_SUPPORT 1
|
||||
/* Example: focaltech_ts_fw_tianma.bin */
|
||||
#define FTS_FW_NAME_PREX_WITH_REQUEST "focaltech_ts_fw_"
|
||||
#define FTS_FW_NAME_PREX_WITH_REQUEST ""
|
||||
#define FTS_READ_BOOT_ID_TIMEOUT 3
|
||||
#define FTS_FLASH_PACKET_LENGTH_SPI_LOW (4 * 1024 - 4)
|
||||
#define FTS_FLASH_PACKET_LENGTH_SPI (64 * 1024)
|
||||
|
|
@ -49,15 +49,12 @@
|
|||
* Global variable or extern global variabls/functions
|
||||
*****************************************************************************/
|
||||
u8 fw_file[] = {
|
||||
#include FTS_UPGRADE_FW_FILE
|
||||
};
|
||||
|
||||
u8 fw_file2[] = {
|
||||
#include FTS_UPGRADE_FW2_FILE
|
||||
};
|
||||
|
||||
u8 fw_file3[] = {
|
||||
#include FTS_UPGRADE_FW3_FILE
|
||||
};
|
||||
|
||||
struct upgrade_module module_list[] = {
|
||||
|
|
@ -446,7 +443,7 @@ static int fts_fw_download(const u8 *buf, u32 len, bool need_reset)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int fts_read_file(char *file_name, u8 **file_buf)
|
||||
static int fts_read_file(char *file_name, u8 **file_buf)
|
||||
{
|
||||
int ret = 0;
|
||||
char file_path[FILE_NAME_LENGTH] = { 0 };
|
||||
|
|
@ -614,12 +611,31 @@ int fts_fw_resume(void)
|
|||
return ret;
|
||||
}
|
||||
|
||||
/* update to newest fw if needed */
|
||||
if (fw != NULL) {
|
||||
u8 *tmpbuf = NULL;
|
||||
if (upg->fw_from_request)
|
||||
vfree(upg->fw);
|
||||
tmpbuf = vmalloc(fw->size);
|
||||
if (NULL == tmpbuf) {
|
||||
FTS_ERROR("fw buffer vmalloc fail");
|
||||
ret = -ENOMEM;
|
||||
goto FTS_FW_RESUME_VMALLOC_ERROR;
|
||||
} else {
|
||||
memcpy(tmpbuf, fw->data, fw->size);
|
||||
upg->fw = tmpbuf;
|
||||
upg->fw_length = fw->size;
|
||||
upg->fw_from_request = 1;
|
||||
}
|
||||
}
|
||||
|
||||
FTS_FW_RESUME_VMALLOC_ERROR:
|
||||
if (fw != NULL) {
|
||||
release_firmware(fw);
|
||||
fw = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int fts_fw_recovery(void)
|
||||
|
|
@ -641,26 +657,29 @@ int fts_fw_recovery(void)
|
|||
}
|
||||
|
||||
upg->ts_data->fw_is_running = false;
|
||||
ret = fts_check_bootid();
|
||||
if (ret < 0) {
|
||||
FTS_ERROR("check boot id fail");
|
||||
upg->ts_data->fw_is_running = true;
|
||||
return ret;
|
||||
if (!upg->ts_data->force_reflash) {
|
||||
ret = fts_check_bootid();
|
||||
if (ret < 0) {
|
||||
FTS_ERROR("check boot id fail");
|
||||
upg->ts_data->fw_is_running = true;
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = fts_read_reg(0xD0, &boot_state);
|
||||
if (ret < 0) {
|
||||
FTS_ERROR("read boot state failed, ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (boot_state != 0x02) {
|
||||
FTS_INFO("not in boot mode(0x%x),exit", boot_state);
|
||||
upg->ts_data->fw_is_running = true;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
FTS_INFO("abnormal situation,need download fw");
|
||||
}
|
||||
|
||||
ret = fts_read_reg(0xD0, &boot_state);
|
||||
if (ret < 0) {
|
||||
FTS_ERROR("read boot state failed, ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (boot_state != 0x02) {
|
||||
FTS_INFO("not in boot mode(0x%x),exit", boot_state);
|
||||
upg->ts_data->fw_is_running = true;
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
FTS_INFO("abnormal situation,need download fw");
|
||||
ret = fts_fw_resume();
|
||||
if (ret < 0) {
|
||||
FTS_ERROR("fts_fw_resume fail");
|
||||
|
|
@ -676,6 +695,31 @@ int fts_fw_recovery(void)
|
|||
return ret;
|
||||
}
|
||||
|
||||
int fts_fw_update_vendor_name(const char* name) {
|
||||
struct fts_upgrade *upg = fwupgrade;
|
||||
char* pos;
|
||||
int len;
|
||||
|
||||
if (!upg || !upg->module_info || !upg->module_info->vendor_name) {
|
||||
FTS_ERROR("upgrade struct not init");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
len = strlen(name);
|
||||
if (len > FILE_NAME_LENGTH) {
|
||||
FTS_ERROR("vendor name is too long");
|
||||
return -EINVAL;
|
||||
}
|
||||
pos = strstr(name, ".bin");
|
||||
if (pos == NULL)
|
||||
snprintf(upg->module_info->vendor_name, FILE_NAME_LENGTH, "%s", name);
|
||||
else {
|
||||
len = len - strlen(".bin");
|
||||
snprintf(upg->module_info->vendor_name, len + 1, "%s", name);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fts_fwupg_get_module_info(struct fts_upgrade *upg)
|
||||
{
|
||||
int i = 0;
|
||||
|
|
@ -814,11 +858,6 @@ static void fts_fwupg_work(struct work_struct *work)
|
|||
u8 chip_id = 0;
|
||||
struct fts_upgrade *upg = fwupgrade;
|
||||
|
||||
#if !FTS_AUTO_UPGRADE_EN
|
||||
FTS_INFO("FTS_AUTO_UPGRADE_EN is disabled, not upgrade when power on");
|
||||
return ;
|
||||
#endif
|
||||
|
||||
FTS_INFO("fw upgrade work function");
|
||||
if (!upg || !upg->ts_data) {
|
||||
FTS_ERROR("upg/ts_data is null");
|
||||
|
|
@ -832,6 +871,11 @@ static void fts_fwupg_work(struct work_struct *work)
|
|||
return ;
|
||||
}
|
||||
|
||||
#if !FTS_AUTO_UPGRADE_EN
|
||||
FTS_INFO("FTS_AUTO_UPGRADE_EN is disabled, not upgrade when power on");
|
||||
return ;
|
||||
#endif
|
||||
|
||||
if (upg->ts_data->fw_loading) {
|
||||
FTS_INFO("fw is loading, not download again");
|
||||
return ;
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue