static int __devexit mipi_s6d6aa0_lcd_remove(struct platform_device *pdev) { struct mipi_s6d6aa0_data *dsi_data; dsi_data = platform_get_drvdata(pdev); if (!dsi_data) return -ENODEV; platform_set_drvdata(pdev, NULL); mipi_dsi_buf_release(&dsi_data->tx_buf); mipi_dsi_buf_release(&dsi_data->rx_buf); kfree(dsi_data); return 0; }
static int setup_reg_access(struct device *dev, struct dsi_buf *rx_buf, struct dsi_buf *tx_buf, char **buf, const char __user *ubuf, size_t count) { int ret = 0; reset_res_buf(); if (rx_buf) { ret = mipi_dsi_buf_alloc(rx_buf, DSI_BUF_SIZE); if (ret <= 0) { dev_err(dev, "mipi_dsi_buf_alloc(rx) failed!\n"); ret = -ENOMEM; goto exit; } } if (tx_buf) { ret = mipi_dsi_buf_alloc(tx_buf, DSI_BUF_SIZE); if (ret <= 0) { dev_err(dev, "mipi_dsi_buf_alloc(tx) failed!\n"); ret = -ENOMEM; goto fail_free_rx; } } *buf = kzalloc(sizeof(char) * count, GFP_KERNEL); if (!*buf) { dev_err(dev, "%s: Failed to allocate buffer\n", __func__); ret = -ENOMEM; goto fail_free_all; } if (copy_from_user(*buf, ubuf, count)) { ret = -EFAULT; kfree(*buf); goto fail_free_all; } return 0; fail_free_all: if (tx_buf) mipi_dsi_buf_release(tx_buf); fail_free_rx: if (rx_buf) mipi_dsi_buf_release(rx_buf); exit: return ret; }
static int __devexit mipi_nt35565_lcd_remove(struct platform_device *pdev) { struct mipi_dsi_data *dsi_data; dsi_data = platform_get_drvdata(pdev); if (!dsi_data) return -ENODEV; #ifdef CONFIG_DEBUG_FS mipi_dsi_debugfs_exit(pdev); #endif platform_set_drvdata(pdev, NULL); mipi_dsi_buf_release(&dsi_data->tx_buf); mipi_dsi_buf_release(&dsi_data->rx_buf); kfree(dsi_data); return 0; }
static int __devexit mipi_r63306_lcd_remove(struct platform_device *pdev) { struct mipi_dsi_data *dsi_data; dsi_data = platform_get_drvdata(pdev); if (!dsi_data) return -ENODEV; #ifdef CONFIG_DEBUG_FS mipi_dsi_panel_remove_debugfs(pdev); #endif #ifdef CONFIG_FB_MSM_RECOVER_PANEL remove_sysfs_interfaces(&pdev->dev); #endif platform_set_drvdata(pdev, NULL); mipi_dsi_buf_release(&dsi_data->tx_buf); mipi_dsi_buf_release(&dsi_data->rx_buf); kfree(dsi_data); return 0; }
static int __devexit mipi_s6d6aa0_lcd_remove(struct platform_device *pdev) { struct mipi_dsi_data *dsi_data; dsi_data = platform_get_drvdata(pdev); if (!dsi_data) return -ENODEV; if (dsi_data->panel->esd_failed_check) destroy_workqueue(dsi_data->esd_wq); #ifdef CONFIG_DEBUG_FS mipi_dsi_panel_remove_debugfs(pdev); #endif platform_set_drvdata(pdev, NULL); mipi_dsi_buf_release(&dsi_data->tx_buf); mipi_dsi_buf_release(&dsi_data->rx_buf); kfree(dsi_data); return 0; }
static int __devinit mipi_nt35565_lcd_probe(struct platform_device *pdev) { int ret; struct lcd_panel_platform_data *platform_data; struct mipi_dsi_data *dsi_data; #ifdef CONFIG_FB_MSM_PANEL_ECO_MODE struct platform_device *fb_pdev; #endif platform_data = pdev->dev.platform_data; if (platform_data == NULL) return -EINVAL; dsi_data = kzalloc(sizeof(struct mipi_dsi_data), GFP_KERNEL); if (dsi_data == NULL) return -ENOMEM; dsi_data->panel_data.on = mipi_nt35565_ic_on_lcd_off; dsi_data->panel_data.controller_on_panel_on = mipi_nt35565_ic_on_lcd_on; dsi_data->panel_data.off = mipi_nt35565_lcd_off; dsi_data->panel_data.power_on_panel_at_pan = 0; dsi_data->default_panels = platform_data->default_panels; dsi_data->panels = platform_data->panels; dsi_data->lcd_power = platform_data->lcd_power; dsi_data->lcd_reset = platform_data->lcd_reset; if (mipi_dsi_need_detect_panel(dsi_data->panels)) { dsi_data->panel_data.panel_detect = mipi_dsi_detect_panel; dsi_data->panel_data.update_panel = mipi_dsi_update_panel; dsi_data->panel_detecting = true; } else { dev_info(&pdev->dev, "no need to detect panel\n"); } ret = mipi_dsi_buf_alloc(&dsi_data->tx_buf, DSI_BUF_SIZE); if (ret <= 0) { dev_err(&pdev->dev, "mipi_dsi_buf_alloc(tx) failed!\n"); goto out_free; } ret = mipi_dsi_buf_alloc(&dsi_data->rx_buf, DSI_BUF_SIZE); if (ret <= 0) { dev_err(&pdev->dev, "mipi_dsi_buf_alloc(rx) failed!\n"); goto out_rx_release; } platform_set_drvdata(pdev, dsi_data); mipi_dsi_set_default_panel(dsi_data); ret = platform_device_add_data(pdev, &dsi_data->panel_data, sizeof(dsi_data->panel_data)); if (ret) { dev_err(&pdev->dev, "platform_device_add_data failed!\n"); goto out_tx_release; } #ifdef CONFIG_FB_MSM_PANEL_ECO_MODE fb_pdev = msm_fb_add_device(pdev); eco_mode_sysfs_register(&fb_pdev->dev); #else msm_fb_add_device(pdev); #endif #ifdef CONFIG_DEBUG_FS mipi_dsi_debugfs_init(pdev, "mipi_nt35565"); #endif return 0; out_tx_release: mipi_dsi_buf_release(&dsi_data->rx_buf); out_rx_release: mipi_dsi_buf_release(&dsi_data->tx_buf); out_free: kfree(dsi_data); return ret; }
static int __devinit mipi_r63306_lcd_probe(struct platform_device *pdev) { int ret; struct lcd_panel_platform_data *platform_data; struct mipi_dsi_data *dsi_data; struct platform_device *fb_pdev; platform_data = pdev->dev.platform_data; if (platform_data == NULL) return -EINVAL; dsi_data = kzalloc(sizeof(struct mipi_dsi_data), GFP_KERNEL); if (dsi_data == NULL) return -ENOMEM; dsi_data->panel_data.on = mipi_r63306_lcd_on; dsi_data->panel_data.off = mipi_r63306_lcd_off; dsi_data->default_panels = platform_data->default_panels; dsi_data->panels = platform_data->panels; dsi_data->lcd_power = platform_data->lcd_power; dsi_data->lcd_reset = platform_data->lcd_reset; dsi_data->eco_mode_switch = mipi_dsi_eco_mode_switch; if (mipi_dsi_need_detect_panel(dsi_data->panels)) { dsi_data->panel_data.panel_detect = mipi_dsi_detect_panel; dsi_data->panel_data.update_panel = mipi_dsi_update_panel; dsi_data->panel_detecting = true; } else { dev_info(&pdev->dev, "no need to detect panel\n"); } #ifdef CONFIG_FB_MSM_RECOVER_PANEL dsi_data->is_nvm_ok = mipi_r63303_is_nvm_ok; dsi_data->backup_nvm_to_ram = mipi_r63306_backup_nvm_to_ram; dsi_data->get_nvm_backup = mipi_r63303_get_nvm_backup; dsi_data->override_nvm_data = mipi_r63306_nvm_override_data; dsi_data->nvm_erase_all = mipi_r63306_nvm_erase_all; dsi_data->nvm_write_trim_area = mipi_r63306_nvm_write_trim_area; dsi_data->nvm_write_user_area = mipi_r63306_nvm_write_user_area; dsi_data->panel_nvm_ok = true; dsi_data->panel_nvm_backup_ok = false; #endif ret = mipi_dsi_buf_alloc(&dsi_data->tx_buf, DSI_BUF_SIZE); if (ret <= 0) { dev_err(&pdev->dev, "mipi_dsi_buf_alloc(tx) failed!\n"); goto err_dsibuf_free; } ret = mipi_dsi_buf_alloc(&dsi_data->rx_buf, DSI_BUF_SIZE); if (ret <= 0) { dev_err(&pdev->dev, "mipi_dsi_buf_alloc(rx) failed!\n"); goto err_txbuf_free; } platform_set_drvdata(pdev, dsi_data); mipi_dsi_set_default_panel(dsi_data); ret = platform_device_add_data(pdev, &dsi_data->panel_data, sizeof(dsi_data->panel_data)); if (ret) { dev_err(&pdev->dev, "platform_device_add_data failed!\n"); goto err_rxbuf_free; } fb_pdev = msm_fb_add_device(pdev); #ifdef CONFIG_FB_MSM_PANEL_ECO_MODE eco_mode_sysfs_register(&fb_pdev->dev); #endif #ifdef CONFIG_FB_MSM_RECOVER_PANEL create_sysfs_interfaces(&fb_pdev->dev); #endif #ifdef CONFIG_DEBUG_FS mipi_dsi_panel_create_debugfs(fb_pdev, "mipi_r63306"); #endif return 0; err_rxbuf_free: mipi_dsi_buf_release(&dsi_data->rx_buf); err_txbuf_free: mipi_dsi_buf_release(&dsi_data->tx_buf); err_dsibuf_free: kfree(dsi_data); return ret; }
static int __devinit mipi_s6d6aa0_lcd_probe(struct platform_device *pdev) { int ret; struct lcd_panel_platform_data *platform_data; struct mipi_s6d6aa0_data *dsi_data; platform_data = pdev->dev.platform_data; if (platform_data == NULL) { ret = -EINVAL; goto error; } dsi_data = kzalloc(sizeof(struct mipi_s6d6aa0_data), GFP_KERNEL); if (dsi_data == NULL) { ret = -ENOMEM; goto error; } dsi_data->pdata = platform_data; dsi_data->panel_data.on = mipi_s6d6aa0_lcd_on; dsi_data->panel_data.off = mipi_s6d6aa0_lcd_off; #ifdef CONFIG_FB_MSM_MIPI_PANEL_DETECT if (msm_fb_detect_client(dsi_data->pdata->pdata->name)) { kfree(dsi_data); ret = -ENODEV; goto error; } #endif ret = mipi_dsi_buf_alloc(&dsi_data->tx_buf, DSI_BUF_SIZE); if (ret <= 0) { dev_err(&pdev->dev, "mipi_dsi_buf_alloc(tx) failed!\n"); kfree(dsi_data); goto error; } ret = mipi_dsi_buf_alloc(&dsi_data->rx_buf, DSI_BUF_SIZE); if (ret <= 0) { dev_err(&pdev->dev, "mipi_dsi_buf_alloc(rx) failed!\n"); mipi_dsi_buf_release(&dsi_data->tx_buf); kfree(dsi_data); goto error; } platform_set_drvdata(pdev, dsi_data); mipi_s6d6aa0_set_panel(dsi_data); ret = platform_device_add_data(pdev, &dsi_data->panel_data, sizeof(dsi_data->panel_data)); if (ret) { dev_err(&pdev->dev, "platform_device_add_data failed!\n"); mipi_dsi_buf_release(&dsi_data->tx_buf); mipi_dsi_buf_release(&dsi_data->rx_buf); kfree(dsi_data); goto error; } msm_fb_add_device(pdev); return 0; error: return ret; }
static int __devinit mipi_s6d6aa0_lcd_probe(struct platform_device *pdev) { int ret = -EINVAL; struct lcd_panel_platform_data *platform_data; struct mipi_dsi_data *dsi_data; struct platform_device *fb_pdev; platform_data = pdev->dev.platform_data; if (platform_data == NULL) return -EINVAL; dsi_data = kzalloc(sizeof(struct mipi_dsi_data), GFP_KERNEL); if (dsi_data == NULL) return -ENOMEM; dsi_data->panel_data.on = mipi_s6d6aa0_lcd_on; dsi_data->panel_data.off = mipi_s6d6aa0_lcd_off; dsi_data->default_panels = platform_data->default_panels; dsi_data->panels = platform_data->panels; dsi_data->lcd_power = platform_data->lcd_power; dsi_data->lcd_reset = platform_data->lcd_reset; dsi_data->eco_mode_switch = mipi_dsi_eco_mode_switch; if (mipi_dsi_need_detect_panel(dsi_data->panels)) { dsi_data->panel_data.panel_detect = mipi_dsi_detect_panel; dsi_data->panel_data.update_panel = mipi_dsi_update_panel; dsi_data->panel_detecting = true; } else { dev_info(&pdev->dev, "no need to detect panel\n"); } ret = mipi_dsi_buf_alloc(&dsi_data->tx_buf, DSI_BUF_SIZE); if (ret <= 0) { dev_err(&pdev->dev, "mipi_dsi_buf_alloc(tx) failed!\n"); goto out_free; } ret = mipi_dsi_buf_alloc(&dsi_data->rx_buf, DSI_BUF_SIZE); if (ret <= 0) { dev_err(&pdev->dev, "mipi_dsi_buf_alloc(rx) failed!\n"); goto out_rx_release; } platform_set_drvdata(pdev, dsi_data); mipi_dsi_set_default_panel(dsi_data); if (dsi_data->panel->esd_failed_check) { dsi_data->esd_wq = create_singlethread_workqueue("panel_esd_check"); if (dsi_data->esd_wq == NULL) { dev_err(&pdev->dev, "can't create ESD workqueue\n"); goto out_tx_release; } INIT_DELAYED_WORK(&dsi_data->esd_work, panel_esd_check_work); dsi_data->esd_check = mipi_dsi_panel_esd_failed_check; } mutex_init(&esd_lock); ret = platform_device_add_data(pdev, &dsi_data->panel_data, sizeof(dsi_data->panel_data)); if (ret) { dev_err(&pdev->dev, "platform_device_add_data failed!\n"); goto out_wq_release; } fb_pdev = msm_fb_add_device(pdev); #ifdef CONFIG_FB_MSM_PANEL_ECO_MODE eco_mode_sysfs_register(&fb_pdev->dev); #endif #ifdef CONFIG_DEBUG_FS mipi_dsi_panel_create_debugfs(fb_pdev, "mipi_s6d6aa0"); #endif return 0; out_wq_release: if (dsi_data->panel->esd_failed_check) destroy_workqueue(dsi_data->esd_wq); out_tx_release: mipi_dsi_buf_release(&dsi_data->rx_buf); out_rx_release: mipi_dsi_buf_release(&dsi_data->tx_buf); out_free: kfree(dsi_data); return ret; }
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; }