Commit d8c61663 authored by Dave Airlie's avatar Dave Airlie

Merge tag 'tilcdc-4.6' of https://github.com/jsarha/linux into drm-next

tilcdc changes for v4.6

Accumulated fixes and improvements from ti-linux-4.1.
* Almost complete rewrite of pagefliping code
* dma-buf support
* pinctrl support
* lot of fixes and cleanups

* tag 'tilcdc-4.6' of https://github.com/jsarha/linux: (22 commits)
  drm/tilcdc: Use devm_kzalloc() and devm_kcalloc() for private data
  drm/tilcdc: Initialize crtc->port
  drm/tilcdc: Disable sync lost interrupt if it fires on every frame
  drm/tilcdc: Add prints on sync lost and FIFO underrun interrupts
  drm/tilcdc: Remove the duplicate LCDC_INT_ENABLE_SET_REG in registers[]
  drm/tilcdc: Fix interrupt enable/disable code for version 2 tilcdc
  drm/tilcdc: Do not update the next frame buffer close to vertical blank
  drm/tilcdc: Get rid of complex ping-pong mechanism
  drm/tilcdc: cleanup irq handling
  drm/tilcdc: remove broken error handling
  drm/tilcdc: split reset to a separate function
  drm/tilcdc: disable crtc on unload
  drm/tilcdc: cleanup runtime PM handling
  drm/tilcdc: Allocate register storage based on the actual number registers
  drm/tilcdc: fix build error when !CONFIG_CPU_FREQ
  drm/tilcdc: Implement dma-buf support for tilcdc
  drm/tilcdc: disable the lcd controller/dma engine when suspend invoked
  drm/tilcdc: make frame_done interrupt active at all times
  drm/tilcdc: fix kernel panic on suspend when no hdmi monitor connected
  drm/tilcdc: adopt pinctrl support
  ...
parents a90cc3f2 d0ec32ca
This diff is collapsed.
......@@ -18,6 +18,8 @@
/* LCDC DRM driver, based on da8xx-fb */
#include <linux/component.h>
#include <linux/pinctrl/consumer.h>
#include <linux/suspend.h>
#include "tilcdc_drv.h"
#include "tilcdc_regs.h"
......@@ -110,6 +112,8 @@ static int tilcdc_unload(struct drm_device *dev)
{
struct tilcdc_drm_private *priv = dev->dev_private;
tilcdc_crtc_dpms(priv->crtc, DRM_MODE_DPMS_OFF);
tilcdc_remove_external_encoders(dev);
drm_fbdev_cma_fini(priv->fbdev);
......@@ -139,11 +143,11 @@ static int tilcdc_unload(struct drm_device *dev)
pm_runtime_disable(dev->dev);
kfree(priv);
return 0;
}
static size_t tilcdc_num_regs(void);
static int tilcdc_load(struct drm_device *dev, unsigned long flags)
{
struct platform_device *pdev = dev->platformdev;
......@@ -154,8 +158,12 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
u32 bpp = 0;
int ret;
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv) {
priv = devm_kzalloc(dev->dev, sizeof(*priv), GFP_KERNEL);
if (priv)
priv->saved_register =
devm_kcalloc(dev->dev, tilcdc_num_regs(),
sizeof(*priv->saved_register), GFP_KERNEL);
if (!priv || !priv->saved_register) {
dev_err(dev->dev, "failed to allocate private data\n");
return -ENOMEM;
}
......@@ -168,7 +176,7 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
priv->wq = alloc_ordered_workqueue("tilcdc", 0);
if (!priv->wq) {
ret = -ENOMEM;
goto fail_free_priv;
goto fail_unset_priv;
}
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
......@@ -192,13 +200,6 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
goto fail_iounmap;
}
priv->disp_clk = clk_get(dev->dev, "dpll_disp_ck");
if (IS_ERR(priv->clk)) {
dev_err(dev->dev, "failed to get display clock\n");
ret = -ENODEV;
goto fail_put_clk;
}
#ifdef CONFIG_CPU_FREQ
priv->lcd_fck_rate = clk_get_rate(priv->clk);
priv->freq_transition.notifier_call = cpufreq_transition;
......@@ -206,7 +207,7 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
CPUFREQ_TRANSITION_NOTIFIER);
if (ret) {
dev_err(dev->dev, "failed to register cpufreq notifier\n");
goto fail_put_disp_clk;
goto fail_put_clk;
}
#endif
......@@ -227,7 +228,6 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
DBG("Maximum Pixel Clock Value %dKHz", priv->max_pixelclock);
pm_runtime_enable(dev->dev);
pm_runtime_irq_safe(dev->dev);
/* Determine LCD IP Version */
pm_runtime_get_sync(dev->dev);
......@@ -330,11 +330,9 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
#ifdef CONFIG_CPU_FREQ
cpufreq_unregister_notifier(&priv->freq_transition,
CPUFREQ_TRANSITION_NOTIFIER);
fail_put_disp_clk:
clk_put(priv->disp_clk);
#endif
fail_put_clk:
#endif
clk_put(priv->clk);
fail_iounmap:
......@@ -344,9 +342,9 @@ static int tilcdc_load(struct drm_device *dev, unsigned long flags)
flush_workqueue(priv->wq);
destroy_workqueue(priv->wq);
fail_free_priv:
fail_unset_priv:
dev->dev_private = NULL;
kfree(priv);
return ret;
}
......@@ -373,10 +371,14 @@ static int tilcdc_irq_postinstall(struct drm_device *dev)
struct tilcdc_drm_private *priv = dev->dev_private;
/* enable FIFO underflow irq: */
if (priv->rev == 1)
if (priv->rev == 1) {
tilcdc_set(dev, LCDC_RASTER_CTRL_REG, LCDC_V1_UNDERFLOW_INT_ENA);
else
tilcdc_set(dev, LCDC_INT_ENABLE_SET_REG, LCDC_V2_UNDERFLOW_INT_ENA);
} else {
tilcdc_write(dev, LCDC_INT_ENABLE_SET_REG,
LCDC_V2_UNDERFLOW_INT_ENA |
LCDC_V2_END_OF_FRAME0_INT_ENA |
LCDC_FRAME_DONE | LCDC_SYNC_LOST);
}
return 0;
}
......@@ -391,43 +393,21 @@ static void tilcdc_irq_uninstall(struct drm_device *dev)
LCDC_V1_UNDERFLOW_INT_ENA | LCDC_V1_PL_INT_ENA);
tilcdc_clear(dev, LCDC_DMA_CTRL_REG, LCDC_V1_END_OF_FRAME_INT_ENA);
} else {
tilcdc_clear(dev, LCDC_INT_ENABLE_SET_REG,
tilcdc_write(dev, LCDC_INT_ENABLE_CLR_REG,
LCDC_V2_UNDERFLOW_INT_ENA | LCDC_V2_PL_INT_ENA |
LCDC_V2_END_OF_FRAME0_INT_ENA | LCDC_V2_END_OF_FRAME1_INT_ENA |
LCDC_FRAME_DONE);
LCDC_V2_END_OF_FRAME0_INT_ENA |
LCDC_FRAME_DONE | LCDC_SYNC_LOST);
}
}
static void enable_vblank(struct drm_device *dev, bool enable)
{
struct tilcdc_drm_private *priv = dev->dev_private;
u32 reg, mask;
if (priv->rev == 1) {
reg = LCDC_DMA_CTRL_REG;
mask = LCDC_V1_END_OF_FRAME_INT_ENA;
} else {
reg = LCDC_INT_ENABLE_SET_REG;
mask = LCDC_V2_END_OF_FRAME0_INT_ENA |
LCDC_V2_END_OF_FRAME1_INT_ENA | LCDC_FRAME_DONE;
}
if (enable)
tilcdc_set(dev, reg, mask);
else
tilcdc_clear(dev, reg, mask);
}
static int tilcdc_enable_vblank(struct drm_device *dev, unsigned int pipe)
{
enable_vblank(dev, true);
return 0;
}
static void tilcdc_disable_vblank(struct drm_device *dev, unsigned int pipe)
{
enable_vblank(dev, false);
return;
}
#if defined(CONFIG_DEBUG_FS) || defined(CONFIG_PM_SLEEP)
......@@ -454,13 +434,22 @@ static const struct {
/* new in revision 2: */
REG(2, false, LCDC_RAW_STAT_REG),
REG(2, false, LCDC_MASKED_STAT_REG),
REG(2, false, LCDC_INT_ENABLE_SET_REG),
REG(2, true, LCDC_INT_ENABLE_SET_REG),
REG(2, false, LCDC_INT_ENABLE_CLR_REG),
REG(2, false, LCDC_END_OF_INT_IND_REG),
REG(2, true, LCDC_CLK_ENABLE_REG),
REG(2, true, LCDC_INT_ENABLE_SET_REG),
#undef REG
};
static size_t tilcdc_num_regs(void)
{
return ARRAY_SIZE(registers);
}
#else
static size_t tilcdc_num_regs(void)
{
return 0;
}
#endif
#ifdef CONFIG_DEBUG_FS
......@@ -547,7 +536,8 @@ static const struct file_operations fops = {
};
static struct drm_driver tilcdc_driver = {
.driver_features = DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET,
.driver_features = (DRIVER_HAVE_IRQ | DRIVER_GEM | DRIVER_MODESET |
DRIVER_PRIME),
.load = tilcdc_load,
.unload = tilcdc_unload,
.lastclose = tilcdc_lastclose,
......@@ -564,6 +554,16 @@ static struct drm_driver tilcdc_driver = {
.dumb_create = drm_gem_cma_dumb_create,
.dumb_map_offset = drm_gem_cma_dumb_map_offset,
.dumb_destroy = drm_gem_dumb_destroy,
.prime_handle_to_fd = drm_gem_prime_handle_to_fd,
.prime_fd_to_handle = drm_gem_prime_fd_to_handle,
.gem_prime_import = drm_gem_prime_import,
.gem_prime_export = drm_gem_prime_export,
.gem_prime_get_sg_table = drm_gem_cma_prime_get_sg_table,
.gem_prime_import_sg_table = drm_gem_cma_prime_import_sg_table,
.gem_prime_vmap = drm_gem_cma_prime_vmap,
.gem_prime_vunmap = drm_gem_cma_prime_vunmap,
.gem_prime_mmap = drm_gem_cma_prime_mmap,
#ifdef CONFIG_DEBUG_FS
.debugfs_init = tilcdc_debugfs_init,
.debugfs_cleanup = tilcdc_debugfs_cleanup,
......@@ -589,11 +589,24 @@ static int tilcdc_pm_suspend(struct device *dev)
drm_kms_helper_poll_disable(ddev);
/* Select sleep pin state */
pinctrl_pm_select_sleep_state(dev);
if (pm_runtime_suspended(dev)) {
priv->ctx_valid = false;
return 0;
}
/* Disable the LCDC controller, to avoid locking up the PRCM */
tilcdc_crtc_dpms(priv->crtc, DRM_MODE_DPMS_OFF);
/* Save register state: */
for (i = 0; i < ARRAY_SIZE(registers); i++)
if (registers[i].save && (priv->rev >= registers[i].rev))
priv->saved_register[n++] = tilcdc_read(ddev, registers[i].reg);
priv->ctx_valid = true;
return 0;
}
......@@ -603,10 +616,17 @@ static int tilcdc_pm_resume(struct device *dev)
struct tilcdc_drm_private *priv = ddev->dev_private;
unsigned i, n = 0;
/* Select default pin state */
pinctrl_pm_select_default_state(dev);
if (priv->ctx_valid == true) {
/* Restore register state: */
for (i = 0; i < ARRAY_SIZE(registers); i++)
if (registers[i].save && (priv->rev >= registers[i].rev))
tilcdc_write(ddev, registers[i].reg, priv->saved_register[n++]);
if (registers[i].save &&
(priv->rev >= registers[i].rev))
tilcdc_write(ddev, registers[i].reg,
priv->saved_register[n++]);
}
drm_kms_helper_poll_enable(ddev);
......
......@@ -49,7 +49,6 @@
struct tilcdc_drm_private {
void __iomem *mmio;
struct clk *disp_clk; /* display dpll */
struct clk *clk; /* functional clock */
int rev; /* IP revision */
......@@ -67,7 +66,8 @@ struct tilcdc_drm_private {
uint32_t max_width;
/* register contents saved across suspend/resume: */
u32 saved_register[12];
u32 *saved_register;
bool ctx_valid;
#ifdef CONFIG_CPU_FREQ
struct notifier_block freq_transition;
......@@ -171,5 +171,6 @@ void tilcdc_crtc_set_simulate_vesa_sync(struct drm_crtc *crtc,
bool simulate_vesa_sync);
int tilcdc_crtc_mode_valid(struct drm_crtc *crtc, struct drm_display_mode *mode);
int tilcdc_crtc_max_width(struct drm_crtc *crtc);
void tilcdc_crtc_dpms(struct drm_crtc *crtc, int mode);
#endif /* __TILCDC_DRV_H__ */
......@@ -45,14 +45,6 @@ struct panel_encoder {
};
#define to_panel_encoder(x) container_of(x, struct panel_encoder, base)
static void panel_encoder_destroy(struct drm_encoder *encoder)
{
struct panel_encoder *panel_encoder = to_panel_encoder(encoder);
drm_encoder_cleanup(encoder);
kfree(panel_encoder);
}
static void panel_encoder_dpms(struct drm_encoder *encoder, int mode)
{
struct panel_encoder *panel_encoder = to_panel_encoder(encoder);
......@@ -90,7 +82,7 @@ static void panel_encoder_mode_set(struct drm_encoder *encoder,
}
static const struct drm_encoder_funcs panel_encoder_funcs = {
.destroy = panel_encoder_destroy,
.destroy = drm_encoder_cleanup,
};
static const struct drm_encoder_helper_funcs panel_encoder_helper_funcs = {
......@@ -107,7 +99,8 @@ static struct drm_encoder *panel_encoder_create(struct drm_device *dev,
struct drm_encoder *encoder;
int ret;
panel_encoder = kzalloc(sizeof(*panel_encoder), GFP_KERNEL);
panel_encoder = devm_kzalloc(dev->dev, sizeof(*panel_encoder),
GFP_KERNEL);
if (!panel_encoder) {
dev_err(dev->dev, "allocation failed\n");
return NULL;
......@@ -128,7 +121,7 @@ static struct drm_encoder *panel_encoder_create(struct drm_device *dev,
return encoder;
fail:
panel_encoder_destroy(encoder);
drm_encoder_cleanup(encoder);
return NULL;
}
......@@ -147,10 +140,8 @@ struct panel_connector {
static void panel_connector_destroy(struct drm_connector *connector)
{
struct panel_connector *panel_connector = to_panel_connector(connector);
drm_connector_unregister(connector);
drm_connector_cleanup(connector);
kfree(panel_connector);
}
static enum drm_connector_status panel_connector_detect(
......@@ -223,7 +214,8 @@ static struct drm_connector *panel_connector_create(struct drm_device *dev,
struct drm_connector *connector;
int ret;
panel_connector = kzalloc(sizeof(*panel_connector), GFP_KERNEL);
panel_connector = devm_kzalloc(dev->dev, sizeof(*panel_connector),
GFP_KERNEL);
if (!panel_connector) {
dev_err(dev->dev, "allocation failed\n");
return NULL;
......
......@@ -54,14 +54,6 @@ struct tfp410_encoder {
};
#define to_tfp410_encoder(x) container_of(x, struct tfp410_encoder, base)
static void tfp410_encoder_destroy(struct drm_encoder *encoder)
{
struct tfp410_encoder *tfp410_encoder = to_tfp410_encoder(encoder);
drm_encoder_cleanup(encoder);
kfree(tfp410_encoder);
}
static void tfp410_encoder_dpms(struct drm_encoder *encoder, int mode)
{
struct tfp410_encoder *tfp410_encoder = to_tfp410_encoder(encoder);
......@@ -99,7 +91,7 @@ static void tfp410_encoder_mode_set(struct drm_encoder *encoder,
}
static const struct drm_encoder_funcs tfp410_encoder_funcs = {
.destroy = tfp410_encoder_destroy,
.destroy = drm_encoder_cleanup,
};
static const struct drm_encoder_helper_funcs tfp410_encoder_helper_funcs = {
......@@ -116,7 +108,8 @@ static struct drm_encoder *tfp410_encoder_create(struct drm_device *dev,
struct drm_encoder *encoder;
int ret;
tfp410_encoder = kzalloc(sizeof(*tfp410_encoder), GFP_KERNEL);
tfp410_encoder = devm_kzalloc(dev->dev, sizeof(*tfp410_encoder),
GFP_KERNEL);
if (!tfp410_encoder) {
dev_err(dev->dev, "allocation failed\n");
return NULL;
......@@ -138,7 +131,7 @@ static struct drm_encoder *tfp410_encoder_create(struct drm_device *dev,
return encoder;
fail:
tfp410_encoder_destroy(encoder);
drm_encoder_cleanup(encoder);
return NULL;
}
......@@ -157,10 +150,8 @@ struct tfp410_connector {
static void tfp410_connector_destroy(struct drm_connector *connector)
{
struct tfp410_connector *tfp410_connector = to_tfp410_connector(connector);
drm_connector_unregister(connector);
drm_connector_cleanup(connector);
kfree(tfp410_connector);
}
static enum drm_connector_status tfp410_connector_detect(
......@@ -228,7 +219,8 @@ static struct drm_connector *tfp410_connector_create(struct drm_device *dev,
struct drm_connector *connector;
int ret;
tfp410_connector = kzalloc(sizeof(*tfp410_connector), GFP_KERNEL);
tfp410_connector = devm_kzalloc(dev->dev, sizeof(*tfp410_connector),
GFP_KERNEL);
if (!tfp410_connector) {
dev_err(dev->dev, "allocation failed\n");
return NULL;
......@@ -313,7 +305,7 @@ static int tfp410_probe(struct platform_device *pdev)
return -ENXIO;
}
tfp410_mod = kzalloc(sizeof(*tfp410_mod), GFP_KERNEL);
tfp410_mod = devm_kzalloc(&pdev->dev, sizeof(*tfp410_mod), GFP_KERNEL);
if (!tfp410_mod)
return -ENOMEM;
......@@ -366,7 +358,6 @@ static int tfp410_probe(struct platform_device *pdev)
i2c_put_adapter(tfp410_mod->i2c);
fail:
kfree(tfp410_mod);
tilcdc_module_cleanup(mod);
return ret;
}
......@@ -380,7 +371,6 @@ static int tfp410_remove(struct platform_device *pdev)
gpio_free(tfp410_mod->gpio);
tilcdc_module_cleanup(mod);
kfree(tfp410_mod);
return 0;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment