2012-02-09 00:47:39 +04:00
|
|
|
/* linux/drivers/video/exynos/exynos_mipi_dsi.c
|
|
|
|
*
|
|
|
|
* Samsung SoC MIPI-DSIM driver.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2012 Samsung Electronics Co., Ltd
|
|
|
|
*
|
|
|
|
* InKi Dae, <inki.dae@samsung.com>
|
|
|
|
* Donghwa Lee, <dh09.lee@samsung.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/clk.h>
|
|
|
|
#include <linux/mutex.h>
|
|
|
|
#include <linux/wait.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/mm.h>
|
|
|
|
#include <linux/fb.h>
|
|
|
|
#include <linux/ctype.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/io.h>
|
|
|
|
#include <linux/irq.h>
|
|
|
|
#include <linux/memory.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/kthread.h>
|
|
|
|
#include <linux/notifier.h>
|
2013-10-16 20:28:12 +04:00
|
|
|
#include <linux/phy/phy.h>
|
2012-02-09 00:47:39 +04:00
|
|
|
#include <linux/regulator/consumer.h>
|
|
|
|
#include <linux/pm_runtime.h>
|
2013-04-30 02:05:43 +04:00
|
|
|
#include <linux/err.h>
|
2012-02-09 00:47:39 +04:00
|
|
|
|
|
|
|
#include <video/exynos_mipi_dsim.h>
|
|
|
|
|
|
|
|
#include "exynos_mipi_dsi_common.h"
|
|
|
|
#include "exynos_mipi_dsi_lowlevel.h"
|
|
|
|
|
|
|
|
struct mipi_dsim_ddi {
|
|
|
|
int bus_id;
|
|
|
|
struct list_head list;
|
|
|
|
struct mipi_dsim_lcd_device *dsim_lcd_dev;
|
|
|
|
struct mipi_dsim_lcd_driver *dsim_lcd_drv;
|
|
|
|
};
|
|
|
|
|
|
|
|
static LIST_HEAD(dsim_ddi_list);
|
|
|
|
|
|
|
|
static DEFINE_MUTEX(mipi_dsim_lock);
|
|
|
|
|
|
|
|
static struct mipi_dsim_platform_data *to_dsim_plat(struct platform_device
|
|
|
|
*pdev)
|
|
|
|
{
|
|
|
|
return pdev->dev.platform_data;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct regulator_bulk_data supplies[] = {
|
2012-05-07 04:20:51 +04:00
|
|
|
{ .supply = "vdd11", },
|
2012-02-09 00:47:39 +04:00
|
|
|
{ .supply = "vdd18", },
|
|
|
|
};
|
|
|
|
|
|
|
|
static int exynos_mipi_regulator_enable(struct mipi_dsim_device *dsim)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
mutex_lock(&dsim->lock);
|
|
|
|
ret = regulator_bulk_enable(ARRAY_SIZE(supplies), supplies);
|
|
|
|
mutex_unlock(&dsim->lock);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int exynos_mipi_regulator_disable(struct mipi_dsim_device *dsim)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
mutex_lock(&dsim->lock);
|
|
|
|
ret = regulator_bulk_disable(ARRAY_SIZE(supplies), supplies);
|
|
|
|
mutex_unlock(&dsim->lock);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* update all register settings to MIPI DSI controller. */
|
|
|
|
static void exynos_mipi_update_cfg(struct mipi_dsim_device *dsim)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* data from Display controller(FIMD) is not transferred in video mode
|
|
|
|
* but in case of command mode, all settings is not updated to
|
|
|
|
* registers.
|
|
|
|
*/
|
|
|
|
exynos_mipi_dsi_stand_by(dsim, 0);
|
|
|
|
|
|
|
|
exynos_mipi_dsi_init_dsim(dsim);
|
|
|
|
exynos_mipi_dsi_init_link(dsim);
|
|
|
|
|
|
|
|
exynos_mipi_dsi_set_hs_enable(dsim);
|
|
|
|
|
|
|
|
/* set display timing. */
|
|
|
|
exynos_mipi_dsi_set_display_mode(dsim, dsim->dsim_config);
|
|
|
|
|
2012-05-04 08:59:22 +04:00
|
|
|
exynos_mipi_dsi_init_interrupt(dsim);
|
|
|
|
|
2012-02-09 00:47:39 +04:00
|
|
|
/*
|
|
|
|
* data from Display controller(FIMD) is transferred in video mode
|
2012-07-21 19:23:15 +04:00
|
|
|
* but in case of command mode, all settings are updated to registers.
|
2012-02-09 00:47:39 +04:00
|
|
|
*/
|
|
|
|
exynos_mipi_dsi_stand_by(dsim, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int exynos_mipi_dsi_early_blank_mode(struct mipi_dsim_device *dsim,
|
|
|
|
int power)
|
|
|
|
{
|
|
|
|
struct mipi_dsim_lcd_driver *client_drv = dsim->dsim_lcd_drv;
|
|
|
|
struct mipi_dsim_lcd_device *client_dev = dsim->dsim_lcd_dev;
|
|
|
|
|
|
|
|
switch (power) {
|
|
|
|
case FB_BLANK_POWERDOWN:
|
|
|
|
if (dsim->suspended)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (client_drv && client_drv->suspend)
|
|
|
|
client_drv->suspend(client_dev);
|
|
|
|
|
|
|
|
clk_disable(dsim->clock);
|
|
|
|
|
|
|
|
exynos_mipi_regulator_disable(dsim);
|
|
|
|
|
|
|
|
dsim->suspended = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int exynos_mipi_dsi_blank_mode(struct mipi_dsim_device *dsim, int power)
|
|
|
|
{
|
|
|
|
struct mipi_dsim_lcd_driver *client_drv = dsim->dsim_lcd_drv;
|
|
|
|
struct mipi_dsim_lcd_device *client_dev = dsim->dsim_lcd_dev;
|
|
|
|
|
|
|
|
switch (power) {
|
|
|
|
case FB_BLANK_UNBLANK:
|
|
|
|
if (!dsim->suspended)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* lcd panel power on. */
|
|
|
|
if (client_drv && client_drv->power_on)
|
|
|
|
client_drv->power_on(client_dev, 1);
|
|
|
|
|
2012-07-23 06:25:30 +04:00
|
|
|
exynos_mipi_regulator_enable(dsim);
|
2012-02-09 00:47:39 +04:00
|
|
|
|
|
|
|
/* enable MIPI-DSI PHY. */
|
2013-10-16 20:28:12 +04:00
|
|
|
phy_power_on(dsim->phy);
|
2012-02-09 00:47:39 +04:00
|
|
|
|
|
|
|
clk_enable(dsim->clock);
|
|
|
|
|
|
|
|
exynos_mipi_update_cfg(dsim);
|
|
|
|
|
|
|
|
/* set lcd panel sequence commands. */
|
|
|
|
if (client_drv && client_drv->set_sequence)
|
|
|
|
client_drv->set_sequence(client_dev);
|
|
|
|
|
|
|
|
dsim->suspended = false;
|
|
|
|
|
|
|
|
break;
|
|
|
|
case FB_BLANK_NORMAL:
|
|
|
|
/* TODO. */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int exynos_mipi_dsi_register_lcd_device(struct mipi_dsim_lcd_device *lcd_dev)
|
|
|
|
{
|
|
|
|
struct mipi_dsim_ddi *dsim_ddi;
|
|
|
|
|
|
|
|
if (!lcd_dev->name) {
|
|
|
|
pr_err("dsim_lcd_device name is NULL.\n");
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
dsim_ddi = kzalloc(sizeof(struct mipi_dsim_ddi), GFP_KERNEL);
|
|
|
|
if (!dsim_ddi) {
|
|
|
|
pr_err("failed to allocate dsim_ddi object.\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
dsim_ddi->dsim_lcd_dev = lcd_dev;
|
|
|
|
|
|
|
|
mutex_lock(&mipi_dsim_lock);
|
|
|
|
list_add_tail(&dsim_ddi->list, &dsim_ddi_list);
|
|
|
|
mutex_unlock(&mipi_dsim_lock);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-08-02 10:14:11 +04:00
|
|
|
static struct mipi_dsim_ddi *exynos_mipi_dsi_find_lcd_device(
|
|
|
|
struct mipi_dsim_lcd_driver *lcd_drv)
|
2012-02-09 00:47:39 +04:00
|
|
|
{
|
|
|
|
struct mipi_dsim_ddi *dsim_ddi, *next;
|
|
|
|
struct mipi_dsim_lcd_device *lcd_dev;
|
|
|
|
|
|
|
|
mutex_lock(&mipi_dsim_lock);
|
|
|
|
|
|
|
|
list_for_each_entry_safe(dsim_ddi, next, &dsim_ddi_list, list) {
|
|
|
|
if (!dsim_ddi)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
lcd_dev = dsim_ddi->dsim_lcd_dev;
|
|
|
|
if (!lcd_dev)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if ((strcmp(lcd_drv->name, lcd_dev->name)) == 0) {
|
|
|
|
/**
|
|
|
|
* bus_id would be used to identify
|
|
|
|
* connected bus.
|
|
|
|
*/
|
|
|
|
dsim_ddi->bus_id = lcd_dev->bus_id;
|
|
|
|
mutex_unlock(&mipi_dsim_lock);
|
|
|
|
|
|
|
|
return dsim_ddi;
|
|
|
|
}
|
|
|
|
|
|
|
|
list_del(&dsim_ddi->list);
|
|
|
|
kfree(dsim_ddi);
|
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
mutex_unlock(&mipi_dsim_lock);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
int exynos_mipi_dsi_register_lcd_driver(struct mipi_dsim_lcd_driver *lcd_drv)
|
|
|
|
{
|
|
|
|
struct mipi_dsim_ddi *dsim_ddi;
|
|
|
|
|
|
|
|
if (!lcd_drv->name) {
|
|
|
|
pr_err("dsim_lcd_driver name is NULL.\n");
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
dsim_ddi = exynos_mipi_dsi_find_lcd_device(lcd_drv);
|
|
|
|
if (!dsim_ddi) {
|
|
|
|
pr_err("mipi_dsim_ddi object not found.\n");
|
|
|
|
return -EFAULT;
|
|
|
|
}
|
|
|
|
|
|
|
|
dsim_ddi->dsim_lcd_drv = lcd_drv;
|
|
|
|
|
|
|
|
pr_info("registered panel driver(%s) to mipi-dsi driver.\n",
|
|
|
|
lcd_drv->name);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-08-02 10:14:11 +04:00
|
|
|
static struct mipi_dsim_ddi *exynos_mipi_dsi_bind_lcd_ddi(
|
|
|
|
struct mipi_dsim_device *dsim,
|
2012-02-09 00:47:39 +04:00
|
|
|
const char *name)
|
|
|
|
{
|
|
|
|
struct mipi_dsim_ddi *dsim_ddi, *next;
|
|
|
|
struct mipi_dsim_lcd_driver *lcd_drv;
|
|
|
|
struct mipi_dsim_lcd_device *lcd_dev;
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
mutex_lock(&dsim->lock);
|
|
|
|
|
|
|
|
list_for_each_entry_safe(dsim_ddi, next, &dsim_ddi_list, list) {
|
|
|
|
lcd_drv = dsim_ddi->dsim_lcd_drv;
|
|
|
|
lcd_dev = dsim_ddi->dsim_lcd_dev;
|
|
|
|
if (!lcd_drv || !lcd_dev ||
|
|
|
|
(dsim->id != dsim_ddi->bus_id))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
dev_dbg(dsim->dev, "lcd_drv->id = %d, lcd_dev->id = %d\n",
|
|
|
|
lcd_drv->id, lcd_dev->id);
|
|
|
|
dev_dbg(dsim->dev, "lcd_dev->bus_id = %d, dsim->id = %d\n",
|
|
|
|
lcd_dev->bus_id, dsim->id);
|
|
|
|
|
|
|
|
if ((strcmp(lcd_drv->name, name) == 0)) {
|
|
|
|
lcd_dev->master = dsim;
|
|
|
|
|
|
|
|
lcd_dev->dev.parent = dsim->dev;
|
|
|
|
dev_set_name(&lcd_dev->dev, "%s", lcd_drv->name);
|
|
|
|
|
|
|
|
ret = device_register(&lcd_dev->dev);
|
|
|
|
if (ret < 0) {
|
|
|
|
dev_err(dsim->dev,
|
|
|
|
"can't register %s, status %d\n",
|
|
|
|
dev_name(&lcd_dev->dev), ret);
|
|
|
|
mutex_unlock(&dsim->lock);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
dsim->dsim_lcd_dev = lcd_dev;
|
|
|
|
dsim->dsim_lcd_drv = lcd_drv;
|
|
|
|
|
|
|
|
mutex_unlock(&dsim->lock);
|
|
|
|
|
|
|
|
return dsim_ddi;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mutex_unlock(&dsim->lock);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* define MIPI-DSI Master operations. */
|
|
|
|
static struct mipi_dsim_master_ops master_ops = {
|
|
|
|
.cmd_read = exynos_mipi_dsi_rd_data,
|
|
|
|
.cmd_write = exynos_mipi_dsi_wr_data,
|
|
|
|
.get_dsim_frame_done = exynos_mipi_dsi_get_frame_done_status,
|
|
|
|
.clear_dsim_frame_done = exynos_mipi_dsi_clear_frame_done,
|
|
|
|
.set_early_blank_mode = exynos_mipi_dsi_early_blank_mode,
|
|
|
|
.set_blank_mode = exynos_mipi_dsi_blank_mode,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int exynos_mipi_dsi_probe(struct platform_device *pdev)
|
|
|
|
{
|
|
|
|
struct resource *res;
|
|
|
|
struct mipi_dsim_device *dsim;
|
|
|
|
struct mipi_dsim_config *dsim_config;
|
|
|
|
struct mipi_dsim_platform_data *dsim_pd;
|
|
|
|
struct mipi_dsim_ddi *dsim_ddi;
|
|
|
|
int ret = -EINVAL;
|
|
|
|
|
2013-02-22 04:42:28 +04:00
|
|
|
dsim = devm_kzalloc(&pdev->dev, sizeof(struct mipi_dsim_device),
|
|
|
|
GFP_KERNEL);
|
2012-02-09 00:47:39 +04:00
|
|
|
if (!dsim) {
|
|
|
|
dev_err(&pdev->dev, "failed to allocate dsim object.\n");
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
dsim->pd = to_dsim_plat(pdev);
|
|
|
|
dsim->dev = &pdev->dev;
|
|
|
|
dsim->id = pdev->id;
|
|
|
|
|
|
|
|
/* get mipi_dsim_platform_data. */
|
|
|
|
dsim_pd = (struct mipi_dsim_platform_data *)dsim->pd;
|
|
|
|
if (dsim_pd == NULL) {
|
|
|
|
dev_err(&pdev->dev, "failed to get platform data for dsim.\n");
|
2013-02-22 04:42:28 +04:00
|
|
|
return -EINVAL;
|
2012-02-09 00:47:39 +04:00
|
|
|
}
|
|
|
|
/* get mipi_dsim_config. */
|
|
|
|
dsim_config = dsim_pd->dsim_config;
|
|
|
|
if (dsim_config == NULL) {
|
|
|
|
dev_err(&pdev->dev, "failed to get dsim config data.\n");
|
2013-02-22 04:42:28 +04:00
|
|
|
return -EINVAL;
|
2012-02-09 00:47:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
dsim->dsim_config = dsim_config;
|
|
|
|
dsim->master_ops = &master_ops;
|
|
|
|
|
|
|
|
mutex_init(&dsim->lock);
|
|
|
|
|
2013-02-22 04:42:28 +04:00
|
|
|
ret = devm_regulator_bulk_get(&pdev->dev, ARRAY_SIZE(supplies),
|
|
|
|
supplies);
|
2012-02-09 00:47:39 +04:00
|
|
|
if (ret) {
|
|
|
|
dev_err(&pdev->dev, "Failed to get regulators: %d\n", ret);
|
2013-02-22 04:42:28 +04:00
|
|
|
return ret;
|
2012-02-09 00:47:39 +04:00
|
|
|
}
|
|
|
|
|
2013-10-16 20:28:12 +04:00
|
|
|
dsim->phy = devm_phy_get(&pdev->dev, "dsim");
|
|
|
|
if (IS_ERR(dsim->phy))
|
|
|
|
return PTR_ERR(dsim->phy);
|
|
|
|
|
2013-02-22 04:42:28 +04:00
|
|
|
dsim->clock = devm_clk_get(&pdev->dev, "dsim0");
|
2012-02-09 00:47:39 +04:00
|
|
|
if (IS_ERR(dsim->clock)) {
|
|
|
|
dev_err(&pdev->dev, "failed to get dsim clock source\n");
|
2013-02-22 04:42:28 +04:00
|
|
|
return -ENODEV;
|
2012-02-09 00:47:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
clk_enable(dsim->clock);
|
|
|
|
|
|
|
|
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
|
|
|
|
2013-04-30 02:05:43 +04:00
|
|
|
dsim->reg_base = devm_ioremap_resource(&pdev->dev, res);
|
|
|
|
if (IS_ERR(dsim->reg_base)) {
|
|
|
|
ret = PTR_ERR(dsim->reg_base);
|
2013-02-22 04:42:28 +04:00
|
|
|
goto error;
|
2012-02-09 00:47:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
mutex_init(&dsim->lock);
|
|
|
|
|
|
|
|
/* bind lcd ddi matched with panel name. */
|
|
|
|
dsim_ddi = exynos_mipi_dsi_bind_lcd_ddi(dsim, dsim_pd->lcd_panel_name);
|
|
|
|
if (!dsim_ddi) {
|
|
|
|
dev_err(&pdev->dev, "mipi_dsim_ddi object not found.\n");
|
2012-10-03 16:40:44 +04:00
|
|
|
ret = -EINVAL;
|
2013-02-22 04:42:28 +04:00
|
|
|
goto error;
|
2012-02-09 00:47:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
dsim->irq = platform_get_irq(pdev, 0);
|
2013-02-22 04:42:27 +04:00
|
|
|
if (IS_ERR_VALUE(dsim->irq)) {
|
2012-02-09 00:47:39 +04:00
|
|
|
dev_err(&pdev->dev, "failed to request dsim irq resource\n");
|
|
|
|
ret = -EINVAL;
|
2013-02-22 04:42:28 +04:00
|
|
|
goto error;
|
2012-02-09 00:47:39 +04:00
|
|
|
}
|
|
|
|
|
2012-05-09 09:33:28 +04:00
|
|
|
init_completion(&dsim_wr_comp);
|
|
|
|
init_completion(&dsim_rd_comp);
|
|
|
|
platform_set_drvdata(pdev, dsim);
|
|
|
|
|
2013-02-22 04:42:28 +04:00
|
|
|
ret = devm_request_irq(&pdev->dev, dsim->irq,
|
|
|
|
exynos_mipi_dsi_interrupt_handler,
|
2012-05-09 09:33:28 +04:00
|
|
|
IRQF_SHARED, dev_name(&pdev->dev), dsim);
|
2012-02-09 00:47:39 +04:00
|
|
|
if (ret != 0) {
|
|
|
|
dev_err(&pdev->dev, "failed to request dsim irq\n");
|
|
|
|
ret = -EINVAL;
|
2013-02-22 04:42:28 +04:00
|
|
|
goto error;
|
2012-02-09 00:47:39 +04:00
|
|
|
}
|
|
|
|
|
2012-05-09 09:33:28 +04:00
|
|
|
/* enable interrupts */
|
2012-02-09 00:47:39 +04:00
|
|
|
exynos_mipi_dsi_init_interrupt(dsim);
|
|
|
|
|
|
|
|
/* initialize mipi-dsi client(lcd panel). */
|
|
|
|
if (dsim_ddi->dsim_lcd_drv && dsim_ddi->dsim_lcd_drv->probe)
|
|
|
|
dsim_ddi->dsim_lcd_drv->probe(dsim_ddi->dsim_lcd_dev);
|
|
|
|
|
2012-05-09 09:33:28 +04:00
|
|
|
/* in case mipi-dsi has been enabled by bootloader */
|
|
|
|
if (dsim_pd->enabled) {
|
|
|
|
exynos_mipi_regulator_enable(dsim);
|
|
|
|
goto done;
|
|
|
|
}
|
2012-02-09 00:47:39 +04:00
|
|
|
|
|
|
|
/* lcd panel power on. */
|
|
|
|
if (dsim_ddi->dsim_lcd_drv && dsim_ddi->dsim_lcd_drv->power_on)
|
|
|
|
dsim_ddi->dsim_lcd_drv->power_on(dsim_ddi->dsim_lcd_dev, 1);
|
|
|
|
|
|
|
|
exynos_mipi_regulator_enable(dsim);
|
|
|
|
|
|
|
|
/* enable MIPI-DSI PHY. */
|
2013-10-16 20:28:12 +04:00
|
|
|
phy_power_on(dsim->phy);
|
2012-02-09 00:47:39 +04:00
|
|
|
|
|
|
|
exynos_mipi_update_cfg(dsim);
|
|
|
|
|
|
|
|
/* set lcd panel sequence commands. */
|
|
|
|
if (dsim_ddi->dsim_lcd_drv && dsim_ddi->dsim_lcd_drv->set_sequence)
|
|
|
|
dsim_ddi->dsim_lcd_drv->set_sequence(dsim_ddi->dsim_lcd_dev);
|
|
|
|
|
|
|
|
dsim->suspended = false;
|
|
|
|
|
2012-05-09 09:33:28 +04:00
|
|
|
done:
|
2012-02-09 00:47:39 +04:00
|
|
|
platform_set_drvdata(pdev, dsim);
|
|
|
|
|
2012-09-01 21:31:09 +04:00
|
|
|
dev_dbg(&pdev->dev, "%s() completed successfully (%s mode)\n", __func__,
|
2012-05-09 09:33:28 +04:00
|
|
|
dsim_config->e_interface == DSIM_COMMAND ? "CPU" : "RGB");
|
2012-02-09 00:47:39 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
2013-02-22 04:42:28 +04:00
|
|
|
error:
|
2012-02-09 00:47:39 +04:00
|
|
|
clk_disable(dsim->clock);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-12-22 01:07:39 +04:00
|
|
|
static int exynos_mipi_dsi_remove(struct platform_device *pdev)
|
2012-02-09 00:47:39 +04:00
|
|
|
{
|
|
|
|
struct mipi_dsim_device *dsim = platform_get_drvdata(pdev);
|
|
|
|
struct mipi_dsim_ddi *dsim_ddi, *next;
|
|
|
|
struct mipi_dsim_lcd_driver *dsim_lcd_drv;
|
|
|
|
|
|
|
|
clk_disable(dsim->clock);
|
|
|
|
|
|
|
|
list_for_each_entry_safe(dsim_ddi, next, &dsim_ddi_list, list) {
|
|
|
|
if (dsim_ddi) {
|
|
|
|
if (dsim->id != dsim_ddi->bus_id)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
dsim_lcd_drv = dsim_ddi->dsim_lcd_drv;
|
|
|
|
|
|
|
|
if (dsim_lcd_drv->remove)
|
|
|
|
dsim_lcd_drv->remove(dsim_ddi->dsim_lcd_dev);
|
|
|
|
|
|
|
|
kfree(dsim_ddi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-05-09 09:33:26 +04:00
|
|
|
#ifdef CONFIG_PM_SLEEP
|
|
|
|
static int exynos_mipi_dsi_suspend(struct device *dev)
|
2012-02-09 00:47:39 +04:00
|
|
|
{
|
2012-05-09 09:33:26 +04:00
|
|
|
struct platform_device *pdev = to_platform_device(dev);
|
2012-02-09 00:47:39 +04:00
|
|
|
struct mipi_dsim_device *dsim = platform_get_drvdata(pdev);
|
|
|
|
struct mipi_dsim_lcd_driver *client_drv = dsim->dsim_lcd_drv;
|
|
|
|
struct mipi_dsim_lcd_device *client_dev = dsim->dsim_lcd_dev;
|
|
|
|
|
|
|
|
disable_irq(dsim->irq);
|
|
|
|
|
|
|
|
if (dsim->suspended)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if (client_drv && client_drv->suspend)
|
|
|
|
client_drv->suspend(client_dev);
|
|
|
|
|
2013-10-16 20:28:12 +04:00
|
|
|
/* disable MIPI-DSI PHY. */
|
|
|
|
phy_power_off(dsim->phy);
|
2012-02-09 00:47:39 +04:00
|
|
|
|
|
|
|
clk_disable(dsim->clock);
|
|
|
|
|
|
|
|
exynos_mipi_regulator_disable(dsim);
|
|
|
|
|
|
|
|
dsim->suspended = true;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-05-09 09:33:26 +04:00
|
|
|
static int exynos_mipi_dsi_resume(struct device *dev)
|
2012-02-09 00:47:39 +04:00
|
|
|
{
|
2012-05-09 09:33:26 +04:00
|
|
|
struct platform_device *pdev = to_platform_device(dev);
|
2012-02-09 00:47:39 +04:00
|
|
|
struct mipi_dsim_device *dsim = platform_get_drvdata(pdev);
|
|
|
|
struct mipi_dsim_lcd_driver *client_drv = dsim->dsim_lcd_drv;
|
|
|
|
struct mipi_dsim_lcd_device *client_dev = dsim->dsim_lcd_dev;
|
|
|
|
|
|
|
|
enable_irq(dsim->irq);
|
|
|
|
|
|
|
|
if (!dsim->suspended)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* lcd panel power on. */
|
|
|
|
if (client_drv && client_drv->power_on)
|
|
|
|
client_drv->power_on(client_dev, 1);
|
|
|
|
|
|
|
|
exynos_mipi_regulator_enable(dsim);
|
|
|
|
|
|
|
|
/* enable MIPI-DSI PHY. */
|
2013-10-16 20:28:12 +04:00
|
|
|
phy_power_on(dsim->phy);
|
2012-02-09 00:47:39 +04:00
|
|
|
|
|
|
|
clk_enable(dsim->clock);
|
|
|
|
|
|
|
|
exynos_mipi_update_cfg(dsim);
|
|
|
|
|
|
|
|
/* set lcd panel sequence commands. */
|
|
|
|
if (client_drv && client_drv->set_sequence)
|
|
|
|
client_drv->set_sequence(client_dev);
|
|
|
|
|
|
|
|
dsim->suspended = false;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-05-09 09:33:26 +04:00
|
|
|
static const struct dev_pm_ops exynos_mipi_dsi_pm_ops = {
|
|
|
|
SET_SYSTEM_SLEEP_PM_OPS(exynos_mipi_dsi_suspend, exynos_mipi_dsi_resume)
|
|
|
|
};
|
|
|
|
|
2012-02-09 00:47:39 +04:00
|
|
|
static struct platform_driver exynos_mipi_dsi_driver = {
|
|
|
|
.probe = exynos_mipi_dsi_probe,
|
2012-12-22 01:07:39 +04:00
|
|
|
.remove = exynos_mipi_dsi_remove,
|
2012-02-09 00:47:39 +04:00
|
|
|
.driver = {
|
|
|
|
.name = "exynos-mipi-dsim",
|
2012-05-09 09:33:26 +04:00
|
|
|
.pm = &exynos_mipi_dsi_pm_ops,
|
2012-02-09 00:47:39 +04:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
module_platform_driver(exynos_mipi_dsi_driver);
|
|
|
|
|
|
|
|
MODULE_AUTHOR("InKi Dae <inki.dae@samsung.com>");
|
2014-10-16 19:09:24 +04:00
|
|
|
MODULE_DESCRIPTION("Samsung SoC MIPI-DSI driver");
|
2012-02-09 00:47:39 +04:00
|
|
|
MODULE_LICENSE("GPL");
|