static ssize_t show_nvm(struct device *dev, struct device_attribute *attr, char *buf) { struct platform_device *pdev; struct mipi_dsi_data *dsi_data; struct msm_fb_data_type *mfd; int rc; pdev = container_of(dev, struct platform_device, dev); mfd = platform_get_drvdata(pdev); dsi_data = platform_get_drvdata(mfd->panel_pdev); if (dsi_data->nvrw_ic_vendor != NVRW_DRV_RENESAS || !dsi_data->nvrw_panel_detective) return 0; rc = prepare_for_reg_access(mfd); if (rc) return 0; mipi_set_tx_power_mode(1); rc = 0; if (dsi_data->panel->pnvrw_ctl && dsi_data->seq_nvm_read) rc = dsi_data->seq_nvm_read(mfd, buf); post_reg_access(mfd); return rc; };
static ssize_t nvm_data_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct platform_device *pdev; struct mipi_dsi_data *dsi_data; struct msm_fb_data_type *mfd; int rc; pdev = container_of(dev, struct platform_device, dev); mfd = platform_get_drvdata(pdev); dsi_data = platform_get_drvdata(mfd->panel_pdev); if (!dsi_data->panel->pnvrw_ctl) goto exit; if (dsi_data->override_nvm_data) { rc = dsi_data->override_nvm_data(mfd, buf, count); if (rc == 0) { dev_err(dev, "%s : nvm data format error.<%s>\n", __func__, buf); goto exit; } } if (prepare_for_reg_access(mfd)) goto exit; mipi_set_tx_power_mode(1); if (dsi_data->nvm_erase_all && dsi_data->nvm_write_trim_area && dsi_data->nvm_write_user_area) { (void)dsi_data->nvm_erase_all(mfd); (void)dsi_data->nvm_write_trim_area(mfd); (void)dsi_data->nvm_write_user_area(mfd); } if (dsi_data->panel_data.on) dsi_data->panel_data.on(mfd->pdev); post_reg_access(mfd); exit: return count; }
static ssize_t reg_write(struct file *file, const char __user *ubuf, size_t count, loff_t *ppos) { struct seq_file *s = file->private_data; struct msm_fb_data_type *mfd = s->private; struct mdss_panel_data *pdata; struct mdss_mdp_ctl *ctl; char *buf; const char *p; enum dbg_cmd_type cmd; u8 data[MAX_WRITE_DATA]; int i = 0; int j; int ret; struct dsi_cmd_desc dsi; struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL; if (!mfd->panel_power_on) { pr_err("%s: panel is NOT on\n", __func__); goto exit; } ctl = mfd_to_ctl(mfd); if (!ctl) goto exit; if (mutex_lock_interruptible(&ctl->lock)) goto exit; pdata = dev_get_platdata(&mfd->pdev->dev); if (!pdata) { pr_err("%s: no panel connected\n", __func__); goto exit; } ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata, panel_data); if (!ctrl_pdata) { pr_err("%s: Invalid input data\n", __func__); goto exit; } pr_err("%s\n", __func__); ret = setup_reg_access(&buf, ubuf, count); if (ret) goto exit; ret = get_cmd_type(buf, &cmd); if (ret) { update_res_buf("Write - unknown type\n"); goto fail_free_all; } p = buf; p = p+4; /* Get first param, Register */ if (sscanf(p, "%4hhx", &data[0]) != 1) { update_res_buf("Write - parameter error\n"); ret = -EINVAL; goto fail_free_all; } i++; while (isxdigit(*p) || (*p == 'x')) p++; ret = get_parameters(p, data, ARRAY_SIZE(data) - 1, &i); if (ret) goto fail_free_all; ret = prepare_for_reg_access(mfd); if (ret) goto fail_free_all; if (cmd == DCS) { if (i == 1) { /* 0 parameters */ dsi.dchdr.dtype = DTYPE_DCS_WRITE; } else if (i == 2) { /* 1 parameter */ dsi.dchdr.dtype = DTYPE_DCS_WRITE1; } else { /* Many parameters */ dsi.dchdr.dtype = DTYPE_DCS_LWRITE; } } else { if (i == 1) { /* 0 parameters */ dsi.dchdr.dtype = DTYPE_GEN_WRITE; } else if (i == 2) { /* 1 parameter */ dsi.dchdr.dtype = DTYPE_GEN_WRITE1; } else if (i == 3) { /* 2 parameters */ dsi.dchdr.dtype = DTYPE_GEN_WRITE2; } else { /* Many parameters */ dsi.dchdr.dtype = DTYPE_GEN_LWRITE; } } dsi.dchdr.last = 1; dsi.dchdr.vc = 0; dsi.dchdr.ack = 0; dsi.dchdr.wait = 0; dsi.dchdr.dlen = i; dsi.payload = data; pr_err("%s: last = %d, vc = %d, ack = %d, wait = %d, dlen = %d\n", __func__, dsi.dchdr.last, dsi.dchdr.vc, dsi.dchdr.ack, dsi.dchdr.wait, dsi.dchdr.dlen); for (j = 0; j < i; j++) pr_err("%s: payload[%d] = 0x%x\n", __func__, j, dsi.payload[j]); mdss_dsi_cmds_tx(ctrl_pdata, &dsi, 1); ret = post_reg_access(mfd); if (ret) goto fail_free_all; print_params(dsi.dchdr.dtype, data[0], i, dsi.payload); mutex_unlock(&ctl->lock); fail_free_all: kfree(buf); exit: return count; }
static ssize_t reg_read(struct file *file, const char __user *ubuf, size_t count, loff_t *ppos) { struct seq_file *s = file->private_data; struct msm_fb_data_type *mfd = s->private; struct mdss_panel_data *pdata; struct mdss_mdp_ctl *ctl; u8 params[3]; /* No more than reg + two parameters is allowed */ char *buf; const char *p; int ret; int nbr_bytes_to_read; int i; int j; enum dbg_cmd_type cmd; struct dsi_cmd_desc dsi; struct mdss_dsi_ctrl_pdata *ctrl_pdata = NULL; if (!mfd->panel_power_on) { pr_err("%s: panel is NOT on\n", __func__); goto exit; } ctl = mfd_to_ctl(mfd); if (!ctl) goto exit; if (mutex_lock_interruptible(&ctl->lock)) goto exit; pdata = dev_get_platdata(&mfd->pdev->dev); if (!pdata) { pr_err("%s: no panel connected\n", __func__); goto exit; } ctrl_pdata = container_of(pdata, struct mdss_dsi_ctrl_pdata, panel_data); if (!ctrl_pdata) { pr_err("%s: Invalid input data\n", __func__); goto exit; } pr_err("%s\n", __func__); ret = setup_reg_access(&buf, ubuf, count); if (ret) goto exit; ret = get_cmd_type(buf, &cmd); if (ret) { update_res_buf("Read - unknown type\n"); goto fail_free_all; } p = buf; p = p+4; /* Get nbr_bytes_to_read */ if (sscanf(p, "%d", &nbr_bytes_to_read) != 1) { update_res_buf("Read - parameter error\n"); ret = -EINVAL; goto fail_free_all; } while (isxdigit(*p) || (*p == 'x')) p++; pr_err("%s: nbr_bytes_to_read = %d\n", __func__, nbr_bytes_to_read); i = 0; ret = get_parameters(p, params, ARRAY_SIZE(params), &i); if (ret) goto fail_free_all; ret = prepare_for_reg_access(mfd); if (ret) goto fail_free_all; if (cmd == DCS) { dsi.dchdr.dtype = DTYPE_DCS_READ; } else { if (i == 1) { /* 0 parameters */ dsi.dchdr.dtype = DTYPE_GEN_READ; } else if (i == 2) { /* 1 parameter */ dsi.dchdr.dtype = DTYPE_GEN_READ1; } else { /* 2 paramters */ dsi.dchdr.dtype = DTYPE_GEN_READ2; } } dsi.dchdr.last = 1; dsi.dchdr.vc = 0; dsi.dchdr.ack = 1; dsi.dchdr.wait = 5; dsi.dchdr.dlen = i; dsi.payload = params; pr_err("%s: dtype=%d, last=%d, vc=%d, ack=%d, wait=%d, dlen=%d\n", __func__, dsi.dchdr.dtype, dsi.dchdr.last, dsi.dchdr.vc, dsi.dchdr.ack, dsi.dchdr.wait, dsi.dchdr.dlen); for (j = 0; j < i; j++) pr_err("%s: payload[%d] = 0x%x\n", __func__, j, dsi.payload[j]); mdss_dsi_cmds_rx(ctrl_pdata, &dsi, nbr_bytes_to_read, 0); ret = post_reg_access(mfd); if (ret) goto fail_free_all; print_params(dsi.dchdr.dtype, params[0], ctrl_pdata->rx_buf.len, ctrl_pdata->rx_buf.data); mutex_unlock(&ctl->lock); fail_free_all: kfree(buf); exit: return count; }
static ssize_t store_nvm(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { struct platform_device *pdev; struct mipi_dsi_data *dsi_data; struct msm_fb_data_type *mfd; int rc; pdev = container_of(dev, struct platform_device, dev); mfd = platform_get_drvdata(pdev); dsi_data = platform_get_drvdata(mfd->panel_pdev); dsi_data->nvrw_result = 0; dsi_data->nvrw_retry_cnt = 0; if (dsi_data->nvrw_ic_vendor != NVRW_DRV_RENESAS || dsi_data->nvrw_panel_detective) return count; if (!dsi_data->panel->pnvrw_ctl) return count; if (dsi_data->override_nvm_data) { rc = dsi_data->override_nvm_data(mfd, buf, count); if (rc == 0) { dev_err(dev, "%s : nvm data format error.<%s>\n", __func__, buf); return count; } } mfd->nvrw_prohibit_draw = true; rc = prepare_for_reg_access(mfd); if (rc) return count; mipi_set_tx_power_mode(1); if (dsi_data->seq_nvm_erase) { rc = dsi_data->seq_nvm_erase(mfd); if (rc == 0) { dev_err(dev, "%s : nvm data erase fail.\n", __func__); goto err_exit; } } if (dsi_data->seq_nvm_rsp_write) { rc = dsi_data->seq_nvm_rsp_write(mfd); if (rc == 0) { dev_err(dev, "%s : rsp write fail.\n", __func__); goto err_exit; } } if (dsi_data->seq_nvm_user_write) { rc = dsi_data->seq_nvm_user_write(mfd); if (rc == 0) { dev_err(dev, "%s : user write fail.\n", __func__); goto err_exit; } } dsi_data->nvrw_result = dsi_data->nvrw_retry_cnt + 1; err_exit: post_reg_access(mfd); mfd->nvrw_prohibit_draw = false; return count; };
static ssize_t reg_write(struct file *file, const char __user *ubuf, size_t count, loff_t *ppos) { struct seq_file *s = file->private_data; struct msm_fb_data_type *mfd = s->private; struct device *dev; char *buf; const char *p; enum dbg_cmd_type cmd; u8 data[MAX_WRITE_DATA]; int i = 0; int j; int ret; struct dsi_buf tx_buf; struct dsi_cmd_desc dsi; enum power_state old_state = PANEL_OFF; dev = &mfd->panel_pdev->dev; dev_dbg(dev, "%s\n", __func__); ret = setup_reg_access(dev, NULL, &tx_buf, &buf, ubuf, count); if (ret) goto exit; ret = get_cmd_type(buf, &cmd); if (ret) { update_res_buf("Write - unknown type\n"); goto fail_free_all; } p = buf; p = p+4; /* Get first param, Register */ if (sscanf(p, "%4hhx", &data[0]) != 1) { update_res_buf("Write - parameter error\n"); ret = -EINVAL; goto fail_free_all; } i++; while (isxdigit(*p) || (*p == 'x')) p++; ret = get_parameters(p, data, ARRAY_SIZE(data) - 1, &i); if (ret) goto fail_free_all; ret = prepare_for_reg_access(mfd, &old_state); if (ret) goto fail_free_all; if (cmd == DCS) { if (i == 1) { /* 0 parameters */ dsi.dtype = DTYPE_DCS_WRITE; } else if (i == 2) { /* 1 parameter */ dsi.dtype = DTYPE_DCS_WRITE1; } else { /* Many parameters */ dsi.dtype = DTYPE_DCS_LWRITE; } } else { if (i == 1) { /* 0 parameters */ dsi.dtype = DTYPE_GEN_WRITE; } else if (i == 2) { /* 1 parameter */ dsi.dtype = DTYPE_GEN_WRITE1; } else if (i == 3) { /* 2 parameters */ dsi.dtype = DTYPE_GEN_WRITE2; } else { /* Many parameters */ dsi.dtype = DTYPE_GEN_LWRITE; } } dsi.last = 1; dsi.vc = 0; dsi.ack = 0; dsi.wait = 0; dsi.dlen = i; dsi.payload = data; dev_dbg(dev, "last = %d, vc = %d, ack = %d, wait = %d, dlen = %d\n", dsi.last, dsi.vc, dsi.ack, dsi.wait, dsi.dlen); for (j = 0; j < i; j++) dev_dbg(dev, "payload[%d] = 0x%x\n", j, dsi.payload[j]); mipi_dsi_cmds_tx(&tx_buf, &dsi, 1); post_reg_access(mfd, old_state); print_params(dsi.dtype, data[0], i, dsi.payload); fail_free_all: kfree(buf); mipi_dsi_buf_release(&tx_buf); exit: return count; }
static ssize_t reg_read(struct file *file, const char __user *ubuf, size_t count, loff_t *ppos) { struct seq_file *s = file->private_data; struct msm_fb_data_type *mfd = s->private; struct device *dev; u8 params[3]; /* No more than reg + two parameters is allowed */ char *buf; const char *p; int ret; int nbr_bytes_to_read; int i; int j; enum dbg_cmd_type cmd; struct dsi_buf tx_buf; struct dsi_buf rx_buf; struct dsi_cmd_desc dsi; enum power_state old_state = PANEL_OFF; dev = &mfd->panel_pdev->dev; dev_dbg(dev, "%s\n", __func__); ret = setup_reg_access(dev, &rx_buf, &tx_buf, &buf, ubuf, count); if (ret) goto exit; ret = get_cmd_type(buf, &cmd); if (ret) { update_res_buf("Read - unknown type\n"); goto fail_free_all; } p = buf; p = p+4; /* Get nbr_bytes_to_read */ if (sscanf(p, "%d", &nbr_bytes_to_read) != 1) { update_res_buf("Read - parameter error\n"); ret = -EINVAL; goto fail_free_all; } while (isxdigit(*p) || (*p == 'x')) p++; dev_dbg(dev, "nbr_bytes_to_read = %d\n", nbr_bytes_to_read); i = 0; ret = get_parameters(p, params, ARRAY_SIZE(params), &i); if (ret) goto fail_free_all; ret = prepare_for_reg_access(mfd, &old_state); if (ret) goto fail_free_all; if (cmd == DCS) { dsi.dtype = DTYPE_DCS_READ; } else { if (i == 1) { /* 0 parameters */ dsi.dtype = DTYPE_GEN_READ; } else if (i == 2) { /* 1 parameter */ dsi.dtype = DTYPE_GEN_READ1; } else { /* 2 paramters */ dsi.dtype = DTYPE_GEN_READ2; } } dsi.last = 1; dsi.vc = 0; dsi.ack = 1; dsi.wait = 5; /* why 5? */ dsi.dlen = i; dsi.payload = params; dev_dbg(dev, "dtype = %d, last = %d, vc = %d\n", dsi.dtype, dsi.last, dsi.vc); dev_dbg(dev, "ack = %d, wait = %d, dlen = %d\n", dsi.ack, dsi.wait, dsi.dlen); for (j = 0; j < i; j++) dev_dbg(dev, "payload[%d] = 0x%x\n", j, dsi.payload[j]); mipi_dsi_cmds_rx(mfd, &tx_buf, &rx_buf, &dsi, nbr_bytes_to_read); post_reg_access(mfd, old_state); print_params(dsi.dtype, params[0], rx_buf.len, rx_buf.data); fail_free_all: kfree(buf); mipi_dsi_buf_release(&rx_buf); mipi_dsi_buf_release(&tx_buf); exit: return count; }