Re: [PATCH v1 0/6] misc: add reboot mode driver

2015-12-28 Thread Andy Yan

Hi Arnd:

On 2015年12月28日 23:28, Arnd Bergmann wrote:

On Wednesday 23 December 2015 17:31:45 Andy Yan wrote:

 I also have the idea to put is in drivers/power/reset,  But considering
 this driver have not bind anything about power, so I put it in
driver/misc
 at last. So I hope if some people can give more suggestions here.

I vote for drivers/power/reset as well. On some platforms, the two things
are related, on others they are not, but it's good to have it all in one
place I think.

Okay, I will move to drivers/power/reset next version.

   drivers/soc/rockchip/Kconfig   |  9 ++
   drivers/soc/rockchip/Makefile  |  1 +
   drivers/soc/rockchip/reboot.c | 68 +++

And maybe that part could be made generic instead of rockchip specific.
It simply uses a regmap to do the accesses, I guess a lot of other
platforms will do that. We have syscon-reboot and syscon-poweroff for example.

I think then we can extend the "framework" by having generic drivers to
store the value in eeprom or nvram for example.


 I also hope the write interface can be generic. But I found some
platform
 use different hardware to store the value. For example, John's patch
use
 SRAM on qcom apq8064 to store value for nexus7. It seems there also have
 some platform use dram or nvram to store it. And these different
hardware use
 different write method. I don't have a generic way to handle this.

 I have a idea to handle it like this:

+static const struct of_device_id reboot_mode_dt_match[] = {
+{ .compatible = "linux,reboot-mode-sfr",/*for magic value
stored in special function register, which  can be accessed by regmap*/
+.data = (void *)&reboot-mode-sfr },

I'd make this one syscon-reboot-mode, to go along with syscon-poweroff
as implemented by drivers/power/reset/syscon-poweroff.c. The syscon concept
is already generic enough that we don't need a linux prefix for that.

Okay, syscon is better.

+{ .compatible = "linux,reboot-mode-sram",  /*for magic value
stored in
+.data = (void *)&reboot-mode-sram },

the sram mode should probably follow the generic SRAM binding and make
the location that stores the reboot mode a separate partition, unless
we want to store other data in the same partition, in which case we might
want to use the same implementation as for the nvram.


+{ .compatible = "linux,reboot-mode-sdram",
+.data = (void *)&reboot-mode-sdram }, /*for magic value
stored

I think "sdram" is not an appropriate name here, as the main system memory
might use some other technology, e.g. DRAM or DDR2-SDRAM.


+{ .compatible = "rockchip,reboot-mode-nvram",
+.data = (void *)&reboot-mode-nvram },
+{},
+};

nvram is a complex topic by itself, because there are so many ways to do it.
I think what you are referring to here is a battery-backed memory that uses
one or more bytes at a fixed offset to store a particular piece of information,
as the drivers/char/nvram.c driver does. Maybe we should put the reboot mode
into that driver then?

There are other nvram drivers at various places in the kernel, and each may
be slightly different, or completely different, like the EFIVARs driver on
UEFI firmware or the key/value store on Open Firmware, these probably need
their own methods and not share the generic driver.


 the data point to different hardware access method.

Hope to see more suggestions from you.

It's probably best to leave these four examples as separate drivers and we can
add further ones when needed.

Arnd


Okay, thanks for your suggestion.  I will add the reboot-mode.c as 
the core library, syscon-reboot-mode.c as one example first. As for 
sram/dram/nvram case, I am not familiar with them, so hope there are 
some hero will extend them when needed.



--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v1 0/6] misc: add reboot mode driver

2015-12-23 Thread Andy Yan

Hi Alexandre:

On 2015年12月23日 00:47, Alexandre Belloni wrote:

Hi,

On 22/12/2015 at 17:02:29 +0800, Andy Yan wrote :

This driver parse the reboot commands like "reboot loader"
and "reboot recovery" to get a boot mode described in the
device tree , then call the vendor specific write interfae
to store the boot mode in some place like special register
or sram , which can be read by the bootloader after system
reboot.

This is commonly done on Android based devices, in order to
reboot the device into fastboot or recovery mode.

Before this patch , I have try some hack on[0], and then found
John Stultz also doing the same work[1].

As John is busy these days, I go on with this work.

[0]https://patchwork.kernel.org/patch/7647751/
[1]https://patchwork.kernel.org/patch/7802391/

Changes in v1:
- fix the embarrassed compile warning
- correct the maskrom magic number
- check for the normal reboot
- correct the maskrom magic number
- use macro defined in rockchip_boot-mode.h for reboot-mode DT node

Andy Yan (6):
   dt-bindings: misc: add document for reboot-mode driver
   dt-bindings: soc: add document for rockchip reboot-mode driver
   misc: add reboot mode driver
   soc: rockchip: add reboot mode driver
   ARM: dts: rockchip: add reboot-mode node
   ARM64: dts: rockchip: add reboot-mode node


This seems nice and useful, some further ideas:


  .../devicetree/bindings/misc/reboot-mode.txt   | 41 +
  .../bindings/soc/rockchip/rockchip,reboot-mode.txt | 39 +
  arch/arm/boot/dts/rk3288.dtsi  | 26 ++
  arch/arm/boot/dts/rk3xxx.dtsi  | 26 ++
  arch/arm64/boot/dts/rockchip/rk3368.dtsi   | 26 ++
  drivers/misc/Kconfig   |  7 ++
  drivers/misc/Makefile  |  1 +
  drivers/misc/reboot_mode.c | 96 ++

I think this actually belongs to drivers/power/reset/ instead of misc


   I also have the idea to put is in drivers/power/reset,  But considering
   this driver have not bind anything about power, so I put it in 
driver/misc

   at last. So I hope if some people can give more suggestions here.



  drivers/soc/rockchip/Kconfig   |  9 ++
  drivers/soc/rockchip/Makefile  |  1 +
  drivers/soc/rockchip/reboot.c  | 68 +++

And maybe that part could be made generic instead of rockchip specific.
It simply uses a regmap to do the accesses, I guess a lot of other
platforms will do that. We have syscon-reboot and syscon-poweroff for example.

I think then we can extend the "framework" by having generic drivers to
store the value in eeprom or nvram for example.



   I also hope the write interface can be generic. But I found some 
platform
   use different hardware to store the value. For example, John's patch 
use

   SRAM on qcom apq8064 to store value for nexus7. It seems there also have
   some platform use dram or nvram to store it. And these different 
hardware use

   different write method. I don't have a generic way to handle this.

   I have a idea to handle it like this:

+static const struct of_device_id reboot_mode_dt_match[] = {
+{ .compatible = "linux,reboot-mode-sfr",/*for magic value 
stored in special function register, which  can be accessed by regmap*/

+.data = (void *)&reboot-mode-sfr },
+{ .compatible = "linux,reboot-mode-sram",  /*for magic value 
stored in

+.data = (void *)&reboot-mode-sram },
+{ .compatible = "linux,reboot-mode-sdram",
+.data = (void *)&reboot-mode-sdram }, /*for magic value 
stored

+{ .compatible = "rockchip,reboot-mode-nvram",
+.data = (void *)&reboot-mode-nvram },
+{},
+};

   the data point to different hardware access method.

  Hope to see more suggestions from you.

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v1 1/6] dt-bindings: misc: add document for reboot-mode driver

2015-12-23 Thread Andy Yan

Hi Rob:

On 2015年12月23日 08:32, Rob Herring wrote:

On Tue, Dec 22, 2015 at 05:05:24PM +0800, Andy Yan wrote:

add device tree bindings document for reboot-mode driver

Signed-off-by: Andy Yan 

---

Changes in v1: None

  .../devicetree/bindings/misc/reboot-mode.txt   | 41 ++
  1 file changed, 41 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/misc/reboot-mode.txt

diff --git a/Documentation/devicetree/bindings/misc/reboot-mode.txt 
b/Documentation/devicetree/bindings/misc/reboot-mode.txt
new file mode 100644
index 000..082bc0c
--- /dev/null
+++ b/Documentation/devicetree/bindings/misc/reboot-mode.txt
@@ -0,0 +1,41 @@
+Generic reboot mode communication driver

You're not describing a driver. It is a mapping of boot modes to values.

+
+This driver get reboot mode arguments from userspace

Coming from userspace is a Linuxism.


+and stores it in special register or ram . Then the
+bootloader will read it and take different action
+according the argument stored.
+
+Required properties:
+- compatible = "reboot-mode" or other vendor compatible string;
+
+Each mode is represented as a sub-node of reboot_mode:
+
+Subnode required properties:
+- linux,mode: reboot mode command,such as "loader","recovery", 
"fastboot".
+- linux,magic: magic number for the mode, this is vendor specific.
+
+example:
+   reboot_mode {
+   compatible = "rockchip,reboot-mode";
+   rockchip,regmap = <&pmu>;
+   offset = <0x40>;
+   loader {
+   linux,mode = "loader";
+   linux,magic = <0x5242C301>;
+   };

These can be much more simply expressed as:

loader = <0x5242c301>;

   how about :
   loader,magic= <0x5242c301>; ?


I would like to see the property names here standardized as much as
possible. I'm not sure if we can define the properties as a u32 or need
some flexibility here.

Rob






--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v1 6/6] ARM64: dts: rockchip: add reboot-mode node

2015-12-22 Thread Andy Yan
Add reboot mode driver DT node for rk3368 platform

Signed-off-by: Andy Yan 
---

Changes in v1: None

 arch/arm64/boot/dts/rockchip/rk3368.dtsi | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3368.dtsi 
b/arch/arm64/boot/dts/rockchip/rk3368.dtsi
index cc093a4..776f1be 100644
--- a/arch/arm64/boot/dts/rockchip/rk3368.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3368.dtsi
@@ -45,6 +45,7 @@
 #include 
 #include 
 #include 
+#include 
 
 / {
compatible = "rockchip,rk3368";
@@ -202,6 +203,31 @@
method = "smc";
};
 
+   reboot_mode {
+   compatible = "rockchip,reboot-mode";
+   rockchip,regmap = <&pmugrf>;
+   offset = <0x200>;
+   loader {
+   linux,mode = "loader";
+   linux,magic = ;
+   };
+
+   maskrom {
+   linux,mode = "maskrom";
+   linux,magic = ;
+   };
+
+   recovery {
+   linux,mode = "recovery";
+   linux,magic = ;
+   };
+
+   fastboot {
+   linux,mode = "fastboot";
+   linux,magic = ;
+   };
+   };
+
timer {
compatible = "arm,armv8-timer";
interrupts = http://vger.kernel.org/majordomo-info.html


[PATCH v1 5/6] ARM: dts: rockchip: add reboot-mode node

2015-12-22 Thread Andy Yan
Add reboot mode driver DT node for rk3xxx,rk3288 platform

Signed-off-by: Andy Yan 

---

Changes in v1:
- correct the maskrom magic number
- use macro defined in rockchip_boot-mode.h for reboot-mode DT node

 arch/arm/boot/dts/rk3288.dtsi | 26 ++
 arch/arm/boot/dts/rk3xxx.dtsi | 26 ++
 2 files changed, 52 insertions(+)

diff --git a/arch/arm/boot/dts/rk3288.dtsi b/arch/arm/boot/dts/rk3288.dtsi
index 04ea209..c6ea207 100644
--- a/arch/arm/boot/dts/rk3288.dtsi
+++ b/arch/arm/boot/dts/rk3288.dtsi
@@ -45,6 +45,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "skeleton.dtsi"
 
 / {
@@ -170,6 +171,31 @@
};
};
 
+   reboot_mode {
+   compatible = "rockchip,reboot-mode";
+   rockchip,regmap = <&pmu>;
+   offset = <0x94>;
+   loader {
+   linux,mode = "loader";
+   linux,magic = ;
+   };
+
+   maskrom {
+   linux,mode = "maskrom";
+   linux,magic = ;
+   };
+
+   recovery {
+   linux,mode = "recovery";
+   linux,magic = ;
+   };
+
+   fastboot {
+   linux,mode = "fastboot";
+   linux,magic = ;
+   };
+   };
+
reserved-memory {
#address-cells = <1>;
#size-cells = <1>;
diff --git a/arch/arm/boot/dts/rk3xxx.dtsi b/arch/arm/boot/dts/rk3xxx.dtsi
index 4497d28..735eef4 100644
--- a/arch/arm/boot/dts/rk3xxx.dtsi
+++ b/arch/arm/boot/dts/rk3xxx.dtsi
@@ -43,6 +43,7 @@
 
 #include 
 #include 
+#include 
 #include "skeleton.dtsi"
 
 / {
@@ -103,6 +104,31 @@
};
};
 
+   reboot_mode {
+   compatible = "rockchip,reboot-mode";
+   rockchip,regmap = <&pmu>;
+   offset = <0x40>;
+   loader {
+   linux,mode = "loader";
+   linux,magic = ;
+   };
+
+   maskrom {
+   linux,mode = "maskrom";
+   linux,magic = ;
+   };
+
+   recovery {
+   linux,mode = "recovery";
+   linux,magic = ;
+   };
+
+   fastboot {
+   linux,mode = "fastboot";
+   linux,magic = ;
+   };
+   };
+
xin24m: oscillator {
compatible = "fixed-clock";
clock-frequency = <2400>;
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v1 4/6] soc: rockchip: add reboot mode driver

2015-12-22 Thread Andy Yan
rockchip platform have a protocol to pass the kernel reboot
mode to bootloader by some special registers when system reboot.
By this way the bootloader can take different action according
to the different kernel reboot mode, for example, command
"reboot loader" will reboot the board to rockusb mode, this is
a very convenient way to get the board enter download mode.

Signed-off-by: Andy Yan 

---

Changes in v1:
- fix the embarrassed compile warning
- correct the maskrom magic number
- check for the normal reboot

 drivers/soc/rockchip/Kconfig |  9 
 drivers/soc/rockchip/Makefile|  1 +
 drivers/soc/rockchip/reboot.c| 68 
 include/dt-bindings/soc/rockchip_boot-mode.h | 30 
 4 files changed, 108 insertions(+)
 create mode 100644 drivers/soc/rockchip/reboot.c
 create mode 100644 include/dt-bindings/soc/rockchip_boot-mode.h

diff --git a/drivers/soc/rockchip/Kconfig b/drivers/soc/rockchip/Kconfig
index 7140ff8..42525f8 100644
--- a/drivers/soc/rockchip/Kconfig
+++ b/drivers/soc/rockchip/Kconfig
@@ -15,4 +15,13 @@ config ROCKCHIP_PM_DOMAINS
 
   If unsure, say N.
 
+config ROCKCHIP_REBOOT
+   bool "Rockchip reboot mode driver"
+   select REBOOT_MODE
+   help
+ Say y here will enable reboot mode driver. This will
+ get reboot mode arguments from userspace and store it
+ in special register, then the bootloader will read it
+ to take different action according to the mode.
+
 endif
diff --git a/drivers/soc/rockchip/Makefile b/drivers/soc/rockchip/Makefile
index 3d73d06..9817496 100644
--- a/drivers/soc/rockchip/Makefile
+++ b/drivers/soc/rockchip/Makefile
@@ -2,3 +2,4 @@
 # Rockchip Soc drivers
 #
 obj-$(CONFIG_ROCKCHIP_PM_DOMAINS) += pm_domains.o
+obj-$(CONFIG_ROCKCHIP_REBOOT) += reboot.o
diff --git a/drivers/soc/rockchip/reboot.c b/drivers/soc/rockchip/reboot.c
new file mode 100644
index 000..7024532
--- /dev/null
+++ b/drivers/soc/rockchip/reboot.c
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static struct regmap *map;
+static u32 offset;
+
+static int rockchip_reboot_mode_write(int magic)
+{
+   if (!magic)
+   magic = BOOT_NORMAL;
+
+   regmap_write(map, offset, magic);
+
+   return 0;
+}
+
+static int rockchip_reboot_probe(struct platform_device *pdev)
+{
+   int ret;
+
+   map = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
+ "rockchip,regmap");
+   if (IS_ERR(map))
+   return PTR_ERR(map);
+
+   if (of_property_read_u32(pdev->dev.of_node, "offset", &offset))
+   return -EINVAL;
+
+   ret = reboot_mode_register(&pdev->dev, rockchip_reboot_mode_write);
+   if (ret)
+   dev_err(&pdev->dev, "can't register reboot mode\n");
+
+   return ret;
+}
+
+static const struct of_device_id rockchip_reboot_of_match[] = {
+   { .compatible = "rockchip,reboot-mode" },
+   {}
+};
+
+static struct platform_driver rockchip_reboot_driver = {
+   .probe = rockchip_reboot_probe,
+   .driver = {
+   .name = "rockchip-reboot",
+   .of_match_table = rockchip_reboot_of_match,
+   },
+};
+module_platform_driver(rockchip_reboot_driver);
+
+MODULE_AUTHOR("Andy Yan http://vger.kernel.org/majordomo-info.html


[PATCH v1 3/6] misc: add reboot mode driver

2015-12-22 Thread Andy Yan
This driver parse the reboot commands like "reboot loader"
and "reboot recovery" to get a boot mode described in the
device tree , then call the vendor specific write interfae
to store the boot mode in some place like special register
or sram , which can be read by the bootloader after system
reboot, then the bootloader can take different action according
to the mode stored.

This is commonly used on Android based devices, in order to
reboot the device into fastboot or recovery mode.

Signed-off-by: Andy Yan 
---

Changes in v1: None

 drivers/misc/Kconfig   |  7 
 drivers/misc/Makefile  |  1 +
 drivers/misc/reboot_mode.c | 96 ++
 include/linux/reboot.h |  4 +-
 4 files changed, 107 insertions(+), 1 deletion(-)
 create mode 100644 drivers/misc/reboot_mode.c

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 22892c7..0cceb74 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -525,6 +525,13 @@ config VEXPRESS_SYSCFG
  bus. System Configuration interface is one of the possible means
  of generating transactions on this bus.
 
+config REBOOT_MODE
+   tristate
+   depends on OF
+   help
+This driver will help to pass the system reboot mode
+to bootloader
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 537d7f3..6ada5de 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -56,3 +56,4 @@ obj-$(CONFIG_GENWQE)  += genwqe/
 obj-$(CONFIG_ECHO) += echo/
 obj-$(CONFIG_VEXPRESS_SYSCFG)  += vexpress-syscfg.o
 obj-$(CONFIG_CXL_BASE) += cxl/
+obj-$(CONFIG_REBOOT_MODE)   += reboot_mode.o
diff --git a/drivers/misc/reboot_mode.c b/drivers/misc/reboot_mode.c
new file mode 100644
index 000..16bbaab
--- /dev/null
+++ b/drivers/misc/reboot_mode.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2015, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct mode_info {
+   const char *mode;
+   int magic;
+   struct list_head list;
+};
+
+struct reboot_mode_driver {
+   struct list_head head;
+   int (*write)(int magic);
+   struct notifier_block reboot_notifier;
+};
+
+static int get_reboot_mode_magic(struct reboot_mode_driver *reboot,
+const char *cmd)
+{
+   int magic = 0;
+   struct mode_info *info;
+
+   if (cmd) {
+   list_for_each_entry(info, &reboot->head, list) {
+   if (!strcmp(info->mode, cmd)) {
+   magic = info->magic;
+   break;
+   }
+   }
+   }
+
+   return magic;
+}
+
+static int reboot_mode_notify(struct notifier_block *this,
+ unsigned long mode, void *cmd)
+{
+   struct reboot_mode_driver *reboot;
+   int magic;
+
+   reboot = container_of(this, struct reboot_mode_driver, reboot_notifier);
+   magic = get_reboot_mode_magic(reboot, cmd);
+   reboot->write(magic);
+
+   return NOTIFY_DONE;
+}
+
+int reboot_mode_register(struct device *dev, int (*write)(int))
+{
+   struct reboot_mode_driver *reboot;
+   struct mode_info *info;
+   struct device_node *child;
+   int ret;
+
+   reboot = devm_kzalloc(dev, sizeof(*reboot), GFP_KERNEL);
+   if (!reboot)
+   return -ENOMEM;
+
+   reboot->write = write;
+   INIT_LIST_HEAD(&reboot->head);
+   for_each_child_of_node(dev->of_node, child) {
+   info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
+   if (!info)
+   return -ENOMEM;
+   info->mode = of_get_property(child, "linux,mode", NULL);
+   if (of_property_read_u32(child, "linux,magic", &info->magic)) {
+   dev_err(dev, "reboot mode %s without magic number\n",
+   info->mode);
+   devm_kfree(dev, info);
+   continue;
+   }
+   list_add_tail(&info->list, &reboot->head);
+   }
+   reboot->reboot_notifier.notifier_call = reboot_mode_notify;
+   ret = register_reboot_notifier(&reboot->reboot_notifier);
+   if (ret)
+       dev_err(dev, "can't register reboot notifier\n");
+
+   return ret;
+}
+EXPORT_SYMBOL_GPL(reboot_mode_register);
+
+MODULE_AUTHOR

[PATCH v1 2/6] dt-bindings: soc: add document for rockchip reboot-mode driver

2015-12-22 Thread Andy Yan
Add device tree binding document for rockchip reboot-mode driver

Signed-off-by: Andy Yan 
---

Changes in v1: None

 .../bindings/soc/rockchip/rockchip,reboot-mode.txt | 39 ++
 1 file changed, 39 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/soc/rockchip/rockchip,reboot-mode.txt

diff --git 
a/Documentation/devicetree/bindings/soc/rockchip/rockchip,reboot-mode.txt 
b/Documentation/devicetree/bindings/soc/rockchip/rockchip,reboot-mode.txt
new file mode 100644
index 000..cdb5093
--- /dev/null
+++ b/Documentation/devicetree/bindings/soc/rockchip/rockchip,reboot-mode.txt
@@ -0,0 +1,39 @@
+Rockchip reboot mode driver
+
+This driver get reboot mode arguments from userspace
+and stores it in special register. Then the bootloader
+will read it and take different action according the
+argument stored.
+
+Required properties:
+- compatible: should be "rockchip,reboot-mode"
+- regmap: this is phandle to the register map node
+- offset: offset in the register map for the storage register (in bytes)
+The rest of the properties should follow the generic reboot-mode discription
+found in ../../misc/reboot-mode.txt
+
+Examples:
+   reboot_mode {
+   compatible = "rockchip,reboot-mode";
+   rockchip,regmap = <&pmu>;
+   offset = <0x40>;
+   loader {
+   linux,mode = "loader";
+   linux,magic = ;
+   };
+
+   maskrom {
+   linux,mode = "maskrom";
+   linux,magic = ;
+   };
+
+   recovery {
+   linux,mode = "recovery";
+   linux,magic = ;
+   };
+
+   fastboot {
+   linux,mode = "fastboot";
+   linux,magic = ;
+   };
+   };
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v1 1/6] dt-bindings: misc: add document for reboot-mode driver

2015-12-22 Thread Andy Yan
add device tree bindings document for reboot-mode driver

Signed-off-by: Andy Yan 

---

Changes in v1: None

 .../devicetree/bindings/misc/reboot-mode.txt   | 41 ++
 1 file changed, 41 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/misc/reboot-mode.txt

diff --git a/Documentation/devicetree/bindings/misc/reboot-mode.txt 
b/Documentation/devicetree/bindings/misc/reboot-mode.txt
new file mode 100644
index 000..082bc0c
--- /dev/null
+++ b/Documentation/devicetree/bindings/misc/reboot-mode.txt
@@ -0,0 +1,41 @@
+Generic reboot mode communication driver
+
+This driver get reboot mode arguments from userspace
+and stores it in special register or ram . Then the
+bootloader will read it and take different action
+according the argument stored.
+
+Required properties:
+- compatible = "reboot-mode" or other vendor compatible string;
+
+Each mode is represented as a sub-node of reboot_mode:
+
+Subnode required properties:
+- linux,mode: reboot mode command,such as "loader","recovery", 
"fastboot".
+- linux,magic: magic number for the mode, this is vendor specific.
+
+example:
+   reboot_mode {
+   compatible = "rockchip,reboot-mode";
+   rockchip,regmap = <&pmu>;
+   offset = <0x40>;
+   loader {
+   linux,mode = "loader";
+   linux,magic = <0x5242C301>;
+   };
+
+   maskrom {
+   linux,mode = "maskrom";
+   linux,magic = <0x5242C302>;
+   };
+
+   recovery {
+   linux,mode = "recovery";
+   linux,magic = <0x5242C303>;
+   };
+
+   fastboot {
+   linux,mode = "fastboot";
+   linux,magic = <0x5242C309>;
+   };
+};
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 5/6] ARM: dts: rockchip: add reboot mode node

2015-12-22 Thread Andy Yan

Hi,

On 2015年12月22日 11:04, Naoki FUKAUMI wrote:

hi,

On Mon, Dec 21, 2015 at 8:42 PM, Andy Yan  wrote:

Add reboot mode driver DT node for rk3xxx,rk3288 platform

Signed-off-by: Andy Yan
---

  arch/arm/boot/dts/rk3288.dtsi| 25 +++
  arch/arm/boot/dts/rk3xxx.dtsi| 26 
  include/dt-bindings/soc/rockchip_boot-mode.h | 30 
  3 files changed, 81 insertions(+)
  create mode 100644 include/dt-bindings/soc/rockchip_boot-mode.h

diff --git a/arch/arm/boot/dts/rk3288.dtsi b/arch/arm/boot/dts/rk3288.dtsi
index 04ea209..937ba4c 100644
--- a/arch/arm/boot/dts/rk3288.dtsi
+++ b/arch/arm/boot/dts/rk3288.dtsi
@@ -170,6 +170,31 @@
 };
 };

+   reboot_mode {
+   compatible = "rockchip,reboot-mode";
+   rockchip,regmap = <&pmu>;
+   offset = <0x94>;
+   loader {
+   linux,mode = "loader";
+   linux,magic = <0x5242C301>;
+   };
+
+   maskrom {
+   linux,mode = "maskrom";
+   linux,magic = <0x5242C302>;
+   };
+
+   recovery {
+   linux,mode = "recovery";
+   linux,magic = <0x5242C303>;
+   };
+
+   fastboot {
+   linux,mode = "fastboot";
+   linux,magic = <0x5242C309>;
+   };
+   };
+

(snip)

I sometimes use 0xEF08A53C to load bootloader from SD card instead of
on-board flash memory such as eMMC.
  
https://github.com/linux-rockchip/u-boot-rockchip/blob/u-boot-rk3288/common/cmd_rockusb.c#L893

I don't know any detail about this function.
(above code says "reboot to maskrom", but it should be wrong from my experience)

do you know something about this function? can you handle this too?

Regards,



 Have some discussion with the bootloader engineer, the correct magic  
number to
 reboot the system to maskrom mode is 0xEF08A53C. I will  fix it in 
next version.


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v1 0/6] misc: add reboot mode driver

2015-12-22 Thread Andy Yan

This driver parse the reboot commands like "reboot loader"
and "reboot recovery" to get a boot mode described in the
device tree , then call the vendor specific write interfae
to store the boot mode in some place like special register
or sram , which can be read by the bootloader after system
reboot.

This is commonly done on Android based devices, in order to
reboot the device into fastboot or recovery mode.

Before this patch , I have try some hack on[0], and then found
John Stultz also doing the same work[1].

As John is busy these days, I go on with this work.

[0]https://patchwork.kernel.org/patch/7647751/
[1]https://patchwork.kernel.org/patch/7802391/

Changes in v1:
- fix the embarrassed compile warning
- correct the maskrom magic number
- check for the normal reboot
- correct the maskrom magic number
- use macro defined in rockchip_boot-mode.h for reboot-mode DT node

Andy Yan (6):
  dt-bindings: misc: add document for reboot-mode driver
  dt-bindings: soc: add document for rockchip reboot-mode driver
  misc: add reboot mode driver
  soc: rockchip: add reboot mode driver
  ARM: dts: rockchip: add reboot-mode node
  ARM64: dts: rockchip: add reboot-mode node

 .../devicetree/bindings/misc/reboot-mode.txt   | 41 +
 .../bindings/soc/rockchip/rockchip,reboot-mode.txt | 39 +
 arch/arm/boot/dts/rk3288.dtsi  | 26 ++
 arch/arm/boot/dts/rk3xxx.dtsi  | 26 ++
 arch/arm64/boot/dts/rockchip/rk3368.dtsi   | 26 ++
 drivers/misc/Kconfig   |  7 ++
 drivers/misc/Makefile  |  1 +
 drivers/misc/reboot_mode.c | 96 ++
 drivers/soc/rockchip/Kconfig   |  9 ++
 drivers/soc/rockchip/Makefile  |  1 +
 drivers/soc/rockchip/reboot.c  | 68 +++
 include/dt-bindings/soc/rockchip_boot-mode.h   | 30 +++
 include/linux/reboot.h |  4 +-
 13 files changed, 373 insertions(+), 1 deletion(-)
 create mode 100644 Documentation/devicetree/bindings/misc/reboot-mode.txt
 create mode 100644 
Documentation/devicetree/bindings/soc/rockchip/rockchip,reboot-mode.txt
 create mode 100644 drivers/misc/reboot_mode.c
 create mode 100644 drivers/soc/rockchip/reboot.c
 create mode 100644 include/dt-bindings/soc/rockchip_boot-mode.h

-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/6] ARM64: dts: rockchip: add reboot mode node

2015-12-21 Thread Andy Yan
Add reboot mode driver DT node for rk3368 platform

Signed-off-by: Andy Yan 
---

 arch/arm64/boot/dts/rockchip/rk3368.dtsi | 26 ++
 1 file changed, 26 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3368.dtsi 
b/arch/arm64/boot/dts/rockchip/rk3368.dtsi
index cc093a4..776f1be 100644
--- a/arch/arm64/boot/dts/rockchip/rk3368.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3368.dtsi
@@ -45,6 +45,7 @@
 #include 
 #include 
 #include 
+#include 
 
 / {
compatible = "rockchip,rk3368";
@@ -202,6 +203,31 @@
method = "smc";
};
 
+   reboot_mode {
+   compatible = "rockchip,reboot-mode";
+   rockchip,regmap = <&pmugrf>;
+   offset = <0x200>;
+   loader {
+   linux,mode = "loader";
+   linux,magic = ;
+   };
+
+   maskrom {
+   linux,mode = "maskrom";
+   linux,magic = ;
+   };
+
+   recovery {
+   linux,mode = "recovery";
+   linux,magic = ;
+   };
+
+   fastboot {
+   linux,mode = "fastboot";
+   linux,magic = ;
+   };
+   };
+
timer {
compatible = "arm,armv8-timer";
interrupts = http://vger.kernel.org/majordomo-info.html


[PATCH 5/6] ARM: dts: rockchip: add reboot mode node

2015-12-21 Thread Andy Yan
Add reboot mode driver DT node for rk3xxx,rk3288 platform

Signed-off-by: Andy Yan 
---

 arch/arm/boot/dts/rk3288.dtsi| 25 +++
 arch/arm/boot/dts/rk3xxx.dtsi| 26 
 include/dt-bindings/soc/rockchip_boot-mode.h | 30 
 3 files changed, 81 insertions(+)
 create mode 100644 include/dt-bindings/soc/rockchip_boot-mode.h

diff --git a/arch/arm/boot/dts/rk3288.dtsi b/arch/arm/boot/dts/rk3288.dtsi
index 04ea209..937ba4c 100644
--- a/arch/arm/boot/dts/rk3288.dtsi
+++ b/arch/arm/boot/dts/rk3288.dtsi
@@ -170,6 +170,31 @@
};
};
 
+   reboot_mode {
+   compatible = "rockchip,reboot-mode";
+   rockchip,regmap = <&pmu>;
+   offset = <0x94>;
+   loader {
+   linux,mode = "loader";
+   linux,magic = <0x5242C301>;
+   };
+
+   maskrom {
+   linux,mode = "maskrom";
+   linux,magic = <0x5242C302>;
+   };
+
+   recovery {
+   linux,mode = "recovery";
+   linux,magic = <0x5242C303>;
+   };
+
+   fastboot {
+   linux,mode = "fastboot";
+   linux,magic = <0x5242C309>;
+   };
+   };
+
reserved-memory {
#address-cells = <1>;
#size-cells = <1>;
diff --git a/arch/arm/boot/dts/rk3xxx.dtsi b/arch/arm/boot/dts/rk3xxx.dtsi
index 4497d28..735eef4 100644
--- a/arch/arm/boot/dts/rk3xxx.dtsi
+++ b/arch/arm/boot/dts/rk3xxx.dtsi
@@ -43,6 +43,7 @@
 
 #include 
 #include 
+#include 
 #include "skeleton.dtsi"
 
 / {
@@ -103,6 +104,31 @@
};
};
 
+   reboot_mode {
+   compatible = "rockchip,reboot-mode";
+   rockchip,regmap = <&pmu>;
+   offset = <0x40>;
+   loader {
+   linux,mode = "loader";
+   linux,magic = ;
+   };
+
+   maskrom {
+   linux,mode = "maskrom";
+   linux,magic = ;
+   };
+
+   recovery {
+   linux,mode = "recovery";
+   linux,magic = ;
+   };
+
+   fastboot {
+   linux,mode = "fastboot";
+   linux,magic = ;
+   };
+   };
+
xin24m: oscillator {
compatible = "fixed-clock";
clock-frequency = <2400>;
diff --git a/include/dt-bindings/soc/rockchip_boot-mode.h 
b/include/dt-bindings/soc/rockchip_boot-mode.h
new file mode 100644
index 000..129edf8
--- /dev/null
+++ b/include/dt-bindings/soc/rockchip_boot-mode.h
@@ -0,0 +1,30 @@
+#ifndef __ROCKCHIP_BOOT_MODE_H
+#define __ROCKCHIP_BOOT_MODE_H
+
+/*high 24 bits is tag, low 8 bits is type*/
+#defineREBOOT_FLAG 0x5242C300
+/* normal boot */
+#defineBOOT_NORMAL (REBOOT_FLAG + 0)
+/* enter loader rockusb mode */
+#defineBOOT_LOADER (REBOOT_FLAG + 1)
+/* enter maskrom rockusb mode */
+#defineBOOT_MASKROM(REBOOT_FLAG + 2)
+/* enter recovery */
+#defineBOOT_RECOVERY   (REBOOT_FLAG + 3)
+/* do not enter recover */
+#defineBOOT_NORECOVER  (REBOOT_FLAG + 4)
+/* boot second OS*/
+#defineBOOT_SECONDOS   (REBOOT_FLAG + 5)
+/* enter recover and wipe data. */
+#defineBOOT_WIPEDATA   (REBOOT_FLAG + 6)
+/* enter recover and wipe all data. */
+#defineBOOT_WIPEALL(REBOOT_FLAG + 7)
+/* check firmware img with backup part*/
+#defineBOOT_CHECKIMG   (REBOOT_FLAG + 8)
+ /* enter fast boot mode */
+#defineBOOT_FASTBOOT   (REBOOT_FLAG + 9)
+#defineBOOT_SECUREBOOT_DISABLE (REBOOT_FLAG + 10)
+/* enter charge mode */
+#defineBOOT_CHARGING   (REBOOT_FLAG + 11)
+
+#endif
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/6] soc: rockchip: add reboot mode driver

2015-12-21 Thread Andy Yan
rockchip platform have a protocol to pass the kernel reboot
mode to bootloader by some special registers when system reboot.
By this way the bootloader can take different action according
to the different kernel reboot mode, for example, command
"reboot loader" will reboot the board to rockusb mode, this is
a very convenient way to get the board enter download mode.

Signed-off-by: Andy Yan 
---

 drivers/soc/rockchip/Kconfig  |  8 ++
 drivers/soc/rockchip/Makefile |  1 +
 drivers/soc/rockchip/loader.h | 22 +++
 drivers/soc/rockchip/reboot.c | 66 +++
 4 files changed, 97 insertions(+)
 create mode 100644 drivers/soc/rockchip/loader.h
 create mode 100644 drivers/soc/rockchip/reboot.c

diff --git a/drivers/soc/rockchip/Kconfig b/drivers/soc/rockchip/Kconfig
index 7140ff8..855d518 100644
--- a/drivers/soc/rockchip/Kconfig
+++ b/drivers/soc/rockchip/Kconfig
@@ -15,4 +15,12 @@ config ROCKCHIP_PM_DOMAINS
 
   If unsure, say N.
 
+config ROCKCHIP_REBOOT
+   bool "Rockchip reboot mode driver"
+   select REBOOT_MODE
+   help
+ Say y here will enable reboot notifier support.
+ This will get reboot mode arguments from userspace and
+ store it in special register.
+
 endif
diff --git a/drivers/soc/rockchip/Makefile b/drivers/soc/rockchip/Makefile
index 3d73d06..9817496 100644
--- a/drivers/soc/rockchip/Makefile
+++ b/drivers/soc/rockchip/Makefile
@@ -2,3 +2,4 @@
 # Rockchip Soc drivers
 #
 obj-$(CONFIG_ROCKCHIP_PM_DOMAINS) += pm_domains.o
+obj-$(CONFIG_ROCKCHIP_REBOOT) += reboot.o
diff --git a/drivers/soc/rockchip/loader.h b/drivers/soc/rockchip/loader.h
new file mode 100644
index 000..bf51baa
--- /dev/null
+++ b/drivers/soc/rockchip/loader.h
@@ -0,0 +1,22 @@
+#ifndef __MACH_ROCKCHIP_LOADER_H
+#define __MACH_ROCKCHIP_LOADER_H
+
+/*high 24 bits is tag, low 8 bits is type*/
+#define SYS_LOADER_REBOOT_FLAG   0x5242C300
+
+enum {
+   BOOT_NORMAL = 0, /* normal boot */
+   BOOT_LOADER, /* enter loader rockusb mode */
+   BOOT_MASKROM,/* enter maskrom rockusb mode (not support now) */
+   BOOT_RECOVER,/* enter recover */
+   BOOT_NORECOVER,  /* do not enter recover */
+   BOOT_SECONDOS,   /* boot second OS (not support now)*/
+   BOOT_WIPEDATA,   /* enter recover and wipe data. */
+   BOOT_WIPEALL,/* enter recover and wipe all data. */
+   BOOT_CHECKIMG,   /* check firmware img with backup part*/
+   BOOT_FASTBOOT,   /* enter fast boot mode */
+   BOOT_SECUREBOOT_DISABLE,
+   BOOT_CHARGING,   /* enter charge mode */
+   BOOT_MAX /* MAX VALID BOOT TYPE.*/
+};
+#endif
diff --git a/drivers/soc/rockchip/reboot.c b/drivers/soc/rockchip/reboot.c
new file mode 100644
index 000..eb580b5
--- /dev/null
+++ b/drivers/soc/rockchip/reboot.c
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "loader.h"
+
+struct regmap *map;
+u32 offset;
+
+static int rockchip_reboot_mode_write(int magic)
+{
+   pr_info("%s-magic:%x\n", __func__, magic);
+   regmap_write(map, offset, magic);
+
+}
+
+static int __init rockchip_reboot_probe(struct platform_device *pdev)
+{
+   struct rockchip_reboot *reboot;
+   int ret;
+
+   map = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
+ "rockchip,regmap");
+   if (IS_ERR(map))
+   return PTR_ERR(map);
+
+   if (of_property_read_u32(pdev->dev.of_node, "offset", &offset))
+   return -EINVAL;
+
+   ret = reboot_mode_register(&pdev->dev, rockchip_reboot_mode_write);
+   if (ret)
+   dev_err(&pdev->dev, "can't register reboot mode\n");
+
+   return ret;
+}
+
+static const struct of_device_id rockchip_reboot_of_match[] = {
+   { .compatible = "rockchip,reboot-mode" },
+   {}
+};
+
+static struct platform_driver rockchip_reboot_driver = {
+   .probe = rockchip_reboot_probe,
+   .driver = {
+   .name = "rockchip-reboot",
+   .of_match_table = rockchip_reboot_of_match,
+   },
+};
+module_platform_driver(rockchip_reboot_driver);
+
+MODULE_AUTHOR("Andy Yan http://vger.kernel.org/majordomo-info.html


[PATCH 3/6] misc: add reboot mode driver

2015-12-21 Thread Andy Yan
This driver parse the reboot commands like "reboot loader"
and "reboot recovery" to get a boot mode described in the
device tree , then call the vendor specific write interfae
to store the boot mode in some place like special register
or sram , which can be read by the bootloader after system
reboot.

This is commonly done on Android based devices, in order to
reboot the device into fastboot or recovery mode.

Signed-off-by: Andy Yan 
---

 drivers/misc/Kconfig|  7 
 drivers/misc/Makefile   |  1 +
 drivers/misc/reboot_mode.c  | 96 +
 drivers/power/reset/Kconfig |  1 -
 include/linux/reboot.h  |  4 +-
 5 files changed, 107 insertions(+), 2 deletions(-)
 create mode 100644 drivers/misc/reboot_mode.c

diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 22892c7..039be78 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -525,6 +525,13 @@ config VEXPRESS_SYSCFG
  bus. System Configuration interface is one of the possible means
  of generating transactions on this bus.
 
+config REBOOT_MODE
+   tristate
+   depends on OF
+   help
+This driver will help to communicate the system reboot mode
+to bootloader
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index 537d7f3..6ada5de 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -56,3 +56,4 @@ obj-$(CONFIG_GENWQE)  += genwqe/
 obj-$(CONFIG_ECHO) += echo/
 obj-$(CONFIG_VEXPRESS_SYSCFG)  += vexpress-syscfg.o
 obj-$(CONFIG_CXL_BASE) += cxl/
+obj-$(CONFIG_REBOOT_MODE)   += reboot_mode.o
diff --git a/drivers/misc/reboot_mode.c b/drivers/misc/reboot_mode.c
new file mode 100644
index 000..39e3f9f
--- /dev/null
+++ b/drivers/misc/reboot_mode.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 2015, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+struct mode_info {
+   const char *mode;
+   int magic;
+   struct list_head list;
+};
+
+struct reboot_mode_driver {
+   struct list_head head;
+   int (*write)(int magic);
+   struct notifier_block reboot_notifier;
+};
+
+static int get_reboot_mode_magic(struct reboot_mode_driver *reboot,
+const char *cmd)
+{
+   int magic = 0;
+   struct mode_info *info;
+
+   if (cmd) {
+   list_for_each_entry(info, &reboot->head, list) {
+   if (!strcmp(info->mode, cmd)) {
+   magic = info->magic;
+   break;
+   }
+   }
+   }
+
+   return magic;
+}
+
+static int reboot_mode_notify(struct notifier_block *this,
+ unsigned long mode, void *cmd)
+{
+   struct reboot_mode_driver *reboot;
+   int magic;
+
+   reboot = container_of(this, struct reboot_mode_driver, reboot_notifier);
+   magic = get_reboot_mode_magic(reboot, cmd);
+   reboot->write(magic);
+
+   return NOTIFY_DONE;
+}
+
+int reboot_mode_register(struct device *dev, int (*write)(int))
+{
+   struct reboot_mode_driver *reboot;
+   struct mode_info *info;
+   struct device_node *child;
+   int ret;
+
+   reboot = devm_kzalloc(dev, sizeof(*reboot), GFP_KERNEL);
+   if (!reboot)
+   return -ENOMEM;
+
+   reboot->write = write;
+   INIT_LIST_HEAD(&reboot->head);
+   for_each_child_of_node(dev->of_node, child) {
+   info = devm_kzalloc(dev, sizeof(*info), GFP_KERNEL);
+   if (!info)
+   return -ENOMEM;
+   info->mode = of_get_property(child, "linux,mode", NULL);
+   if (of_property_read_u32(child, "linux,magic", &info->magic)) {
+   dev_err(dev, "reboot mode %s without magic number\n",
+   info->mode);
+   devm_kfree(dev, info);
+   continue;
+   }
+   list_add_tail(&info->list, &reboot->head);
+   }
+   reboot->reboot_notifier.notifier_call = reboot_mode_notify;
+   ret = register_reboot_notifier(&reboot->reboot_notifier);
+   if (ret)
+       dev_err(dev, "can't register reboot notifier\n");
+
+   return ret;
+}
+EXPORT_SYMBOL_GPL(reboot_mode_register);
+
+MODULE_AUTHOR("Andy Yan 
 #include 
 #include 
 
@@ -42,6 +42,8

[PATCH 2/6] dt-bindings: soc: add document for rockchip reboot-mode driver

2015-12-21 Thread Andy Yan
Add device tree binding document for rockchip reboot-mode driver

Signed-off-by: Andy Yan 
---

 .../bindings/soc/rockchip/rockchip,reboot-mode.txt | 39 ++
 1 file changed, 39 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/soc/rockchip/rockchip,reboot-mode.txt

diff --git 
a/Documentation/devicetree/bindings/soc/rockchip/rockchip,reboot-mode.txt 
b/Documentation/devicetree/bindings/soc/rockchip/rockchip,reboot-mode.txt
new file mode 100644
index 000..ede8509
--- /dev/null
+++ b/Documentation/devicetree/bindings/soc/rockchip/rockchip,reboot-mode.txt
@@ -0,0 +1,39 @@
+Rockchip reboot mode driver
+
+This driver get reboot mode arguments from userspace
+and stores it in special register. Then the bootloader
+will read it and take different action according the
+argument stored.
+
+Required properties:
+- compatible: should be "rockchip,reboot-mode"
+- regmap: this is phandle to the register map node
+- offset: offset in the register map for the storage register (in bytes)
+The rest of the properties should follow the generic reboot-mode discription
+found in ../../misc/reboot-mode.txt
+
+Examples:
+   reboot_mode {
+   compatible = "rockchip,reboot-mode";
+   rockchip,regmap = <&pmu>;
+   offset = <0x40>;
+   loader {
+   linux,mode = "loader";
+   linux,magic = <0x5242C301>;
+   };
+
+   maskrom {
+   linux,mode = "maskrom";
+   linux,magic = <0x5242C302>;
+   };
+
+   recovery {
+   linux,mode = "recovery";
+   linux,magic = <0x5242C303>;
+   };
+
+   fastboot {
+   linux,mode = "fastboot";
+   linux,magic = <0x5242C309>;
+   };
+   };
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/6] dt-bindings: misc: add document for reboot-mode driver

2015-12-21 Thread Andy Yan
add device tree bindings document for reboot-mode driver

Signed-off-by: Andy Yan 

---

 .../devicetree/bindings/misc/reboot-mode.txt   | 41 ++
 1 file changed, 41 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/misc/reboot-mode.txt

diff --git a/Documentation/devicetree/bindings/misc/reboot-mode.txt 
b/Documentation/devicetree/bindings/misc/reboot-mode.txt
new file mode 100644
index 000..68346b3
--- /dev/null
+++ b/Documentation/devicetree/bindings/misc/reboot-mode.txt
@@ -0,0 +1,41 @@
+Generic reboot mode communication driver
+
+This driver get reboot mode arguments from userspace
+and stores it in special register or ram . Then the
+bootloader will read it and take different action
+according the argument stored.
+
+Required properties:
+- compatible = "reboot-mode" or other vendor compatible string;
+
+Each mode is represented as a sub-node of reboot_mode:
+
+Subnode properties:
+- linux,mode: reboot mode command,such as "loader","recover", 
"fastboot".
+- linux,magic: magic number for the mode, this is vendor specific.
+
+example:
+   reboot_mode {
+   compatible = "rockchip,reboot-mode";
+   rockchip,regmap = <&pmu>;
+   offset = <0x40>;
+   loader {
+   linux,mode = "loader";
+   linux,magic = <0x5242C301>;
+   };
+
+   maskrom {
+   linux,mode = "maskrom";
+   linux,magic = <0x5242C302>;
+   };
+
+   recovery {
+   linux,mode = "recovery";
+   linux,magic = <0x5242C303>;
+   };
+
+   fastboot {
+   linux,mode = "fastboot";
+   linux,magic = <0x5242C309>;
+   };
+};
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/6] misc: add reboot mode driver

2015-12-21 Thread Andy Yan

This driver parse the reboot commands like "reboot loader"
and "reboot recovery" to get a boot mode described in the
device tree , then call the vendor specific write interfae
to store the boot mode in some place like special register
or sram , which can be read by the bootloader after system
reboot.

This is commonly done on Android based devices, in order to
reboot the device into fastboot or recovery mode.

Before this patch , I have try some hack on[0], and then found
John Stultz also doing the same work[1].

As John is busy these days, I go on with this work.

[0]https://patchwork.kernel.org/patch/7647751/
[1]https://patchwork.kernel.org/patch/7802391/


Andy Yan (6):
  dt-bindings: misc: add document for reboot-mode driver
  dt-bindings: soc: add document for rockchip reboot-mode driver
  misc: add reboot mode driver
  soc: rockchip: add reboot mode driver
  ARM: dts: rockchip: add reboot mode node
  ARM64: dts: rockchip: add reboot mode node

 .../devicetree/bindings/misc/reboot-mode.txt   | 41 +
 .../bindings/soc/rockchip/rockchip,reboot-mode.txt | 39 +
 arch/arm/boot/dts/rk3288.dtsi  | 25 ++
 arch/arm/boot/dts/rk3xxx.dtsi  | 26 ++
 arch/arm64/boot/dts/rockchip/rk3368.dtsi   | 26 ++
 drivers/misc/Kconfig   |  7 ++
 drivers/misc/Makefile  |  1 +
 drivers/misc/reboot_mode.c | 96 ++
 drivers/power/reset/Kconfig|  1 -
 drivers/soc/rockchip/Kconfig   |  8 ++
 drivers/soc/rockchip/Makefile  |  1 +
 drivers/soc/rockchip/loader.h  | 22 +
 drivers/soc/rockchip/reboot.c  | 66 +++
 include/dt-bindings/soc/rockchip_boot-mode.h   | 30 +++
 include/linux/reboot.h |  4 +-
 15 files changed, 391 insertions(+), 2 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/misc/reboot-mode.txt
 create mode 100644 
Documentation/devicetree/bindings/soc/rockchip/rockchip,reboot-mode.txt
 create mode 100644 drivers/misc/reboot_mode.c
 create mode 100644 drivers/soc/rockchip/loader.h
 create mode 100644 drivers/soc/rockchip/reboot.c
 create mode 100644 include/dt-bindings/soc/rockchip_boot-mode.h

-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 0/5] Add reboot notifier driver for rockchip platform

2015-12-14 Thread Andy Yan

Hi John:

On 2015年12月12日 05:29, Heiko Stübner wrote:

Am Mittwoch, 18. November 2015, 17:47:24 schrieb Andy Yan:

rockchip platform have a protocol to pass the kernel reboot
mode to bootloader by some special registers when system reboot.
By this way the bootloader can take different action according
to the different kernel reboot mode, for example, command
"reboot loader" will reboot the board to rockusb mode, this is
a very convenient way to get the board enter download mode.
And Android system also use this protocol to pass "recovery"、
“fastboot” reboot mode to bootloader. In upstream land, We found
tegra platform also use this mechanism.

Before this version, I have sent two Series, which can be found
at [0] [1]
[0] https://patchwork.kernel.org/patch/7140751/
[1] https://patchwork.kernel.org/patch/7153531/

just so it doesn't get lost, this ties into a slightly more generic approach,
John Stultz is doing for the android reboot reasons:

http://thread.gmane.org/gmane.linux.kernel/2103447

The only difference is that we'd need to use the pmu syscon for it.


Very glad to see your work on this. And your work is more generic 
than my.
 So hope we can share the code. As you can see, the rockchip 
platform use
 a GRF or PMU register to store the reboot reason. So maybe we need 
a phandle

 in the DT node to describe it.

Changes in v3:
  - rename a pinctrl node in rk3288-veyron, the original name will be
used in the incoming reboot notifier driver
  - add dt binding
  - move from mach-rockchip to drivers/soc/rockchip, as the tegra does
  - use dts pass the related register
  - add DT node

Changes in v2:
   - check cpu dt node
   - remove a unnecessary of_put_node in function rockchip_get_pmu_regmap
   - fix a align issue
   - use reboot_notifier instead of restart_handler

Andy Yan (5):
   ARM: dts: rockchip: rk3288-veyron: rename pinctrl node reboot to reset
   dt-bindings: soc: add document for rockchip reboot notifier driver
   soc: rockchip: add reboot notifier driver
   ARM: dts: rockchip: add reboot node
   ARM64: dts: rockchip: add reboot node

  .../bindings/soc/rockchip/rockchip-reboot.txt  | 18 
  arch/arm/boot/dts/rk3288-veyron.dtsi   |  2 +-
  arch/arm/boot/dts/rk3288.dtsi  |  6 ++
  arch/arm/boot/dts/rk3xxx.dtsi  |  6 ++
  arch/arm64/boot/dts/rockchip/rk3368.dtsi   |  6 ++
  drivers/soc/rockchip/Kconfig   |  7 ++
  drivers/soc/rockchip/Makefile  |  1 +
  drivers/soc/rockchip/loader.h  | 22 +
  drivers/soc/rockchip/reboot.c  | 98
++ 9 files changed, 165 insertions(+), 1 deletion(-)
  create mode 100644
Documentation/devicetree/bindings/soc/rockchip/rockchip-reboot.txt create
mode 100644 drivers/soc/rockchip/loader.h
  create mode 100644 drivers/soc/rockchip/reboot.c


___
Linux-rockchip mailing list
linux-rockc...@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip



--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 2/5] dt-bindings: soc: add document for rockchip reboot notifier driver

2015-11-19 Thread Andy Yan

Hi Heiko:

On 2015年11月19日 12:35, Heiko Stuebner wrote:

Hi Andy,

Am Donnerstag, 19. November 2015, 09:17:37 schrieb Andy Yan:

Hi Rob:

On 2015年11月19日 06:59, Rob Herring wrote:

On Wed, Nov 18, 2015 at 05:53:30PM +0800, Andy Yan wrote:

Add devicetree binding document for rockchip reboot nofifier driver

Just reading the subject this is way too specific to the Linux driver
needs rather than a h/w description. Please don't create fake DT nodes
just to bind to drivers. Whatever &pmu is is probably what should have
the DT node. Let the driver for it create child devices if you need
that.

  This is note a fake DT nodes, we really need it to tell the driver
   which register to use to store the reboot mode. Because rockchip
   use different register file to store the reboot mode on different
   platform, on rk3066,rk3188, rk3288,it use  one of the PMU
register, on
   the incoming RK3036, it use one of the GRF register, and it use
one  of
   the PMUGRF register for arm64 platform rk3368. On the other hand, the
   PMU/GRF/PMUGRF register file are mapped as "syscon", then referenced
   by other DT nodes by phandle. So maybe let it as a separate DT
node here
   is better.

or alternatively we could do something similar to what the bl-switcher
cupfreq-driver does. Take a look at

drivers/cpufreq/arm_big_little.c
drivers/clk/clk-mb86s7x.c

We already have the core restart-handler code in the clock-tree, so could
maybe simply do the
platform_device_register_simple("rockchip-reboot", -1, NULL, 0);
in that common code?

Though I'm not yet sure how to get the platform-data. I guess one option would
be to do things like the 3288 suspend code does (arch/arm/mach-rockchip/pm.c
at the bottom), by having the per-soc-data in the driver and then matching
against the pmu. Because the pmu is not part of the clock controller binding
(and probably also shouldn't be).


Heiko






   Thanks for your suggestion.
I have read the code you list above, if we implement the reboot 
notifier
driver like this, the driver need to add much more code to find the 
platform
data(like arch/arm/mach-rockhcip/pm.c), what's more, if we have a 
new soc
in the future and the soc use a different register here, we need 
modify the
driver to add a new platform data again, this will bring additional 
work.


Use the DT node pass the register will make the driver code simple 
and clear.

Is there any hurt to put this information in the DT?

Andy

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v3 2/5] dt-bindings: soc: add document for rockchip reboot notifier driver

2015-11-18 Thread Andy Yan

Hi Rob:

On 2015年11月19日 06:59, Rob Herring wrote:

On Wed, Nov 18, 2015 at 05:53:30PM +0800, Andy Yan wrote:

Add devicetree binding document for rockchip reboot nofifier driver

Just reading the subject this is way too specific to the Linux driver
needs rather than a h/w description. Please don't create fake DT nodes
just to bind to drivers. Whatever &pmu is is probably what should have
the DT node. Let the driver for it create child devices if you need
that.


This is note a fake DT nodes, we really need it to tell the driver
 which register to use to store the reboot mode. Because rockchip
 use different register file to store the reboot mode on different
 platform, on rk3066,rk3188, rk3288,it use  one of the PMU 
register, on
 the incoming RK3036, it use one of the GRF register, and it use 
one  of

 the PMUGRF register for arm64 platform rk3368. On the other hand, the
 PMU/GRF/PMUGRF register file are mapped as "syscon", then referenced
 by other DT nodes by phandle. So maybe let it as a separate DT 
node here

 is better.


Rob

Signed-off-by: Andy Yan 

---

Changes in v3:
  - add dt binding

Changes in v2: None

  .../bindings/soc/rockchip/rockchip-reboot.txt  | 18 ++
  1 file changed, 18 insertions(+)
  create mode 100644 
Documentation/devicetree/bindings/soc/rockchip/rockchip-reboot.txt

diff --git a/Documentation/devicetree/bindings/soc/rockchip/rockchip-reboot.txt 
b/Documentation/devicetree/bindings/soc/rockchip/rockchip-reboot.txt
new file mode 100644
index 000..6f69c8d
--- /dev/null
+++ b/Documentation/devicetree/bindings/soc/rockchip/rockchip-reboot.txt
@@ -0,0 +1,18 @@
+Rockchip reboot notifier driver
+
+This driver get reboot mode arguments from userspace
+and stores it in special register. Then the bootloader
+will read it and take different action according the
+argument stored.
+
+Required properties:
+- compatible: should be "rockchip,reboot"
+- regmap: this is phandle to the register map node
+- offset: offset in the register map for the storage register (in bytes)
+
+Examples:
+   reboot {
+  compatible = "rockchip,reboot";
+  regmap = <&pmu>;
+  offset = <0x94>;
+   };
--
1.9.1








--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 5/5] ARM64: dts: rockchip: add reboot node

2015-11-18 Thread Andy Yan
Add reboot notifier driver DT node for rk3368 platform

Signed-off-by: Andy Yan 

---

Changes in v3:
 - add DT node

Changes in v2: None

 arch/arm64/boot/dts/rockchip/rk3368.dtsi | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm64/boot/dts/rockchip/rk3368.dtsi 
b/arch/arm64/boot/dts/rockchip/rk3368.dtsi
index a712bea..c390f61 100644
--- a/arch/arm64/boot/dts/rockchip/rk3368.dtsi
+++ b/arch/arm64/boot/dts/rockchip/rk3368.dtsi
@@ -202,6 +202,12 @@
method = "smc";
};
 
+   reboot {
+   compatible = "rockchip,reboot";
+   rockchip,regmap = <&pmugrf>;
+   offset = <0x200>;
+   };
+
timer {
compatible = "arm,armv8-timer";
interrupts = http://vger.kernel.org/majordomo-info.html


[PATCH v3 4/5] ARM: dts: rockchip: add reboot node

2015-11-18 Thread Andy Yan
Add reboot notifier driver DT node for rk3xxx,rk3288 platform

Signed-off-by: Andy Yan 

---

Changes in v3:
 - add DT node

Changes in v2: None

 arch/arm/boot/dts/rk3288.dtsi | 6 ++
 arch/arm/boot/dts/rk3xxx.dtsi | 6 ++
 2 files changed, 12 insertions(+)

diff --git a/arch/arm/boot/dts/rk3288.dtsi b/arch/arm/boot/dts/rk3288.dtsi
index 906e938..975b8c9 100644
--- a/arch/arm/boot/dts/rk3288.dtsi
+++ b/arch/arm/boot/dts/rk3288.dtsi
@@ -169,6 +169,12 @@
};
};
 
+   reboot {
+   compatible = "rockchip,reboot";
+   rockchip,regmap = <&pmu>;
+   offset = <0x94>;
+   };
+
reserved-memory {
#address-cells = <1>;
#size-cells = <1>;
diff --git a/arch/arm/boot/dts/rk3xxx.dtsi b/arch/arm/boot/dts/rk3xxx.dtsi
index 4497d28..7b14d7a 100644
--- a/arch/arm/boot/dts/rk3xxx.dtsi
+++ b/arch/arm/boot/dts/rk3xxx.dtsi
@@ -103,6 +103,12 @@
};
};
 
+   reboot {
+   compatible = "rockchip,reboot";
+   rockchip,regmap = <&pmu>;
+   offset = <0x40>;
+   };
+
xin24m: oscillator {
compatible = "fixed-clock";
clock-frequency = <2400>;
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 3/5] soc: rockchip: add reboot notifier driver

2015-11-18 Thread Andy Yan
rockchip platform have a protocol to pass the kernel reboot
mode to bootloader by some special registers when system reboot.
By this way the bootloader can take different action according
to the different kernel reboot mode, for example, command
"reboot loader" will reboot the board to rockusb mode, this is
a very convenient way to get the board enter download mode.

Signed-off-by: Andy Yan 

---

Changes in v3:
 - move from mach-rockchip to drivers/soc/rockchip, as the tegra does
 - use dts pass the related register

Changes in v2:
  - check cpu dt node
  - remove a unnecessary of_put_node in function rockchip_get_pmu_regmap
  - fix a align issue
  - use reboot_notifier instead of restart_handler

 drivers/soc/rockchip/Kconfig  |  7 
 drivers/soc/rockchip/Makefile |  1 +
 drivers/soc/rockchip/loader.h | 22 ++
 drivers/soc/rockchip/reboot.c | 98 +++
 4 files changed, 128 insertions(+)
 create mode 100644 drivers/soc/rockchip/loader.h
 create mode 100644 drivers/soc/rockchip/reboot.c

diff --git a/drivers/soc/rockchip/Kconfig b/drivers/soc/rockchip/Kconfig
index 7140ff8..4edbc44 100644
--- a/drivers/soc/rockchip/Kconfig
+++ b/drivers/soc/rockchip/Kconfig
@@ -15,4 +15,11 @@ config ROCKCHIP_PM_DOMAINS
 
   If unsure, say N.
 
+config ROCKCHIP_REBOOT
+   bool "Rockchip reboot notifier driver"
+   help
+ Say y here will enable reboot notifier support.
+ This will get reboot mode arguments from userspace and
+ store it in special register.
+
 endif
diff --git a/drivers/soc/rockchip/Makefile b/drivers/soc/rockchip/Makefile
index 3d73d06..9817496 100644
--- a/drivers/soc/rockchip/Makefile
+++ b/drivers/soc/rockchip/Makefile
@@ -2,3 +2,4 @@
 # Rockchip Soc drivers
 #
 obj-$(CONFIG_ROCKCHIP_PM_DOMAINS) += pm_domains.o
+obj-$(CONFIG_ROCKCHIP_REBOOT) += reboot.o
diff --git a/drivers/soc/rockchip/loader.h b/drivers/soc/rockchip/loader.h
new file mode 100644
index 000..bf51baa
--- /dev/null
+++ b/drivers/soc/rockchip/loader.h
@@ -0,0 +1,22 @@
+#ifndef __MACH_ROCKCHIP_LOADER_H
+#define __MACH_ROCKCHIP_LOADER_H
+
+/*high 24 bits is tag, low 8 bits is type*/
+#define SYS_LOADER_REBOOT_FLAG   0x5242C300
+
+enum {
+   BOOT_NORMAL = 0, /* normal boot */
+   BOOT_LOADER, /* enter loader rockusb mode */
+   BOOT_MASKROM,/* enter maskrom rockusb mode (not support now) */
+   BOOT_RECOVER,/* enter recover */
+   BOOT_NORECOVER,  /* do not enter recover */
+   BOOT_SECONDOS,   /* boot second OS (not support now)*/
+   BOOT_WIPEDATA,   /* enter recover and wipe data. */
+   BOOT_WIPEALL,/* enter recover and wipe all data. */
+   BOOT_CHECKIMG,   /* check firmware img with backup part*/
+   BOOT_FASTBOOT,   /* enter fast boot mode */
+   BOOT_SECUREBOOT_DISABLE,
+   BOOT_CHARGING,   /* enter charge mode */
+   BOOT_MAX /* MAX VALID BOOT TYPE.*/
+};
+#endif
diff --git a/drivers/soc/rockchip/reboot.c b/drivers/soc/rockchip/reboot.c
new file mode 100644
index 000..048aeb0b
--- /dev/null
+++ b/drivers/soc/rockchip/reboot.c
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include "loader.h"
+
+struct rockchip_reboot {
+   struct device *dev;
+   struct regmap *map;
+   u32 offset;
+   struct notifier_block reboot_notifier;
+};
+
+static void rockchip_get_reboot_flag(const char *cmd, u32 *flag)
+{
+   *flag = SYS_LOADER_REBOOT_FLAG + BOOT_NORMAL;
+
+   if (cmd) {
+   if (!strcmp(cmd, "loader") || !strcmp(cmd, "bootloader"))
+   *flag = SYS_LOADER_REBOOT_FLAG + BOOT_LOADER;
+   else if (!strcmp(cmd, "recovery"))
+   *flag = SYS_LOADER_REBOOT_FLAG + BOOT_RECOVER;
+   else if (!strcmp(cmd, "charge"))
+   *flag = SYS_LOADER_REBOOT_FLAG + BOOT_CHARGING;
+   else if (!strcmp(cmd, "fastboot"))
+   *flag = SYS_LOADER_REBOOT_FLAG + BOOT_FASTBOOT;
+   }
+}
+
+static int rockchip_reboot_notify(struct notifier_block *this,
+ unsigned long mode, void *cmd)
+{
+   struct rockchip_reboot *reboot;
+   u32 flag;
+
+   reboot = container_of(this, struct rockchip_reboot, reboot_notifier);
+   rockchip_get_reboot_flag(cmd, &flag);
+   regmap_write(reboot->map, reboot->offset, flag);
+
+   return NOTIFY_DONE;
+}
+
+static int __init rockchip_reboot_probe(struct platform_device *pdev)
+{
+   s

[PATCH v3 2/5] dt-bindings: soc: add document for rockchip reboot notifier driver

2015-11-18 Thread Andy Yan
Add devicetree binding document for rockchip reboot nofifier driver

Signed-off-by: Andy Yan 

---

Changes in v3:
 - add dt binding

Changes in v2: None

 .../bindings/soc/rockchip/rockchip-reboot.txt  | 18 ++
 1 file changed, 18 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/soc/rockchip/rockchip-reboot.txt

diff --git a/Documentation/devicetree/bindings/soc/rockchip/rockchip-reboot.txt 
b/Documentation/devicetree/bindings/soc/rockchip/rockchip-reboot.txt
new file mode 100644
index 000..6f69c8d
--- /dev/null
+++ b/Documentation/devicetree/bindings/soc/rockchip/rockchip-reboot.txt
@@ -0,0 +1,18 @@
+Rockchip reboot notifier driver
+
+This driver get reboot mode arguments from userspace
+and stores it in special register. Then the bootloader
+will read it and take different action according the
+argument stored.
+
+Required properties:
+- compatible: should be "rockchip,reboot"
+- regmap: this is phandle to the register map node
+- offset: offset in the register map for the storage register (in bytes)
+
+Examples:
+   reboot {
+  compatible = "rockchip,reboot";
+  regmap = <&pmu>;
+  offset = <0x94>;
+   };
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 1/5] ARM: dts: rockchip: rk3288-veyron: rename pinctrl node reboot to reset

2015-11-18 Thread Andy Yan
rename pinctrl node reboot to reset to match it's lable name

Signed-off-by: Andy Yan 

---

Changes in v3:
 - rename a pinctrl node in rk3288-veyron, the original name will be
   used in the incoming reboot notifier driver

Changes in v2: None

 arch/arm/boot/dts/rk3288-veyron.dtsi | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/boot/dts/rk3288-veyron.dtsi 
b/arch/arm/boot/dts/rk3288-veyron.dtsi
index 2fa7a0d..292aaaf 100644
--- a/arch/arm/boot/dts/rk3288-veyron.dtsi
+++ b/arch/arm/boot/dts/rk3288-veyron.dtsi
@@ -495,7 +495,7 @@
};
};
 
-   reboot {
+   reset {
ap_warm_reset_h: ap-warm-reset-h {
rockchip,pins = ;
};
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v3 0/5] Add reboot notifier driver for rockchip platform

2015-11-18 Thread Andy Yan

rockchip platform have a protocol to pass the kernel reboot
mode to bootloader by some special registers when system reboot.
By this way the bootloader can take different action according
to the different kernel reboot mode, for example, command
"reboot loader" will reboot the board to rockusb mode, this is
a very convenient way to get the board enter download mode.
And Android system also use this protocol to pass "recovery"、
“fastboot” reboot mode to bootloader. In upstream land, We found
tegra platform also use this mechanism.

Before this version, I have sent two Series, which can be found
at [0] [1]
[0] https://patchwork.kernel.org/patch/7140751/
[1] https://patchwork.kernel.org/patch/7153531/

Changes in v3:
 - rename a pinctrl node in rk3288-veyron, the original name will be
   used in the incoming reboot notifier driver
 - add dt binding
 - move from mach-rockchip to drivers/soc/rockchip, as the tegra does
 - use dts pass the related register
 - add DT node

Changes in v2:
  - check cpu dt node
  - remove a unnecessary of_put_node in function rockchip_get_pmu_regmap
  - fix a align issue
  - use reboot_notifier instead of restart_handler

Andy Yan (5):
  ARM: dts: rockchip: rk3288-veyron: rename pinctrl node reboot to reset
  dt-bindings: soc: add document for rockchip reboot notifier driver
  soc: rockchip: add reboot notifier driver
  ARM: dts: rockchip: add reboot node
  ARM64: dts: rockchip: add reboot node

 .../bindings/soc/rockchip/rockchip-reboot.txt  | 18 
 arch/arm/boot/dts/rk3288-veyron.dtsi   |  2 +-
 arch/arm/boot/dts/rk3288.dtsi  |  6 ++
 arch/arm/boot/dts/rk3xxx.dtsi  |  6 ++
 arch/arm64/boot/dts/rockchip/rk3368.dtsi   |  6 ++
 drivers/soc/rockchip/Kconfig   |  7 ++
 drivers/soc/rockchip/Makefile  |  1 +
 drivers/soc/rockchip/loader.h  | 22 +
 drivers/soc/rockchip/reboot.c  | 98 ++
 9 files changed, 165 insertions(+), 1 deletion(-)
 create mode 100644 
Documentation/devicetree/bindings/soc/rockchip/rockchip-reboot.txt
 create mode 100644 drivers/soc/rockchip/loader.h
 create mode 100644 drivers/soc/rockchip/reboot.c

-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v2 0/2] add dts for PopMetal board

2015-03-04 Thread Andy Yan

Hi Heiko:
 Thanks very much.
On 2015年03月05日 03:57, Heiko Stuebner wrote:

Hi Andy,

Am Sonntag, 1. März 2015, 17:25:14 schrieb Andy Yan:

PopMetal is a rockchip rk3288 based board made by ChipSpark,
which has many interface such as VGA,HDMI,usb,ir,sdcad and lots of
sensors such as gyroscope(L3G4200D),accelerometer(mma8452),compass(AK8963C).

http://wiki.chipspark.com/en/index.php?title=PopMetal

This patch add basic support for it, which can boot the board
into a shell with linux boot logo on hdmi, sdcard and many
sensors enabled. More feather will be enabled later.

I've added both patches to my dts branch


Heiko






--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 2/2] ARM: dts: add rk3288 PopMetal board

2015-03-01 Thread Andy Yan
PopMetal is a rockchip rk3288 based board made by ChipSpark,
which has many interface such as VGA,HDMI,usb,ir,sdcad and lots of
sensors such as gyroscope(L3G4200D),accelerometer(mma8452),
compass(AK8963C).

This patch add a basic support for this board, which make the board
boot into a initramfs shell with sdcard,hdmi and all sensors enabled

Signed-off-by: Andy Yan 

---

Changes in v2:
- use GPL + X11 dual license, adviced by Heiko
- indent pwrbtn
- move node "ak8963" before "buttons"
- add cpu0-supply
- add supply for rk808 regulator

 arch/arm/boot/dts/rk3288-popmetal.dts | 447 ++
 1 file changed, 447 insertions(+)
 create mode 100644 arch/arm/boot/dts/rk3288-popmetal.dts

diff --git a/arch/arm/boot/dts/rk3288-popmetal.dts 
b/arch/arm/boot/dts/rk3288-popmetal.dts
new file mode 100644
index 000..d081f0e
--- /dev/null
+++ b/arch/arm/boot/dts/rk3288-popmetal.dts
@@ -0,0 +1,447 @@
+/*
+ * Copyright (c) 2014, 2015 Andy Yan 
+ *
+ * This file is dual-licensed: you can use it either under the terms
+ * of the GPL or the X11 license, at your option. Note that this dual
+ * licensing only applies to this file, and not this project as a
+ * whole.
+ *
+ *  a) This file is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This file 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.
+ *
+ *  Or, alternatively,
+ *
+ *  b) Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use,
+ * copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following
+ * conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+ * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+ * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+/dts-v1/;
+
+#include "rk3288.dtsi"
+
+/ {
+   model = "PopMetal-RK3288";
+   compatible = "chipspark,popmetal-rk3288", "rockchip,rk3288";
+
+   memory{
+   reg = <0 0x8000>;
+   };
+
+   ext_gmac: external-gmac-clock {
+   compatible = "fixed-clock";
+   clock-frequency = <12500>;
+   clock-output-names = "ext_gmac";
+   #clock-cells = <0>;
+   };
+
+   gpio-keys {
+   compatible = "gpio-keys";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   autorepeat;
+
+   pinctrl-names = "default";
+   pinctrl-0 = <&pwrbtn>;
+
+   button@0 {
+   gpios = <&gpio0 5 GPIO_ACTIVE_LOW>;
+   linux,code = <116>;
+   label = "GPIO Key Power";
+   linux,input-type = <1>;
+   gpio-key,wakeup = <1>;
+   debounce-interval = <100>;
+   };
+   };
+
+   ir: ir-receiver {
+   compatible = "gpio-ir-receiver";
+   gpios = <&gpio0 6 GPIO_ACTIVE_LOW>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&ir_int>;
+   };
+
+   vcc_sys: vsys-regulator {
+   compatible = "regulator-fixed";
+   regulator-name = "vcc_sys";
+   regulator-min-microvolt = <500>;
+   regulator-max-microvolt = <500>;
+   regulator-always-on;
+   regulator-boot-on;
+   };
+};
+
+&cpu0 {
+   cpu0-supply = <&vdd_cpu>;
+};
+
+&emmc {
+   broken-cd;
+   bus-width = <8>;
+   cap-mmc-highspeed;
+   disable-wp

[PATCH v2 1/2] dt-bindings: add root compatible property for PopMetal board

2015-03-01 Thread Andy Yan
PopMetal board is a rk3288 based board made by ChipSpark, this
add root compatible property for it

Signed-off-by: Andy Yan 

---

Changes in v2:
- change "PopMetal PopMetal-RK3288 board" to "ChipSPARK PopMetal-RK3288 board"

 Documentation/devicetree/bindings/arm/rockchip.txt | 4 
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/rockchip.txt 
b/Documentation/devicetree/bindings/arm/rockchip.txt
index 6809e4e..60d4a1e 100644
--- a/Documentation/devicetree/bindings/arm/rockchip.txt
+++ b/Documentation/devicetree/bindings/arm/rockchip.txt
@@ -22,3 +22,7 @@ Rockchip platforms device tree bindings
   - compatible = "firefly,firefly-rk3288", "rockchip,rk3288";
 or
   - compatible = "firefly,firefly-rk3288-beta", "rockchip,rk3288";
+
+- ChipSPARK PopMetal-RK3288 board:
+Required root node properties:
+  - compatible = "chipspark,popmetal-rk3288", "rockchip,rk3288";
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 0/2] add dts for PopMetal board

2015-03-01 Thread Andy Yan

PopMetal is a rockchip rk3288 based board made by ChipSpark,
which has many interface such as VGA,HDMI,usb,ir,sdcad and lots of
sensors such as gyroscope(L3G4200D),accelerometer(mma8452),compass(AK8963C).

http://wiki.chipspark.com/en/index.php?title=PopMetal

This patch add basic support for it, which can boot the board
into a shell with linux boot logo on hdmi, sdcard and many
sensors enabled. More feather will be enabled later.

Changes in v2:
- change "PopMetal PopMetal-RK3288 board" to "ChipSPARK PopMetal-RK3288 board"
- use GPL + X11 dual license, adviced by Heiko
- indent pwrbtn
- move node "ak8963" before "buttons"

Andy Yan (2):
  dt-bindings: add root compatible property for PopMetal board
  ARM: dts: add rk3288 PopMetal board

 Documentation/devicetree/bindings/arm/rockchip.txt |   4 +
 arch/arm/boot/dts/rk3288-popmetal.dts  | 447 +
 2 files changed, 451 insertions(+)
 create mode 100644 arch/arm/boot/dts/rk3288-popmetal.dts

-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/2] ARM: dts: add rk3288 PopMetal board

2015-02-28 Thread Andy Yan

Hi Heiko:

On 2015年03月01日 01:57, Heiko Stübner wrote:

Hi Andy,

Am Freitag, 27. Februar 2015, 19:03:03 schrieb Andy Yan:

PopMetal is a rockchip rk3288 based board made by ChipSpark,
which has many interface such as VGA,HDMI,usb,ir,sdcad and
lots of sensors such as gyroscope(L3G4200D),accelerometer(mma8452),
compass(AK8963C).

This patch add a basic support for this board, which make the board
boot into a initramfs shell with sdcard and all sensors enabled

Signed-off-by: Andy Yan 
---

  arch/arm/boot/dts/rk3288-popmetal.dts | 396
++ 1 file changed, 396 insertions(+)
  create mode 100644 arch/arm/boot/dts/rk3288-popmetal.dts

diff --git a/arch/arm/boot/dts/rk3288-popmetal.dts
b/arch/arm/boot/dts/rk3288-popmetal.dts new file mode 100644
index 000..f0c0cd9
--- /dev/null
+++ b/arch/arm/boot/dts/rk3288-popmetal.dts
@@ -0,0 +1,396 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.

could you please put the new file under a gpl2+x11 dual license?
See the firefly dts files for an example.

Relicensing the of the already existing files is somewhere on my todo list, but
but at least we shouldn't introduce new restricted files at this point :-) .


Licensing with a more permissible license is necessary so that other projects
can use our dts files too (like the BSDs) and the gpl2 + x11 dual license is
the current agreed upon combination.

ok, I will use gpl2+x11 dual license



+ */
+
+/dts-v1/;
+
+#include "rk3288.dtsi"
+
+/ {
+   model = "PopMetal-RK3288";
+   compatible = "chipspark,popmetal-rk3288", "rockchip,rk3288";

a blank line here please

   ok



+   memory{
+   reg = <0 0x8000>;
+   };
+
+   ext_gmac: external-gmac-clock {
+   compatible = "fixed-clock";
+   clock-frequency = <12500>;
+   clock-output-names = "ext_gmac";
+   #clock-cells = <0>;
+   };
+
+   gpio-keys {
+   compatible = "gpio-keys";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   autorepeat;
+
+   pinctrl-names = "default";
+   pinctrl-0 = <&pwrbtn>;
+
+   button@0 {
+   gpios = <&gpio0 5 GPIO_ACTIVE_LOW>;
+   linux,code = <116>;
+   label = "GPIO Key Power";
+   linux,input-type = <1>;
+   gpio-key,wakeup = <1>;
+   debounce-interval = <100>;
+   };
+   };
+
+   ir: ir-receiver {
+   compatible = "gpio-ir-receiver";
+   gpios = <&gpio0 6 GPIO_ACTIVE_LOW>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&ir_int>;
+   };
+
+};
+
+&emmc {
+   broken-cd;
+   bus-width = <8>;
+   cap-mmc-highspeed;
+   disable-wp;
+   non-removable;
+   num-slots = <1>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&emmc_clk &emmc_cmd &emmc_pwr &emmc_bus8>;
+   status = "okay";
+};
+
+&sdmmc {
+   bus-width = <4>;
+   cap-mmc-highspeed;
+   cap-sd-highspeed;
+   card-detect-delay = <200>;
+   disable-wp; /* wp not hooked up */
+   num-slots = <1>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&sdmmc_clk &sdmmc_cmd &sdmmc_cd &sdmmc_bus4>;
+   status = "okay";
+};
+
+&gmac {
+   phy-supply = <&vcc_lan>;
+   phy-mode = "rgmii";
+   clock_in_out = "input";
+   snps,reset-gpio = <&gpio4 7 0>;
+   snps,reset-active-low;
+   snps,reset-delays-us = <0 1 100>;
+   assigned-clocks = <&cru SCLK_MAC>;
+   assigned-clock-parents = <&ext_gmac>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&rgmii_pins>;
+   tx_delay = <0x30>;
+   rx_delay = <0x10>;
+   status = "ok";
+};
+
+&hdmi {
+   ddc-i2c-bus = <&i2c5>;
+   status = "okay";
+};
+
+&i2c0 {
+   status = "okay";
+   clock-frequency = <40>;
+
+   rk808: pmic@1b {
+   compatible = &q

Re: [PATCH 1/2] dt-bindings: add root compatible property for PopMetal board

2015-02-28 Thread Andy Yan

Hi Heiko:

On 2015年03月01日 01:43, Heiko Stübner wrote:

Hi Andy,

Am Freitag, 27. Februar 2015, 18:59:01 schrieb Andy Yan:

PopMetal board is a rk3288 based board made by ChipSpark,
this patch add root compatible property for it

Signed-off-by: Andy Yan 

---

  Documentation/devicetree/bindings/arm/rockchip.txt | 4 
  1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/rockchip.txt
b/Documentation/devicetree/bindings/arm/rockchip.txt index 6809e4e..818d249
100644
--- a/Documentation/devicetree/bindings/arm/rockchip.txt
+++ b/Documentation/devicetree/bindings/arm/rockchip.txt
@@ -22,3 +22,7 @@ Rockchip platforms device tree bindings
- compatible = "firefly,firefly-rk3288", "rockchip,rk3288";
  or
- compatible = "firefly,firefly-rk3288-beta", "rockchip,rk3288";
+
+- PopMetal PopMetal-RK3288 board:

this should probably be
ChipSPARK PopMetal-RK3288 board:

  ok, this will be fixed in V2




+Required root node properties:
+  - compatible = "chipspark,popmetal-rk3288", "rockchip,rk3288";







--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] dt-bindings: add root compatible property for PopMetal board

2015-02-27 Thread Andy Yan
PopMetal board is a rk3288 based board made by ChipSpark,
this patch add root compatible property for it

Signed-off-by: Andy Yan 

---

 Documentation/devicetree/bindings/arm/rockchip.txt | 4 
 1 file changed, 4 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/rockchip.txt 
b/Documentation/devicetree/bindings/arm/rockchip.txt
index 6809e4e..818d249 100644
--- a/Documentation/devicetree/bindings/arm/rockchip.txt
+++ b/Documentation/devicetree/bindings/arm/rockchip.txt
@@ -22,3 +22,7 @@ Rockchip platforms device tree bindings
   - compatible = "firefly,firefly-rk3288", "rockchip,rk3288";
 or
   - compatible = "firefly,firefly-rk3288-beta", "rockchip,rk3288";
+
+- PopMetal PopMetal-RK3288 board:
+Required root node properties:
+  - compatible = "chipspark,popmetal-rk3288", "rockchip,rk3288";
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 0/2] add dts for PopMetal board

2015-02-27 Thread Andy Yan

PopMetal is a rockchip rk3288 based board made by ChipSpark,
which has many interface such as VGA,HDMI,usb,ir,sdcad and lots of
sensors such as gyroscope(L3G4200D),accelerometer(mma8452),compass(AK8963C).

http://wiki.chipspark.com/en/index.php?title=PopMetal

This patch add basic support for it. More feather will be enabled later.


Andy Yan (2):
  dt-bindings: add root compatible property for PopMetal board
  ARM: dts: add rk3288 PopMetal board

 Documentation/devicetree/bindings/arm/rockchip.txt |   4 +
 arch/arm/boot/dts/rk3288-popmetal.dts  | 396 +
 2 files changed, 400 insertions(+)
 create mode 100644 arch/arm/boot/dts/rk3288-popmetal.dts

-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] ARM: dts: add rk3288 PopMetal board

2015-02-27 Thread Andy Yan
PopMetal is a rockchip rk3288 based board made by ChipSpark,
which has many interface such as VGA,HDMI,usb,ir,sdcad and
lots of sensors such as gyroscope(L3G4200D),accelerometer(mma8452),
compass(AK8963C).

This patch add a basic support for this board, which make the board
boot into a initramfs shell with sdcard and all sensors enabled

Signed-off-by: Andy Yan 
---

 arch/arm/boot/dts/rk3288-popmetal.dts | 396 ++
 1 file changed, 396 insertions(+)
 create mode 100644 arch/arm/boot/dts/rk3288-popmetal.dts

diff --git a/arch/arm/boot/dts/rk3288-popmetal.dts 
b/arch/arm/boot/dts/rk3288-popmetal.dts
new file mode 100644
index 000..f0c0cd9
--- /dev/null
+++ b/arch/arm/boot/dts/rk3288-popmetal.dts
@@ -0,0 +1,396 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * 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.
+ */
+
+/dts-v1/;
+
+#include "rk3288.dtsi"
+
+/ {
+   model = "PopMetal-RK3288";
+   compatible = "chipspark,popmetal-rk3288", "rockchip,rk3288";
+   memory{
+   reg = <0 0x8000>;
+   };
+
+   ext_gmac: external-gmac-clock {
+   compatible = "fixed-clock";
+   clock-frequency = <12500>;
+   clock-output-names = "ext_gmac";
+   #clock-cells = <0>;
+   };
+
+   gpio-keys {
+   compatible = "gpio-keys";
+   #address-cells = <1>;
+   #size-cells = <0>;
+   autorepeat;
+
+   pinctrl-names = "default";
+   pinctrl-0 = <&pwrbtn>;
+
+   button@0 {
+   gpios = <&gpio0 5 GPIO_ACTIVE_LOW>;
+   linux,code = <116>;
+   label = "GPIO Key Power";
+   linux,input-type = <1>;
+   gpio-key,wakeup = <1>;
+   debounce-interval = <100>;
+   };
+   };
+
+   ir: ir-receiver {
+   compatible = "gpio-ir-receiver";
+   gpios = <&gpio0 6 GPIO_ACTIVE_LOW>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&ir_int>;
+   };
+
+};
+
+&emmc {
+   broken-cd;
+   bus-width = <8>;
+   cap-mmc-highspeed;
+   disable-wp;
+   non-removable;
+   num-slots = <1>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&emmc_clk &emmc_cmd &emmc_pwr &emmc_bus8>;
+   status = "okay";
+};
+
+&sdmmc {
+   bus-width = <4>;
+   cap-mmc-highspeed;
+   cap-sd-highspeed;
+   card-detect-delay = <200>;
+   disable-wp; /* wp not hooked up */
+   num-slots = <1>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&sdmmc_clk &sdmmc_cmd &sdmmc_cd &sdmmc_bus4>;
+   status = "okay";
+};
+
+&gmac {
+   phy-supply = <&vcc_lan>;
+   phy-mode = "rgmii";
+   clock_in_out = "input";
+   snps,reset-gpio = <&gpio4 7 0>;
+   snps,reset-active-low;
+   snps,reset-delays-us = <0 1 100>;
+   assigned-clocks = <&cru SCLK_MAC>;
+   assigned-clock-parents = <&ext_gmac>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&rgmii_pins>;
+   tx_delay = <0x30>;
+   rx_delay = <0x10>;
+   status = "ok";
+};
+
+&hdmi {
+   ddc-i2c-bus = <&i2c5>;
+   status = "okay";
+};
+
+&i2c0 {
+   status = "okay";
+   clock-frequency = <40>;
+
+   rk808: pmic@1b {
+   compatible = "rockchip,rk808";
+   reg = <0x1b>;
+   interrupt-parent = <&gpio0>;
+   interrupts = <4 IRQ_TYPE_LEVEL_LOW>;
+   pinctrl-names = "default";
+   pinctrl-0 = <&pmic_int &global_pwroff>;
+   rockchip,system-power-controller;
+   wakeup-source;
+   #clock-cells = <1>;
+   clock-output-names = "xin32k", "rk808-clkout2";
+
+   vcc8-supply = <&vcc_18>;
+   vcc9-supply = <&vcc_io&

[PATCH v18 12/12] drm: bridge/dw_hdmi: add rockchip rk3288 support

2015-01-06 Thread Andy Yan
Rockchip RK3288 hdmi is compatible with dw_hdmi

Signed-off-by: Andy Yan 

---

Changes in v18:
- fix two compile errors when build as module

Changes in v17:
- parse resource and irq in platform driver

Changes in v16: None
Changes in v15:
- remove THIS_MODULE in platform driver

Changes in v14: None
Changes in v13: None
Changes in v12:
- add comment for the depend on patch

Changes in v11: None
Changes in v10:
- add more display mode support mpll configuration for rk3288

Changes in v9:
- move some phy configuration to platform driver

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/bridge/dw_hdmi.c|   3 +
 drivers/gpu/drm/rockchip/Kconfig|  10 +
 drivers/gpu/drm/rockchip/Makefile   |   2 +
 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 341 
 include/drm/bridge/dw_hdmi.h|   1 +
 5 files changed, 357 insertions(+)
 create mode 100644 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index cecc46a..01c95a8 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -852,6 +852,9 @@ static int hdmi_phy_configure(struct dw_hdmi *hdmi, 
unsigned char prep,
dw_hdmi_phy_gen2_txpwron(hdmi, 1);
dw_hdmi_phy_gen2_pddq(hdmi, 0);
 
+   if (hdmi->dev_type == RK3288_HDMI)
+   dw_hdmi_phy_enable_spare(hdmi, 1);
+
/*Wait for PHY PLL lock */
msec = 5;
do {
diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
index ca9f085..6ebebe8 100644
--- a/drivers/gpu/drm/rockchip/Kconfig
+++ b/drivers/gpu/drm/rockchip/Kconfig
@@ -15,3 +15,13 @@ config DRM_ROCKCHIP
  management to userspace. This driver does not provide
  2D or 3D acceleration; acceleration is performed by other
  IP found on the SoC.
+
+config ROCKCHIP_DW_HDMI
+bool "Rockchip specific extensions for Synopsys DW HDMI"
+depends on DRM_ROCKCHIP
+select DRM_DW_HDMI
+help
+ This selects support for Rockchip SoC specific extensions
+ for the Synopsys DesignWare HDMI driver. If you want to
+ enable HDMI on RK3288 based SoC, you should selet this
+ option.
diff --git a/drivers/gpu/drm/rockchip/Makefile 
b/drivers/gpu/drm/rockchip/Makefile
index 2cb0672..f3d8a19 100644
--- a/drivers/gpu/drm/rockchip/Makefile
+++ b/drivers/gpu/drm/rockchip/Makefile
@@ -5,4 +5,6 @@
 rockchipdrm-y := rockchip_drm_drv.o rockchip_drm_fb.o rockchip_drm_fbdev.o \
rockchip_drm_gem.o
 
+obj-$(CONFIG_ROCKCHIP_DW_HDMI) += dw_hdmi-rockchip.o
+
 obj-$(CONFIG_DRM_ROCKCHIP) += rockchipdrm.o rockchip_drm_vop.o
diff --git a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c 
b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
new file mode 100644
index 000..d236faa
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
@@ -0,0 +1,341 @@
+/*
+ * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "rockchip_drm_drv.h"
+#include "rockchip_drm_vop.h"
+
+#define GRF_SOC_CON60x025c
+#define HDMI_SEL_VOP_LIT(1 << 4)
+
+struct rockchip_hdmi {
+   struct device *dev;
+   struct regmap *regmap;
+   struct drm_encoder encoder;
+};
+
+#define to_rockchip_hdmi(x)container_of(x, struct rockchip_hdmi, x)
+
+static const struct dw_hdmi_mpll_config rockchip_mpll_cfg[] = {
+   {
+   2700, {
+   { 0x00b3, 0x},
+   { 0x2153, 0x},
+   { 0x40f3, 0x}
+   },
+   }, {
+   3600, {
+   { 0x00b3, 0x},
+   { 0x2153, 0x},
+   { 0x40f3, 0x}
+   },
+   }, {
+   4000, {
+   { 0x00b3, 0x},
+   { 0x2153, 0x},
+   { 0x40f3, 0x}
+   },
+   }, {
+   5400, {
+   { 0x0072, 0x0001},
+   { 0x2142, 0x0001},
+   { 0x40a2, 0x0001},
+   },
+   }, {
+   6500, {
+   { 0x0072, 0x0001},
+   { 0x2142, 0x0001},
+   { 0x40a2, 0x0001},
+   },
+   }, {
+   6600, {
+   { 0x013e, 0x0003},
+

Re: [PATCH v18 0/12] dw-hdmi: convert imx hdmi to bridge/dw_hdmi

2015-01-06 Thread Andy Yan

Hi Liu Ying , Philipp:

On 2015年01月07日 10:39, Liu Ying wrote:


On 12/05/2014 02:22 PM, Andy Yan wrote:


We found Freescale imx6 and Rockchip rk3288 and Ingenic JZ4780 
(Xburst/MIPS)

use the interface compatible Designware HDMI IP, but they also have some
lightly differences, such as phy pll configuration, register 
width(imx hdmi
register is one byte, but rk3288 is 4 bytes width and can only be 
accessed
by word), 4K support(imx6 doesn't support 4k, but rk3288 does), and 
HDMI2.0

support.

To reuse the imx-hdmi driver, we make this patch set:
(1): fix some CodingStyle warning to make checkpatch happy
(2): convert imx-hdmi to drm_bridge
(3): split platform specific code
(4): move imx-hdmi to bridge/dw_hdmi
(5): extend dw_hdmi.c to support rk3288 hdmi
(6): add rockchip rk3288 platform specific code dw_hdmi-rockchip.c

Changes in v18:
- remove a multiple blank lines in imx-hdmi.c
- fix a checkpatch warning in imx-hdmi_pltfm.c
- add port bindings
- correct some spelling mistakes in dw_hdmi bindings doc
- correct some spelling mistakes in dw_hdmi-rockchip bindings doc

Changes in v17:
- remove platform device stuff, adviced by Russell King
- remove prompt message of dw_hdmi, adviced by Russel King
- parse resource and irq in platform driver

Changes in v16:
- use the common binding for the clocks
- describe ddc-i2c-bus as optional
- add common clocks bindings
- modify clocks bindings
- descrbie ddc-i2c-bus as optional

Changes in v15:
- add prefix dw_hdmi/DW_HDMI for public used dw_hdmi structs
   adviced by Philipp Zabel
- remove THIS_MODULE in platform driver
- remove unio of the multi-byte register access, adviced by Philipp 
Zabel

- remove THIS_MODULE in platform driver

Changes in v14:
- add defer probing, adviced by Philipp Zabel
- remove drm_connector_register, because imx-drm core has registered
connector

Changes in v13:
- patch against drm-next
- split platform specific phy configuration
- split phy configuration from patch#4

Changes in v12:
- refactor of_node_put(ddc_node)
- squash patch 
- add comment for the depend on patch

Changes in v11:
- squash patch  

Changes in v10:
- split generic dw_hdmi.c improvements from patch#11 (add rk3288 
support)

- add more display mode support mpll configuration for rk3288

Changes in v9:
- move some phy configuration to platform driver

Changes in v8:
- correct some spelling mistake
- modify ddc-i2c-bus and interrupt description
- Add documentation for rockchip dw hdmi

Changes in v7:
- remove unused variables from structure dw_hdmi
- remove a wrong modification
- add copyrights for dw_hdmi-imx.c

Changes in v6:
- rearrange the patch order
- refactor register access without reg_shift

Changes in v5:
- refactor reg-io-width

Changes in v4:
- fix checkpatch CHECK
- defer probe ddc i2c adapter

Changes in v3:
- split multi-register access to one indepent patch

Andy Yan (12):
   drm: imx: imx-hdmi: make checkpatch happy
   drm: imx: imx-hdmi: return defer if can't get ddc i2c adapter
   drm: imx: imx-hdmi: convert imx-hdmi to drm_bridge mode
   drm: imx: imx-hdmi: split phy configuration to platform driver
   drm: imx: imx-hdmi: move imx-hdmi to bridge/dw_hdmi
   dt-bindings: add document for dw_hdmi
   drm: bridge/dw_hdmi: add support for multi-byte register width access
   drm: bridge/dw_hdmi: add mode_valid support
   drm: bridge/dw_hdmi: clear i2cmphy_stat0 reg in 
hdmi_phy_wait_i2c_done

   drm: bridge/dw_hdmi: add function dw_hdmi_phy_enable_spare
   dt-bindings: Add documentation for rockchip dw hdmi
   drm: bridge/dw_hdmi: add rockchip rk3288 support

  .../devicetree/bindings/drm/bridge/dw_hdmi.txt |  50 ++
  .../devicetree/bindings/video/dw_hdmi-rockchip.txt |  46 ++
  drivers/gpu/drm/bridge/Kconfig |   5 +
  drivers/gpu/drm/bridge/Makefile|   1 +
  .../gpu/drm/{imx/imx-hdmi.c => bridge/dw_hdmi.c}   | 717 
++---

  .../gpu/drm/{imx/imx-hdmi.h => bridge/dw_hdmi.h}   |   4 +-
  drivers/gpu/drm/imx/Kconfig|   1 +
  drivers/gpu/drm/imx/Makefile   |   2 +-
  drivers/gpu/drm/imx/dw_hdmi-imx.c  | 258 
  drivers/gpu/drm/rockchip/Kconfig   |  10 +
  drivers/gpu/drm/rockchip/Makefile  |   2 +
  drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c| 341 ++
  include/drm/bridge/dw_hdmi.h   |  61 ++
  13 files changed,  insertions(+), 387 deletions(-)
  create mode 100644 
Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt
  create mode 100644 
Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt

  rename drivers/gpu/drm/{imx/imx-hdmi.c => bridge/dw_hdmi.c} (72%)
  rename drivers/gpu/drm/{imx/imx-hdmi.h => bridge/dw_hdmi.h} (99%)
  create mode 100644 drivers/gpu/drm/imx/dw_hdmi-imx.c
  create mode 100644 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
  create mode 100644 include/drm/bridge/dw_hdmi.h



After applying this series, I find 

Re: [PATCH v18 06/12] dt-bindings: add document for dw_hdmi

2014-12-07 Thread Andy Yan

Hi Mark Rutland, Rob Herring, Pawel Moll, Ian Campbell, Kumar Gala:
Would you please give an Ack for this?

On 2014年12月05日 21:54, Philipp Zabel wrote:

Am Freitag, den 05.12.2014, 14:27 +0800 schrieb Andy Yan:

Signed-off-by: Andy Yan 

This binding is mostly a copy of the existing
Documentation/devicetree/bindings/drm/imx/hdmi.txt, but there is a new
reg-io-width property to configure the register access bus width and we
have added new compatibles "rockchip,rk3288-dw-hdmi" and the common
"snps,dw-hdmi-tx". Could we get an Ack for this and patch 11 by the
device tree maintainers?

regards
Philipp

---

Changes in v18:
- add port bindings
- correct some spelling mistakes in dw_hdmi bindings doc

Changes in v17: None
Changes in v16:
- describe ddc-i2c-bus as optional
- add common clocks bindings

Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8:
- correct some spelling mistake
- modify ddc-i2c-bus and interrupt description

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

  .../devicetree/bindings/drm/bridge/dw_hdmi.txt | 50 ++
  1 file changed, 50 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt

diff --git a/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt 
b/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt
new file mode 100644
index 000..a905c14
--- /dev/null
+++ b/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt
@@ -0,0 +1,50 @@
+DesignWare HDMI bridge bindings
+
+Required properties:
+- compatible: platform specific such as:
+   * "snps,dw-hdmi-tx"
+   * "fsl,imx6q-hdmi"
+   * "fsl,imx6dl-hdmi"
+   * "rockchip,rk3288-dw-hdmi"
+- reg: Physical base address and length of the controller's registers.
+- interrupts: The HDMI interrupt number
+- clocks, clock-names : must have the phandles to the HDMI iahb and isfr 
clocks,
+  as described in Documentation/devicetree/bindings/clock/clock-bindings.txt,
+  the clocks are soc specific, the clock-names should be "iahb", "isfr"
+-port@[X]: SoC specific port nodes with endpoint definitions as defined
+   in Documentation/devicetree/bindings/media/video-interfaces.txt,
+   please refer to the SoC specific binding document:
+* Documentation/devicetree/bindings/drm/imx/hdmi.txt
+* Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt
+
+Optional properties
+- reg-io-width: the width of the reg:1,4, default set to 1 if not present
+- ddc-i2c-bus: phandle of an I2C controller used for DDC EDID probing
+- clocks, clock-names: phandle to the HDMI CEC clock, name should be "cec"
+
+Example:
+   hdmi: hdmi@012 {
+   compatible = "fsl,imx6q-hdmi";
+   reg = <0x0012 0x9000>;
+   interrupts = <0 115 0x04>;
+   gpr = <&gpr>;
+   clocks = <&clks 123>, <&clks 124>;
+   clock-names = "iahb", "isfr";
+   ddc-i2c-bus = <&i2c2>;
+
+   port@0 {
+   reg = <0>;
+
+   hdmi_mux_0: endpoint {
+   remote-endpoint = <&ipu1_di0_hdmi>;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+
+   hdmi_mux_1: endpoint {
+   remote-endpoint = <&ipu1_di1_hdmi>;
+   };
+   };
+   };








--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v18 0/12] dw-hdmi: convert imx hdmi to bridge/dw_hdmi

2014-12-05 Thread Andy Yan

Hi Philipp:
On 2014年12月05日 21:55, Philipp Zabel wrote:

Hi Andy,

Am Freitag, den 05.12.2014, 14:22 +0800 schrieb Andy Yan:

We found Freescale imx6 and Rockchip rk3288 and Ingenic JZ4780 (Xburst/MIPS)
use the interface compatible Designware HDMI IP, but they also have some
lightly differences, such as phy pll configuration, register width(imx hdmi
register is one byte, but rk3288 is 4 bytes width and can only be accessed
by word), 4K support(imx6 doesn't support 4k, but rk3288 does), and HDMI2.0
support.

To reuse the imx-hdmi driver, we make this patch set:
(1): fix some CodingStyle warning to make checkpatch happy
(2): convert imx-hdmi to drm_bridge
(3): split platform specific code
(4): move imx-hdmi to bridge/dw_hdmi
(5): extend dw_hdmi.c to support rk3288 hdmi
(6): add rockchip rk3288 platform specific code dw_hdmi-rockchip.c

Changes in v18:
- remove a multiple blank lines in imx-hdmi.c
- fix a checkpatch warning in imx-hdmi_pltfm.c
- add port bindings
- correct some spelling mistakes in dw_hdmi bindings doc
- correct some spelling mistakes in dw_hdmi-rockchip bindings doc

[...]

I am happy with the series so far. Pending Acks from the device tree
maintainers for the new binding documents, I'd like to apply either the
whole of it on top of
 git://git.pengutronix.de/git/pza/linux.git imx-drm/next
or take at least the i.MX specific patches (1-5) because of the
dependency on the imx-drm OF helper conversion.

regards
Philipp




 I am very glad to see you are happy with the patch set, it's would be 
very

 nice if you can apply all of it.
 Thanks very much for you review.


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v18 12/12] drm: bridge/dw_hdmi: add rockchip rk3288 support

2014-12-04 Thread Andy Yan
Rockchip RK3288 hdmi is compatible with dw_hdmi

this patch is depend on patch by Mark Yao
drm: rockchip: Add basic drm driver
see https://lkml.org/lkml/2014/12/2/161

Signed-off-by: Andy Yan 

---

Changes in v18: None
Changes in v17:
- parse resource and irq in platform driver

Changes in v16: None
Changes in v15:
- remove THIS_MODULE in platform driver

Changes in v14: None
Changes in v13: None
Changes in v12:
- add comment for the depend on patch

Changes in v11: None
Changes in v10:
- add more display mode support mpll configuration for rk3288

Changes in v9:
- move some phy configuration to platform driver

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/bridge/dw_hdmi.c|   3 +
 drivers/gpu/drm/rockchip/Kconfig|  10 +
 drivers/gpu/drm/rockchip/Makefile   |   2 +
 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 341 
 include/drm/bridge/dw_hdmi.h|   1 +
 5 files changed, 357 insertions(+)
 create mode 100644 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index cecc46a..01c95a8 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -852,6 +852,9 @@ static int hdmi_phy_configure(struct dw_hdmi *hdmi, 
unsigned char prep,
dw_hdmi_phy_gen2_txpwron(hdmi, 1);
dw_hdmi_phy_gen2_pddq(hdmi, 0);
 
+   if (hdmi->dev_type == RK3288_HDMI)
+   dw_hdmi_phy_enable_spare(hdmi, 1);
+
/*Wait for PHY PLL lock */
msec = 5;
do {
diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
index ca9f085..6ebebe8 100644
--- a/drivers/gpu/drm/rockchip/Kconfig
+++ b/drivers/gpu/drm/rockchip/Kconfig
@@ -15,3 +15,13 @@ config DRM_ROCKCHIP
  management to userspace. This driver does not provide
  2D or 3D acceleration; acceleration is performed by other
  IP found on the SoC.
+
+config ROCKCHIP_DW_HDMI
+bool "Rockchip specific extensions for Synopsys DW HDMI"
+depends on DRM_ROCKCHIP
+select DRM_DW_HDMI
+help
+ This selects support for Rockchip SoC specific extensions
+ for the Synopsys DesignWare HDMI driver. If you want to
+ enable HDMI on RK3288 based SoC, you should selet this
+ option.
diff --git a/drivers/gpu/drm/rockchip/Makefile 
b/drivers/gpu/drm/rockchip/Makefile
index 2cb0672..beed7df 100644
--- a/drivers/gpu/drm/rockchip/Makefile
+++ b/drivers/gpu/drm/rockchip/Makefile
@@ -5,4 +5,6 @@
 rockchipdrm-y := rockchip_drm_drv.o rockchip_drm_fb.o rockchip_drm_fbdev.o \
rockchip_drm_gem.o
 
+rockchipdrm-$(CONFIG_ROCKCHIP_DW_HDMI) += dw_hdmi-rockchip.o
+
 obj-$(CONFIG_DRM_ROCKCHIP) += rockchipdrm.o rockchip_drm_vop.o
diff --git a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c 
b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
new file mode 100644
index 000..11d54b0
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
@@ -0,0 +1,341 @@
+/*
+ * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "rockchip_drm_drv.h"
+#include "rockchip_drm_vop.h"
+
+#define GRF_SOC_CON60x025c
+#define HDMI_SEL_VOP_LIT(1 << 4)
+
+struct rockchip_hdmi {
+   struct device *dev;
+   struct regmap *regmap;
+   struct drm_encoder encoder;
+};
+
+#define to_rockchip_hdmi(x)container_of(x, struct rockchip_hdmi, x)
+
+static const struct dw_hdmi_mpll_config rockchip_mpll_cfg[] = {
+   {
+   2700, {
+   { 0x00b3, 0x},
+   { 0x2153, 0x},
+   { 0x40f3, 0x}
+   },
+   }, {
+   3600, {
+   { 0x00b3, 0x},
+   { 0x2153, 0x},
+   { 0x40f3, 0x}
+   },
+   }, {
+   4000, {
+   { 0x00b3, 0x},
+   { 0x2153, 0x},
+   { 0x40f3, 0x}
+   },
+   }, {
+   5400, {
+   { 0x0072, 0x0001},
+   { 0x2142, 0x0001},
+   { 0x40a2, 0x0001},
+   },
+   }, {
+   6500, {
+   { 0x0072, 0x0001},
+   { 0x2142, 0x0001},
+   { 0x40a2, 0x0001},
+   }

[PATCH v18 11/12] dt-bindings: Add documentation for rockchip dw hdmi

2014-12-04 Thread Andy Yan
Signed-off-by: Andy Yan 

---

Changes in v18:
- correct some spelling mistakes in dw_hdmi-rockchip bindings doc

Changes in v17: None
Changes in v16:
- modify clocks bindings
- descrbie ddc-i2c-bus as optional

Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8:
- Add documentation for rockchip dw hdmi

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 .../devicetree/bindings/video/dw_hdmi-rockchip.txt | 46 ++
 1 file changed, 46 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt

diff --git a/Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt 
b/Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt
new file mode 100644
index 000..668091f
--- /dev/null
+++ b/Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt
@@ -0,0 +1,46 @@
+Rockchip specific extensions to the Synopsys Designware HDMI
+
+
+Required properties:
+- compatible: "rockchip,rk3288-dw-hdmi";
+- reg: Physical base address and length of the controller's registers.
+- clocks: phandle to hdmi iahb and isfr clocks.
+- clock-names: should be "iahb" "isfr"
+- rockchip,grf: this soc should set GRF regs to mux vopl/vopb.
+- interrupts: HDMI interrupt number
+- ports: contain a port node with endpoint definitions as defined in
+  Documentation/devicetree/bindings/media/video-interfaces.txt. For
+  vopb,set the reg = <0> and set the reg = <1> for vopl.
+- reg-io-width: the width of the reg:1,4, the value should be 4 on
+  rk3288 platform
+
+Optional properties
+- ddc-i2c-bus: phandle of an I2C controller used for DDC EDID probing
+- clocks, clock-names: phandle to the HDMI CEC clock, name should be "cec"
+
+Example:
+hdmi: hdmi@ff98 {
+   compatible = "rockchip,rk3288-dw-hdmi";
+   reg = <0xff98 0x2>;
+   reg-io-width = <4>;
+   ddc-i2c-bus = <&i2c5>;
+   rockchip,grf = <&grf>;
+   interrupts = ;
+   clocks = <&cru  PCLK_HDMI_CTRL>, <&cru SCLK_HDMI_HDCP>;
+   clock-names = "iahb", "isfr";
+   status = "disabled";
+   ports {
+   hdmi_in: port {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   hdmi_in_vopb: endpoint@0 {
+   reg = <0>;
+   remote-endpoint = <&vopb_out_hdmi>;
+   };
+   hdmi_in_vopl: endpoint@1 {
+   reg = <1>;
+   remote-endpoint = <&vopl_out_hdmi>;
+   };
+   };
+   };
+};
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v18 10/12] drm: bridge/dw_hdmi: add function dw_hdmi_phy_enable_spare

2014-12-04 Thread Andy Yan
RK3288 HDMI will not work without the spare bit of
HDMI_PHY_CONF0 enable

Signed-off-by: Andy Yan 
---

Changes in v18: None
Changes in v17: None
Changes in v16: None
Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/bridge/dw_hdmi.c | 7 +++
 drivers/gpu/drm/bridge/dw_hdmi.h | 3 ++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index 2264ec1..cecc46a 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -713,6 +713,13 @@ static void dw_hdmi_phy_enable_tmds(struct dw_hdmi *hdmi, 
u8 enable)
 HDMI_PHY_CONF0_ENTMDS_MASK);
 }
 
+static void dw_hdmi_phy_enable_spare(struct dw_hdmi *hdmi, u8 enable)
+{
+   hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0,
+HDMI_PHY_CONF0_SPARECTRL_OFFSET,
+HDMI_PHY_CONF0_SPARECTRL_MASK);
+}
+
 static void dw_hdmi_phy_gen2_pddq(struct dw_hdmi *hdmi, u8 enable)
 {
hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0,
diff --git a/drivers/gpu/drm/bridge/dw_hdmi.h b/drivers/gpu/drm/bridge/dw_hdmi.h
index baa7849..175dbc8 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.h
+++ b/drivers/gpu/drm/bridge/dw_hdmi.h
@@ -837,7 +837,8 @@ enum {
HDMI_PHY_CONF0_PDZ_OFFSET = 7,
HDMI_PHY_CONF0_ENTMDS_MASK = 0x40,
HDMI_PHY_CONF0_ENTMDS_OFFSET = 6,
-   HDMI_PHY_CONF0_SPARECTRL = 0x20,
+   HDMI_PHY_CONF0_SPARECTRL_MASK = 0x20,
+   HDMI_PHY_CONF0_SPARECTRL_OFFSET = 5,
HDMI_PHY_CONF0_GEN2_PDDQ_MASK = 0x10,
HDMI_PHY_CONF0_GEN2_PDDQ_OFFSET = 4,
HDMI_PHY_CONF0_GEN2_TXPWRON_MASK = 0x8,
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v18 09/12] drm: bridge/dw_hdmi: clear i2cmphy_stat0 reg in hdmi_phy_wait_i2c_done

2014-12-04 Thread Andy Yan
HDMI_IH_I2CMPHY_STAT0 is a clear on write register, which indicates i2cm
operation status(i2c transfer done or error), every hdmi phy register
configuration must check this register to make sure the configuration
has complete. But the indication bit should be cleared after check, otherwise
the corresponding bit will hold on forever, this may give a wrong signal for
next check.

Signed-off-by: Andy Yan 
---

Changes in v18: None
Changes in v17: None
Changes in v16: None
Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/bridge/dw_hdmi.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index d5bec0c..2264ec1 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -666,11 +666,15 @@ static inline void hdmi_phy_test_dout(struct dw_hdmi 
*hdmi,
 
 static bool hdmi_phy_wait_i2c_done(struct dw_hdmi *hdmi, int msec)
 {
-   while ((hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3) == 0) {
+   u32 val;
+
+   while ((val = hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3) == 0) {
if (msec-- == 0)
return false;
udelay(1000);
}
+   hdmi_writeb(hdmi, val, HDMI_IH_I2CMPHY_STAT0);
+
return true;
 }
 
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v18 08/12] drm: bridge/dw_hdmi: add mode_valid support

2014-12-04 Thread Andy Yan
some platform may not support all the display mode,
add mode_valid interface check it

Signed-off-by: Andy Yan 

---

Changes in v18: None
Changes in v17: None
Changes in v16: None
Changes in v15: None
Changes in v14:
- remove drm_connector_register, because imx-drm core has registered
connector

Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/bridge/dw_hdmi.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index d49861c..d5bec0c 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -1405,6 +1405,20 @@ static int dw_hdmi_connector_get_modes(struct 
drm_connector *connector)
return 0;
 }
 
+static enum drm_mode_status
+dw_hdmi_connector_mode_valid(struct drm_connector *connector,
+struct drm_display_mode *mode)
+{
+   struct dw_hdmi *hdmi = container_of(connector,
+  struct dw_hdmi, connector);
+   enum drm_mode_status mode_status = MODE_OK;
+
+   if (hdmi->plat_data->mode_valid)
+   mode_status = hdmi->plat_data->mode_valid(connector, mode);
+
+   return mode_status;
+}
+
 static struct drm_encoder *dw_hdmi_connector_best_encoder(struct drm_connector
   *connector)
 {
@@ -1429,6 +1443,7 @@ static struct drm_connector_funcs dw_hdmi_connector_funcs 
= {
 
 static struct drm_connector_helper_funcs dw_hdmi_connector_helper_funcs = {
.get_modes = dw_hdmi_connector_get_modes,
+   .mode_valid = dw_hdmi_connector_mode_valid,
.best_encoder = dw_hdmi_connector_best_encoder,
 };
 
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v18 07/12] drm: bridge/dw_hdmi: add support for multi-byte register width access

2014-12-04 Thread Andy Yan
On rockchip rk3288, only word(32-bit) accesses are
permitted for hdmi registers.  Byte width accesses (writeb,
readb) generate an imprecise external abort.

Signed-off-by: Andy Yan 

---

Changes in v18: None
Changes in v17: None
Changes in v16: None
Changes in v15:
- remove unio of the multi-byte register access, adviced by Philipp Zabel

Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6:
- refactor register access without reg_shift

Changes in v5:
- refactor reg-io-width

Changes in v4: None
Changes in v3:
- split multi-register access to one indepent patch

 drivers/gpu/drm/bridge/dw_hdmi.c | 44 ++--
 1 file changed, 42 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index e0a7bc3..d49861c 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -128,18 +128,41 @@ struct dw_hdmi {
 
unsigned int sample_rate;
int ratio;
+
+   void (*write)(struct dw_hdmi *hdmi, u8 val, int offset);
+   u8 (*read)(struct dw_hdmi *hdmi, int offset);
 };
 
-static inline void hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset)
+static void dw_hdmi_writel(struct dw_hdmi *hdmi, u8 val, int offset)
+{
+   writel(val, hdmi->regs + (offset << 2));
+}
+
+static u8 dw_hdmi_readl(struct dw_hdmi *hdmi, int offset)
+{
+   return readl(hdmi->regs + (offset << 2));
+}
+
+static void dw_hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset)
 {
writeb(val, hdmi->regs + offset);
 }
 
-static inline u8 hdmi_readb(struct dw_hdmi *hdmi, int offset)
+static u8 dw_hdmi_readb(struct dw_hdmi *hdmi, int offset)
 {
return readb(hdmi->regs + offset);
 }
 
+static inline void hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset)
+{
+   hdmi->write(hdmi, val, offset);
+}
+
+static inline u8 hdmi_readb(struct dw_hdmi *hdmi, int offset)
+{
+   return hdmi->read(hdmi, offset);
+}
+
 static void hdmi_modb(struct dw_hdmi *hdmi, u8 data, u8 mask, unsigned reg)
 {
u8 val = hdmi_readb(hdmi, reg) & ~mask;
@@ -1511,6 +1534,7 @@ int dw_hdmi_bind(struct device *dev, struct device 
*master,
struct device_node *ddc_node;
struct dw_hdmi *hdmi;
int ret;
+   u32 val = 1;
 
hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL);
if (!hdmi)
@@ -1523,6 +1547,22 @@ int dw_hdmi_bind(struct device *dev, struct device 
*master,
hdmi->ratio = 100;
hdmi->encoder = encoder;
 
+   of_property_read_u32(np, "reg-io-width", &val);
+
+   switch (val) {
+   case 4:
+   hdmi->write = dw_hdmi_writel;
+   hdmi->read = dw_hdmi_readl;
+   break;
+   case 1:
+   hdmi->write = dw_hdmi_writeb;
+   hdmi->read = dw_hdmi_readb;
+   break;
+   default:
+   dev_err(dev, "reg-io-width must be 1 or 4\n");
+   return -EINVAL;
+   }
+
ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0);
if (ddc_node) {
hdmi->ddc = of_find_i2c_adapter_by_node(ddc_node);
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v18 06/12] dt-bindings: add document for dw_hdmi

2014-12-04 Thread Andy Yan
Signed-off-by: Andy Yan 

---

Changes in v18:
- add port bindings
- correct some spelling mistakes in dw_hdmi bindings doc

Changes in v17: None
Changes in v16:
- describe ddc-i2c-bus as optional
- add common clocks bindings

Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8:
- correct some spelling mistake
- modify ddc-i2c-bus and interrupt description

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 .../devicetree/bindings/drm/bridge/dw_hdmi.txt | 50 ++
 1 file changed, 50 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt

diff --git a/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt 
b/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt
new file mode 100644
index 000..a905c14
--- /dev/null
+++ b/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt
@@ -0,0 +1,50 @@
+DesignWare HDMI bridge bindings
+
+Required properties:
+- compatible: platform specific such as:
+   * "snps,dw-hdmi-tx"
+   * "fsl,imx6q-hdmi"
+   * "fsl,imx6dl-hdmi"
+   * "rockchip,rk3288-dw-hdmi"
+- reg: Physical base address and length of the controller's registers.
+- interrupts: The HDMI interrupt number
+- clocks, clock-names : must have the phandles to the HDMI iahb and isfr 
clocks,
+  as described in Documentation/devicetree/bindings/clock/clock-bindings.txt,
+  the clocks are soc specific, the clock-names should be "iahb", "isfr"
+-port@[X]: SoC specific port nodes with endpoint definitions as defined
+   in Documentation/devicetree/bindings/media/video-interfaces.txt,
+   please refer to the SoC specific binding document:
+* Documentation/devicetree/bindings/drm/imx/hdmi.txt
+* Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt
+
+Optional properties
+- reg-io-width: the width of the reg:1,4, default set to 1 if not present
+- ddc-i2c-bus: phandle of an I2C controller used for DDC EDID probing
+- clocks, clock-names: phandle to the HDMI CEC clock, name should be "cec"
+
+Example:
+   hdmi: hdmi@012 {
+   compatible = "fsl,imx6q-hdmi";
+   reg = <0x0012 0x9000>;
+   interrupts = <0 115 0x04>;
+   gpr = <&gpr>;
+   clocks = <&clks 123>, <&clks 124>;
+   clock-names = "iahb", "isfr";
+   ddc-i2c-bus = <&i2c2>;
+
+   port@0 {
+   reg = <0>;
+
+   hdmi_mux_0: endpoint {
+   remote-endpoint = <&ipu1_di0_hdmi>;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+
+   hdmi_mux_1: endpoint {
+   remote-endpoint = <&ipu1_di1_hdmi>;
+   };
+   };
+   };
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v18 05/12] drm: imx: imx-hdmi: move imx-hdmi to bridge/dw_hdmi

2014-12-04 Thread Andy Yan
the original imx hdmi driver is under drm/imx/,
which depends on imx-drm, so move the imx hdmi
driver out to drm/bridge and rename it to dw_hdmi

Signed-off-by: Andy Yan 

---

Changes in v18: None
Changes in v17:
- remove prompt message of dw_hdmi, adviced by Russel King

Changes in v16: None
Changes in v15:
- add prefix dw_hdmi/DW_HDMI for public used dw_hdmi structs
  adviced by Philipp Zabel
- remove THIS_MODULE in platform driver

Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/bridge/Kconfig |   5 +
 drivers/gpu/drm/bridge/Makefile|   1 +
 .../gpu/drm/{imx/imx-hdmi.c => bridge/dw_hdmi.c}   | 278 +++--
 .../gpu/drm/{imx/imx-hdmi.h => bridge/dw_hdmi.h}   |  43 
 drivers/gpu/drm/imx/Kconfig|   1 +
 drivers/gpu/drm/imx/Makefile   |   2 +-
 .../drm/imx/{imx-hdmi_pltfm.c => dw_hdmi-imx.c}| 110 
 include/drm/bridge/dw_hdmi.h   |  60 +
 8 files changed, 262 insertions(+), 238 deletions(-)
 rename drivers/gpu/drm/{imx/imx-hdmi.c => bridge/dw_hdmi.c} (84%)
 rename drivers/gpu/drm/{imx/imx-hdmi.h => bridge/dw_hdmi.h} (98%)
 rename drivers/gpu/drm/imx/{imx-hdmi_pltfm.c => dw_hdmi-imx.c} (58%)
 create mode 100644 include/drm/bridge/dw_hdmi.h

diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index 884923f..4d822f0 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -3,3 +3,8 @@ config DRM_PTN3460
depends on DRM
select DRM_KMS_HELPER
---help---
+
+config DRM_DW_HDMI
+   bool
+   depends on DRM
+   select DRM_KMS_HELPER
diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
index b4733e1..d8a8cfd 100644
--- a/drivers/gpu/drm/bridge/Makefile
+++ b/drivers/gpu/drm/bridge/Makefile
@@ -1,3 +1,4 @@
 ccflags-y := -Iinclude/drm
 
 obj-$(CONFIG_DRM_PTN3460) += ptn3460.o
+obj-$(CONFIG_DRM_DW_HDMI) += dw_hdmi.o
diff --git a/drivers/gpu/drm/imx/imx-hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
similarity index 84%
rename from drivers/gpu/drm/imx/imx-hdmi.c
rename to drivers/gpu/drm/bridge/dw_hdmi.c
index 409fb4f..e0a7bc3 100644
--- a/drivers/gpu/drm/imx/imx-hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -6,12 +6,11 @@
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
  *
- * SH-Mobile High-Definition Multimedia Interface (HDMI) driver
- * for SLISHDMI13T and SLIPHDMIT IP cores
+ * Designware High-Definition Multimedia Interface (HDMI) driver
  *
  * Copyright (C) 2010, Guennadi Liakhovetski 
  */
-
+#include 
 #include 
 #include 
 #include 
@@ -24,8 +23,9 @@
 #include 
 #include 
 #include 
+#include 
 
-#include "imx-hdmi.h"
+#include "dw_hdmi.h"
 
 #define HDMI_EDID_LEN  512
 
@@ -101,18 +101,19 @@ struct hdmi_data_info {
struct hdmi_vmode video_mode;
 };
 
-struct imx_hdmi {
+struct dw_hdmi {
struct drm_connector connector;
struct drm_encoder *encoder;
struct drm_bridge *bridge;
 
-   enum imx_hdmi_devtype dev_type;
+   enum dw_hdmi_devtype dev_type;
struct device *dev;
struct clk *isfr_clk;
struct clk *iahb_clk;
 
struct hdmi_data_info hdmi_data;
-   const struct imx_hdmi_plat_data *plat_data;
+   const struct dw_hdmi_plat_data *plat_data;
+
int vic;
 
u8 edid[HDMI_EDID_LEN];
@@ -129,17 +130,17 @@ struct imx_hdmi {
int ratio;
 };
 
-static inline void hdmi_writeb(struct imx_hdmi *hdmi, u8 val, int offset)
+static inline void hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset)
 {
writeb(val, hdmi->regs + offset);
 }
 
-static inline u8 hdmi_readb(struct imx_hdmi *hdmi, int offset)
+static inline u8 hdmi_readb(struct dw_hdmi *hdmi, int offset)
 {
return readb(hdmi->regs + offset);
 }
 
-static void hdmi_modb(struct imx_hdmi *hdmi, u8 data, u8 mask, unsigned reg)
+static void hdmi_modb(struct dw_hdmi *hdmi, u8 data, u8 mask, unsigned reg)
 {
u8 val = hdmi_readb(hdmi, reg) & ~mask;
 
@@ -147,13 +148,13 @@ static void hdmi_modb(struct imx_hdmi *hdmi, u8 data, u8 
mask, unsigned reg)
hdmi_writeb(hdmi, val, reg);
 }
 
-static void hdmi_mask_writeb(struct imx_hdmi *hdmi, u8 data, unsigned int reg,
+static void hdmi_mask_writeb(struct dw_hdmi *hdmi, u8 data, unsigned int reg,
 u8 shift, u8 mask)
 {
hdmi_modb(hdmi, data << shift, mask, reg);
 }
 
-static void hdmi_set_clock_regenerator_n(struct imx_hdmi *hdmi,
+static void hdmi_set_clock_regenerator_n(struct dw_hdmi *hdmi,
 unsigned int value)
 {
hdmi_writeb(hdmi, value

[PATCH v18 04/12] drm: imx: imx-hdmi: split phy configuration to platform driver

2014-12-04 Thread Andy Yan
hdmi phy configuration is platform specific, which can be adusted
according to the board to get the best SI

Signed-off-by: Andy Yan 

---

Changes in v18: None
Changes in v17: None
Changes in v16: None
Changes in v15: None
Changes in v14: None
Changes in v13:
- split phy configuration from patch#4

Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/imx/imx-hdmi.c   | 85 +++-
 drivers/gpu/drm/imx/imx-hdmi.h   | 29 
 drivers/gpu/drm/imx/imx-hdmi_pltfm.c | 57 
 3 files changed, 101 insertions(+), 70 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-hdmi.c b/drivers/gpu/drm/imx/imx-hdmi.c
index d72f82c..409fb4f 100644
--- a/drivers/gpu/drm/imx/imx-hdmi.c
+++ b/drivers/gpu/drm/imx/imx-hdmi.c
@@ -713,76 +713,14 @@ static void imx_hdmi_phy_sel_interface_control(struct 
imx_hdmi *hdmi, u8 enable)
 HDMI_PHY_CONF0_SELDIPIF_MASK);
 }
 
-enum {
-   RES_8,
-   RES_10,
-   RES_12,
-   RES_MAX,
-};
-
-struct mpll_config {
-   unsigned long mpixelclock;
-   struct {
-   u16 cpce;
-   u16 gmp;
-   } res[RES_MAX];
-};
-
-static const struct mpll_config mpll_config[] = {
-   {
-   4525, {
-   { 0x01e0, 0x },
-   { 0x21e1, 0x },
-   { 0x41e2, 0x }
-   },
-   }, {
-   9250, {
-   { 0x0140, 0x0005 },
-   { 0x2141, 0x0005 },
-   { 0x4142, 0x0005 },
-   },
-   }, {
-   14850, {
-   { 0x00a0, 0x000a },
-   { 0x20a1, 0x000a },
-   { 0x40a2, 0x000a },
-   },
-   }, {
-   ~0UL, {
-   { 0x00a0, 0x000a },
-   { 0x2001, 0x000f },
-   { 0x4002, 0x000f },
-   },
-   }
-};
-
-struct curr_ctrl {
-   unsigned long mpixelclock;
-   u16 curr[RES_MAX];
-};
-
-static const struct curr_ctrl curr_ctrl[] = {
-   /*  pixelclk bpp8bpp10   bpp12 */
-   {
-5400, { 0x091c, 0x091c, 0x06dc },
-   }, {
-5840, { 0x091c, 0x06dc, 0x06dc },
-   }, {
-7200, { 0x06dc, 0x06dc, 0x091c },
-   }, {
-7425, { 0x06dc, 0x0b5c, 0x091c },
-   }, {
-   11880, { 0x091c, 0x091c, 0x06dc },
-   }, {
-   21600, { 0x06dc, 0x0b5c, 0x091c },
-   }
-};
-
 static int hdmi_phy_configure(struct imx_hdmi *hdmi, unsigned char prep,
  unsigned char res, int cscon)
 {
unsigned res_idx, i;
u8 val, msec;
+   const struct mpll_config *mpll_config = hdmi->plat_data->mpll_cfg;
+   const struct curr_ctrl   *curr_ctrl = hdmi->plat_data->cur_ctr;
+   const struct sym_term *sym_term =  hdmi->plat_data->sym_term;
 
if (prep)
return -EINVAL;
@@ -828,7 +766,7 @@ static int hdmi_phy_configure(struct imx_hdmi *hdmi, 
unsigned char prep,
hdmi_phy_test_clear(hdmi, 0);
 
/* PLL/MPLL Cfg - always match on final entry */
-   for (i = 0; i < ARRAY_SIZE(mpll_config) - 1; i++)
+   for (i = 0; mpll_config[i].mpixelclock != (~0UL); i++)
if (hdmi->hdmi_data.video_mode.mpixelclock <=
mpll_config[i].mpixelclock)
break;
@@ -836,12 +774,12 @@ static int hdmi_phy_configure(struct imx_hdmi *hdmi, 
unsigned char prep,
hdmi_phy_i2c_write(hdmi, mpll_config[i].res[res_idx].cpce, 0x06);
hdmi_phy_i2c_write(hdmi, mpll_config[i].res[res_idx].gmp, 0x15);
 
-   for (i = 0; i < ARRAY_SIZE(curr_ctrl); i++)
+   for (i = 0; curr_ctrl[i].mpixelclock != (~0UL); i++)
if (hdmi->hdmi_data.video_mode.mpixelclock <=
curr_ctrl[i].mpixelclock)
break;
 
-   if (i >= ARRAY_SIZE(curr_ctrl)) {
+   if (curr_ctrl[i].mpixelclock == (~0UL)) {
dev_err(hdmi->dev, "Pixel clock %d - unsupported by HDMI\n",
hdmi->hdmi_data.video_mode.mpixelclock);
return -EINVAL;
@@ -852,10 +790,17 @@ static int hdmi_phy_configure(struct imx_hdmi *hdmi, 
unsigned char prep,
 
hdmi_phy_i2c_write(hdmi, 0x, 0x13);  /* PLLPHBYCTRL */
hdmi_phy_i2c_write(hdmi, 0x0006, 0x17);
+
+   for (i = 0; sym_term[i].mpixelclock != (~0UL); i++)
+   if (hdmi->hdmi_data.video_mode.mpixelclock <=
+   sym_term[i].mpixelclock)
+   break;
+
/* RESISTANCE TERM 133Ohm Cfg 

[PATCH v18 03/12] drm: imx: imx-hdmi: convert imx-hdmi to drm_bridge mode

2014-12-04 Thread Andy Yan
IMX6 and Rockchip RK3288 and JZ4780 (Ingenic Xburst/MIPS)
use the interface compatible Designware HDMI IP, but they
also have some lightly differences, such as phy pll configuration,
register width, 4K support, clk useage, and the crtc mux configuration
is also platform specific.

To reuse the imx hdmi driver, convert it to drm_bridge

handle encoder in imx-hdmi_pltfm.c, as most of the encoder
operation are platform specific such as crtc select and
panel format set

This patch depends on Russell King's patch:
 drm: imx: convert imx-drm to use the generic DRM OF helper
 
http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2014-July/053484.html

Signed-off-by: Andy Yan 
Signed-off-by: Yakir Yang 

---

Changes in v18:
- remove a multiple blank lines in imx-hdmi.c
- fix a checkpatch warning in imx-hdmi_pltfm.c

Changes in v17:
- remove platform device stuff, adviced by Russell King

Changes in v16:
- use the common binding for the clocks

Changes in v15: None
Changes in v14:
- add defer probing, adviced by Philipp Zabel

Changes in v13:
- split platform specific phy configuration

Changes in v12:
- squash patch 

Changes in v11:
- squash patch  

Changes in v10:
- split generic dw_hdmi.c improvements from patch#11 (add rk3288 support)

Changes in v9: None
Changes in v8: None
Changes in v7:
- remove unused variables from structure dw_hdmi
- remove a wrong modification
- add copyrights for dw_hdmi-imx.c

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/imx/Makefile |   2 +-
 drivers/gpu/drm/imx/imx-hdmi.c   | 258 +--
 drivers/gpu/drm/imx/imx-hdmi.h   |  15 ++
 drivers/gpu/drm/imx/imx-hdmi_pltfm.c | 203 +++
 4 files changed, 315 insertions(+), 163 deletions(-)
 create mode 100644 drivers/gpu/drm/imx/imx-hdmi_pltfm.c

diff --git a/drivers/gpu/drm/imx/Makefile b/drivers/gpu/drm/imx/Makefile
index 582c438..63cf56a 100644
--- a/drivers/gpu/drm/imx/Makefile
+++ b/drivers/gpu/drm/imx/Makefile
@@ -9,4 +9,4 @@ obj-$(CONFIG_DRM_IMX_LDB) += imx-ldb.o
 
 imx-ipuv3-crtc-objs  := ipuv3-crtc.o ipuv3-plane.o
 obj-$(CONFIG_DRM_IMX_IPUV3)+= imx-ipuv3-crtc.o
-obj-$(CONFIG_DRM_IMX_HDMI) += imx-hdmi.o
+obj-$(CONFIG_DRM_IMX_HDMI) += imx-hdmi.o imx-hdmi_pltfm.o
diff --git a/drivers/gpu/drm/imx/imx-hdmi.c b/drivers/gpu/drm/imx/imx-hdmi.c
index 7a54d20..d72f82c 100644
--- a/drivers/gpu/drm/imx/imx-hdmi.c
+++ b/drivers/gpu/drm/imx/imx-hdmi.c
@@ -12,25 +12,20 @@
  * Copyright (C) 2010, Guennadi Liakhovetski 
  */
 
-#include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 
 #include "imx-hdmi.h"
-#include "imx-drm.h"
 
 #define HDMI_EDID_LEN  512
 
@@ -54,11 +49,6 @@ enum hdmi_datamap {
YCbCr422_12B = 0x12,
 };
 
-enum imx_hdmi_devtype {
-   IMX6Q_HDMI,
-   IMX6DL_HDMI,
-};
-
 static const u16 csc_coeff_default[3][4] = {
{ 0x2000, 0x, 0x, 0x },
{ 0x, 0x2000, 0x, 0x },
@@ -113,7 +103,8 @@ struct hdmi_data_info {
 
 struct imx_hdmi {
struct drm_connector connector;
-   struct drm_encoder encoder;
+   struct drm_encoder *encoder;
+   struct drm_bridge *bridge;
 
enum imx_hdmi_devtype dev_type;
struct device *dev;
@@ -121,6 +112,7 @@ struct imx_hdmi {
struct clk *iahb_clk;
 
struct hdmi_data_info hdmi_data;
+   const struct imx_hdmi_plat_data *plat_data;
int vic;
 
u8 edid[HDMI_EDID_LEN];
@@ -137,13 +129,6 @@ struct imx_hdmi {
int ratio;
 };
 
-static void imx_hdmi_set_ipu_di_mux(struct imx_hdmi *hdmi, int ipu_di)
-{
-   regmap_update_bits(hdmi->regmap, IOMUXC_GPR3,
-  IMX6Q_GPR3_HDMI_MUX_CTL_MASK,
-  ipu_di << IMX6Q_GPR3_HDMI_MUX_CTL_SHIFT);
-}
-
 static inline void hdmi_writeb(struct imx_hdmi *hdmi, u8 val, int offset)
 {
writeb(val, hdmi->regs + offset);
@@ -1371,6 +1356,50 @@ static void imx_hdmi_poweroff(struct imx_hdmi *hdmi)
imx_hdmi_phy_disable(hdmi);
 }
 
+static void imx_hdmi_bridge_mode_set(struct drm_bridge *bridge,
+struct drm_display_mode *mode,
+struct drm_display_mode *adjusted_mode)
+{
+   struct imx_hdmi *hdmi = bridge->driver_private;
+
+   imx_hdmi_setup(hdmi, mode);
+
+   /* Store the display mode for plugin/DKMS poweron events */
+   memcpy(&hdmi->previous_mode, mode, sizeof(hdmi->previous_mode));
+}
+
+static bool imx_hdmi_bridge_mode_fixup(struct drm_bridge *bridge,
+  const struct drm_display_mode *mode,
+  struct drm_display_mode *adjusted_mode)
+{
+   return true;
+}
+
+static void imx_hdmi_bridge_disable(struct drm_bridge *bridge)
+{
+   

[PATCH v18 02/12] drm: imx: imx-hdmi: return defer if can't get ddc i2c adapter

2014-12-04 Thread Andy Yan
drm driver may probe before the i2c bus, so the driver should
defer probing until it is available

Signed-off-by: Andy Yan 
Reviewed-by: Daniel Kurtz 

---

Changes in v18: None
Changes in v17: None
Changes in v16: None
Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12:
- refactor of_node_put(ddc_node)

Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4:
- defer probe ddc i2c adapter

Changes in v3: None

 drivers/gpu/drm/imx/imx-hdmi.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-hdmi.c b/drivers/gpu/drm/imx/imx-hdmi.c
index 7fd90ae..7a54d20 100644
--- a/drivers/gpu/drm/imx/imx-hdmi.c
+++ b/drivers/gpu/drm/imx/imx-hdmi.c
@@ -1611,10 +1611,12 @@ static int imx_hdmi_bind(struct device *dev, struct 
device *master, void *data)
ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0);
if (ddc_node) {
hdmi->ddc = of_find_i2c_adapter_by_node(ddc_node);
-   if (!hdmi->ddc)
+   of_node_put(ddc_node);
+   if (!hdmi->ddc) {
dev_dbg(hdmi->dev, "failed to read ddc node\n");
+   return -EPROBE_DEFER;
+   }
 
-   of_node_put(ddc_node);
} else {
dev_dbg(hdmi->dev, "no ddc property found\n");
}
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v18 01/12] drm: imx: imx-hdmi: make checkpatch happy

2014-12-04 Thread Andy Yan
CHECK: Alignment should match open parenthesis
+   if ((hdmi->vic == 10) || (hdmi->vic == 11) ||
+   (hdmi->vic == 12) || (hdmi->vic == 13) ||

CHECK: braces {} should be used on all arms of this statement
+   if (hdmi->hdmi_data.video_mode.mdvi)
[...]
+   else {
[...]

Signed-off-by: Andy Yan 
Reviewed-by: Daniel Kurtz 

---

Changes in v18: None
Changes in v17: None
Changes in v16: None
Changes in v15: None
Changes in v14: None
Changes in v13:
- patch against drm-next

Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6:
- rearrange the patch order

Changes in v5: None
Changes in v4:
- fix checkpatch CHECK

Changes in v3: None

 drivers/gpu/drm/imx/imx-hdmi.c | 109 -
 1 file changed, 52 insertions(+), 57 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-hdmi.c b/drivers/gpu/drm/imx/imx-hdmi.c
index aaec6b2..7fd90ae 100644
--- a/drivers/gpu/drm/imx/imx-hdmi.c
+++ b/drivers/gpu/drm/imx/imx-hdmi.c
@@ -163,7 +163,7 @@ static void hdmi_modb(struct imx_hdmi *hdmi, u8 data, u8 
mask, unsigned reg)
 }
 
 static void hdmi_mask_writeb(struct imx_hdmi *hdmi, u8 data, unsigned int reg,
- u8 shift, u8 mask)
+u8 shift, u8 mask)
 {
hdmi_modb(hdmi, data << shift, mask, reg);
 }
@@ -327,7 +327,7 @@ static unsigned int hdmi_compute_cts(unsigned int freq, 
unsigned long pixel_clk,
 }
 
 static void hdmi_set_clk_regenerator(struct imx_hdmi *hdmi,
-   unsigned long pixel_clk)
+unsigned long pixel_clk)
 {
unsigned int clk_n, clk_cts;
 
@@ -338,7 +338,7 @@ static void hdmi_set_clk_regenerator(struct imx_hdmi *hdmi,
 
if (!clk_cts) {
dev_dbg(hdmi->dev, "%s: pixel clock not supported: %lu\n",
-__func__, pixel_clk);
+   __func__, pixel_clk);
return;
}
 
@@ -477,13 +477,11 @@ static void imx_hdmi_update_csc_coeffs(struct imx_hdmi 
*hdmi)
u16 coeff_b = (*csc_coeff)[1][i];
u16 coeff_c = (*csc_coeff)[2][i];
 
-   hdmi_writeb(hdmi, coeff_a & 0xff,
-   HDMI_CSC_COEF_A1_LSB + i * 2);
+   hdmi_writeb(hdmi, coeff_a & 0xff, HDMI_CSC_COEF_A1_LSB + i * 2);
hdmi_writeb(hdmi, coeff_a >> 8, HDMI_CSC_COEF_A1_MSB + i * 2);
hdmi_writeb(hdmi, coeff_b & 0xff, HDMI_CSC_COEF_B1_LSB + i * 2);
hdmi_writeb(hdmi, coeff_b >> 8, HDMI_CSC_COEF_B1_MSB + i * 2);
-   hdmi_writeb(hdmi, coeff_c & 0xff,
-   HDMI_CSC_COEF_C1_LSB + i * 2);
+   hdmi_writeb(hdmi, coeff_c & 0xff, HDMI_CSC_COEF_C1_LSB + i * 2);
hdmi_writeb(hdmi, coeff_c >> 8, HDMI_CSC_COEF_C1_MSB + i * 2);
}
 
@@ -535,21 +533,22 @@ static void hdmi_video_packetize(struct imx_hdmi *hdmi)
struct hdmi_data_info *hdmi_data = &hdmi->hdmi_data;
u8 val, vp_conf;
 
-   if (hdmi_data->enc_out_format == RGB
-   || hdmi_data->enc_out_format == YCBCR444) {
-   if (!hdmi_data->enc_color_depth)
+   if (hdmi_data->enc_out_format == RGB ||
+   hdmi_data->enc_out_format == YCBCR444) {
+   if (!hdmi_data->enc_color_depth) {
output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS;
-   else if (hdmi_data->enc_color_depth == 8) {
+   } else if (hdmi_data->enc_color_depth == 8) {
color_depth = 4;
output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS;
-   } else if (hdmi_data->enc_color_depth == 10)
+   } else if (hdmi_data->enc_color_depth == 10) {
color_depth = 5;
-   else if (hdmi_data->enc_color_depth == 12)
+   } else if (hdmi_data->enc_color_depth == 12) {
color_depth = 6;
-   else if (hdmi_data->enc_color_depth == 16)
+   } else if (hdmi_data->enc_color_depth == 16) {
color_depth = 7;
-   else
+   } else {
return;
+   }
} else if (hdmi_data->enc_out_format == YCBCR422_8BITS) {
if (!hdmi_data->enc_color_depth ||
hdmi_data->enc_color_depth == 8)
@@ -561,8 +560,9 @@ static void hdmi_video_packetize(struct imx_hdmi *hdmi)
else
return;
output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_YCC422;
-   } else
+   } else {
return;
+   }
 
/* set the packetizer registers */
val = ((color_depth << HDMI_VP_PR_CD_COLOR_DEPTH_OFFSET) &
@@ -

[PATCH v18 0/12] dw-hdmi: convert imx hdmi to bridge/dw_hdmi

2014-12-04 Thread Andy Yan

We found Freescale imx6 and Rockchip rk3288 and Ingenic JZ4780 (Xburst/MIPS)
use the interface compatible Designware HDMI IP, but they also have some
lightly differences, such as phy pll configuration, register width(imx hdmi
register is one byte, but rk3288 is 4 bytes width and can only be accessed
by word), 4K support(imx6 doesn't support 4k, but rk3288 does), and HDMI2.0
support.

To reuse the imx-hdmi driver, we make this patch set:
(1): fix some CodingStyle warning to make checkpatch happy
(2): convert imx-hdmi to drm_bridge
(3): split platform specific code
(4): move imx-hdmi to bridge/dw_hdmi
(5): extend dw_hdmi.c to support rk3288 hdmi
(6): add rockchip rk3288 platform specific code dw_hdmi-rockchip.c

Changes in v18:
- remove a multiple blank lines in imx-hdmi.c
- fix a checkpatch warning in imx-hdmi_pltfm.c
- add port bindings
- correct some spelling mistakes in dw_hdmi bindings doc
- correct some spelling mistakes in dw_hdmi-rockchip bindings doc

Changes in v17:
- remove platform device stuff, adviced by Russell King
- remove prompt message of dw_hdmi, adviced by Russel King
- parse resource and irq in platform driver

Changes in v16:
- use the common binding for the clocks
- describe ddc-i2c-bus as optional
- add common clocks bindings
- modify clocks bindings
- descrbie ddc-i2c-bus as optional

Changes in v15:
- add prefix dw_hdmi/DW_HDMI for public used dw_hdmi structs
  adviced by Philipp Zabel
- remove THIS_MODULE in platform driver
- remove unio of the multi-byte register access, adviced by Philipp Zabel
- remove THIS_MODULE in platform driver

Changes in v14:
- add defer probing, adviced by Philipp Zabel
- remove drm_connector_register, because imx-drm core has registered
connector

Changes in v13:
- patch against drm-next
- split platform specific phy configuration
- split phy configuration from patch#4

Changes in v12:
- refactor of_node_put(ddc_node)
- squash patch 
- add comment for the depend on patch

Changes in v11:
- squash patch  

Changes in v10:
- split generic dw_hdmi.c improvements from patch#11 (add rk3288 support)
- add more display mode support mpll configuration for rk3288

Changes in v9:
- move some phy configuration to platform driver

Changes in v8:
- correct some spelling mistake
- modify ddc-i2c-bus and interrupt description
- Add documentation for rockchip dw hdmi

Changes in v7:
- remove unused variables from structure dw_hdmi
- remove a wrong modification
- add copyrights for dw_hdmi-imx.c

Changes in v6:
- rearrange the patch order
- refactor register access without reg_shift

Changes in v5:
- refactor reg-io-width

Changes in v4:
- fix checkpatch CHECK
- defer probe ddc i2c adapter

Changes in v3:
- split multi-register access to one indepent patch

Andy Yan (12):
  drm: imx: imx-hdmi: make checkpatch happy
  drm: imx: imx-hdmi: return defer if can't get ddc i2c adapter
  drm: imx: imx-hdmi: convert imx-hdmi to drm_bridge mode
  drm: imx: imx-hdmi: split phy configuration to platform driver
  drm: imx: imx-hdmi: move imx-hdmi to bridge/dw_hdmi
  dt-bindings: add document for dw_hdmi
  drm: bridge/dw_hdmi: add support for multi-byte register width access
  drm: bridge/dw_hdmi: add mode_valid support
  drm: bridge/dw_hdmi: clear i2cmphy_stat0 reg in hdmi_phy_wait_i2c_done
  drm: bridge/dw_hdmi: add function dw_hdmi_phy_enable_spare
  dt-bindings: Add documentation for rockchip dw hdmi
  drm: bridge/dw_hdmi: add rockchip rk3288 support

 .../devicetree/bindings/drm/bridge/dw_hdmi.txt |  50 ++
 .../devicetree/bindings/video/dw_hdmi-rockchip.txt |  46 ++
 drivers/gpu/drm/bridge/Kconfig |   5 +
 drivers/gpu/drm/bridge/Makefile|   1 +
 .../gpu/drm/{imx/imx-hdmi.c => bridge/dw_hdmi.c}   | 717 ++---
 .../gpu/drm/{imx/imx-hdmi.h => bridge/dw_hdmi.h}   |   4 +-
 drivers/gpu/drm/imx/Kconfig|   1 +
 drivers/gpu/drm/imx/Makefile   |   2 +-
 drivers/gpu/drm/imx/dw_hdmi-imx.c  | 258 
 drivers/gpu/drm/rockchip/Kconfig   |  10 +
 drivers/gpu/drm/rockchip/Makefile  |   2 +
 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c| 341 ++
 include/drm/bridge/dw_hdmi.h   |  61 ++
 13 files changed,  insertions(+), 387 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt
 create mode 100644 Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt
 rename drivers/gpu/drm/{imx/imx-hdmi.c => bridge/dw_hdmi.c} (72%)
 rename drivers/gpu/drm/{imx/imx-hdmi.h => bridge/dw_hdmi.h} (99%)
 create mode 100644 drivers/gpu/drm/imx/dw_hdmi-imx.c
 create mode 100644 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
 create mode 100644 include/drm/bridge/dw_hdmi.h

-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v17 06/12] dt-bindings: add document for dw_hdmi

2014-12-04 Thread Andy Yan

Hi Philipp:
On 2014年12月04日 19:30, Philipp Zabel wrote:

Hi Andy,

Am Donnerstag, den 04.12.2014, 18:06 +0800 schrieb Andy Yan:

Signed-off-by: Andy Yan 

---

Changes in v17: None
Changes in v16:
- describe ddc-i2c-bus as optional
- add common clocks bindings

Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8:
- correct some spelling mistake
- modify ddc-i2c-bus and interrupt description

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

  .../devicetree/bindings/drm/bridge/dw_hdmi.txt | 45 ++
  1 file changed, 45 insertions(+)
  create mode 100644 Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt

diff --git a/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt 
b/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt
new file mode 100644
index 000..fb14730
--- /dev/null
+++ b/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt
@@ -0,0 +1,45 @@
+DesignWare HDMI bridge bindings
+
+Required properities:
+- compatible: platform specific such as:
+   * "snps,dw-hdmi-tx"
+   * "fsl,imx6q-hdmi"
+   * "fsl,imx6dl-hdmi"
+   * "rockchip,rk3288-dw-hdmi"
+- reg: Physical base address and length of the controller's registers.
+- interrupts: The HDMI interrupt number
+- clocks, clock-names : must have the phandles to the HDMI iahb and isrf 
clocks,
+  as described in Documentation/devicetree/bindings/clock/clock-bindings.txt,
+  the clock-names should be "iahb", "isfr"

This is missing the port bindings, I think it should mention the port
property here and refer to the soc specific binding document.

  - port@...: SoC specific port nodes with endpoint definitions as defined
in Documentation/devicetree/bindings/media/video-interfaces.txt,
please refer to the SoC specific binding document:
 * Documentation/devicetree/bindings/drm/imx/hdmi.txt
 * Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt

This also makes be wonder, shouldn't dw_hdmi-rockchip be under drm/?

   ok, I will add the port bindings
   because rockchip drm binds are under video, so I put the 
dw_hdmi-rockchip

   under video to keep consistency.



+Optional properties
+- reg-io-width: the width of the reg:1,4, default set to 1 if not present
+- ddc-i2c-bus: phandle of an I2C controller used for DDC EDID probing
+- clkocks, clock-names: phandle to the HDMI cec clock, name should be "cec"

s/clkocks/clocks/, and I'd uppercase the HDMI CEC clock for consistency.

thanks for point it, I will correct it in next version



+
+Example:
+   hdmi: hdmi@012 {
+   compatible = "fsl,imx6q-hdmi";

Could you change this example to:
compatible = "fsl,imx6q-hdmi", "snps,dw-hdmi-tx"


+   reg = <0x0012 0x9000>;
+   interrupts = <0 115 0x04>;
+   gpr = <&gpr>;
+   clocks = <&clks 123>, <&clks 124>;
+   clock-names = "iahb", "isfr";
+   ddc-i2c-bus = <&i2c2>;
+
+   port@0 {
+   reg = <0>;
+
+   hdmi_mux_0: endpoint {
+   remote-endpoint = <&ipu1_di0_hdmi>;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+
+   hdmi_mux_1: endpoint {
+   remote-endpoint = <&ipu1_di1_hdmi>;
+   };
+   };
+   };








--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v17 04/12] drm: imx: imx-hdmi: split phy configuration to platform driver

2014-12-04 Thread Andy Yan
hdmi phy configuration is platform specific, which can be adusted
according to the board to get the best SI

Signed-off-by: Andy Yan 

---

Changes in v17: None
Changes in v16: None
Changes in v15: None
Changes in v14: None
Changes in v13:
- split phy configuration from patch#4

Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/imx/imx-hdmi.c   | 85 +++-
 drivers/gpu/drm/imx/imx-hdmi.h   | 29 
 drivers/gpu/drm/imx/imx-hdmi_pltfm.c | 57 
 3 files changed, 101 insertions(+), 70 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-hdmi.c b/drivers/gpu/drm/imx/imx-hdmi.c
index 3ea9726..72358144 100644
--- a/drivers/gpu/drm/imx/imx-hdmi.c
+++ b/drivers/gpu/drm/imx/imx-hdmi.c
@@ -713,76 +713,14 @@ static void imx_hdmi_phy_sel_interface_control(struct 
imx_hdmi *hdmi, u8 enable)
 HDMI_PHY_CONF0_SELDIPIF_MASK);
 }
 
-enum {
-   RES_8,
-   RES_10,
-   RES_12,
-   RES_MAX,
-};
-
-struct mpll_config {
-   unsigned long mpixelclock;
-   struct {
-   u16 cpce;
-   u16 gmp;
-   } res[RES_MAX];
-};
-
-static const struct mpll_config mpll_config[] = {
-   {
-   4525, {
-   { 0x01e0, 0x },
-   { 0x21e1, 0x },
-   { 0x41e2, 0x }
-   },
-   }, {
-   9250, {
-   { 0x0140, 0x0005 },
-   { 0x2141, 0x0005 },
-   { 0x4142, 0x0005 },
-   },
-   }, {
-   14850, {
-   { 0x00a0, 0x000a },
-   { 0x20a1, 0x000a },
-   { 0x40a2, 0x000a },
-   },
-   }, {
-   ~0UL, {
-   { 0x00a0, 0x000a },
-   { 0x2001, 0x000f },
-   { 0x4002, 0x000f },
-   },
-   }
-};
-
-struct curr_ctrl {
-   unsigned long mpixelclock;
-   u16 curr[RES_MAX];
-};
-
-static const struct curr_ctrl curr_ctrl[] = {
-   /*  pixelclk bpp8bpp10   bpp12 */
-   {
-5400, { 0x091c, 0x091c, 0x06dc },
-   }, {
-5840, { 0x091c, 0x06dc, 0x06dc },
-   }, {
-7200, { 0x06dc, 0x06dc, 0x091c },
-   }, {
-7425, { 0x06dc, 0x0b5c, 0x091c },
-   }, {
-   11880, { 0x091c, 0x091c, 0x06dc },
-   }, {
-   21600, { 0x06dc, 0x0b5c, 0x091c },
-   }
-};
-
 static int hdmi_phy_configure(struct imx_hdmi *hdmi, unsigned char prep,
  unsigned char res, int cscon)
 {
unsigned res_idx, i;
u8 val, msec;
+   const struct mpll_config *mpll_config = hdmi->plat_data->mpll_cfg;
+   const struct curr_ctrl   *curr_ctrl = hdmi->plat_data->cur_ctr;
+   const struct sym_term *sym_term =  hdmi->plat_data->sym_term;
 
if (prep)
return -EINVAL;
@@ -828,7 +766,7 @@ static int hdmi_phy_configure(struct imx_hdmi *hdmi, 
unsigned char prep,
hdmi_phy_test_clear(hdmi, 0);
 
/* PLL/MPLL Cfg - always match on final entry */
-   for (i = 0; i < ARRAY_SIZE(mpll_config) - 1; i++)
+   for (i = 0; mpll_config[i].mpixelclock != (~0UL); i++)
if (hdmi->hdmi_data.video_mode.mpixelclock <=
mpll_config[i].mpixelclock)
break;
@@ -836,12 +774,12 @@ static int hdmi_phy_configure(struct imx_hdmi *hdmi, 
unsigned char prep,
hdmi_phy_i2c_write(hdmi, mpll_config[i].res[res_idx].cpce, 0x06);
hdmi_phy_i2c_write(hdmi, mpll_config[i].res[res_idx].gmp, 0x15);
 
-   for (i = 0; i < ARRAY_SIZE(curr_ctrl); i++)
+   for (i = 0; curr_ctrl[i].mpixelclock != (~0UL); i++)
if (hdmi->hdmi_data.video_mode.mpixelclock <=
curr_ctrl[i].mpixelclock)
break;
 
-   if (i >= ARRAY_SIZE(curr_ctrl)) {
+   if (curr_ctrl[i].mpixelclock == (~0UL)) {
dev_err(hdmi->dev, "Pixel clock %d - unsupported by HDMI\n",
hdmi->hdmi_data.video_mode.mpixelclock);
return -EINVAL;
@@ -852,10 +790,17 @@ static int hdmi_phy_configure(struct imx_hdmi *hdmi, 
unsigned char prep,
 
hdmi_phy_i2c_write(hdmi, 0x, 0x13);  /* PLLPHBYCTRL */
hdmi_phy_i2c_write(hdmi, 0x0006, 0x17);
+
+   for (i = 0; sym_term[i].mpixelclock != (~0UL); i++)
+   if (hdmi->hdmi_data.video_mode.mpixelclock <=
+   sym_term[i].mpixelclock)
+   break;
+
/* RESISTANCE TERM 133Ohm Cfg */
-   hdmi_phy_i2c_write(hdmi, 0x0005, 0x1

[PATCH v17 05/12] drm: imx: imx-hdmi: move imx-hdmi to bridge/dw_hdmi

2014-12-04 Thread Andy Yan
the original imx hdmi driver is under drm/imx/,
which depends on imx-drm, so move the imx hdmi
driver out to drm/bridge and rename it to dw_hdmi

Signed-off-by: Andy Yan 

---

Changes in v17:
- remove prompt message of dw_hdmi, adviced by Russel King

Changes in v16: None
Changes in v15:
- add prefix dw_hdmi/DW_HDMI for public used dw_hdmi structs
  adviced by Philipp Zabel
- remove THIS_MODULE in platform driver

Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/bridge/Kconfig |   5 +
 drivers/gpu/drm/bridge/Makefile|   1 +
 .../gpu/drm/{imx/imx-hdmi.c => bridge/dw_hdmi.c}   | 278 +++--
 .../gpu/drm/{imx/imx-hdmi.h => bridge/dw_hdmi.h}   |  43 
 drivers/gpu/drm/imx/Kconfig|   1 +
 drivers/gpu/drm/imx/Makefile   |   2 +-
 .../drm/imx/{imx-hdmi_pltfm.c => dw_hdmi-imx.c}| 127 +-
 include/drm/bridge/dw_hdmi.h   |  60 +
 8 files changed, 270 insertions(+), 247 deletions(-)
 rename drivers/gpu/drm/{imx/imx-hdmi.c => bridge/dw_hdmi.c} (84%)
 rename drivers/gpu/drm/{imx/imx-hdmi.h => bridge/dw_hdmi.h} (98%)
 rename drivers/gpu/drm/imx/{imx-hdmi_pltfm.c => dw_hdmi-imx.c} (55%)
 create mode 100644 include/drm/bridge/dw_hdmi.h

diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index 884923f..4d822f0 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -3,3 +3,8 @@ config DRM_PTN3460
depends on DRM
select DRM_KMS_HELPER
---help---
+
+config DRM_DW_HDMI
+   bool
+   depends on DRM
+   select DRM_KMS_HELPER
diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
index b4733e1..d8a8cfd 100644
--- a/drivers/gpu/drm/bridge/Makefile
+++ b/drivers/gpu/drm/bridge/Makefile
@@ -1,3 +1,4 @@
 ccflags-y := -Iinclude/drm
 
 obj-$(CONFIG_DRM_PTN3460) += ptn3460.o
+obj-$(CONFIG_DRM_DW_HDMI) += dw_hdmi.o
diff --git a/drivers/gpu/drm/imx/imx-hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
similarity index 84%
rename from drivers/gpu/drm/imx/imx-hdmi.c
rename to drivers/gpu/drm/bridge/dw_hdmi.c
index 72358144..b69057d 100644
--- a/drivers/gpu/drm/imx/imx-hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -6,12 +6,11 @@
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
  *
- * SH-Mobile High-Definition Multimedia Interface (HDMI) driver
- * for SLISHDMI13T and SLIPHDMIT IP cores
+ * Designware High-Definition Multimedia Interface (HDMI) driver
  *
  * Copyright (C) 2010, Guennadi Liakhovetski 
  */
-
+#include 
 #include 
 #include 
 #include 
@@ -24,8 +23,9 @@
 #include 
 #include 
 #include 
+#include 
 
-#include "imx-hdmi.h"
+#include "dw_hdmi.h"
 
 #define HDMI_EDID_LEN  512
 
@@ -101,18 +101,19 @@ struct hdmi_data_info {
struct hdmi_vmode video_mode;
 };
 
-struct imx_hdmi {
+struct dw_hdmi {
struct drm_connector connector;
struct drm_encoder *encoder;
struct drm_bridge *bridge;
 
-   enum imx_hdmi_devtype dev_type;
+   enum dw_hdmi_devtype dev_type;
struct device *dev;
struct clk *isfr_clk;
struct clk *iahb_clk;
 
struct hdmi_data_info hdmi_data;
-   const struct imx_hdmi_plat_data *plat_data;
+   const struct dw_hdmi_plat_data *plat_data;
+
int vic;
 
u8 edid[HDMI_EDID_LEN];
@@ -129,17 +130,17 @@ struct imx_hdmi {
int ratio;
 };
 
-static inline void hdmi_writeb(struct imx_hdmi *hdmi, u8 val, int offset)
+static inline void hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset)
 {
writeb(val, hdmi->regs + offset);
 }
 
-static inline u8 hdmi_readb(struct imx_hdmi *hdmi, int offset)
+static inline u8 hdmi_readb(struct dw_hdmi *hdmi, int offset)
 {
return readb(hdmi->regs + offset);
 }
 
-static void hdmi_modb(struct imx_hdmi *hdmi, u8 data, u8 mask, unsigned reg)
+static void hdmi_modb(struct dw_hdmi *hdmi, u8 data, u8 mask, unsigned reg)
 {
u8 val = hdmi_readb(hdmi, reg) & ~mask;
 
@@ -147,13 +148,13 @@ static void hdmi_modb(struct imx_hdmi *hdmi, u8 data, u8 
mask, unsigned reg)
hdmi_writeb(hdmi, val, reg);
 }
 
-static void hdmi_mask_writeb(struct imx_hdmi *hdmi, u8 data, unsigned int reg,
+static void hdmi_mask_writeb(struct dw_hdmi *hdmi, u8 data, unsigned int reg,
 u8 shift, u8 mask)
 {
hdmi_modb(hdmi, data << shift, mask, reg);
 }
 
-static void hdmi_set_clock_regenerator_n(struct imx_hdmi *hdmi,
+static void hdmi_set_clock_regenerator_n(struct dw_hdmi *hdmi,
 unsigned int value)
 {
hdmi_writeb(hdmi, value

[PATCH v17 12/12] drm: bridge/dw_hdmi: add rockchip rk3288 support

2014-12-04 Thread Andy Yan
Rockchip RK3288 hdmi is compatible with dw_hdmi

this patch is depend on patch by Mark Yao
see https://lkml.org/lkml/2014/12/2/161
drm: rockchip: Add basic drm driver

Signed-off-by: Andy Yan 

---

Changes in v17:
- parse resource and irq in platform driver

Changes in v16: None
Changes in v15:
- remove THIS_MODULE in platform driver

Changes in v14: None
Changes in v13: None
Changes in v12:
- add comment for the depend on patch

Changes in v11: None
Changes in v10:
- add more display mode support mpll configuration for rk3288

Changes in v9:
- move some phy configuration to platform driver

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/bridge/dw_hdmi.c|   3 +
 drivers/gpu/drm/rockchip/Kconfig|  10 +
 drivers/gpu/drm/rockchip/Makefile   |   2 +
 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 340 
 include/drm/bridge/dw_hdmi.h|   1 +
 5 files changed, 356 insertions(+)
 create mode 100644 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index 5ec337e..c01b423 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -852,6 +852,9 @@ static int hdmi_phy_configure(struct dw_hdmi *hdmi, 
unsigned char prep,
dw_hdmi_phy_gen2_txpwron(hdmi, 1);
dw_hdmi_phy_gen2_pddq(hdmi, 0);
 
+   if (hdmi->dev_type == RK3288_HDMI)
+   dw_hdmi_phy_enable_spare(hdmi, 1);
+
/*Wait for PHY PLL lock */
msec = 5;
do {
diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
index ca9f085..6ebebe8 100644
--- a/drivers/gpu/drm/rockchip/Kconfig
+++ b/drivers/gpu/drm/rockchip/Kconfig
@@ -15,3 +15,13 @@ config DRM_ROCKCHIP
  management to userspace. This driver does not provide
  2D or 3D acceleration; acceleration is performed by other
  IP found on the SoC.
+
+config ROCKCHIP_DW_HDMI
+bool "Rockchip specific extensions for Synopsys DW HDMI"
+depends on DRM_ROCKCHIP
+select DRM_DW_HDMI
+help
+ This selects support for Rockchip SoC specific extensions
+ for the Synopsys DesignWare HDMI driver. If you want to
+ enable HDMI on RK3288 based SoC, you should selet this
+ option.
diff --git a/drivers/gpu/drm/rockchip/Makefile 
b/drivers/gpu/drm/rockchip/Makefile
index 2cb0672..beed7df 100644
--- a/drivers/gpu/drm/rockchip/Makefile
+++ b/drivers/gpu/drm/rockchip/Makefile
@@ -5,4 +5,6 @@
 rockchipdrm-y := rockchip_drm_drv.o rockchip_drm_fb.o rockchip_drm_fbdev.o \
rockchip_drm_gem.o
 
+rockchipdrm-$(CONFIG_ROCKCHIP_DW_HDMI) += dw_hdmi-rockchip.o
+
 obj-$(CONFIG_DRM_ROCKCHIP) += rockchipdrm.o rockchip_drm_vop.o
diff --git a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c 
b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
new file mode 100644
index 000..28b258e
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
@@ -0,0 +1,340 @@
+/*
+ * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "rockchip_drm_drv.h"
+#include "rockchip_drm_vop.h"
+
+#define GRF_SOC_CON60x025c
+#define HDMI_SEL_VOP_LIT(1 << 4)
+
+struct rockchip_hdmi {
+   struct device *dev;
+   struct regmap *regmap;
+   struct drm_encoder encoder;
+};
+
+#define to_rockchip_hdmi(x)container_of(x, struct rockchip_hdmi, x)
+
+static const struct dw_hdmi_mpll_config rockchip_mpll_cfg[] = {
+   {
+   2700, {
+   { 0x00b3, 0x},
+   { 0x2153, 0x},
+   { 0x40f3, 0x}
+   },
+   }, {
+   3600, {
+   { 0x00b3, 0x},
+   { 0x2153, 0x},
+   { 0x40f3, 0x}
+   },
+   }, {
+   4000, {
+   { 0x00b3, 0x},
+   { 0x2153, 0x},
+   { 0x40f3, 0x}
+   },
+   }, {
+   5400, {
+   { 0x0072, 0x0001},
+   { 0x2142, 0x0001},
+   { 0x40a2, 0x0001},
+   },
+   }, {
+   6500, {
+   { 0x0072, 0x0001},
+   { 0x2142, 0x0001},
+   { 0x40a2, 0x0001},
+   },
+   }, {
+   6600, {
+

[PATCH v17 11/12] dt-bindings: Add documentation for rockchip dw hdmi

2014-12-04 Thread Andy Yan
Signed-off-by: Andy Yan 

---

Changes in v17: None
Changes in v16:
- modify clocks bindings
- descrbie ddc-i2c-bus as optional

Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8:
- Add documentation for rockchip dw hdmi

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 .../devicetree/bindings/video/dw_hdmi-rockchip.txt | 46 ++
 1 file changed, 46 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt

diff --git a/Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt 
b/Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt
new file mode 100644
index 000..264cb4f
--- /dev/null
+++ b/Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt
@@ -0,0 +1,46 @@
+Rockchip specific extensions to the Synopsys Designware HDMI
+
+
+Required properties:
+- compatible: "rockchip,rk3288-dw-hdmi";
+- reg: Physical base address and length of the controller's registers.
+- clocks: phandle to hdmi iahb and isrf clocks.
+- clock-names: should be "iahb" "isfr"
+- rockchip,grf: this soc should set GRF regs to mux vopl/vopb.
+- interrupts: HDMI interrupt number
+- ports: contain a port node with endpoint definitions as defined in
+  Documentation/devicetree/bindings/media/video-interfaces.txt. For
+  vopb,set the reg = <0> and set the reg = <1> for vopl.
+- reg-io-width: the width of the reg:1,4, the value should be 4 on
+  rk3288 platform
+
+Optional properties
+- ddc-i2c-bus: phandle of an I2C controller used for DDC EDID probing
+- clkocks, clock-names: phandle to the HDMI cec clock, name should be "cec"
+
+Example:
+hdmi: hdmi@ff98 {
+   compatible = "rockchip,rk3288-dw-hdmi";
+   reg = <0xff98 0x2>;
+   reg-io-width = <4>;
+   ddc-i2c-bus = <&i2c5>;
+   rockchip,grf = <&grf>;
+   interrupts = ;
+   clocks = <&cru  PCLK_HDMI_CTRL>, <&cru SCLK_HDMI_HDCP>;
+   clock-names = "iahb", "isfr";
+   status = "disabled";
+   ports {
+   hdmi_in: port {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   hdmi_in_vopb: endpoint@0 {
+   reg = <0>;
+   remote-endpoint = <&vopb_out_hdmi>;
+   };
+   hdmi_in_vopl: endpoint@1 {
+   reg = <1>;
+   remote-endpoint = <&vopl_out_hdmi>;
+   };
+   };
+   };
+};
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v17 10/12] drm: bridge/dw_hdmi: add function dw_hdmi_phy_enable_spare

2014-12-04 Thread Andy Yan
RK3288 HDMI will not work without the spare bit of
HDMI_PHY_CONF0 enable

Signed-off-by: Andy Yan 
---

Changes in v17: None
Changes in v16: None
Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/bridge/dw_hdmi.c | 7 +++
 drivers/gpu/drm/bridge/dw_hdmi.h | 3 ++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index 93bf5ca..5ec337e 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -713,6 +713,13 @@ static void dw_hdmi_phy_enable_tmds(struct dw_hdmi *hdmi, 
u8 enable)
 HDMI_PHY_CONF0_ENTMDS_MASK);
 }
 
+static void dw_hdmi_phy_enable_spare(struct dw_hdmi *hdmi, u8 enable)
+{
+   hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0,
+HDMI_PHY_CONF0_SPARECTRL_OFFSET,
+HDMI_PHY_CONF0_SPARECTRL_MASK);
+}
+
 static void dw_hdmi_phy_gen2_pddq(struct dw_hdmi *hdmi, u8 enable)
 {
hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0,
diff --git a/drivers/gpu/drm/bridge/dw_hdmi.h b/drivers/gpu/drm/bridge/dw_hdmi.h
index baa7849..175dbc8 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.h
+++ b/drivers/gpu/drm/bridge/dw_hdmi.h
@@ -837,7 +837,8 @@ enum {
HDMI_PHY_CONF0_PDZ_OFFSET = 7,
HDMI_PHY_CONF0_ENTMDS_MASK = 0x40,
HDMI_PHY_CONF0_ENTMDS_OFFSET = 6,
-   HDMI_PHY_CONF0_SPARECTRL = 0x20,
+   HDMI_PHY_CONF0_SPARECTRL_MASK = 0x20,
+   HDMI_PHY_CONF0_SPARECTRL_OFFSET = 5,
HDMI_PHY_CONF0_GEN2_PDDQ_MASK = 0x10,
HDMI_PHY_CONF0_GEN2_PDDQ_OFFSET = 4,
HDMI_PHY_CONF0_GEN2_TXPWRON_MASK = 0x8,
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v17 09/12] drm: bridge/dw_hdmi: clear i2cmphy_stat0 reg in hdmi_phy_wait_i2c_done

2014-12-04 Thread Andy Yan
HDMI_IH_I2CMPHY_STAT0 is a clear on write register, which indicates i2cm
operation status(i2c transfer done or error), every hdmi phy register
configuration must check this register to make sure the configuration
has complete. But the indication bit should be cleared after check, otherwise
the corresponding bit will hold on forever, this may give a wrong signal for
next check.

Signed-off-by: Andy Yan 
---

Changes in v17: None
Changes in v16: None
Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/bridge/dw_hdmi.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index 9119094..93bf5ca 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -666,11 +666,15 @@ static inline void hdmi_phy_test_dout(struct dw_hdmi 
*hdmi,
 
 static bool hdmi_phy_wait_i2c_done(struct dw_hdmi *hdmi, int msec)
 {
-   while ((hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3) == 0) {
+   u32 val;
+
+   while ((val = hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3) == 0) {
if (msec-- == 0)
return false;
udelay(1000);
}
+   hdmi_writeb(hdmi, val, HDMI_IH_I2CMPHY_STAT0);
+
return true;
 }
 
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v17 06/12] dt-bindings: add document for dw_hdmi

2014-12-04 Thread Andy Yan
Signed-off-by: Andy Yan 

---

Changes in v17: None
Changes in v16:
- describe ddc-i2c-bus as optional
- add common clocks bindings

Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8:
- correct some spelling mistake
- modify ddc-i2c-bus and interrupt description

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 .../devicetree/bindings/drm/bridge/dw_hdmi.txt | 45 ++
 1 file changed, 45 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt

diff --git a/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt 
b/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt
new file mode 100644
index 000..fb14730
--- /dev/null
+++ b/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt
@@ -0,0 +1,45 @@
+DesignWare HDMI bridge bindings
+
+Required properities:
+- compatible: platform specific such as:
+   * "snps,dw-hdmi-tx"
+   * "fsl,imx6q-hdmi"
+   * "fsl,imx6dl-hdmi"
+   * "rockchip,rk3288-dw-hdmi"
+- reg: Physical base address and length of the controller's registers.
+- interrupts: The HDMI interrupt number
+- clocks, clock-names : must have the phandles to the HDMI iahb and isrf 
clocks,
+  as described in Documentation/devicetree/bindings/clock/clock-bindings.txt,
+  the clock-names should be "iahb", "isfr"
+
+Optional properties
+- reg-io-width: the width of the reg:1,4, default set to 1 if not present
+- ddc-i2c-bus: phandle of an I2C controller used for DDC EDID probing
+- clkocks, clock-names: phandle to the HDMI cec clock, name should be "cec"
+
+Example:
+   hdmi: hdmi@012 {
+   compatible = "fsl,imx6q-hdmi";
+   reg = <0x0012 0x9000>;
+   interrupts = <0 115 0x04>;
+   gpr = <&gpr>;
+   clocks = <&clks 123>, <&clks 124>;
+   clock-names = "iahb", "isfr";
+   ddc-i2c-bus = <&i2c2>;
+
+   port@0 {
+   reg = <0>;
+
+   hdmi_mux_0: endpoint {
+   remote-endpoint = <&ipu1_di0_hdmi>;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+
+   hdmi_mux_1: endpoint {
+   remote-endpoint = <&ipu1_di1_hdmi>;
+   };
+   };
+   };
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v17 07/12] drm: bridge/dw_hdmi: add support for multi-byte register width access

2014-12-04 Thread Andy Yan
On rockchip rk3288, only word(32-bit) accesses are
permitted for hdmi registers.  Byte width accesses (writeb,
readb) generate an imprecise external abort.

Signed-off-by: Andy Yan 

---

Changes in v17: None
Changes in v16: None
Changes in v15:
- remove unio of the multi-byte register access, adviced by Philipp Zabel

Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6:
- refactor register access without reg_shift

Changes in v5:
- refactor reg-io-width

Changes in v4: None
Changes in v3:
- split multi-register access to one indepent patch

 drivers/gpu/drm/bridge/dw_hdmi.c | 44 ++--
 1 file changed, 42 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index b69057d..37966f4 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -128,18 +128,41 @@ struct dw_hdmi {
 
unsigned int sample_rate;
int ratio;
+
+   void (*write)(struct dw_hdmi *hdmi, u8 val, int offset);
+   u8 (*read)(struct dw_hdmi *hdmi, int offset);
 };
 
-static inline void hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset)
+static void dw_hdmi_writel(struct dw_hdmi *hdmi, u8 val, int offset)
+{
+   writel(val, hdmi->regs + (offset << 2));
+}
+
+static u8 dw_hdmi_readl(struct dw_hdmi *hdmi, int offset)
+{
+   return readl(hdmi->regs + (offset << 2));
+}
+
+static void dw_hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset)
 {
writeb(val, hdmi->regs + offset);
 }
 
-static inline u8 hdmi_readb(struct dw_hdmi *hdmi, int offset)
+static u8 dw_hdmi_readb(struct dw_hdmi *hdmi, int offset)
 {
return readb(hdmi->regs + offset);
 }
 
+static inline void hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset)
+{
+   hdmi->write(hdmi, val, offset);
+}
+
+static inline u8 hdmi_readb(struct dw_hdmi *hdmi, int offset)
+{
+   return hdmi->read(hdmi, offset);
+}
+
 static void hdmi_modb(struct dw_hdmi *hdmi, u8 data, u8 mask, unsigned reg)
 {
u8 val = hdmi_readb(hdmi, reg) & ~mask;
@@ -1511,6 +1534,7 @@ int dw_hdmi_bind(struct device *dev, struct device 
*master,
struct device_node *ddc_node;
struct dw_hdmi *hdmi;
int ret;
+   u32 val = 1;
 
hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL);
if (!hdmi)
@@ -1523,6 +1547,22 @@ int dw_hdmi_bind(struct device *dev, struct device 
*master,
hdmi->ratio = 100;
hdmi->encoder = encoder;
 
+   of_property_read_u32(np, "reg-io-width", &val);
+
+   switch (val) {
+   case 4:
+   hdmi->write = dw_hdmi_writel;
+   hdmi->read = dw_hdmi_readl;
+   break;
+   case 1:
+   hdmi->write = dw_hdmi_writeb;
+   hdmi->read = dw_hdmi_readb;
+   break;
+   default:
+   dev_err(dev, "reg-io-width must be 1 or 4\n");
+   return -EINVAL;
+   }
+
ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0);
if (ddc_node) {
hdmi->ddc = of_find_i2c_adapter_by_node(ddc_node);
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v17 08/12] drm: bridge/dw_hdmi: add mode_valid support

2014-12-04 Thread Andy Yan
some platform may not support all the display mode,
add mode_valid interface check it

Signed-off-by: Andy Yan 

---

Changes in v17: None
Changes in v16: None
Changes in v15: None
Changes in v14:
- remove drm_connector_register, because imx-drm core has registered
connector

Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/bridge/dw_hdmi.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index 37966f4..9119094 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -1405,6 +1405,20 @@ static int dw_hdmi_connector_get_modes(struct 
drm_connector *connector)
return 0;
 }
 
+static enum drm_mode_status
+dw_hdmi_connector_mode_valid(struct drm_connector *connector,
+struct drm_display_mode *mode)
+{
+   struct dw_hdmi *hdmi = container_of(connector,
+  struct dw_hdmi, connector);
+   enum drm_mode_status mode_status = MODE_OK;
+
+   if (hdmi->plat_data->mode_valid)
+   mode_status = hdmi->plat_data->mode_valid(connector, mode);
+
+   return mode_status;
+}
+
 static struct drm_encoder *dw_hdmi_connector_best_encoder(struct drm_connector
   *connector)
 {
@@ -1429,6 +1443,7 @@ static struct drm_connector_funcs dw_hdmi_connector_funcs 
= {
 
 static struct drm_connector_helper_funcs dw_hdmi_connector_helper_funcs = {
.get_modes = dw_hdmi_connector_get_modes,
+   .mode_valid = dw_hdmi_connector_mode_valid,
.best_encoder = dw_hdmi_connector_best_encoder,
 };
 
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v17 01/12] drm: imx: imx-hdmi: make checkpatch happy

2014-12-04 Thread Andy Yan
CHECK: Alignment should match open parenthesis
+   if ((hdmi->vic == 10) || (hdmi->vic == 11) ||
+   (hdmi->vic == 12) || (hdmi->vic == 13) ||

CHECK: braces {} should be used on all arms of this statement
+   if (hdmi->hdmi_data.video_mode.mdvi)
[...]
+   else {
[...]

Signed-off-by: Andy Yan 
Reviewed-by: Daniel Kurtz 

---

Changes in v17: None
Changes in v16: None
Changes in v15: None
Changes in v14: None
Changes in v13:
- patch against drm-next

Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6:
- rearrange the patch order

Changes in v5: None
Changes in v4:
- fix checkpatch CHECK

Changes in v3: None

 drivers/gpu/drm/imx/imx-hdmi.c | 109 -
 1 file changed, 52 insertions(+), 57 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-hdmi.c b/drivers/gpu/drm/imx/imx-hdmi.c
index aaec6b2..7fd90ae 100644
--- a/drivers/gpu/drm/imx/imx-hdmi.c
+++ b/drivers/gpu/drm/imx/imx-hdmi.c
@@ -163,7 +163,7 @@ static void hdmi_modb(struct imx_hdmi *hdmi, u8 data, u8 
mask, unsigned reg)
 }
 
 static void hdmi_mask_writeb(struct imx_hdmi *hdmi, u8 data, unsigned int reg,
- u8 shift, u8 mask)
+u8 shift, u8 mask)
 {
hdmi_modb(hdmi, data << shift, mask, reg);
 }
@@ -327,7 +327,7 @@ static unsigned int hdmi_compute_cts(unsigned int freq, 
unsigned long pixel_clk,
 }
 
 static void hdmi_set_clk_regenerator(struct imx_hdmi *hdmi,
-   unsigned long pixel_clk)
+unsigned long pixel_clk)
 {
unsigned int clk_n, clk_cts;
 
@@ -338,7 +338,7 @@ static void hdmi_set_clk_regenerator(struct imx_hdmi *hdmi,
 
if (!clk_cts) {
dev_dbg(hdmi->dev, "%s: pixel clock not supported: %lu\n",
-__func__, pixel_clk);
+   __func__, pixel_clk);
return;
}
 
@@ -477,13 +477,11 @@ static void imx_hdmi_update_csc_coeffs(struct imx_hdmi 
*hdmi)
u16 coeff_b = (*csc_coeff)[1][i];
u16 coeff_c = (*csc_coeff)[2][i];
 
-   hdmi_writeb(hdmi, coeff_a & 0xff,
-   HDMI_CSC_COEF_A1_LSB + i * 2);
+   hdmi_writeb(hdmi, coeff_a & 0xff, HDMI_CSC_COEF_A1_LSB + i * 2);
hdmi_writeb(hdmi, coeff_a >> 8, HDMI_CSC_COEF_A1_MSB + i * 2);
hdmi_writeb(hdmi, coeff_b & 0xff, HDMI_CSC_COEF_B1_LSB + i * 2);
hdmi_writeb(hdmi, coeff_b >> 8, HDMI_CSC_COEF_B1_MSB + i * 2);
-   hdmi_writeb(hdmi, coeff_c & 0xff,
-   HDMI_CSC_COEF_C1_LSB + i * 2);
+   hdmi_writeb(hdmi, coeff_c & 0xff, HDMI_CSC_COEF_C1_LSB + i * 2);
hdmi_writeb(hdmi, coeff_c >> 8, HDMI_CSC_COEF_C1_MSB + i * 2);
}
 
@@ -535,21 +533,22 @@ static void hdmi_video_packetize(struct imx_hdmi *hdmi)
struct hdmi_data_info *hdmi_data = &hdmi->hdmi_data;
u8 val, vp_conf;
 
-   if (hdmi_data->enc_out_format == RGB
-   || hdmi_data->enc_out_format == YCBCR444) {
-   if (!hdmi_data->enc_color_depth)
+   if (hdmi_data->enc_out_format == RGB ||
+   hdmi_data->enc_out_format == YCBCR444) {
+   if (!hdmi_data->enc_color_depth) {
output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS;
-   else if (hdmi_data->enc_color_depth == 8) {
+   } else if (hdmi_data->enc_color_depth == 8) {
color_depth = 4;
output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS;
-   } else if (hdmi_data->enc_color_depth == 10)
+   } else if (hdmi_data->enc_color_depth == 10) {
color_depth = 5;
-   else if (hdmi_data->enc_color_depth == 12)
+   } else if (hdmi_data->enc_color_depth == 12) {
color_depth = 6;
-   else if (hdmi_data->enc_color_depth == 16)
+   } else if (hdmi_data->enc_color_depth == 16) {
color_depth = 7;
-   else
+   } else {
return;
+   }
} else if (hdmi_data->enc_out_format == YCBCR422_8BITS) {
if (!hdmi_data->enc_color_depth ||
hdmi_data->enc_color_depth == 8)
@@ -561,8 +560,9 @@ static void hdmi_video_packetize(struct imx_hdmi *hdmi)
else
return;
output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_YCC422;
-   } else
+   } else {
return;
+   }
 
/* set the packetizer registers */
val = ((color_depth << HDMI_VP_PR_CD_COLOR_DEPTH_OFFSET) &
@@ -623,34 +623,34 @@ static void hdmi_video_packetize(struct 

[PATCH v17 03/12] drm: imx: imx-hdmi: convert imx-hdmi to drm_bridge mode

2014-12-04 Thread Andy Yan
IMX6 and Rockchip RK3288 and JZ4780 (Ingenic Xburst/MIPS)
use the interface compatible Designware HDMI IP, but they
also have some lightly differences, such as phy pll configuration,
register width, 4K support, clk useage, and the crtc mux configuration
is also platform specific.

To reuse the imx hdmi driver, convert it to drm_bridge

handle encoder in imx-hdmi_pltfm.c, as most of the encoder
operation are platform specific such as crtc select and
panel format set

This patch depends on Russell King's patch:
 drm: imx: convert imx-drm to use the generic DRM OF helper
 
http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2014-July/053484.html

Signed-off-by: Andy Yan 
Signed-off-by: Yakir Yang 

---

Changes in v17:
- remove platform device stuff, adviced by Russell King

Changes in v16:
- use the common binding for the clocks

Changes in v15: None
Changes in v14:
- add defer probing, adviced by Philipp Zabel

Changes in v13:
- split platform specific phy configuration

Changes in v12:
- squash patch 

Changes in v11:
- squash patch  

Changes in v10:
- split generic dw_hdmi.c improvements from patch#11 (add rk3288 support)

Changes in v9: None
Changes in v8: None
Changes in v7:
- remove unused variables from structure dw_hdmi
- remove a wrong modification
- add copyrights for dw_hdmi-imx.c

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/imx/Makefile |   2 +-
 drivers/gpu/drm/imx/imx-hdmi.c   | 257 +--
 drivers/gpu/drm/imx/imx-hdmi.h   |  15 ++
 drivers/gpu/drm/imx/imx-hdmi_pltfm.c | 204 +++
 4 files changed, 316 insertions(+), 162 deletions(-)
 create mode 100644 drivers/gpu/drm/imx/imx-hdmi_pltfm.c

diff --git a/drivers/gpu/drm/imx/Makefile b/drivers/gpu/drm/imx/Makefile
index 582c438..63cf56a 100644
--- a/drivers/gpu/drm/imx/Makefile
+++ b/drivers/gpu/drm/imx/Makefile
@@ -9,4 +9,4 @@ obj-$(CONFIG_DRM_IMX_LDB) += imx-ldb.o
 
 imx-ipuv3-crtc-objs  := ipuv3-crtc.o ipuv3-plane.o
 obj-$(CONFIG_DRM_IMX_IPUV3)+= imx-ipuv3-crtc.o
-obj-$(CONFIG_DRM_IMX_HDMI) += imx-hdmi.o
+obj-$(CONFIG_DRM_IMX_HDMI) += imx-hdmi.o imx-hdmi_pltfm.o
diff --git a/drivers/gpu/drm/imx/imx-hdmi.c b/drivers/gpu/drm/imx/imx-hdmi.c
index 7a54d20..3ea9726 100644
--- a/drivers/gpu/drm/imx/imx-hdmi.c
+++ b/drivers/gpu/drm/imx/imx-hdmi.c
@@ -12,25 +12,20 @@
  * Copyright (C) 2010, Guennadi Liakhovetski 
  */
 
-#include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 
 #include "imx-hdmi.h"
-#include "imx-drm.h"
 
 #define HDMI_EDID_LEN  512
 
@@ -54,11 +49,6 @@ enum hdmi_datamap {
YCbCr422_12B = 0x12,
 };
 
-enum imx_hdmi_devtype {
-   IMX6Q_HDMI,
-   IMX6DL_HDMI,
-};
-
 static const u16 csc_coeff_default[3][4] = {
{ 0x2000, 0x, 0x, 0x },
{ 0x, 0x2000, 0x, 0x },
@@ -113,7 +103,8 @@ struct hdmi_data_info {
 
 struct imx_hdmi {
struct drm_connector connector;
-   struct drm_encoder encoder;
+   struct drm_encoder *encoder;
+   struct drm_bridge *bridge;
 
enum imx_hdmi_devtype dev_type;
struct device *dev;
@@ -121,6 +112,7 @@ struct imx_hdmi {
struct clk *iahb_clk;
 
struct hdmi_data_info hdmi_data;
+   const struct imx_hdmi_plat_data *plat_data;
int vic;
 
u8 edid[HDMI_EDID_LEN];
@@ -137,13 +129,6 @@ struct imx_hdmi {
int ratio;
 };
 
-static void imx_hdmi_set_ipu_di_mux(struct imx_hdmi *hdmi, int ipu_di)
-{
-   regmap_update_bits(hdmi->regmap, IOMUXC_GPR3,
-  IMX6Q_GPR3_HDMI_MUX_CTL_MASK,
-  ipu_di << IMX6Q_GPR3_HDMI_MUX_CTL_SHIFT);
-}
-
 static inline void hdmi_writeb(struct imx_hdmi *hdmi, u8 val, int offset)
 {
writeb(val, hdmi->regs + offset);
@@ -1371,6 +1356,50 @@ static void imx_hdmi_poweroff(struct imx_hdmi *hdmi)
imx_hdmi_phy_disable(hdmi);
 }
 
+static void imx_hdmi_bridge_mode_set(struct drm_bridge *bridge,
+struct drm_display_mode *mode,
+struct drm_display_mode *adjusted_mode)
+{
+   struct imx_hdmi *hdmi = bridge->driver_private;
+
+   imx_hdmi_setup(hdmi, mode);
+
+   /* Store the display mode for plugin/DKMS poweron events */
+   memcpy(&hdmi->previous_mode, mode, sizeof(hdmi->previous_mode));
+}
+
+static bool imx_hdmi_bridge_mode_fixup(struct drm_bridge *bridge,
+  const struct drm_display_mode *mode,
+  struct drm_display_mode *adjusted_mode)
+{
+   return true;
+}
+
+static void imx_hdmi_bridge_disable(struct drm_bridge *bridge)
+{
+   struct imx_hdmi *hdmi = bridge->driver_private;
+
+   imx_hdmi_poweroff(hdmi);
+}
+
+static 

[PATCH v17 02/12] drm: imx: imx-hdmi: return defer if can't get ddc i2c adapter

2014-12-04 Thread Andy Yan
drm driver may probe before the i2c bus, so the driver should
defer probing until it is available

Signed-off-by: Andy Yan 
Reviewed-by: Daniel Kurtz 

---

Changes in v17: None
Changes in v16: None
Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12:
- refactor of_node_put(ddc_node)

Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4:
- defer probe ddc i2c adapter

Changes in v3: None

 drivers/gpu/drm/imx/imx-hdmi.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-hdmi.c b/drivers/gpu/drm/imx/imx-hdmi.c
index 7fd90ae..7a54d20 100644
--- a/drivers/gpu/drm/imx/imx-hdmi.c
+++ b/drivers/gpu/drm/imx/imx-hdmi.c
@@ -1611,10 +1611,12 @@ static int imx_hdmi_bind(struct device *dev, struct 
device *master, void *data)
ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0);
if (ddc_node) {
hdmi->ddc = of_find_i2c_adapter_by_node(ddc_node);
-   if (!hdmi->ddc)
+   of_node_put(ddc_node);
+   if (!hdmi->ddc) {
dev_dbg(hdmi->dev, "failed to read ddc node\n");
+   return -EPROBE_DEFER;
+   }
 
-   of_node_put(ddc_node);
} else {
dev_dbg(hdmi->dev, "no ddc property found\n");
}
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v17 0/12] dw-hdmi: convert imx hdmi to bridge/dw_hdmi

2014-12-04 Thread Andy Yan

We found Freescale imx6 and Rockchip rk3288 and Ingenic JZ4780 (Xburst/MIPS)
use the interface compatible Designware HDMI IP, but they also have some
lightly differences, such as phy pll configuration, register width(imx hdmi
register is one byte, but rk3288 is 4 bytes width and can only be accessed
by word), 4K support(imx6 doesn't support 4k, but rk3288 does), and HDMI2.0
support.

To reuse the imx-hdmi driver, we make this patch set:
(1): fix some CodingStyle warning to make checkpatch happy
(2): convert imx-hdmi to drm_bridge
(3): split platform specific code
(4): move imx-hdmi to bridge/dw_hdmi
(5): extend dw_hdmi.c to support rk3288 hdmi
(6): add rockchip rk3288 platform specific code dw_hdmi-rockchip.c

Changes in v17:
- remove platform device stuff from dw_hdmi core, adviced by Russell King
- remove prompt message of dw_hdmi kconfig, adviced by Russel King
- parse resource and irq in platform driver

Changes in v16:
- use the common binding for the clocks
- describe ddc-i2c-bus as optional
- add common clocks bindings
- modify clocks bindings

Changes in v15:
- add prefix dw_hdmi/DW_HDMI for public used dw_hdmi structs
  adviced by Philipp Zabel
- remove THIS_MODULE in platform driver
- remove unio of the multi-byte register access, adviced by Philipp Zabel
- remove THIS_MODULE in platform driver

Changes in v14:
- add defer probing, adviced by Philipp Zabel
- remove drm_connector_register, because imx-drm core has registered
connector

Changes in v13:
- patch against drm-next
- split platform specific phy configuration
- split phy configuration from patch#4

Changes in v12:
- refactor of_node_put(ddc_node)
- squash patch 
- add comment for the depend on patch

Changes in v11:
- squash patch  

Changes in v10:
- split generic dw_hdmi.c improvements from patch#11 (add rk3288 support)
- add more display mode support mpll configuration for rk3288

Changes in v9:
- move some phy configuration to platform driver

Changes in v8:
- correct some spelling mistake
- modify ddc-i2c-bus and interrupt description
- Add documentation for rockchip dw hdmi

Changes in v7:
- remove unused variables from structure dw_hdmi
- remove a wrong modification
- add copyrights for dw_hdmi-imx.c

Changes in v6:
- rearrange the patch order
- refactor register access without reg_shift

Changes in v5:
- refactor reg-io-width

Changes in v4:
- fix checkpatch CHECK
- defer probe ddc i2c adapter

Changes in v3:
- split multi-register access to one indepent patch

Andy Yan (12):
  drm: imx: imx-hdmi: make checkpatch happy
  drm: imx: imx-hdmi: return defer if can't get ddc i2c adapter
  drm: imx: imx-hdmi: convert imx-hdmi to drm_bridge mode
  drm: imx: imx-hdmi: split phy configuration to platform driver
  drm: imx: imx-hdmi: move imx-hdmi to bridge/dw_hdmi
  dt-bindings: add document for dw_hdmi
  drm: bridge/dw_hdmi: add support for multi-byte register width access
  drm: bridge/dw_hdmi: add mode_valid support
  drm: bridge/dw_hdmi: clear i2cmphy_stat0 reg in hdmi_phy_wait_i2c_done
  drm: bridge/dw_hdmi: add function dw_hdmi_phy_enable_spare
  dt-bindings: Add documentation for rockchip dw hdmi
  drm: bridge/dw_hdmi: add rockchip rk3288 support

 .../devicetree/bindings/drm/bridge/dw_hdmi.txt |  45 ++
 .../devicetree/bindings/video/dw_hdmi-rockchip.txt |  46 ++
 drivers/gpu/drm/bridge/Kconfig |   5 +
 drivers/gpu/drm/bridge/Makefile|   1 +
 .../gpu/drm/{imx/imx-hdmi.c => bridge/dw_hdmi.c}   | 716 ++---
 .../gpu/drm/{imx/imx-hdmi.h => bridge/dw_hdmi.h}   |   4 +-
 drivers/gpu/drm/imx/Kconfig|   1 +
 drivers/gpu/drm/imx/Makefile   |   2 +-
 drivers/gpu/drm/imx/dw_hdmi-imx.c  | 258 
 drivers/gpu/drm/rockchip/Kconfig   |  10 +
 drivers/gpu/drm/rockchip/Makefile  |   2 +
 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c| 340 ++
 include/drm/bridge/dw_hdmi.h   |  61 ++
 13 files changed, 1105 insertions(+), 386 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt
 create mode 100644 Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt
 rename drivers/gpu/drm/{imx/imx-hdmi.c => bridge/dw_hdmi.c} (72%)
 rename drivers/gpu/drm/{imx/imx-hdmi.h => bridge/dw_hdmi.h} (99%)
 create mode 100644 drivers/gpu/drm/imx/dw_hdmi-imx.c
 create mode 100644 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
 create mode 100644 include/drm/bridge/dw_hdmi.h

-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v16 03/12] drm: imx: imx-hdmi: convert imx-hdmi to drm_bridge mode

2014-12-03 Thread Andy Yan

Hi Russel:
On 2014年12月04日 07:40, Russell King - ARM Linux wrote:

On Thu, Dec 04, 2014 at 12:56:24AM +0800, Andy Yan wrote:

Hi Russell:
On 2014年12月04日 00:33, Russell King - ARM Linux wrote:

On Thu, Dec 04, 2014 at 12:30:23AM +0800, Andy Yan wrote:

On 2014年12月04日 00:11, Russell King - ARM Linux wrote:

I meant that imx_hdmi_bind should be passed these, so that it needs to
know nothing about the struct device beyond the generic device structure.
In other words, the dw-hdmi core should not assume that the struct device
is part of a platform device.


if so, how about the device tree properties  ddc-i2c-bus, reg-io-width,
iahb, isfr,
   they are all found by device?

If the device has a device tree node associated with it, it will have a
non-NULL dev->of_node - which is part of the generic device structure.


   so , I just need get the resource and irq number in the
dw_hdmi-imx/rockchip ,than
   pass them to imx_hdmi_bind, as the properties ddc-i2c-bus, reg-io-width,
iahb,isfr, they
   are still can be handled in imx_hdmi_bind ?

Basically, what I'm suggesting is just this change to imx_hdmi_bind():

  int imx_hdmi_bind(struct device *dev, struct device *master,
  void *data, struct drm_encoder *encoder,
+ const struct resource *iores, int irq,
  const struct imx_hdmi_plat_data *plat_data)
  {
-   struct platform_device *pdev = to_platform_device(dev);
...
}

-   irq = platform_get_irq(pdev, 0);
if (irq < 0)
return irq;
...
return ret;

-   iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
hdmi->regs = devm_ioremap_resource(dev, iores);
if (IS_ERR(hdmi->regs))

and supplying those as arguments from the caller.


  got it, thanks, and also many thanks for Philipp


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v16 03/12] drm: imx: imx-hdmi: convert imx-hdmi to drm_bridge mode

2014-12-03 Thread Andy Yan

Hi Russell:
On 2014年12月04日 00:33, Russell King - ARM Linux wrote:

On Thu, Dec 04, 2014 at 12:30:23AM +0800, Andy Yan wrote:

On 2014年12月04日 00:11, Russell King - ARM Linux wrote:

I meant that imx_hdmi_bind should be passed these, so that it needs to
know nothing about the struct device beyond the generic device structure.
In other words, the dw-hdmi core should not assume that the struct device
is part of a platform device.


if so, how about the device tree properties  ddc-i2c-bus, reg-io-width,
iahb, isfr,
   they are all found by device?

If the device has a device tree node associated with it, it will have a
non-NULL dev->of_node - which is part of the generic device structure.

  so , I just need get the resource and irq number in the 
dw_hdmi-imx/rockchip ,than
  pass them to imx_hdmi_bind, as the properties ddc-i2c-bus, 
reg-io-width, iahb,isfr, they

  are still can be handled in imx_hdmi_bind ?

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v16 03/12] drm: imx: imx-hdmi: convert imx-hdmi to drm_bridge mode

2014-12-03 Thread Andy Yan


On 2014年12月04日 00:11, Russell King - ARM Linux wrote:

On Thu, Dec 04, 2014 at 12:04:37AM +0800, Andy Yan wrote:

Hi Russell:

On 2014年12月03日 23:38, Russell King - ARM Linux wrote:

On Wed, Dec 03, 2014 at 11:29:26PM +0800, Andy Yan wrote:

+int imx_hdmi_bind(struct device *dev, struct device *master,
+ void *data, struct drm_encoder *encoder,
+ const struct imx_hdmi_plat_data *plat_data)
  {
struct platform_device *pdev = to_platform_device(dev);
-   const struct of_device_id *of_id =
-   of_match_device(imx_hdmi_dt_ids, dev);
struct drm_device *drm = data;
struct device_node *np = dev->of_node;
struct device_node *ddc_node;
@@ -1594,19 +1566,16 @@ static int imx_hdmi_bind(struct device *dev, struct 
device *master, void *data)
struct resource *iores;
int ret, irq;
-   hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL);
+   hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL);
if (!hdmi)
return -ENOMEM;
-   hdmi->dev = dev;
+   hdmi->plat_data = plat_data;
+   hdmi->dev = &pdev->dev;
+   hdmi->dev_type = plat_data->dev_type;
hdmi->sample_rate = 48000;
hdmi->ratio = 100;
-
-   if (of_id) {
-   const struct platform_device_id *device_id = of_id->data;
-
-   hdmi->dev_type = device_id->driver_data;
-   }
+   hdmi->encoder = encoder;

I'd suggest changing imx_hdmi_bind() to take the struct resource and irq
number, and avoiding the platform device stuff altogether in here.


Actually this is what the current code do: the resource and irq number
are all handled in imx_hdmi_bind

I meant that imx_hdmi_bind should be passed these, so that it needs to
know nothing about the struct device beyond the generic device structure.
In other words, the dw-hdmi core should not assume that the struct device
is part of a platform device.

   if so, how about the device tree properties  ddc-i2c-bus, 
reg-io-width, iahb, isfr,

  they are all found by device?

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v16 03/12] drm: imx: imx-hdmi: convert imx-hdmi to drm_bridge mode

2014-12-03 Thread Andy Yan

Hi Russell:

On 2014年12月03日 23:38, Russell King - ARM Linux wrote:

On Wed, Dec 03, 2014 at 11:29:26PM +0800, Andy Yan wrote:

+int imx_hdmi_bind(struct device *dev, struct device *master,
+ void *data, struct drm_encoder *encoder,
+ const struct imx_hdmi_plat_data *plat_data)
  {
struct platform_device *pdev = to_platform_device(dev);
-   const struct of_device_id *of_id =
-   of_match_device(imx_hdmi_dt_ids, dev);
struct drm_device *drm = data;
struct device_node *np = dev->of_node;
struct device_node *ddc_node;
@@ -1594,19 +1566,16 @@ static int imx_hdmi_bind(struct device *dev, struct 
device *master, void *data)
struct resource *iores;
int ret, irq;
  
-	hdmi = devm_kzalloc(dev, sizeof(*hdmi), GFP_KERNEL);

+   hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL);
if (!hdmi)
return -ENOMEM;
  
-	hdmi->dev = dev;

+   hdmi->plat_data = plat_data;
+   hdmi->dev = &pdev->dev;
+   hdmi->dev_type = plat_data->dev_type;
hdmi->sample_rate = 48000;
hdmi->ratio = 100;
-
-   if (of_id) {
-   const struct platform_device_id *device_id = of_id->data;
-
-   hdmi->dev_type = device_id->driver_data;
-   }
+   hdmi->encoder = encoder;

I'd suggest changing imx_hdmi_bind() to take the struct resource and irq
number, and avoiding the platform device stuff altogether in here.


   Actually this is what the current code do: the resource and irq number
are all handled in imx_hdmi_bind


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v16 05/12] drm: imx: imx-hdmi: move imx-hdmi to bridge/dw_hdmi

2014-12-03 Thread Andy Yan

Hi Russell:

On 2014年12月03日 23:45, Russell King - ARM Linux wrote:

On Wed, Dec 03, 2014 at 11:32:12PM +0800, Andy Yan wrote:

diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index 884923f..26162ef 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -3,3 +3,8 @@ config DRM_PTN3460
depends on DRM
select DRM_KMS_HELPER
---help---
+
+config DRM_DW_HDMI
+   bool "Synopsys DesignWare High-Definition Multimedia Interface"
+   depends on DRM
+   select DRM_KMS_HELPER

...

diff --git a/drivers/gpu/drm/imx/Kconfig b/drivers/gpu/drm/imx/Kconfig
index 82fb758..7070077 100644
--- a/drivers/gpu/drm/imx/Kconfig
+++ b/drivers/gpu/drm/imx/Kconfig
@@ -48,6 +48,7 @@ config DRM_IMX_IPUV3
  
  config DRM_IMX_HDMI

tristate "Freescale i.MX DRM HDMI"
+   select DRM_DW_HDMI
depends on DRM_IMX
help
  Choose this if you want to use HDMI on i.MX6.

I'd recommend that if you want to select DRM_DW_HDMI, then don't give
DRM_DW_HDMI a prompt message.  I assume you're going to do something
similar with your Rockchip driver too - in which case DRM_DW_HDMI is
really about building a library module.

  Do you mean I just neet to do like bellow?

+
+config DRM_DW_HDMI
+   bool
+   depends on DRM
+   select DRM_KMS_HELPER



--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v16 12/12] drm: bridge/dw_hdmi: add rockchip rk3288 support

2014-12-03 Thread Andy Yan
Rockchip RK3288 hdmi is compatible with dw_hdmi

this patch is depend on patch by Mark Yao
see https://lkml.org/lkml/2014/12/2/161
drm: rockchip: Add basic drm driver

Signed-off-by: Andy Yan 

---

Changes in v16: None
Changes in v15:
- remove THIS_MODULE in platform driver

Changes in v14: None
Changes in v13: None
Changes in v12:
- add comment for the depend on patch

Changes in v11: None
Changes in v10:
- add more display mode support mpll configuration for rk3288

Changes in v9:
- move some phy configuration to platform driver

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/bridge/dw_hdmi.c|   3 +
 drivers/gpu/drm/rockchip/Kconfig|  10 +
 drivers/gpu/drm/rockchip/Makefile   |   2 +
 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 321 
 include/drm/bridge/dw_hdmi.h|   1 +
 5 files changed, 337 insertions(+)
 create mode 100644 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index efc3b6f..1d5a6b3 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -852,6 +852,9 @@ static int hdmi_phy_configure(struct dw_hdmi *hdmi, 
unsigned char prep,
dw_hdmi_phy_gen2_txpwron(hdmi, 1);
dw_hdmi_phy_gen2_pddq(hdmi, 0);
 
+   if (hdmi->dev_type == RK3288_HDMI)
+   dw_hdmi_phy_enable_spare(hdmi, 1);
+
/*Wait for PHY PLL lock */
msec = 5;
do {
diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
index ca9f085..6ebebe8 100644
--- a/drivers/gpu/drm/rockchip/Kconfig
+++ b/drivers/gpu/drm/rockchip/Kconfig
@@ -15,3 +15,13 @@ config DRM_ROCKCHIP
  management to userspace. This driver does not provide
  2D or 3D acceleration; acceleration is performed by other
  IP found on the SoC.
+
+config ROCKCHIP_DW_HDMI
+bool "Rockchip specific extensions for Synopsys DW HDMI"
+depends on DRM_ROCKCHIP
+select DRM_DW_HDMI
+help
+ This selects support for Rockchip SoC specific extensions
+ for the Synopsys DesignWare HDMI driver. If you want to
+ enable HDMI on RK3288 based SoC, you should selet this
+ option.
diff --git a/drivers/gpu/drm/rockchip/Makefile 
b/drivers/gpu/drm/rockchip/Makefile
index 2cb0672..beed7df 100644
--- a/drivers/gpu/drm/rockchip/Makefile
+++ b/drivers/gpu/drm/rockchip/Makefile
@@ -5,4 +5,6 @@
 rockchipdrm-y := rockchip_drm_drv.o rockchip_drm_fb.o rockchip_drm_fbdev.o \
rockchip_drm_gem.o
 
+rockchipdrm-$(CONFIG_ROCKCHIP_DW_HDMI) += dw_hdmi-rockchip.o
+
 obj-$(CONFIG_DRM_ROCKCHIP) += rockchipdrm.o rockchip_drm_vop.o
diff --git a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c 
b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
new file mode 100644
index 000..3369a7e
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
@@ -0,0 +1,321 @@
+/*
+ * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "rockchip_drm_drv.h"
+#include "rockchip_drm_vop.h"
+
+#define GRF_SOC_CON60x025c
+#define HDMI_SEL_VOP_LIT(1 << 4)
+
+struct rockchip_hdmi {
+   struct device *dev;
+   struct regmap *regmap;
+   struct drm_encoder encoder;
+};
+
+#define to_rockchip_hdmi(x)container_of(x, struct rockchip_hdmi, x)
+
+static const struct dw_hdmi_mpll_config rockchip_mpll_cfg[] = {
+   {
+   2700, {
+   { 0x00b3, 0x},
+   { 0x2153, 0x},
+   { 0x40f3, 0x}
+   },
+   }, {
+   3600, {
+   { 0x00b3, 0x},
+   { 0x2153, 0x},
+   { 0x40f3, 0x}
+   },
+   }, {
+   4000, {
+   { 0x00b3, 0x},
+   { 0x2153, 0x},
+   { 0x40f3, 0x}
+   },
+   }, {
+   5400, {
+   { 0x0072, 0x0001},
+   { 0x2142, 0x0001},
+   { 0x40a2, 0x0001},
+   },
+   }, {
+   6500, {
+   { 0x0072, 0x0001},
+   { 0x2142, 0x0001},
+   { 0x40a2, 0x0001},
+   },
+   }, {
+   6600, {
+   { 0x013e, 0x0003},
+

[PATCH v16 11/12] dt-bindings: Add documentation for rockchip dw hdmi

2014-12-03 Thread Andy Yan
Signed-off-by: Andy Yan 

---

Changes in v16:
- modify clocks bindings
- descrbie ddc-i2c-bus as optional

Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8:
- Add documentation for rockchip dw hdmi

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 .../devicetree/bindings/video/dw_hdmi-rockchip.txt | 46 ++
 1 file changed, 46 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt

diff --git a/Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt 
b/Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt
new file mode 100644
index 000..264cb4f
--- /dev/null
+++ b/Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt
@@ -0,0 +1,46 @@
+Rockchip specific extensions to the Synopsys Designware HDMI
+
+
+Required properties:
+- compatible: "rockchip,rk3288-dw-hdmi";
+- reg: Physical base address and length of the controller's registers.
+- clocks: phandle to hdmi iahb and isrf clocks.
+- clock-names: should be "iahb" "isfr"
+- rockchip,grf: this soc should set GRF regs to mux vopl/vopb.
+- interrupts: HDMI interrupt number
+- ports: contain a port node with endpoint definitions as defined in
+  Documentation/devicetree/bindings/media/video-interfaces.txt. For
+  vopb,set the reg = <0> and set the reg = <1> for vopl.
+- reg-io-width: the width of the reg:1,4, the value should be 4 on
+  rk3288 platform
+
+Optional properties
+- ddc-i2c-bus: phandle of an I2C controller used for DDC EDID probing
+- clkocks, clock-names: phandle to the HDMI cec clock, name should be "cec"
+
+Example:
+hdmi: hdmi@ff98 {
+   compatible = "rockchip,rk3288-dw-hdmi";
+   reg = <0xff98 0x2>;
+   reg-io-width = <4>;
+   ddc-i2c-bus = <&i2c5>;
+   rockchip,grf = <&grf>;
+   interrupts = ;
+   clocks = <&cru  PCLK_HDMI_CTRL>, <&cru SCLK_HDMI_HDCP>;
+   clock-names = "iahb", "isfr";
+   status = "disabled";
+   ports {
+   hdmi_in: port {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   hdmi_in_vopb: endpoint@0 {
+   reg = <0>;
+   remote-endpoint = <&vopb_out_hdmi>;
+   };
+   hdmi_in_vopl: endpoint@1 {
+   reg = <1>;
+   remote-endpoint = <&vopl_out_hdmi>;
+   };
+   };
+   };
+};
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v16 09/12] drm: bridge/dw_hdmi: clear i2cmphy_stat0 reg in hdmi_phy_wait_i2c_done

2014-12-03 Thread Andy Yan
HDMI_IH_I2CMPHY_STAT0 is a clear on write register, which indicates i2cm
operation status(i2c transfer done or error), every hdmi phy register
configuration must check this register to make sure the configuration
has complete. But the indication bit should be cleared after check, otherwise
the corresponding bit will hold on forever, this may give a wrong signal for
next check.

Signed-off-by: Andy Yan 
---

Changes in v16: None
Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/bridge/dw_hdmi.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index e3999da..e53dae0 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -666,11 +666,15 @@ static inline void hdmi_phy_test_dout(struct dw_hdmi 
*hdmi,
 
 static bool hdmi_phy_wait_i2c_done(struct dw_hdmi *hdmi, int msec)
 {
-   while ((hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3) == 0) {
+   u32 val;
+
+   while ((val = hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3) == 0) {
if (msec-- == 0)
return false;
udelay(1000);
}
+   hdmi_writeb(hdmi, val, HDMI_IH_I2CMPHY_STAT0);
+
return true;
 }
 
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v16 10/12] drm: bridge/dw_hdmi: add function dw_hdmi_phy_enable_spare

2014-12-03 Thread Andy Yan
RK3288 HDMI will not work without the spare bit of
HDMI_PHY_CONF0 enable

Signed-off-by: Andy Yan 
---

Changes in v16: None
Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/bridge/dw_hdmi.c | 7 +++
 drivers/gpu/drm/bridge/dw_hdmi.h | 3 ++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index e53dae0..efc3b6f 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -713,6 +713,13 @@ static void dw_hdmi_phy_enable_tmds(struct dw_hdmi *hdmi, 
u8 enable)
 HDMI_PHY_CONF0_ENTMDS_MASK);
 }
 
+static void dw_hdmi_phy_enable_spare(struct dw_hdmi *hdmi, u8 enable)
+{
+   hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0,
+HDMI_PHY_CONF0_SPARECTRL_OFFSET,
+HDMI_PHY_CONF0_SPARECTRL_MASK);
+}
+
 static void dw_hdmi_phy_gen2_pddq(struct dw_hdmi *hdmi, u8 enable)
 {
hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0,
diff --git a/drivers/gpu/drm/bridge/dw_hdmi.h b/drivers/gpu/drm/bridge/dw_hdmi.h
index baa7849..175dbc8 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.h
+++ b/drivers/gpu/drm/bridge/dw_hdmi.h
@@ -837,7 +837,8 @@ enum {
HDMI_PHY_CONF0_PDZ_OFFSET = 7,
HDMI_PHY_CONF0_ENTMDS_MASK = 0x40,
HDMI_PHY_CONF0_ENTMDS_OFFSET = 6,
-   HDMI_PHY_CONF0_SPARECTRL = 0x20,
+   HDMI_PHY_CONF0_SPARECTRL_MASK = 0x20,
+   HDMI_PHY_CONF0_SPARECTRL_OFFSET = 5,
HDMI_PHY_CONF0_GEN2_PDDQ_MASK = 0x10,
HDMI_PHY_CONF0_GEN2_PDDQ_OFFSET = 4,
HDMI_PHY_CONF0_GEN2_TXPWRON_MASK = 0x8,
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v16 08/12] drm: bridge/dw_hdmi: add mode_valid support

2014-12-03 Thread Andy Yan
some platform may not support all the display mode,
add mode_valid interface check it

Signed-off-by: Andy Yan 

---

Changes in v16: None
Changes in v15: None
Changes in v14:
- remove drm_connector_register, because imx-drm core has registered
connector

Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/bridge/dw_hdmi.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index d2c6ba8..e3999da 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -1405,6 +1405,20 @@ static int dw_hdmi_connector_get_modes(struct 
drm_connector *connector)
return 0;
 }
 
+static enum drm_mode_status
+dw_hdmi_connector_mode_valid(struct drm_connector *connector,
+struct drm_display_mode *mode)
+{
+   struct dw_hdmi *hdmi = container_of(connector,
+  struct dw_hdmi, connector);
+   enum drm_mode_status mode_status = MODE_OK;
+
+   if (hdmi->plat_data->mode_valid)
+   mode_status = hdmi->plat_data->mode_valid(connector, mode);
+
+   return mode_status;
+}
+
 static struct drm_encoder *dw_hdmi_connector_best_encoder(struct drm_connector
   *connector)
 {
@@ -1429,6 +1443,7 @@ static struct drm_connector_funcs dw_hdmi_connector_funcs 
= {
 
 static struct drm_connector_helper_funcs dw_hdmi_connector_helper_funcs = {
.get_modes = dw_hdmi_connector_get_modes,
+   .mode_valid = dw_hdmi_connector_mode_valid,
.best_encoder = dw_hdmi_connector_best_encoder,
 };
 
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v16 07/12] drm: bridge/dw_hdmi: add support for multi-byte register width access

2014-12-03 Thread Andy Yan
On rockchip rk3288, only word(32-bit) accesses are
permitted for hdmi registers.  Byte width accesses (writeb,
readb) generate an imprecise external abort.

Signed-off-by: Andy Yan 

---

Changes in v16: None
Changes in v15:
- remove unio of the multi-byte register access, adviced by Philipp Zabel

Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6:
- refactor register access without reg_shift

Changes in v5:
- refactor reg-io-width

Changes in v4: None
Changes in v3:
- split multi-register access to one indepent patch

 drivers/gpu/drm/bridge/dw_hdmi.c | 44 ++--
 1 file changed, 42 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index ac5f5e2..d2c6ba8 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -128,18 +128,41 @@ struct dw_hdmi {
 
unsigned int sample_rate;
int ratio;
+
+   void (*write)(struct dw_hdmi *hdmi, u8 val, int offset);
+   u8 (*read)(struct dw_hdmi *hdmi, int offset);
 };
 
-static inline void hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset)
+static void dw_hdmi_writel(struct dw_hdmi *hdmi, u8 val, int offset)
+{
+   writel(val, hdmi->regs + (offset << 2));
+}
+
+static u8 dw_hdmi_readl(struct dw_hdmi *hdmi, int offset)
+{
+   return readl(hdmi->regs + (offset << 2));
+}
+
+static void dw_hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset)
 {
writeb(val, hdmi->regs + offset);
 }
 
-static inline u8 hdmi_readb(struct dw_hdmi *hdmi, int offset)
+static u8 dw_hdmi_readb(struct dw_hdmi *hdmi, int offset)
 {
return readb(hdmi->regs + offset);
 }
 
+static inline void hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset)
+{
+   hdmi->write(hdmi, val, offset);
+}
+
+static inline u8 hdmi_readb(struct dw_hdmi *hdmi, int offset)
+{
+   return hdmi->read(hdmi, offset);
+}
+
 static void hdmi_modb(struct dw_hdmi *hdmi, u8 data, u8 mask, unsigned reg)
 {
u8 val = hdmi_readb(hdmi, reg) & ~mask;
@@ -1512,6 +1535,7 @@ int dw_hdmi_bind(struct device *dev, struct device 
*master,
struct dw_hdmi *hdmi;
struct resource *iores;
int ret, irq;
+   u32 val = 1;
 
hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL);
if (!hdmi)
@@ -1524,6 +1548,22 @@ int dw_hdmi_bind(struct device *dev, struct device 
*master,
hdmi->ratio = 100;
hdmi->encoder = encoder;
 
+   of_property_read_u32(np, "reg-io-width", &val);
+
+   switch (val) {
+   case 4:
+   hdmi->write = dw_hdmi_writel;
+   hdmi->read = dw_hdmi_readl;
+   break;
+   case 1:
+   hdmi->write = dw_hdmi_writeb;
+   hdmi->read = dw_hdmi_readb;
+   break;
+   default:
+   dev_err(dev, "reg-io-width must be 1 or 4\n");
+   return -EINVAL;
+   }
+
ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0);
if (ddc_node) {
hdmi->ddc = of_find_i2c_adapter_by_node(ddc_node);
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v16 06/12] dt-bindings: add document for dw_hdmi

2014-12-03 Thread Andy Yan
Signed-off-by: Andy Yan 

---

Changes in v16:
- describe ddc-i2c-bus as optional
- add common clocks bindings

Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8:
- correct some spelling mistake
- modify ddc-i2c-bus and interrupt description

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 .../devicetree/bindings/drm/bridge/dw_hdmi.txt | 45 ++
 1 file changed, 45 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt

diff --git a/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt 
b/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt
new file mode 100644
index 000..fb14730
--- /dev/null
+++ b/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt
@@ -0,0 +1,45 @@
+DesignWare HDMI bridge bindings
+
+Required properities:
+- compatible: platform specific such as:
+   * "snps,dw-hdmi-tx"
+   * "fsl,imx6q-hdmi"
+   * "fsl,imx6dl-hdmi"
+   * "rockchip,rk3288-dw-hdmi"
+- reg: Physical base address and length of the controller's registers.
+- interrupts: The HDMI interrupt number
+- clocks, clock-names : must have the phandles to the HDMI iahb and isrf 
clocks,
+  as described in Documentation/devicetree/bindings/clock/clock-bindings.txt,
+  the clock-names should be "iahb", "isfr"
+
+Optional properties
+- reg-io-width: the width of the reg:1,4, default set to 1 if not present
+- ddc-i2c-bus: phandle of an I2C controller used for DDC EDID probing
+- clkocks, clock-names: phandle to the HDMI cec clock, name should be "cec"
+
+Example:
+   hdmi: hdmi@012 {
+   compatible = "fsl,imx6q-hdmi";
+   reg = <0x0012 0x9000>;
+   interrupts = <0 115 0x04>;
+   gpr = <&gpr>;
+   clocks = <&clks 123>, <&clks 124>;
+   clock-names = "iahb", "isfr";
+   ddc-i2c-bus = <&i2c2>;
+
+   port@0 {
+   reg = <0>;
+
+   hdmi_mux_0: endpoint {
+   remote-endpoint = <&ipu1_di0_hdmi>;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+
+   hdmi_mux_1: endpoint {
+   remote-endpoint = <&ipu1_di1_hdmi>;
+   };
+   };
+   };
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v16 05/12] drm: imx: imx-hdmi: move imx-hdmi to bridge/dw_hdmi

2014-12-03 Thread Andy Yan
the original imx hdmi driver is under drm/imx/,
which depends on imx-drm, so move the imx hdmi
driver out to drm/bridge and rename it to dw_hdmi

Signed-off-by: Andy Yan 

---

Changes in v16: None
Changes in v15:
- add prefix dw_hdmi/DW_HDMI for public used dw_hdmi structs
  adviced by Philipp Zabel
- remove THIS_MODULE in platform driver

Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/bridge/Kconfig |   5 +
 drivers/gpu/drm/bridge/Makefile|   1 +
 .../gpu/drm/{imx/imx-hdmi.c => bridge/dw_hdmi.c}   | 282 +++--
 .../gpu/drm/{imx/imx-hdmi.h => bridge/dw_hdmi.h}   |  42 ---
 drivers/gpu/drm/imx/Kconfig|   1 +
 drivers/gpu/drm/imx/Makefile   |   2 +-
 .../drm/imx/{imx-hdmi_pltfm.c => dw_hdmi-imx.c}| 127 +-
 include/drm/bridge/dw_hdmi.h   |  59 +
 8 files changed, 271 insertions(+), 248 deletions(-)
 rename drivers/gpu/drm/{imx/imx-hdmi.c => bridge/dw_hdmi.c} (84%)
 rename drivers/gpu/drm/{imx/imx-hdmi.h => bridge/dw_hdmi.h} (98%)
 rename drivers/gpu/drm/imx/{imx-hdmi_pltfm.c => dw_hdmi-imx.c} (53%)
 create mode 100644 include/drm/bridge/dw_hdmi.h

diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index 884923f..26162ef 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -3,3 +3,8 @@ config DRM_PTN3460
depends on DRM
select DRM_KMS_HELPER
---help---
+
+config DRM_DW_HDMI
+   bool "Synopsys DesignWare High-Definition Multimedia Interface"
+   depends on DRM
+   select DRM_KMS_HELPER
diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
index b4733e1..d8a8cfd 100644
--- a/drivers/gpu/drm/bridge/Makefile
+++ b/drivers/gpu/drm/bridge/Makefile
@@ -1,3 +1,4 @@
 ccflags-y := -Iinclude/drm
 
 obj-$(CONFIG_DRM_PTN3460) += ptn3460.o
+obj-$(CONFIG_DRM_DW_HDMI) += dw_hdmi.o
diff --git a/drivers/gpu/drm/imx/imx-hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
similarity index 84%
rename from drivers/gpu/drm/imx/imx-hdmi.c
rename to drivers/gpu/drm/bridge/dw_hdmi.c
index 4ad6663..ac5f5e2 100644
--- a/drivers/gpu/drm/imx/imx-hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -6,12 +6,11 @@
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
  *
- * SH-Mobile High-Definition Multimedia Interface (HDMI) driver
- * for SLISHDMI13T and SLIPHDMIT IP cores
+ * Designware High-Definition Multimedia Interface (HDMI) driver
  *
  * Copyright (C) 2010, Guennadi Liakhovetski 
  */
-
+#include 
 #include 
 #include 
 #include 
@@ -24,8 +23,9 @@
 #include 
 #include 
 #include 
+#include 
 
-#include "imx-hdmi.h"
+#include "dw_hdmi.h"
 
 #define HDMI_EDID_LEN  512
 
@@ -101,18 +101,19 @@ struct hdmi_data_info {
struct hdmi_vmode video_mode;
 };
 
-struct imx_hdmi {
+struct dw_hdmi {
struct drm_connector connector;
struct drm_encoder *encoder;
struct drm_bridge *bridge;
 
-   enum imx_hdmi_devtype dev_type;
+   enum dw_hdmi_devtype dev_type;
struct device *dev;
struct clk *isfr_clk;
struct clk *iahb_clk;
 
struct hdmi_data_info hdmi_data;
-   const struct imx_hdmi_plat_data *plat_data;
+   const struct dw_hdmi_plat_data *plat_data;
+
int vic;
 
u8 edid[HDMI_EDID_LEN];
@@ -129,17 +130,17 @@ struct imx_hdmi {
int ratio;
 };
 
-static inline void hdmi_writeb(struct imx_hdmi *hdmi, u8 val, int offset)
+static inline void hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset)
 {
writeb(val, hdmi->regs + offset);
 }
 
-static inline u8 hdmi_readb(struct imx_hdmi *hdmi, int offset)
+static inline u8 hdmi_readb(struct dw_hdmi *hdmi, int offset)
 {
return readb(hdmi->regs + offset);
 }
 
-static void hdmi_modb(struct imx_hdmi *hdmi, u8 data, u8 mask, unsigned reg)
+static void hdmi_modb(struct dw_hdmi *hdmi, u8 data, u8 mask, unsigned reg)
 {
u8 val = hdmi_readb(hdmi, reg) & ~mask;
 
@@ -147,13 +148,13 @@ static void hdmi_modb(struct imx_hdmi *hdmi, u8 data, u8 
mask, unsigned reg)
hdmi_writeb(hdmi, val, reg);
 }
 
-static void hdmi_mask_writeb(struct imx_hdmi *hdmi, u8 data, unsigned int reg,
+static void hdmi_mask_writeb(struct dw_hdmi *hdmi, u8 data, unsigned int reg,
 u8 shift, u8 mask)
 {
hdmi_modb(hdmi, data << shift, mask, reg);
 }
 
-static void hdmi_set_clock_regenerator_n(struct imx_hdmi *hdmi,
+static void hdmi_set_clock_regenerator_n(struct dw_hdmi *hdmi,
 unsigned int value)
 {
hdmi_writeb(hdmi, value & 0xff, HDMI_AUD_N1);
@@ -164,

[PATCH v16 04/12] drm: imx: imx-hdmi: split phy configuration to platform driver

2014-12-03 Thread Andy Yan
hdmi phy configuration is platform specific, which can be adusted
according to the board to get the best SI

Signed-off-by: Andy Yan 

---

Changes in v16: None
Changes in v15: None
Changes in v14: None
Changes in v13:
- split phy configuration from patch#4

Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/imx/imx-hdmi.c   | 85 +++-
 drivers/gpu/drm/imx/imx-hdmi.h   | 29 
 drivers/gpu/drm/imx/imx-hdmi_pltfm.c | 57 
 3 files changed, 101 insertions(+), 70 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-hdmi.c b/drivers/gpu/drm/imx/imx-hdmi.c
index a7c1ec7..4ad6663 100644
--- a/drivers/gpu/drm/imx/imx-hdmi.c
+++ b/drivers/gpu/drm/imx/imx-hdmi.c
@@ -713,76 +713,14 @@ static void imx_hdmi_phy_sel_interface_control(struct 
imx_hdmi *hdmi, u8 enable)
 HDMI_PHY_CONF0_SELDIPIF_MASK);
 }
 
-enum {
-   RES_8,
-   RES_10,
-   RES_12,
-   RES_MAX,
-};
-
-struct mpll_config {
-   unsigned long mpixelclock;
-   struct {
-   u16 cpce;
-   u16 gmp;
-   } res[RES_MAX];
-};
-
-static const struct mpll_config mpll_config[] = {
-   {
-   4525, {
-   { 0x01e0, 0x },
-   { 0x21e1, 0x },
-   { 0x41e2, 0x }
-   },
-   }, {
-   9250, {
-   { 0x0140, 0x0005 },
-   { 0x2141, 0x0005 },
-   { 0x4142, 0x0005 },
-   },
-   }, {
-   14850, {
-   { 0x00a0, 0x000a },
-   { 0x20a1, 0x000a },
-   { 0x40a2, 0x000a },
-   },
-   }, {
-   ~0UL, {
-   { 0x00a0, 0x000a },
-   { 0x2001, 0x000f },
-   { 0x4002, 0x000f },
-   },
-   }
-};
-
-struct curr_ctrl {
-   unsigned long mpixelclock;
-   u16 curr[RES_MAX];
-};
-
-static const struct curr_ctrl curr_ctrl[] = {
-   /*  pixelclk bpp8bpp10   bpp12 */
-   {
-5400, { 0x091c, 0x091c, 0x06dc },
-   }, {
-5840, { 0x091c, 0x06dc, 0x06dc },
-   }, {
-7200, { 0x06dc, 0x06dc, 0x091c },
-   }, {
-7425, { 0x06dc, 0x0b5c, 0x091c },
-   }, {
-   11880, { 0x091c, 0x091c, 0x06dc },
-   }, {
-   21600, { 0x06dc, 0x0b5c, 0x091c },
-   }
-};
-
 static int hdmi_phy_configure(struct imx_hdmi *hdmi, unsigned char prep,
  unsigned char res, int cscon)
 {
unsigned res_idx, i;
u8 val, msec;
+   const struct mpll_config *mpll_config = hdmi->plat_data->mpll_cfg;
+   const struct curr_ctrl   *curr_ctrl = hdmi->plat_data->cur_ctr;
+   const struct sym_term *sym_term =  hdmi->plat_data->sym_term;
 
if (prep)
return -EINVAL;
@@ -828,7 +766,7 @@ static int hdmi_phy_configure(struct imx_hdmi *hdmi, 
unsigned char prep,
hdmi_phy_test_clear(hdmi, 0);
 
/* PLL/MPLL Cfg - always match on final entry */
-   for (i = 0; i < ARRAY_SIZE(mpll_config) - 1; i++)
+   for (i = 0; mpll_config[i].mpixelclock != (~0UL); i++)
if (hdmi->hdmi_data.video_mode.mpixelclock <=
mpll_config[i].mpixelclock)
break;
@@ -836,12 +774,12 @@ static int hdmi_phy_configure(struct imx_hdmi *hdmi, 
unsigned char prep,
hdmi_phy_i2c_write(hdmi, mpll_config[i].res[res_idx].cpce, 0x06);
hdmi_phy_i2c_write(hdmi, mpll_config[i].res[res_idx].gmp, 0x15);
 
-   for (i = 0; i < ARRAY_SIZE(curr_ctrl); i++)
+   for (i = 0; curr_ctrl[i].mpixelclock != (~0UL); i++)
if (hdmi->hdmi_data.video_mode.mpixelclock <=
curr_ctrl[i].mpixelclock)
break;
 
-   if (i >= ARRAY_SIZE(curr_ctrl)) {
+   if (curr_ctrl[i].mpixelclock == (~0UL)) {
dev_err(hdmi->dev, "Pixel clock %d - unsupported by HDMI\n",
hdmi->hdmi_data.video_mode.mpixelclock);
return -EINVAL;
@@ -852,10 +790,17 @@ static int hdmi_phy_configure(struct imx_hdmi *hdmi, 
unsigned char prep,
 
hdmi_phy_i2c_write(hdmi, 0x, 0x13);  /* PLLPHBYCTRL */
hdmi_phy_i2c_write(hdmi, 0x0006, 0x17);
+
+   for (i = 0; sym_term[i].mpixelclock != (~0UL); i++)
+   if (hdmi->hdmi_data.video_mode.mpixelclock <=
+   sym_term[i].mpixelclock)
+   break;
+
/* RESISTANCE TERM 133Ohm Cfg */
-   hdmi_phy_i2c_write(hdmi, 0x0005, 0x19);  /* TXTE

[PATCH v16 03/12] drm: imx: imx-hdmi: convert imx-hdmi to drm_bridge mode

2014-12-03 Thread Andy Yan
IMX6 and Rockchip RK3288 and JZ4780 (Ingenic Xburst/MIPS)
use the interface compatible Designware HDMI IP, but they
also have some lightly differences, such as phy pll configuration,
register width, 4K support, clk useage, and the crtc mux configuration
is also platform specific.

To reuse the imx hdmi driver, convert it to drm_bridge

handle encoder in imx-hdmi_pltfm.c, as most of the encoder
operation are platform specific such as crtc select and
panel format set

This patch depends on Russell King's patch:
 drm: imx: convert imx-drm to use the generic DRM OF helper
 
http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2014-July/053484.html

Signed-off-by: Andy Yan 
Signed-off-by: Yakir Yang 

---

Changes in v16:
- use the common binding for the clocks

Changes in v15: None
Changes in v14:
- add defer probing, adviced by Philipp Zabel

Changes in v13:
- split platform specific phy configuration

Changes in v12:
- squash patch 

Changes in v11:
- squash patch  

Changes in v10:
- split generic dw_hdmi.c improvements from patch#11 (add rk3288 support)

Changes in v9: None
Changes in v8: None
Changes in v7:
- remove unused variables from structure dw_hdmi
- remove a wrong modification
- add copyrights for dw_hdmi-imx.c

Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/imx/Makefile |   2 +-
 drivers/gpu/drm/imx/imx-hdmi.c   | 252 +--
 drivers/gpu/drm/imx/imx-hdmi.h   |  14 ++
 drivers/gpu/drm/imx/imx-hdmi_pltfm.c | 193 +++
 4 files changed, 304 insertions(+), 157 deletions(-)
 create mode 100644 drivers/gpu/drm/imx/imx-hdmi_pltfm.c

diff --git a/drivers/gpu/drm/imx/Makefile b/drivers/gpu/drm/imx/Makefile
index 582c438..63cf56a 100644
--- a/drivers/gpu/drm/imx/Makefile
+++ b/drivers/gpu/drm/imx/Makefile
@@ -9,4 +9,4 @@ obj-$(CONFIG_DRM_IMX_LDB) += imx-ldb.o
 
 imx-ipuv3-crtc-objs  := ipuv3-crtc.o ipuv3-plane.o
 obj-$(CONFIG_DRM_IMX_IPUV3)+= imx-ipuv3-crtc.o
-obj-$(CONFIG_DRM_IMX_HDMI) += imx-hdmi.o
+obj-$(CONFIG_DRM_IMX_HDMI) += imx-hdmi.o imx-hdmi_pltfm.o
diff --git a/drivers/gpu/drm/imx/imx-hdmi.c b/drivers/gpu/drm/imx/imx-hdmi.c
index 7a54d20..a7c1ec7 100644
--- a/drivers/gpu/drm/imx/imx-hdmi.c
+++ b/drivers/gpu/drm/imx/imx-hdmi.c
@@ -12,25 +12,20 @@
  * Copyright (C) 2010, Guennadi Liakhovetski 
  */
 
-#include 
 #include 
 #include 
 #include 
 #include 
 #include 
-#include 
-#include 
-#include 
 #include 
 
+#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 
 #include "imx-hdmi.h"
-#include "imx-drm.h"
 
 #define HDMI_EDID_LEN  512
 
@@ -54,11 +49,6 @@ enum hdmi_datamap {
YCbCr422_12B = 0x12,
 };
 
-enum imx_hdmi_devtype {
-   IMX6Q_HDMI,
-   IMX6DL_HDMI,
-};
-
 static const u16 csc_coeff_default[3][4] = {
{ 0x2000, 0x, 0x, 0x },
{ 0x, 0x2000, 0x, 0x },
@@ -113,7 +103,8 @@ struct hdmi_data_info {
 
 struct imx_hdmi {
struct drm_connector connector;
-   struct drm_encoder encoder;
+   struct drm_encoder *encoder;
+   struct drm_bridge *bridge;
 
enum imx_hdmi_devtype dev_type;
struct device *dev;
@@ -121,6 +112,7 @@ struct imx_hdmi {
struct clk *iahb_clk;
 
struct hdmi_data_info hdmi_data;
+   const struct imx_hdmi_plat_data *plat_data;
int vic;
 
u8 edid[HDMI_EDID_LEN];
@@ -137,13 +129,6 @@ struct imx_hdmi {
int ratio;
 };
 
-static void imx_hdmi_set_ipu_di_mux(struct imx_hdmi *hdmi, int ipu_di)
-{
-   regmap_update_bits(hdmi->regmap, IOMUXC_GPR3,
-  IMX6Q_GPR3_HDMI_MUX_CTL_MASK,
-  ipu_di << IMX6Q_GPR3_HDMI_MUX_CTL_SHIFT);
-}
-
 static inline void hdmi_writeb(struct imx_hdmi *hdmi, u8 val, int offset)
 {
writeb(val, hdmi->regs + offset);
@@ -1371,6 +1356,50 @@ static void imx_hdmi_poweroff(struct imx_hdmi *hdmi)
imx_hdmi_phy_disable(hdmi);
 }
 
+static void imx_hdmi_bridge_mode_set(struct drm_bridge *bridge,
+struct drm_display_mode *mode,
+struct drm_display_mode *adjusted_mode)
+{
+   struct imx_hdmi *hdmi = bridge->driver_private;
+
+   imx_hdmi_setup(hdmi, mode);
+
+   /* Store the display mode for plugin/DKMS poweron events */
+   memcpy(&hdmi->previous_mode, mode, sizeof(hdmi->previous_mode));
+}
+
+static bool imx_hdmi_bridge_mode_fixup(struct drm_bridge *bridge,
+  const struct drm_display_mode *mode,
+  struct drm_display_mode *adjusted_mode)
+{
+   return true;
+}
+
+static void imx_hdmi_bridge_disable(struct drm_bridge *bridge)
+{
+   struct imx_hdmi *hdmi = bridge->driver_private;
+
+   imx_hdmi_poweroff(hdmi);
+}
+
+static void imx_hdmi_bridge_enable(struct drm_bridge *bridge)
+{
+

[PATCH v16 02/12] drm: imx: imx-hdmi: return defer if can't get ddc i2c adapter

2014-12-03 Thread Andy Yan
drm driver may probe before the i2c bus, so the driver should
defer probing until it is available

Signed-off-by: Andy Yan 
Reviewed-by: Daniel Kurtz 

---

Changes in v16: None
Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12:
- refactor of_node_put(ddc_node)

Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4:
- defer probe ddc i2c adapter

Changes in v3: None

 drivers/gpu/drm/imx/imx-hdmi.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-hdmi.c b/drivers/gpu/drm/imx/imx-hdmi.c
index 7fd90ae..7a54d20 100644
--- a/drivers/gpu/drm/imx/imx-hdmi.c
+++ b/drivers/gpu/drm/imx/imx-hdmi.c
@@ -1611,10 +1611,12 @@ static int imx_hdmi_bind(struct device *dev, struct 
device *master, void *data)
ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0);
if (ddc_node) {
hdmi->ddc = of_find_i2c_adapter_by_node(ddc_node);
-   if (!hdmi->ddc)
+   of_node_put(ddc_node);
+   if (!hdmi->ddc) {
dev_dbg(hdmi->dev, "failed to read ddc node\n");
+   return -EPROBE_DEFER;
+   }
 
-   of_node_put(ddc_node);
} else {
dev_dbg(hdmi->dev, "no ddc property found\n");
}
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v16 01/12] drm: imx: imx-hdmi: make checkpatch happy

2014-12-03 Thread Andy Yan
CHECK: Alignment should match open parenthesis
+   if ((hdmi->vic == 10) || (hdmi->vic == 11) ||
+   (hdmi->vic == 12) || (hdmi->vic == 13) ||

CHECK: braces {} should be used on all arms of this statement
+   if (hdmi->hdmi_data.video_mode.mdvi)
[...]
+   else {
[...]

Signed-off-by: Andy Yan 
Reviewed-by: Daniel Kurtz 

---

Changes in v16: None
Changes in v15: None
Changes in v14: None
Changes in v13:
- patch against drm-next

Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6:
- rearrange the patch order

Changes in v5: None
Changes in v4:
- fix checkpatch CHECK

Changes in v3: None

 drivers/gpu/drm/imx/imx-hdmi.c | 109 -
 1 file changed, 52 insertions(+), 57 deletions(-)

diff --git a/drivers/gpu/drm/imx/imx-hdmi.c b/drivers/gpu/drm/imx/imx-hdmi.c
index aaec6b2..7fd90ae 100644
--- a/drivers/gpu/drm/imx/imx-hdmi.c
+++ b/drivers/gpu/drm/imx/imx-hdmi.c
@@ -163,7 +163,7 @@ static void hdmi_modb(struct imx_hdmi *hdmi, u8 data, u8 
mask, unsigned reg)
 }
 
 static void hdmi_mask_writeb(struct imx_hdmi *hdmi, u8 data, unsigned int reg,
- u8 shift, u8 mask)
+u8 shift, u8 mask)
 {
hdmi_modb(hdmi, data << shift, mask, reg);
 }
@@ -327,7 +327,7 @@ static unsigned int hdmi_compute_cts(unsigned int freq, 
unsigned long pixel_clk,
 }
 
 static void hdmi_set_clk_regenerator(struct imx_hdmi *hdmi,
-   unsigned long pixel_clk)
+unsigned long pixel_clk)
 {
unsigned int clk_n, clk_cts;
 
@@ -338,7 +338,7 @@ static void hdmi_set_clk_regenerator(struct imx_hdmi *hdmi,
 
if (!clk_cts) {
dev_dbg(hdmi->dev, "%s: pixel clock not supported: %lu\n",
-__func__, pixel_clk);
+   __func__, pixel_clk);
return;
}
 
@@ -477,13 +477,11 @@ static void imx_hdmi_update_csc_coeffs(struct imx_hdmi 
*hdmi)
u16 coeff_b = (*csc_coeff)[1][i];
u16 coeff_c = (*csc_coeff)[2][i];
 
-   hdmi_writeb(hdmi, coeff_a & 0xff,
-   HDMI_CSC_COEF_A1_LSB + i * 2);
+   hdmi_writeb(hdmi, coeff_a & 0xff, HDMI_CSC_COEF_A1_LSB + i * 2);
hdmi_writeb(hdmi, coeff_a >> 8, HDMI_CSC_COEF_A1_MSB + i * 2);
hdmi_writeb(hdmi, coeff_b & 0xff, HDMI_CSC_COEF_B1_LSB + i * 2);
hdmi_writeb(hdmi, coeff_b >> 8, HDMI_CSC_COEF_B1_MSB + i * 2);
-   hdmi_writeb(hdmi, coeff_c & 0xff,
-   HDMI_CSC_COEF_C1_LSB + i * 2);
+   hdmi_writeb(hdmi, coeff_c & 0xff, HDMI_CSC_COEF_C1_LSB + i * 2);
hdmi_writeb(hdmi, coeff_c >> 8, HDMI_CSC_COEF_C1_MSB + i * 2);
}
 
@@ -535,21 +533,22 @@ static void hdmi_video_packetize(struct imx_hdmi *hdmi)
struct hdmi_data_info *hdmi_data = &hdmi->hdmi_data;
u8 val, vp_conf;
 
-   if (hdmi_data->enc_out_format == RGB
-   || hdmi_data->enc_out_format == YCBCR444) {
-   if (!hdmi_data->enc_color_depth)
+   if (hdmi_data->enc_out_format == RGB ||
+   hdmi_data->enc_out_format == YCBCR444) {
+   if (!hdmi_data->enc_color_depth) {
output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS;
-   else if (hdmi_data->enc_color_depth == 8) {
+   } else if (hdmi_data->enc_color_depth == 8) {
color_depth = 4;
output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_BYPASS;
-   } else if (hdmi_data->enc_color_depth == 10)
+   } else if (hdmi_data->enc_color_depth == 10) {
color_depth = 5;
-   else if (hdmi_data->enc_color_depth == 12)
+   } else if (hdmi_data->enc_color_depth == 12) {
color_depth = 6;
-   else if (hdmi_data->enc_color_depth == 16)
+   } else if (hdmi_data->enc_color_depth == 16) {
color_depth = 7;
-   else
+   } else {
return;
+   }
} else if (hdmi_data->enc_out_format == YCBCR422_8BITS) {
if (!hdmi_data->enc_color_depth ||
hdmi_data->enc_color_depth == 8)
@@ -561,8 +560,9 @@ static void hdmi_video_packetize(struct imx_hdmi *hdmi)
else
return;
output_select = HDMI_VP_CONF_OUTPUT_SELECTOR_YCC422;
-   } else
+   } else {
return;
+   }
 
/* set the packetizer registers */
val = ((color_depth << HDMI_VP_PR_CD_COLOR_DEPTH_OFFSET) &
@@ -623,34 +623,34 @@ static void hdmi_video_packetize(struct imx_hdmi 

[PATCH v16 0/12] dw-hdmi: convert imx hdmi to bridge/dw_hdmi

2014-12-03 Thread Andy Yan

We found Freescale imx6 and Rockchip rk3288 and Ingenic JZ4780 (Xburst/MIPS)
use the interface compatible Designware HDMI IP, but they also have some
lightly differences, such as phy pll configuration, register width(imx hdmi
register is one byte, but rk3288 is 4 bytes width and can only be accessed
by word), 4K support(imx6 doesn't support 4k, but rk3288 does), and HDMI2.0
support.

To reuse the imx-hdmi driver, we make this patch set:
(1): fix some CodingStyle warning to make checkpatch happy
(2): convert imx-hdmi to drm_bridge
(3): split platform specific code
(4): move imx-hdmi to bridge/dw_hdmi
(5): extend dw_hdmi.c to support rk3288 hdmi
(6): add rockchip rk3288 platform specific code dw_hdmi-rockchip.c

Changes in v16:
- use the common binding for the clocks
- describe ddc-i2c-bus as optional

Changes in v15:
- add prefix dw_hdmi/DW_HDMI for public used dw_hdmi structs
  adviced by Philipp Zabel
- remove THIS_MODULE in platform driver
- remove unio of the multi-byte register access, adviced by Philipp Zabel
- remove THIS_MODULE in platform driver

Changes in v14:
- add defer probing, adviced by Philipp Zabel
- remove drm_connector_register, because imx-drm core has registered
connector

Changes in v13:
- patch against drm-next
- split platform specific phy configuration
- split phy configuration from patch#4

Changes in v12:
- refactor of_node_put(ddc_node)
- squash patch 
- add comment for the depend on patch

Changes in v11:
- squash patch  

Changes in v10:
- split generic dw_hdmi.c improvements from patch#11 (add rk3288 support)
- add more display mode support mpll configuration for rk3288

Changes in v9:
- move some phy configuration to platform driver

Changes in v8:
- correct some spelling mistake
- modify ddc-i2c-bus and interrupt description
- Add documentation for rockchip dw hdmi

Changes in v7:
- remove unused variables from structure dw_hdmi
- remove a wrong modification
- add copyrights for dw_hdmi-imx.c

Changes in v6:
- rearrange the patch order
- refactor register access without reg_shift

Changes in v5:
- refactor reg-io-width

Changes in v4:
- fix checkpatch CHECK
- defer probe ddc i2c adapter

Changes in v3:
- split multi-register access to one indepent patch

Andy Yan (12):
  drm: imx: imx-hdmi: make checkpatch happy
  drm: imx: imx-hdmi: return defer if can't get ddc i2c adapter
  drm: imx: imx-hdmi: convert imx-hdmi to drm_bridge mode
  drm: imx: imx-hdmi: split phy configuration to platform driver
  drm: imx: imx-hdmi: move imx-hdmi to bridge/dw_hdmi
  dt-bindings: add document for dw_hdmi
  drm: bridge/dw_hdmi: add support for multi-byte register width access
  drm: bridge/dw_hdmi: add mode_valid support
  drm: bridge/dw_hdmi: clear i2cmphy_stat0 reg in hdmi_phy_wait_i2c_done
  drm: bridge/dw_hdmi: add function dw_hdmi_phy_enable_spare
  dt-bindings: Add documentation for rockchip dw hdmi
  drm: bridge/dw_hdmi: add rockchip rk3288 support

 .../devicetree/bindings/drm/bridge/dw_hdmi.txt |  45 ++
 .../devicetree/bindings/video/dw_hdmi-rockchip.txt |  46 ++
 drivers/gpu/drm/bridge/Kconfig |   5 +
 drivers/gpu/drm/bridge/Makefile|   1 +
 .../gpu/drm/{imx/imx-hdmi.c => bridge/dw_hdmi.c}   | 711 ++---
 .../gpu/drm/{imx/imx-hdmi.h => bridge/dw_hdmi.h}   |   4 +-
 drivers/gpu/drm/imx/Kconfig|   1 +
 drivers/gpu/drm/imx/Makefile   |   2 +-
 drivers/gpu/drm/imx/dw_hdmi-imx.c  | 247 +++
 drivers/gpu/drm/rockchip/Kconfig   |  10 +
 drivers/gpu/drm/rockchip/Makefile  |   2 +
 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c| 321 ++
 include/drm/bridge/dw_hdmi.h   |  60 ++
 13 files changed, 1074 insertions(+), 381 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt
 create mode 100644 Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt
 rename drivers/gpu/drm/{imx/imx-hdmi.c => bridge/dw_hdmi.c} (73%)
 rename drivers/gpu/drm/{imx/imx-hdmi.h => bridge/dw_hdmi.h} (99%)
 create mode 100644 drivers/gpu/drm/imx/dw_hdmi-imx.c
 create mode 100644 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
 create mode 100644 include/drm/bridge/dw_hdmi.h

-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v15 12/12] drm: bridge/dw_hdmi: add rockchip rk3288 support

2014-12-03 Thread Andy Yan

Hi Philipp:
On 2014年12月03日 21:09, Philipp Zabel wrote:

Hi Andy,

Am Mittwoch, den 03.12.2014, 20:32 +0800 schrieb Andy Yan:

My question is not about the available gates at the SoC level, but about
the actual clock inputs from point of view of the HDMI TX IP.

It could be that the hdmi_ctrl_clk gates all inputs to the module and
bus clocks together. If so, you could just reuse "isfr" and "iahb" and
set it to the same clock. If not, we'd need to think of something else.
Unfortunately I don't have any Synopsys documentation of the HDMI TX at
that level.

 After confirming with the IC designer, we finally make clear that
 Rockchip RK3288 almost use the same clock design with imx:
 clk-iahbclk, used for hdmi module and bus
 hdcp_clk-isfrclk, used for hdcp and i2cm
 cecclk -cecclk, but this clk can be gated on rockchip, this is
different with imx,
 but we don't handle the cec stuff now. So i will try to reuse the
imx clk binds. do you
think that is ok?

Thank you for taking the time to verify this. So we should move the
clock handling out of the soc specific parts into the common driver and
reuse the existing clock bindings ("iahb", "isfr").
I'd suggest to add the "cec" clock now to the binding document as an
optional clock, then you can already specify it in the rockchip dtsi.

  ok


regards
Philipp





--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v15 12/12] drm: bridge/dw_hdmi: add rockchip rk3288 support

2014-12-03 Thread Andy Yan

Hi Philipp:
On 2014年12月02日 21:00, Philipp Zabel wrote:

Hi Andy,

Am Dienstag, den 02.12.2014, 20:34 +0800 schrieb Andy Yan:

Hi Philipp:
On 2014年12月02日 18:24, Philipp Zabel wrote:

Hi Andy,

Am Dienstag, den 02.12.2014, 15:45 +0800 schrieb Andy Yan:
[...]

+static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master,
+void *data)
+{
+   struct platform_device *pdev = to_platform_device(dev);
+   const struct dw_hdmi_plat_data *plat_data;
+   const struct of_device_id *match;
+   struct drm_device *drm = data;
+   struct drm_encoder *encoder;
+   struct rockchip_hdmi *hdmi;
+   int ret;
+
+   if (!pdev->dev.of_node)
+   return -ENODEV;
+
+   hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL);
+   if (!hdmi)
+   return -ENOMEM;
+
+   match = of_match_node(dw_hdmi_rockchip_ids, pdev->dev.of_node);
+   plat_data = match->data;
+   hdmi->dev = &pdev->dev;
+   encoder = &hdmi->encoder;
+   platform_set_drvdata(pdev, hdmi);
+
+   ret = rockchip_hdmi_parse_dt(hdmi);
+   if (ret) {
+   dev_err(hdmi->dev, "Unable to parse OF data\n");
+   return ret;
+   }
+
+   ret = clk_prepare_enable(hdmi->clk);
+   if (ret) {
+   dev_err(hdmi->dev, "Cannot enable HDMI clock: %d\n", ret);
+   return ret;
+   }
+
+   ret = clk_prepare_enable(hdmi->hdcp_clk);
+   if (ret) {
+   dev_err(hdmi->dev, "Cannot enable HDMI hdcp clock: %d\n", ret);
+   return ret;
+   }

Could we have a look at the clocks again? Basically the Rockchip clock
handling is exactly the same, except the clocks are called by other
names.

On i.MX6, according to the reference manual, the HDMI TX module has four
clock inputs: "iahbclk" (bus clock), "icecclk" (32 kHz CEC clock),
"ihclk" (module clock), and "isfrclk" (27 MHz internal SFR clock).
The "iahbclk" and "ihclk" are both sourced from the SoC AHB root clock,
the 32 kHz reference input can't be gated, and the "isfrclk" has its own
gate.

Does the HDMI TX implementation on Rockchip still have the separate
external sfr bus and module clock inputs? I assume that your "clk" input
is a single gate bit for bus and module clocks at the same time?
If possible, I'd prefer to find a common binding for the clocks with
some of the clocks being optional, but for that we need to know the
actual clock inputs to the HDMI TX module.

regards
Philipp


  There are three  individual clock inputs on Rockchip RK3288 HDMI:
"hdmi_ctrl_clk",
  "hdmi_cec_clk", "hdmi_hdcp_clk", the three clocks are responsible
for different
   functions as their name described, and have their own private gate
bit. That is
   to say, the cec_clk and hdcp_clk can all be disabled if we don't
need hdcp and cec
   function.
   So I think it's better to make the clk control platform independent.

My question is not about the available gates at the SoC level, but about
the actual clock inputs from point of view of the HDMI TX IP.

It could be that the hdmi_ctrl_clk gates all inputs to the module and
bus clocks together. If so, you could just reuse "isfr" and "iahb" and
set it to the same clock. If not, we'd need to think of something else.
Unfortunately I don't have any Synopsys documentation of the HDMI TX at
that level.


   After confirming with the IC designer, we finally make clear that
   Rockchip RK3288 almost use the same clock design with imx:
   clk-iahbclk, used for hdmi module and bus
   hdcp_clk-isfrclk, used for hdcp and i2cm
   cecclk -cecclk, but this clk can be gated on rockchip, this is 
different with imx,
   but we don't handle the cec stuff now. So i will try to reuse the 
imx clk binds. do you

  think that is ok?

regards
Philipp







--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v15 06/12] dt-bindings: add document for dw_hdmi

2014-12-03 Thread Andy Yan


On 2014年12月03日 19:52, Philipp Zabel wrote:

Am Mittwoch, den 03.12.2014, 17:46 +0800 schrieb Andy Yan:

On 2014年12月03日 02:23, Philipp Zabel wrote:

Hi Andy,

Am Dienstag, den 02.12.2014, 15:42 +0800 schrieb Andy Yan:

diff --git a/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt 
b/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt
new file mode 100644
index 000..107c1ca
--- /dev/null
+++ b/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt
@@ -0,0 +1,40 @@
+DesignWare HDMI bridge bindings
+
+Required properities:
+- compatible: platform specific such as:
+   * "fsl,imx6q-hdmi"
+   * "fsl,imx6dl-hdmi"
+   * "rockchip,rk3288-dw-hdmi"

I think we should add a common compatible value "snps,dw-hdmi-tx" here:

compatible = "fsl,imx6q-hdmi", "snps,dw-hdmi-tx";


+- reg: Physical base address and length of the controller's registers.
+- ddc-i2c-bus: phandle of an I2C controller used for DDC EDID probing

Better make ddc-i2c-bus optional, see the other thread about the ddc i2c
master.

  I have the same idea too, but the patch about ddc i2c master has not
   landed yet,  can we change the ddc-i2c-bus to optional  after the ddc
i2c master
   patch land?

Check out Documentation/devicetree/bindings/drm/imx/hdmi.txt, it was
already marked as optional. We can't make it required now.

regards
Philipp




  OK, got it, thanks

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v15 06/12] dt-bindings: add document for dw_hdmi

2014-12-03 Thread Andy Yan


On 2014年12月03日 02:23, Philipp Zabel wrote:

Hi Andy,

Am Dienstag, den 02.12.2014, 15:42 +0800 schrieb Andy Yan:

diff --git a/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt 
b/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt
new file mode 100644
index 000..107c1ca
--- /dev/null
+++ b/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt
@@ -0,0 +1,40 @@
+DesignWare HDMI bridge bindings
+
+Required properities:
+- compatible: platform specific such as:
+   * "fsl,imx6q-hdmi"
+   * "fsl,imx6dl-hdmi"
+   * "rockchip,rk3288-dw-hdmi"

I think we should add a common compatible value "snps,dw-hdmi-tx" here:

compatible = "fsl,imx6q-hdmi", "snps,dw-hdmi-tx";


+- reg: Physical base address and length of the controller's registers.
+- ddc-i2c-bus: phandle of an I2C controller used for DDC EDID probing

Better make ddc-i2c-bus optional, see the other thread about the ddc i2c
master.

I have the same idea too, but the patch about ddc i2c master has not
 landed yet,  can we change the ddc-i2c-bus to optional  after the ddc 
i2c master

 patch land?

+- interrupts: The HDMI interrupt number
+
+Optional properties
+- reg-io-width: the width of the reg:1,4, default set to 1 if not present
+
+Example:
+   hdmi: hdmi@012 {
+   compatible = "fsl,imx6q-hdmi";
+   reg = <0x0012 0x9000>;
+   interrupts = <0 115 0x04>;
+   gpr = <&gpr>;
+   clocks = <&clks 123>, <&clks 124>;
+   clock-names = "iahb", "isfr";
+   ddc-i2c-bus = <&i2c2>;
+
+   port@0 {
+   reg = <0>;
+
+   hdmi_mux_0: endpoint {
+   remote-endpoint = <&ipu1_di0_hdmi>;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+
+   hdmi_mux_1: endpoint {
+   remote-endpoint = <&ipu1_di1_hdmi>;
+   };
+   };
+   };

regards
Philipp


___
Linux-rockchip mailing list
linux-rockc...@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip






--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v15 06/12] dt-bindings: add document for dw_hdmi

2014-12-03 Thread Andy Yan

Hi Philipp:
On 2014年12月03日 17:19, Philipp Zabel wrote:

Hi Andy,

Am Mittwoch, den 03.12.2014, 08:54 +0800 schrieb Andy Yan:

+Required properities:
+- compatible: platform specific such as:
+   * "fsl,imx6q-hdmi"
+   * "fsl,imx6dl-hdmi"
+   * "rockchip,rk3288-dw-hdmi"

I think we should add a common compatible value "snps,dw-hdmi-tx" here:

compatible = "fsl,imx6q-hdmi", "snps,dw-hdmi-tx";


   How about "snps,dw-hdmi", because the driver is not only about
hdmi tx, but also include hdmi phy.

Synopsys call the whole module
"DesignWare HDMI Transmitter (TX) IP Solution":

https://www.synopsys.com/dw/ipdir.php?ds=dwc_hdmi_14_csds_tx
https://www.synopsys.com/dw/ipdir.php?ds=dwc_hdmi_20_csds_tx

That includes the PHY. I'd prefer keeping the -tx in there to
differentiate from a possible future "snps,dw-hdmi-rx":

https://www.synopsys.com/dw/ipdir.php?ds=dwc_hdmi_14_csds_rx
https://www.synopsys.com/dw/ipdir.php?ds=dwc_hdmi_20_csds_rx


  Ok, I will add the compatible "snps, dw-hdmi-tx",
   So do I need to add this value to imx6dl.dtsi?

If we add such compatible value, do we have to implement another
 platform driver like dw_hdmi-pltfm.c with the
compatible="snps,dw-hdmi" ,
 or just include the compatible value in dw_hdmi-imx.c and
dw_hdmi-rockchip.c?

That common compatible doesn't have to be used by any driver. It's just
there to show these are the same/similar IP core.
If a common driver without any SoC specific knowledge could be written,
that one would match against the common compatible.

regards
Philipp


___
Linux-rockchip mailing list
linux-rockc...@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip






--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v15 06/12] dt-bindings: add document for dw_hdmi

2014-12-02 Thread Andy Yan

Hi Philipp:
On 2014年12月03日 02:23, Philipp Zabel wrote:

Hi Andy,

Am Dienstag, den 02.12.2014, 15:42 +0800 schrieb Andy Yan:

diff --git a/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt 
b/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt
new file mode 100644
index 000..107c1ca
--- /dev/null
+++ b/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt
@@ -0,0 +1,40 @@
+DesignWare HDMI bridge bindings
+
+Required properities:
+- compatible: platform specific such as:
+   * "fsl,imx6q-hdmi"
+   * "fsl,imx6dl-hdmi"
+   * "rockchip,rk3288-dw-hdmi"

I think we should add a common compatible value "snps,dw-hdmi-tx" here:

compatible = "fsl,imx6q-hdmi", "snps,dw-hdmi-tx";


 How about "snps,dw-hdmi", because the driver is not only about
  hdmi tx, but also include hdmi phy.
  If we add such compatible value, do we have to implement another
   platform driver like dw_hdmi-pltfm.c with the 
compatible="snps,dw-hdmi" ,
   or just include the compatible value in dw_hdmi-imx.c and 
dw_hdmi-rockchip.c?

+- reg: Physical base address and length of the controller's registers.
+- ddc-i2c-bus: phandle of an I2C controller used for DDC EDID probing

Better make ddc-i2c-bus optional, see the other thread about the ddc i2c
master.


+- interrupts: The HDMI interrupt number
+
+Optional properties
+- reg-io-width: the width of the reg:1,4, default set to 1 if not present
+
+Example:
+   hdmi: hdmi@012 {
+   compatible = "fsl,imx6q-hdmi";
+   reg = <0x0012 0x9000>;
+   interrupts = <0 115 0x04>;
+   gpr = <&gpr>;
+   clocks = <&clks 123>, <&clks 124>;
+   clock-names = "iahb", "isfr";
+   ddc-i2c-bus = <&i2c2>;
+
+   port@0 {
+   reg = <0>;
+
+   hdmi_mux_0: endpoint {
+   remote-endpoint = <&ipu1_di0_hdmi>;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+
+   hdmi_mux_1: endpoint {
+   remote-endpoint = <&ipu1_di1_hdmi>;
+   };
+   };
+   };

regards
Philipp


___
Linux-rockchip mailing list
linux-rockc...@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-rockchip






--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH v15 12/12] drm: bridge/dw_hdmi: add rockchip rk3288 support

2014-12-02 Thread Andy Yan

Hi Philipp:
On 2014年12月02日 18:24, Philipp Zabel wrote:

Hi Andy,

Am Dienstag, den 02.12.2014, 15:45 +0800 schrieb Andy Yan:
[...]

+static int dw_hdmi_rockchip_bind(struct device *dev, struct device *master,
+void *data)
+{
+   struct platform_device *pdev = to_platform_device(dev);
+   const struct dw_hdmi_plat_data *plat_data;
+   const struct of_device_id *match;
+   struct drm_device *drm = data;
+   struct drm_encoder *encoder;
+   struct rockchip_hdmi *hdmi;
+   int ret;
+
+   if (!pdev->dev.of_node)
+   return -ENODEV;
+
+   hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL);
+   if (!hdmi)
+   return -ENOMEM;
+
+   match = of_match_node(dw_hdmi_rockchip_ids, pdev->dev.of_node);
+   plat_data = match->data;
+   hdmi->dev = &pdev->dev;
+   encoder = &hdmi->encoder;
+   platform_set_drvdata(pdev, hdmi);
+
+   ret = rockchip_hdmi_parse_dt(hdmi);
+   if (ret) {
+   dev_err(hdmi->dev, "Unable to parse OF data\n");
+   return ret;
+   }
+
+   ret = clk_prepare_enable(hdmi->clk);
+   if (ret) {
+   dev_err(hdmi->dev, "Cannot enable HDMI clock: %d\n", ret);
+   return ret;
+   }
+
+   ret = clk_prepare_enable(hdmi->hdcp_clk);
+   if (ret) {
+   dev_err(hdmi->dev, "Cannot enable HDMI hdcp clock: %d\n", ret);
+   return ret;
+   }

Could we have a look at the clocks again? Basically the Rockchip clock
handling is exactly the same, except the clocks are called by other
names.

On i.MX6, according to the reference manual, the HDMI TX module has four
clock inputs: "iahbclk" (bus clock), "icecclk" (32 kHz CEC clock),
"ihclk" (module clock), and "isfrclk" (27 MHz internal SFR clock).
The "iahbclk" and "ihclk" are both sourced from the SoC AHB root clock,
the 32 kHz reference input can't be gated, and the "isfrclk" has its own
gate.

Does the HDMI TX implementation on Rockchip still have the separate
external sfr bus and module clock inputs? I assume that your "clk" input
is a single gate bit for bus and module clocks at the same time?
If possible, I'd prefer to find a common binding for the clocks with
some of the clocks being optional, but for that we need to know the
actual clock inputs to the HDMI TX module.

regards
Philipp

There are three  individual clock inputs on Rockchip RK3288 HDMI: 
"hdmi_ctrl_clk",
"hdmi_cec_clk", "hdmi_hdcp_clk", the three clocks are responsible 
for different
 functions as their name described, and have their own private gate 
bit. That is
 to say, the cec_clk and hdcp_clk can all be disabled if we don't 
need hdcp and cec

 function.
 So I think it's better to make the clk control platform independent.

Heiko, do you have any suggestions?






--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v15 12/12] drm: bridge/dw_hdmi: add rockchip rk3288 support

2014-12-01 Thread Andy Yan
Rockchip RK3288 hdmi is compatible with dw_hdmi

this patch is depend on patch by Mark Yao Add drm
driver for Rockchip Socs

see https://lkml.org/lkml/2014/11/19/1153

Signed-off-by: Andy Yan 

---

Changes in v15:
- remove THIS_MODULE in platform driver

Changes in v14: None
Changes in v13: None
Changes in v12:
- add comment for the depend on patch

Changes in v11: None
Changes in v10:
- add more display mode support mpll configuration for rk3288

Changes in v9:
- move some phy configuration to platform driver

Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/bridge/dw_hdmi.c|   3 +
 drivers/gpu/drm/rockchip/Kconfig|  10 +
 drivers/gpu/drm/rockchip/Makefile   |   2 +-
 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c | 354 
 include/drm/bridge/dw_hdmi.h|   1 +
 5 files changed, 369 insertions(+), 1 deletion(-)
 create mode 100644 drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index 961693a..8772abd 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -849,6 +849,9 @@ static int hdmi_phy_configure(struct dw_hdmi *hdmi, 
unsigned char prep,
dw_hdmi_phy_gen2_txpwron(hdmi, 1);
dw_hdmi_phy_gen2_pddq(hdmi, 0);
 
+   if (hdmi->dev_type == RK3288_HDMI)
+   dw_hdmi_phy_enable_spare(hdmi, 1);
+
/*Wait for PHY PLL lock */
msec = 5;
do {
diff --git a/drivers/gpu/drm/rockchip/Kconfig b/drivers/gpu/drm/rockchip/Kconfig
index 0ff6682..06371ae 100644
--- a/drivers/gpu/drm/rockchip/Kconfig
+++ b/drivers/gpu/drm/rockchip/Kconfig
@@ -15,3 +15,13 @@ config DRM_ROCKCHIP
  management to userspace. This driver does not provide
  2D or 3D acceleration; acceleration is performed by other
  IP found on the SoC.
+
+config ROCKCHIP_DW_HDMI
+bool "Rockchip specific extensions for Synopsys DW HDMI"
+depends on DRM_ROCKCHIP
+select DRM_DW_HDMI
+help
+ This selects support for Rockchip SoC specific extensions
+ for the Synopsys DesignWare HDMI driver. If you want to
+ enable HDMI on RK3288 based SoC, you should selet this
+ option.
diff --git a/drivers/gpu/drm/rockchip/Makefile 
b/drivers/gpu/drm/rockchip/Makefile
index b3a5193..347e65c 100644
--- a/drivers/gpu/drm/rockchip/Makefile
+++ b/drivers/gpu/drm/rockchip/Makefile
@@ -4,5 +4,5 @@
 
 rockchipdrm-y := rockchip_drm_drv.o rockchip_drm_fb.o rockchip_drm_fbdev.o \
rockchip_drm_gem.o rockchip_drm_vop.o
-
+rockchipdrm-$(CONFIG_ROCKCHIP_DW_HDMI) += dw_hdmi-rockchip.o
 obj-$(CONFIG_DRM_ROCKCHIP) += rockchipdrm.o
diff --git a/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c 
b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
new file mode 100644
index 000..99144f8
--- /dev/null
+++ b/drivers/gpu/drm/rockchip/dw_hdmi-rockchip.c
@@ -0,0 +1,354 @@
+/*
+ * Copyright (c) 2014, Fuzhou Rockchip Electronics Co., Ltd
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "rockchip_drm_drv.h"
+#include "rockchip_drm_vop.h"
+
+#define GRF_SOC_CON60x025c
+#define HDMI_SEL_VOP_LIT(1 << 4)
+
+struct rockchip_hdmi {
+   struct device *dev;
+   struct clk *clk;
+   struct clk *hdcp_clk;
+   struct regmap *regmap;
+   struct drm_encoder encoder;
+};
+
+#define to_rockchip_hdmi(x)container_of(x, struct rockchip_hdmi, x)
+
+static const struct dw_hdmi_mpll_config rockchip_mpll_cfg[] = {
+   {
+   2700, {
+   { 0x00b3, 0x},
+   { 0x2153, 0x},
+   { 0x40f3, 0x}
+   },
+   }, {
+   3600, {
+   { 0x00b3, 0x},
+   { 0x2153, 0x},
+   { 0x40f3, 0x}
+   },
+   }, {
+   4000, {
+   { 0x00b3, 0x},
+   { 0x2153, 0x},
+   { 0x40f3, 0x}
+   },
+   }, {
+   5400, {
+   { 0x0072, 0x0001},
+   { 0x2142, 0x0001},
+   { 0x40a2, 0x0001},
+   },
+   }, {
+   6500, {
+   { 0x0072, 0x0001},
+   { 0x2142, 0x0001},
+   { 0x40a2, 0x0001},
+   },
+   }, {
+   6600, {
+

[PATCH v15 11/12] dt-bindings: Add documentation for rockchip dw hdmi

2014-12-01 Thread Andy Yan
Signed-off-by: Andy Yan 

---

Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8:
- Add documentation for rockchip dw hdmi

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 .../devicetree/bindings/video/dw_hdmi-rockchip.txt | 43 ++
 1 file changed, 43 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt

diff --git a/Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt 
b/Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt
new file mode 100644
index 000..0735464
--- /dev/null
+++ b/Documentation/devicetree/bindings/video/dw_hdmi-rockchip.txt
@@ -0,0 +1,43 @@
+Rockchip specific extensions to the Synopsys Designware HDMI
+
+
+Required properties:
+- compatible: "rockchip,rk3288-dw-hdmi";
+- reg: Physical base address and length of the controller's registers.
+- ddc-i2c-bus:  phandle of an I2C controller used for DDC EDID probing
+- clocks: from common clock binding: handle to hdmi clock.
+- clock-names: should be "clk" "hdcp_clk"
+- rockchip,grf: this soc should set GRF regs to mux vopl/vopb.
+- interrupts: HDMI interrupt number
+- ports: contain a port node with endpoint definitions as defined in
+  Documentation/devicetree/bindings/media/video-interfaces.txt. For
+  vopb,set the reg = <0> and set the reg = <1> for vopl.
+- reg-io-width: the width of the reg:1,4, the value should be 4 on
+  rk3288 platform
+
+Example:
+hdmi: hdmi@ff98 {
+   compatible = "rockchip,rk3288-dw-hdmi";
+   reg = <0xff98 0x2>;
+   reg-io-width = <4>;
+   ddc-i2c-bus = <&i2c5>;
+   rockchip,grf = <&grf>;
+   interrupts = ;
+   clocks = <&cru  PCLK_HDMI_CTRL>, <&cru SCLK_HDMI_HDCP>;
+   clock-names = "clk", "hdcp_clk";
+   status = "disabled";
+   ports {
+   hdmi_in: port {
+   #address-cells = <1>;
+   #size-cells = <0>;
+   hdmi_in_vopb: endpoint@0 {
+   reg = <0>;
+   remote-endpoint = <&vopb_out_hdmi>;
+   };
+   hdmi_in_vopl: endpoint@1 {
+   reg = <1>;
+   remote-endpoint = <&vopl_out_hdmi>;
+   };
+   };
+   };
+};
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v15 10/12] drm: bridge/dw_hdmi: add function dw_hdmi_phy_enable_spare

2014-12-01 Thread Andy Yan
RK3288 HDMI will not work without the spare bit of
HDMI_PHY_CONF0 enable

Signed-off-by: Andy Yan 
---

Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/bridge/dw_hdmi.c | 7 +++
 drivers/gpu/drm/bridge/dw_hdmi.h | 3 ++-
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index 13ace4e..961693a 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -710,6 +710,13 @@ static void dw_hdmi_phy_enable_tmds(struct dw_hdmi *hdmi, 
u8 enable)
 HDMI_PHY_CONF0_ENTMDS_MASK);
 }
 
+static void dw_hdmi_phy_enable_spare(struct dw_hdmi *hdmi, u8 enable)
+{
+   hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0,
+HDMI_PHY_CONF0_SPARECTRL_OFFSET,
+HDMI_PHY_CONF0_SPARECTRL_MASK);
+}
+
 static void dw_hdmi_phy_gen2_pddq(struct dw_hdmi *hdmi, u8 enable)
 {
hdmi_mask_writeb(hdmi, enable, HDMI_PHY_CONF0,
diff --git a/drivers/gpu/drm/bridge/dw_hdmi.h b/drivers/gpu/drm/bridge/dw_hdmi.h
index baa7849..175dbc8 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.h
+++ b/drivers/gpu/drm/bridge/dw_hdmi.h
@@ -837,7 +837,8 @@ enum {
HDMI_PHY_CONF0_PDZ_OFFSET = 7,
HDMI_PHY_CONF0_ENTMDS_MASK = 0x40,
HDMI_PHY_CONF0_ENTMDS_OFFSET = 6,
-   HDMI_PHY_CONF0_SPARECTRL = 0x20,
+   HDMI_PHY_CONF0_SPARECTRL_MASK = 0x20,
+   HDMI_PHY_CONF0_SPARECTRL_OFFSET = 5,
HDMI_PHY_CONF0_GEN2_PDDQ_MASK = 0x10,
HDMI_PHY_CONF0_GEN2_PDDQ_OFFSET = 4,
HDMI_PHY_CONF0_GEN2_TXPWRON_MASK = 0x8,
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v15 09/12] drm: bridge/dw_hdmi: clear i2cmphy_stat0 reg in hdmi_phy_wait_i2c_done

2014-12-01 Thread Andy Yan
HDMI_IH_I2CMPHY_STAT0 is a clear on write register, which indicates i2cm
operation status(i2c transfer done or error), every hdmi phy register
configuration must check this register to make sure the configuration
has complete. But the indication bit should be cleared after check, otherwise
the corresponding bit will hold on forever, this may give a wrong signal for
next check.

Signed-off-by: Andy Yan 
---

Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/bridge/dw_hdmi.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index 65cb077..13ace4e 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -663,11 +663,15 @@ static inline void hdmi_phy_test_dout(struct dw_hdmi 
*hdmi,
 
 static bool hdmi_phy_wait_i2c_done(struct dw_hdmi *hdmi, int msec)
 {
-   while ((hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3) == 0) {
+   u32 val;
+
+   while ((val = hdmi_readb(hdmi, HDMI_IH_I2CMPHY_STAT0) & 0x3) == 0) {
if (msec-- == 0)
return false;
udelay(1000);
}
+   hdmi_writeb(hdmi, val, HDMI_IH_I2CMPHY_STAT0);
+
return true;
 }
 
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v15 08/12] drm: bridge/dw_hdmi: add mode_valid support

2014-12-01 Thread Andy Yan
some platform may not support all the display mode,
add mode_valid interface check it

Signed-off-by: Andy Yan 

---

Changes in v15: None
Changes in v14:
- remove drm_connector_register, because imx-drm core has registered
connector

Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/bridge/dw_hdmi.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index 0e8afd6..65cb077 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -1402,6 +1402,20 @@ static int dw_hdmi_connector_get_modes(struct 
drm_connector *connector)
return 0;
 }
 
+static enum drm_mode_status
+dw_hdmi_connector_mode_valid(struct drm_connector *connector,
+struct drm_display_mode *mode)
+{
+   struct dw_hdmi *hdmi = container_of(connector,
+  struct dw_hdmi, connector);
+   enum drm_mode_status mode_status = MODE_OK;
+
+   if (hdmi->plat_data->mode_valid)
+   mode_status = hdmi->plat_data->mode_valid(connector, mode);
+
+   return mode_status;
+}
+
 static struct drm_encoder *dw_hdmi_connector_best_encoder(struct drm_connector
   *connector)
 {
@@ -1426,6 +1440,7 @@ static struct drm_connector_funcs dw_hdmi_connector_funcs 
= {
 
 static struct drm_connector_helper_funcs dw_hdmi_connector_helper_funcs = {
.get_modes = dw_hdmi_connector_get_modes,
+   .mode_valid = dw_hdmi_connector_mode_valid,
.best_encoder = dw_hdmi_connector_best_encoder,
 };
 
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v15 07/12] drm: bridge/dw_hdmi: add support for multi-byte register width access

2014-12-01 Thread Andy Yan
On rockchip rk3288, only word(32-bit) accesses are
permitted for hdmi registers.  Byte width accesses (writeb,
readb) generate an imprecise external abort.

Signed-off-by: Andy Yan 

---

Changes in v15:
- remove unio of the multi-byte register access, adviced by Philipp Zabel

Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6:
- refactor register access without reg_shift

Changes in v5:
- refactor reg-io-width

Changes in v4: None
Changes in v3:
- split multi-register access to one indepent patch

 drivers/gpu/drm/bridge/dw_hdmi.c | 44 ++--
 1 file changed, 42 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/dw_hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
index 6f5b70a..0e8afd6 100644
--- a/drivers/gpu/drm/bridge/dw_hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -125,18 +125,41 @@ struct dw_hdmi {
 
unsigned int sample_rate;
int ratio;
+
+   void (*write)(struct dw_hdmi *hdmi, u8 val, int offset);
+   u8 (*read)(struct dw_hdmi *hdmi, int offset);
 };
 
-static inline void hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset)
+static void dw_hdmi_writel(struct dw_hdmi *hdmi, u8 val, int offset)
+{
+   writel(val, hdmi->regs + (offset << 2));
+}
+
+static u8 dw_hdmi_readl(struct dw_hdmi *hdmi, int offset)
+{
+   return readl(hdmi->regs + (offset << 2));
+}
+
+static void dw_hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset)
 {
writeb(val, hdmi->regs + offset);
 }
 
-static inline u8 hdmi_readb(struct dw_hdmi *hdmi, int offset)
+static u8 dw_hdmi_readb(struct dw_hdmi *hdmi, int offset)
 {
return readb(hdmi->regs + offset);
 }
 
+static inline void hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset)
+{
+   hdmi->write(hdmi, val, offset);
+}
+
+static inline u8 hdmi_readb(struct dw_hdmi *hdmi, int offset)
+{
+   return hdmi->read(hdmi, offset);
+}
+
 static void hdmi_modb(struct dw_hdmi *hdmi, u8 data, u8 mask, unsigned reg)
 {
u8 val = hdmi_readb(hdmi, reg) & ~mask;
@@ -1509,6 +1532,7 @@ int dw_hdmi_bind(struct device *dev, struct device 
*master,
struct dw_hdmi *hdmi;
struct resource *iores;
int ret, irq;
+   u32 val = 1;
 
hdmi = devm_kzalloc(&pdev->dev, sizeof(*hdmi), GFP_KERNEL);
if (!hdmi)
@@ -1521,6 +1545,22 @@ int dw_hdmi_bind(struct device *dev, struct device 
*master,
hdmi->ratio = 100;
hdmi->encoder = encoder;
 
+   of_property_read_u32(np, "reg-io-width", &val);
+
+   switch (val) {
+   case 4:
+   hdmi->write = dw_hdmi_writel;
+   hdmi->read = dw_hdmi_readl;
+   break;
+   case 1:
+   hdmi->write = dw_hdmi_writeb;
+   hdmi->read = dw_hdmi_readb;
+   break;
+   default:
+   dev_err(dev, "reg-io-width must be 1 or 4\n");
+   return -EINVAL;
+   }
+
ddc_node = of_parse_phandle(np, "ddc-i2c-bus", 0);
if (ddc_node) {
hdmi->ddc = of_find_i2c_adapter_by_node(ddc_node);
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v15 06/12] dt-bindings: add document for dw_hdmi

2014-12-01 Thread Andy Yan
Signed-off-by: Andy Yan 

---

Changes in v15: None
Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8:
- correct some spelling mistake
- modify ddc-i2c-bus and interrupt description

Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 .../devicetree/bindings/drm/bridge/dw_hdmi.txt | 40 ++
 1 file changed, 40 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt

diff --git a/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt 
b/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt
new file mode 100644
index 000..107c1ca
--- /dev/null
+++ b/Documentation/devicetree/bindings/drm/bridge/dw_hdmi.txt
@@ -0,0 +1,40 @@
+DesignWare HDMI bridge bindings
+
+Required properities:
+- compatible: platform specific such as:
+   * "fsl,imx6q-hdmi"
+   * "fsl,imx6dl-hdmi"
+   * "rockchip,rk3288-dw-hdmi"
+- reg: Physical base address and length of the controller's registers.
+- ddc-i2c-bus: phandle of an I2C controller used for DDC EDID probing
+- interrupts: The HDMI interrupt number
+
+Optional properties
+- reg-io-width: the width of the reg:1,4, default set to 1 if not present
+
+Example:
+   hdmi: hdmi@012 {
+   compatible = "fsl,imx6q-hdmi";
+   reg = <0x0012 0x9000>;
+   interrupts = <0 115 0x04>;
+   gpr = <&gpr>;
+   clocks = <&clks 123>, <&clks 124>;
+   clock-names = "iahb", "isfr";
+   ddc-i2c-bus = <&i2c2>;
+
+   port@0 {
+   reg = <0>;
+
+   hdmi_mux_0: endpoint {
+   remote-endpoint = <&ipu1_di0_hdmi>;
+   };
+   };
+
+   port@1 {
+   reg = <1>;
+
+   hdmi_mux_1: endpoint {
+   remote-endpoint = <&ipu1_di1_hdmi>;
+   };
+   };
+   };
-- 
1.9.1


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v15 05/12] drm: imx: imx-hdmi: move imx-hdmi to bridge/dw_hdmi

2014-12-01 Thread Andy Yan
the original imx hdmi driver is under drm/imx/,
which depends on imx-drm, so move the imx hdmi
driver out to drm/bridge and rename it to dw_hdmi

Signed-off-by: Andy Yan 

---

Changes in v15:
- add prefix dw_hdmi/DW_HDMI for public used dw_hdmi structs
  adviced by Philipp Zabel
- remove THIS_MODULE in platform driver

Changes in v14: None
Changes in v13: None
Changes in v12: None
Changes in v11: None
Changes in v10: None
Changes in v9: None
Changes in v8: None
Changes in v7: None
Changes in v6: None
Changes in v5: None
Changes in v4: None
Changes in v3: None

 drivers/gpu/drm/bridge/Kconfig |   5 +
 drivers/gpu/drm/bridge/Makefile|   1 +
 .../gpu/drm/{imx/imx-hdmi.c => bridge/dw_hdmi.c}   | 282 +++--
 .../gpu/drm/{imx/imx-hdmi.h => bridge/dw_hdmi.h}   |  42 ---
 drivers/gpu/drm/imx/Kconfig|   1 +
 drivers/gpu/drm/imx/Makefile   |   2 +-
 .../drm/imx/{imx-hdmi_pltfm.c => dw_hdmi-imx.c}| 129 +-
 include/drm/bridge/dw_hdmi.h   |  59 +
 8 files changed, 272 insertions(+), 249 deletions(-)
 rename drivers/gpu/drm/{imx/imx-hdmi.c => bridge/dw_hdmi.c} (83%)
 rename drivers/gpu/drm/{imx/imx-hdmi.h => bridge/dw_hdmi.h} (98%)
 rename drivers/gpu/drm/imx/{imx-hdmi_pltfm.c => dw_hdmi-imx.c} (58%)
 create mode 100644 include/drm/bridge/dw_hdmi.h

diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index 884923f..26162ef 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -3,3 +3,8 @@ config DRM_PTN3460
depends on DRM
select DRM_KMS_HELPER
---help---
+
+config DRM_DW_HDMI
+   bool "Synopsys DesignWare High-Definition Multimedia Interface"
+   depends on DRM
+   select DRM_KMS_HELPER
diff --git a/drivers/gpu/drm/bridge/Makefile b/drivers/gpu/drm/bridge/Makefile
index b4733e1..d8a8cfd 100644
--- a/drivers/gpu/drm/bridge/Makefile
+++ b/drivers/gpu/drm/bridge/Makefile
@@ -1,3 +1,4 @@
 ccflags-y := -Iinclude/drm
 
 obj-$(CONFIG_DRM_PTN3460) += ptn3460.o
+obj-$(CONFIG_DRM_DW_HDMI) += dw_hdmi.o
diff --git a/drivers/gpu/drm/imx/imx-hdmi.c b/drivers/gpu/drm/bridge/dw_hdmi.c
similarity index 83%
rename from drivers/gpu/drm/imx/imx-hdmi.c
rename to drivers/gpu/drm/bridge/dw_hdmi.c
index 99c2966..6f5b70a 100644
--- a/drivers/gpu/drm/imx/imx-hdmi.c
+++ b/drivers/gpu/drm/bridge/dw_hdmi.c
@@ -6,12 +6,11 @@
  * the Free Software Foundation; either version 2 of the License, or
  * (at your option) any later version.
  *
- * SH-Mobile High-Definition Multimedia Interface (HDMI) driver
- * for SLISHDMI13T and SLIPHDMIT IP cores
+ * Designware High-Definition Multimedia Interface (HDMI) driver
  *
  * Copyright (C) 2010, Guennadi Liakhovetski 
  */
-
+#include 
 #include 
 #include 
 #include 
@@ -23,8 +22,9 @@
 #include 
 #include 
 #include 
+#include 
 
-#include "imx-hdmi.h"
+#include "dw_hdmi.h"
 
 #define HDMI_EDID_LEN  512
 
@@ -100,16 +100,17 @@ struct hdmi_data_info {
struct hdmi_vmode video_mode;
 };
 
-struct imx_hdmi {
+struct dw_hdmi {
struct drm_connector connector;
struct drm_encoder *encoder;
struct drm_bridge *bridge;
 
-   enum imx_hdmi_devtype dev_type;
+   enum dw_hdmi_devtype dev_type;
struct device *dev;
 
struct hdmi_data_info hdmi_data;
-   const struct imx_hdmi_plat_data *plat_data;
+   const struct dw_hdmi_plat_data *plat_data;
+
int vic;
 
u8 edid[HDMI_EDID_LEN];
@@ -126,17 +127,17 @@ struct imx_hdmi {
int ratio;
 };
 
-static inline void hdmi_writeb(struct imx_hdmi *hdmi, u8 val, int offset)
+static inline void hdmi_writeb(struct dw_hdmi *hdmi, u8 val, int offset)
 {
writeb(val, hdmi->regs + offset);
 }
 
-static inline u8 hdmi_readb(struct imx_hdmi *hdmi, int offset)
+static inline u8 hdmi_readb(struct dw_hdmi *hdmi, int offset)
 {
return readb(hdmi->regs + offset);
 }
 
-static void hdmi_modb(struct imx_hdmi *hdmi, u8 data, u8 mask, unsigned reg)
+static void hdmi_modb(struct dw_hdmi *hdmi, u8 data, u8 mask, unsigned reg)
 {
u8 val = hdmi_readb(hdmi, reg) & ~mask;
 
@@ -144,13 +145,13 @@ static void hdmi_modb(struct imx_hdmi *hdmi, u8 data, u8 
mask, unsigned reg)
hdmi_writeb(hdmi, val, reg);
 }
 
-static void hdmi_mask_writeb(struct imx_hdmi *hdmi, u8 data, unsigned int reg,
+static void hdmi_mask_writeb(struct dw_hdmi *hdmi, u8 data, unsigned int reg,
 u8 shift, u8 mask)
 {
hdmi_modb(hdmi, data << shift, mask, reg);
 }
 
-static void hdmi_set_clock_regenerator_n(struct imx_hdmi *hdmi,
+static void hdmi_set_clock_regenerator_n(struct dw_hdmi *hdmi,
 unsigned int value)
 {
hdmi_writeb(hdmi, value & 0xff, HDMI_AUD_N1);
@@ -161,7 +162,7 @@ static void hdmi_set_clock_regenerator_n(struct imx_hdmi 
*hdmi,

  1   2   3   >