[PATCH v6 2/2] drm/panel: Add JDI LT070ME05000 WUXGA DSI Panel

2016-06-17 Thread Vinay Simha BN
Add support for the JDI LT070ME05000 WUXGA DSI panel used in
Nexus 7 2013 devices.

Programming sequence for the panel is was originally found in the
android-msm-flo-3.4-lollipop-release branch from:
https://android.googlesource.com/kernel/msm.git

And video mode setting is from dsi-panel-jdi-dualmipi1-video.dtsi
file in:
git://codeaurora.org/kernel/msm-3.10.git  LNX.LA.3.6_rb1.27

Cc: Archit Taneja 
Cc: Rob Clark 
Cc: Sumit Semwal 
Cc: John Stultz 
Cc: Emil Velikov 
Cc: Thierry Reding 
Cc: David Airlie 
Signed-off-by: Sumit Semwal 
Signed-off-by: John Stultz 
Signed-off-by: Vinay Simha BN 

---
v1:
 * sumit ported to drm/panel framework, john cherry-picked to mainline,
   folded down other fixes from Vinay and Archit, vinay removed interface
   setting cmd mode, video mode panel selected
v2:
 * incorporated code reviews from theiry, archit
   code style, alphabetical soring in Makefile, Kconfig, regulator_bulk,
   arrays of u8, generic helper function, documentation bindings,

v3:
 * dcs backlight support added
 * tested this panel driver in nexus7 2013 device

v4:
 * backlight interface added in the panel driver
 * incorporated width_mm and height_mm suggested by rob herring

v5:
 * theirry review comments incorporated
   panel model naming consistent, alphabetical soring in Kconfig
   Makefile, MAX_BRIGHTNESS dropped, regulator_names, parameterize
   panel width and height, descprition for control display, cabc
   and interface setting, temporary variable removed, consistent
   error reporting and commit message
 * removed tear on/off, scanline, since these are required only
   for command mode panels

v6:
 * emil review comments incorporated
   PANEL_NUM_REGULATORS dropped, return ret added at necessary
   places, if checks dropped for backlight and gpios
---
 drivers/gpu/drm/panel/Kconfig  |  11 +
 drivers/gpu/drm/panel/Makefile |   1 +
 drivers/gpu/drm/panel/panel-jdi-lt070me05000.c | 494 +
 3 files changed, 506 insertions(+)
 create mode 100644 drivers/gpu/drm/panel/panel-jdi-lt070me05000.c

diff --git a/drivers/gpu/drm/panel/Kconfig b/drivers/gpu/drm/panel/Kconfig
index 1500ab9..62aba97 100644
--- a/drivers/gpu/drm/panel/Kconfig
+++ b/drivers/gpu/drm/panel/Kconfig
@@ -18,6 +18,17 @@ config DRM_PANEL_SIMPLE
  that it can be automatically turned off when the panel goes into a
  low power state.

+config DRM_PANEL_JDI_LT070ME05000
+   tristate "JDI LT070ME05000 WUXGA DSI panel"
+   depends on OF
+   depends on DRM_MIPI_DSI
+   depends on BACKLIGHT_CLASS_DEVICE
+   help
+ Say Y here if you want to enable support for JDI DSI video mode
+ panel as found in Google Nexus 7 (2013) devices.
+ The panel has a 1200(RGB)×1920 (WUXGA) resolution and uses
+ 24 bit per pixel.
+
 config DRM_PANEL_SAMSUNG_LD9040
tristate "Samsung LD9040 RGB/SPI panel"
depends on OF && SPI
diff --git a/drivers/gpu/drm/panel/Makefile b/drivers/gpu/drm/panel/Makefile
index f277eed..a5c7ec0 100644
--- a/drivers/gpu/drm/panel/Makefile
+++ b/drivers/gpu/drm/panel/Makefile
@@ -1,4 +1,5 @@
 obj-$(CONFIG_DRM_PANEL_SIMPLE) += panel-simple.o
+obj-$(CONFIG_DRM_PANEL_JDI_LT070ME05000) += panel-jdi-lt070me05000.o
 obj-$(CONFIG_DRM_PANEL_LG_LG4573) += panel-lg-lg4573.o
 obj-$(CONFIG_DRM_PANEL_PANASONIC_VVX10F034N00) += 
panel-panasonic-vvx10f034n00.o
 obj-$(CONFIG_DRM_PANEL_SAMSUNG_LD9040) += panel-samsung-ld9040.o
diff --git a/drivers/gpu/drm/panel/panel-jdi-lt070me05000.c 
b/drivers/gpu/drm/panel/panel-jdi-lt070me05000.c
new file mode 100644
index 000..3213025
--- /dev/null
+++ b/drivers/gpu/drm/panel/panel-jdi-lt070me05000.c
@@ -0,0 +1,494 @@
+/*
+ * Copyright (C) 2016 InforceComputing
+ * Author: Vinay Simha BN 
+ *
+ * Copyright (C) 2016 Linaro Ltd
+ * Author: Sumit Semwal 
+ *
+ * From internet archives, the panel for Nexus 7 2nd Gen, 2013 model is a
+ * JDI model LT070ME05000, and its data sheet is at:
+ * http://panelone.net/en/7-0-inch/JDI_LT070ME05000_7.0_inch-datasheet
+ *
+ * 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.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see .
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+static const char * const regulator_names[] = {
+   "vddp",
+   "dcdc_en",
+   "vcc"
+};
+
+struct jdi_panel {
+   struct drm_panel base;
+   struct mipi_dsi_device *dsi;
+
+   struct regulator

[PATCH v2 1/2] drm/dsi: Implement dcs set/get display brightness

2016-06-17 Thread Vinay Simha BN
Provide a small convenience wrapper that set/get the
display brightness value

Cc: John Stultz 
Cc: Sumit Semwal 
Cc: Archit Taneja 
Cc: Rob Clark 
Cc: Jani Nikula 
Cc: Thierry Reding 
Signed-off-by: Vinay Simha BN 

---
v1:
 *tested in nexus7 2nd gen.

v2:
 * implemented jani review comments
   -functions name mapped accordingly
   -bl value increased from 0xff to 0x
   -backlight interface will be handled in panel driver,
so it is moved from the mipi_dsi helper function
---
 drivers/gpu/drm/drm_mipi_dsi.c | 49 ++
 include/drm/drm_mipi_dsi.h |  4 
 2 files changed, 53 insertions(+)

diff --git a/drivers/gpu/drm/drm_mipi_dsi.c b/drivers/gpu/drm/drm_mipi_dsi.c
index 49311fc..2c03784 100644
--- a/drivers/gpu/drm/drm_mipi_dsi.c
+++ b/drivers/gpu/drm/drm_mipi_dsi.c
@@ -1041,6 +1041,55 @@ int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device 
*dsi, u8 format)
 }
 EXPORT_SYMBOL(mipi_dsi_dcs_set_pixel_format);

+/**
+ * mipi_dsi_dcs_get_display_brightness() - gets the current brightness value
+ * of the display
+ * @dsi: DSI peripheral device
+ * @brightness: brightness value
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi,
+   u16 *brightness)
+{
+   ssize_t err;
+
+   err = mipi_dsi_dcs_read(dsi, MIPI_DCS_GET_DISPLAY_BRIGHTNESS,
+   brightness, sizeof(*brightness));
+   if (err < 0) {
+   if (err == 0)
+   err = -ENODATA;
+
+   return err;
+   }
+
+   return 0;
+}
+EXPORT_SYMBOL(mipi_dsi_dcs_get_display_brightness);
+
+/**
+ * mipi_dsi_dcs_set_display_brightness() - sets the brightness value of
+ * the display
+ * @dsi: DSI peripheral device
+ * @brightness: brightness value
+ *
+ * Return: 0 on success or a negative error code on failure.
+ */
+int mipi_dsi_dcs_set_display_brightness(struct mipi_dsi_device *dsi,
+   u16 brightness)
+{
+   ssize_t err;
+   u8 bl_value[2] = { brightness & 0xff, brightness >> 8 };
+
+   err = mipi_dsi_dcs_write(dsi, MIPI_DCS_SET_DISPLAY_BRIGHTNESS,
+bl_value, sizeof(bl_value));
+   if (err < 0)
+   return err;
+
+   return 0;
+}
+EXPORT_SYMBOL(mipi_dsi_dcs_set_display_brightness);
+
 static int mipi_dsi_drv_probe(struct device *dev)
 {
struct mipi_dsi_driver *drv = to_mipi_dsi_driver(dev->driver);
diff --git a/include/drm/drm_mipi_dsi.h b/include/drm/drm_mipi_dsi.h
index 72f5b15..4d77bb0 100644
--- a/include/drm/drm_mipi_dsi.h
+++ b/include/drm/drm_mipi_dsi.h
@@ -270,6 +270,10 @@ int mipi_dsi_dcs_set_tear_off(struct mipi_dsi_device *dsi);
 int mipi_dsi_dcs_set_tear_on(struct mipi_dsi_device *dsi,
 enum mipi_dsi_dcs_tear_mode mode);
 int mipi_dsi_dcs_set_pixel_format(struct mipi_dsi_device *dsi, u8 format);
+int mipi_dsi_dcs_get_display_brightness(struct mipi_dsi_device *dsi,
+   u16 *brightness);
+int mipi_dsi_dcs_set_display_brightness(struct mipi_dsi_device *dsi,
+   u16 brightness);

 /**
  * struct mipi_dsi_driver - DSI driver
-- 
1.9.1



[drm] e28cd4d0a2: INFO: trying to register non-static key.

2016-06-17 Thread Chris Wilson
On Sat, Jun 18, 2016 at 05:24:30AM +0800, kernel test robot wrote:
> [1.338384] 00:05: ttyS0 at I/O 0x3f8 (irq = 4, base_baud = 115200) is a 
> 16550A
> [1.340531] toshiba: not a supported Toshiba laptop
> [1.341126] [drm] Initialized drm 1.1.0 20060810
> [1.342029] INFO: trying to register non-static key.
> [1.342535] the code is fine but needs lockdep annotation.
> [1.343074] turning off the locking correctness validator.
> [1.343610] CPU: 0 PID: 1 Comm: swapper Not tainted 
> 4.7.0-rc2-00564-ge28cd4d #1
> [1.344330] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 
> Debian-1.8.2-1 04/01/2014
> [1.345192]    d28dbdc8 c12a197b d28dbe04 c1058c18 
> c16986b2 c169870c
> [1.346063]  c16986e2 c14e3fdc   d28dbdf0 c1027c67 
>  
> [1.346917]  d39e8b24 0001  d28dbe74 c105b796 c14e3fdc 
> c1af7ee4 c1af7ee4
> [1.347772] Call Trace:
> [1.348031]  [] dump_stack+0x16/0x18
> [1.348450]  [] register_lock_class+0x164/0x3d1
> [1.348985]  [] ? kvm_sched_clock_read+0x9/0x18
> [1.349509]  [] __lock_acquire+0x95/0x13c4
> [1.350007]  [] ? __lock_acquire+0x10d2/0x13c4
> [1.350530]  [] ? __lock_is_held+0x24/0x43
> [1.351029]  [] lock_acquire+0x59/0x77
> [1.351477]  [] ? drm_connector_register_all+0x1a/0x92
> [1.352053]  [] mutex_lock_nested+0x4d/0x2c3
> [1.352554]  [] ? drm_connector_register_all+0x1a/0x92
> [1.353140]  [] ? drm_connector_register_all+0x1a/0x92
> [1.353720]  [] ? trace_hardirqs_on+0xb/0xd
> [1.354239]  [] drm_connector_register_all+0x1a/0x92
> [1.354845]  [] ? kstrdup+0x25/0x3a
> [1.355271]  [] drm_dev_register+0x59/0x99
> [1.355781]  [] vgem_init+0x34/0x49
> [1.356213]  [] ? mipi_dsi_bus_init+0xf/0xf
> [1.356702]  [] do_one_initcall+0x7c/0xfd
> [1.357182]  [] ? parse_args+0x1fd/0x314
> [1.357648]  [] ? kernel_init_freeable+0xd0/0x179
> [1.358203]  [] kernel_init_freeable+0xec/0x179
> [1.358763]  [] kernel_init+0x8/0xcb
> [1.359222]  [] ret_from_kernel_thread+0xe/0x30
> [1.359744]  [] ? rest_init+0x10e/0x10e

Fwiw, I'm looking at polishing up dmabuf support for vGEM and adding a
couple of basic tests using vGEM to BAT. My goal being for testing
PRIME import/fencing within i915.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


[PATCH 11/16] drm: Nuke SET_UNIQUE ioctl

2016-06-17 Thread Emil Velikov
On 17 June 2016 at 08:33, Daniel Vetter  wrote:
> Ever since
>
> commit 2e1868b560315a8b20d688e646c489a5ad93eeae
> Author: Eric Anholt 
> Date:   Wed Jun 16 09:25:21 2004 +
>
> DRI trunk-20040613 import
>
> the X server supports drm 1.1, and doesn't even call this ioctl any
> more. When reviewing this note that for hilarity both the
s/and doesn't even call this ioctl any more/thus doesn't call libdrm's
drmSetBusid - the sole user of the said API ioctl./

> kernel-internal functiosn (set_busid) and the libdrm wrapper
s/functiosn/functions/

-Emil


[PATCH 08/16] drm: Use dev->name as fallback for dev->unique

2016-06-17 Thread Emil Velikov
Hi Daniel,

On 17 June 2016 at 08:33, Daniel Vetter  wrote:
> Lots of arm drivers get this wrong and for most arm boards this is the
> right thing actually. And anyway with most loaders you want to chase
> sysfs links anyway to figure out which dri device you want.
>
> This will fix dmesg noise for rockchip and sti.
>
> Also add a fallback to driver->name for entirely virtual drivers like
> vgem.
>
> v2: Rebase on top of
>
> commit e112e593b215c394c0303dbf0534db0928e87967
> Author: Nicolas Iooss 
> Date:   Fri Dec 11 11:20:28 2015 +0100
>
> drm: use dev_name as default unique name in drm_dev_alloc()
>
> and simplify a bit. Plus add a comment.
>
> Cc: Ilia Mirkin 
> Reported-by: Ilia Mirkin 
> Signed-off-by: Daniel Vetter 
> ---
>  drivers/gpu/drm/drm_drv.c   | 10 +-
>  drivers/gpu/drm/drm_ioctl.c |  8 +---
>  2 files changed, 6 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 10afa2539181..ecba2511ef5a 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -523,11 +523,11 @@ struct drm_device *drm_dev_alloc(struct drm_driver 
> *driver,
> }
> }
>
> -   if (parent) {
> -   ret = drm_dev_set_unique(dev, dev_name(parent));
> -   if (ret)
> -   goto err_setunique;
> -   }
> +   /* Use the parent device name as DRM device unique identifier, but 
> fall
> +* back to the driver name for virtual devices like vgem. */
> +   ret = drm_dev_set_unique(dev, parent ? dev_name(parent) : 
> driver->name);
> +   if (ret)
> +   goto err_setunique;
>
> return dev;
>
> diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c
> index 11eda9050215..83892b6b1e0d 100644
> --- a/drivers/gpu/drm/drm_ioctl.c
> +++ b/drivers/gpu/drm/drm_ioctl.c
> @@ -134,13 +134,7 @@ static int drm_set_busid(struct drm_device *dev, struct 
> drm_file *file_priv)
> drm_unset_busid(dev, master);
> return ret;
> }
> -   } else {
> -   if (WARN(dev->unique == NULL,
> -"No drm_driver.set_busid() implementation provided 
> by "
> -"%ps. Use drm_dev_set_unique() to set the unique "
> -"name explicitly.", dev->driver))
> -   return -EINVAL;
> -
> +   } else if (dev->unique) {
With the drm_drv.c hunk in place this will always evaluate to true,
correct ? Hmmm strictly speaking it could be NULL since vgem/platform
devices call drm_dev_set_unique() and only sun4i checks if the
function has failed.

Is it worth dropping the check here or after (alongside) patch 10 ?

-Emil


[drm] e28cd4d0a2: INFO: trying to register non-static key.

2016-06-17 Thread Chris Wilson
On Sat, Jun 18, 2016 at 05:24:30AM +0800, kernel test robot wrote:
> 
> 
> FYI, we noticed the following commit:
> 
> git://anongit.freedesktop.org/drm-intel topic/drm-misc
> commit e28cd4d0a223e1bcea616326e2281900e7e7e9a2 ("drm: Automatically 
> register/unregister all connectors")
> 
> 
> on test machine: vm-lkp-wsx03-yocto-i386: 1 threads qemu-system-i386 
> -enable-kvm with 320M memory
> 
> caused below changes:

So one driver skips drm_mode_config_init() and so
drm_connector_register_all() dies on the mutex_lock().

Maybe

if (list_empty_safe(&dev->mode_config.connector_list))
return;

or we could add a boolean to indicate an active mode_config?
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre


[PATCH] dma-buf: propagate errors from dma_buf_describe() on debugfs read

2016-06-17 Thread Mathias Krause
The callback function dma_buf_describe() returns an int not void so the
function pointer cast in dma_buf_show() is wrong. dma_buf_describe() can
also fail when acquiring the mutex gets interrupted so always returning
0 in dma_buf_show() is wrong, too.

Fix both issues by casting the function pointer to the correct type and
propagate its return value.

This type mismatch was caught by the PaX RAP plugin.

Signed-off-by: Mathias Krause 
Cc: Sumit Semwal 
Cc: Daniel Vetter 
Cc: PaX Team 
---
 drivers/dma-buf/dma-buf.c |5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 6355ab38d630..0f2a4592fdd2 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -881,10 +881,9 @@ static int dma_buf_describe(struct seq_file *s)

 static int dma_buf_show(struct seq_file *s, void *unused)
 {
-   void (*func)(struct seq_file *) = s->private;
+   int (*func)(struct seq_file *) = s->private;

-   func(s);
-   return 0;
+   return func(s);
 }

 static int dma_buf_debug_open(struct inode *inode, struct file *file)
-- 
1.7.10.4



RS780 UVD cause hpet_readl() very slow

2016-06-17 Thread Huacai Chen
Yes, USB device can fixes the issue (only attaching a device has no
effect, attching and do data transferring can fix).

Huacai

On Fri, Jun 17, 2016 at 5:31 PM, Koenig, Christian
 wrote:
> Hi Huacai,
>
> Adding our internal list on CC as well, maybe somebody else has an idea.
>
> I unfortunately don't understand at all how playing something with UVD could
> delay a simple register read by about 1ms.
>
> And do I get that right that attaching something to the USB controller on
> the south bridge fixes the issue?
>
> Additional to that the RS780 is already rather old and we don't have any
> hardware for testing that generation any more.
>
> Sorry no idea of hand,
> Christina.
>
> Am 17.06.2016 10:52 schrieb Huacai Chen :
>
> Hi, Christian
>
> We found that if we use RS780 UVD decoding, hpet_readl() will need as
> long as 1ms.
> But, if attach a U-disk on south bridge (SB700) and read some data
> from it, hpet_readl() has no problem.
> Could you please give me some suggestions or fix it?
>
> How to reproduce:
> 1, apply the patch on top of kernel (4.2+) and boot with this kernel
>
> diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
> index 307a498..a0c8634 100644
> --- a/arch/x86/kernel/apic/apic.c
> +++ b/arch/x86/kernel/apic/apic.c
> @@ -452,10 +452,12 @@ EXPORT_SYMBOL_GPL(setup_APIC_eilvt);
>  /*
>   * Program the next event, relative to now
>   */
> +void check_hpet(void);
>  static int lapic_next_event(unsigned long delta,
> struct clock_event_device *evt)
>  {
> apic_write(APIC_TMICT, delta);
> +   check_hpet();
> return 0;
>  }
>
> diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
> index 3acbff4..19329e8 100644
> --- a/arch/x86/kernel/hpet.c
> +++ b/arch/x86/kernel/hpet.c
> @@ -367,6 +367,15 @@ static void hpet_set_mode(enum clock_event_mode mode,
> }
>  }
>
> +void check_hpet(void)
> +{
> +   u32 cnt1,cnt2;
> +
> +   cnt1 = hpet_readl(HPET_COUNTER);
> +   cnt2 = hpet_readl(HPET_COUNTER);
> +   if(cnt2-cnt1>1000) printk("So big! (%u)\n",cnt2-cnt1);
> +}
> +
>  static int hpet_next_event(unsigned long delta,
>struct clock_event_device *evt, int timer)
>  {
>
> 2, ensure that no USB device attached on SB700 (except keyboard and mouse)
> 3, download this file:
> http://mirror.lemote.com/fedora-users/ipfootball/video_bench/1920x1080_25fps_h264_ac3.mkv
> 4, ffmpeg -hwaccel vdpau -i 1920x1080_25fps_h264_acc.mkv  -f rawvideo
> -an -y /dev/null
> 5, dmesg will complain "So big..."
>
> Huacai


[PATCH] drm/panel: simple: Update backlight state property

2016-06-17 Thread Thierry Reding
From: Thierry Reding 

Some backlight drivers ignore the power property and instead only use
the state property. Fixup the panel driver to set the state property in
addition to the power property.

Signed-off-by: Thierry Reding 
---
Jingoo, Lee,

What's the correct way to do this? Should we update both power and state
properties, or just state? I didn't find code anywhere to keep both in
sync, so it seemed like both needed to be set explicitly.

 drivers/gpu/drm/panel/panel-simple.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index 359cd37d09cb..f503d12b3930 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -168,6 +168,7 @@ static int panel_simple_disable(struct drm_panel *panel)

if (p->backlight) {
p->backlight->props.power = FB_BLANK_POWERDOWN;
+   p->backlight->props.state |= BL_CORE_FBBLANK;
backlight_update_status(p->backlight);
}

@@ -235,6 +236,7 @@ static int panel_simple_enable(struct drm_panel *panel)
msleep(p->desc->delay.enable);

if (p->backlight) {
+   p->backlight->props.state &= ~BL_CORE_FBBLANK;
p->backlight->props.power = FB_BLANK_UNBLANK;
backlight_update_status(p->backlight);
}
-- 
2.8.3



[RFC PATCH 00/13] Add support for Tegra DPAUX pinctrl

2016-06-17 Thread Thierry Reding
On Fri, Jun 17, 2016 at 06:56:11PM +0200, Thierry Reding wrote:
> On Fri, Jun 17, 2016 at 01:03:34PM +0100, Jon Hunter wrote:
> > The Display Port Auxiliary (DPAUX) channel pads can be shared with an
> > internal I2C controller. Add pinctrl support for these pads so that the
> > I2C controller can request and use these pads.
> > 
> > Jon Hunter (13):
> >   drm/tegra: Clean-up if probing DPAUX fails
> >   drm/tegra: Add helper functions for setting up DPAUX pads
> >   dt-bindings: drm/tegra: Update DPAUX documentation
> >   drm/tegra: Add sor-safe clock for DPAUX on Tegra210
> >   drm/tegra: Prepare DPAUX for supporting generic PM domains
> >   pinctrl: pinconf: Add generic helper function for freeing mappings
> >   dt-bindings: i2c: Add support for 'i2c-bus' subnode
> >   i2c: core: Add support for 'i2c-bus' subnode
> >   dt-bindings: drm/tegra: Add DPAUX pinctrl documentation
> >   drm/tegra: Add pinctrl support for DPAUX
> >   arm64: tegra: Add SOR power-domain node
> >   arm64: tegra: Add sor-safe clock to DPAUX binding
> >   arm64: tegra: Add DPAUX pinctrl bindings
> 
> There aren't really any hard dependencies between all these patches,
> right? I think the worst case would be if the arm64 DTS changes get
> merged before the I2C core changes (i2c-bus node support), then the
> I2C core will complain about the pinmux nodes, but that wouldn't be
> fatal, or have any bad side-effects, right?

Oh wait... there's the pinctrl helper function that is a build-
dependency. Linus, would you be okay if I took that through the
drm-tegra tree along with the DPAUX driver change, and provide a
stable branch for you to resolve conflicts against if needed?

Thierry
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160617/a3edcb40/attachment.sig>


[RFC PATCH 00/13] Add support for Tegra DPAUX pinctrl

2016-06-17 Thread Thierry Reding
On Fri, Jun 17, 2016 at 01:03:34PM +0100, Jon Hunter wrote:
> The Display Port Auxiliary (DPAUX) channel pads can be shared with an
> internal I2C controller. Add pinctrl support for these pads so that the
> I2C controller can request and use these pads.
> 
> Jon Hunter (13):
>   drm/tegra: Clean-up if probing DPAUX fails
>   drm/tegra: Add helper functions for setting up DPAUX pads
>   dt-bindings: drm/tegra: Update DPAUX documentation
>   drm/tegra: Add sor-safe clock for DPAUX on Tegra210
>   drm/tegra: Prepare DPAUX for supporting generic PM domains
>   pinctrl: pinconf: Add generic helper function for freeing mappings
>   dt-bindings: i2c: Add support for 'i2c-bus' subnode
>   i2c: core: Add support for 'i2c-bus' subnode
>   dt-bindings: drm/tegra: Add DPAUX pinctrl documentation
>   drm/tegra: Add pinctrl support for DPAUX
>   arm64: tegra: Add SOR power-domain node
>   arm64: tegra: Add sor-safe clock to DPAUX binding
>   arm64: tegra: Add DPAUX pinctrl bindings

There aren't really any hard dependencies between all these patches,
right? I think the worst case would be if the arm64 DTS changes get
merged before the I2C core changes (i2c-bus node support), then the
I2C core will complain about the pinmux nodes, but that wouldn't be
fatal, or have any bad side-effects, right?

If so, I think it would be fine if the I2C changes went through the
I2C tree. It might be nicer to have the I2C changes in a separate branch
that could be pulled into the Tegra tree so that we can get everything
ready there and avoid the warnings.

Wolfram, if you agree I can apply the I2C patches (binding + core) to a
stable branch and send out a pull request? That is, once Jon's addressed
any comments and you are onboard with the change.

Thierry
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160617/69dc185c/attachment.sig>


[RFC PATCH 13/13] arm64: tegra: Add DPAUX pinctrl bindings

2016-06-17 Thread Thierry Reding
On Fri, Jun 17, 2016 at 01:03:47PM +0100, Jon Hunter wrote:
> Add the DPAUX pinctrl states for the DPAUX nodes defining all three
> possible states of "aux", "i2c" and "off". Also add the 'i2c-bus'
> node for the DPAUX nodes so that the I2C driver core does not attempt
> to parse the pinctrl state nodes.
> 
> Populate the nodes for the pinctrl clients of the DPAUX pin controller.
> There are two clients for each DPAUX instance, namely the SOR and one of
> the I2C adapters. The SOR clients may used the DPAUX pins in either AUX
> or I2C modes and so for these devices we don't define any of the generic
> pinctrl states (default, idle, etc) because the SOR driver will directly
> set the state needed. For I2C clients only the I2C mode is used and so
> we can simplify matters by using the generic pinctrl states for default
> and idle.
> 
> Signed-off-by: Jon Hunter 
> ---
>  arch/arm64/boot/dts/nvidia/tegra210.dtsi | 48 
> 
>  1 file changed, 48 insertions(+)

Looks good to me. Thanks for driving this to conclusion.

Thierry
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160617/e75f2a2b/attachment.sig>


[RFC PATCH 12/13] arm64: tegra: Add sor-safe clock to DPAUX binding

2016-06-17 Thread Thierry Reding
On Fri, Jun 17, 2016 at 01:03:46PM +0100, Jon Hunter wrote:
> Populate the 'sor-safe' clock for DPAUX devices on Tegra210 that require
> this clock for operation. Update the compatability string for the DPAUX
> instance at address 0x545c to be "nvidia,tegra210-dpaux" to ensure
> that the 'sor-safe' clock is enabled for this device.

Does the second DPAUX need this, too? I have a vague recollection that
they were both slightly different.

Thierry
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160617/08224a2c/attachment-0001.sig>


[RFC PATCH 07/13] dt-bindings: i2c: Add support for 'i2c-bus' subnode

2016-06-17 Thread Thierry Reding
On Fri, Jun 17, 2016 at 05:30:54PM +0100, Mark Rutland wrote:
> On Fri, Jun 17, 2016 at 01:03:41PM +0100, Jon Hunter wrote:
> > The I2C driver core for boards using device-tree assumes any subnode of
> > an I2C adapter in the device-tree blob as being a I2C slave device.
> > Although this makes complete sense, some I2C adapters may have subnodes
> > which are not I2C slaves but subnodes presenting other features. For
> > example some Tegra devices have an I2C interface which may share its
> > pins with other devices and to share these pins subnodes for
> > representing these pins so they have be shared via the pinctrl framework
> > are needed.
> > 
> > To allow I2C adapters to have non-I2C specific subnodes in device-tree
> > that are not parsed by the I2C driver core by adding support for a
> > 'i2c-bus' subnode where I2C slaves can be placed. If the 'i2c-bus'
> > subnode is present then all I2C slaves must be placed under this subnode.
> > 
> > Signed-off-by: Jon Hunter 
> > ---
> >  Documentation/devicetree/bindings/i2c/i2c.txt | 8 
> >  1 file changed, 8 insertions(+)
> > 
> > diff --git a/Documentation/devicetree/bindings/i2c/i2c.txt 
> > b/Documentation/devicetree/bindings/i2c/i2c.txt
> > index f31b2ad1552b..ed56b08c7e6e 100644
> > --- a/Documentation/devicetree/bindings/i2c/i2c.txt
> > +++ b/Documentation/devicetree/bindings/i2c/i2c.txt
> > @@ -32,6 +32,14 @@ wants to support one of the below features, it should 
> > adapt the bindings below.
> >  - clock-frequency
> > frequency of bus clock in Hz.
> >  
> > +- i2c-bus
> > +   For I2C adapters that have child nodes that are a mixture of both I2C
> > +   devices and non-I2C devices (such as a pin controller), the 'i2c-bus'
> > +   subnode can be used for populating I2C devices to prevent the I2C core
> > +   from attempting to add any non-i2c nodes as I2C devices. If 'i2c-bus'
> > +   subnode is present then all I2C slaves must be added under this
> > +   subnode.
> 
> The general idea seems sound.
> 
> It would be good if we could remove the mention of the I2C core,
> something like:
> 
>   - i2c-bus
>   For I2C adapters that have child nodes that are a mixture of both I2C
>   devices and non-I2C devices (such as a pin controller), the 'i2c-bus'
>   subnode can be used for populating I2C devices. If an 'i2c-bus'
>   subnode is present, only subnodes of this will be considered as
>   I2C slaves.
> 
> How are #address-cells and #size-cells handled in this case? I assume
> that they should live under the i2c-bus subnode, which should be called
> out.

Good catch. Yes, I think the i2c-bus subnode would be the right place
for #address-cells and #size-cells.

Thierry
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160617/32cd8775/attachment.sig>


[RFC PATCH 11/13] arm64: tegra: Add SOR power-domain node

2016-06-17 Thread Thierry Reding
On Fri, Jun 17, 2016 at 01:03:45PM +0100, Jon Hunter wrote:
> Add node for SOR power-domain for Tegra210 and populate the SOR
> power-domain phandle for SOR and DPAUX nodes that are dependent
> on this power-domain.
> 
> Please note that although neither the SOR or DPAUX drivers currently
> support runtime power-management, by populating the power-domain node
> the SOR power-domain will be turned on before probing SOR or DPAUX
> devices and kept on while the devices are bound.
> 
> Signed-off-by: Jon Hunter 
> ---
>  arch/arm64/boot/dts/nvidia/tegra210.dtsi | 18 ++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/arch/arm64/boot/dts/nvidia/tegra210.dtsi 
> b/arch/arm64/boot/dts/nvidia/tegra210.dtsi
> index ebf44f4059f8..94f780b43037 100644
> --- a/arch/arm64/boot/dts/nvidia/tegra210.dtsi
> +++ b/arch/arm64/boot/dts/nvidia/tegra210.dtsi
> @@ -34,6 +34,7 @@
>   clock-names = "dpaux", "parent";
>   resets = <&tegra_car 207>;
>   reset-names = "dpaux";
> + power-domains = <&pd_sor>;
>   status = "disabled";
>   };
>  
> @@ -154,6 +155,7 @@
>   clock-names = "sor", "parent", "dp", "safe";
>   resets = <&tegra_car 182>;
>   reset-names = "sor";
> + power-domains = <&pd_sor>;
>   status = "disabled";
>   };
>  
> @@ -168,6 +170,7 @@
>   clock-names = "sor", "parent", "dp", "safe";
>   resets = <&tegra_car 183>;
>   reset-names = "sor";
> + power-domains = <&pd_sor>;
>   status = "disabled";
>   };
>  
> @@ -180,6 +183,7 @@
>   clock-names = "dpaux", "parent";
>   resets = <&tegra_car 181>;
>   reset-names = "dpaux";
> + power-domains = <&pd_sor>;
>   status = "disabled";
>   };
>  
> @@ -592,6 +596,20 @@
>   resets = <&tegra_car 198>;
>   #power-domain-cells = <0>;
>   };
> +
> + pd_sor: sor {
> + clocks = <&tegra_car TEGRA210_CLK_SOR0>,
> +  <&tegra_car TEGRA210_CLK_DSIA>,
> +  <&tegra_car TEGRA210_CLK_DSIB>,
> +  <&tegra_car TEGRA210_CLK_MIPI_CAL>,

Does this mean that all of these clocks will be running while the SOR
partition is enabled? Seems like a waste because we rarely need MIPI_CAL
and DSIA and DSIB are completely unused on boards that for example have
only an HDMI output.

I vaguely remember the power domain driver only making sure these are
enabled during the partition power transitions, so perhaps my concerns
aren't justified?

Thierry
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160617/39fcb041/attachment.sig>


[RFC PATCH 11/13] arm64: tegra: Add SOR power-domain node

2016-06-17 Thread Thierry Reding
On Fri, Jun 17, 2016 at 01:03:45PM +0100, Jon Hunter wrote:
> Add node for SOR power-domain for Tegra210 and populate the SOR
> power-domain phandle for SOR and DPAUX nodes that are dependent
> on this power-domain.
> 
> Please note that although neither the SOR or DPAUX drivers currently
> support runtime power-management, by populating the power-domain node
> the SOR power-domain will be turned on before probing SOR or DPAUX
> devices and kept on while the devices are bound.
> 
> Signed-off-by: Jon Hunter 
> ---
>  arch/arm64/boot/dts/nvidia/tegra210.dtsi | 18 ++
>  1 file changed, 18 insertions(+)

I've got patches queued in my drm-tegra tree to add support for runtime
PM for the SOR driver. Will that in some way clash with this work if
merged in parallel?

Thierry
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160617/a0169030/attachment.sig>


[RFC PATCH 10/13] drm/tegra: Add pinctrl support for DPAUX

2016-06-17 Thread Thierry Reding
On Fri, Jun 17, 2016 at 01:03:44PM +0100, Jon Hunter wrote:
> The DPAUX pins are shared with an internal I2C controller. To allow
> these pins to be muxed to the I2C controller, register a pinctrl device
> for the DPAUX device. Make Tegra DRM support dependent on PINCTRL to
> avoid any compilation issues.
> 
> Signed-off-by: Jon Hunter 
> ---
>  drivers/gpu/drm/tegra/Kconfig |   1 +
>  drivers/gpu/drm/tegra/dpaux.c | 117 
> --
>  2 files changed, 115 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tegra/Kconfig b/drivers/gpu/drm/tegra/Kconfig
> index 63ebb154b9b5..d34937a96f94 100644
> --- a/drivers/gpu/drm/tegra/Kconfig
> +++ b/drivers/gpu/drm/tegra/Kconfig
> @@ -4,6 +4,7 @@ config DRM_TEGRA
>   depends on COMMON_CLK
>   depends on DRM
>   depends on RESET_CONTROLLER
> + depends on PINCTRL

Could we instead make the code optional? I don't care much about pulling
in the extra dependency (for Tegra we always enable PINCTRL anyway), but
I worry that somebody may end up searching for DRM_TEGRA and not find it
because PINCTRL happens to be disabled in they .config.

> diff --git a/drivers/gpu/drm/tegra/dpaux.c b/drivers/gpu/drm/tegra/dpaux.c
[...]
> @@ -439,6 +537,19 @@ static int tegra_dpaux_probe(struct platform_device 
> *pdev)
>   if (err < 0)
>   return err;
>  
> + dpaux->desc.name = dev_name(&pdev->dev);
> + dpaux->desc.pins = tegra_dpaux_pins;
> + dpaux->desc.npins = ARRAY_SIZE(tegra_dpaux_pins);
> + dpaux->desc.pctlops = &tegra_dpaux_pinctrl_ops;
> + dpaux->desc.pmxops = &tegra_dpaux_pinmux_ops;
> + dpaux->desc.owner = THIS_MODULE;
> +
> + dpaux->pinctrl = pinctrl_register(&dpaux->desc, &pdev->dev, dpaux);
> + if (!dpaux->pinctrl) {
> + dev_err(&pdev->dev, "failed to register pincontrol\n");
> + return -ENODEV;
> + }

Did you mean to use the devm_ variant here? Because I don't see a
pinctrl_unregister() in tegra_dpaux_remove().

Thierry
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160617/9dd3f389/attachment.sig>


[PATCH V8 3/3] soc/tegra: pmc: Add support for IO pads power state and voltage

2016-06-17 Thread Laxman Dewangan
The IO pins of Tegra SoCs are grouped for common control of IO
interface like setting voltage signal levels and power state of
the interface. The group is generally referred as IO pads. The
power state and voltage control of IO pins can be done at IO pads
level.

Tegra generation SoC supports the power down of IO pads when it
is not used even in the active state of system. This saves power
from that IO interface. Also it supports multiple voltage level
in IO pins for interfacing on some of pads. The IO pad voltage is
automatically detected till T124, hence SW need not to configure
this. But from T210, the automatically detection logic has been
removed, hence SW need to explicitly set the IO pad voltage into
IO pad configuration registers.

Add support to set the power states and voltage level of the IO pads
from client driver. The implementation for the APIs are in generic
which is applicable for all generation os Tegra SoC.

IO pads ID and information of bit field for power state and voltage
level controls are added for Tegra124, Tegra132 and Tegra210. The SOR
driver is modified to use the new APIs.

Signed-off-by: Laxman Dewangan 
Tested-by: Jon Hunter 
Acked-by: Jon Hunter 

---
Changes from V1:
This is reworked on earlier path to have separation between IO rails and
io pads and add power state and voltage control APIs in single call.

Changes from V2:
- Remove the tegra_io_rail_power_off/on() apis and change client (sor) driver
to use the new APIs for IO pad power.
- Remove the TEGRA_IO_RAIL_ macros.

Changes from V3:
- Make all pad_id/io_pad_id to id.
- tegra_io_pad_ -> tegra_io_pads
- dpd_bit -> bit, pwr_mask/bit to mask/bit.
- Rename function to tegra_io_pads_{set,get}_voltage_config
- Make the io pad tables common for all SoC.
- Make io_pads enums.
- Add enums for voltage.

Changes from V4:
- IO_PAD->IO_PADS
- TEGRA_IO_PADS_POWER_SOURCE_ -> TEGRA_IO_PADS_VCONF_

Changes from V5:
- Fix comment style to multi-line format.
- Use -EINVAL instead of -1 to refactor some of function as suggested by Jon.

Changes from V6:
- Doc style formatting.
- io pads id checks.
- Documenting public functions.
- Corrected error numbers.

Changes from V7:
- Fix typo and comment style.
---
 drivers/gpu/drm/tegra/sor.c |   8 +-
 drivers/soc/tegra/pmc.c | 280 +++-
 include/soc/tegra/pmc.h | 134 +++--
 3 files changed, 351 insertions(+), 71 deletions(-)

diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c
index 34958d7..3de00b4 100644
--- a/drivers/gpu/drm/tegra/sor.c
+++ b/drivers/gpu/drm/tegra/sor.c
@@ -1133,7 +1133,7 @@ static void tegra_sor_edp_disable(struct drm_encoder 
*encoder)
dev_err(sor->dev, "failed to disable DP: %d\n", err);
}

-   err = tegra_io_rail_power_off(TEGRA_IO_RAIL_LVDS);
+   err = tegra_io_pads_power_disable(TEGRA_IO_PADS_LVDS);
if (err < 0)
dev_err(sor->dev, "failed to power off I/O rail: %d\n", err);

@@ -1295,7 +1295,7 @@ static void tegra_sor_edp_enable(struct drm_encoder 
*encoder)
tegra_sor_writel(sor, value, SOR_DP_PADCTL0);

/* step 2 */
-   err = tegra_io_rail_power_on(TEGRA_IO_RAIL_LVDS);
+   err = tegra_io_pads_power_enable(TEGRA_IO_PADS_LVDS);
if (err < 0)
dev_err(sor->dev, "failed to power on I/O rail: %d\n", err);

@@ -1747,7 +1747,7 @@ static void tegra_sor_hdmi_disable(struct drm_encoder 
*encoder)
if (err < 0)
dev_err(sor->dev, "failed to power down SOR: %d\n", err);

-   err = tegra_io_rail_power_off(TEGRA_IO_RAIL_HDMI);
+   err = tegra_io_pads_power_disable(TEGRA_IO_PADS_HDMI);
if (err < 0)
dev_err(sor->dev, "failed to power off HDMI rail: %d\n", err);

@@ -1786,7 +1786,7 @@ static void tegra_sor_hdmi_enable(struct drm_encoder 
*encoder)

div = clk_get_rate(sor->clk) / 100 * 4;

-   err = tegra_io_rail_power_on(TEGRA_IO_RAIL_HDMI);
+   err = tegra_io_pads_power_enable(TEGRA_IO_PADS_HDMI);
if (err < 0)
dev_err(sor->dev, "failed to power on HDMI rail: %d\n", err);

diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
index 288dcb7..85ee970 100644
--- a/drivers/soc/tegra/pmc.c
+++ b/drivers/soc/tegra/pmc.c
@@ -77,6 +77,10 @@

 #define PMC_SCRATCH41  0x140

+/* Power detect for pad voltage */
+#define PMC_PWR_DET0x48
+#define PMC_PWR_DET_VAL0xe4
+
 #define PMC_SENSOR_CTRL0x1b0
 #define PMC_SENSOR_CTRL_SCRATCH_WRITE  BIT(2)
 #define PMC_SENSOR_CTRL_ENABLE_RST BIT(1)
@@ -114,6 +118,15 @@

 #define GPU_RG_CNTRL   0x2d4

+/**
+ * Define the IO_PADS SOC for SOC mask to find out that IO pads supported
+ * or not in given SoC.
+ */
+#define TEGRA_IO_PADS_T124 0x1
+#define TEGRA_IO_PADS_T210 0x2
+#define TEGRA_IO_PADS_T124_T210(TEGRA_IO_PADS_T124 |   \

[PATCH V8 2/3] soc/tegra: pmc: Correct type of variable for tegra_pmc_readl()

2016-06-17 Thread Laxman Dewangan
The function tegra_pmc_readl() returns the u32 type data and hence
change the data type of variable where this data is stored to u32
type.

Signed-off-by: Laxman Dewangan 
Reviewed-by: Jon Hunter 

---
Changes from V1:
-This is new in series as per discussion on V1 series to use u32 for
tegra_pmc_readl.

Changes from V2:
- Make unsigned long to u32 for some missed variable from V1.

Changes from V3:
- Revert back the value to ulong where time calcualtion is done.

Changes from V4:
- Collected RB from Jon.

Changes from V5/V6:
- None
---
 drivers/soc/tegra/pmc.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
index 6b61ec6..288dcb7 100644
--- a/drivers/soc/tegra/pmc.c
+++ b/drivers/soc/tegra/pmc.c
@@ -885,10 +885,10 @@ static int tegra_io_rail_prepare(unsigned int id, 
unsigned long *request,
return 0;
 }

-static int tegra_io_rail_poll(unsigned long offset, unsigned long mask,
- unsigned long val, unsigned long timeout)
+static int tegra_io_rail_poll(unsigned long offset, u32 mask,
+ u32 val, unsigned long timeout)
 {
-   unsigned long value;
+   u32 value;

timeout = jiffies + msecs_to_jiffies(timeout);

@@ -910,8 +910,9 @@ static void tegra_io_rail_unprepare(void)

 int tegra_io_rail_power_on(unsigned int id)
 {
-   unsigned long request, status, value;
-   unsigned int bit, mask;
+   unsigned long request, status;
+   unsigned int bit;
+   u32 value, mask;
int err;

mutex_lock(&pmc->powergates_lock);
@@ -945,8 +946,9 @@ EXPORT_SYMBOL(tegra_io_rail_power_on);

 int tegra_io_rail_power_off(unsigned int id)
 {
-   unsigned long request, status, value;
-   unsigned int bit, mask;
+   unsigned long request, status;
+   unsigned int bit;
+   u32 value, mask;
int err;

mutex_lock(&pmc->powergates_lock);
-- 
2.1.4



[PATCH V8 1/3] soc/tegra: pmc: Use BIT macro for register field definition

2016-06-17 Thread Laxman Dewangan
Use BIT macro for register field definition and make constant as U
when using in shift operator like (3 << 30) to (3U << 30)

Signed-off-by: Laxman Dewangan 
Acked-by: Jon Hunter 

Changes from V1:
- Remove the indenting of line which is not for BIT macro usage.
Changes from V2:
- None

Changes from V3:
- None

Changes from V4:
- Collected ack from Jon.

Changes from V5/V6:
- None

Changes from V7:
- Rebase on next-20160617
---
 drivers/soc/tegra/pmc.c | 42 +-
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/drivers/soc/tegra/pmc.c b/drivers/soc/tegra/pmc.c
index d135169..6b61ec6 100644
--- a/drivers/soc/tegra/pmc.c
+++ b/drivers/soc/tegra/pmc.c
@@ -45,29 +45,29 @@
 #include 

 #define PMC_CNTRL  0x0
-#define  PMC_CNTRL_SYSCLK_POLARITY (1 << 10)  /* sys clk polarity */
-#define  PMC_CNTRL_SYSCLK_OE   (1 << 11)  /* system clock enable */
-#define  PMC_CNTRL_SIDE_EFFECT_LP0 (1 << 14)  /* LP0 when CPU pwr gated */
-#define  PMC_CNTRL_CPU_PWRREQ_POLARITY (1 << 15)  /* CPU pwr req polarity */
-#define  PMC_CNTRL_CPU_PWRREQ_OE   (1 << 16)  /* CPU pwr req enable */
-#define  PMC_CNTRL_INTR_POLARITY   (1 << 17)  /* inverts INTR polarity */
-#define  PMC_CNTRL_MAIN_RST(1 <<  4)
+#define PMC_CNTRL_SYSCLK_POLARITY  BIT(10) /* sys clk polarity */
+#define PMC_CNTRL_SYSCLK_OEBIT(11) /* system clock enable */
+#define PMC_CNTRL_SIDE_EFFECT_LP0  BIT(14) /* LP0 when CPU pwr gated */
+#define PMC_CNTRL_CPU_PWRREQ_POLARITY  BIT(15) /* CPU pwr req polarity */
+#define PMC_CNTRL_CPU_PWRREQ_OEBIT(16) /* CPU pwr req enable */
+#define PMC_CNTRL_INTR_POLARITYBIT(17)/* inverts INTR polarity 
*/
+#define  PMC_CNTRL_MAIN_RSTBIT(4)

 #define DPD_SAMPLE 0x020
-#define  DPD_SAMPLE_ENABLE (1 << 0)
-#define  DPD_SAMPLE_DISABLE(0 << 0)
+#define DPD_SAMPLE_ENABLE  BIT(0)
+#define DPD_SAMPLE_DISABLE (0 << 0)

 #define PWRGATE_TOGGLE 0x30
-#define  PWRGATE_TOGGLE_START  (1 << 8)
+#define PWRGATE_TOGGLE_START   BIT(8)

 #define REMOVE_CLAMPING0x34

 #define PWRGATE_STATUS 0x38

 #define PMC_SCRATCH0   0x50
-#define  PMC_SCRATCH0_MODE_RECOVERY(1 << 31)
-#define  PMC_SCRATCH0_MODE_BOOTLOADER  (1 << 30)
-#define  PMC_SCRATCH0_MODE_RCM (1 << 1)
+#define PMC_SCRATCH0_MODE_RECOVERY BIT(31)
+#define PMC_SCRATCH0_MODE_BOOTLOADER   BIT(30)
+#define PMC_SCRATCH0_MODE_RCM  BIT(1)
 #define  PMC_SCRATCH0_MODE_MASK(PMC_SCRATCH0_MODE_RECOVERY | \
 PMC_SCRATCH0_MODE_BOOTLOADER | \
 PMC_SCRATCH0_MODE_RCM)
@@ -78,8 +78,8 @@
 #define PMC_SCRATCH41  0x140

 #define PMC_SENSOR_CTRL0x1b0
-#define PMC_SENSOR_CTRL_SCRATCH_WRITE  (1 << 2)
-#define PMC_SENSOR_CTRL_ENABLE_RST (1 << 1)
+#define PMC_SENSOR_CTRL_SCRATCH_WRITE  BIT(2)
+#define PMC_SENSOR_CTRL_ENABLE_RST BIT(1)

 #define PMC_RST_STATUS 0x1b4
 #define  PMC_RST_STATUS_POR0
@@ -90,10 +90,10 @@
 #define  PMC_RST_STATUS_AOTAG  5

 #define IO_DPD_REQ 0x1b8
-#define  IO_DPD_REQ_CODE_IDLE  (0 << 30)
-#define  IO_DPD_REQ_CODE_OFF   (1 << 30)
-#define  IO_DPD_REQ_CODE_ON(2 << 30)
-#define  IO_DPD_REQ_CODE_MASK  (3 << 30)
+#define IO_DPD_REQ_CODE_IDLE   (0 << 30)
+#define IO_DPD_REQ_CODE_OFF(1U << 30)
+#define IO_DPD_REQ_CODE_ON (2U << 30)
+#define IO_DPD_REQ_CODE_MASK   (3U << 30)

 #define IO_DPD_STATUS  0x1bc
 #define IO_DPD2_REQ0x1c0
@@ -105,10 +105,10 @@
 #define PMC_SCRATCH54_ADDR_SHIFT   0

 #define PMC_SCRATCH55  0x25c
-#define PMC_SCRATCH55_RESET_TEGRA  (1 << 31)
+#define PMC_SCRATCH55_RESET_TEGRA  BIT(31)
 #define PMC_SCRATCH55_CNTRL_ID_SHIFT   27
 #define PMC_SCRATCH55_PINMUX_SHIFT 24
-#define PMC_SCRATCH55_16BITOP  (1 << 15)
+#define PMC_SCRATCH55_16BITOP  BIT(15)
 #define PMC_SCRATCH55_CHECKSUM_SHIFT   16
 #define PMC_SCRATCH55_I2CSLV1_SHIFT0

-- 
2.1.4



[PATCH V8 0/3] soc/tegra: Add support for IO pads power and voltage control

2016-06-17 Thread Laxman Dewangan
The IO pins of Tegra SoCs are grouped for common control of IO interface
like setting voltage signal levels and power state of the interface. The 
group is generally referred as IO pads. The power state and voltage control
of IO pins can be done at IO pads level.

Tegra124 onwards IO pads support the power down state when system is
active. The voltage levels on IO pads are auto detected on Tegra124/
Tegra132 but it is not in Tegra210. For Tegra210, the SW need to
explicitly configure the voltage levels of IO pads

This series add the interface for the IO pad power state and voltage
configurations. Modifies the client to use new APIs.
Register the child devices to provide the client interface to configure
IO pads power state and voltage from Device tree.

---
Changes from V2: 
- Drop the pinctrl driver from series till pmc interfce is finalise.
- Move client to use the new APIs.
- Remove older APIs to configure IO rail and related macros.

Changes from V3: 
- keep value  to be unsigned long in the dpd_prepare.
- Make all pad_id/io_pad_id to id.
- tegra_io_pad_ -> tegra_io_pads
- dpd_bit -> bit, pwr_mask/bit to mask/bit.
- Rename function to tegra_io_pads_{set,get}_voltage_config
- Make the io pad tables common for all SoC.
- Make io_pads enums.
- Add enums for voltage.
- Drop patch of adding sub devs

Changes from V4:
- Change IO_PAD to IO_PADS.
- Change enum for voltage config 

Changes from V5:
- Fix multiline comment.
- Use -EINVAL instead of -1 for nonsupported case and refactor APIs to
  convert io-pads to bit.

Changes from V7:
- Fix document format.
- Document public APIs.
- Fix the bit check.
- Add check of pad ID validatity.

Changes from V8:
- Fix comment style and typo.
- Rebase the series on 20160617

Laxman Dewangan (3):
  soc/tegra: pmc: Use BIT macro for register field definition
  soc/tegra: pmc: Correct type of variable for tegra_pmc_readl()
  soc/tegra: pmc: Add support for IO pads power state and voltage

 drivers/gpu/drm/tegra/sor.c |   8 +-
 drivers/soc/tegra/pmc.c | 273 +++-
 include/soc/tegra/pmc.h | 132 +++--
 3 files changed, 321 insertions(+), 92 deletions(-)

-- 
2.1.4



[RFC PATCH 09/13] dt-bindings: drm/tegra: Add DPAUX pinctrl documentation

2016-06-17 Thread Thierry Reding
On Fri, Jun 17, 2016 at 01:03:43PM +0100, Jon Hunter wrote:
> On Tegra124, Tegra132 and Tegra210 devices the pads used by the Display
> Port Auxiliary (DPAUX) channel are multiplexed such that they can also
> be used by one of the internal i2c controllers. Note that this is
> different from i2c-over-AUX supported by the DPAUX controller. The
> register that configures these pads is part of the DPAUX controllers
> register set and so a pinctrl driver is being added for the DPAUX device
> to share these pads. Add the device-tree binding documentation for the
> DPAUX pad controller.

There are a couple more "i2c" vs. "I2C" in the above. Please use the
latter consistently.

Also the subject line should be something different. drm is a linuxism
and hence shouldn't be used anywhere near DT bindings.

> Please note that although the "off" function for the DPAUX pads is not
> technically a pin-mux setting but more of a pin-conf setting it is
> simpler to expose these as a function so that the user can simply select
> either "aux", "i2c" or "off" as the current function/mode.
> 
> Update the main DPAUX binding documentation to reference the DPAUX pad
> controller binding document and add the 'i2c-bus' subnode. The 'i2c-bus'
> subnode is used for populating I2C slaves for the DPAUX device so that
> the I2C driver core does not attempt to add the DPAUX pad controller
> nodes as I2C slaves.
> 
> Signed-off-by: Jon Hunter 
> ---
>  .../display/tegra/nvidia,tegra20-host1x.txt|  4 ++
>  .../pinctrl/nvidia,tegra124-dpaux-padctl.txt   | 60 
> ++
>  2 files changed, 64 insertions(+)
>  create mode 100644 
> Documentation/devicetree/bindings/pinctrl/nvidia,tegra124-dpaux-padctl.txt
> 
> diff --git 
> a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt 
> b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt
> index 361a472eac4b..6759554b7b8f 100644
> --- 
> a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt
> +++ 
> b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt
> @@ -242,6 +242,10 @@ of the following host1x client modules:
>- reset-names: Must include the following entries:
>  - dpaux
>- vdd-supply: phandle of a supply that powers the DisplayPort link
> +  - i2c-bus: Subnode where I2C slave devices should be listed.

Should we perhaps say at this point that the subnode should always be
added, oven if empty? Otherwise we'll still run into a conflict with the
pinmux nodes.

> +
> +  See ../pinctrl/nvidia,tegra124-dpaux-padctl.txt for information
> +  regarding the DPAUX pad controller bindings.
>  
>  Example:
>  
> diff --git 
> a/Documentation/devicetree/bindings/pinctrl/nvidia,tegra124-dpaux-padctl.txt 
> b/Documentation/devicetree/bindings/pinctrl/nvidia,tegra124-dpaux-padctl.txt
> new file mode 100644
> index ..3be0ced01680
> --- /dev/null
> +++ 
> b/Documentation/devicetree/bindings/pinctrl/nvidia,tegra124-dpaux-padctl.txt
> @@ -0,0 +1,60 @@
> +Device tree binding for NVIDIA Tegra DPAUX pad controller
> +
> +
> +The Tegra Display Port Auxiliary (DPAUX) pad controller manages two pins
> +which can be assigned to either the DPAUX channel or to an I2C
> +controller.
> +
> +This document defines the device-specific binding for the DPAUX pad
> +controller. Refer to pinctrl-bindings.txt in this directory for generic
> +information about pin controller device tree bindings. Please refer to
> +the binding document ../display/tegra/nvidia,tegra20-host1x.txt for more
> +details on the DPAUX binding.
> +
> +Pin muxing:
> +---
> +
> +Child nodes contain the pinmux configurations following the conventions
> +from the pinctrl-bindings.txt document.
> +
> +Since only three configurations are possible, only three child nodes are
> +needed to describe the pin mux'ing options for the DPAUX pads.
> +Furthermore, given that the pad functions are only applicable to a
> +single set of pads, the child nodes do not need to describe the pads the
> +functions are being applied to.
> +
> +Required properties:
> +- groups: Must be "dpaux-io"

Above you say that we don't need to describe the pads, but then the
groups property does describe the pads. Why?

Thierry
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160617/9e66dfed/attachment.sig>


[PATCH -next] drm/hisilicon: Fix return value check in ade_dts_parse()

2016-06-17 Thread weiyj...@163.com
From: Wei Yongjun 

In case of error, the function devm_clk_get() returns ERR_PTR()
and never returns NULL. The NULL test in the return value check
should be replaced with IS_ERR().

Signed-off-by: Wei Yongjun 
---
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c 
b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
index ed76baad..16834f4 100644
--- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
+++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
@@ -965,21 +965,21 @@ static int ade_dts_parse(struct platform_device *pdev, 
struct ade_hw_ctx *ctx)
}

ctx->ade_core_clk = devm_clk_get(dev, "clk_ade_core");
-   if (!ctx->ade_core_clk) {
+   if (IS_ERR(ctx->ade_core_clk)) {
DRM_ERROR("failed to parse clk ADE_CORE\n");
-   return -ENODEV;
+   return PTR_ERR(ctx->ade_core_clk);
}

ctx->media_noc_clk = devm_clk_get(dev, "clk_codec_jpeg");
-   if (!ctx->media_noc_clk) {
+   if (IS_ERR(ctx->media_noc_clk)) {
DRM_ERROR("failed to parse clk CODEC_JPEG\n");
-   return -ENODEV;
+   return PTR_ERR(ctx->media_noc_clk);
}

ctx->ade_pix_clk = devm_clk_get(dev, "clk_ade_pix");
-   if (!ctx->ade_pix_clk) {
+   if (IS_ERR(ctx->ade_pix_clk)) {
DRM_ERROR("failed to parse clk ADE_PIX\n");
-   return -ENODEV;
+   return PTR_ERR(ctx->ade_pix_clk);
}

return 0;







[RFC PATCH 08/13] i2c: core: Add support for 'i2c-bus' subnode

2016-06-17 Thread Thierry Reding
On Fri, Jun 17, 2016 at 01:03:42PM +0100, Jon Hunter wrote:
> If the 'i2c-bus' device-tree node is present for an I2C adapter then
> parse this subnode for I2C slaves.
> 
> Signed-off-by: Jon Hunter 
> ---
>  drivers/i2c/i2c-core.c | 11 +--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
> index 952d2f0c02c5..f552d97bad32 100644
> --- a/drivers/i2c/i2c-core.c
> +++ b/drivers/i2c/i2c-core.c
> @@ -1452,7 +1452,7 @@ static struct i2c_client *of_i2c_register_device(struct 
> i2c_adapter *adap,
>  
>  static void of_i2c_register_devices(struct i2c_adapter *adap)
>  {
> - struct device_node *node;
> + struct device_node *bus, *node;
>  
>   /* Only register child devices if the adapter has a node pointer set */
>   if (!adap->dev.of_node)
> @@ -1460,11 +1460,18 @@ static void of_i2c_register_devices(struct 
> i2c_adapter *adap)
>  
>   dev_dbg(&adap->dev, "of_i2c: walking child nodes\n");
>  
> - for_each_available_child_of_node(adap->dev.of_node, node) {
> + bus = of_get_child_by_name(adap->dev.of_node, "i2c-bus");
> + if (!bus)
> + bus = adap->dev.of_node;

Maybe
bus = of_node_get(adap->dev.of_node);

here...

> +
> + for_each_available_child_of_node(bus, node) {
>   if (of_node_test_and_set_flag(node, OF_POPULATED))
>   continue;
>   of_i2c_register_device(adap, node);
>   }
> +
> + if (bus != adap->dev.of_node)
> + of_node_put(bus);

... and drop the extra check here?

Thierry
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160617/6cd78bd9/attachment.sig>


[RFC PATCH 07/13] dt-bindings: i2c: Add support for 'i2c-bus' subnode

2016-06-17 Thread Thierry Reding
On Fri, Jun 17, 2016 at 01:03:41PM +0100, Jon Hunter wrote:
> The I2C driver core for boards using device-tree assumes any subnode of
> an I2C adapter in the device-tree blob as being a I2C slave device.
> Although this makes complete sense, some I2C adapters may have subnodes
> which are not I2C slaves but subnodes presenting other features. For
> example some Tegra devices have an I2C interface which may share its
> pins with other devices and to share these pins subnodes for
> representing these pins so they have be shared via the pinctrl framework
> are needed.
> 
> To allow I2C adapters to have non-I2C specific subnodes in device-tree
> that are not parsed by the I2C driver core by adding support for a
> 'i2c-bus' subnode where I2C slaves can be placed. If the 'i2c-bus'
> subnode is present then all I2C slaves must be placed under this subnode.
> 
> Signed-off-by: Jon Hunter 
> ---
>  Documentation/devicetree/bindings/i2c/i2c.txt | 8 
>  1 file changed, 8 insertions(+)

I think this makes a lot of sense, so:

Acked-by: Thierry Reding 

One minor inconsistency below...

> diff --git a/Documentation/devicetree/bindings/i2c/i2c.txt 
> b/Documentation/devicetree/bindings/i2c/i2c.txt
> index f31b2ad1552b..ed56b08c7e6e 100644
> --- a/Documentation/devicetree/bindings/i2c/i2c.txt
> +++ b/Documentation/devicetree/bindings/i2c/i2c.txt
> @@ -32,6 +32,14 @@ wants to support one of the below features, it should 
> adapt the bindings below.
>  - clock-frequency
>   frequency of bus clock in Hz.
>  
> +- i2c-bus
> + For I2C adapters that have child nodes that are a mixture of both I2C
> + devices and non-I2C devices (such as a pin controller), the 'i2c-bus'
> + subnode can be used for populating I2C devices to prevent the I2C core
> + from attempting to add any non-i2c nodes as I2C devices. If 'i2c-bus'

"non-I2C"

Thierry
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160617/23938e39/attachment.sig>


[RFC PATCH 04/13] drm/tegra: Add sor-safe clock for DPAUX on Tegra210

2016-06-17 Thread Thierry Reding
On Fri, Jun 17, 2016 at 01:03:38PM +0100, Jon Hunter wrote:
> For Tegra210 the 'sor-safe' clock needs to be enabled when using DPAUX.
> Add support to the DPAUX driver for enabling this clock on Tegra210.
> 
> Signed-off-by: Jon Hunter 
> ---
>  drivers/gpu/drm/tegra/dpaux.c | 29 +++--
>  1 file changed, 27 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tegra/dpaux.c b/drivers/gpu/drm/tegra/dpaux.c
> index aa3a037fcd3b..d696a7e45935 100644
> --- a/drivers/gpu/drm/tegra/dpaux.c
> +++ b/drivers/gpu/drm/tegra/dpaux.c
> @@ -37,6 +37,7 @@ struct tegra_dpaux {
>  
>   struct reset_control *rst;
>   struct clk *clk_parent;
> + struct clk *clk_sor;

Can we call this "clk_safe", please? On one hand that mirrors the name
of the clock in the binding and on the other hand it avoids confusion
with the real SOR clock.

>   struct clk *clk;
>  
>   struct regulator *vdd;
> @@ -340,18 +341,37 @@ static int tegra_dpaux_probe(struct platform_device 
> *pdev)
>   return PTR_ERR(dpaux->rst);
>   }
>  
> + if (of_device_is_compatible(pdev->dev.of_node,
> + "nvidia,tegra210-dpaux")) {
> + dpaux->clk_sor = devm_clk_get(&pdev->dev, "sor-safe");
> + if (IS_ERR(dpaux->clk_sor)) {
> + dev_err(&pdev->dev,
> + "failed to get sor-safe clock: %ld\n",
> + PTR_ERR(dpaux->clk_sor));
> + return PTR_ERR(dpaux->clk_sor);
> + }
> +
> + err = clk_prepare_enable(dpaux->clk_sor);
> + if (err < 0) {
> + dev_err(&pdev->dev,
> + "failed to enable sor-safe clock: %d\n", err);
> + return err;
> + }
> + }

Please make this part of a struct tegra_dpaux_soc, so that we don't have
to check the compatible string again here. This could look like:

struct tegra_dpaux_soc {
bool needs_safe_clock;
};

static const struct tegra_dpaux_soc tegra124_dpaux_soc = {
.needs_safe_clock = false,
};

static const struct tegra_dpaux_soc tegra210_dpaux_soc = {
.needs_safe_clock = true,
};

...

static const struct of_device_id tegra_dpaux_of_match[] = {
{ .compatible = "nvidia,tegra210-dpaux", .data = 
&tegra210_dpaux_soc },
{ .compatible = "nvidia,tegra124-dpaux", .data = 
&tegra124_dpaux_soc },
{ },
};

> @@ -434,6 +454,9 @@ disable_parent_clk:
>  assert_reset:
>   reset_control_assert(dpaux->rst);
>   clk_disable_unprepare(dpaux->clk);
> +disable_sor_clk:
> + if (dpaux->clk_sor)
> + clk_disable_unprepare(dpaux->clk_sor);

You can drop the extra check here, since the common clock framework
ignores NULL or ERR_PTR() pointers.

>  
>   return err;
>  }
> @@ -456,6 +479,8 @@ static int tegra_dpaux_remove(struct platform_device 
> *pdev)
>   clk_disable_unprepare(dpaux->clk_parent);
>   reset_control_assert(dpaux->rst);
>   clk_disable_unprepare(dpaux->clk);
> +     if (dpaux->clk_sor)
> + clk_disable_unprepare(dpaux->clk_sor);

Same here.

Thierry
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160617/dda9d770/attachment.sig>


[RFC PATCH 03/13] dt-bindings: drm/tegra: Update DPAUX documentation

2016-06-17 Thread Thierry Reding
On Fri, Jun 17, 2016 at 01:03:37PM +0100, Jon Hunter wrote:
> Update the DPAUX compatibility string information for Tegra124, Tegra132
> and Tegra210. For Tegra210 an additional clock, 'sor-safe' is also
> required for DPAUX and so add this clock information as well.
> 
> Signed-off-by: Jon Hunter 
> ---
>  .../devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt| 7 
> ---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git 
> a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt 
> b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt
> index a3bd8c050c4e..361a472eac4b 100644
> --- 
> a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt
> +++ 
> b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt
> @@ -226,9 +226,9 @@ of the following host1x client modules:
>- nvidia,dpaux: phandle to a DispayPort AUX interface
>  
>  - dpaux: DisplayPort AUX interface
> -  - compatible: For Tegra124, must contain "nvidia,tegra124-dpaux".  
> Otherwise,
> -must contain '"nvidia,-dpaux", "nvidia,tegra124-dpaux"', where
> - is tegra132.
> +  - compatible : Should contain one of the following:
> +- "nvidia,tegra124-dpaux": for Tegra124 and Tegra132
> +- "nvidia,tegra210-dpaux": for Tegra210
>- reg: Physical base address and length of the controller's registers.
>- interrupts: The interrupt outputs from the controller.
>- clocks: Must contain an entry for each entry in clock-names.
> @@ -236,6 +236,7 @@ of the following host1x client modules:
>- clock-names: Must include the following entries:
>  - dpaux: clock input for the DPAUX hardware
>  - parent: reference clock
> +- sor-safe: additional clock input for the DPAUX hardware on Tegra210

It might be worth calling this simply "safe" because that's the
contextual role of the clock, whereas sor-safe is the system name of the
clock.

Thierry
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160617/0007ce84/attachment-0001.sig>


[RFC PATCH 02/13] drm/tegra: Add helper functions for setting up DPAUX pads

2016-06-17 Thread Thierry Reding
On Fri, Jun 17, 2016 at 01:03:36PM +0100, Jon Hunter wrote:
> In preparation for adding pinctrl support for the DPAUX pads, add
> helpers functions for configuring the pads and controlling the power
> for the pads.
> 
> Please note that although a simple if-statement could be used instead
> of a case statement for configuring the pads as there are only two
> possible modes, a case statement is used because when integrating with
> the pinctrl framework, we need to be able to handle invalid modes that
> could be passed.
> 
> Signed-off-by: Jon Hunter 
> ---
>  drivers/gpu/drm/tegra/dpaux.c | 75 
> ++-
>  1 file changed, 45 insertions(+), 30 deletions(-)
> 
> diff --git a/drivers/gpu/drm/tegra/dpaux.c b/drivers/gpu/drm/tegra/dpaux.c
> index 0874a7e5b37b..aa3a037fcd3b 100644
> --- a/drivers/gpu/drm/tegra/dpaux.c
> +++ b/drivers/gpu/drm/tegra/dpaux.c
> @@ -267,6 +267,45 @@ static irqreturn_t tegra_dpaux_irq(int irq, void *data)
>   return ret;
>  }
>  
> +static void tegra_dpaux_powerdown(struct tegra_dpaux *dpaux, bool enable)
> +{
> + u32 value = tegra_dpaux_readl(dpaux, DPAUX_HYBRID_SPARE);
> +
> + if (enable)
> + value |= DPAUX_HYBRID_SPARE_PAD_POWER_DOWN;
> + else
> + value &= ~DPAUX_HYBRID_SPARE_PAD_POWER_DOWN;
> +
> + tegra_dpaux_writel(dpaux, value, DPAUX_HYBRID_SPARE);
> +}

I'd like for this to be two functions without the boolean parameter. The
reason is that without looking at the implementation there's no way to
understand what the meaning of true and false is. If instead you call
this:

static void tegra_dpaux_pad_power_down(struct tegra_dpaux *dpaux)
{
...
}

and

static void tegra_dpaux_pad_power_up(struct tegra_dpaux *dpaux)
{
...
}

you can easily deduce from the name what's going on.

> +static int tegra_dpaux_config(struct tegra_dpaux *dpaux, int function)

Can function not be unsigned?

Thierry
-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160617/64d2c065/attachment.sig>


[PATCH 0/3] Fixes for HPD

2016-06-17 Thread Lyude
Forgot to mention, Ville: if you could get me an example of how to get
vlv into an infinite loop with these patches I'd appreciate that. I
haven't been able to reproduce this at all with the Valleyview machine
I've got here.

On Fri, 2016-06-17 at 17:58 -0400, Lyude wrote:
> These are a couple of patches intended to fix one of the big problems
> we have
> with a lot of chipsets on i915 right now: in the various forms of
> suspend we
> use in the driver, many of them break HPD while active and can lead
> to some
> seriously confusing situations where they can't get their monitors to
> turn on.
> 
> The patches here for fixing Valleyview need to be used with Ville
> Syrjälä's
> patchset for (partially?) preventing valleyview from getting in an
> infinite hpd
> detect loop when doing polling:
> 
> https://patchwork.freedesktop.org/series/5884/
> 
> It should also be noted some of these are resends, since the original
> patches
> never got picked up by patchwork
> 
> Lyude (3):
>   drm/i915/vlv: Make intel_crt_reset() per-encoder
>   drm/i915/vlv: Reset the ADPA in vlv_display_power_well_init()
>   drm/i915: Enable polling when we don't have hpd
> 
> Cc: stable at vger.kernel.org
> Cc: Ville Syrjälä 
> Cc: Daniel Vetter 
> 
>  drivers/gpu/drm/i915/i915_drv.c         |  7 +++-
>  drivers/gpu/drm/i915/i915_drv.h         |  3 ++
>  drivers/gpu/drm/i915/intel_crt.c        | 10 ++---
>  drivers/gpu/drm/i915/intel_drv.h        |  4 +-
>  drivers/gpu/drm/i915/intel_hotplug.c    | 69
> -
>  drivers/gpu/drm/i915/intel_runtime_pm.c | 10 +
>  6 files changed, 86 insertions(+), 17 deletions(-)
> 
-- 
Cheers,
Lyude



[PATCH 3/3] drm/i915: Enable polling when we don't have hpd

2016-06-17 Thread Lyude
Unfortunately, there's two situations where we lose hpd right now:
- Runtime suspend
- When we've shut off all of the power wells on Valleyview/Cherryview

While it would be nice if this didn't cause issues, this has the
ability to get us in some awkward states where a user won't be able to
get their display to turn on. For instance; if we boot a Valleyview
system without any monitors connected, it won't need any of it's power
wells and thus shut them off. Since this causes us to lose HPD, this
means that unless the user knows how to ssh into their machine and do a
manual reprobe for monitors, none of the monitors they connect after
booting will actually work.

Eventually we should come up with a better fix then having to enable
polling for this, since this makes rpm a lot less useful, but for now
the infrastructure in i915 just isn't there yet to get hpd in these
situations.

Cc: stable at vger.kernel.org
Cc: Ville Syrjälä 
Cc: Daniel Vetter 
Signed-off-by: Lyude 
---
 drivers/gpu/drm/i915/i915_drv.c |  7 +++-
 drivers/gpu/drm/i915/i915_drv.h |  3 ++
 drivers/gpu/drm/i915/intel_drv.h|  2 +
 drivers/gpu/drm/i915/intel_hotplug.c| 69 -
 drivers/gpu/drm/i915/intel_runtime_pm.c |  3 ++
 5 files changed, 73 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index f313b4d..a593889 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -1574,6 +1574,9 @@ static int intel_runtime_suspend(struct device *device)

assert_forcewakes_inactive(dev_priv);

+   if (!IS_VALLEYVIEW(dev_priv) || !IS_CHERRYVIEW(dev_priv))
+   intel_hpd_poll_enable(dev_priv, true);
+
DRM_DEBUG_KMS("Device suspended\n");
return 0;
 }
@@ -1629,8 +1632,10 @@ static int intel_runtime_resume(struct device *device)
 * power well, so hpd is reinitialized from there. For
 * everyone else do it here.
 */
-   if (!IS_VALLEYVIEW(dev_priv) && !IS_CHERRYVIEW(dev_priv))
+   if (!IS_VALLEYVIEW(dev_priv) && !IS_CHERRYVIEW(dev_priv)) {
intel_hpd_init(dev_priv);
+   intel_hpd_poll_enable(dev_priv, false);
+   }

intel_enable_gt_powersave(dev);

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 7c334e9..3062d55 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -281,6 +281,9 @@ struct i915_hotplug {
u32 short_port_mask;
struct work_struct dig_port_work;

+   struct work_struct poll_enable_work;
+   bool poll_enabled;
+
/*
 * if we get a HPD irq from DP and a HPD irq from non-DP
 * the non-DP HPD could block the workqueue on a mode config
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index fdec45d..80cd626 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1348,6 +1348,8 @@ void intel_dsi_init(struct drm_device *dev);

 /* intel_dvo.c */
 void intel_dvo_init(struct drm_device *dev);
+/* intel_hotplug.c */
+void intel_hpd_poll_enable(struct drm_i915_private *dev_priv, bool enabled);


 /* legacy fbdev emulation in intel_fbdev.c */
diff --git a/drivers/gpu/drm/i915/intel_hotplug.c 
b/drivers/gpu/drm/i915/intel_hotplug.c
index bee6730..0fc2fe0 100644
--- a/drivers/gpu/drm/i915/intel_hotplug.c
+++ b/drivers/gpu/drm/i915/intel_hotplug.c
@@ -465,20 +465,25 @@ void intel_hpd_init(struct drm_i915_private *dev_priv)
dev_priv->hotplug.stats[i].count = 0;
dev_priv->hotplug.stats[i].state = HPD_ENABLED;
}
-   list_for_each_entry(connector, &mode_config->connector_list, head) {
-   struct intel_connector *intel_connector = 
to_intel_connector(connector);
-   connector->polled = intel_connector->polled;
+   if (!mode_config->poll_running) {
+   list_for_each_entry(connector, &mode_config->connector_list, 
head) {
+   struct intel_connector *intel_connector =
+   to_intel_connector(connector);
+   connector->polled = intel_connector->polled;

-   /* MST has a dynamic intel_connector->encoder and it's reprobing
-* is all handled by the MST helpers. */
-   if (intel_connector->mst_port)
-   continue;
+   /* MST has a dynamic intel_connector->encoder and it's
+* reprobing is all handled by the MST helpers. */
+   if (intel_connector->mst_port)
+   continue;

-   if (!connector->polled && I915_HAS_HOTPLUG(dev) &&
-   intel_connector->encoder->hpd_pin > HPD_NONE)
-   connector->polled = DRM_CONNECTOR_POLL_HPD;
+   if (!connector->polled && I915_HAS_HOTPLUG(dev) &&
+ 

[PATCH RESEND 2/3] drm/i915/vlv: Reset the ADPA in vlv_display_power_well_init()

2016-06-17 Thread Lyude
While VGA hotplugging worked(ish) before, it looks like that was mainly
because we'd unintentionally enable it in
valleyview_crt_detect_hotplug() when we did a force trigger. This
doesn't work reliably enough because whenever the display powerwell on
vlv gets disabled, the values set in VLV_ADPA get cleared and
consequently VGA hotplugging gets disabled. This causes bugs such as one
we found on an Intel NUC, where doing the following sequence of
hotplugs:

  - Disconnect all monitors
  - Connect VGA
  - Disconnect VGA
  - Connect HDMI

Would result in VGA hotplugging becoming disabled, due to the powerwells
getting toggled in the process of connecting HDMI.

Changes since v3:
 - Expose intel_crt_reset() through intel_drv.h and call that in
   vlv_display_power_well_init() instead of
   encoder->base.funcs->reset(&encoder->base);

Changes since v2:
 - Use intel_encoder structs instead of drm_encoder structs

Changes since v1:
 - Instead of handling the register writes ourself, we just reuse
   intel_crt_detect()
 - Instead of resetting the ADPA during display IRQ installation, we now
   reset them in vlv_display_power_well_init()

Cc: stable at vger.kernel.org
Cc: Ville Syrjälä 
Cc: Daniel Vetter 
Signed-off-by: Lyude 
Reviewed-by: Ville Syrjälä 
---
 drivers/gpu/drm/i915/intel_crt.c| 2 +-
 drivers/gpu/drm/i915/intel_drv.h| 2 +-
 drivers/gpu/drm/i915/intel_runtime_pm.c | 7 +++
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c
index e4dc33e..d0fb961 100644
--- a/drivers/gpu/drm/i915/intel_crt.c
+++ b/drivers/gpu/drm/i915/intel_crt.c
@@ -713,7 +713,7 @@ static int intel_crt_set_property(struct drm_connector 
*connector,
return 0;
 }

-static void intel_crt_reset(struct drm_encoder *encoder)
+void intel_crt_reset(struct drm_encoder *encoder)
 {
struct drm_device *dev = encoder->dev;
struct drm_i915_private *dev_priv = dev->dev_private;
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 4a24b00..fdec45d 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1054,7 +1054,7 @@ void gen8_irq_power_well_pre_disable(struct 
drm_i915_private *dev_priv,

 /* intel_crt.c */
 void intel_crt_init(struct drm_device *dev);
-
+void intel_crt_reset(struct drm_encoder *encoder);

 /* intel_ddi.c */
 void intel_ddi_clk_select(struct intel_encoder *encoder,
diff --git a/drivers/gpu/drm/i915/intel_runtime_pm.c 
b/drivers/gpu/drm/i915/intel_runtime_pm.c
index 7fb1da4..4a3fd3a 100644
--- a/drivers/gpu/drm/i915/intel_runtime_pm.c
+++ b/drivers/gpu/drm/i915/intel_runtime_pm.c
@@ -952,6 +952,7 @@ static void vlv_init_display_clock_gating(struct 
drm_i915_private *dev_priv)

 static void vlv_display_power_well_init(struct drm_i915_private *dev_priv)
 {
+   struct intel_encoder *encoder;
enum pipe pipe;

/*
@@ -987,6 +988,12 @@ static void vlv_display_power_well_init(struct 
drm_i915_private *dev_priv)

intel_hpd_init(dev_priv);

+   /* Re-enable the ADPA, if we have one */
+   for_each_intel_encoder(dev_priv->dev, encoder) {
+   if (encoder->type == INTEL_OUTPUT_ANALOG)
+   intel_crt_reset(&encoder->base);
+   }
+
i915_redisable_vga_power_on(dev_priv->dev);
 }

-- 
2.5.5



[PATCH RESEND 1/3] drm/i915/vlv: Make intel_crt_reset() per-encoder

2016-06-17 Thread Lyude
This lets call intel_crt_reset() in contexts where IRQs are disabled and
as such, can't hold the locks required to work with the connectors.

Cc: stable at vger.kernel.org
Cc: Ville Syrjälä 
Cc: Daniel Vetter 
Signed-off-by: Lyude 
---
 drivers/gpu/drm/i915/intel_crt.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c
index 3fbb6fc..e4dc33e 100644
--- a/drivers/gpu/drm/i915/intel_crt.c
+++ b/drivers/gpu/drm/i915/intel_crt.c
@@ -713,11 +713,11 @@ static int intel_crt_set_property(struct drm_connector 
*connector,
return 0;
 }

-static void intel_crt_reset(struct drm_connector *connector)
+static void intel_crt_reset(struct drm_encoder *encoder)
 {
-   struct drm_device *dev = connector->dev;
+   struct drm_device *dev = encoder->dev;
struct drm_i915_private *dev_priv = dev->dev_private;
-   struct intel_crt *crt = intel_attached_crt(connector);
+   struct intel_crt *crt = intel_encoder_to_crt(to_intel_encoder(encoder));

if (INTEL_INFO(dev)->gen >= 5) {
u32 adpa;
@@ -739,7 +739,6 @@ static void intel_crt_reset(struct drm_connector *connector)
  */

 static const struct drm_connector_funcs intel_crt_connector_funcs = {
-   .reset = intel_crt_reset,
.dpms = drm_atomic_helper_connector_dpms,
.detect = intel_crt_detect,
.fill_modes = drm_helper_probe_single_connector_modes,
@@ -757,6 +756,7 @@ static const struct drm_connector_helper_funcs 
intel_crt_connector_helper_funcs
 };

 static const struct drm_encoder_funcs intel_crt_enc_funcs = {
+   .reset = intel_crt_reset,
.destroy = intel_encoder_destroy,
 };

@@ -902,5 +902,5 @@ void intel_crt_init(struct drm_device *dev)
dev_priv->fdi_rx_config = I915_READ(FDI_RX_CTL(PIPE_A)) & 
fdi_config;
}

-   intel_crt_reset(connector);
+   intel_crt_reset(&crt->base.base);
 }
-- 
2.5.5



[PATCH 0/3] Fixes for HPD

2016-06-17 Thread Lyude
These are a couple of patches intended to fix one of the big problems we have
with a lot of chipsets on i915 right now: in the various forms of suspend we
use in the driver, many of them break HPD while active and can lead to some
seriously confusing situations where they can't get their monitors to turn on.

The patches here for fixing Valleyview need to be used with Ville Syrjälä's
patchset for (partially?) preventing valleyview from getting in an infinite hpd
detect loop when doing polling:

https://patchwork.freedesktop.org/series/5884/

It should also be noted some of these are resends, since the original patches
never got picked up by patchwork

Lyude (3):
  drm/i915/vlv: Make intel_crt_reset() per-encoder
  drm/i915/vlv: Reset the ADPA in vlv_display_power_well_init()
  drm/i915: Enable polling when we don't have hpd

Cc: stable at vger.kernel.org
Cc: Ville Syrjälä 
Cc: Daniel Vetter 

 drivers/gpu/drm/i915/i915_drv.c |  7 +++-
 drivers/gpu/drm/i915/i915_drv.h |  3 ++
 drivers/gpu/drm/i915/intel_crt.c| 10 ++---
 drivers/gpu/drm/i915/intel_drv.h|  4 +-
 drivers/gpu/drm/i915/intel_hotplug.c| 69 -
 drivers/gpu/drm/i915/intel_runtime_pm.c | 10 +
 6 files changed, 86 insertions(+), 17 deletions(-)

-- 
2.5.5



[RFC PATCH 07/13] dt-bindings: i2c: Add support for 'i2c-bus' subnode

2016-06-17 Thread Mark Rutland
On Fri, Jun 17, 2016 at 01:03:41PM +0100, Jon Hunter wrote:
> The I2C driver core for boards using device-tree assumes any subnode of
> an I2C adapter in the device-tree blob as being a I2C slave device.
> Although this makes complete sense, some I2C adapters may have subnodes
> which are not I2C slaves but subnodes presenting other features. For
> example some Tegra devices have an I2C interface which may share its
> pins with other devices and to share these pins subnodes for
> representing these pins so they have be shared via the pinctrl framework
> are needed.
> 
> To allow I2C adapters to have non-I2C specific subnodes in device-tree
> that are not parsed by the I2C driver core by adding support for a
> 'i2c-bus' subnode where I2C slaves can be placed. If the 'i2c-bus'
> subnode is present then all I2C slaves must be placed under this subnode.
> 
> Signed-off-by: Jon Hunter 
> ---
>  Documentation/devicetree/bindings/i2c/i2c.txt | 8 
>  1 file changed, 8 insertions(+)
> 
> diff --git a/Documentation/devicetree/bindings/i2c/i2c.txt 
> b/Documentation/devicetree/bindings/i2c/i2c.txt
> index f31b2ad1552b..ed56b08c7e6e 100644
> --- a/Documentation/devicetree/bindings/i2c/i2c.txt
> +++ b/Documentation/devicetree/bindings/i2c/i2c.txt
> @@ -32,6 +32,14 @@ wants to support one of the below features, it should 
> adapt the bindings below.
>  - clock-frequency
>   frequency of bus clock in Hz.
>  
> +- i2c-bus
> + For I2C adapters that have child nodes that are a mixture of both I2C
> + devices and non-I2C devices (such as a pin controller), the 'i2c-bus'
> + subnode can be used for populating I2C devices to prevent the I2C core
> + from attempting to add any non-i2c nodes as I2C devices. If 'i2c-bus'
> + subnode is present then all I2C slaves must be added under this
> + subnode.

The general idea seems sound.

It would be good if we could remove the mention of the I2C core,
something like:

  - i2c-bus
For I2C adapters that have child nodes that are a mixture of both I2C
devices and non-I2C devices (such as a pin controller), the 'i2c-bus'
subnode can be used for populating I2C devices. If an 'i2c-bus'
subnode is present, only subnodes of this will be considered as
I2C slaves.

How are #address-cells and #size-cells handled in this case? I assume
that they should live under the i2c-bus subnode, which should be called
out.

Thanks,
Mark.


[PATCH v2] drm: Deal with rotation in drm_plane_helper_check_update()

2016-06-17 Thread ville.syrj...@linux.intel.com
From: Ville Syrjälä 

drm_plane_helper_check_update() needs to account for the plane rotation
for correct clipping/scaling calculations. Do so.

There was an earlier attempt [1] to add this into
intel_check_primary_plane() but I requested that it'd be put into the
helper instead. An updated patch never materialized AFAICS, so I went
ahead and cooked one up myself.

v2: Deal with new drm_plane_helper_check_update() callers

[1] https://patchwork.freedesktop.org/patch/65177/
Cc: Nabendu Maiti 
Cc: Noralf Trønnes 
Cc: CK Hu 
Cc: Mark Yao 
Cc: Russell King 
Signed-off-by: Ville Syrjälä 
Reviewed-by: Patrik Jakobsson 
---
 drivers/gpu/drm/armada/armada_overlay.c |  1 +
 drivers/gpu/drm/drm_plane_helper.c  | 28 ++--
 drivers/gpu/drm/drm_simple_kms_helper.c |  1 +
 drivers/gpu/drm/i915/intel_display.c|  2 ++
 drivers/gpu/drm/mediatek/mtk_drm_plane.c|  1 +
 drivers/gpu/drm/rockchip/rockchip_drm_vop.c |  1 +
 include/drm/drm_plane_helper.h  |  1 +
 7 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/armada/armada_overlay.c 
b/drivers/gpu/drm/armada/armada_overlay.c
index 148e8a42b2c6..1ee707ef6b8d 100644
--- a/drivers/gpu/drm/armada/armada_overlay.c
+++ b/drivers/gpu/drm/armada/armada_overlay.c
@@ -121,6 +121,7 @@ armada_ovl_plane_update(struct drm_plane *plane, struct 
drm_crtc *crtc,
int ret;

ret = drm_plane_helper_check_update(plane, crtc, fb, &src, &dest, &clip,
+   BIT(DRM_ROTATE_0),
0, INT_MAX, true, false, &visible);
if (ret)
return ret;
diff --git a/drivers/gpu/drm/drm_plane_helper.c 
b/drivers/gpu/drm/drm_plane_helper.c
index fc51306fe365..16c4a7bd7465 100644
--- a/drivers/gpu/drm/drm_plane_helper.c
+++ b/drivers/gpu/drm/drm_plane_helper.c
@@ -115,6 +115,7 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc,
  * @src: source coordinates in 16.16 fixed point
  * @dest: integer destination coordinates
  * @clip: integer clipping coordinates
+ * @rotation: plane rotation
  * @min_scale: minimum @src:@dest scaling factor in 16.16 fixed point
  * @max_scale: maximum @src:@dest scaling factor in 16.16 fixed point
  * @can_position: is it legal to position the plane such that it
@@ -134,16 +135,17 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc,
  * Zero if update appears valid, error code on failure
  */
 int drm_plane_helper_check_update(struct drm_plane *plane,
-   struct drm_crtc *crtc,
-   struct drm_framebuffer *fb,
-   struct drm_rect *src,
-   struct drm_rect *dest,
-   const struct drm_rect *clip,
-   int min_scale,
-   int max_scale,
-   bool can_position,
-   bool can_update_disabled,
-   bool *visible)
+ struct drm_crtc *crtc,
+ struct drm_framebuffer *fb,
+ struct drm_rect *src,
+ struct drm_rect *dest,
+ const struct drm_rect *clip,
+ unsigned int rotation,
+ int min_scale,
+ int max_scale,
+ bool can_position,
+ bool can_update_disabled,
+ bool *visible)
 {
int hscale, vscale;

@@ -163,6 +165,8 @@ int drm_plane_helper_check_update(struct drm_plane *plane,
return -EINVAL;
}

+   drm_rect_rotate(src, fb->width << 16, fb->height << 16, rotation);
+
/* Check scaling */
hscale = drm_rect_calc_hscale(src, dest, min_scale, max_scale);
vscale = drm_rect_calc_vscale(src, dest, min_scale, max_scale);
@@ -174,6 +178,9 @@ int drm_plane_helper_check_update(struct drm_plane *plane,
}

*visible = drm_rect_clip_scaled(src, dest, clip, hscale, vscale);
+
+   drm_rect_rotate_inv(src, fb->width << 16, fb->height << 16, rotation);
+
if (!*visible)
/*
 * Plane isn't visible; some drivers can handle this
@@ -267,6 +274,7 @@ int drm_primary_helper_update(struct drm_plane *plane, 
struct drm_crtc *crtc,

ret = drm_plane_helper_check_update(plane, crtc, fb,
&src, &dest, &clip,
+   BIT(DRM_ROTATE_0),
DRM_PLANE_HELPER_NO_SCALING,
DRM_PLANE_HELPER_NO_SCALING,
false, false, &visible);
diff --

RS780 UVD cause hpet_readl() very slow

2016-06-17 Thread Huacai Chen
Hi, Christian

We found that if we use RS780 UVD decoding, hpet_readl() will need as
long as 1ms.
But, if attach a U-disk on south bridge (SB700) and read some data
from it, hpet_readl() has no problem.
Could you please give me some suggestions or fix it?

How to reproduce:
1, apply the patch on top of kernel (4.2+) and boot with this kernel

diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
index 307a498..a0c8634 100644
--- a/arch/x86/kernel/apic/apic.c
+++ b/arch/x86/kernel/apic/apic.c
@@ -452,10 +452,12 @@ EXPORT_SYMBOL_GPL(setup_APIC_eilvt);
 /*
  * Program the next event, relative to now
  */
+void check_hpet(void);
 static int lapic_next_event(unsigned long delta,
struct clock_event_device *evt)
 {
apic_write(APIC_TMICT, delta);
+   check_hpet();
return 0;
 }

diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c
index 3acbff4..19329e8 100644
--- a/arch/x86/kernel/hpet.c
+++ b/arch/x86/kernel/hpet.c
@@ -367,6 +367,15 @@ static void hpet_set_mode(enum clock_event_mode mode,
}
 }

+void check_hpet(void)
+{
+   u32 cnt1,cnt2;
+
+   cnt1 = hpet_readl(HPET_COUNTER);
+   cnt2 = hpet_readl(HPET_COUNTER);
+   if(cnt2-cnt1>1000) printk("So big! (%u)\n",cnt2-cnt1);
+}
+
 static int hpet_next_event(unsigned long delta,
   struct clock_event_device *evt, int timer)
 {

2, ensure that no USB device attached on SB700 (except keyboard and mouse)
3, download this file:
http://mirror.lemote.com/fedora-users/ipfootball/video_bench/1920x1080_25fps_h264_ac3.mkv
4, ffmpeg -hwaccel vdpau -i 1920x1080_25fps_h264_acc.mkv  -f rawvideo
-an -y /dev/null
5, dmesg will complain "So big..."

Huacai


[PATCH v2] drm: Deal with rotation in drm_plane_helper_check_update()

2016-06-17 Thread Daniel Vetter
On Fri, Jun 17, 2016 at 05:13:10PM +0300, ville.syrjala at linux.intel.com 
wrote:
> From: Ville Syrjälä 
> 
> drm_plane_helper_check_update() needs to account for the plane rotation
> for correct clipping/scaling calculations. Do so.
> 
> There was an earlier attempt [1] to add this into
> intel_check_primary_plane() but I requested that it'd be put into the
> helper instead. An updated patch never materialized AFAICS, so I went
> ahead and cooked one up myself.
> 
> v2: Deal with new drm_plane_helper_check_update() callers
> 
> [1] https://patchwork.freedesktop.org/patch/65177/
> Cc: Nabendu Maiti 
> Cc: Noralf Trønnes 
> Cc: CK Hu 
> Cc: Mark Yao 
> Cc: Russell King 
> Signed-off-by: Ville Syrjälä 
> Reviewed-by: Patrik Jakobsson 

Applied to drm-misc, thanks.
-Daniel

> ---
>  drivers/gpu/drm/armada/armada_overlay.c |  1 +
>  drivers/gpu/drm/drm_plane_helper.c  | 28 ++--
>  drivers/gpu/drm/drm_simple_kms_helper.c |  1 +
>  drivers/gpu/drm/i915/intel_display.c|  2 ++
>  drivers/gpu/drm/mediatek/mtk_drm_plane.c|  1 +
>  drivers/gpu/drm/rockchip/rockchip_drm_vop.c |  1 +
>  include/drm/drm_plane_helper.h  |  1 +
>  7 files changed, 25 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/armada/armada_overlay.c 
> b/drivers/gpu/drm/armada/armada_overlay.c
> index 148e8a42b2c6..1ee707ef6b8d 100644
> --- a/drivers/gpu/drm/armada/armada_overlay.c
> +++ b/drivers/gpu/drm/armada/armada_overlay.c
> @@ -121,6 +121,7 @@ armada_ovl_plane_update(struct drm_plane *plane, struct 
> drm_crtc *crtc,
>   int ret;
>  
>   ret = drm_plane_helper_check_update(plane, crtc, fb, &src, &dest, &clip,
> + BIT(DRM_ROTATE_0),
>   0, INT_MAX, true, false, &visible);
>   if (ret)
>   return ret;
> diff --git a/drivers/gpu/drm/drm_plane_helper.c 
> b/drivers/gpu/drm/drm_plane_helper.c
> index fc51306fe365..16c4a7bd7465 100644
> --- a/drivers/gpu/drm/drm_plane_helper.c
> +++ b/drivers/gpu/drm/drm_plane_helper.c
> @@ -115,6 +115,7 @@ static int get_connectors_for_crtc(struct drm_crtc *crtc,
>   * @src: source coordinates in 16.16 fixed point
>   * @dest: integer destination coordinates
>   * @clip: integer clipping coordinates
> + * @rotation: plane rotation
>   * @min_scale: minimum @src:@dest scaling factor in 16.16 fixed point
>   * @max_scale: maximum @src:@dest scaling factor in 16.16 fixed point
>   * @can_position: is it legal to position the plane such that it
> @@ -134,16 +135,17 @@ static int get_connectors_for_crtc(struct drm_crtc 
> *crtc,
>   * Zero if update appears valid, error code on failure
>   */
>  int drm_plane_helper_check_update(struct drm_plane *plane,
> - struct drm_crtc *crtc,
> - struct drm_framebuffer *fb,
> - struct drm_rect *src,
> - struct drm_rect *dest,
> - const struct drm_rect *clip,
> - int min_scale,
> - int max_scale,
> - bool can_position,
> - bool can_update_disabled,
> - bool *visible)
> +   struct drm_crtc *crtc,
> +   struct drm_framebuffer *fb,
> +   struct drm_rect *src,
> +   struct drm_rect *dest,
> +   const struct drm_rect *clip,
> +   unsigned int rotation,
> +   int min_scale,
> +   int max_scale,
> +   bool can_position,
> +   bool can_update_disabled,
> +   bool *visible)
>  {
>   int hscale, vscale;
>  
> @@ -163,6 +165,8 @@ int drm_plane_helper_check_update(struct drm_plane *plane,
>   return -EINVAL;
>   }
>  
> + drm_rect_rotate(src, fb->width << 16, fb->height << 16, rotation);
> +
>   /* Check scaling */
>   hscale = drm_rect_calc_hscale(src, dest, min_scale, max_scale);
>   vscale = drm_rect_calc_vscale(src, dest, min_scale, max_scale);
> @@ -174,6 +178,9 @@ int drm_plane_helper_check_update(struct drm_plane *plane,
>   }
>  
>   *visible = drm_rect_clip_scaled(src, dest, clip, hscale, vscale);
> +
> + drm_rect_rotate_inv(src, fb->width << 16, fb->height << 16, rotation);
> +
>   if (!*visible)
>   /*
>* Plane isn't visible; some drivers can handle this
> @@ -267,6 +274,7 @@ int drm_primary_helper_update(struct drm_plane *plane, 
> struct drm_crtc *crtc,
>  
>   ret = drm_plane_helper_check_update(plane, crtc, fb,
>   &src, &dest, &clip,
> +  

[PATCH 19/38] drm/hisilicon: Implement some semblance of vblank event handling

2016-06-17 Thread Xinliang Liu
Hi,

On 17 June 2016 at 15:23, Daniel Vetter  wrote:
> On Fri, Jun 17, 2016 at 10:09:50AM +0800, Xinliang Liu wrote:
>> Hi Daniel,
>>
>> I have tested your David's drm-next branch[1] which including this patch.
>> In most time it is ok. But when switching modes or disable/re-enable
>> mode, it will encounter bellow error msg:
>> --
>> [  357.940728] [drm:drm_atomic_helper_commit_cleanup_done] *ERROR*
>> [CRTC:24:crtc-0] flip_done timed out
>> [  368.004962] [drm:drm_atomic_helper_commit_cleanup_done] *ERROR*
>> [CRTC:24:crtc-0] flip_done timed out
>> [  396.064871] INFO: rcu_preempt detected stalls on CPUs/tasks:
>> [  396.070548]  0-...: (3 GPs behind) idle=f4f/1/0 softirq=4253/4253 fqs=19
>> [  396.077335]  7-...: (1 GPs behind) idle=71f/140/0
>> softirq=2444/2451 fqs=19
>> [  396.085332]  (detected by 1, t=6028 jiffies, g=3924, c=3923, q=246)
>> [  396.091600] Task dump for CPU 0:
>> [  396.094821] swapper/0   R  running task0 0  0 
>> 0x0002
>> [  396.101872] Call trace:
>> [  396.104323] [] __switch_to+0xa4/0xd4
>> [  396.109460] [] __boot_cpu_mode+0x0/0x80
>> [  396.114852] Task dump for CPU 7:
>> [  396.118072] XorgR  running task0  1658   1646 
>> 0x0002
>> [  396.125121] Call trace:
>> [  396.127562] [] __switch_to+0xc8/0xd4
>> [  396.132695] [] 0x800035567110
>> [  396.137569] rcu_preempt kthread starved for 1000 jiffies! g3924
>> c3923 f0x0 RCU_GP_WAIT_FQS(3) ->state=0x1
>> [  396.147130] rcu_preempt S 08085c10 0 7  2 
>> 0x
>> [  396.154180] Call trace:
>> [  396.156620] [] __switch_to+0xc8/0xd4
>> [  396.161758] [] __schedule+0x188/0x590
>> [  396.166978] [] schedule+0x3c/0xa0
>> [  396.171851] [] schedule_timeout+0x104/0x1a4
>> [  396.177595] [] rcu_gp_kthread+0x54c/0x814
>> [  396.183164] [] kthread+0xd4/0xe8
>> [  396.187951] [] ret_from_fork+0x10/0x40
>> --
>>
>> Then the console stuck. Any tips for addressing this issue?
>> I am running a debian system.
>>
>> [1] git://people.freedesktop.org/~airlied/linux drm-next
>
> hisilicon doesn't handle crtc_state->event correctly. Most likely when
> shutting down a CRTC if fails to send out that flip event, which means the
> waiting for flip_done times out. My patch tried to fix that (it's not
> correct, but it did work on other drivers).
>
> From a quick look what's wrong with hisilicon vblank handling:
> - You don't call drm_crtc_vblank_on/off, which means the core thinks
>   vblanks will keep working even when the CRTC is off. That throws off the
>   hack in my patch. You need to put a call to drm_crtc_vblank_off into
>   crtc->disable hook, and drm_crtc_vblank_on into crtc->enable.

Yes, this is really a problem. I will add drm_crtc_vblank_on/off into
 crtc->disable/enable hook.
And try.

>
> - While at it please review that the event sending is placed correctly and
>   can't race with the new buffers showing up on the screen. The event
>   should be signalled at exactly the time the buffers start to get scanned
>   out. The important bit is to make sure that even if something races or
>   gets delayed that it still happens together.

Our display controller has a interrupt to indicate that  one
commit/flip is taken effect in hardware.
Should I put the sending event in this interrupt handler?

Thanks,
-xinliang

>
> Cheers, Daniel
>>
>> Thanks,
>> -xinliang
>>
>> On 2 June 2016 at 06:06, Daniel Vetter  wrote:
>> > atomic_flush seems to be the right place, but I'm not entirely sure
>> > whether this will catch them all. It could be that when disabling the
>> > crtc we'll miss the vblank.
>> >
>> > While at it nuke the dummy functions.
>> >
>> > v2: Be more robust and either arm, when the CRTC is on, or just send
>> > the event out right away.
>> >
>> > Cc: Xinliang Liu 
>> > Cc: Xinwei Kong 
>> > Cc: Archit Taneja 
>> > Signed-off-by: Daniel Vetter 
>>
>> Acked-by: Xinliang Liu 
>>
>> > ---
>> >  drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 20 
>> >  1 file changed, 12 insertions(+), 8 deletions(-)
>> >
>> > diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c 
>> > b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
>> > index fba6372d060e..ed76baad525f 100644
>> > --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
>> > +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
>> > @@ -502,13 +502,6 @@ static void ade_crtc_disable(struct drm_crtc *crtc)
>> > acrtc->enable = false;
>> >  }
>> >
>> > -static int ade_crtc_atomic_check(struct drm_crtc *crtc,
>> > -struct drm_crtc_state *state)
>> > -{
>> > -   /* do nothing */
>> > -   return 0;
>> > -}
>> > -
>> >  static void ade_crtc_mode_set_nofb(struct drm_crtc *crtc)
>> >  {
>> > struct ade_crtc *acrtc = to_ade_crtc(crtc);
>> > @@ -537,6 +530,7 @@ static void ade_crtc_atomic_flush(struct drm_crtc 
>> > *crtc,
>> >  {
>> > struct ade_crtc *acrtc = to_ade_crtc(crtc);
>> > struct ade_hw_ctx *ctx = acr

[Intel-gfx] Bad flicker on skylake HQD due to code in the 4.7 merge window

2016-06-17 Thread Jani Nikula
On Fri, 17 Jun 2016, Daniel Vetter  wrote:
> On Thu, Jun 16, 2016 at 03:42:12PM -0700, James Bottomley wrote:
>> On Thu, 2016-06-16 at 14:29 -0700, James Bottomley wrote:
>> > On Thu, 2016-06-16 at 23:24 +0200, Daniel Vetter wrote:
>> > > I guess we'll need the bisect on this one to make progress.
>> > 
>> > Sigh, I was afraid that might be the next step.
>> 
>> OK, I have a curious data point.  I assumed the problem would be
>> somewhere in the drm update, so I started bisecting that at the top. 
>>  However, the top most commit:
>> 
>> commit 1d6da87a3241deb13d073c4125d19ed0e5a0c62c
>> Merge: 1f40c49 a39ed68
>> Author: Linus Torvalds 
>> Date:   Mon May 23 11:48:48 2016 -0700
>> 
>> Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux
>> 
>> Isn't actually bad.  There's no flicker here, so whatever caused the
>> problem came from some update after this.
>
> There was a fixes pull after this. Might be worth it to restrict to just
> the i915 changes, which are just 5b4fd5bb1230cd037..157d2c7fad0863222
>
> Looking at those nothing seems to stick out which might explain what's
> happening for you.

This should be easy enough to try before bisecting:
http://patchwork.freedesktop.org/patch/msgid/1466162081-12042-1-git-send-email-mika.kahola
 at intel.com

BR,
Jani.


-- 
Jani Nikula, Intel Open Source Technology Center


[Mesa-dev] [RFC] New dma_buf -> EGLImage EGL extension - Final spec published!

2016-06-17 Thread Pekka Paalanen
orientation" connect with "GL texture coordinates"?
The latter have explicitly defined orientation and origin. For use in
GL, the right way up image is having the origin in the bottom-left
corner. An image right way up is an image right way up, regardless
which corner is the origin. The problem comes when you start using
coordinates.

> Do you just get that w/ i965?  I know some linaro folks have been
> using this extension to import buffers from video decoder with
> freedreno/gallium and no one mentioned the video being upside down.

Intel, yes, but since this happens *only* for the GL import path and
direct scanout is fine without y-flipping, I bet people just flipped y
and did not think twice, if there even was a problem. I just have a
habit of asking "why". ;-)

After all, using GL with windows and FBOs and stuff you very often find
yourself upside down, and I suspect people have got the habit of just
flipping it if it does not look right the first time. See e.g. the
row-order of data going into glTexImage2D...

If the answer is "oops, well, dmabuf import is semantically y-flipping
when it should not, but we cannot fix it because that would break
everyone", I would be happy with that. I just want confirmation before
flipping the flip flag. :-)


Thanks,
pq
-- next part --
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 811 bytes
Desc: OpenPGP digital signature
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160617/6d36d9fa/attachment.sig>


[PATCH v7 00/12] Support non-lru page migration

2016-06-17 Thread Joonsoo Kim
On Thu, Jun 16, 2016 at 07:09:32PM +0900, Minchan Kim wrote:
> On Thu, Jun 16, 2016 at 05:42:11PM +0900, Sergey Senozhatsky wrote:
> > On (06/16/16 15:47), Minchan Kim wrote:
> > > > [..]
> > > > > > this is what I'm getting with the [zsmalloc: keep first object 
> > > > > > offset in struct page]
> > > > > > applied:  "count:0 mapcount:-127". which may be not related to 
> > > > > > zsmalloc at this point.
> > > > > > 
> > > > > > kernel: BUG: Bad page state in process khugepaged  pfn:101db8
> > > > > > kernel: page:ea0004076e00 count:0 mapcount:-127 mapping:
> > > > > >   (null) index:0x1
> > > > > 
> > > > > Hm, it seems double free.
> > > > > 
> > > > > It doen't happen if you disable zram? IOW, it seems to be related
> > > > > zsmalloc migration?
> > > > 
> > > > need to test more, can't confidently answer now.
> > > > 
> > > > > How easy can you reprodcue it? Could you bisect it?
> > > > 
> > > > it takes some (um.. random) time to trigger the bug.
> > > > I'll try to come up with more details.
> > > 
> > > Could you revert [1] and retest?
> > > 
> > > [1] mm/compaction: split freepages without holding the zone lock
> > 
> > ok, so this is not related to zsmalloc. finally manged to reproduce
> > it. will fork a separate thread.
> 
> The reason I mentioned [1] is that it seems to have a bug.
> 
> isolate_freepages_block
>   __isolate_free_page
> if(!zone_watermark_ok())
>   return 0;
>   list_add_tail(&page->lru, freelist);
> 
> However, the page is not isolated.
> Joonsoo?

Good job!
I will fix it soon.

Thanks.


[Intel-gfx] Bad flicker on skylake HQD due to code in the 4.7 merge window

2016-06-17 Thread James Bottomley
On Fri, 2016-06-17 at 16:34 +0300, Jani Nikula wrote:
> On Fri, 17 Jun 2016, Daniel Vetter  wrote:
> > On Thu, Jun 16, 2016 at 03:42:12PM -0700, James Bottomley wrote:
> > > On Thu, 2016-06-16 at 14:29 -0700, James Bottomley wrote:
> > > > On Thu, 2016-06-16 at 23:24 +0200, Daniel Vetter wrote:
> > > > > I guess we'll need the bisect on this one to make progress.
> > > > 
> > > > Sigh, I was afraid that might be the next step.
> > > 
> > > OK, I have a curious data point.  I assumed the problem would be
> > > somewhere in the drm update, so I started bisecting that at the
> > > top. 
> > >  However, the top most commit:
> > > 
> > > commit 1d6da87a3241deb13d073c4125d19ed0e5a0c62c
> > > Merge: 1f40c49 a39ed68
> > > Author: Linus Torvalds 
> > > Date:   Mon May 23 11:48:48 2016 -0700
> > > 
> > > Merge branch 'drm-next' of
> > > git://people.freedesktop.org/~airlied/linux
> > > 
> > > Isn't actually bad.  There's no flicker here, so whatever caused
> > > the
> > > problem came from some update after this.
> > 
> > There was a fixes pull after this. Might be worth it to restrict to
> > just
> > the i915 changes, which are just
> > 5b4fd5bb1230cd037..157d2c7fad0863222
> > 
> > Looking at those nothing seems to stick out which might explain
> > what's
> > happening for you.

OK, so just on the firmware, the system seems less flickery with the
new 1.4.3 UEFI, so I'm starting to think it is a Skylake errata issue. 
 The flicker isn't gone for good, but seems to be reboot dependent
(it's there in some boots, but gone on a reboot).

> This should be easy enough to try before bisecting:
> http://patchwork.freedesktop.org/patch/msgid/1466162081-12042-1-git-s
> end-email-mika.kahola at intel.com

Applying this didn't seem to make a difference: still there on some and
gone on other reboots.

James




[PATCH 01/20] clk: fixed-factor: Pass clk rates change to the parent

2016-06-17 Thread Michael Turquette
Quoting Maxime Ripard (2016-05-16 05:47:01)
> A fixed factor clock, if it needs to change its rate, by definition do not
> have any choice but to modify its parent rate.

Logically it makes sense to always propagate the rate-change request up
to the parent for a fixed-factor clock if we desire to change its rate.
However, I wonder if doing this for all users of fixed-factor-clock in
DT is safe? Some users may be counting on it not changing.

There are 397 instances of fixed-factor-clock in .dts[i] today, so this
change worries me a bit.

> 
> Add the CLK_SET_RATE_PARENT flag to that clock so that it can happen
> 
> Signed-off-by: Maxime Ripard 
> ---
>  drivers/clk/clk-fixed-factor.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/clk/clk-fixed-factor.c b/drivers/clk/clk-fixed-factor.c
> index 75cd6c792cb8..3363abd9b4ae 100644
> --- a/drivers/clk/clk-fixed-factor.c
> +++ b/drivers/clk/clk-fixed-factor.c
> @@ -167,7 +167,8 @@ void __init of_fixed_factor_clk_setup(struct device_node 
> *node)
> of_property_read_string(node, "clock-output-names", &clk_name);
> parent_name = of_clk_get_parent_name(node, 0);
>  
> -   clk = clk_register_fixed_factor(NULL, clk_name, parent_name, 0,
> +   clk = clk_register_fixed_factor(NULL, clk_name, parent_name,
> +   CLK_SET_RATE_PARENT,

An alternative would be to pass in the flags you want, somehow. For the
clock you are trying to fix, is it inside of the SoC or external? If it
is internal, and part of a larger clock controller driver, is this for
the legacy style allwinner clock drivers that put everything in DT? If
not, it would better to initialize it statically and shove this flag
into the struct clk_init_data storage.

Regards,
Mike

> mult, div);
> if (!IS_ERR(clk))
> of_clk_add_provider(node, of_clk_src_simple_get, clk);
> -- 
> 2.8.2
> 


[PATCH 4/5] drm/imx: drop deprecated load/unload drm_driver ops

2016-06-17 Thread Daniel Vetter
On Fri, Jun 17, 2016 at 12:13:41PM +0200, Lucas Stach wrote:
> Drop the load/unload driver ops, as they are deprecated because of their
> inherent races, with devices being visible to userspace before they are
> fully initialized.
> 
> Move this code into the driver bind/unbind routines bracketed by the
> proper drm_dev_alloc/register and drm_dev_unregister/unref calls.
> 
> Signed-off-by: Lucas Stach 
> ---
>  drivers/gpu/drm/imx/imx-drm-core.c | 247 
> ++---
>  1 file changed, 121 insertions(+), 126 deletions(-)
> 
> diff --git a/drivers/gpu/drm/imx/imx-drm-core.c 
> b/drivers/gpu/drm/imx/imx-drm-core.c
> index c63378661e11..799a68976590 100644
> --- a/drivers/gpu/drm/imx/imx-drm-core.c
> +++ b/drivers/gpu/drm/imx/imx-drm-core.c
> @@ -78,25 +78,6 @@ static void imx_drm_driver_lastclose(struct drm_device 
> *drm)
>   }
>  }
>  
> -static int imx_drm_driver_unload(struct drm_device *drm)
> -{
> - struct imx_drm_device *imxdrm = drm->dev_private;
> -
> - drm_kms_helper_poll_fini(drm);
> -
> - if (imxdrm->fbhelper)
> - drm_fbdev_cma_fini(imxdrm->fbhelper);
> -
> - component_unbind_all(drm->dev, drm);
> -
> - drm_vblank_cleanup(drm);
> - drm_mode_config_cleanup(drm);
> -
> - platform_set_drvdata(drm->platformdev, NULL);
> -
> - return 0;
> -}
> -
>  static struct imx_drm_crtc *imx_drm_find_crtc(struct drm_crtc *crtc)
>  {
>   struct imx_drm_device *imxdrm = crtc->dev->dev_private;
> @@ -223,109 +204,6 @@ static const struct drm_mode_config_funcs 
> imx_drm_mode_config_funcs = {
>  };
>  
>  /*
> - * Main DRM initialisation. This binds, initialises and registers
> - * with DRM the subcomponents of the driver.
> - */
> -static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags)
> -{
> - struct imx_drm_device *imxdrm;
> - struct drm_connector *connector;
> - int ret;
> -
> - imxdrm = devm_kzalloc(drm->dev, sizeof(*imxdrm), GFP_KERNEL);
> - if (!imxdrm)
> - return -ENOMEM;
> -
> - imxdrm->drm = drm;
> -
> - drm->dev_private = imxdrm;
> -
> - /*
> -  * enable drm irq mode.
> -  * - with irq_enabled = true, we can use the vblank feature.
> -  *
> -  * P.S. note that we wouldn't use drm irq handler but
> -  *  just specific driver own one instead because
> -  *  drm framework supports only one irq handler and
> -  *  drivers can well take care of their interrupts
> -  */
> - drm->irq_enabled = true;
> -
> - /*
> -  * set max width and height as default value(4096x4096).
> -  * this value would be used to check framebuffer size limitation
> -  * at drm_mode_addfb().
> -  */
> - drm->mode_config.min_width = 64;
> - drm->mode_config.min_height = 64;
> - drm->mode_config.max_width = 4096;
> - drm->mode_config.max_height = 4096;
> - drm->mode_config.funcs = &imx_drm_mode_config_funcs;
> -
> - drm_mode_config_init(drm);
> -
> - ret = drm_vblank_init(drm, MAX_CRTC);
> - if (ret)
> - goto err_kms;
> -
> - platform_set_drvdata(drm->platformdev, drm);
> -
> - /* Now try and bind all our sub-components */
> - ret = component_bind_all(drm->dev, drm);
> - if (ret)
> - goto err_vblank;
> -
> - /*
> -  * All components are now added, we can publish the connector sysfs
> -  * entries to userspace.  This will generate hotplug events and so
> -  * userspace will expect to be able to access DRM at this point.
> -  */
> - list_for_each_entry(connector, &drm->mode_config.connector_list, head) {
> - ret = drm_connector_register(connector);
> - if (ret) {
> - dev_err(drm->dev,
> - "[CONNECTOR:%d:%s] drm_connector_register 
> failed: %d\n",
> - connector->base.id,
> - connector->name, ret);
> - goto err_unbind;
> - }
> - }
> -
> - /*
> -  * All components are now initialised, so setup the fb helper.
> -  * The fb helper takes copies of key hardware information, so the
> -  * crtcs/connectors/encoders must not change after this point.
> -  */
> -#if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION)
> - if (legacyfb_depth != 16 && legacyfb_depth != 32) {
> - dev_warn(drm->dev, "Invalid legacyfb_depth.  Defaulting to 
> 16bpp\n");
> - legacyfb_depth = 16;
> - }
> - drm_helper_disable_unused_functions(drm);
> - imxdrm->fbhelper = drm_fbdev_cma_init(drm, legacyfb_depth,
> - drm->mode_config.num_crtc, MAX_CRTC);
> - if (IS_ERR(imxdrm->fbhelper)) {
> - ret = PTR_ERR(imxdrm->fbhelper);
> - imxdrm->fbhelper = NULL;
> - goto err_unbind;
> - }
> -#endif
> -
> - drm_kms_helper_poll_init(drm);
> -
> - return 0;
> -
> -err_unbind:
> - component_unbind_all(drm

[PATCH 1/5] drm/imx: disable outputs in lastclose when framebuffer emulation is disabled

2016-06-17 Thread Daniel Vetter
On Fri, Jun 17, 2016 at 12:13:38PM +0200, Lucas Stach wrote:
> If there is no framebuffer mode that can be restored, all outputs should
> be disabled in order to avoid information leaks.

No, this was a short-term regression that's now fixed again. When a client
closes or calls rmfb, we make sure that buffer isn't in use any more. This
shouldn't be needed any more.

Also, a generic fix in driver code. Tsk! ;-)

Cheers, Daniel

> 
> Signed-off-by: Lucas Stach 
> ---
>  drivers/gpu/drm/imx/imx-drm-core.c | 14 +-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/imx/imx-drm-core.c 
> b/drivers/gpu/drm/imx/imx-drm-core.c
> index 82656654fb21..c63378661e11 100644
> --- a/drivers/gpu/drm/imx/imx-drm-core.c
> +++ b/drivers/gpu/drm/imx/imx-drm-core.c
> @@ -63,7 +63,19 @@ static void imx_drm_driver_lastclose(struct drm_device 
> *drm)
>  {
>   struct imx_drm_device *imxdrm = drm->dev_private;
>  
> - drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
> + if (imxdrm->fbhelper) {
> + drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
> + } else {
> + struct drm_connector *connector;
> +
> + /* no kernel mode to go back to, disable all outputs */
> + drm_modeset_lock_all(drm);
> + drm_for_each_connector(connector, drm)
> + connector->encoder = NULL;
> + drm_modeset_unlock_all(drm);
> +
> + drm_helper_disable_unused_functions(drm);
> + }
>  }
>  
>  static int imx_drm_driver_unload(struct drm_device *drm)
> -- 
> 2.8.1
> 
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[PATCH 6/7] drm/msm: Remove redundant calls to drm_connector_register_all()

2016-06-17 Thread Archit Taneja


On 06/17/2016 01:55 PM, Chris Wilson wrote:
> Up to now, the recommendation was for drivers to call drm_dev_register()
> followed by drm_connector_register_all(). Now that
> drm_connector_register() is safe against multiple invocations, we can
> move drm_connector_register_all() to drm_dev_register() and not suffer
> from any backwards compatibility issues with drivers not following the
> more rigorous init ordering.
>

Tested-by: Archit Taneja 

> Signed-off-by: Chris Wilson 
> Cc: Daniel Vetter 
> Cc: Rob Clark 
> Cc: David Airlie 
> Cc: dri-devel at lists.freedesktop.org
> Cc: linux-arm-msm at vger.kernel.org
> Cc: freedreno at lists.freedesktop.org
> ---
>   drivers/gpu/drm/msm/msm_drv.c | 8 
>   1 file changed, 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c
> index 9c654092ef78..568fcc328f27 100644
> --- a/drivers/gpu/drm/msm/msm_drv.c
> +++ b/drivers/gpu/drm/msm/msm_drv.c
> @@ -197,8 +197,6 @@ static int msm_drm_uninit(struct device *dev)
>
>   drm_kms_helper_poll_fini(ddev);
>
> - drm_connector_unregister_all(ddev);
> -
>   drm_dev_unregister(ddev);
>
>   #ifdef CONFIG_DRM_FBDEV_EMULATION
> @@ -431,12 +429,6 @@ static int msm_drm_init(struct device *dev, struct 
> drm_driver *drv)
>   if (ret)
>   goto fail;
>
> - ret = drm_connector_register_all(ddev);
> - if (ret) {
> - dev_err(dev, "failed to register connectors\n");
> - goto fail;
> - }
> -
>   drm_mode_config_reset(ddev);
>
>   #ifdef CONFIG_DRM_FBDEV_EMULATION
>

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora 
Forum, hosted by The Linux Foundation


[PATCH 1/7] drm: Automatically register/unregister all connectors

2016-06-17 Thread Daniel Vetter
On Fri, Jun 17, 2016 at 09:25:17AM +0100, Chris Wilson wrote:
> As the drm_connector is now safe for multiple calls to
> register/unregister, automatically perform a registration on all known
> connectors drm drv_register (and unregister from drm_drv_unregister).
> Drivers can still call drm_connector_register() and
> drm_connector_unregister() individually, or defer as required.
> 
> Signed-off-by: Chris Wilson 
> Cc: Daniel Vetter 
> Cc: dri-devel at lists.freedesktop.org

Applied to drm-misc. I'll let driver maintainers have a little bit more
time to ack or test the patches before I vacuum them up.

Thanks, Daniel

> ---
>  drivers/gpu/drm/drm_crtc.c |  6 +++---
>  drivers/gpu/drm/drm_drv.c  | 10 +-
>  2 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
> index 316dea9bea08..e7c862bd2f19 100644
> --- a/drivers/gpu/drm/drm_crtc.c
> +++ b/drivers/gpu/drm/drm_crtc.c
> @@ -1047,9 +1047,9 @@ EXPORT_SYMBOL(drm_connector_unregister);
>   * @dev: drm device
>   *
>   * This function registers all connectors in sysfs and other places so that
> - * userspace can start to access them. Drivers can call it after calling
> - * drm_dev_register() to complete the device registration, if they don't call
> - * drm_connector_register() on each connector individually.
> + * userspace can start to access them. drm_connector_register_all() is called
> + * automatically from drm_dev_register() to complete the device registration,
> + * if they don't call drm_connector_register() on each connector 
> individually.
>   *
>   * When a device is unplugged and should be removed from userspace access,
>   * call drm_connector_unregister_all(), which is the inverse of this
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index 40fb4352432c..2067ff089380 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -650,11 +650,7 @@ EXPORT_SYMBOL(drm_dev_unref);
>   *
>   * Register the DRM device @dev with the system, advertise device to 
> user-space
>   * and start normal device operation. @dev must be allocated via 
> drm_dev_alloc()
> - * previously. Right after drm_dev_register() the driver should call
> - * drm_connector_register_all() to register all connectors in sysfs. This is
> - * a separate call for backward compatibility with drivers still using
> - * the deprecated ->load() callback, where connectors are registered from 
> within
> - * the ->load() callback.
> + * previously.
>   *
>   * Never call this twice on any device!
>   *
> @@ -691,6 +687,8 @@ int drm_dev_register(struct drm_device *dev, unsigned 
> long flags)
>   goto err_minors;
>   }
>  
> + drm_connector_register_all(dev);
> +
>   ret = 0;
>   goto out_unlock;
>  
> @@ -721,6 +719,8 @@ void drm_dev_unregister(struct drm_device *dev)
>  
>   drm_lastclose(dev);
>  
> + drm_connector_unregister_all(dev);
> +
>   if (dev->driver->unload)
>   dev->driver->unload(dev);
>  
> -- 
> 2.8.1
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[Intel-gfx] [PATCH 2/2] drm: Minimally initialise drm_dp_aux

2016-06-17 Thread Daniel Vetter
On Fri, Jun 17, 2016 at 09:33:18AM +0100, Chris Wilson wrote:
> When trying to split up the initialisation phase and the registration
> phase, one immediate problem encountered is trying to use our own i2c
> devices before registration with userspace (to read EDID during device
> discovery). drm_dp_aux in particular only offers an interface for setting
> up the device *after* we have exposed the connector via sysfs. In order
> to break the chicken-and-egg problem, export drm_dp_aux_init() to
> minimally prepare the i2c device for internal use before
> drm_connector_register().
> 
> Signed-off-by: Chris Wilson 
> Cc: Dave Airlie 
> Cc: Rafael Antognolli 
> Cc: Ville Syrjälä 
> Cc: dri-devel at lists.freedesktop.org
> ---
>  drivers/gpu/drm/drm_dp_helper.c | 26 +-
>  include/drm/drm_dp_helper.h |  1 +
>  2 files changed, 22 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
> index 4b088afa21b2..9b4ec65e1de6 100644
> --- a/drivers/gpu/drm/drm_dp_helper.c
> +++ b/drivers/gpu/drm/drm_dp_helper.c
> @@ -791,15 +791,16 @@ static void unlock_bus(struct i2c_adapter *i2c, 
> unsigned int flags)
>  }
>  
>  /**
> - * drm_dp_aux_register() - initialise and register aux channel
> + * drm_dp_aux_init() - minimally initialise an aux channel
>   * @aux: DisplayPort AUX channel
>   *
> - * Returns 0 on success or a negative error code on failure.
> + * If you need to use the drm_dp_aux's i2c adapter prior to registering it
> + * with the outside world, call drm_dp_aux_init() first. You must still
> + * call drm_dp_aux_register() once the connector has been registered to
> + * allow userspace access to the auxiliary DP channel.
>   */
> -int drm_dp_aux_register(struct drm_dp_aux *aux)
> +void drm_dp_aux_init(struct drm_dp_aux *aux)
>  {
> - int ret;
> -
>   mutex_init(&aux->hw_mutex);
>  
>   aux->ddc.algo = &drm_dp_i2c_algo;
> @@ -809,6 +810,21 @@ int drm_dp_aux_register(struct drm_dp_aux *aux)
>   aux->ddc.lock_bus = lock_bus;
>   aux->ddc.trylock_bus = trylock_bus;
>   aux->ddc.unlock_bus = unlock_bus;
> +}
> +EXPORT_SYMBOL(drm_dp_aux_init);
> +
> +/**
> + * drm_dp_aux_register() - initialise and register aux channel
> + * @aux: DisplayPort AUX channel
> + *
> + * Returns 0 on success or a negative error code on failure.

I amended kerneldoc slightly here and merged both, thanks.
-Daniel

> + */
> +int drm_dp_aux_register(struct drm_dp_aux *aux)
> +{
> + int ret;
> +
> + if (!aux->ddc.algo)
> + drm_dp_aux_init(aux);
>  
>   aux->ddc.class = I2C_CLASS_DDC;
>   aux->ddc.owner = THIS_MODULE;
> diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
> index 5a848e734422..4d85cf2874af 100644
> --- a/include/drm/drm_dp_helper.h
> +++ b/include/drm/drm_dp_helper.h
> @@ -805,6 +805,7 @@ int drm_dp_link_power_up(struct drm_dp_aux *aux, struct 
> drm_dp_link *link);
>  int drm_dp_link_power_down(struct drm_dp_aux *aux, struct drm_dp_link *link);
>  int drm_dp_link_configure(struct drm_dp_aux *aux, struct drm_dp_link *link);
>  
> +void drm_dp_aux_init(struct drm_dp_aux *aux);
>  int drm_dp_aux_register(struct drm_dp_aux *aux);
>  void drm_dp_aux_unregister(struct drm_dp_aux *aux);
>  
> -- 
> 2.8.1
> 
> ___
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[PATCH 37/38] drm/sti: Don't call drm_helper_disable_unused_functions

2016-06-17 Thread Daniel Vetter
On Fri, Jun 17, 2016 at 12:04:16PM +0200, Benjamin Gaignard wrote:
> Acked-by: Benjamin Gaignard 

Applied to drm-misc.
-Daniel

> 
> 2016-06-02 0:07 GMT+02:00 Daniel Vetter :
> > Atomic drivers are supposed to do hw/sw state reset with the
> > drm_mode_config_reset() call right above it.
> >
> > Cc: Benjamin Gaignard 
> > Signed-off-by: Daniel Vetter 
> > ---
> >  drivers/gpu/drm/sti/sti_drv.c | 1 -
> >  1 file changed, 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
> > index dd2c400c4a46..26aa85d4b872 100644
> > --- a/drivers/gpu/drm/sti/sti_drv.c
> > +++ b/drivers/gpu/drm/sti/sti_drv.c
> > @@ -279,7 +279,6 @@ static int sti_load(struct drm_device *dev, unsigned 
> > long flags)
> >
> > drm_mode_config_reset(dev);
> >
> > -   drm_helper_disable_unused_functions(dev);
> > drm_fbdev_cma_init(dev, 32,
> >dev->mode_config.num_crtc,
> >dev->mode_config.num_connector);
> > --
> > 2.8.1
> >
> 
> 
> 
> -- 
> Benjamin Gaignard
> 
> Graphic Working Group
> 
> Linaro.org │ Open source software for ARM SoCs
> 
> Follow Linaro: Facebook | Twitter | Blog

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


[PATCH 19/38] drm/hisilicon: Implement some semblance of vblank event handling

2016-06-17 Thread Daniel Vetter
On Fri, Jun 17, 2016 at 04:38:06PM +0800, Xinliang Liu wrote:
> Hi,
> 
> On 17 June 2016 at 15:23, Daniel Vetter  wrote:
> > On Fri, Jun 17, 2016 at 10:09:50AM +0800, Xinliang Liu wrote:
> >> Hi Daniel,
> >>
> >> I have tested your David's drm-next branch[1] which including this patch.
> >> In most time it is ok. But when switching modes or disable/re-enable
> >> mode, it will encounter bellow error msg:
> >> --
> >> [  357.940728] [drm:drm_atomic_helper_commit_cleanup_done] *ERROR*
> >> [CRTC:24:crtc-0] flip_done timed out
> >> [  368.004962] [drm:drm_atomic_helper_commit_cleanup_done] *ERROR*
> >> [CRTC:24:crtc-0] flip_done timed out
> >> [  396.064871] INFO: rcu_preempt detected stalls on CPUs/tasks:
> >> [  396.070548]  0-...: (3 GPs behind) idle=f4f/1/0 softirq=4253/4253 fqs=19
> >> [  396.077335]  7-...: (1 GPs behind) idle=71f/140/0
> >> softirq=2444/2451 fqs=19
> >> [  396.085332]  (detected by 1, t=6028 jiffies, g=3924, c=3923, q=246)
> >> [  396.091600] Task dump for CPU 0:
> >> [  396.094821] swapper/0   R  running task0 0  0 
> >> 0x0002
> >> [  396.101872] Call trace:
> >> [  396.104323] [] __switch_to+0xa4/0xd4
> >> [  396.109460] [] __boot_cpu_mode+0x0/0x80
> >> [  396.114852] Task dump for CPU 7:
> >> [  396.118072] XorgR  running task0  1658   1646 
> >> 0x0002
> >> [  396.125121] Call trace:
> >> [  396.127562] [] __switch_to+0xc8/0xd4
> >> [  396.132695] [] 0x800035567110
> >> [  396.137569] rcu_preempt kthread starved for 1000 jiffies! g3924
> >> c3923 f0x0 RCU_GP_WAIT_FQS(3) ->state=0x1
> >> [  396.147130] rcu_preempt S 08085c10 0 7  2 
> >> 0x
> >> [  396.154180] Call trace:
> >> [  396.156620] [] __switch_to+0xc8/0xd4
> >> [  396.161758] [] __schedule+0x188/0x590
> >> [  396.166978] [] schedule+0x3c/0xa0
> >> [  396.171851] [] schedule_timeout+0x104/0x1a4
> >> [  396.177595] [] rcu_gp_kthread+0x54c/0x814
> >> [  396.183164] [] kthread+0xd4/0xe8
> >> [  396.187951] [] ret_from_fork+0x10/0x40
> >> --
> >>
> >> Then the console stuck. Any tips for addressing this issue?
> >> I am running a debian system.
> >>
> >> [1] git://people.freedesktop.org/~airlied/linux drm-next
> >
> > hisilicon doesn't handle crtc_state->event correctly. Most likely when
> > shutting down a CRTC if fails to send out that flip event, which means the
> > waiting for flip_done times out. My patch tried to fix that (it's not
> > correct, but it did work on other drivers).
> >
> > From a quick look what's wrong with hisilicon vblank handling:
> > - You don't call drm_crtc_vblank_on/off, which means the core thinks
> >   vblanks will keep working even when the CRTC is off. That throws off the
> >   hack in my patch. You need to put a call to drm_crtc_vblank_off into
> >   crtc->disable hook, and drm_crtc_vblank_on into crtc->enable.
> 
> Yes, this is really a problem. I will add drm_crtc_vblank_on/off into
>  crtc->disable/enable hook.
> And try.
> 
> >
> > - While at it please review that the event sending is placed correctly and
> >   can't race with the new buffers showing up on the screen. The event
> >   should be signalled at exactly the time the buffers start to get scanned
> >   out. The important bit is to make sure that even if something races or
> >   gets delayed that it still happens together.
> 
> Our display controller has a interrupt to indicate that  one
> commit/flip is taken effect in hardware.
> Should I put the sending event in this interrupt handler?

Yes, that would be perfect. So instead of the drm_crtc_arm_vblank_event
you put the event into a driver-private slot where the irq handler can
pick it up and send it out using drm_crtc_send_vblank_event.

Two important details:
- You need to arm the event this way before the hw can fire this special
  interrupt, so probably somewhere in atomic_begin.
- the drm_crtc_send_vblank_event must be called after
  drm_crtc_handle_vblank, because otherwise the vblank timestamp isn't
  properly updated.

Cheers, Daniel

> 
> Thanks,
> -xinliang
> 
> >
> > Cheers, Daniel
> >>
> >> Thanks,
> >> -xinliang
> >>
> >> On 2 June 2016 at 06:06, Daniel Vetter  wrote:
> >> > atomic_flush seems to be the right place, but I'm not entirely sure
> >> > whether this will catch them all. It could be that when disabling the
> >> > crtc we'll miss the vblank.
> >> >
> >> > While at it nuke the dummy functions.
> >> >
> >> > v2: Be more robust and either arm, when the CRTC is on, or just send
> >> > the event out right away.
> >> >
> >> > Cc: Xinliang Liu 
> >> > Cc: Xinwei Kong 
> >> > Cc: Archit Taneja 
> >> > Signed-off-by: Daniel Vetter 
> >>
> >> Acked-by: Xinliang Liu 
> >>
> >> > ---
> >> >  drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 20 
> >> > 
> >> >  1 file changed, 12 insertions(+), 8 deletions(-)
> >> >
> >> > diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c 
> >> > b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
> >> > index fba6

[PATCH 10/16] drm: Don't call drm_dev_set_unique from platform drivers

2016-06-17 Thread Laurent Pinchart
Hi Daniel,

Thank you for the patch.

On Friday 17 Jun 2016 09:33:28 Daniel Vetter wrote:
> Since
> 
> commit e112e593b215c394c0303dbf0534db0928e87967
> Author: Nicolas Iooss 
> Date:   Fri Dec 11 11:20:28 2015 +0100
> 
> drm: use dev_name as default unique name in drm_dev_alloc()
> 
> we're using a reasonable default which should work for everyone. Only
> mtk, rcar-du and sun4i are affected, and as kms-only drivers without
> any rendering support no one should ever care about the unique name
> 
> v2: Rebase on top of mediatek.
> 
> Cc: Philipp Zabel 
> Cc: Maxime Ripard 
> Cc: Laurent Pinchart 
> Cc: Emil Velikov 
> Signed-off-by: Daniel Vetter 

Reviewed-by: Laurent Pinchart 

> ---
>  drivers/gpu/drm/drm_drv.c  | 35 +-
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c |  2 --
>  drivers/gpu/drm/rcar-du/rcar_du_drv.c  |  2 --
>  drivers/gpu/drm/sun4i/sun4i_drv.c  |  4 
>  include/drm/drmP.h |  1 -
>  5 files changed, 11 insertions(+), 33 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
> index ecba2511ef5a..25f10586a74d 100644
> --- a/drivers/gpu/drm/drm_drv.c
> +++ b/drivers/gpu/drm/drm_drv.c
> @@ -298,10 +298,9 @@ void drm_minor_release(struct drm_minor *minor)
>   * callbacks implemented by the driver. The driver then needs to initialize
> all * the various subsystems for the drm device like memory management,
> vblank * handling, modesetting support and intial output configuration plus
> obviously - * initialize all the corresponding hardware bits. An important
> part of this is - * also calling drm_dev_set_unique() to set the
> userspace-visible unique name of - * this device instance. Finally when
> everything is up and running and ready for - * userspace the device
> instance can be published using drm_dev_register(). + * initialize all the
> corresponding hardware bits. Finally when everything is up + * and running
> and ready for userspace the device instance can be published + * using
> drm_dev_register().
>   *
>   * There is also deprecated support for initalizing device instances using
>   * bus-specific helpers and the ->load() callback. But due to
> @@ -323,6 +322,14 @@ void drm_minor_release(struct drm_minor *minor)
>   * dev_priv field of &drm_device.
>   */
> 
> +static int drm_dev_set_unique(struct drm_device *dev, const char *name)
> +{
> + kfree(dev->unique);
> + dev->unique = kstrdup(name, GFP_KERNEL);
> +
> + return dev->unique ? 0 : -ENOMEM;
> +}
> +
>  /**
>   * drm_put_dev - Unregister and release a DRM device
>   * @dev: DRM device
> @@ -697,26 +704,6 @@ void drm_dev_unregister(struct drm_device *dev)
>  }
>  EXPORT_SYMBOL(drm_dev_unregister);
> 
> -/**
> - * drm_dev_set_unique - Set the unique name of a DRM device
> - * @dev: device of which to set the unique name
> - * @name: unique name
> - *
> - * Sets the unique name of a DRM device using the specified string. Drivers
> - * can use this at driver probe time if the unique name of the devices
> they - * drive is static.
> - *
> - * Return: 0 on success or a negative error code on failure.
> - */
> -int drm_dev_set_unique(struct drm_device *dev, const char *name)
> -{
> - kfree(dev->unique);
> - dev->unique = kstrdup(name, GFP_KERNEL);
> -
> - return dev->unique ? 0 : -ENOMEM;
> -}
> -EXPORT_SYMBOL(drm_dev_set_unique);
> -
>  /*
>   * DRM Core
>   * The DRM core module initializes all global DRM objects and makes them
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> b/drivers/gpu/drm/mediatek/mtk_drm_drv.c index c33bf98c5d5e..04e901a80234
> 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -280,8 +280,6 @@ static int mtk_drm_bind(struct device *dev)
>   if (!drm)
>   return -ENOMEM;
> 
> - drm_dev_set_unique(drm, dev_name(dev));
> -
>   drm->dev_private = private;
>   private->drm = drm;
> 
> diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> b/drivers/gpu/drm/rcar-du/rcar_du_drv.c index 48ec4b6e8b26..8784208d8eed
> 100644
> --- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> +++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
> @@ -320,8 +320,6 @@ static int rcar_du_probe(struct platform_device *pdev)
>   if (!ddev)
>   return -ENOMEM;
> 
> - drm_dev_set_unique(ddev, dev_name(&pdev->dev));
> -
>   rcdu->ddev = ddev;
>   ddev->dev_private = rcdu;
> 
> diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c
> b/drivers/gpu/drm/sun4i/sun4i_drv.c index 68e9d85085fb..5c4b4ad17ad3 100644
> --- a/drivers/gpu/drm/sun4i/sun4i_drv.c
> +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c
> @@ -135,10 +135,6 @@ static int sun4i_drv_bind(struct device *dev)
>   if (!drm)
>   return -ENOMEM;
> 
> - ret = drm_dev_set_unique(drm, dev_name(drm->dev));
> - if (ret)
> - goto free_drm;
> -
>   drv = devm_kzalloc(dev, sizeof(*drv), GFP_KERNEL);
>   if (!drv) {
>   ret = -ENOMEM;
> diff

[PATCH 1/3] RFC: drm: Restrict vblank ioctl to master

2016-06-17 Thread Rainer Hochecker
like that (possibly has
> been
> >> > since before the DRM master concept even existed), and presumably it
> >> > actually works with simple setups (which might be the majority). So
> >> > there might be some backlash if it suddenly stops working.
> >>
> >> Fully agreed. Hence just RFC, and yes we need to get the EGL extension
> >> in place first, and at least kick most of the popular apps to have
> >> their code ready, and wait a bit, and wait some more, before we can
> >> nuke the ioctl from the kernel for non-master. It'll probably take 5
> >> years if we're fast :( I do think that we should be ok with breaking
> >> the last few hold-outs, but we definitely need to have an alternate
> >> solution for EGL ready. Hence why I want to know whether there's
> >> anyone who's using this outside of EGL.
> >>
> >> Really this was just drive-by that I spotted while looking around at
> >> stuff for our other discussion around vblanks.
> >> -Daniel
> >> --
> >> Daniel Vetter
> >> Software Engineer, Intel Corporation
> >> +41 (0) 79 365 57 48 - http://blog.ffwll.ch
> >
> >
>
>
>
> --
> Daniel Vetter
> Software Engineer, Intel Corporation
> +41 (0) 79 365 57 48 - http://blog.ffwll.ch
>
-- next part --
An HTML attachment was scrubbed...
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160617/56edf334/attachment-0001.html>


[Bug 96326] Heavy screen flickering in OpenGL apps on R9 390

2016-06-17 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=96326

Vedran Miletić  changed:

   What|Removed |Added

 CC||vedran at miletic.net

--- Comment #1 from Vedran Miletić  ---
Confirmed by lilleman on #radeon:
https://people.freedesktop.org/~cbrill/dri-log/?channel=radeon&date=2016-06-17

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160617/52f839fa/attachment.html>


[PATCH 1/2] drm: sti: rework init sequence

2016-06-17 Thread Benjamin Gaignard
Use drm_dev_alloc() and drm_dev_register() instead of .load()
Since debugfs root is created only when the device is registered
bind sub-components after this step.
Need to be reworked before upstream

Signed-off-by: Benjamin Gaignard 
---
 drivers/gpu/drm/sti/sti_drv.c  | 146 +
 drivers/gpu/drm/sti/sti_drv.h  |   1 +
 drivers/gpu/drm/sti/sti_dvo.c  |   7 --
 drivers/gpu/drm/sti/sti_hda.c  |   8 +--
 drivers/gpu/drm/sti/sti_hdmi.c |  21 +-
 5 files changed, 108 insertions(+), 75 deletions(-)

diff --git a/drivers/gpu/drm/sti/sti_drv.c b/drivers/gpu/drm/sti/sti_drv.c
index dd2c400..e6b3a7d 100644
--- a/drivers/gpu/drm/sti/sti_drv.c
+++ b/drivers/gpu/drm/sti/sti_drv.c
@@ -226,8 +226,28 @@ static int sti_atomic_commit(struct drm_device *drm,
return 0;
 }

+static void sti_output_poll_changed(struct drm_device *ddev)
+{
+   struct sti_private *private = ddev->dev_private;
+
+   if (!ddev->mode_config.num_connector)
+   return;
+
+   if (private->fbdev) {
+   drm_fbdev_cma_hotplug_event(private->fbdev);
+   return;
+   }
+
+   private->fbdev = drm_fbdev_cma_init(ddev, 32,
+   ddev->mode_config.num_crtc,
+   ddev->mode_config.num_connector);
+   if (IS_ERR(private->fbdev))
+   private->fbdev = NULL;
+}
+
 static const struct drm_mode_config_funcs sti_mode_config_funcs = {
.fb_create = drm_fb_cma_create,
+   .output_poll_changed = sti_output_poll_changed,
.atomic_check = drm_atomic_helper_check,
.atomic_commit = sti_atomic_commit,
 };
@@ -248,45 +268,6 @@ static void sti_mode_config_init(struct drm_device *dev)
dev->mode_config.funcs = &sti_mode_config_funcs;
 }

-static int sti_load(struct drm_device *dev, unsigned long flags)
-{
-   struct sti_private *private;
-   int ret;
-
-   private = kzalloc(sizeof(*private), GFP_KERNEL);
-   if (!private) {
-   DRM_ERROR("Failed to allocate private\n");
-   return -ENOMEM;
-   }
-   dev->dev_private = (void *)private;
-   private->drm_dev = dev;
-
-   mutex_init(&private->commit.lock);
-   INIT_WORK(&private->commit.work, sti_atomic_work);
-
-   drm_mode_config_init(dev);
-   drm_kms_helper_poll_init(dev);
-
-   sti_mode_config_init(dev);
-
-   ret = component_bind_all(dev->dev, dev);
-   if (ret) {
-   drm_kms_helper_poll_fini(dev);
-   drm_mode_config_cleanup(dev);
-   kfree(private);
-   return ret;
-   }
-
-   drm_mode_config_reset(dev);
-
-   drm_helper_disable_unused_functions(dev);
-   drm_fbdev_cma_init(dev, 32,
-  dev->mode_config.num_crtc,
-  dev->mode_config.num_connector);
-
-   return 0;
-}
-
 static const struct file_operations sti_driver_fops = {
.owner = THIS_MODULE,
.open = drm_open,
@@ -303,7 +284,6 @@ static const struct file_operations sti_driver_fops = {
 static struct drm_driver sti_driver = {
.driver_features = DRIVER_HAVE_IRQ | DRIVER_MODESET |
DRIVER_GEM | DRIVER_PRIME | DRIVER_ATOMIC,
-   .load = sti_load,
.gem_free_object_unlocked = drm_gem_cma_free_object,
.gem_vm_ops = &drm_gem_cma_vm_ops,
.dumb_create = drm_gem_cma_dumb_create,
@@ -340,14 +320,96 @@ static int compare_of(struct device *dev, void *data)
return dev->of_node == data;
 }

+static int sti_init(struct drm_device *ddev)
+{
+   struct sti_private *private;
+
+   private = kzalloc(sizeof(*private), GFP_KERNEL);
+   if (!private)
+   return -ENOMEM;
+
+   ddev->dev_private = (void *)private;
+   dev_set_drvdata(ddev->dev, ddev);
+   private->drm_dev = ddev;
+
+   mutex_init(&private->commit.lock);
+   INIT_WORK(&private->commit.work, sti_atomic_work);
+
+   drm_mode_config_init(ddev);
+
+   sti_mode_config_init(ddev);
+
+   drm_kms_helper_poll_init(ddev);
+
+   return 0;
+}
+
+static void sti_cleanup(struct drm_device *ddev)
+{
+   struct sti_private *private = ddev->dev_private;
+
+   if (private->fbdev) {
+   drm_fbdev_cma_fini(private->fbdev);
+   private->fbdev = NULL;
+   }
+
+   drm_kms_helper_poll_fini(ddev);
+   drm_vblank_cleanup(ddev);
+   drm_mode_config_cleanup(ddev);
+   kfree(private);
+   ddev->dev_private = NULL;
+}
+
 static int sti_bind(struct device *dev)
 {
-   return drm_platform_init(&sti_driver, to_platform_device(dev));
+   struct drm_device *ddev;
+   int ret;
+
+   ddev = drm_dev_alloc(&sti_driver, dev);
+   if (!ddev)
+   return -ENOMEM;
+
+   drm_dev_set_unique(ddev, dev_name(dev));
+
+   ddev->platformdev = to_platform_device(dev);
+
+   ret = sti_init(ddev);
+   if (ret)
+   goto err_d

[PATCH 2/2] drm/sti: adjust delay for AWG

2016-06-17 Thread Benjamin Gaignard
From: Bich Hemon 

Compensate delay introduced by AWG IP during DE generation

Signed-off-by: Bich Hemon 
Reviewed-by: Vincent ABRIOU 
---
 drivers/gpu/drm/sti/sti_awg_utils.c | 4 +++-
 drivers/gpu/drm/sti/sti_vtg.c   | 2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/sti/sti_awg_utils.c 
b/drivers/gpu/drm/sti/sti_awg_utils.c
index a516eb8..2da7d68 100644
--- a/drivers/gpu/drm/sti/sti_awg_utils.c
+++ b/drivers/gpu/drm/sti/sti_awg_utils.c
@@ -6,6 +6,8 @@

 #include "sti_awg_utils.h"

+#define AWG_DELAY (-5)
+
 #define AWG_OPCODE_OFFSET 10
 #define AWG_MAX_ARG   0x3ff

@@ -125,7 +127,7 @@ static int awg_generate_line_signal(
val = timing->blanking_level;
ret |= awg_generate_instr(RPLSET, val, 0, 0, fwparams);

-   val = timing->trailing_pixels - 1;
+   val = timing->trailing_pixels - 1 + AWG_DELAY;
ret |= awg_generate_instr(SKIP, val, 0, 0, fwparams);
}

diff --git a/drivers/gpu/drm/sti/sti_vtg.c b/drivers/gpu/drm/sti/sti_vtg.c
index 6bf4ce4..957ce71 100644
--- a/drivers/gpu/drm/sti/sti_vtg.c
+++ b/drivers/gpu/drm/sti/sti_vtg.c
@@ -65,7 +65,7 @@
 #define HDMI_DELAY  (5)

 /* Delay introduced by the DVO in nb of pixel */
-#define DVO_DELAY   (2)
+#define DVO_DELAY   (7)

 /* delay introduced by the Arbitrary Waveform Generator in nb of pixels */
 #define AWG_DELAY_HD(-9)
-- 
1.9.1



[RFC PATCH 10/13] drm/tegra: Add pinctrl support for DPAUX

2016-06-17 Thread Jon Hunter


On 17/06/16 13:03, Jon Hunter wrote:
> The DPAUX pins are shared with an internal I2C controller. To allow
> these pins to be muxed to the I2C controller, register a pinctrl device
> for the DPAUX device. Make Tegra DRM support dependent on PINCTRL to
> avoid any compilation issues.

I forgot to add a comment here to say that this is based upon work from
Thierry Reding and give credit for that.

Cheers
Jon

-- 
nvpublic


[PATCH v6 8/8] dt-bindings: drm/bridge: Update bindings for ADV7533

2016-06-17 Thread Archit Taneja
Add description of ADV7533. Add the required and optional properties that
are specific to it.

Cc: devicetree at vger.kernel.org

Acked-by: Rob Herring 

Signed-off-by: Archit Taneja 
---
 .../bindings/display/bridge/adi,adv7511.txt| 26 +-
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt 
b/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt
index 96c25ee..6532a59 100644
--- a/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt
+++ b/Documentation/devicetree/bindings/display/bridge/adi,adv7511.txt
@@ -1,13 +1,19 @@
-Analog Device ADV7511(W)/13 HDMI Encoders
+Analog Device ADV7511(W)/13/33 HDMI Encoders
 -

-The ADV7511, ADV7511W and ADV7513 are HDMI audio and video transmitters
+The ADV7511, ADV7511W, ADV7513 and ADV7533 are HDMI audio and video 
transmitters
 compatible with HDMI 1.4 and DVI 1.0. They support color space conversion,
-S/PDIF, CEC and HDCP.
+S/PDIF, CEC and HDCP. ADV7533 supports the DSI interface for input pixels, 
while
+the others support RGB interface.

 Required properties:

-- compatible: Should be one of "adi,adv7511", "adi,adv7511w" or "adi,adv7513"
+- compatible: Should be one of:
+   "adi,adv7511"
+   "adi,adv7511w"
+   "adi,adv7513"
+   "adi,adv7533"
+
 - reg: I2C slave address

 The ADV7511 supports a large number of input data formats that differ by their
@@ -32,6 +38,11 @@ The following input format properties are required except in 
"rgb 1x" and
 - adi,input-justification: The input bit justification ("left", "evenly",
   "right").

+The following properties are required for ADV7533:
+
+- adi,dsi-lanes: Number of DSI data lanes connected to the DSI host. It should
+  be one of 1, 2, 3 or 4.
+
 Optional properties:

 - interrupts: Specifier for the ADV7511 interrupt
@@ -42,13 +53,18 @@ Optional properties:
 - adi,embedded-sync: The input uses synchronization signals embedded in the
   data stream (similar to BT.656). Defaults to separate H/V synchronization
   signals.
+- adi,disable-timing-generator: Only for ADV7533. Disables the internal timing
+  generator. The chip will rely on the sync signals in the DSI data lanes,
+  rather than generate its own timings for HDMI output.

 Required nodes:

 The ADV7511 has two video ports. Their connections are modelled using the OF
 graph bindings specified in Documentation/devicetree/bindings/graph.txt.

-- Video port 0 for the RGB or YUV input
+- Video port 0 for the RGB, YUV or DSI input. In the case of ADV7533, the
+  remote endpoint phandle should be a reference to a valid mipi_dsi_host device
+  node.
 - Video port 1 for the HDMI output


-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH v6 7/8] drm/bridge: adv7533: Change number of DSI lanes dynamically

2016-06-17 Thread Archit Taneja
Lower modes on ADV7533 require lower number of DSI lanes for correct
operation. If ADV7533 is being used with 4 DSI lanes, then switch the
lanes to 3 when the target mode's pixel clock is less than 80 Mhz.

Based on patch by Andy Green 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/bridge/adv7511/adv7511.h |  6 ++
 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c |  3 +++
 drivers/gpu/drm/bridge/adv7511/adv7533.c | 22 ++
 3 files changed, 31 insertions(+)

diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511.h 
b/drivers/gpu/drm/bridge/adv7511/adv7511.h
index 90a8c09..161c923 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511.h
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511.h
@@ -339,6 +339,7 @@ struct adv7511 {
 #ifdef CONFIG_DRM_I2C_ADV7533
 void adv7533_dsi_power_on(struct adv7511 *adv);
 void adv7533_dsi_power_off(struct adv7511 *adv);
+void adv7533_mode_set(struct adv7511 *adv, struct drm_display_mode *mode);
 int adv7533_patch_registers(struct adv7511 *adv);
 void adv7533_uninit_cec(struct adv7511 *adv);
 int adv7533_init_cec(struct adv7511 *adv);
@@ -354,6 +355,11 @@ static inline void adv7533_dsi_power_off(struct adv7511 
*adv)
 {
 }

+static inline void adv7533_mode_set(struct adv7511 *adv,
+   struct drm_display_mode *mode)
+{
+}
+
 static inline int adv7533_patch_registers(struct adv7511 *adv)
 {
return -ENODEV;
diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c 
b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
index e0c353e..ec8fb2e 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
@@ -712,6 +712,9 @@ static void adv7511_mode_set(struct adv7511 *adv7511,
regmap_update_bits(adv7511->regmap, 0x17,
0x60, (vsync_polarity << 6) | (hsync_polarity << 5));

+   if (adv7511->type == ADV7533)
+   adv7533_mode_set(adv7511, adj_mode);
+
drm_mode_copy(&adv7511->curr_mode, adj_mode);

/*
diff --git a/drivers/gpu/drm/bridge/adv7511/adv7533.c 
b/drivers/gpu/drm/bridge/adv7511/adv7533.c
index d002ac4..5eebd15 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7533.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7533.c
@@ -115,6 +115,28 @@ void adv7533_dsi_power_off(struct adv7511 *adv)
regmap_write(adv->regmap_cec, 0x27, 0x0b);
 }

+void adv7533_mode_set(struct adv7511 *adv, struct drm_display_mode *mode)
+{
+   struct mipi_dsi_device *dsi = adv->dsi;
+   int lanes, ret;
+
+   if (adv->num_dsi_lanes != 4)
+   return;
+
+   if (mode->clock > 8)
+   lanes = 4;
+   else
+   lanes = 3;
+
+   if (lanes != dsi->lanes) {
+   mipi_dsi_detach(dsi);
+   dsi->lanes = lanes;
+   ret = mipi_dsi_attach(dsi);
+   if (ret)
+   dev_err(&dsi->dev, "failed to change host lanes\n");
+   }
+}
+
 int adv7533_patch_registers(struct adv7511 *adv)
 {
return regmap_register_patch(adv->regmap,
-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH v6 6/8] drm/bridge: adv7533: Use internal timing generator

2016-06-17 Thread Archit Taneja
ADV7533 provides an internal timing generator for certain modes that it
can't use the DSI clock directly.

We've observed that HDMI is more stable with the internal timing
generator, especially if there are instabilities in the DSI clock source.
The data spec also seems to recommend the usage of the timing generator
for all modes.

However, on some platforms, it's reported that enabling the timing
generator causes instabilities with the HDMI output.

Create a DT parameter that lets a platform explicitly disable the timing
generator. The timing generator is enabled by default.

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/bridge/adv7511/adv7511.h |  3 ++
 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c |  2 +
 drivers/gpu/drm/bridge/adv7511/adv7533.c | 60 +++-
 3 files changed, 63 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511.h 
b/drivers/gpu/drm/bridge/adv7511/adv7511.h
index 3e4d47a..90a8c09 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511.h
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511.h
@@ -306,6 +306,8 @@ struct adv7511 {
enum drm_connector_status status;
bool powered;

+   struct drm_display_mode curr_mode;
+
unsigned int f_tmds;

unsigned int current_edid_segment;
@@ -329,6 +331,7 @@ struct adv7511 {
struct device_node *host_node;
struct mipi_dsi_device *dsi;
u8 num_dsi_lanes;
+   bool use_timing_gen;

enum adv7511_type type;
 };
diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c 
b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
index 6586c52..e0c353e 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
@@ -712,6 +712,8 @@ static void adv7511_mode_set(struct adv7511 *adv7511,
regmap_update_bits(adv7511->regmap, 0x17,
0x60, (vsync_polarity << 6) | (hsync_polarity << 5));

+   drm_mode_copy(&adv7511->curr_mode, adj_mode);
+
/*
 * TODO Test first order 4:2:2 to 4:4:4 up conversion method, which is
 * supposed to give better results.
diff --git a/drivers/gpu/drm/bridge/adv7511/adv7533.c 
b/drivers/gpu/drm/bridge/adv7511/adv7533.c
index ecbcaa0..d002ac4 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7533.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7533.c
@@ -39,14 +39,65 @@ static const struct regmap_config adv7533_cec_regmap_config 
= {
.cache_type = REGCACHE_RBTREE,
 };

+static void adv7511_dsi_config_timing_gen(struct adv7511 *adv)
+{
+   struct mipi_dsi_device *dsi = adv->dsi;
+   struct drm_display_mode *mode = &adv->curr_mode;
+   unsigned int hsw, hfp, hbp, vsw, vfp, vbp;
+   u8 clock_div_by_lanes[] = { 6, 4, 3 };  /* 2, 3, 4 lanes */
+
+   hsw = mode->hsync_end - mode->hsync_start;
+   hfp = mode->hsync_start - mode->hdisplay;
+   hbp = mode->htotal - mode->hsync_end;
+   vsw = mode->vsync_end - mode->vsync_start;
+   vfp = mode->vsync_start - mode->vdisplay;
+   vbp = mode->vtotal - mode->vsync_end;
+
+   /* set pixel clock divider mode */
+   regmap_write(adv->regmap_cec, 0x16,
+clock_div_by_lanes[dsi->lanes - 2] << 3);
+
+   /* horizontal porch params */
+   regmap_write(adv->regmap_cec, 0x28, mode->htotal >> 4);
+   regmap_write(adv->regmap_cec, 0x29, (mode->htotal << 4) & 0xff);
+   regmap_write(adv->regmap_cec, 0x2a, hsw >> 4);
+   regmap_write(adv->regmap_cec, 0x2b, (hsw << 4) & 0xff);
+   regmap_write(adv->regmap_cec, 0x2c, hfp >> 4);
+   regmap_write(adv->regmap_cec, 0x2d, (hfp << 4) & 0xff);
+   regmap_write(adv->regmap_cec, 0x2e, hbp >> 4);
+   regmap_write(adv->regmap_cec, 0x2f, (hbp << 4) & 0xff);
+
+   /* vertical porch params */
+   regmap_write(adv->regmap_cec, 0x30, mode->vtotal >> 4);
+   regmap_write(adv->regmap_cec, 0x31, (mode->vtotal << 4) & 0xff);
+   regmap_write(adv->regmap_cec, 0x32, vsw >> 4);
+   regmap_write(adv->regmap_cec, 0x33, (vsw << 4) & 0xff);
+   regmap_write(adv->regmap_cec, 0x34, vfp >> 4);
+   regmap_write(adv->regmap_cec, 0x35, (vfp << 4) & 0xff);
+   regmap_write(adv->regmap_cec, 0x36, vbp >> 4);
+   regmap_write(adv->regmap_cec, 0x37, (vbp << 4) & 0xff);
+}
+
 void adv7533_dsi_power_on(struct adv7511 *adv)
 {
struct mipi_dsi_device *dsi = adv->dsi;

+   if (adv->use_timing_gen)
+   adv7511_dsi_config_timing_gen(adv);
+
/* set number of dsi lanes */
regmap_write(adv->regmap_cec, 0x1c, dsi->lanes << 4);
-   /* disable internal timing generator */
-   regmap_write(adv->regmap_cec, 0x27, 0x0b);
+
+   if (adv->use_timing_gen) {
+   /* reset internal timing generator */
+   regmap_write(adv->regmap_cec, 0x27, 0xcb);
+   regmap_write(adv->regmap_cec, 0x27, 0x8b);
+   regmap_write(adv->regmap_cec, 0x27, 0xcb);
+   } else {
+   /* disable internal timi

[PATCH v6 5/8] drm/bridge: adv7533: Create a MIPI DSI device

2016-06-17 Thread Archit Taneja
In order to pass DSI specific parameters to the DSI host, we need the
driver to create a mipi_dsi_device DSI device that attaches to the
host.

Use of_graph helpers to get the DSI host DT node. Create a MIPI DSI
device using this host. Finally, attach this device to the DSI host.

Populate DT parameters (number of data lanes for now) that are required
for DSI RX to work correctly. Hardcode few other parameters (rgb,
embedded_sync) for now.

Select DRM_MIPI_DSI config option only when ADV7533 support is enabled.

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/bridge/adv7511/Kconfig   |  1 +
 drivers/gpu/drm/bridge/adv7511/adv7511.h | 23 +++
 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 40 ++--
 drivers/gpu/drm/bridge/adv7511/adv7533.c | 91 +++-
 4 files changed, 147 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/bridge/adv7511/Kconfig 
b/drivers/gpu/drm/bridge/adv7511/Kconfig
index eb84419..d2b0499 100644
--- a/drivers/gpu/drm/bridge/adv7511/Kconfig
+++ b/drivers/gpu/drm/bridge/adv7511/Kconfig
@@ -9,6 +9,7 @@ config DRM_I2C_ADV7511
 config DRM_I2C_ADV7533
bool "ADV7533 encoder"
depends on DRM_I2C_ADV7511
+   select DRM_MIPI_DSI
default y
help
  Support for the Analog Devices ADV7533 DSI to HDMI encoder.
diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511.h 
b/drivers/gpu/drm/bridge/adv7511/adv7511.h
index 5dea769..3e4d47a 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511.h
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511.h
@@ -14,6 +14,7 @@
 #include 

 #include 
+#include 

 #define ADV7511_REG_CHIP_REVISION  0x00
 #define ADV7511_REG_N0 0x01
@@ -324,6 +325,11 @@ struct adv7511 {

struct gpio_desc *gpio_pd;

+   /* ADV7533 DSI RX related params */
+   struct device_node *host_node;
+   struct mipi_dsi_device *dsi;
+   u8 num_dsi_lanes;
+
enum adv7511_type type;
 };

@@ -333,6 +339,9 @@ void adv7533_dsi_power_off(struct adv7511 *adv);
 int adv7533_patch_registers(struct adv7511 *adv);
 void adv7533_uninit_cec(struct adv7511 *adv);
 int adv7533_init_cec(struct adv7511 *adv);
+int adv7533_attach_dsi(struct adv7511 *adv);
+void adv7533_detach_dsi(struct adv7511 *adv);
+int adv7533_parse_dt(struct device_node *np, struct adv7511 *adv);
 #else
 static inline void adv7533_dsi_power_on(struct adv7511 *adv)
 {
@@ -355,6 +364,20 @@ static inline int adv7533_init_cec(struct adv7511 *adv)
 {
return -ENODEV;
 }
+
+static inline int adv7533_attach_dsi(struct adv7511 *adv)
+{
+   return -ENODEV;
+}
+
+static inline void adv7533_detach_dsi(struct adv7511 *adv)
+{
+}
+
+static inline int adv7533_parse_dt(struct device_node *np, struct adv7511 *adv)
+{
+   return -ENODEV;
+}
 #endif

 #endif /* __DRM_I2C_ADV7511_H__ */
diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c 
b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
index e33702b..6586c52 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
@@ -817,6 +817,9 @@ static int adv7511_bridge_attach(struct drm_bridge *bridge)
 &adv7511_connector_helper_funcs);
drm_mode_connector_attach_encoder(&adv->connector, bridge->encoder);

+   if (adv->type == ADV7533)
+   ret = adv7533_attach_dsi(adv);
+
return ret;
 }

@@ -943,11 +946,12 @@ static int adv7511_probe(struct i2c_client *i2c, const 
struct i2c_device_id *id)

memset(&link_config, 0, sizeof(link_config));

-   if (adv7511->type == ADV7511) {
+   if (adv7511->type == ADV7511)
ret = adv7511_parse_dt(dev->of_node, &link_config);
-   if (ret)
-   return ret;
-   }
+   else
+   ret = adv7533_parse_dt(dev->of_node, adv7511);
+   if (ret)
+   return ret;

/*
 * The power down GPIO is optional. If present, toggle it from active to
@@ -1042,9 +1046,13 @@ static int adv7511_remove(struct i2c_client *i2c)
 {
struct adv7511 *adv7511 = i2c_get_clientdata(i2c);

+   if (adv7511->type == ADV7533) {
+   adv7533_detach_dsi(adv7511);
+   adv7533_uninit_cec(adv7511);
+   }
+
drm_bridge_remove(&adv7511->bridge);

-   adv7533_uninit_cec(adv7511);
i2c_unregister_device(adv7511->i2c_edid);

kfree(adv7511->edid);
@@ -1074,6 +1082,10 @@ static const struct of_device_id adv7511_of_ids[] = {
 };
 MODULE_DEVICE_TABLE(of, adv7511_of_ids);

+static struct mipi_dsi_driver adv7533_dsi_driver = {
+   .driver.name = "adv7533",
+};
+
 static struct i2c_driver adv7511_driver = {
.driver = {
.name = "adv7511",
@@ -1084,7 +1096,23 @@ static struct i2c_driver adv7511_driver = {
.remove = adv7511_remove,
 };

-module_i2c_driver(adv7511_driver);
+static int __init adv7511_init(void)
+{
+   if (IS_ENABLED(CONFIG_DRM_MIPI_DSI))
+   

[PATCH v6 4/8] drm/bridge: adv7533: Initial support for ADV7533

2016-06-17 Thread Archit Taneja
ADV7533 is a DSI to HDMI encoder chip. It is a derivative of ADV7511,
with additional blocks to translate input DSI data to parallel RGB
data. Besides the ADV7511 I2C register map, it has additional registers
that require to be configured to activate the DSI Rx block.

Create a new config that enables ADV7533 support. Use DT compatible
strings to populate the ADV7533 type enum. Add minimal register
configurations belonging to the DSI/CEC register map. Keep the ADV7533
code in a separate file.

Originally worked on by Lars-Peter Clausen 

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/bridge/adv7511/Kconfig   |   7 ++
 drivers/gpu/drm/bridge/adv7511/Makefile  |   1 +
 drivers/gpu/drm/bridge/adv7511/adv7511.h |  71 +++
 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 100 ++-
 drivers/gpu/drm/bridge/adv7511/adv7533.c | 100 +++
 5 files changed, 230 insertions(+), 49 deletions(-)
 create mode 100644 drivers/gpu/drm/bridge/adv7511/adv7533.c

diff --git a/drivers/gpu/drm/bridge/adv7511/Kconfig 
b/drivers/gpu/drm/bridge/adv7511/Kconfig
index 222c6cc..eb84419 100644
--- a/drivers/gpu/drm/bridge/adv7511/Kconfig
+++ b/drivers/gpu/drm/bridge/adv7511/Kconfig
@@ -5,3 +5,10 @@ config DRM_I2C_ADV7511
select REGMAP_I2C
help
  Support for the Analog Device ADV7511(W) and ADV7513 HDMI encoders.
+
+config DRM_I2C_ADV7533
+   bool "ADV7533 encoder"
+   depends on DRM_I2C_ADV7511
+   default y
+   help
+ Support for the Analog Devices ADV7533 DSI to HDMI encoder.
diff --git a/drivers/gpu/drm/bridge/adv7511/Makefile 
b/drivers/gpu/drm/bridge/adv7511/Makefile
index 692f83a..9019327 100644
--- a/drivers/gpu/drm/bridge/adv7511/Makefile
+++ b/drivers/gpu/drm/bridge/adv7511/Makefile
@@ -1,2 +1,3 @@
 adv7511-y := adv7511_drv.o
+adv7511-$(CONFIG_DRM_I2C_ADV7533) += adv7533.o
 obj-$(CONFIG_DRM_I2C_ADV7511) += adv7511.o
diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511.h 
b/drivers/gpu/drm/bridge/adv7511/adv7511.h
index 38515b3..5dea769 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511.h
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511.h
@@ -10,6 +10,10 @@
 #define __DRM_I2C_ADV7511_H__

 #include 
+#include 
+#include 
+
+#include 

 #define ADV7511_REG_CHIP_REVISION  0x00
 #define ADV7511_REG_N0 0x01
@@ -286,4 +290,71 @@ struct adv7511_video_config {
struct hdmi_avi_infoframe avi_infoframe;
 };

+enum adv7511_type {
+   ADV7511,
+   ADV7533,
+};
+
+struct adv7511 {
+   struct i2c_client *i2c_main;
+   struct i2c_client *i2c_edid;
+   struct i2c_client *i2c_cec;
+
+   struct regmap *regmap;
+   struct regmap *regmap_cec;
+   enum drm_connector_status status;
+   bool powered;
+
+   unsigned int f_tmds;
+
+   unsigned int current_edid_segment;
+   uint8_t edid_buf[256];
+   bool edid_read;
+
+   wait_queue_head_t wq;
+   struct drm_bridge bridge;
+   struct drm_connector connector;
+
+   bool embedded_sync;
+   enum adv7511_sync_polarity vsync_polarity;
+   enum adv7511_sync_polarity hsync_polarity;
+   bool rgb;
+
+   struct edid *edid;
+
+   struct gpio_desc *gpio_pd;
+
+   enum adv7511_type type;
+};
+
+#ifdef CONFIG_DRM_I2C_ADV7533
+void adv7533_dsi_power_on(struct adv7511 *adv);
+void adv7533_dsi_power_off(struct adv7511 *adv);
+int adv7533_patch_registers(struct adv7511 *adv);
+void adv7533_uninit_cec(struct adv7511 *adv);
+int adv7533_init_cec(struct adv7511 *adv);
+#else
+static inline void adv7533_dsi_power_on(struct adv7511 *adv)
+{
+}
+
+static inline void adv7533_dsi_power_off(struct adv7511 *adv)
+{
+}
+
+static inline int adv7533_patch_registers(struct adv7511 *adv)
+{
+   return -ENODEV;
+}
+
+static inline void adv7533_uninit_cec(struct adv7511 *adv)
+{
+}
+
+static inline int adv7533_init_cec(struct adv7511 *adv)
+{
+   return -ENODEV;
+}
+#endif
+
 #endif /* __DRM_I2C_ADV7511_H__ */
diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c 
b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
index 1fff0ab..e33702b 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
@@ -8,48 +8,17 @@

 #include 
 #include 
-#include 
 #include 
-#include 
+#include 
 #include 

 #include 
 #include 
 #include 
-#include 
 #include 

 #include "adv7511.h"

-struct adv7511 {
-   struct i2c_client *i2c_main;
-   struct i2c_client *i2c_edid;
-
-   struct regmap *regmap;
-   struct regmap *packet_memory_regmap;
-   enum drm_connector_status status;
-   bool powered;
-
-   unsigned int f_tmds;
-
-   unsigned int current_edid_segment;
-   uint8_t edid_buf[256];
-   bool edid_read;
-
-   wait_queue_head_t wq;
-   struct drm_bridge bridge;
-   struct drm_connector connector;
-
-   bool embedded_sync;
-   enum adv7511_sync_polarity vsync_polarity;
-   enum adv751

[PATCH v6 3/8] drm/bridge: adv7511: Fix mutex deadlock when interrupts are disabled

2016-06-17 Thread Archit Taneja
When the adv7511 i2c client doesn't have an interrupt line, we observe a
deadlock on caused by trying to lock drm device's mode_config.mutex twice
in the same context.

Here is the sequence that causes it:

ioctl DRM_IOCTL_MODE_GETCONNECTOR from userspace
  drm_mode_getconnector (acquires mode_config mutex)
connector->fill_modes()
drm_helper_probe_single_connector_modes
  connector_funcs->get_modes
adv7511_encoder_get_modes
  adv7511_get_edid_block
adv7511_irq_process
  drm_helper_hpd_irq_event (acquires mode_config mutex again)

In adv7511_irq_process, don't call drm_helper_hpd_irq_event when not
called from the interrupt handler. It doesn't serve any purpose there
anyway.

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c 
b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
index c2642f9..1fff0ab 100644
--- a/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
@@ -427,7 +427,7 @@ static bool adv7511_hpd(struct adv7511 *adv7511)
return false;
 }

-static int adv7511_irq_process(struct adv7511 *adv7511)
+static int adv7511_irq_process(struct adv7511 *adv7511, bool process_hpd)
 {
unsigned int irq0, irq1;
int ret;
@@ -443,7 +443,7 @@ static int adv7511_irq_process(struct adv7511 *adv7511)
regmap_write(adv7511->regmap, ADV7511_REG_INT(0), irq0);
regmap_write(adv7511->regmap, ADV7511_REG_INT(1), irq1);

-   if (irq0 & ADV7511_INT0_HPD && adv7511->bridge.encoder)
+   if (process_hpd && irq0 & ADV7511_INT0_HPD && adv7511->bridge.encoder)
drm_helper_hpd_irq_event(adv7511->connector.dev);

if (irq0 & ADV7511_INT0_EDID_READY || irq1 & ADV7511_INT1_DDC_ERROR) {
@@ -461,7 +461,7 @@ static irqreturn_t adv7511_irq_handler(int irq, void *devid)
struct adv7511 *adv7511 = devid;
int ret;

-   ret = adv7511_irq_process(adv7511);
+   ret = adv7511_irq_process(adv7511, true);
return ret < 0 ? IRQ_NONE : IRQ_HANDLED;
 }

@@ -478,7 +478,7 @@ static int adv7511_wait_for_edid(struct adv7511 *adv7511, 
int timeout)
adv7511->edid_read, msecs_to_jiffies(timeout));
} else {
for (; timeout > 0; timeout -= 25) {
-   ret = adv7511_irq_process(adv7511);
+   ret = adv7511_irq_process(adv7511, false);
if (ret < 0)
break;

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCH v6 2/8] drm/i2c: adv7511: Move to bridge folder

2016-06-17 Thread Archit Taneja
The driver has been converted to use drm_bridge instead of
drm_i2c_slave_encoder. We can now move it to the bridge folder.

Create a separate folder since we already have a couple of files and
expect more when we support audio and ADV7533.

Rename the driver to adv7511_drv.c. This will come in handy later
when the driver module will need to be built from multiple object
files.

Signed-off-by: Archit Taneja 
---
v6:
- New patch

 drivers/gpu/drm/bridge/Kconfig   |2 +
 drivers/gpu/drm/bridge/Makefile  |1 +
 drivers/gpu/drm/bridge/adv7511/Kconfig   |7 +
 drivers/gpu/drm/bridge/adv7511/Makefile  |2 +
 drivers/gpu/drm/bridge/adv7511/adv7511.h |  289 +++
 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c | 1089 ++
 drivers/gpu/drm/i2c/Kconfig  |7 -
 drivers/gpu/drm/i2c/Makefile |2 -
 drivers/gpu/drm/i2c/adv7511.c| 1089 --
 drivers/gpu/drm/i2c/adv7511.h|  289 ---
 10 files changed, 1390 insertions(+), 1387 deletions(-)
 create mode 100644 drivers/gpu/drm/bridge/adv7511/Kconfig
 create mode 100644 drivers/gpu/drm/bridge/adv7511/Makefile
 create mode 100644 drivers/gpu/drm/bridge/adv7511/adv7511.h
 create mode 100644 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
 delete mode 100644 drivers/gpu/drm/i2c/adv7511.c
 delete mode 100644 drivers/gpu/drm/i2c/adv7511.h

diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index 8f7423f..9ac6427 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -52,4 +52,6 @@ config DRM_PARADE_PS8622

 source "drivers/gpu/drm/bridge/analogix/Kconfig"

+source "drivers/gpu/drm/bridge/adv7511/Kconfig"
+
 endmenu
diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
index 96b13b3..94e7d2f 100644
--- a/drivers/gpu/drm/bridge/Makefile
+++ b/drivers/gpu/drm/bridge/Makefile
@@ -6,3 +6,4 @@ obj-$(CONFIG_DRM_DW_HDMI_AHB_AUDIO) += dw-hdmi-ahb-audio.o
 obj-$(CONFIG_DRM_NXP_PTN3460) += nxp-ptn3460.o
 obj-$(CONFIG_DRM_PARADE_PS8622) += parade-ps8622.o
 obj-$(CONFIG_DRM_ANALOGIX_DP) += analogix/
+obj-$(CONFIG_DRM_I2C_ADV7511) += adv7511/
diff --git a/drivers/gpu/drm/bridge/adv7511/Kconfig 
b/drivers/gpu/drm/bridge/adv7511/Kconfig
new file mode 100644
index 000..222c6cc
--- /dev/null
+++ b/drivers/gpu/drm/bridge/adv7511/Kconfig
@@ -0,0 +1,7 @@
+config DRM_I2C_ADV7511
+   tristate "AV7511 encoder"
+   depends on OF
+   select DRM_KMS_HELPER
+   select REGMAP_I2C
+   help
+ Support for the Analog Device ADV7511(W) and ADV7513 HDMI encoders.
diff --git a/drivers/gpu/drm/bridge/adv7511/Makefile 
b/drivers/gpu/drm/bridge/adv7511/Makefile
new file mode 100644
index 000..692f83a
--- /dev/null
+++ b/drivers/gpu/drm/bridge/adv7511/Makefile
@@ -0,0 +1,2 @@
+adv7511-y := adv7511_drv.o
+obj-$(CONFIG_DRM_I2C_ADV7511) += adv7511.o
diff --git a/drivers/gpu/drm/bridge/adv7511/adv7511.h 
b/drivers/gpu/drm/bridge/adv7511/adv7511.h
new file mode 100644
index 000..38515b3
--- /dev/null
+++ b/drivers/gpu/drm/bridge/adv7511/adv7511.h
@@ -0,0 +1,289 @@
+/*
+ * Analog Devices ADV7511 HDMI transmitter driver
+ *
+ * Copyright 2012 Analog Devices Inc.
+ *
+ * Licensed under the GPL-2.
+ */
+
+#ifndef __DRM_I2C_ADV7511_H__
+#define __DRM_I2C_ADV7511_H__
+
+#include 
+
+#define ADV7511_REG_CHIP_REVISION  0x00
+#define ADV7511_REG_N0 0x01
+#define ADV7511_REG_N1 0x02
+#define ADV7511_REG_N2 0x03
+#define ADV7511_REG_SPDIF_FREQ 0x04
+#define ADV7511_REG_CTS_AUTOMATIC1 0x05
+#define ADV7511_REG_CTS_AUTOMATIC2 0x06
+#define ADV7511_REG_CTS_MANUAL00x07
+#define ADV7511_REG_CTS_MANUAL10x08
+#define ADV7511_REG_CTS_MANUAL20x09
+#define ADV7511_REG_AUDIO_SOURCE   0x0a
+#define ADV7511_REG_AUDIO_CONFIG   0x0b
+#define ADV7511_REG_I2S_CONFIG 0x0c
+#define ADV7511_REG_I2S_WIDTH  0x0d
+#define ADV7511_REG_AUDIO_SUB_SRC0 0x0e
+#define ADV7511_REG_AUDIO_SUB_SRC1 0x0f
+#define ADV7511_REG_AUDIO_SUB_SRC2 0x10
+#define ADV7511_REG_AUDIO_SUB_SRC3 0x11
+#define ADV7511_REG_AUDIO_CFG1 0x12
+#define ADV7511_REG_AUDIO_CFG2 0x13
+#define ADV7511_REG_AUDIO_CFG3 0x14
+#define ADV7511_REG_I2C_FREQ_ID_CFG0x15
+#define ADV7511_REG_VIDEO_INPUT_CFG1   0x16
+#define ADV7511_REG_CSC_UPPER(x)   (0x18 + (x) * 2)
+#define ADV7511_REG_CSC_LOWER(x)   (0x19 + (x) * 2)
+#define ADV7511_REG_SYNC_DECODER(x)(0x30 + (x))
+#define ADV7511_REG_DE_GENERATOR   (0x35 + (x))
+#define ADV7511_REG_PIXEL_REPETITION   0x3b
+#define ADV7511_REG_VIC_MANUAL 0x3c
+#d

[PATCH v6 1/8] drm/i2c: adv7511: Convert to drm_bridge

2016-06-17 Thread Archit Taneja
We don't want to use the old i2c slave encoder interface anymore.

Remove that and make the i2c driver create a drm_bridge entity instead.
Converting to bridges helps because the kms drivers don't need to
exract encoder slave ops from this driver and use it within their
own encoder/connector ops.

The driver now creates its own connector when a kms driver attaches
itself to the bridge. Therefore, kms drivers don't need to create
their own connectors anymore.

The old encoder slave ops are now used by the new bridge and connector
entities.

The of_node member in drm_bridge is accessible only when CONFIG_OF is
enabled. The driver anyway only works only when OF is available. Make
the driver depend on OF in its Kconfig.

Signed-off-by: Archit Taneja 
---
 drivers/gpu/drm/i2c/Kconfig   |   1 +
 drivers/gpu/drm/i2c/adv7511.c | 213 +++---
 2 files changed, 140 insertions(+), 74 deletions(-)

diff --git a/drivers/gpu/drm/i2c/Kconfig b/drivers/gpu/drm/i2c/Kconfig
index 22c7ed6..8bb0697 100644
--- a/drivers/gpu/drm/i2c/Kconfig
+++ b/drivers/gpu/drm/i2c/Kconfig
@@ -3,6 +3,7 @@ menu "I2C encoder or helper chips"

 config DRM_I2C_ADV7511
tristate "AV7511 encoder"
+   depends on OF
select REGMAP_I2C
help
  Support for the Analog Device ADV7511(W) and ADV7513 HDMI encoders.
diff --git a/drivers/gpu/drm/i2c/adv7511.c b/drivers/gpu/drm/i2c/adv7511.c
index a02112b..c2642f9 100644
--- a/drivers/gpu/drm/i2c/adv7511.c
+++ b/drivers/gpu/drm/i2c/adv7511.c
@@ -14,9 +14,10 @@
 #include 

 #include 
+#include 
+#include 
 #include 
 #include 
-#include 

 #include "adv7511.h"

@@ -36,7 +37,8 @@ struct adv7511 {
bool edid_read;

wait_queue_head_t wq;
-   struct drm_encoder *encoder;
+   struct drm_bridge bridge;
+   struct drm_connector connector;

bool embedded_sync;
enum adv7511_sync_polarity vsync_polarity;
@@ -48,11 +50,6 @@ struct adv7511 {
struct gpio_desc *gpio_pd;
 };

-static struct adv7511 *encoder_to_adv7511(struct drm_encoder *encoder)
-{
-   return to_encoder_slave(encoder)->slave_priv;
-}
-
 /* ADI recommended values for proper operation. */
 static const struct reg_sequence adv7511_fixed_registers[] = {
{ 0x98, 0x03 },
@@ -446,8 +443,8 @@ static int adv7511_irq_process(struct adv7511 *adv7511)
regmap_write(adv7511->regmap, ADV7511_REG_INT(0), irq0);
regmap_write(adv7511->regmap, ADV7511_REG_INT(1), irq1);

-   if (irq0 & ADV7511_INT0_HPD && adv7511->encoder)
-   drm_helper_hpd_irq_event(adv7511->encoder->dev);
+   if (irq0 & ADV7511_INT0_HPD && adv7511->bridge.encoder)
+   drm_helper_hpd_irq_event(adv7511->connector.dev);

if (irq0 & ADV7511_INT0_EDID_READY || irq1 & ADV7511_INT1_DDC_ERROR) {
adv7511->edid_read = true;
@@ -563,13 +560,12 @@ static int adv7511_get_edid_block(void *data, u8 *buf, 
unsigned int block,
 }

 /* 
-
- * Encoder operations
+ * ADV75xx helpers
  */

-static int adv7511_get_modes(struct drm_encoder *encoder,
+static int adv7511_get_modes(struct adv7511 *adv7511,
 struct drm_connector *connector)
 {
-   struct adv7511 *adv7511 = encoder_to_adv7511(encoder);
struct edid *edid;
unsigned int count;

@@ -606,21 +602,9 @@ static int adv7511_get_modes(struct drm_encoder *encoder,
return count;
 }

-static void adv7511_encoder_dpms(struct drm_encoder *encoder, int mode)
-{
-   struct adv7511 *adv7511 = encoder_to_adv7511(encoder);
-
-   if (mode == DRM_MODE_DPMS_ON)
-   adv7511_power_on(adv7511);
-   else
-   adv7511_power_off(adv7511);
-}
-
 static enum drm_connector_status
-adv7511_encoder_detect(struct drm_encoder *encoder,
-  struct drm_connector *connector)
+adv7511_detect(struct adv7511 *adv7511, struct drm_connector *connector)
 {
-   struct adv7511 *adv7511 = encoder_to_adv7511(encoder);
enum drm_connector_status status;
unsigned int val;
bool hpd;
@@ -644,7 +628,7 @@ adv7511_encoder_detect(struct drm_encoder *encoder,
if (status == connector_status_connected && hpd && adv7511->powered) {
regcache_mark_dirty(adv7511->regmap);
adv7511_power_on(adv7511);
-   adv7511_get_modes(encoder, connector);
+   adv7511_get_modes(adv7511, connector);
if (adv7511->status == connector_status_connected)
status = connector_status_disconnected;
} else {
@@ -658,8 +642,8 @@ adv7511_encoder_detect(struct drm_encoder *encoder,
return status;
 }

-static int adv7511_encoder_mode_valid(struct drm_encoder *encoder,
- struct drm_display_mode *mode)
+static int adv7511_mode_valid(struct adv7511 *adv7511,
+ struct drm_display

[PATCH v6 0/8] drm/i2c: adv7511: ADV7533 support

2016-06-17 Thread Archit Taneja
ADV7533 is a DSI to HDMI encoder chip. It's like ADV7511, but with an
additional DSI RX block that takes in DSI video mode output.

This revision is quite similar to the previous version with some
issues fixed.

Changes in v6:
- v5 changed the adv7511 module name to adv75xx.ko, it was previously
  called adv7511.ko. This revision fixes the Makefile such that the
  module name doesn't change, and hence not break userspace.
- Move the driver to the drivers/gpu/drm/bridge folder. This was
  planned to be done later, but I thought it would be better if we
  did it in this patchset itself since the driver is already converted
  to a bridge.

Changes in v5:
- Fix break observed when built for x86.
- Based off current drm-misc. 
- Removes best_encoder connector helper function since it isn't needed
  after this series:
  https://lkml.org/lkml/2016/6/2/508

Changes in v4:
- Separated out build for ADV7533. The original plan was to stub out the
  drm_mipi_dsi funcs, but that seemed like an overkill since it helped
  just this driver. It seems better to stub out the ADV7533 functionality
  altogether instead.
- Some minor DT binding corrections suggested by Laurent.

Archit Taneja (8):
  drm/i2c: adv7511: Convert to drm_bridge
  drm/i2c: adv7511: Move to bridge folder
  drm/bridge: adv7511: Fix mutex deadlock when interrupts are disabled
  drm/bridge: adv7533: Initial support for ADV7533
  drm/bridge: adv7533: Create a MIPI DSI device
  drm/bridge: adv7533: Use internal timing generator
  drm/bridge: adv7533: Change number of DSI lanes dynamically
  dt-bindings: drm/bridge: Update bindings for ADV7533

 .../bindings/display/bridge/adi,adv7511.txt|   26 +-
 drivers/gpu/drm/bridge/Kconfig |2 +
 drivers/gpu/drm/bridge/Makefile|1 +
 drivers/gpu/drm/bridge/adv7511/Kconfig |   15 +
 drivers/gpu/drm/bridge/adv7511/Makefile|3 +
 drivers/gpu/drm/bridge/adv7511/adv7511.h   |  392 +++
 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c   | 1124 
 drivers/gpu/drm/bridge/adv7511/adv7533.c   |  265 +
 drivers/gpu/drm/i2c/Kconfig|6 -
 drivers/gpu/drm/i2c/Makefile   |2 -
 drivers/gpu/drm/i2c/adv7511.c  | 1024 --
 drivers/gpu/drm/i2c/adv7511.h  |  289 -
 12 files changed, 1823 insertions(+), 1326 deletions(-)
 create mode 100644 drivers/gpu/drm/bridge/adv7511/Kconfig
 create mode 100644 drivers/gpu/drm/bridge/adv7511/Makefile
 create mode 100644 drivers/gpu/drm/bridge/adv7511/adv7511.h
 create mode 100644 drivers/gpu/drm/bridge/adv7511/adv7511_drv.c
 create mode 100644 drivers/gpu/drm/bridge/adv7511/adv7533.c
 delete mode 100644 drivers/gpu/drm/i2c/adv7511.c
 delete mode 100644 drivers/gpu/drm/i2c/adv7511.h

-- 
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation



[PATCHv16 08/13] DocBook/media: add CEC documentation

2016-06-17 Thread Hans Verkuil
On 06/17/2016 11:50 AM, Mauro Carvalho Chehab wrote:
 +
 +  CEC_MODE_MONITOR
 +  0xe0
 +  Put the file descriptor into monitor mode. Can only be used 
 in combination
 +  with CEC_MODE_NO_INITIATOR, otherwise &EINVAL; 
 will be
 +  returned. In monitor mode all messages this CEC device transmits 
 and all messages
 +  it receives (both broadcast messages and directed messages for one 
 its logical
 +  addresses) will be reported. This is very useful for 
 debugging.
 +
 +
 +  CEC_MODE_MONITOR_ALL
 +  0xf0
 +  Put the file descriptor into 'monitor all' mode. Can only be 
 used in combination
 +with CEC_MODE_NO_INITIATOR, otherwise 
 &EINVAL; will be
 +returned. In 'monitor all' mode all messages this CEC device 
 transmits and all messages
 +it receives, including directed messages for other CEC 
 devices will be reported. This
 +  is very useful for debugging, but not all devices support this. 
 This mode requires that
 +  the CEC_CAP_MONITOR_ALL capability is set, and 
 depending on the
 +  hardware, you may have to be root to select this mode.  
>>>
>>> Please mention the error codes when it fails.  
>>
>> Ack.
>>
>>> "and depending on the hardware, you may have to be root to select this 
>>> mode."
>>>
>>> No. We should define if CAP_SYS_ADMIN (or maybe CAP_NET_ADMIN, with
>>> is required to set promiscuous mode for network) will be required or
>>> not and enforce it for all hardware.  
>>
>> Ack for CAP_SYS_ADMIN (or possible NET_ADMIN, I'll look into that).
> 
> Thanks.
> 
>>> IMHO, putting the device into monitor mode should require it.  
>>
>> No. The CEC 2.0 spec explicitly recommends that the CEC adapter should be 
>> able to
>> monitor all messages.
> 
> What the hardware should or should not do is one thing. The other
> thing is what permissions are needed in order to use such
> feature.
> 
> I don't doubt that a similar requirement exists on 802.x, or on some
> industry standard document requiring that all Ethernet hardware should 
> support promiscuous mode. Yet, for security reasons, enabling such feature 
> requires special caps on Linux.
> 
>> The problem is that 1) not all hardware supports this, and 2)
>> hardware that does support this tends to mention that it is for testing only 
>> and
>> it shouldn't be used otherwise.
>>
>> If the hardware is fine with allowing monitoring of all messages, then anyone
>> should be able to do that. 
> 
> Why?

The spec recommends that this is supported in order for applications to take 
advantage
of seeing such traffic to optimize their performance (i.e. by sniffing traffic 
you can see which
devices are there so you don't have to discover them). The underlying reason is 
that
the CEC bus is so hopelessly slow, so any mechanism that helps avoids having to 
use
the bus is good.

>From the HDMI 2.0 spec (section 11.4):

"Polling can and should be skipped if other CEC traffic shows that a device is 
present.
 Hence, a device should not poll a certain Logical Address within at least one 
Minimum
 Polling Period after the following CEC events occur between the device that is 
polling
 and the device whose Logical Address is to be polled:

 - A directly addressed message, sent to that Logical Address, was acknowledged.
 - A directly addressed message has been sent from that Logical Address.
 - A broadcast message has been sent from that Logical Address.

 It is recommended that, if the device is capable of monitoring CEC traffic 
directed to
 other devices, then this capability should also be used to further reduce the 
need for polling.
 In this case, such a device should not poll a certain Logical Address for at 
least one
 Minimum Polling Period after it detects that that Logical Address acknowledged 
a directed
 message initiated from any Logical Address, or any message was sent from that 
Logical Address."

I wouldn't have required CAP_*_ADMIN at all if it wasn't for the scary language 
in some of the
hardware specs that I have seen.

(see below before replying to this :-) )

> 
>> But if it comes with all these 'for testing only' caveats,
>> then I think it should should be protected against 'casual' use. 
>> Unfortunately they
>> never tell you why it should be used for testing only (overly cautious or 
>> could
>> something actually fail when in this mode?).
>>
>> The reality is that being able to monitor the CEC bus is extremely useful 
>> when debugging.
> 
> Well, it can be debugged as root. That's not an issue. The issue
> here is if sniffing the traffic by a normal user could leak
> something that should not usually be seen by a normal user, like
> a Netflix password, that was typed via the RC, for example.

Interesting example. I hadn't thought of that.

OK, so I'm going to change the code so CAP_SYS/NET_ADMIN is required for th

[RFC PATCH 13/13] arm64: tegra: Add DPAUX pinctrl bindings

2016-06-17 Thread Jon Hunter
Add the DPAUX pinctrl states for the DPAUX nodes defining all three
possible states of "aux", "i2c" and "off". Also add the 'i2c-bus'
node for the DPAUX nodes so that the I2C driver core does not attempt
to parse the pinctrl state nodes.

Populate the nodes for the pinctrl clients of the DPAUX pin controller.
There are two clients for each DPAUX instance, namely the SOR and one of
the I2C adapters. The SOR clients may used the DPAUX pins in either AUX
or I2C modes and so for these devices we don't define any of the generic
pinctrl states (default, idle, etc) because the SOR driver will directly
set the state needed. For I2C clients only the I2C mode is used and so
we can simplify matters by using the generic pinctrl states for default
and idle.

Signed-off-by: Jon Hunter 
---
 arch/arm64/boot/dts/nvidia/tegra210.dtsi | 48 
 1 file changed, 48 insertions(+)

diff --git a/arch/arm64/boot/dts/nvidia/tegra210.dtsi 
b/arch/arm64/boot/dts/nvidia/tegra210.dtsi
index 78bcc87b627d..c4ae0215291a 100644
--- a/arch/arm64/boot/dts/nvidia/tegra210.dtsi
+++ b/arch/arm64/boot/dts/nvidia/tegra210.dtsi
@@ -37,6 +37,23 @@
reset-names = "dpaux";
power-domains = <&pd_sor>;
status = "disabled";
+
+   state_dpaux1_aux: pinmux_aux {
+   groups = "dpaux-io";
+   function = "aux";
+   };
+
+   state_dpaux1_i2c: pinmux_i2c {
+   groups = "dpaux-io";
+   function = "i2c";
+   };
+
+   state_dpaux1_off: pinmux_off {
+   groups = "dpaux-io";
+   function = "off";
+   };
+
+   i2c-bus { };
};

vi at 5408 {
@@ -156,6 +173,10 @@
clock-names = "sor", "parent", "dp", "safe";
resets = <&tegra_car 182>;
reset-names = "sor";
+   pinctrl-0 = <&state_dpaux_aux>;
+   pinctrl-1 = <&state_dpaux_i2c>;
+   pinctrl-2 = <&state_dpaux_off>;
+   pinctrl-names = "aux", "i2c", "off";
power-domains = <&pd_sor>;
status = "disabled";
};
@@ -171,6 +192,10 @@
clock-names = "sor", "parent", "dp", "safe";
resets = <&tegra_car 183>;
reset-names = "sor";
+   pinctrl-0 = <&state_dpaux1_aux>;
+   pinctrl-1 = <&state_dpaux1_i2c>;
+   pinctrl-2 = <&state_dpaux1_off>;
+   pinctrl-names = "aux", "i2c", "off";
power-domains = <&pd_sor>;
status = "disabled";
};
@@ -187,6 +212,23 @@
reset-names = "dpaux";
power-domains = <&pd_sor>;
status = "disabled";
+
+   state_dpaux_aux: pinmux_aux {
+   groups = "dpaux-io";
+   function = "aux";
+   };
+
+   state_dpaux_i2c: pinmux_i2c {
+   groups = "dpaux-io";
+   function = "i2c";
+   };
+
+   state_dpaux_off: pinmux_off {
+   groups = "dpaux-io";
+   function = "off";
+   };
+
+   i2c-bus { };
};

isp at 5460 {
@@ -484,6 +526,9 @@
reset-names = "i2c";
dmas = <&apbdma 26>, <&apbdma 26>;
dma-names = "rx", "tx";
+   pinctrl-0 = <&state_dpaux1_i2c>;
+   pinctrl-1 = <&state_dpaux1_off>;
+   pinctrl-names = "default", "idle";
status = "disabled";
};

@@ -514,6 +559,9 @@
reset-names = "i2c";
dmas = <&apbdma 30>, <&apbdma 30>;
dma-names = "rx", "tx";
+   pinctrl-0 = <&state_dpaux_i2c>;
+   pinctrl-1 = <&state_dpaux_off>;
+   pinctrl-names = "default", "idle";
status = "disabled";
};

-- 
2.1.4



[RFC PATCH 12/13] arm64: tegra: Add sor-safe clock to DPAUX binding

2016-06-17 Thread Jon Hunter
Populate the 'sor-safe' clock for DPAUX devices on Tegra210 that require
this clock for operation. Update the compatability string for the DPAUX
instance at address 0x545c to be "nvidia,tegra210-dpaux" to ensure
that the 'sor-safe' clock is enabled for this device.

Signed-off-by: Jon Hunter 
---
 arch/arm64/boot/dts/nvidia/tegra210.dtsi | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/arch/arm64/boot/dts/nvidia/tegra210.dtsi 
b/arch/arm64/boot/dts/nvidia/tegra210.dtsi
index 94f780b43037..78bcc87b627d 100644
--- a/arch/arm64/boot/dts/nvidia/tegra210.dtsi
+++ b/arch/arm64/boot/dts/nvidia/tegra210.dtsi
@@ -30,8 +30,9 @@
reg = <0x0 0x5404 0x0 0x0004>;
interrupts = ;
clocks = <&tegra_car TEGRA210_CLK_DPAUX1>,
-<&tegra_car TEGRA210_CLK_PLL_DP>;
-   clock-names = "dpaux", "parent";
+<&tegra_car TEGRA210_CLK_PLL_DP>,
+<&tegra_car TEGRA210_CLK_SOR_SAFE>;
+   clock-names = "dpaux", "parent", "sor-safe";
resets = <&tegra_car 207>;
reset-names = "dpaux";
power-domains = <&pd_sor>;
@@ -175,12 +176,13 @@
};

dpaux: dpaux at 545c {
-   compatible = "nvidia,tegra124-dpaux";
+   compatible = "nvidia,tegra210-dpaux";
reg = <0x0 0x545c 0x0 0x0004>;
interrupts = ;
clocks = <&tegra_car TEGRA210_CLK_DPAUX>,
-<&tegra_car TEGRA210_CLK_PLL_DP>;
-   clock-names = "dpaux", "parent";
+<&tegra_car TEGRA210_CLK_PLL_DP>,
+<&tegra_car TEGRA210_CLK_SOR_SAFE>;
+   clock-names = "dpaux", "parent", "sor-safe";
resets = <&tegra_car 181>;
reset-names = "dpaux";
power-domains = <&pd_sor>;
-- 
2.1.4



[RFC PATCH 11/13] arm64: tegra: Add SOR power-domain node

2016-06-17 Thread Jon Hunter
Add node for SOR power-domain for Tegra210 and populate the SOR
power-domain phandle for SOR and DPAUX nodes that are dependent
on this power-domain.

Please note that although neither the SOR or DPAUX drivers currently
support runtime power-management, by populating the power-domain node
the SOR power-domain will be turned on before probing SOR or DPAUX
devices and kept on while the devices are bound.

Signed-off-by: Jon Hunter 
---
 arch/arm64/boot/dts/nvidia/tegra210.dtsi | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/arch/arm64/boot/dts/nvidia/tegra210.dtsi 
b/arch/arm64/boot/dts/nvidia/tegra210.dtsi
index ebf44f4059f8..94f780b43037 100644
--- a/arch/arm64/boot/dts/nvidia/tegra210.dtsi
+++ b/arch/arm64/boot/dts/nvidia/tegra210.dtsi
@@ -34,6 +34,7 @@
clock-names = "dpaux", "parent";
resets = <&tegra_car 207>;
reset-names = "dpaux";
+   power-domains = <&pd_sor>;
status = "disabled";
};

@@ -154,6 +155,7 @@
clock-names = "sor", "parent", "dp", "safe";
resets = <&tegra_car 182>;
reset-names = "sor";
+   power-domains = <&pd_sor>;
status = "disabled";
};

@@ -168,6 +170,7 @@
clock-names = "sor", "parent", "dp", "safe";
resets = <&tegra_car 183>;
reset-names = "sor";
+   power-domains = <&pd_sor>;
status = "disabled";
};

@@ -180,6 +183,7 @@
clock-names = "dpaux", "parent";
resets = <&tegra_car 181>;
reset-names = "dpaux";
+   power-domains = <&pd_sor>;
status = "disabled";
};

@@ -592,6 +596,20 @@
resets = <&tegra_car 198>;
#power-domain-cells = <0>;
};
+
+   pd_sor: sor {
+   clocks = <&tegra_car TEGRA210_CLK_SOR0>,
+<&tegra_car TEGRA210_CLK_DSIA>,
+<&tegra_car TEGRA210_CLK_DSIB>,
+<&tegra_car TEGRA210_CLK_MIPI_CAL>,
+<&tegra_car TEGRA210_CLK_DPAUX>;
+   resets = <&tegra_car TEGRA210_CLK_SOR0>,
+<&tegra_car TEGRA210_CLK_DSIA>,
+<&tegra_car TEGRA210_CLK_DSIB>,
+<&tegra_car TEGRA210_CLK_DPAUX>,
+<&tegra_car TEGRA210_CLK_MIPI_CAL>;
+   #power-domain-cells = <0>;
+   };
};
};

-- 
2.1.4



[RFC PATCH 10/13] drm/tegra: Add pinctrl support for DPAUX

2016-06-17 Thread Jon Hunter
The DPAUX pins are shared with an internal I2C controller. To allow
these pins to be muxed to the I2C controller, register a pinctrl device
for the DPAUX device. Make Tegra DRM support dependent on PINCTRL to
avoid any compilation issues.

Signed-off-by: Jon Hunter 
---
 drivers/gpu/drm/tegra/Kconfig |   1 +
 drivers/gpu/drm/tegra/dpaux.c | 117 --
 2 files changed, 115 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/tegra/Kconfig b/drivers/gpu/drm/tegra/Kconfig
index 63ebb154b9b5..d34937a96f94 100644
--- a/drivers/gpu/drm/tegra/Kconfig
+++ b/drivers/gpu/drm/tegra/Kconfig
@@ -4,6 +4,7 @@ config DRM_TEGRA
depends on COMMON_CLK
depends on DRM
depends on RESET_CONTROLLER
+   depends on PINCTRL
select DRM_KMS_HELPER
select DRM_MIPI_DSI
select DRM_PANEL
diff --git a/drivers/gpu/drm/tegra/dpaux.c b/drivers/gpu/drm/tegra/dpaux.c
index 289bb064ca1e..391273652fc8 100644
--- a/drivers/gpu/drm/tegra/dpaux.c
+++ b/drivers/gpu/drm/tegra/dpaux.c
@@ -12,6 +12,9 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -45,6 +48,9 @@ struct tegra_dpaux {
struct completion complete;
struct work_struct work;
struct list_head list;
+
+   struct pinctrl_dev *pinctrl;
+   struct pinctrl_desc desc;
 };

 static inline struct tegra_dpaux *to_dpaux(struct drm_dp_aux *aux)
@@ -268,6 +274,80 @@ static irqreturn_t tegra_dpaux_irq(int irq, void *data)
return ret;
 }

+static const struct pinctrl_pin_desc tegra_dpaux_pins[] = {
+   PINCTRL_PIN(0, "DP_AUX_CHx_P"),
+   PINCTRL_PIN(1, "DP_AUX_CHx_N"),
+};
+
+static const unsigned tegra_dpaux_pin_numbers[] = { 0, 1 };
+
+static const char * const tegra_dpaux_groups[] = {
+   "dpaux-io",
+};
+
+static const char * const tegra_dpaux_functions[] = {
+   "aux",
+   "i2c",
+   "off",
+};
+
+static int tegra_dpaux_get_groups_count(struct pinctrl_dev *pinctrl)
+{
+   return ARRAY_SIZE(tegra_dpaux_groups);
+}
+
+static const char *tegra_dpaux_get_group_name(struct pinctrl_dev *pinctrl,
+ unsigned int group)
+{
+   return tegra_dpaux_groups[group];
+}
+
+static int tegra_dpaux_get_group_pins(struct pinctrl_dev *pinctrl,
+ unsigned group, const unsigned **pins,
+ unsigned *num_pins)
+{
+   *pins = tegra_dpaux_pin_numbers;
+   *num_pins = ARRAY_SIZE(tegra_dpaux_pin_numbers);
+
+   return 0;
+}
+
+enum tegra_dpaux_functions {
+   DPAUX_PADCTL_FUNC_AUX,
+   DPAUX_PADCTL_FUNC_I2C,
+   DPAUX_PADCTL_FUNC_OFF,
+};
+
+static const struct pinctrl_ops tegra_dpaux_pinctrl_ops = {
+   .get_groups_count = tegra_dpaux_get_groups_count,
+   .get_group_name = tegra_dpaux_get_group_name,
+   .get_group_pins = tegra_dpaux_get_group_pins,
+   .dt_node_to_map = pinconf_generic_dt_node_to_map_group,
+   .dt_free_map = pinconf_generic_dt_free_map,
+};
+
+static int tegra_dpaux_get_functions_count(struct pinctrl_dev *pinctrl)
+{
+   return ARRAY_SIZE(tegra_dpaux_functions);
+}
+
+static const char *tegra_dpaux_get_function_name(struct pinctrl_dev *pinctrl,
+unsigned int function)
+{
+   return tegra_dpaux_functions[function];
+}
+
+static int tegra_dpaux_get_function_groups(struct pinctrl_dev *pinctrl,
+  unsigned int function,
+  const char * const **groups,
+  unsigned * const num_groups)
+{
+   *num_groups = ARRAY_SIZE(tegra_dpaux_groups);
+   *groups = tegra_dpaux_groups;
+
+   return 0;
+}
+
 static void tegra_dpaux_powerdown(struct tegra_dpaux *dpaux, bool enable)
 {
u32 value = tegra_dpaux_readl(dpaux, DPAUX_HYBRID_SPARE);
@@ -285,18 +365,21 @@ static int tegra_dpaux_config(struct tegra_dpaux *dpaux, 
int function)
u32 value;

switch (function) {
-   case DPAUX_HYBRID_PADCTL_MODE_AUX:
+   case DPAUX_PADCTL_FUNC_AUX:
value = DPAUX_HYBRID_PADCTL_AUX_CMH(2) |
DPAUX_HYBRID_PADCTL_AUX_DRVZ(4) |
DPAUX_HYBRID_PADCTL_AUX_DRVI(0x18) |
DPAUX_HYBRID_PADCTL_AUX_INPUT_RCV |
DPAUX_HYBRID_PADCTL_MODE_AUX;
break;
-   case DPAUX_HYBRID_PADCTL_MODE_I2C:
+   case DPAUX_PADCTL_FUNC_I2C:
value = DPAUX_HYBRID_PADCTL_I2C_SDA_INPUT_RCV |
DPAUX_HYBRID_PADCTL_I2C_SCL_INPUT_RCV |
DPAUX_HYBRID_PADCTL_MODE_I2C;
break;
+   case DPAUX_PADCTL_FUNC_OFF:
+   tegra_dpaux_powerdown(dpaux, true);
+   return 0;
default:
return -ENOTSUPP;
}
@@ -307,6 +390,21 @@ static int tegra_dpaux_config(

[RFC PATCH 09/13] dt-bindings: drm/tegra: Add DPAUX pinctrl documentation

2016-06-17 Thread Jon Hunter
On Tegra124, Tegra132 and Tegra210 devices the pads used by the Display
Port Auxiliary (DPAUX) channel are multiplexed such that they can also
be used by one of the internal i2c controllers. Note that this is
different from i2c-over-AUX supported by the DPAUX controller. The
register that configures these pads is part of the DPAUX controllers
register set and so a pinctrl driver is being added for the DPAUX device
to share these pads. Add the device-tree binding documentation for the
DPAUX pad controller.

Please note that although the "off" function for the DPAUX pads is not
technically a pin-mux setting but more of a pin-conf setting it is
simpler to expose these as a function so that the user can simply select
either "aux", "i2c" or "off" as the current function/mode.

Update the main DPAUX binding documentation to reference the DPAUX pad
controller binding document and add the 'i2c-bus' subnode. The 'i2c-bus'
subnode is used for populating I2C slaves for the DPAUX device so that
the I2C driver core does not attempt to add the DPAUX pad controller
nodes as I2C slaves.

Signed-off-by: Jon Hunter 
---
 .../display/tegra/nvidia,tegra20-host1x.txt|  4 ++
 .../pinctrl/nvidia,tegra124-dpaux-padctl.txt   | 60 ++
 2 files changed, 64 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/pinctrl/nvidia,tegra124-dpaux-padctl.txt

diff --git 
a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt 
b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt
index 361a472eac4b..6759554b7b8f 100644
--- a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt
+++ b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt
@@ -242,6 +242,10 @@ of the following host1x client modules:
   - reset-names: Must include the following entries:
 - dpaux
   - vdd-supply: phandle of a supply that powers the DisplayPort link
+  - i2c-bus: Subnode where I2C slave devices should be listed.
+
+  See ../pinctrl/nvidia,tegra124-dpaux-padctl.txt for information
+  regarding the DPAUX pad controller bindings.

 Example:

diff --git 
a/Documentation/devicetree/bindings/pinctrl/nvidia,tegra124-dpaux-padctl.txt 
b/Documentation/devicetree/bindings/pinctrl/nvidia,tegra124-dpaux-padctl.txt
new file mode 100644
index ..3be0ced01680
--- /dev/null
+++ b/Documentation/devicetree/bindings/pinctrl/nvidia,tegra124-dpaux-padctl.txt
@@ -0,0 +1,60 @@
+Device tree binding for NVIDIA Tegra DPAUX pad controller
+
+
+The Tegra Display Port Auxiliary (DPAUX) pad controller manages two pins
+which can be assigned to either the DPAUX channel or to an I2C
+controller.
+
+This document defines the device-specific binding for the DPAUX pad
+controller. Refer to pinctrl-bindings.txt in this directory for generic
+information about pin controller device tree bindings. Please refer to
+the binding document ../display/tegra/nvidia,tegra20-host1x.txt for more
+details on the DPAUX binding.
+
+Pin muxing:
+---
+
+Child nodes contain the pinmux configurations following the conventions
+from the pinctrl-bindings.txt document.
+
+Since only three configurations are possible, only three child nodes are
+needed to describe the pin mux'ing options for the DPAUX pads.
+Furthermore, given that the pad functions are only applicable to a
+single set of pads, the child nodes do not need to describe the pads the
+functions are being applied to.
+
+Required properties:
+- groups: Must be "dpaux-io"
+- function: Must be either "aux", "i2c" or "off".
+
+Example:
+
+
+   dpaux at 545c {
+   ...
+
+   state_dpaux_aux: pinmux_aux {
+   groups = "dpaux-io";
+   function = "aux";
+   };
+
+   state_dpaux_i2c: pinmux_i2c {
+   groups = "dpaux-io";
+   function = "i2c";
+   };
+
+   state_dpaux_off: pinmux_off {
+   groups = "dpaux-io";
+   function = "off";
+   };
+   };
+
+   ...
+
+   i2c at 7000d100 {
+   ...
+   pinctrl-0 = <&state_dpaux_i2c>;
+   pinctrl-1 = <&state_dpaux_off>;
+   pinctrl-names = "default", "idle";
+   status = "disabled";
+   };
-- 
2.1.4



[RFC PATCH 08/13] i2c: core: Add support for 'i2c-bus' subnode

2016-06-17 Thread Jon Hunter
If the 'i2c-bus' device-tree node is present for an I2C adapter then
parse this subnode for I2C slaves.

Signed-off-by: Jon Hunter 
---
 drivers/i2c/i2c-core.c | 11 +--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c
index 952d2f0c02c5..f552d97bad32 100644
--- a/drivers/i2c/i2c-core.c
+++ b/drivers/i2c/i2c-core.c
@@ -1452,7 +1452,7 @@ static struct i2c_client *of_i2c_register_device(struct 
i2c_adapter *adap,

 static void of_i2c_register_devices(struct i2c_adapter *adap)
 {
-   struct device_node *node;
+   struct device_node *bus, *node;

/* Only register child devices if the adapter has a node pointer set */
if (!adap->dev.of_node)
@@ -1460,11 +1460,18 @@ static void of_i2c_register_devices(struct i2c_adapter 
*adap)

dev_dbg(&adap->dev, "of_i2c: walking child nodes\n");

-   for_each_available_child_of_node(adap->dev.of_node, node) {
+   bus = of_get_child_by_name(adap->dev.of_node, "i2c-bus");
+   if (!bus)
+   bus = adap->dev.of_node;
+
+   for_each_available_child_of_node(bus, node) {
if (of_node_test_and_set_flag(node, OF_POPULATED))
continue;
of_i2c_register_device(adap, node);
}
+
+   if (bus != adap->dev.of_node)
+   of_node_put(bus);
 }

 static int of_dev_node_match(struct device *dev, void *data)
-- 
2.1.4



[RFC PATCH 07/13] dt-bindings: i2c: Add support for 'i2c-bus' subnode

2016-06-17 Thread Jon Hunter
The I2C driver core for boards using device-tree assumes any subnode of
an I2C adapter in the device-tree blob as being a I2C slave device.
Although this makes complete sense, some I2C adapters may have subnodes
which are not I2C slaves but subnodes presenting other features. For
example some Tegra devices have an I2C interface which may share its
pins with other devices and to share these pins subnodes for
representing these pins so they have be shared via the pinctrl framework
are needed.

To allow I2C adapters to have non-I2C specific subnodes in device-tree
that are not parsed by the I2C driver core by adding support for a
'i2c-bus' subnode where I2C slaves can be placed. If the 'i2c-bus'
subnode is present then all I2C slaves must be placed under this subnode.

Signed-off-by: Jon Hunter 
---
 Documentation/devicetree/bindings/i2c/i2c.txt | 8 
 1 file changed, 8 insertions(+)

diff --git a/Documentation/devicetree/bindings/i2c/i2c.txt 
b/Documentation/devicetree/bindings/i2c/i2c.txt
index f31b2ad1552b..ed56b08c7e6e 100644
--- a/Documentation/devicetree/bindings/i2c/i2c.txt
+++ b/Documentation/devicetree/bindings/i2c/i2c.txt
@@ -32,6 +32,14 @@ wants to support one of the below features, it should adapt 
the bindings below.
 - clock-frequency
frequency of bus clock in Hz.

+- i2c-bus
+   For I2C adapters that have child nodes that are a mixture of both I2C
+   devices and non-I2C devices (such as a pin controller), the 'i2c-bus'
+   subnode can be used for populating I2C devices to prevent the I2C core
+   from attempting to add any non-i2c nodes as I2C devices. If 'i2c-bus'
+   subnode is present then all I2C slaves must be added under this
+   subnode.
+
 - i2c-scl-falling-time-ns
Number of nanoseconds the SCL signal takes to fall; t(f) in the I2C
specification.
-- 
2.1.4



[RFC PATCH 06/13] pinctrl: pinconf: Add generic helper function for freeing mappings

2016-06-17 Thread Jon Hunter
The pinconf-generic.h file exposes functions for creating generic mappings
but it does not expose a function for freeing the mappings. Add a function
for freeing generic mappings.

Signed-off-by: Jon Hunter 
---
 drivers/pinctrl/pinconf-generic.c   | 8 
 include/linux/pinctrl/pinconf-generic.h | 2 ++
 2 files changed, 10 insertions(+)

diff --git a/drivers/pinctrl/pinconf-generic.c 
b/drivers/pinctrl/pinconf-generic.c
index 34b601b06764..5020ae534479 100644
--- a/drivers/pinctrl/pinconf-generic.c
+++ b/drivers/pinctrl/pinconf-generic.c
@@ -395,4 +395,12 @@ exit:
 }
 EXPORT_SYMBOL_GPL(pinconf_generic_dt_node_to_map);

+void pinconf_generic_dt_free_map(struct pinctrl_dev *pctldev,
+struct pinctrl_map *map,
+unsigned num_maps)
+{
+   pinctrl_utils_free_map(pctldev, map, num_maps);
+}
+EXPORT_SYMBOL_GPL(pinconf_generic_dt_free_map);
+
 #endif
diff --git a/include/linux/pinctrl/pinconf-generic.h 
b/include/linux/pinctrl/pinconf-generic.h
index d921afd5f109..12343caa114e 100644
--- a/include/linux/pinctrl/pinconf-generic.h
+++ b/include/linux/pinctrl/pinconf-generic.h
@@ -175,6 +175,8 @@ int pinconf_generic_dt_subnode_to_map(struct pinctrl_dev 
*pctldev,
 int pinconf_generic_dt_node_to_map(struct pinctrl_dev *pctldev,
struct device_node *np_config, struct pinctrl_map **map,
unsigned *num_maps, enum pinctrl_map_type type);
+void pinconf_generic_dt_free_map(struct pinctrl_dev *pctldev,
+   struct pinctrl_map *map, unsigned num_maps);

 static inline int pinconf_generic_dt_node_to_map_group(
struct pinctrl_dev *pctldev, struct device_node *np_config,
-- 
2.1.4



[RFC PATCH 05/13] drm/tegra: Prepare DPAUX for supporting generic PM domains

2016-06-17 Thread Jon Hunter
To utilise the DPAUX on Tegra, the SOR power partition must be enabled.
Now that Tegra supports the generic PM domain framework we manage the
SOR power partition via this framework for DPAUX. However, the sequence
for gating/ungating the SOR power partition requires that the DPAUX
reset is asserted/de-asserted at the time the SOR power partition is
gated/ungated, respectively. Now that the reset control core assumes
that resets are exclusive, the Tegra generic PM domain code and the
DPAUX driver cannot request the same reset unless we mark the resets as
shared. Sharing resets we will not work in this case because we cannot
guarantee that the reset is asserted/de-asserted at the appropriate
time. Therefore, given that the Tegra generic PM domain code will handle
the DPAUX reset, do not request the reset in the DPAUX driver if the
DPAUX device has a PM domain associated.

Signed-off-by: Jon Hunter 
---
 drivers/gpu/drm/tegra/dpaux.c | 22 ++
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/tegra/dpaux.c b/drivers/gpu/drm/tegra/dpaux.c
index d696a7e45935..289bb064ca1e 100644
--- a/drivers/gpu/drm/tegra/dpaux.c
+++ b/drivers/gpu/drm/tegra/dpaux.c
@@ -334,11 +334,14 @@ static int tegra_dpaux_probe(struct platform_device *pdev)
return -ENXIO;
}

-   dpaux->rst = devm_reset_control_get(&pdev->dev, "dpaux");
-   if (IS_ERR(dpaux->rst)) {
-   dev_err(&pdev->dev, "failed to get reset control: %ld\n",
-   PTR_ERR(dpaux->rst));
-   return PTR_ERR(dpaux->rst);
+   if (!pdev->dev.pm_domain) {
+   dpaux->rst = devm_reset_control_get(&pdev->dev, "dpaux");
+   if (IS_ERR(dpaux->rst)) {
+   dev_err(&pdev->dev,
+   "failed to get reset control: %ld\n",
+   PTR_ERR(dpaux->rst));
+   return PTR_ERR(dpaux->rst);
+   }
}

if (of_device_is_compatible(pdev->dev.of_node,
@@ -374,7 +377,8 @@ static int tegra_dpaux_probe(struct platform_device *pdev)
goto disable_sor_clk;
}

-   reset_control_deassert(dpaux->rst);
+   if (dpaux->rst)
+   reset_control_deassert(dpaux->rst);

dpaux->clk_parent = devm_clk_get(&pdev->dev, "parent");
if (IS_ERR(dpaux->clk_parent)) {
@@ -452,7 +456,8 @@ static int tegra_dpaux_probe(struct platform_device *pdev)
 disable_parent_clk:
clk_disable_unprepare(dpaux->clk_parent);
 assert_reset:
-   reset_control_assert(dpaux->rst);
+   if (dpaux->rst)
+   reset_control_assert(dpaux->rst);
clk_disable_unprepare(dpaux->clk);
 disable_sor_clk:
if (dpaux->clk_sor)
@@ -477,7 +482,8 @@ static int tegra_dpaux_remove(struct platform_device *pdev)
cancel_work_sync(&dpaux->work);

clk_disable_unprepare(dpaux->clk_parent);
-   reset_control_assert(dpaux->rst);
+   if (dpaux->rst)
+   reset_control_assert(dpaux->rst);
clk_disable_unprepare(dpaux->clk);
if (dpaux->clk_sor)
clk_disable_unprepare(dpaux->clk_sor);
-- 
2.1.4



[RFC PATCH 04/13] drm/tegra: Add sor-safe clock for DPAUX on Tegra210

2016-06-17 Thread Jon Hunter
For Tegra210 the 'sor-safe' clock needs to be enabled when using DPAUX.
Add support to the DPAUX driver for enabling this clock on Tegra210.

Signed-off-by: Jon Hunter 
---
 drivers/gpu/drm/tegra/dpaux.c | 29 +++--
 1 file changed, 27 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/tegra/dpaux.c b/drivers/gpu/drm/tegra/dpaux.c
index aa3a037fcd3b..d696a7e45935 100644
--- a/drivers/gpu/drm/tegra/dpaux.c
+++ b/drivers/gpu/drm/tegra/dpaux.c
@@ -37,6 +37,7 @@ struct tegra_dpaux {

struct reset_control *rst;
struct clk *clk_parent;
+   struct clk *clk_sor;
struct clk *clk;

struct regulator *vdd;
@@ -340,18 +341,37 @@ static int tegra_dpaux_probe(struct platform_device *pdev)
return PTR_ERR(dpaux->rst);
}

+   if (of_device_is_compatible(pdev->dev.of_node,
+   "nvidia,tegra210-dpaux")) {
+   dpaux->clk_sor = devm_clk_get(&pdev->dev, "sor-safe");
+   if (IS_ERR(dpaux->clk_sor)) {
+   dev_err(&pdev->dev,
+   "failed to get sor-safe clock: %ld\n",
+   PTR_ERR(dpaux->clk_sor));
+   return PTR_ERR(dpaux->clk_sor);
+   }
+
+   err = clk_prepare_enable(dpaux->clk_sor);
+   if (err < 0) {
+   dev_err(&pdev->dev,
+   "failed to enable sor-safe clock: %d\n", err);
+   return err;
+   }
+   }
+
dpaux->clk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(dpaux->clk)) {
dev_err(&pdev->dev, "failed to get module clock: %ld\n",
PTR_ERR(dpaux->clk));
-   return PTR_ERR(dpaux->clk);
+   err = PTR_ERR(dpaux->clk);
+   goto disable_sor_clk;
}

err = clk_prepare_enable(dpaux->clk);
if (err < 0) {
dev_err(&pdev->dev, "failed to enable module clock: %d\n",
err);
-   return err;
+   goto disable_sor_clk;
}

reset_control_deassert(dpaux->rst);
@@ -434,6 +454,9 @@ disable_parent_clk:
 assert_reset:
reset_control_assert(dpaux->rst);
clk_disable_unprepare(dpaux->clk);
+disable_sor_clk:
+   if (dpaux->clk_sor)
+   clk_disable_unprepare(dpaux->clk_sor);

return err;
 }
@@ -456,6 +479,8 @@ static int tegra_dpaux_remove(struct platform_device *pdev)
clk_disable_unprepare(dpaux->clk_parent);
reset_control_assert(dpaux->rst);
clk_disable_unprepare(dpaux->clk);
+   if (dpaux->clk_sor)
+   clk_disable_unprepare(dpaux->clk_sor);

return 0;
 }
-- 
2.1.4



[RFC PATCH 03/13] dt-bindings: drm/tegra: Update DPAUX documentation

2016-06-17 Thread Jon Hunter
Update the DPAUX compatibility string information for Tegra124, Tegra132
and Tegra210. For Tegra210 an additional clock, 'sor-safe' is also
required for DPAUX and so add this clock information as well.

Signed-off-by: Jon Hunter 
---
 .../devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt| 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git 
a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt 
b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt
index a3bd8c050c4e..361a472eac4b 100644
--- a/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt
+++ b/Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.txt
@@ -226,9 +226,9 @@ of the following host1x client modules:
   - nvidia,dpaux: phandle to a DispayPort AUX interface

 - dpaux: DisplayPort AUX interface
-  - compatible: For Tegra124, must contain "nvidia,tegra124-dpaux".  Otherwise,
-must contain '"nvidia,-dpaux", "nvidia,tegra124-dpaux"', where
- is tegra132.
+  - compatible : Should contain one of the following:
+- "nvidia,tegra124-dpaux": for Tegra124 and Tegra132
+- "nvidia,tegra210-dpaux": for Tegra210
   - reg: Physical base address and length of the controller's registers.
   - interrupts: The interrupt outputs from the controller.
   - clocks: Must contain an entry for each entry in clock-names.
@@ -236,6 +236,7 @@ of the following host1x client modules:
   - clock-names: Must include the following entries:
 - dpaux: clock input for the DPAUX hardware
 - parent: reference clock
+- sor-safe: additional clock input for the DPAUX hardware on Tegra210
   - resets: Must contain an entry for each entry in reset-names.
 See ../reset/reset.txt for details.
   - reset-names: Must include the following entries:
-- 
2.1.4



[RFC PATCH 02/13] drm/tegra: Add helper functions for setting up DPAUX pads

2016-06-17 Thread Jon Hunter
In preparation for adding pinctrl support for the DPAUX pads, add
helpers functions for configuring the pads and controlling the power
for the pads.

Please note that although a simple if-statement could be used instead
of a case statement for configuring the pads as there are only two
possible modes, a case statement is used because when integrating with
the pinctrl framework, we need to be able to handle invalid modes that
could be passed.

Signed-off-by: Jon Hunter 
---
 drivers/gpu/drm/tegra/dpaux.c | 75 ++-
 1 file changed, 45 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/tegra/dpaux.c b/drivers/gpu/drm/tegra/dpaux.c
index 0874a7e5b37b..aa3a037fcd3b 100644
--- a/drivers/gpu/drm/tegra/dpaux.c
+++ b/drivers/gpu/drm/tegra/dpaux.c
@@ -267,6 +267,45 @@ static irqreturn_t tegra_dpaux_irq(int irq, void *data)
return ret;
 }

+static void tegra_dpaux_powerdown(struct tegra_dpaux *dpaux, bool enable)
+{
+   u32 value = tegra_dpaux_readl(dpaux, DPAUX_HYBRID_SPARE);
+
+   if (enable)
+   value |= DPAUX_HYBRID_SPARE_PAD_POWER_DOWN;
+   else
+   value &= ~DPAUX_HYBRID_SPARE_PAD_POWER_DOWN;
+
+   tegra_dpaux_writel(dpaux, value, DPAUX_HYBRID_SPARE);
+}
+
+static int tegra_dpaux_config(struct tegra_dpaux *dpaux, int function)
+{
+   u32 value;
+
+   switch (function) {
+   case DPAUX_HYBRID_PADCTL_MODE_AUX:
+   value = DPAUX_HYBRID_PADCTL_AUX_CMH(2) |
+   DPAUX_HYBRID_PADCTL_AUX_DRVZ(4) |
+   DPAUX_HYBRID_PADCTL_AUX_DRVI(0x18) |
+   DPAUX_HYBRID_PADCTL_AUX_INPUT_RCV |
+   DPAUX_HYBRID_PADCTL_MODE_AUX;
+   break;
+   case DPAUX_HYBRID_PADCTL_MODE_I2C:
+   value = DPAUX_HYBRID_PADCTL_I2C_SDA_INPUT_RCV |
+   DPAUX_HYBRID_PADCTL_I2C_SCL_INPUT_RCV |
+   DPAUX_HYBRID_PADCTL_MODE_I2C;
+   break;
+   default:
+   return -ENOTSUPP;
+   }
+
+   tegra_dpaux_writel(dpaux, value, DPAUX_HYBRID_PADCTL);
+   tegra_dpaux_powerdown(dpaux, false);
+
+   return 0;
+}
+
 static int tegra_dpaux_probe(struct platform_device *pdev)
 {
struct tegra_dpaux *dpaux;
@@ -372,15 +411,9 @@ static int tegra_dpaux_probe(struct platform_device *pdev)
 * is no possibility to perform the I2C mode configuration in the
 * HDMI path.
 */
-   value = tegra_dpaux_readl(dpaux, DPAUX_HYBRID_SPARE);
-   value &= ~DPAUX_HYBRID_SPARE_PAD_POWER_DOWN;
-   tegra_dpaux_writel(dpaux, value, DPAUX_HYBRID_SPARE);
-
-   value = tegra_dpaux_readl(dpaux, DPAUX_HYBRID_PADCTL);
-   value = DPAUX_HYBRID_PADCTL_I2C_SDA_INPUT_RCV |
-   DPAUX_HYBRID_PADCTL_I2C_SCL_INPUT_RCV |
-   DPAUX_HYBRID_PADCTL_MODE_I2C;
-   tegra_dpaux_writel(dpaux, value, DPAUX_HYBRID_PADCTL);
+   err = tegra_dpaux_config(dpaux, DPAUX_HYBRID_PADCTL_MODE_I2C);
+   if (err < 0)
+   return err;

/* enable and clear all interrupts */
value = DPAUX_INTR_AUX_DONE | DPAUX_INTR_IRQ_EVENT |
@@ -408,12 +441,9 @@ assert_reset:
 static int tegra_dpaux_remove(struct platform_device *pdev)
 {
struct tegra_dpaux *dpaux = platform_get_drvdata(pdev);
-   u32 value;

/* make sure pads are powered down when not in use */
-   value = tegra_dpaux_readl(dpaux, DPAUX_HYBRID_SPARE);
-   value |= DPAUX_HYBRID_SPARE_PAD_POWER_DOWN;
-   tegra_dpaux_writel(dpaux, value, DPAUX_HYBRID_SPARE);
+   tegra_dpaux_powerdown(dpaux, true);

drm_dp_aux_unregister(&dpaux->aux);

@@ -538,30 +568,15 @@ enum drm_connector_status drm_dp_aux_detect(struct 
drm_dp_aux *aux)
 int drm_dp_aux_enable(struct drm_dp_aux *aux)
 {
struct tegra_dpaux *dpaux = to_dpaux(aux);
-   u32 value;
-
-   value = DPAUX_HYBRID_PADCTL_AUX_CMH(2) |
-   DPAUX_HYBRID_PADCTL_AUX_DRVZ(4) |
-   DPAUX_HYBRID_PADCTL_AUX_DRVI(0x18) |
-   DPAUX_HYBRID_PADCTL_AUX_INPUT_RCV |
-   DPAUX_HYBRID_PADCTL_MODE_AUX;
-   tegra_dpaux_writel(dpaux, value, DPAUX_HYBRID_PADCTL);
-
-   value = tegra_dpaux_readl(dpaux, DPAUX_HYBRID_SPARE);
-   value &= ~DPAUX_HYBRID_SPARE_PAD_POWER_DOWN;
-   tegra_dpaux_writel(dpaux, value, DPAUX_HYBRID_SPARE);

-   return 0;
+   return tegra_dpaux_config(dpaux, DPAUX_HYBRID_PADCTL_MODE_AUX);
 }

 int drm_dp_aux_disable(struct drm_dp_aux *aux)
 {
struct tegra_dpaux *dpaux = to_dpaux(aux);
-   u32 value;

-   value = tegra_dpaux_readl(dpaux, DPAUX_HYBRID_SPARE);
-   value |= DPAUX_HYBRID_SPARE_PAD_POWER_DOWN;
-   tegra_dpaux_writel(dpaux, value, DPAUX_HYBRID_SPARE);
+   tegra_dpaux_powerdown(dpaux, true);

return 0;
 }
-- 
2.1.4



[RFC PATCH 01/13] drm/tegra: Clean-up if probing DPAUX fails

2016-06-17 Thread Jon Hunter
If the probing of the DPAUX fails, then clocks are left enabled and the
DPAUX reset de-asserted. Add code to perform the necessary clean-up on
probe failure by disabling clocks and asserting the reset.

Signed-off-by: Jon Hunter 
---
 drivers/gpu/drm/tegra/dpaux.c | 22 --
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/tegra/dpaux.c b/drivers/gpu/drm/tegra/dpaux.c
index b24a0f14821a..0874a7e5b37b 100644
--- a/drivers/gpu/drm/tegra/dpaux.c
+++ b/drivers/gpu/drm/tegra/dpaux.c
@@ -321,28 +321,30 @@ static int tegra_dpaux_probe(struct platform_device *pdev)
if (IS_ERR(dpaux->clk_parent)) {
dev_err(&pdev->dev, "failed to get parent clock: %ld\n",
PTR_ERR(dpaux->clk_parent));
-   return PTR_ERR(dpaux->clk_parent);
+   err = PTR_ERR(dpaux->clk_parent);
+   goto assert_reset;
}

err = clk_prepare_enable(dpaux->clk_parent);
if (err < 0) {
dev_err(&pdev->dev, "failed to enable parent clock: %d\n",
err);
-   return err;
+   goto assert_reset;
}

err = clk_set_rate(dpaux->clk_parent, 27000);
if (err < 0) {
dev_err(&pdev->dev, "failed to set clock to 270 MHz: %d\n",
err);
-   return err;
+   goto disable_parent_clk;
}

dpaux->vdd = devm_regulator_get(&pdev->dev, "vdd");
if (IS_ERR(dpaux->vdd)) {
dev_err(&pdev->dev, "failed to get VDD supply: %ld\n",
PTR_ERR(dpaux->vdd));
-   return PTR_ERR(dpaux->vdd);
+   err = PTR_ERR(dpaux->vdd);
+   goto disable_parent_clk;
}

err = devm_request_irq(dpaux->dev, dpaux->irq, tegra_dpaux_irq, 0,
@@ -350,7 +352,7 @@ static int tegra_dpaux_probe(struct platform_device *pdev)
if (err < 0) {
dev_err(dpaux->dev, "failed to request IRQ#%u: %d\n",
dpaux->irq, err);
-   return err;
+   goto disable_parent_clk;
}

disable_irq(dpaux->irq);
@@ -360,7 +362,7 @@ static int tegra_dpaux_probe(struct platform_device *pdev)

err = drm_dp_aux_register(&dpaux->aux);
if (err < 0)
-   return err;
+   goto disable_parent_clk;

/*
 * Assume that by default the DPAUX/I2C pads will be used for HDMI,
@@ -393,6 +395,14 @@ static int tegra_dpaux_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, dpaux);

return 0;
+
+disable_parent_clk:
+   clk_disable_unprepare(dpaux->clk_parent);
+assert_reset:
+   reset_control_assert(dpaux->rst);
+   clk_disable_unprepare(dpaux->clk);
+
+   return err;
 }

 static int tegra_dpaux_remove(struct platform_device *pdev)
-- 
2.1.4



[RFC PATCH 00/13] Add support for Tegra DPAUX pinctrl

2016-06-17 Thread Jon Hunter
The Display Port Auxiliary (DPAUX) channel pads can be shared with an
internal I2C controller. Add pinctrl support for these pads so that the
I2C controller can request and use these pads.

Jon Hunter (13):
  drm/tegra: Clean-up if probing DPAUX fails
  drm/tegra: Add helper functions for setting up DPAUX pads
  dt-bindings: drm/tegra: Update DPAUX documentation
  drm/tegra: Add sor-safe clock for DPAUX on Tegra210
  drm/tegra: Prepare DPAUX for supporting generic PM domains
  pinctrl: pinconf: Add generic helper function for freeing mappings
  dt-bindings: i2c: Add support for 'i2c-bus' subnode
  i2c: core: Add support for 'i2c-bus' subnode
  dt-bindings: drm/tegra: Add DPAUX pinctrl documentation
  drm/tegra: Add pinctrl support for DPAUX
  arm64: tegra: Add SOR power-domain node
  arm64: tegra: Add sor-safe clock to DPAUX binding
  arm64: tegra: Add DPAUX pinctrl bindings

 .../display/tegra/nvidia,tegra20-host1x.txt|  11 +-
 Documentation/devicetree/bindings/i2c/i2c.txt  |   8 +
 .../pinctrl/nvidia,tegra124-dpaux-padctl.txt   |  60 +
 arch/arm64/boot/dts/nvidia/tegra210.dtsi   |  78 ++-
 drivers/gpu/drm/tegra/Kconfig  |   1 +
 drivers/gpu/drm/tegra/dpaux.c  | 255 +
 drivers/i2c/i2c-core.c |  11 +-
 drivers/pinctrl/pinconf-generic.c  |   8 +
 include/linux/pinctrl/pinconf-generic.h|   2 +
 9 files changed, 380 insertions(+), 54 deletions(-)
 create mode 100644 
Documentation/devicetree/bindings/pinctrl/nvidia,tegra124-dpaux-padctl.txt

-- 
2.1.4



[PATCH v5 0/8] drm/tilcdc Fixes and cleanups

2016-06-17 Thread Tomi Valkeinen


On 17/06/16 12:22, Jyri Sarha wrote:
> Some fixes and cleanups that should get merged to tilcdc even if my
> atomic changes are still a work in progress.
> 
> Yet one more round, sorry for spamming.

I think these look fine:

Reviewed-by: Tomi Valkeinen 

 Tomi

-- next part --
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160617/056ff96d/attachment.sig>


[PATCH 2/2] drm/etnaviv: remove generic GPU init failure reporting

2016-06-17 Thread Lucas Stach
The GPU init path now reports any errors which might occur more accurately
than what is possible with the generic "something failed" message.

Remove the generic reporting, so we don't log an error into dmesg anymore
if any of the GPU cores are ignored.

Signed-off-by: Lucas Stach 
---
 drivers/gpu/drm/etnaviv/etnaviv_drv.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_drv.c 
b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
index 3d4f56df8359..7c5a4b408961 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
@@ -91,10 +91,8 @@ static void load_gpu(struct drm_device *dev)
int ret;

ret = etnaviv_gpu_init(g);
-   if (ret) {
-   dev_err(g->dev, "hw init failed: %d\n", ret);
+   if (ret)
priv->gpu[i] = NULL;
-   }
}
}
 }
-- 
2.8.1



[PATCH 1/2] drm/etnaviv: improve error reporting in GPU init path

2016-06-17 Thread Lucas Stach
Print error messages that mention the exact cause of the failure on
all paths which may fail the GPU init.

Signed-off-by: Lucas Stach 
---
 drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c 
b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
index 9b72b6a9c29c..87ef34150d46 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
@@ -597,8 +597,10 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
bool mmuv2;

ret = pm_runtime_get_sync(gpu->dev);
-   if (ret < 0)
+   if (ret < 0) {
+   dev_err(gpu->dev, "Failed to enable GPU power domain\n");
return ret;
+   }

etnaviv_hw_identify(gpu);

@@ -635,8 +637,10 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
}

ret = etnaviv_hw_reset(gpu);
-   if (ret)
+   if (ret) {
+   dev_err(gpu->dev, "GPU reset failed\n");
goto fail;
+   }

/* Setup IOMMU.. eventually we will (I think) do this once per context
 * and have separate page tables per context.  For now, to keep things
@@ -654,12 +658,14 @@ int etnaviv_gpu_init(struct etnaviv_gpu *gpu)
}

if (!iommu) {
+   dev_err(gpu->dev, "Failed to allocate GPU IOMMU domain\n");
ret = -ENOMEM;
goto fail;
}

gpu->mmu = etnaviv_iommu_new(gpu, iommu, version);
if (!gpu->mmu) {
+   dev_err(gpu->dev, "Failed to instantiate GPU IOMMU\n");
iommu_domain_free(iommu);
ret = -ENOMEM;
goto fail;
-- 
2.8.1



[Bug 88458] The monitor turns off when playing starcraft 2 in wine

2016-06-17 Thread bugzilla-dae...@freedesktop.org
https://bugs.freedesktop.org/show_bug.cgi?id=88458

--- Comment #10 from Nicolai Hähnle  ---
VM faults from CB, interesting.

If the VM faults are reproducible using the trace, I'd be interested in
downloading it if you can manage to upload it somewhere despite the size
(Google Drive?).

-- 
You are receiving this mail because:
You are the assignee for the bug.
-- next part --
An HTML attachment was scrubbed...
URL: 
<https://lists.freedesktop.org/archives/dri-devel/attachments/20160617/e2f48612/attachment.html>


[patch v2] drm/amdgpu: missing bounds check in amdgpu_set_pp_force_state()

2016-06-17 Thread Alex Deucher
On Thu, Jun 16, 2016 at 4:39 AM, Christian König
 wrote:
> Am 16.06.2016 um 10:30 schrieb Dan Carpenter:
>>
>> There is no limit on high "idx" can go.  It should be less than
>> ARRAY_SIZE(data.states) which is 16.
>>
>> The "data" variable wasn't declared in that scope so I shifted the code
>> around a bit to make it work.  Also I made "idx" unsigned.
>>
>> Fixes: f3898ea12fc1 ('drm/amd/powerplay: add some sysfs interfaces for
>> powerplay.')
>> Signed-off-by: Dan Carpenter 
>
>
> Acked-by: Christian König .
>

Applied.  thanks!

Alex

>
>> ---
>> v2: make idx unsigned
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
>> index 589b36e..0e13d80 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c
>> @@ -270,30 +270,28 @@ static ssize_t amdgpu_set_pp_force_state(struct
>> device *dev,
>> struct drm_device *ddev = dev_get_drvdata(dev);
>> struct amdgpu_device *adev = ddev->dev_private;
>> enum amd_pm_state_type state = 0;
>> -   long idx;
>> +   unsigned long idx;
>> int ret;
>> if (strlen(buf) == 1)
>> adev->pp_force_state_enabled = false;
>> -   else {
>> -   ret = kstrtol(buf, 0, &idx);
>> +   else if (adev->pp_enabled) {
>> +   struct pp_states_info data;
>>   - if (ret) {
>> +   ret = kstrtoul(buf, 0, &idx);
>> +   if (ret || idx >= ARRAY_SIZE(data.states)) {
>> count = -EINVAL;
>> goto fail;
>> }
>>   - if (adev->pp_enabled) {
>> -   struct pp_states_info data;
>> -   amdgpu_dpm_get_pp_num_states(adev, &data);
>> -   state = data.states[idx];
>> -   /* only set user selected power states */
>> -   if (state != POWER_STATE_TYPE_INTERNAL_BOOT &&
>> -   state != POWER_STATE_TYPE_DEFAULT) {
>> -   amdgpu_dpm_dispatch_task(adev,
>> -
>> AMD_PP_EVENT_ENABLE_USER_STATE, &state, NULL);
>> -   adev->pp_force_state_enabled = true;
>> -   }
>> +   amdgpu_dpm_get_pp_num_states(adev, &data);
>> +   state = data.states[idx];
>> +   /* only set user selected power states */
>> +   if (state != POWER_STATE_TYPE_INTERNAL_BOOT &&
>> +   state != POWER_STATE_TYPE_DEFAULT) {
>> +   amdgpu_dpm_dispatch_task(adev,
>> +   AMD_PP_EVENT_ENABLE_USER_STATE,
>> &state, NULL);
>> +   adev->pp_force_state_enabled = true;
>> }
>> }
>>   fail:
>
>
> ___
> dri-devel mailing list
> dri-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v5 8/8] drm/tilcdc: Avoid error print by of_graph_get_next_endpoint()

2016-06-17 Thread Jyri Sarha
Avoid error print by of_graph_get_next_endpoint() if there is no ports
present.

Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/tilcdc/tilcdc_external.c | 13 +++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_external.c 
b/drivers/gpu/drm/tilcdc/tilcdc_external.c
index 03acb4f..ad3db4d 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_external.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_external.c
@@ -138,12 +138,21 @@ static int dev_match_of(struct device *dev, void *data)
 int tilcdc_get_external_components(struct device *dev,
   struct component_match **match)
 {
+   struct device_node *node;
struct device_node *ep = NULL;
int count = 0;

-   while ((ep = of_graph_get_next_endpoint(dev->of_node, ep))) {
-   struct device_node *node;
+   /* Avoid error print by of_graph_get_next_endpoint() if there
+* is no ports present.
+*/
+   node = of_get_child_by_name(dev->of_node, "ports");
+   if (!node)
+   node = of_get_child_by_name(dev->of_node, "port");
+   if (!node)
+   return 0;
+   of_node_put(node);

+   while ((ep = of_graph_get_next_endpoint(dev->of_node, ep))) {
node = of_graph_get_remote_port_parent(ep);
if (!node && !of_device_is_available(node)) {
of_node_put(node);
-- 
1.9.1



[PATCH v5 7/8] drm/tilcdc: Refer to panel.txt and tfp410.txt bindings in tilcdc.txt

2016-06-17 Thread Jyri Sarha
The legacy panel.txt and tfp410.txt bindings are still the only supported
way to connect lcd panel and tfp410 DVI encoder to tilcdc.

Signed-off-by: Jyri Sarha 
---
 Documentation/devicetree/bindings/display/tilcdc/tilcdc.txt | 4 
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/display/tilcdc/tilcdc.txt 
b/Documentation/devicetree/bindings/display/tilcdc/tilcdc.txt
index 2136ee8..6efa4c5 100644
--- a/Documentation/devicetree/bindings/display/tilcdc/tilcdc.txt
+++ b/Documentation/devicetree/bindings/display/tilcdc/tilcdc.txt
@@ -24,6 +24,10 @@ Optional nodes:
binding follows Documentation/devicetree/bindings/graph.txt and
suppors a single port with a single endpoint.

+ - See also Documentation/devicetree/bindings/display/tilcdc/panel.txt and
+   Documentation/devicetree/bindings/display/tilcdc/tfp410.txt for connecting
+   tfp410 DVI encoder or lcd panel to lcdc
+
 Example:

fb: fb at 4830e000 {
-- 
1.9.1



[PATCH v5 6/8] drm/tilcdc: Call drm_crtc_vblank_on() and *_off() in start() and stop()

2016-06-17 Thread Jyri Sarha
Add drm_crtc_vblank_on() and *_off() calls to start() and stop()
functions, to make sure any vblank waits etc. gets properly cleaned
up.

Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c 
b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 419e43f..80ae134 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -109,6 +109,8 @@ static void start(struct drm_crtc *crtc)
tilcdc_clear(dev, LCDC_DMA_CTRL_REG, LCDC_DUAL_FRAME_BUFFER_ENABLE);
tilcdc_set(dev, LCDC_RASTER_CTRL_REG, 
LCDC_PALETTE_LOAD_MODE(DATA_ONLY));
tilcdc_set(dev, LCDC_RASTER_CTRL_REG, LCDC_RASTER_ENABLE);
+
+   drm_crtc_vblank_on(crtc);
 }

 static void stop(struct drm_crtc *crtc)
@@ -132,6 +134,8 @@ static void stop(struct drm_crtc *crtc)
dev_err(dev->dev, "%s: timeout waiting for framedone\n",
__func__);
}
+
+   drm_crtc_vblank_off(crtc);
 }

 static void tilcdc_crtc_destroy(struct drm_crtc *crtc)
-- 
1.9.1



[PATCH v5 5/8] drm/tilcdc: Increase time out for waiting frame done interrupt

2016-06-17 Thread Jyri Sarha
Increase time out for waiting frame done interrupt. 50ms is long
enough for the usual display modes (50 Hz or higher refresh rate), but
it may be a bit tight for some unusual mode.

Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c 
b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 4d90509..419e43f 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -127,7 +127,7 @@ static void stop(struct drm_crtc *crtc)
if (priv->rev == 2) {
int ret = wait_event_timeout(tilcdc_crtc->frame_done_wq,
 tilcdc_crtc->frame_done,
-msecs_to_jiffies(50));
+msecs_to_jiffies(500));
if (ret == 0)
dev_err(dev->dev, "%s: timeout waiting for framedone\n",
__func__);
-- 
1.9.1



[PATCH v5 4/8] drm/tilcdc: Move waiting of LCDC_FRAME_DONE IRQ into stop()

2016-06-17 Thread Jyri Sarha
Move wait queue waiting of LCDC_FRAME_DONE IRQ from tilcdc_crtc_dpms()
into stop() function. This is just a cleanup and enables independent
use of stop() function.

Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 31 ---
 1 file changed, 16 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c 
b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 65284e9..4d90509 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -113,9 +113,25 @@ static void start(struct drm_crtc *crtc)

 static void stop(struct drm_crtc *crtc)
 {
+   struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
struct drm_device *dev = crtc->dev;
+   struct tilcdc_drm_private *priv = dev->dev_private;

+   tilcdc_crtc->frame_done = false;
tilcdc_clear(dev, LCDC_RASTER_CTRL_REG, LCDC_RASTER_ENABLE);
+
+   /*
+* if necessary wait for framedone irq which will still come
+* before putting things to sleep..
+*/
+   if (priv->rev == 2) {
+   int ret = wait_event_timeout(tilcdc_crtc->frame_done_wq,
+tilcdc_crtc->frame_done,
+msecs_to_jiffies(50));
+   if (ret == 0)
+   dev_err(dev->dev, "%s: timeout waiting for framedone\n",
+   __func__);
+   }
 }

 static void tilcdc_crtc_destroy(struct drm_crtc *crtc)
@@ -212,22 +228,7 @@ void tilcdc_crtc_dpms(struct drm_crtc *crtc, int mode)
pm_runtime_get_sync(dev->dev);
start(crtc);
} else {
-   tilcdc_crtc->frame_done = false;
stop(crtc);
-
-   /*
-* if necessary wait for framedone irq which will still come
-* before putting things to sleep..
-*/
-   if (priv->rev == 2) {
-   int ret = wait_event_timeout(
-   tilcdc_crtc->frame_done_wq,
-   tilcdc_crtc->frame_done,
-   msecs_to_jiffies(50));
-   if (ret == 0)
-   dev_err(dev->dev, "timeout waiting for 
framedone\n");
-   }
-
pm_runtime_put_sync(dev->dev);

if (tilcdc_crtc->next_fb) {
-- 
1.9.1



[PATCH v5 3/8] drm/tilcdc: Write to LCDC_END_OF_INT_IND_REG at the end of IRQ function

2016-06-17 Thread Jyri Sarha
Reorder the IRQ function so that the write to LCDC_END_OF_INT_IND_REG
is done last. The write to LCDC_END_OF_INT_IND_REG indicates to LCDC
that the interrupt service routine has completed (see section
13.3.6.1.6 in AM335x TRM). This is needed if LCDC's ipgvmodirq module
is configured for pulse interrupts.

Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c 
b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 6309d3c..65284e9 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -725,12 +725,16 @@ irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc)
tilcdc_crtc->frame_intact = true;
}

+   if (stat & LCDC_FIFO_UNDERFLOW)
+   dev_err_ratelimited(dev->dev, "%s(0x%08x): FIFO underfow",
+   __func__, stat);
+
+   /* For revision 2 only */
if (priv->rev == 2) {
if (stat & LCDC_FRAME_DONE) {
tilcdc_crtc->frame_done = true;
wake_up(&tilcdc_crtc->frame_done_wq);
}
-   tilcdc_write(dev, LCDC_END_OF_INT_IND_REG, 0);

if (stat & LCDC_SYNC_LOST) {
dev_err_ratelimited(dev->dev, "%s(0x%08x): Sync lost",
@@ -743,11 +747,12 @@ irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc)
 LCDC_SYNC_LOST);
}
}
-   }

-   if (stat & LCDC_FIFO_UNDERFLOW)
-   dev_err_ratelimited(dev->dev, "%s(0x%08x): FIFO underfow",
-   __func__, stat);
+   /* Indicate to LCDC that the interrupt service routine has
+* completed, see 13.3.6.1.6 in AM335x TRM.
+*/
+   tilcdc_write(dev, LCDC_END_OF_INT_IND_REG, 0);
+   }

return IRQ_HANDLED;
 }
-- 
1.9.1



[PATCH v5 2/8] drm/tilcdc: Move LCDC_SYNC_LOST handling inside if (ver == 2) statement

2016-06-17 Thread Jyri Sarha
Move LCDC_SYNC_LOST handling inside if (ver == 2) statement.
LCDC_SYNC_LOST interrupt status bit is only defined for version 2
silicon.

Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 21 ++---
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c 
b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 4d8f9a5..6309d3c 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -731,18 +731,17 @@ irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc)
wake_up(&tilcdc_crtc->frame_done_wq);
}
tilcdc_write(dev, LCDC_END_OF_INT_IND_REG, 0);
-   }

-   if (stat & LCDC_SYNC_LOST) {
-   dev_err_ratelimited(dev->dev, "%s(0x%08x): Sync lost",
-   __func__, stat);
-   tilcdc_crtc->frame_intact = false;
-   if (tilcdc_crtc->sync_lost_count++ > SYNC_LOST_COUNT_LIMIT) {
-   dev_err(dev->dev,
-   "%s(0x%08x): Sync lost flood detected, 
disabling the interrupt",
-   __func__, stat);
-   tilcdc_write(dev, LCDC_INT_ENABLE_CLR_REG,
-LCDC_SYNC_LOST);
+   if (stat & LCDC_SYNC_LOST) {
+   dev_err_ratelimited(dev->dev, "%s(0x%08x): Sync lost",
+   __func__, stat);
+   tilcdc_crtc->frame_intact = false;
+   if (tilcdc_crtc->sync_lost_count++ >
+   SYNC_LOST_COUNT_LIMIT) {
+   dev_err(dev->dev, "%s(0x%08x): Sync lost flood 
detected, disabling the interrupt", __func__, stat);
+   tilcdc_write(dev, LCDC_INT_ENABLE_CLR_REG,
+LCDC_SYNC_LOST);
+   }
}
}

-- 
1.9.1



[PATCH v5 2/8] drm/tilcdc: Move LCDC_SYNC_LOST handling in side if (ver == 2) statement

2016-06-17 Thread Jyri Sarha
Move LCDC_SYNC_LOST handling in side if (ver == 2) statement.
LCDC_SYNC_LOST interrupt status bit is only defined for version 2
silicon.

Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 21 ++---
 1 file changed, 10 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c 
b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 4d8f9a5..6309d3c 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -731,18 +731,17 @@ irqreturn_t tilcdc_crtc_irq(struct drm_crtc *crtc)
wake_up(&tilcdc_crtc->frame_done_wq);
}
tilcdc_write(dev, LCDC_END_OF_INT_IND_REG, 0);
-   }

-   if (stat & LCDC_SYNC_LOST) {
-   dev_err_ratelimited(dev->dev, "%s(0x%08x): Sync lost",
-   __func__, stat);
-   tilcdc_crtc->frame_intact = false;
-   if (tilcdc_crtc->sync_lost_count++ > SYNC_LOST_COUNT_LIMIT) {
-   dev_err(dev->dev,
-   "%s(0x%08x): Sync lost flood detected, 
disabling the interrupt",
-   __func__, stat);
-   tilcdc_write(dev, LCDC_INT_ENABLE_CLR_REG,
-LCDC_SYNC_LOST);
+   if (stat & LCDC_SYNC_LOST) {
+   dev_err_ratelimited(dev->dev, "%s(0x%08x): Sync lost",
+   __func__, stat);
+   tilcdc_crtc->frame_intact = false;
+   if (tilcdc_crtc->sync_lost_count++ >
+   SYNC_LOST_COUNT_LIMIT) {
+   dev_err(dev->dev, "%s(0x%08x): Sync lost flood 
detected, disabling the interrupt", __func__, stat);
+   tilcdc_write(dev, LCDC_INT_ENABLE_CLR_REG,
+LCDC_SYNC_LOST);
+   }
}
}

-- 
1.9.1



[PATCH v5 1/8] drm/tilcdc: Restore old dpms state in pm_resume()

2016-06-17 Thread Jyri Sarha
Restore old dpms state in pm_resume(). The dpms is turned off in
pm_suspend() and it should be restored to its original state in
pm_resume(). Without this patch the display is left blanked after a
suspend/resume cycle.

Fixes commit 614b3cfeb8d2 ("drm/tilcdc: disable the lcd controller/dma
engine when suspend invoked")

Signed-off-by: Jyri Sarha 
---
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c | 7 +++
 drivers/gpu/drm/tilcdc/tilcdc_drv.c  | 3 +++
 drivers/gpu/drm/tilcdc/tilcdc_drv.h  | 2 ++
 3 files changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c 
b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
index 79027b1..4d8f9a5 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -246,6 +246,13 @@ void tilcdc_crtc_dpms(struct drm_crtc *crtc, int mode)
}
 }

+int tilcdc_crtc_current_dpms_state(struct drm_crtc *crtc)
+{
+   struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
+
+   return tilcdc_crtc->dpms;
+}
+
 static bool tilcdc_crtc_mode_fixup(struct drm_crtc *crtc,
const struct drm_display_mode *mode,
struct drm_display_mode *adjusted_mode)
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.c 
b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
index 308e197..148b1ed 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.c
@@ -598,6 +598,7 @@ static int tilcdc_pm_suspend(struct device *dev)
}

/* Disable the LCDC controller, to avoid locking up the PRCM */
+   priv->saved_dpms_state = tilcdc_crtc_current_dpms_state(priv->crtc);
tilcdc_crtc_dpms(priv->crtc, DRM_MODE_DPMS_OFF);

/* Save register state: */
@@ -628,6 +629,8 @@ static int tilcdc_pm_resume(struct device *dev)
 priv->saved_register[n++]);
}

+   tilcdc_crtc_dpms(priv->crtc, priv->saved_dpms_state);
+
drm_kms_helper_poll_enable(ddev);

return 0;
diff --git a/drivers/gpu/drm/tilcdc/tilcdc_drv.h 
b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
index c1de18b..3b52ce8 100644
--- a/drivers/gpu/drm/tilcdc/tilcdc_drv.h
+++ b/drivers/gpu/drm/tilcdc/tilcdc_drv.h
@@ -67,6 +67,7 @@ struct tilcdc_drm_private {

/* register contents saved across suspend/resume: */
u32 *saved_register;
+   int saved_dpms_state;
bool ctx_valid;

 #ifdef CONFIG_CPU_FREQ
@@ -172,5 +173,6 @@ void tilcdc_crtc_set_simulate_vesa_sync(struct drm_crtc 
*crtc,
 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);
+int tilcdc_crtc_current_dpms_state(struct drm_crtc *crtc);

 #endif /* __TILCDC_DRV_H__ */
-- 
1.9.1



[PATCH v5 0/8] drm/tilcdc Fixes and cleanups

2016-06-17 Thread Jyri Sarha
Some fixes and cleanups that should get merged to tilcdc even if my
atomic changes are still a work in progress.

Yet one more round, sorry for spamming.

Changes since v4:
- Split 
  "drm/tilcdc: Move LCDC_SYNC_LOST handling inside if (ver == 2) statement"
  out of 
  "drm/tilcdc: Write to LCDC_END_OF_INT_IND_REG at the end of IRQ"

Changes since v3:
- "drm/tilcdc: Write to LCDC_END_OF_INT_IND_REG at the end of IRQ"
  - Do not bail out in the middle of irq routine, use full
"if (rev == 2)"-statement in stead

Changes since v2:
- "drm/tilcdc: Restore old dpms state in pm_resume()"
  - Improve description
- "drm/tilcdc: Write to LCDC_END_OF_INT_IND_REG at the end of IRQ
  - Handle LCDC_FIFO_UNDERFLOW also for v1 silicon
- "drm/tilcdc: Move waiting of LCDC_FRAME_DONE IRQ into stop()"
  - Improve description
- Add "drm/tilcdc: Increase time out for waiting frame done interrupt"

Changes since first version:
- "drm/tilcdc: Restore old dpms state in pm_resume()"
  - Fix typos from description and subject
- Add "drm/tilcdc: Call drm_crtc_vblank_on() and *_off() in start() and
  stop()"

Jyri Sarha (8):
  drm/tilcdc: Restore old dpms state in pm_resume()
  drm/tilcdc: Move LCDC_SYNC_LOST handling inside if (ver == 2)
statement
  drm/tilcdc: Write to LCDC_END_OF_INT_IND_REG at the end of IRQ
function
  drm/tilcdc: Move waiting of LCDC_FRAME_DONE IRQ into stop()
  drm/tilcdc: Increase time out for waiting frame done interrupt
  drm/tilcdc: Call drm_crtc_vblank_on() and *_off() in start() and
stop()
  drm/tilcdc: Refer to panel.txt and tfp410.txt bindings in tilcdc.txt
  drm/tilcdc: Avoid error print by of_graph_get_next_endpoint()

 .../devicetree/bindings/display/tilcdc/tilcdc.txt  |  4 ++
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c   | 78 +-
 drivers/gpu/drm/tilcdc/tilcdc_drv.c|  3 +
 drivers/gpu/drm/tilcdc/tilcdc_drv.h|  2 +
 drivers/gpu/drm/tilcdc/tilcdc_external.c   | 13 +++-
 5 files changed, 67 insertions(+), 33 deletions(-)

-- 
1.9.1



[PATCH 5/5] drm/imx: don't destroy mode objects manually on driver unbind

2016-06-17 Thread Lucas Stach
Instead let drm_mode_config_cleanup() do the work when taking down
the master device. This requires all cleanup functions to be
properly hooked up to the mode object .destroy callback.

Signed-off-by: Lucas Stach 
---
 drivers/gpu/drm/bridge/dw-hdmi.c   | 3 ---
 drivers/gpu/drm/imx/imx-drm-core.c | 4 ++--
 drivers/gpu/drm/imx/imx-ldb.c  | 6 --
 drivers/gpu/drm/imx/imx-tve.c  | 3 ---
 drivers/gpu/drm/imx/ipuv3-crtc.c   | 9 ++---
 drivers/gpu/drm/imx/parallel-display.c | 3 ---
 6 files changed, 8 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/bridge/dw-hdmi.c b/drivers/gpu/drm/bridge/dw-hdmi.c
index c9d941283d30..5f97977f7e5c 100644
--- a/drivers/gpu/drm/bridge/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/dw-hdmi.c
@@ -1834,9 +1834,6 @@ void dw_hdmi_unbind(struct device *dev, struct device 
*master, void *data)
/* Disable all interrupts */
hdmi_writeb(hdmi, ~0, HDMI_IH_MUTE_PHY_STAT0);

-   hdmi->connector.funcs->destroy(&hdmi->connector);
-   hdmi->encoder->funcs->destroy(hdmi->encoder);
-
clk_disable_unprepare(hdmi->iahb_clk);
clk_disable_unprepare(hdmi->isfr_clk);
i2c_put_adapter(hdmi->ddc);
diff --git a/drivers/gpu/drm/imx/imx-drm-core.c 
b/drivers/gpu/drm/imx/imx-drm-core.c
index 799a68976590..71e33666cae8 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -466,11 +466,11 @@ static void imx_drm_unbind(struct device *dev)
if (fbhelper)
drm_fbdev_cma_fini(fbhelper);

+   drm_mode_config_cleanup(drm);
+
component_unbind_all(drm->dev, drm);
dev_set_drvdata(dev, NULL);

-   drm_mode_config_cleanup(drm);
-
drm_dev_unref(drm);
 }

diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c
index 9e117a654417..b49948d51110 100644
--- a/drivers/gpu/drm/imx/imx-ldb.c
+++ b/drivers/gpu/drm/imx/imx-ldb.c
@@ -674,12 +674,6 @@ static void imx_ldb_unbind(struct device *dev, struct 
device *master,
if (channel->panel)
drm_panel_detach(channel->panel);

-   if (!channel->connector.funcs)
-   continue;
-
-   channel->connector.funcs->destroy(&channel->connector);
-   channel->encoder.funcs->destroy(&channel->encoder);
-
kfree(channel->edid);
i2c_put_adapter(channel->ddc);
}
diff --git a/drivers/gpu/drm/imx/imx-tve.c b/drivers/gpu/drm/imx/imx-tve.c
index baf788121287..3973b2c85e2d 100644
--- a/drivers/gpu/drm/imx/imx-tve.c
+++ b/drivers/gpu/drm/imx/imx-tve.c
@@ -688,9 +688,6 @@ static void imx_tve_unbind(struct device *dev, struct 
device *master,
 {
struct imx_tve *tve = dev_get_drvdata(dev);

-   tve->connector.funcs->destroy(&tve->connector);
-   tve->encoder.funcs->destroy(&tve->encoder);
-
if (!IS_ERR(tve->dac_reg))
regulator_disable(tve->dac_reg);
 }
diff --git a/drivers/gpu/drm/imx/ipuv3-crtc.c b/drivers/gpu/drm/imx/ipuv3-crtc.c
index fc040417e1e8..4d5dbea48cef 100644
--- a/drivers/gpu/drm/imx/ipuv3-crtc.c
+++ b/drivers/gpu/drm/imx/ipuv3-crtc.c
@@ -228,9 +228,14 @@ put_vblank:
return ret;
 }

+static void ipu_crtc_cleanup(struct drm_crtc *crtc)
+{
+   imx_drm_remove_crtc(to_ipu_crtc(crtc)->imx_crtc);
+}
+
 static const struct drm_crtc_funcs ipu_crtc_funcs = {
.set_config = drm_crtc_helper_set_config,
-   .destroy = drm_crtc_cleanup,
+   .destroy = ipu_crtc_cleanup,
.page_flip = ipu_page_flip,
 };

@@ -551,8 +556,6 @@ static void ipu_drm_unbind(struct device *dev, struct 
device *master,
 {
struct ipu_crtc *ipu_crtc = dev_get_drvdata(dev);

-   imx_drm_remove_crtc(ipu_crtc->imx_crtc);
-
destroy_workqueue(ipu_crtc->flip_queue);
ipu_plane_put_resources(ipu_crtc->plane[0]);
ipu_put_resources(ipu_crtc);
diff --git a/drivers/gpu/drm/imx/parallel-display.c 
b/drivers/gpu/drm/imx/parallel-display.c
index 2d1fd02cd3d6..a1fa8fc91336 100644
--- a/drivers/gpu/drm/imx/parallel-display.c
+++ b/drivers/gpu/drm/imx/parallel-display.c
@@ -248,9 +248,6 @@ static void imx_pd_unbind(struct device *dev, struct device 
*master,
 {
struct imx_parallel_display *imxpd = dev_get_drvdata(dev);

-   imxpd->encoder.funcs->destroy(&imxpd->encoder);
-   imxpd->connector.funcs->destroy(&imxpd->connector);
-
kfree(imxpd->edid);
 }

-- 
2.8.1



[PATCH 4/5] drm/imx: drop deprecated load/unload drm_driver ops

2016-06-17 Thread Lucas Stach
Drop the load/unload driver ops, as they are deprecated because of their
inherent races, with devices being visible to userspace before they are
fully initialized.

Move this code into the driver bind/unbind routines bracketed by the
proper drm_dev_alloc/register and drm_dev_unregister/unref calls.

Signed-off-by: Lucas Stach 
---
 drivers/gpu/drm/imx/imx-drm-core.c | 247 ++---
 1 file changed, 121 insertions(+), 126 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-drm-core.c 
b/drivers/gpu/drm/imx/imx-drm-core.c
index c63378661e11..799a68976590 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -78,25 +78,6 @@ static void imx_drm_driver_lastclose(struct drm_device *drm)
}
 }

-static int imx_drm_driver_unload(struct drm_device *drm)
-{
-   struct imx_drm_device *imxdrm = drm->dev_private;
-
-   drm_kms_helper_poll_fini(drm);
-
-   if (imxdrm->fbhelper)
-   drm_fbdev_cma_fini(imxdrm->fbhelper);
-
-   component_unbind_all(drm->dev, drm);
-
-   drm_vblank_cleanup(drm);
-   drm_mode_config_cleanup(drm);
-
-   platform_set_drvdata(drm->platformdev, NULL);
-
-   return 0;
-}
-
 static struct imx_drm_crtc *imx_drm_find_crtc(struct drm_crtc *crtc)
 {
struct imx_drm_device *imxdrm = crtc->dev->dev_private;
@@ -223,109 +204,6 @@ static const struct drm_mode_config_funcs 
imx_drm_mode_config_funcs = {
 };

 /*
- * Main DRM initialisation. This binds, initialises and registers
- * with DRM the subcomponents of the driver.
- */
-static int imx_drm_driver_load(struct drm_device *drm, unsigned long flags)
-{
-   struct imx_drm_device *imxdrm;
-   struct drm_connector *connector;
-   int ret;
-
-   imxdrm = devm_kzalloc(drm->dev, sizeof(*imxdrm), GFP_KERNEL);
-   if (!imxdrm)
-   return -ENOMEM;
-
-   imxdrm->drm = drm;
-
-   drm->dev_private = imxdrm;
-
-   /*
-* enable drm irq mode.
-* - with irq_enabled = true, we can use the vblank feature.
-*
-* P.S. note that we wouldn't use drm irq handler but
-*  just specific driver own one instead because
-*  drm framework supports only one irq handler and
-*  drivers can well take care of their interrupts
-*/
-   drm->irq_enabled = true;
-
-   /*
-* set max width and height as default value(4096x4096).
-* this value would be used to check framebuffer size limitation
-* at drm_mode_addfb().
-*/
-   drm->mode_config.min_width = 64;
-   drm->mode_config.min_height = 64;
-   drm->mode_config.max_width = 4096;
-   drm->mode_config.max_height = 4096;
-   drm->mode_config.funcs = &imx_drm_mode_config_funcs;
-
-   drm_mode_config_init(drm);
-
-   ret = drm_vblank_init(drm, MAX_CRTC);
-   if (ret)
-   goto err_kms;
-
-   platform_set_drvdata(drm->platformdev, drm);
-
-   /* Now try and bind all our sub-components */
-   ret = component_bind_all(drm->dev, drm);
-   if (ret)
-   goto err_vblank;
-
-   /*
-* All components are now added, we can publish the connector sysfs
-* entries to userspace.  This will generate hotplug events and so
-* userspace will expect to be able to access DRM at this point.
-*/
-   list_for_each_entry(connector, &drm->mode_config.connector_list, head) {
-   ret = drm_connector_register(connector);
-   if (ret) {
-   dev_err(drm->dev,
-   "[CONNECTOR:%d:%s] drm_connector_register 
failed: %d\n",
-   connector->base.id,
-   connector->name, ret);
-   goto err_unbind;
-   }
-   }
-
-   /*
-* All components are now initialised, so setup the fb helper.
-* The fb helper takes copies of key hardware information, so the
-* crtcs/connectors/encoders must not change after this point.
-*/
-#if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION)
-   if (legacyfb_depth != 16 && legacyfb_depth != 32) {
-   dev_warn(drm->dev, "Invalid legacyfb_depth.  Defaulting to 
16bpp\n");
-   legacyfb_depth = 16;
-   }
-   drm_helper_disable_unused_functions(drm);
-   imxdrm->fbhelper = drm_fbdev_cma_init(drm, legacyfb_depth,
-   drm->mode_config.num_crtc, MAX_CRTC);
-   if (IS_ERR(imxdrm->fbhelper)) {
-   ret = PTR_ERR(imxdrm->fbhelper);
-   imxdrm->fbhelper = NULL;
-   goto err_unbind;
-   }
-#endif
-
-   drm_kms_helper_poll_init(drm);
-
-   return 0;
-
-err_unbind:
-   component_unbind_all(drm->dev, drm);
-err_vblank:
-   drm_vblank_cleanup(drm);
-err_kms:
-   drm_mode_config_cleanup(drm);
-
-   return ret;
-}
-
-/*
  * imx_drm_add_crtc - add a new crtc
  */
 int imx_d

[PATCH 3/5] drm/imx: imx-ldb: detach panel on unbind

2016-06-17 Thread Lucas Stach
Make sure to leave a clean panel state behind and allow to
properly attach to the panel again on a rebind.

Signed-off-by: Lucas Stach 
---
 drivers/gpu/drm/imx/imx-ldb.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c
index 48166df14042..9e117a654417 100644
--- a/drivers/gpu/drm/imx/imx-ldb.c
+++ b/drivers/gpu/drm/imx/imx-ldb.c
@@ -671,6 +671,9 @@ static void imx_ldb_unbind(struct device *dev, struct 
device *master,
for (i = 0; i < 2; i++) {
struct imx_ldb_channel *channel = &imx_ldb->channel[i];

+   if (channel->panel)
+   drm_panel_detach(channel->panel);
+
if (!channel->connector.funcs)
continue;

-- 
2.8.1



[PATCH 2/5] drm/imx: imx-ldb: check return code on panel attach

2016-06-17 Thread Lucas Stach
Check the return code on panel attach. Avoids a kernel crash later
on if the attach failed.

Signed-off-by: Lucas Stach 
---
 drivers/gpu/drm/imx/imx-ldb.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-ldb.c b/drivers/gpu/drm/imx/imx-ldb.c
index beff793bb717..48166df14042 100644
--- a/drivers/gpu/drm/imx/imx-ldb.c
+++ b/drivers/gpu/drm/imx/imx-ldb.c
@@ -427,8 +427,12 @@ static int imx_ldb_register(struct drm_device *drm,
drm_connector_init(drm, &imx_ldb_ch->connector,
   &imx_ldb_connector_funcs, DRM_MODE_CONNECTOR_LVDS);

-   if (imx_ldb_ch->panel)
-   drm_panel_attach(imx_ldb_ch->panel, &imx_ldb_ch->connector);
+   if (imx_ldb_ch->panel) {
+   ret = drm_panel_attach(imx_ldb_ch->panel,
+  &imx_ldb_ch->connector);
+   if (ret)
+   return ret;
+   }

drm_mode_connector_attach_encoder(&imx_ldb_ch->connector,
&imx_ldb_ch->encoder);
-- 
2.8.1



[PATCH 1/5] drm/imx: disable outputs in lastclose when framebuffer emulation is disabled

2016-06-17 Thread Lucas Stach
If there is no framebuffer mode that can be restored, all outputs should
be disabled in order to avoid information leaks.

Signed-off-by: Lucas Stach 
---
 drivers/gpu/drm/imx/imx-drm-core.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/imx/imx-drm-core.c 
b/drivers/gpu/drm/imx/imx-drm-core.c
index 82656654fb21..c63378661e11 100644
--- a/drivers/gpu/drm/imx/imx-drm-core.c
+++ b/drivers/gpu/drm/imx/imx-drm-core.c
@@ -63,7 +63,19 @@ static void imx_drm_driver_lastclose(struct drm_device *drm)
 {
struct imx_drm_device *imxdrm = drm->dev_private;

-   drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
+   if (imxdrm->fbhelper) {
+   drm_fbdev_cma_restore_mode(imxdrm->fbhelper);
+   } else {
+   struct drm_connector *connector;
+
+   /* no kernel mode to go back to, disable all outputs */
+   drm_modeset_lock_all(drm);
+   drm_for_each_connector(connector, drm)
+   connector->encoder = NULL;
+   drm_modeset_unlock_all(drm);
+
+   drm_helper_disable_unused_functions(drm);
+   }
 }

 static int imx_drm_driver_unload(struct drm_device *drm)
-- 
2.8.1



  1   2   >