Re: [v2, 3/3] ARM: dts: AM33XX: Add NAND flash device tree data to am335x-evm

2013-05-30 Thread Benoit Cousson
Hi Pekon,

On 05/20/2013 06:44 AM, Gupta, Pekon wrote:
>  
>
>   am33xx_pinmux: pinmux@44e10800 {
>   pinctrl-names = "default";
> - pinctrl-0 = <&matrix_keypad_s0 &volume_keys_s0>;
> + pinctrl-0 = <&matrix_keypad_s0 &volume_keys_s0
> + &nandflash_pins_s0>;

 Why add this to the board level fallback (called pinctrl hogs, I think)?
 This can be part of nand node you added below so that the pinctrl will
 take effect when nand gets probed instead of all the time.
>>>
>>> Yes we should have all the pinctrl entries under the related drivers.
>>> This makes it easy remux pins during runtime if needed, and also
>>> allows unloading pinctrl-single.ko for development.
>>>
>> Yes, accepted. This has been already fixed in v3 of this patch set.
>> If all fine, then please pull this for next merge..
>>
>> http://lists.infradead.org/pipermail/linux-mtd/2013-May/046712.html
>>
>> http://lists.infradead.org/pipermail/linux-mtd/2013-May/046814.html
>>
>> http://lists.infradead.org/pipermail/linux-mtd/2013-May/046710.html
>>
>>
>> with regards, pekon
> 
> Request you to please accept | provide feedbacks on this patch series.
> These are waiting acceptance since Jan-2013, and are necessary for 
> DT based configs for board having NAND support.
> 
> with regards, pekon

Sorry, I missed that series.

I'm applying it right now.

Thanks,
Benoit


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


RE: [v2, 3/3] ARM: dts: AM33XX: Add NAND flash device tree data to am335x-evm

2013-05-30 Thread Gupta, Pekon
 
> Sorry, I missed that series.
> 
> I'm applying it right now.
> 
No issues.. Please pick newer v4 versions of this series.
Following are rebased, updated and tested on linux-3.10-rc3

[PATCH v4,0/3] http://www.spinics.net/lists/linux-omap/msg91165.html

[PATCH v4,1/3] http://www.spinics.net/lists/linux-omap/msg91166.html

[PATCH v4,2/3] (please skip this one)
instead pick http://www.spinics.net/lists/linux-omap/msg91161.html

[PATCH v4,3/3] http://www.spinics.net/lists/linux-omap/msg91167.html


Thanks..
with regards, pekon
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


RE: [v2, 3/3] ARM: dts: AM33XX: Add NAND flash device tree data to am335x-evm

2013-05-30 Thread Gupta, Pekon
> > Sorry, I missed that series.
> >
> > I'm applying it right now.
> >
> No issues.. Please pick newer v4 versions of this series.
> Following are rebased, updated and tested on linux-3.10-rc3
> 
> [PATCH v4,0/3] http://www.spinics.net/lists/linux-omap/msg91165.html
> 
> [PATCH v4,1/3] http://www.spinics.net/lists/linux-omap/msg91166.html
> 
> [PATCH v4,2/3] (please skip this one)
> instead pick http://www.spinics.net/lists/linux-omap/msg91161.html
> 
> [PATCH v4,3/3] (typo) 
http://www.spinics.net/lists/linux-omap/msg91164.html
> 
> 
> Thanks..
> with regards, pekon
> 
> __
> Linux MTD discussion mailing list
> http://lists.infradead.org/mailman/listinfo/linux-mtd/
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [v2, 3/3] ARM: dts: AM33XX: Add NAND flash device tree data to am335x-evm

2013-05-30 Thread Benoit Cousson
On 05/30/2013 09:31 AM, Gupta, Pekon wrote:
>> Sorry, I missed that series.
>>
>> I'm applying it right now.
>>
> No issues.. Please pick newer v4 versions of this series.
> Following are rebased, updated and tested on linux-3.10-rc3
> 
> [PATCH v4,0/3] http://www.spinics.net/lists/linux-omap/msg91165.html
> 
> [PATCH v4,1/3] http://www.spinics.net/lists/linux-omap/msg91166.html
> 
> [PATCH v4,2/3] (please skip this one)
> instead pick http://www.spinics.net/lists/linux-omap/msg91161.html
> 
> [PATCH v4,3/3] http://www.spinics.net/lists/linux-omap/msg91167.html

Could you please rebase on for_3.11/dts and repost the whole stuff. It
looks like Tony already pulled the GPMC node, and the two other ones
cannot apply anymore.

Thanks,
Benoit

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


[PATCH] ASoC: OMAP: Remove obsolete Makefile line

2013-05-30 Thread Paul Bolle
Support for omap2evm was removed in v3.0. But only one of its two
lines in this Makefile was removed. Remove the second line too.

Signed-off-by: Paul Bolle 
---
Eyeball tested only.

 sound/soc/omap/Makefile | 1 -
 1 file changed, 1 deletion(-)

diff --git a/sound/soc/omap/Makefile b/sound/soc/omap/Makefile
index 2b22594..a725905 100644
--- a/sound/soc/omap/Makefile
+++ b/sound/soc/omap/Makefile
@@ -26,7 +26,6 @@ obj-$(CONFIG_SND_OMAP_SOC_N810) += snd-soc-n810.o
 obj-$(CONFIG_SND_OMAP_SOC_RX51) += snd-soc-rx51.o
 obj-$(CONFIG_SND_OMAP_SOC_AMS_DELTA) += snd-soc-ams-delta.o
 obj-$(CONFIG_SND_OMAP_SOC_OSK5912) += snd-soc-osk5912.o
-obj-$(CONFIG_SND_OMAP_SOC_OMAP2EVM) += snd-soc-omap2evm.o
 obj-$(CONFIG_SND_OMAP_SOC_AM3517EVM) += snd-soc-am3517evm.o
 obj-$(CONFIG_SND_OMAP_SOC_OMAP_ABE_TWL6040) += snd-soc-omap-abe-twl6040.o
 obj-$(CONFIG_SND_OMAP_SOC_OMAP_TWL4030) += snd-soc-omap-twl4030.o
-- 
1.7.11.7

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


Re: [net-next PATCH v3 1/6] net: cpsw: enhance pinctrl support

2013-05-30 Thread Mugunthan V N

On 5/28/2013 7:35 PM, Mugunthan V N wrote:

On 5/28/2013 3:06 AM, Tony Lindgren wrote:

* Mugunthan V N  [130526 11:28]:

From: Hebbar Gururaja 

Amend cpsw controller to optionally take a pin control handle and set
the state of the pins to:

- "default" on boot, resume
- "sleep" on suspend()

This should make it possible to optimize energy usage for the pins
for the suspend/resume cycle.

If any of the above pin states are missing in dt, a warning message
about the missing state is displayed.
If certain pin-states are not available, to remove this warning message
pass respective state name with null phandler.

Signed-off-by: Hebbar Gururaja 
Signed-off-by: Mugunthan V N 
---
  drivers/net/ethernet/ti/cpsw.c |   48 


  1 file changed, 48 insertions(+)

diff --git a/drivers/net/ethernet/ti/cpsw.c 
b/drivers/net/ethernet/ti/cpsw.c

index 21a5b29..c9ed730 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -35,6 +35,7 @@
  #include 
#include 
+#include 
#include "cpsw_ale.h"
  #include "cpts.h"
@@ -351,6 +352,11 @@ struct cpsw_priv {
  bool irq_enabled;
  struct cpts *cpts;
  u32 emac_port;
+
+/* Two optional pin states - default & sleep */
+struct pinctrl*pinctrl;
+struct pinctrl_state*pins_def;
+struct pinctrl_state*pins_sleep;
  };

Which pins do you need to dynamically remux? If it's not all
the pins, you should have three sets: default, active and idle.
This way the static pins in the default group don't need to be
constantly toggled.

Regards,

Tony

Tony

I am using this for all the pins, in probe all the cpsw pins will be 
configured

and i have used the same in suspend/resume callback for power saving.


Tony

Do you have any comments on this, or is it ok with two pinctrl_state nodes?

Regards
Mugunthan V N

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" 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/1] ARM: omap3: Fix regression in dpll4 child clock frequency setting.

2013-05-30 Thread jean-philippe francois
Hi,

The following patch fixes a wrong container_of usage for omap3630.
All sub clock of dpll4 that do not use a reset value as divider are
affected.

For instance CAM_MCLK is 216 MHz instead of the asked 172,8 MHz
Any user of this clock is affected. This is the case for instance if
CAM_XCLKA is used to provide clock for an external camera.

Beyond wrong frequency setting, this is also a potential oops waiting
to bite any omap3isp user, since a wrong pointer is dereferenced, and
content of this pointer is used to do __raw_writel / __raw_readl.

v2 :
Follow Mike Turquette's comment and use clock framework instead of
directly accessing register.

Regards,
Jean-Philippe François
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2 1/1] ARM : omap3 : fix wrong container_of in clock36xx.c

2013-05-30 Thread Jean-Philippe Francois
omap36xx_pwrdn_clk_enable_with_hsdiv_restore expects the parent hw of the clock
to be a clk_hw_omap. However, looking at cclock3xxx_data.c, all concerned clock
have parent defined as clk_divider. Instead of using container_of to eventually 
get
to the register and directly mess with the divider, change freq via 
clk_set_rate, 
and let the clock framework toggle the divider value.
Tested with  3.9 on dm3730.

Signed-off-by: Jean-Philippe François 

Index: b/arch/arm/mach-omap2/clock36xx.c
===
--- a/arch/arm/mach-omap2/clock36xx.c
+++ b/arch/arm/mach-omap2/clock36xx.c
@@ -39,30 +39,25 @@
  */
 int omap36xx_pwrdn_clk_enable_with_hsdiv_restore(struct clk_hw *clk)
 {
-   struct clk_hw_omap *parent;
-   struct clk_hw *parent_hw;
-   u32 dummy_v, orig_v, clksel_shift;
int ret;
 
/* Clear PWRDN bit of HSDIVIDER */
ret = omap2_dflt_clk_enable(clk);
 
-   parent_hw = __clk_get_hw(__clk_get_parent(clk->clk));
-   parent = to_clk_hw_omap(parent_hw);
-
-   /* Restore the dividers */
+   /* kick parent's clksel register after toggling PWRDN bit */
if (!ret) {
-   clksel_shift = __ffs(parent->clksel_mask);
-   orig_v = __raw_readl(parent->clksel_reg);
-   dummy_v = orig_v;
-
-   /* Write any other value different from the Read value */
-   dummy_v ^= (1 << clksel_shift);
-   __raw_writel(dummy_v, parent->clksel_reg);
-
-   /* Write the original divider */
-   __raw_writel(orig_v, parent->clksel_reg);
+   struct clk *parent = clk_get_parent(clk->clk);
+   unsigned long parent_rate = clk_get_rate(parent);
+   ret = clk_set_rate(parent, parent_rate/2);
+   if(ret)
+   goto badfreq;
+   ret = clk_set_rate(parent, parent_rate);
+   if(ret)
+   goto badfreq;
}
+   return ret;
 
+ badfreq :
+   omap2_dflt_clk_disable(clk);
return ret;
 }
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/1] i2c: omap: correct usage of the interrupt enable register

2013-05-30 Thread Oleksandr Dmytryshyn

On 05/29/2013 08:22 PM, Kevin Hilman wrote:

Oleksandr Dmytryshyn  writes:


Starting from the OMAP chips with version2 registers scheme there are
2 registers (I2C_IRQENABLE_SET and I2C_IRQENABLE_CLR) to manage
interrupts instead of the older OMAP chips with old scheme which have
only one register (I2C_IE).  Now we should use I2C_IRQENABLE_SET
register for enabling interrupts and I2C_IRQENABLE_CLR register for
disabling interrupts.

Why?  (changelogs should always answer the "why" question)

IOW, what is broken without this change, how does it fail?  And equally
important, how is it currently working?

Kevin



Hi, Kevin.

If the i2c controller during suspend will generate an interrupt, it can 
lead to unpredictable behaviour in the kernel.


Based on the logic of the kernel code interrupts from i2c should be 
prohibited during suspend. Kernel writes 0 to the I2C_IE register in the 
omap_i2c_runtime_suspend() function. In the other side kernel writes 
saved interrupt flags to the I2C_IE register in 
omap_i2c_runtime_resume() function. I.e. interrupts should be disabled 
during suspend.


This works for chips with version1 registers scheme. Interrupts are 
disabled during suspend. For chips with version2 scheme registers 
writting 0 to the I2C_IE register does nothing (because now the 
I2C_IRQENABLE_SET register is located at this address ). This register 
is used to enable interrupts. For disabling interrupts I2C_IRQENABLE_CLR 
register should be used.


I've checked that interrupts in the i2c controller are still enabled 
after writting 0 to the I2C_IE register. But with my patch interrupts 
are disabled in the omap_i2c_runtime_suspend() function.


--

Best regards,
Oleksandr Dmytryshyn | OMAP4 Platform
GlobalLogic Inc. | Innovation by Design
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] ARM: OMAP2+: omap-usb-host: clean up pin mux setup code

2013-05-30 Thread Roger Quadros
On 05/09/2013 02:52 AM, Tony Lindgren wrote:
> * Roger Quadros  [130422 03:02]:
>> The USB host pins are named quite differently between OMAP3 and
>> OMAP4+ SoCs. To make this managable in code, we create a pin mapping
>> table (pin_names) that maps pin function to pin name.
>>
>> This pin mapping table is populated at runtime based on a pin
>> name template. Templates are provided for OMAP3 and 4 SoCs.
>>
>> The setup_io_mux() function uses the pin mapping table to
>> setup the pin mux.
>>
>> The resulting code is a lot more clean, manageable and scalable.
> 
> I'm planning to drop all the omap4 pdata soonish. Will post some
> patches after -rc1 to do that. Do you still need this patch
> considering that?
> 

In that case we don't need this.

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


[PATCH 00/32] OMAPDSS: dss-dev-model "base" (Part 1/2)

2013-05-30 Thread Tomi Valkeinen
Hi,

Here's are the first sets of patches targeting towards enabling DT for DSS and
changing the DSS device model to be more versatile. The exact division of the
sets of patches is still a bit open, and some splitting up for arch/driver
changes is needed, but most likely there will be at least the following major
sets, each based on the former one:

- base, containing cleanups and changes that do not yet really bring bigger new
  features
- dev-model, implements the new DSS device model, including new panel drivers
- dt, adds DSS DT support (not at all ready yet, although works for a few 
boards)

The patches can be found from the following branches:

git://gitorious.org/linux-omap-dss2/linux.git work/dss-dev-model-base
git://gitorious.org/linux-omap-dss2/linux.git work/dss-dev-model
git://gitorious.org/linux-omap-dss2/linux.git work/dss-dev-model-dt

The set you are looking at is the "base" set.

The "base" set shouldn't change anything from the user's point of view. It
contains patches that do not make much sense until "dev-model" and "dt" are
merged, but those patches should not cause any problems either. Most likely the
"base" set is quite stable, I don't expect any changes to it.

 Tomi


Tomi Valkeinen (32):
  OMAPDSS: add pdata->default_display_name
  OMAPDSS: only probe pdata if there's one
  OMAPDSS: add omap_dss_find_output()
  OMAPDSS: add omap_dss_find_output_by_node()
  OMAPDSS: fix dss_get_ctx_loss_count for DT
  OMAPDSS: DPI: fix regulators for DT
  OMAPDSS: SDI: fix regulators for DT
  OMAPDSS: clean up dss_[ovl|mgr]_get_device()
  OMAPDSS: add helpers to get mgr or output from display
  OMAPDSS: split overlay manager creation
  OMAPDRM: fix overlay manager handling
  OMAPDSS: Implement display (dis)connect support
  OMAPDSS: CORE: use devm_regulator_get
  OMAPDSS: DSI: cleanup regulator init
  OMAPDSS: DPI: cleanup pll & regulator init
  OMAPDSS: HDMI: add hdmi_init_regulator
  OMAPDSS: SDI: clean up regulator init
  OMAPDSS: VENC: clean up regulator init
  OMAPDSS: add videomode conversion support
  OMAPDSS: remove dssdev uses in trivial cases
  OMAPDSS: add panel list
  OMAPDSS: use the panel list in omap_dss_get_next_device
  OMAPDSS: don't use dss bus in suspend/resume
  OMAPDSS: implement display sysfs without dss bus
  OMAPDSS: Add panel dev pointer to dssdev
  OMAPDSS: remove omap_dss_start/stop_device()
  OMAPDSS: combine omap_dss_output into omap_dss_device
  OMAPDSS: omapdss.h: add owner field to omap_dss_device
  OMAPDSS: add module_get/put to omap_dss_get/put_device()
  OMAPDSS: add THIS_MODULE owner to DSS outputs
  OMAPDSS: output: increase refcount in find_output funcs
  OMAPFB: use EPROBE_DEFER if default display is not present

 drivers/gpu/drm/omapdrm/omap_crtc.c|  46 +++-
 drivers/gpu/drm/omapdrm/omap_drv.c |  21 +-
 drivers/gpu/drm/omapdrm/omap_drv.h |   1 +
 drivers/video/omap2/displays/panel-acx565akm.c |  16 +-
 drivers/video/omap2/displays/panel-generic-dpi.c   |  26 +--
 .../omap2/displays/panel-lgphilips-lb035q02.c  |  10 +-
 drivers/video/omap2/displays/panel-n8x0.c  |  30 +--
 .../omap2/displays/panel-nec-nl8048hl11-01b.c  |   4 +-
 drivers/video/omap2/displays/panel-picodlp.c   |  32 +--
 .../video/omap2/displays/panel-sharp-ls037v7dw01.c |  10 +-
 drivers/video/omap2/displays/panel-taal.c  | 164 +++---
 drivers/video/omap2/displays/panel-tfp410.c|  32 +--
 .../video/omap2/displays/panel-tpo-td043mtea1.c|  36 +--
 drivers/video/omap2/dss/Kconfig|   1 +
 drivers/video/omap2/dss/apply.c|  47 ++--
 drivers/video/omap2/dss/core.c | 108 +
 drivers/video/omap2/dss/dispc.c|   4 +
 drivers/video/omap2/dss/display-sysfs.c| 154 +++--
 drivers/video/omap2/dss/display.c  | 246 ++---
 drivers/video/omap2/dss/dpi.c  | 140 ++--
 drivers/video/omap2/dss/dsi.c  | 124 ---
 drivers/video/omap2/dss/dss.c  |   3 +-
 drivers/video/omap2/dss/dss.h  |  16 +-
 drivers/video/omap2/dss/hdmi.c |  87 
 drivers/video/omap2/dss/manager-sysfs.c|  47 ++--
 drivers/video/omap2/dss/manager.c  |  29 ++-
 drivers/video/omap2/dss/output.c   |  78 ++-
 drivers/video/omap2/dss/rfbi.c |  39 ++--
 drivers/video/omap2/dss/sdi.c  |  78 ---
 drivers/video/omap2/dss/venc.c |  74 +++
 drivers/video/omap2/dss/venc_panel.c   |  16 +-
 drivers/video/omap2/omapfb/omapfb-ioctl.c  |   9 +-
 drivers/video/omap2/omapfb/omapfb-main.c   |  27 +--
 include/video/omapdss.h| 103 ++---
 34 files changed, 1088 insertions(+), 770 deletions(-)

-- 
1.8.1.2

--
To unsubscribe from this list: sen

[PATCH 01/32] OMAPDSS: add pdata->default_display_name

2013-05-30 Thread Tomi Valkeinen
We can currently set the default display (i.e. the initial display) in
the omapdss platform data by using a pointer to the default
omap_dss_device. Internally omapdss uses the device's name to resolve
the default display.

As it's difficult to get the omap_dss_device pointer in the future,
after we've changed the omapdss device model, this patch adds a new way
to define the default display, by using the name of the display.

Signed-off-by: Tomi Valkeinen 
Reviewed-by: Archit Taneja 
---
 drivers/video/omap2/dss/core.c | 2 ++
 include/video/omapdss.h| 1 +
 2 files changed, 3 insertions(+)

diff --git a/drivers/video/omap2/dss/core.c b/drivers/video/omap2/dss/core.c
index 60cc6fe..502ec1b 100644
--- a/drivers/video/omap2/dss/core.c
+++ b/drivers/video/omap2/dss/core.c
@@ -235,6 +235,8 @@ static int __init omap_dss_probe(struct platform_device 
*pdev)
 
if (def_disp_name)
core.default_display_name = def_disp_name;
+   else if (pdata->default_display_name)
+   core.default_display_name = pdata->default_display_name;
else if (pdata->default_device)
core.default_display_name = pdata->default_device->name;
 
diff --git a/include/video/omapdss.h b/include/video/omapdss.h
index 62ca9a7..d5f1fff 100644
--- a/include/video/omapdss.h
+++ b/include/video/omapdss.h
@@ -365,6 +365,7 @@ struct omap_dss_board_info {
int num_devices;
struct omap_dss_device **devices;
struct omap_dss_device *default_device;
+   const char *default_display_name;
int (*dsi_enable_pads)(int dsi_id, unsigned lane_mask);
void (*dsi_disable_pads)(int dsi_id, unsigned lane_mask);
int (*set_min_bus_tput)(struct device *dev, unsigned long r);
-- 
1.8.1.2

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


[PATCH 02/32] OMAPDSS: only probe pdata if there's one

2013-05-30 Thread Tomi Valkeinen
omapdss output drivers always read the platform data. This crashes when
there's no platform data when using DT.

Add a check to read the platform data only if it exists.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/dpi.c  | 12 
 drivers/video/omap2/dss/dsi.c  | 13 +++--
 drivers/video/omap2/dss/hdmi.c | 16 ++--
 drivers/video/omap2/dss/rfbi.c | 11 ++-
 drivers/video/omap2/dss/sdi.c  | 12 
 drivers/video/omap2/dss/venc.c | 13 +++--
 6 files changed, 46 insertions(+), 31 deletions(-)

diff --git a/drivers/video/omap2/dss/dpi.c b/drivers/video/omap2/dss/dpi.c
index 757b57f..ef8fca2 100644
--- a/drivers/video/omap2/dss/dpi.c
+++ b/drivers/video/omap2/dss/dpi.c
@@ -706,13 +706,17 @@ static int omap_dpi_probe(struct platform_device *pdev)
 
dpi_init_output(pdev);
 
-   r = dpi_probe_pdata(pdev);
-   if (r) {
-   dpi_uninit_output(pdev);
-   return r;
+   if (pdev->dev.platform_data) {
+   r = dpi_probe_pdata(pdev);
+   if (r)
+   goto err_probe;
}
 
return 0;
+
+err_probe:
+   dpi_uninit_output(pdev);
+   return r;
 }
 
 static int __exit omap_dpi_remove(struct platform_device *pdev)
diff --git a/drivers/video/omap2/dss/dsi.c b/drivers/video/omap2/dss/dsi.c
index a73dedc..b0d 100644
--- a/drivers/video/omap2/dss/dsi.c
+++ b/drivers/video/omap2/dss/dsi.c
@@ -5563,12 +5563,10 @@ static int omap_dsihw_probe(struct platform_device 
*dsidev)
 
dsi_init_output(dsidev);
 
-   r = dsi_probe_pdata(dsidev);
-   if (r) {
-   dsi_runtime_put(dsidev);
-   dsi_uninit_output(dsidev);
-   pm_runtime_disable(&dsidev->dev);
-   return r;
+   if (dsidev->dev.platform_data) {
+   r = dsi_probe_pdata(dsidev);
+   if (r)
+   goto err_probe;
}
 
dsi_runtime_put(dsidev);
@@ -5586,6 +5584,9 @@ static int omap_dsihw_probe(struct platform_device 
*dsidev)
 #endif
return 0;
 
+err_probe:
+   dsi_runtime_put(dsidev);
+   dsi_uninit_output(dsidev);
 err_runtime_get:
pm_runtime_disable(&dsidev->dev);
return r;
diff --git a/drivers/video/omap2/dss/hdmi.c b/drivers/video/omap2/dss/hdmi.c
index 17f4d55..99f4ab5 100644
--- a/drivers/video/omap2/dss/hdmi.c
+++ b/drivers/video/omap2/dss/hdmi.c
@@ -1098,15 +1098,19 @@ static int omapdss_hdmihw_probe(struct platform_device 
*pdev)
 
dss_debugfs_create_file("hdmi", hdmi_dump_regs);
 
-   r = hdmi_probe_pdata(pdev);
-   if (r) {
-   hdmi_panel_exit();
-   hdmi_uninit_output(pdev);
-   pm_runtime_disable(&pdev->dev);
-   return r;
+   if (pdev->dev.platform_data) {
+   r = hdmi_probe_pdata(pdev);
+   if (r)
+   goto err_probe;
}
 
return 0;
+
+err_probe:
+   hdmi_panel_exit();
+   hdmi_uninit_output(pdev);
+   pm_runtime_disable(&pdev->dev);
+   return r;
 }
 
 static int __exit hdmi_remove_child(struct device *dev, void *data)
diff --git a/drivers/video/omap2/dss/rfbi.c b/drivers/video/omap2/dss/rfbi.c
index 1a17dd1..1ff221e 100644
--- a/drivers/video/omap2/dss/rfbi.c
+++ b/drivers/video/omap2/dss/rfbi.c
@@ -1093,15 +1093,16 @@ static int omap_rfbihw_probe(struct platform_device 
*pdev)
 
rfbi_init_output(pdev);
 
-   r = rfbi_probe_pdata(pdev);
-   if (r) {
-   rfbi_uninit_output(pdev);
-   pm_runtime_disable(&pdev->dev);
-   return r;
+   if (pdev->dev.platform_data) {
+   r = rfbi_probe_pdata(pdev);
+   if (r)
+   goto err_probe;
}
 
return 0;
 
+err_probe:
+   rfbi_uninit_output(pdev);
 err_runtime_get:
pm_runtime_disable(&pdev->dev);
return r;
diff --git a/drivers/video/omap2/dss/sdi.c b/drivers/video/omap2/dss/sdi.c
index 0bcd302..6277c05 100644
--- a/drivers/video/omap2/dss/sdi.c
+++ b/drivers/video/omap2/dss/sdi.c
@@ -365,13 +365,17 @@ static int omap_sdi_probe(struct platform_device *pdev)
 
sdi_init_output(pdev);
 
-   r = sdi_probe_pdata(pdev);
-   if (r) {
-   sdi_uninit_output(pdev);
-   return r;
+   if (pdev->dev.platform_data) {
+   r = sdi_probe_pdata(pdev);
+   if (r)
+   goto err_probe;
}
 
return 0;
+
+err_probe:
+   sdi_uninit_output(pdev);
+   return r;
 }
 
 static int __exit omap_sdi_remove(struct platform_device *pdev)
diff --git a/drivers/video/omap2/dss/venc.c b/drivers/video/omap2/dss/venc.c
index 74fdb3e..7b2e3ae 100644
--- a/drivers/video/omap2/dss/venc.c
+++ b/drivers/video/omap2/dss/venc.c
@@ -866,16 +866,17 @@ static int omap_venchw_probe(struct platform_device *pdev)
 
venc_init_output(pdev);
 
-   r = venc_probe_pdata(pdev);
-

[PATCH 03/32] OMAPDSS: add omap_dss_find_output()

2013-05-30 Thread Tomi Valkeinen
Add a support function to find a DSS output by given name. This is used
in later patches to link the panels to DSS outputs.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/output.c | 13 +
 include/video/omapdss.h  |  1 +
 2 files changed, 14 insertions(+)

diff --git a/drivers/video/omap2/dss/output.c b/drivers/video/omap2/dss/output.c
index 5214df6..3274628 100644
--- a/drivers/video/omap2/dss/output.c
+++ b/drivers/video/omap2/dss/output.c
@@ -115,6 +115,19 @@ struct omap_dss_output *omap_dss_get_output(enum 
omap_dss_output_id id)
 }
 EXPORT_SYMBOL(omap_dss_get_output);
 
+struct omap_dss_output *omap_dss_find_output(const char *name)
+{
+   struct omap_dss_output *out;
+
+   list_for_each_entry(out, &output_list, list) {
+   if (strcmp(out->name, name) == 0)
+   return out;
+   }
+
+   return NULL;
+}
+EXPORT_SYMBOL(omap_dss_find_output);
+
 static const struct dss_mgr_ops *dss_mgr_ops;
 
 int dss_install_mgr_ops(const struct dss_mgr_ops *mgr_ops)
diff --git a/include/video/omapdss.h b/include/video/omapdss.h
index d5f1fff..aad47a2 100644
--- a/include/video/omapdss.h
+++ b/include/video/omapdss.h
@@ -779,6 +779,7 @@ int omap_dss_get_num_overlays(void);
 struct omap_overlay *omap_dss_get_overlay(int num);
 
 struct omap_dss_output *omap_dss_get_output(enum omap_dss_output_id id);
+struct omap_dss_output *omap_dss_find_output(const char *name);
 int omapdss_output_set_device(struct omap_dss_output *out,
struct omap_dss_device *dssdev);
 int omapdss_output_unset_device(struct omap_dss_output *out);
-- 
1.8.1.2

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


[PATCH 04/32] OMAPDSS: add omap_dss_find_output_by_node()

2013-05-30 Thread Tomi Valkeinen
Add a support function to find a DSS output by given DT node. This is
used in later patches to link the panels to DSS outputs.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/output.c | 13 +
 include/video/omapdss.h  |  1 +
 2 files changed, 14 insertions(+)

diff --git a/drivers/video/omap2/dss/output.c b/drivers/video/omap2/dss/output.c
index 3274628..4d01001 100644
--- a/drivers/video/omap2/dss/output.c
+++ b/drivers/video/omap2/dss/output.c
@@ -128,6 +128,19 @@ struct omap_dss_output *omap_dss_find_output(const char 
*name)
 }
 EXPORT_SYMBOL(omap_dss_find_output);
 
+struct omap_dss_output *omap_dss_find_output_by_node(struct device_node *node)
+{
+   struct omap_dss_output *out;
+
+   list_for_each_entry(out, &output_list, list) {
+   if (out->pdev->dev.of_node == node)
+   return out;
+   }
+
+   return NULL;
+}
+EXPORT_SYMBOL(omap_dss_find_output_by_node);
+
 static const struct dss_mgr_ops *dss_mgr_ops;
 
 int dss_install_mgr_ops(const struct dss_mgr_ops *mgr_ops)
diff --git a/include/video/omapdss.h b/include/video/omapdss.h
index aad47a2..7fe6144 100644
--- a/include/video/omapdss.h
+++ b/include/video/omapdss.h
@@ -780,6 +780,7 @@ struct omap_overlay *omap_dss_get_overlay(int num);
 
 struct omap_dss_output *omap_dss_get_output(enum omap_dss_output_id id);
 struct omap_dss_output *omap_dss_find_output(const char *name);
+struct omap_dss_output *omap_dss_find_output_by_node(struct device_node *node);
 int omapdss_output_set_device(struct omap_dss_output *out,
struct omap_dss_device *dssdev);
 int omapdss_output_unset_device(struct omap_dss_output *out);
-- 
1.8.1.2

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


[PATCH 05/32] OMAPDSS: fix dss_get_ctx_loss_count for DT

2013-05-30 Thread Tomi Valkeinen
When using DT, dss device does not have platform data. However,
dss_get_ctx_loss_count() uses dss device's platform data to find the
get_ctx_loss_count function pointer.

To fix this, dss_get_ctx_loss_count() needs to be changed to get the
platform data from the omapdss device, which is a "virtual" device and
always has platform data.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/dss.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/video/omap2/dss/dss.c b/drivers/video/omap2/dss/dss.c
index 94f66f9..bd01608 100644
--- a/drivers/video/omap2/dss/dss.c
+++ b/drivers/video/omap2/dss/dss.c
@@ -157,7 +157,8 @@ static void dss_restore_context(void)
 
 int dss_get_ctx_loss_count(void)
 {
-   struct omap_dss_board_info *board_data = dss.pdev->dev.platform_data;
+   struct platform_device *core_pdev = dss_get_core_pdev();
+   struct omap_dss_board_info *board_data = core_pdev->dev.platform_data;
int cnt;
 
if (!board_data->get_context_loss_count)
-- 
1.8.1.2

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


[PATCH 06/32] OMAPDSS: DPI: fix regulators for DT

2013-05-30 Thread Tomi Valkeinen
On some platforms DPI requires a regulator to be enabled to power up the
output pins. This regulator is, for some reason, currently attached to
the virtual omapdss device, instead of the DPI device. This does not
work for DT, as the regulator mappings need to be described in the DT
data, and the virtual omapdss device is not present there.

Fix the issue by acquiring the regulator in the DPI device. To retain
compatibility with the current board files, the old method of getting
the regulator is kept. The old method can be removed when the board
files have been changed to pass the regulator to DPI.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/dpi.c | 21 ++---
 1 file changed, 18 insertions(+), 3 deletions(-)

diff --git a/drivers/video/omap2/dss/dpi.c b/drivers/video/omap2/dss/dpi.c
index ef8fca2..43f6b26 100644
--- a/drivers/video/omap2/dss/dpi.c
+++ b/drivers/video/omap2/dss/dpi.c
@@ -37,7 +37,10 @@
 #include "dss_features.h"
 
 static struct {
+   struct platform_device *pdev;
+
struct regulator *vdds_dsi_reg;
+   bool vdds_dsi_from_core;
struct platform_device *dsidev;
 
struct mutex lock;
@@ -583,10 +586,15 @@ static int dpi_init_display(struct omap_dss_device 
*dssdev)
struct regulator *vdds_dsi;
 
vdds_dsi = dss_get_vdds_dsi();
-
if (IS_ERR(vdds_dsi)) {
-   DSSERR("can't get VDDS_DSI regulator\n");
-   return PTR_ERR(vdds_dsi);
+   vdds_dsi = regulator_get(&dpi.pdev->dev, "vdds_dsi");
+   if (IS_ERR(vdds_dsi)) {
+   DSSERR("can't get VDDS_DSI regulator\n");
+   return PTR_ERR(vdds_dsi);
+   }
+   dpi.vdds_dsi_from_core = false;
+   } else {
+   dpi.vdds_dsi_from_core = true;
}
 
dpi.vdds_dsi_reg = vdds_dsi;
@@ -702,6 +710,8 @@ static int omap_dpi_probe(struct platform_device *pdev)
 {
int r;
 
+   dpi.pdev = pdev;
+
mutex_init(&dpi.lock);
 
dpi_init_output(pdev);
@@ -725,6 +735,11 @@ static int __exit omap_dpi_remove(struct platform_device 
*pdev)
 
dpi_uninit_output(pdev);
 
+   if (dpi.vdds_dsi_reg != NULL && dpi.vdds_dsi_from_core == false) {
+   regulator_put(dpi.vdds_dsi_reg);
+   dpi.vdds_dsi_reg = NULL;
+   }
+
return 0;
 }
 
-- 
1.8.1.2

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


[PATCH 07/32] OMAPDSS: SDI: fix regulators for DT

2013-05-30 Thread Tomi Valkeinen
SDI requires a regulator to operate. This regulator is, for some reason,
currently attached to the virtual omapdss device, instead of the SDI
device. This does not work for DT, as the regulator mappings need to be
described in the DT data, and the virtual omapdss device is not present
there.

Fix the issue by acquiring the regulator in the SDI device. To retain
compatibility with the current board files, the old method of getting
the regulator is kept. The old method can be removed when the board
files have been changed to pass the regulator to SDI.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/sdi.c | 20 ++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/drivers/video/omap2/dss/sdi.c b/drivers/video/omap2/dss/sdi.c
index 6277c05..2e3afb8 100644
--- a/drivers/video/omap2/dss/sdi.c
+++ b/drivers/video/omap2/dss/sdi.c
@@ -31,8 +31,11 @@
 #include "dss.h"
 
 static struct {
+   struct platform_device *pdev;
+
bool update_enabled;
struct regulator *vdds_sdi_reg;
+   bool vdds_sdi_from_core;
 
struct dss_lcd_mgr_config mgr_config;
struct omap_video_timings timings;
@@ -258,8 +261,14 @@ static int sdi_init_display(struct omap_dss_device *dssdev)
vdds_sdi = dss_get_vdds_sdi();
 
if (IS_ERR(vdds_sdi)) {
-   DSSERR("can't get VDDS_SDI regulator\n");
-   return PTR_ERR(vdds_sdi);
+   vdds_sdi = regulator_get(&sdi.pdev->dev, "vdds_sdi");
+   if (IS_ERR(vdds_sdi)) {
+   DSSERR("can't get VDDS_SDI regulator\n");
+   return PTR_ERR(vdds_sdi);
+   }
+   sdi.vdds_sdi_from_core = false;
+   } else {
+   sdi.vdds_sdi_from_core = true;
}
 
sdi.vdds_sdi_reg = vdds_sdi;
@@ -363,6 +372,8 @@ static int omap_sdi_probe(struct platform_device *pdev)
 {
int r;
 
+   sdi.pdev = pdev;
+
sdi_init_output(pdev);
 
if (pdev->dev.platform_data) {
@@ -384,6 +395,11 @@ static int __exit omap_sdi_remove(struct platform_device 
*pdev)
 
sdi_uninit_output(pdev);
 
+   if (sdi.vdds_sdi_reg != NULL && sdi.vdds_sdi_from_core == false) {
+   regulator_put(sdi.vdds_sdi_reg);
+   sdi.vdds_sdi_reg = NULL;
+   }
+
return 0;
 }
 
-- 
1.8.1.2

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


[PATCH 08/32] OMAPDSS: clean up dss_[ovl|mgr]_get_device()

2013-05-30 Thread Tomi Valkeinen
Minor cleanup for the dss_[ovl|mgr]_get_device() functions to make them
more readable.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/apply.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/video/omap2/dss/apply.c b/drivers/video/omap2/dss/apply.c
index a4b356a..b84bd99 100644
--- a/drivers/video/omap2/dss/apply.c
+++ b/drivers/video/omap2/dss/apply.c
@@ -420,16 +420,14 @@ static void wait_pending_extra_info_updates(void)
DSSWARN("timeout in wait_pending_extra_info_updates\n");
 }
 
-static inline struct omap_dss_device *dss_ovl_get_device(struct omap_overlay 
*ovl)
+static struct omap_dss_device *dss_mgr_get_device(struct omap_overlay_manager 
*mgr)
 {
-   return ovl->manager ?
-   (ovl->manager->output ? ovl->manager->output->device : NULL) :
-   NULL;
+   return mgr->output ? mgr->output->device : NULL;
 }
 
-static inline struct omap_dss_device *dss_mgr_get_device(struct 
omap_overlay_manager *mgr)
+static struct omap_dss_device *dss_ovl_get_device(struct omap_overlay *ovl)
 {
-   return mgr->output ? mgr->output->device : NULL;
+   return ovl->manager ? dss_mgr_get_device(ovl->manager) : NULL;
 }
 
 static int dss_mgr_wait_for_vsync(struct omap_overlay_manager *mgr)
-- 
1.8.1.2

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


[PATCH 09/32] OMAPDSS: add helpers to get mgr or output from display

2013-05-30 Thread Tomi Valkeinen
Add two helper functions that can be used to find either the DSS output
or the overlay manager that is connected to the given display.

This hides how the output and the manager are actually connected, making
it easier to change the connections in the future.

Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/omap_drv.c|  5 -
 drivers/video/omap2/dss/manager-sysfs.c   |  4 +++-
 drivers/video/omap2/dss/output.c  | 19 +++
 drivers/video/omap2/omapfb/omapfb-ioctl.c |  9 +++--
 drivers/video/omap2/omapfb/omapfb-main.c  | 16 +++-
 include/video/omapdss.h   |  3 +++
 6 files changed, 43 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index 9c53c25..691e760 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -247,6 +247,9 @@ static int omap_modeset_init(struct drm_device *dev)
struct drm_encoder *encoder = priv->encoders[i];
struct omap_dss_device *dssdev =
omap_encoder_get_dssdev(encoder);
+   struct omap_dss_output *output;
+
+   output = omapdss_find_output_from_display(dssdev);
 
/* figure out which crtc's we can connect the encoder to: */
encoder->possible_crtcs = 0;
@@ -259,7 +262,7 @@ static int omap_modeset_init(struct drm_device *dev)
supported_outputs =
dss_feat_get_supported_outputs(crtc_channel);
 
-   if (supported_outputs & dssdev->output->id)
+   if (supported_outputs & output->id)
encoder->possible_crtcs |= (1 << id);
}
}
diff --git a/drivers/video/omap2/dss/manager-sysfs.c 
b/drivers/video/omap2/dss/manager-sysfs.c
index 9a2fb59..5104681 100644
--- a/drivers/video/omap2/dss/manager-sysfs.c
+++ b/drivers/video/omap2/dss/manager-sysfs.c
@@ -78,7 +78,9 @@ static ssize_t manager_display_store(struct 
omap_overlay_manager *mgr,
}
 
if (dssdev) {
-   struct omap_dss_output *out = dssdev->output;
+   struct omap_dss_output *out;
+
+   out = omapdss_find_output_from_display(dssdev);
 
/*
 * a registered device should have an output connected to it
diff --git a/drivers/video/omap2/dss/output.c b/drivers/video/omap2/dss/output.c
index 4d01001..ab2c0f0 100644
--- a/drivers/video/omap2/dss/output.c
+++ b/drivers/video/omap2/dss/output.c
@@ -141,6 +141,25 @@ struct omap_dss_output 
*omap_dss_find_output_by_node(struct device_node *node)
 }
 EXPORT_SYMBOL(omap_dss_find_output_by_node);
 
+struct omap_dss_output *omapdss_find_output_from_display(struct 
omap_dss_device *dssdev)
+{
+   return dssdev->output;
+}
+EXPORT_SYMBOL(omapdss_find_output_from_display);
+
+struct omap_overlay_manager *omapdss_find_mgr_from_display(struct 
omap_dss_device *dssdev)
+{
+   struct omap_dss_output *out;
+
+   out = omapdss_find_output_from_display(dssdev);
+
+   if (out == NULL)
+   return NULL;
+
+   return out->manager;
+}
+EXPORT_SYMBOL(omapdss_find_mgr_from_display);
+
 static const struct dss_mgr_ops *dss_mgr_ops;
 
 int dss_install_mgr_ops(const struct dss_mgr_ops *mgr_ops)
diff --git a/drivers/video/omap2/omapfb/omapfb-ioctl.c 
b/drivers/video/omap2/omapfb/omapfb-ioctl.c
index d30b45d..146b6f5 100644
--- a/drivers/video/omap2/omapfb/omapfb-ioctl.c
+++ b/drivers/video/omap2/omapfb/omapfb-ioctl.c
@@ -770,12 +770,17 @@ int omapfb_ioctl(struct fb_info *fbi, unsigned int cmd, 
unsigned long arg)
 
case OMAPFB_WAITFORVSYNC:
DBG("ioctl WAITFORVSYNC\n");
-   if (!display || !display->output || !display->output->manager) {
+
+   if (!display) {
r = -EINVAL;
break;
}
 
-   mgr = display->output->manager;
+   mgr = omapdss_find_mgr_from_display(display);
+   if (!mgr) {
+   r = -EINVAL;
+   break;
+   }
 
r = mgr->wait_for_vsync(mgr);
break;
diff --git a/drivers/video/omap2/omapfb/omapfb-main.c 
b/drivers/video/omap2/omapfb/omapfb-main.c
index c84bb8a..dd972c5 100644
--- a/drivers/video/omap2/omapfb/omapfb-main.c
+++ b/drivers/video/omap2/omapfb/omapfb-main.c
@@ -2363,18 +2363,16 @@ static int omapfb_init_connections(struct 
omapfb2_device *fbdev,
int i, r;
struct omap_overlay_manager *mgr;
 
-   if (!def_dssdev->output) {
-   dev_err(fbdev->dev, "no output for the default display\n");
-   return -EINVAL;
-   }
-
for (i = 0; i < fbdev->num_displays; ++i) {
struct omap_dss_device *dssdev = fbdev->displays[i].dssdev;
-   struct omap_dss_output *out 

[PATCH 10/32] OMAPDSS: split overlay manager creation

2013-05-30 Thread Tomi Valkeinen
Split the function that creates overlay manager structs into two: one
that creates just the structs, and one that creates the sysfs files for
the manager.

This will help us use the overlay manager structs with omapdrm in the
following patches, while still leaving the sysfs files out.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/apply.c |  9 ++---
 drivers/video/omap2/dss/dss.h   |  6 --
 drivers/video/omap2/dss/manager-sysfs.c |  2 ++
 drivers/video/omap2/dss/manager.c   | 29 ++---
 4 files changed, 34 insertions(+), 12 deletions(-)

diff --git a/drivers/video/omap2/dss/apply.c b/drivers/video/omap2/dss/apply.c
index b84bd99..74d1d00 100644
--- a/drivers/video/omap2/dss/apply.c
+++ b/drivers/video/omap2/dss/apply.c
@@ -1577,7 +1577,8 @@ int omapdss_compat_init(void)
 
apply_init_priv();
 
-   dss_init_overlay_managers(pdev);
+   dss_init_overlay_managers();
+   dss_init_overlay_managers_sysfs(pdev);
dss_init_overlays(pdev);
 
for (i = 0; i < omap_dss_get_num_overlay_managers(); i++) {
@@ -1640,7 +1641,8 @@ err_disp_sysfs:
dss_uninstall_mgr_ops();
 
 err_mgr_ops:
-   dss_uninit_overlay_managers(pdev);
+   dss_uninit_overlay_managers_sysfs(pdev);
+   dss_uninit_overlay_managers();
dss_uninit_overlays(pdev);
 
compat_refcnt--;
@@ -1668,7 +1670,8 @@ void omapdss_compat_uninit(void)
 
dss_uninstall_mgr_ops();
 
-   dss_uninit_overlay_managers(pdev);
+   dss_uninit_overlay_managers_sysfs(pdev);
+   dss_uninit_overlay_managers();
dss_uninit_overlays(pdev);
 out:
mutex_unlock(&compat_init_lock);
diff --git a/drivers/video/omap2/dss/dss.h b/drivers/video/omap2/dss/dss.h
index 8475893..7964d3b 100644
--- a/drivers/video/omap2/dss/dss.h
+++ b/drivers/video/omap2/dss/dss.h
@@ -194,8 +194,10 @@ void display_uninit_sysfs(struct platform_device *pdev,
struct omap_dss_device *dssdev);
 
 /* manager */
-int dss_init_overlay_managers(struct platform_device *pdev);
-void dss_uninit_overlay_managers(struct platform_device *pdev);
+int dss_init_overlay_managers(void);
+void dss_uninit_overlay_managers(void);
+int dss_init_overlay_managers_sysfs(struct platform_device *pdev);
+void dss_uninit_overlay_managers_sysfs(struct platform_device *pdev);
 int dss_mgr_simple_check(struct omap_overlay_manager *mgr,
const struct omap_overlay_manager_info *info);
 int dss_mgr_check_timings(struct omap_overlay_manager *mgr,
diff --git a/drivers/video/omap2/dss/manager-sysfs.c 
b/drivers/video/omap2/dss/manager-sysfs.c
index 5104681..72784b3 100644
--- a/drivers/video/omap2/dss/manager-sysfs.c
+++ b/drivers/video/omap2/dss/manager-sysfs.c
@@ -511,4 +511,6 @@ void dss_manager_kobj_uninit(struct omap_overlay_manager 
*mgr)
 {
kobject_del(&mgr->kobj);
kobject_put(&mgr->kobj);
+
+   memset(&mgr->kobj, 0, sizeof(mgr->kobj));
 }
diff --git a/drivers/video/omap2/dss/manager.c 
b/drivers/video/omap2/dss/manager.c
index 2551eaa..1aac9b4 100644
--- a/drivers/video/omap2/dss/manager.c
+++ b/drivers/video/omap2/dss/manager.c
@@ -36,9 +36,9 @@
 static int num_managers;
 static struct omap_overlay_manager *managers;
 
-int dss_init_overlay_managers(struct platform_device *pdev)
+int dss_init_overlay_managers(void)
 {
-   int i, r;
+   int i;
 
num_managers = dss_feat_get_num_mgrs();
 
@@ -76,6 +76,17 @@ int dss_init_overlay_managers(struct platform_device *pdev)
dss_feat_get_supported_outputs(mgr->id);
 
INIT_LIST_HEAD(&mgr->overlays);
+   }
+
+   return 0;
+}
+
+int dss_init_overlay_managers_sysfs(struct platform_device *pdev)
+{
+   int i, r;
+
+   for (i = 0; i < num_managers; ++i) {
+   struct omap_overlay_manager *mgr = &managers[i];
 
r = dss_manager_kobj_init(mgr, pdev);
if (r)
@@ -85,18 +96,22 @@ int dss_init_overlay_managers(struct platform_device *pdev)
return 0;
 }
 
-void dss_uninit_overlay_managers(struct platform_device *pdev)
+void dss_uninit_overlay_managers(void)
+{
+   kfree(managers);
+   managers = NULL;
+   num_managers = 0;
+}
+
+void dss_uninit_overlay_managers_sysfs(struct platform_device *pdev)
 {
int i;
 
for (i = 0; i < num_managers; ++i) {
struct omap_overlay_manager *mgr = &managers[i];
+
dss_manager_kobj_uninit(mgr);
}
-
-   kfree(managers);
-   managers = NULL;
-   num_managers = 0;
 }
 
 int omap_dss_get_num_overlay_managers(void)
-- 
1.8.1.2

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


[PATCH 11/32] OMAPDRM: fix overlay manager handling

2013-05-30 Thread Tomi Valkeinen
Currently omapdrm creates crtcs, which map directly to DSS overlay
managers, only on demand at init time. This would make it difficult to
manage connecting the display entities in the future, as the code cannot
just search for a suitable overlay manager.

We cannot fix this the sane way, which would be to create crtcs for each
overlay manager, because we need an overlay for each crtc. With limited
number of overlays, that's not possible.

So the solution for now is to detach the overlay manager from the crtc.
crtcs are still created on demand at init time, but all overlay managers
are always initialized by the omapdss.

This way we can create and connect whole display pipelines from the
overlay manager to the display, regardless of which crtcs omapdrm would
create.

Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/omap_crtc.c | 22 +++---
 drivers/gpu/drm/omapdrm/omap_drv.c  |  2 ++
 drivers/gpu/drm/omapdrm/omap_drv.h  |  1 +
 drivers/video/omap2/dss/apply.c |  3 ---
 drivers/video/omap2/dss/dispc.c |  4 
 5 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 79b200a..02075bf 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -40,7 +40,7 @@ struct omap_crtc {
 * mgr->id.)  Eventually this will be replaced w/ something
 * more common-panel-framework-y
 */
-   struct omap_overlay_manager mgr;
+   struct omap_overlay_manager *mgr;
 
struct omap_video_timings timings;
bool enabled;
@@ -90,6 +90,9 @@ uint32_t pipe2vbl(struct drm_crtc *crtc)
  * job of sequencing the setup of the video pipe in the proper order
  */
 
+/* ovl-mgr-id -> crtc */
+static struct omap_crtc *omap_crtcs[8];
+
 /* we can probably ignore these until we support command-mode panels: */
 static void omap_crtc_start_update(struct omap_overlay_manager *mgr)
 {
@@ -107,7 +110,7 @@ static void omap_crtc_disable(struct omap_overlay_manager 
*mgr)
 static void omap_crtc_set_timings(struct omap_overlay_manager *mgr,
const struct omap_video_timings *timings)
 {
-   struct omap_crtc *omap_crtc = container_of(mgr, struct omap_crtc, mgr);
+   struct omap_crtc *omap_crtc = omap_crtcs[mgr->id];
DBG("%s", omap_crtc->name);
omap_crtc->timings = *timings;
omap_crtc->full_update = true;
@@ -116,7 +119,7 @@ static void omap_crtc_set_timings(struct 
omap_overlay_manager *mgr,
 static void omap_crtc_set_lcd_config(struct omap_overlay_manager *mgr,
const struct dss_lcd_mgr_config *config)
 {
-   struct omap_crtc *omap_crtc = container_of(mgr, struct omap_crtc, mgr);
+   struct omap_crtc *omap_crtc = omap_crtcs[mgr->id];
DBG("%s", omap_crtc->name);
dispc_mgr_set_lcd_config(omap_crtc->channel, config);
 }
@@ -569,7 +572,7 @@ static void omap_crtc_pre_apply(struct omap_drm_apply 
*apply)
} else {
if (encoder) {
omap_encoder_set_enabled(encoder, false);
-   omap_encoder_update(encoder, &omap_crtc->mgr,
+   omap_encoder_update(encoder, omap_crtc->mgr,
&omap_crtc->timings);
omap_encoder_set_enabled(encoder, true);
omap_crtc->full_update = false;
@@ -595,6 +598,11 @@ static const char *channel_names[] = {
[OMAP_DSS_CHANNEL_LCD2] = "lcd2",
 };
 
+void omap_crtc_pre_init(void)
+{
+   dss_install_mgr_ops(&mgr_ops);
+}
+
 /* initialize crtc */
 struct drm_crtc *omap_crtc_init(struct drm_device *dev,
struct drm_plane *plane, enum omap_channel channel, int id)
@@ -635,9 +643,7 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
omap_irq_register(dev, &omap_crtc->error_irq);
 
/* temporary: */
-   omap_crtc->mgr.id = channel;
-
-   dss_install_mgr_ops(&mgr_ops);
+   omap_crtc->mgr = omap_dss_get_overlay_manager(channel);
 
/* TODO: fix hard-coded setup.. add properties! */
info = &omap_crtc->info;
@@ -651,6 +657,8 @@ struct drm_crtc *omap_crtc_init(struct drm_device *dev,
 
omap_plane_install_properties(omap_crtc->plane, &crtc->base);
 
+   omap_crtcs[channel] = omap_crtc;
+
return crtc;
 
 fail:
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index 691e760..f8947f9 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -98,6 +98,8 @@ static int omap_modeset_init(struct drm_device *dev)
int num_crtcs;
int i, id = 0;
 
+   omap_crtc_pre_init();
+
drm_mode_config_init(dev);
 
omap_drm_irq_install(dev);
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.h 
b/drivers/gpu/drm/omapdrm/omap_drv.h
index 215a20d..14f17da 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.h
+++ b/drivers/gpu/drm/omapdrm/om

[PATCH 13/32] OMAPDSS: CORE: use devm_regulator_get

2013-05-30 Thread Tomi Valkeinen
Use devm_regulator_get() instead of regulator_get() to simplify code.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/core.c | 14 ++
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/drivers/video/omap2/dss/core.c b/drivers/video/omap2/dss/core.c
index 4bd8f79..f64d0ac 100644
--- a/drivers/video/omap2/dss/core.c
+++ b/drivers/video/omap2/dss/core.c
@@ -80,7 +80,7 @@ struct regulator *dss_get_vdds_dsi(void)
if (core.vdds_dsi_reg != NULL)
return core.vdds_dsi_reg;
 
-   reg = regulator_get(&core.pdev->dev, "vdds_dsi");
+   reg = devm_regulator_get(&core.pdev->dev, "vdds_dsi");
if (!IS_ERR(reg))
core.vdds_dsi_reg = reg;
 
@@ -94,7 +94,7 @@ struct regulator *dss_get_vdds_sdi(void)
if (core.vdds_sdi_reg != NULL)
return core.vdds_sdi_reg;
 
-   reg = regulator_get(&core.pdev->dev, "vdds_sdi");
+   reg = devm_regulator_get(&core.pdev->dev, "vdds_sdi");
if (!IS_ERR(reg))
core.vdds_sdi_reg = reg;
 
@@ -654,16 +654,6 @@ static int __init omap_dss_init(void)
 
 static void __exit omap_dss_exit(void)
 {
-   if (core.vdds_dsi_reg != NULL) {
-   regulator_put(core.vdds_dsi_reg);
-   core.vdds_dsi_reg = NULL;
-   }
-
-   if (core.vdds_sdi_reg != NULL) {
-   regulator_put(core.vdds_sdi_reg);
-   core.vdds_sdi_reg = NULL;
-   }
-
omap_dss_unregister_drivers();
 
omap_dss_bus_unregister();
-- 
1.8.1.2

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


[PATCH 14/32] OMAPDSS: DSI: cleanup regulator init

2013-05-30 Thread Tomi Valkeinen
Separate the regulator initialization code to its own function, removing
duplicate code.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/dsi.c | 82 ---
 1 file changed, 31 insertions(+), 51 deletions(-)

diff --git a/drivers/video/omap2/dss/dsi.c b/drivers/video/omap2/dss/dsi.c
index b0d..37ca980 100644
--- a/drivers/video/omap2/dss/dsi.c
+++ b/drivers/video/omap2/dss/dsi.c
@@ -1114,6 +1114,30 @@ void dsi_runtime_put(struct platform_device *dsidev)
WARN_ON(r < 0 && r != -ENOSYS);
 }
 
+static int dsi_regulator_init(struct platform_device *dsidev)
+{
+   struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
+   struct regulator *vdds_dsi;
+
+   if (dsi->vdds_dsi_reg != NULL)
+   return 0;
+
+   vdds_dsi = regulator_get(&dsi->pdev->dev, "vdds_dsi");
+
+   /* DT HACK: try VCXIO to make omapdss work for o4 sdp/panda */
+   if (IS_ERR(vdds_dsi))
+   vdds_dsi = regulator_get(&dsi->pdev->dev, "VCXIO");
+
+   if (IS_ERR(vdds_dsi)) {
+   DSSERR("can't get VDDS_DSI regulator\n");
+   return PTR_ERR(vdds_dsi);
+   }
+
+   dsi->vdds_dsi_reg = vdds_dsi;
+
+   return 0;
+}
+
 /* source clock for DSI PLL. this could also be PCLKFREE */
 static inline void dsi_enable_pll_clock(struct platform_device *dsidev,
bool enable)
@@ -1592,22 +1616,9 @@ int dsi_pll_init(struct platform_device *dsidev, bool 
enable_hsclk,
 */
enable_hsclk = enable_hsdiv = true;
 
-   if (dsi->vdds_dsi_reg == NULL) {
-   struct regulator *vdds_dsi;
-
-   vdds_dsi = regulator_get(&dsi->pdev->dev, "vdds_dsi");
-
-   /* DT HACK: try VCXIO to make omapdss work for o4 sdp/panda */
-   if (IS_ERR(vdds_dsi))
-   vdds_dsi = regulator_get(&dsi->pdev->dev, "VCXIO");
-
-   if (IS_ERR(vdds_dsi)) {
-   DSSERR("can't get VDDS_DSI regulator\n");
-   return PTR_ERR(vdds_dsi);
-   }
-
-   dsi->vdds_dsi_reg = vdds_dsi;
-   }
+   r = dsi_regulator_init(dsidev);
+   if (r)
+   return r;
 
dsi_enable_pll_clock(dsidev, 1);
/*
@@ -5225,34 +5236,6 @@ static enum omap_channel dsi_get_channel(int module_id)
}
 }
 
-static int dsi_init_display(struct omap_dss_device *dssdev)
-{
-   struct platform_device *dsidev =
-   dsi_get_dsidev_from_id(dssdev->phy.dsi.module);
-   struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
-
-   DSSDBG("DSI init\n");
-
-   if (dsi->vdds_dsi_reg == NULL) {
-   struct regulator *vdds_dsi;
-
-   vdds_dsi = regulator_get(&dsi->pdev->dev, "vdds_dsi");
-
-   /* DT HACK: try VCXIO to make omapdss work for o4 sdp/panda */
-   if (IS_ERR(vdds_dsi))
-   vdds_dsi = regulator_get(&dsi->pdev->dev, "VCXIO");
-
-   if (IS_ERR(vdds_dsi)) {
-   DSSERR("can't get VDDS_DSI regulator\n");
-   return PTR_ERR(vdds_dsi);
-   }
-
-   dsi->vdds_dsi_reg = vdds_dsi;
-   }
-
-   return 0;
-}
-
 int omap_dsi_request_vc(struct omap_dss_device *dssdev, int *channel)
 {
struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
@@ -5410,19 +5393,16 @@ static int dsi_probe_pdata(struct platform_device 
*dsidev)
if (!plat_dssdev)
return 0;
 
+   r = dsi_regulator_init(dsidev);
+   if (r)
+   return r;
+
dssdev = dss_alloc_and_init_device(&dsidev->dev);
if (!dssdev)
return -ENOMEM;
 
dss_copy_device_pdata(dssdev, plat_dssdev);
 
-   r = dsi_init_display(dssdev);
-   if (r) {
-   DSSERR("device %s init failed: %d\n", dssdev->name, r);
-   dss_put_device(dssdev);
-   return r;
-   }
-
r = omapdss_output_set_device(&dsi->output, dssdev);
if (r) {
DSSERR("failed to connect output to new device: %s\n",
-- 
1.8.1.2

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


[PATCH 12/32] OMAPDSS: Implement display (dis)connect support

2013-05-30 Thread Tomi Valkeinen
We currently have two steps in panel initialization and startup: probing
and enabling. After the panel has been probed, it's ready and can be
configured and later enabled.

This model is not enough with more complex display pipelines, where we
may have, for example, two panels, of which only one can be used at a
time, connected to the same video output.

To support that kind of scenarios, we need to add new step to the
initialization: connect.

This patch adds support for connecting and disconnecting panels. After
probe, but before connect, no panel ops should be called. When the
connect is called, a proper video pipeline is established, and the panel
is ready for use. If some part in the video pipeline is already
connected (by some other panel), the connect call fails.

One key difference with the old style setup is that connect() handles
also connecting to the overlay manager. This means that the omapfb (or
omapdrm) no longer needs to figure out which overlay manager to use, but
it can just call connect() on the panel, and the proper overlay manager
is connected by omapdss.

This also allows us to add back the support for dynamic switching
between two exclusive panels. However, the current panel device model is
not changed to support this, as the new device model is implemented in
the following patches and the old model will be removed. The new device
model supports dynamic switching.

Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/omap_crtc.c  | 24 +
 drivers/gpu/drm/omapdrm/omap_drv.c   | 12 -
 drivers/video/omap2/dss/apply.c  | 14 ++
 drivers/video/omap2/dss/core.c   | 44 +++
 drivers/video/omap2/dss/display-sysfs.c  | 28 +++-
 drivers/video/omap2/dss/manager-sysfs.c  | 45 
 drivers/video/omap2/dss/output.c | 14 ++
 drivers/video/omap2/omapfb/omapfb-main.c | 25 ++
 include/video/omapdss.h  | 23 
 9 files changed, 188 insertions(+), 41 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index 02075bf..b2ab2f5 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -94,6 +94,28 @@ uint32_t pipe2vbl(struct drm_crtc *crtc)
 static struct omap_crtc *omap_crtcs[8];
 
 /* we can probably ignore these until we support command-mode panels: */
+static int omap_crtc_connect(struct omap_overlay_manager *mgr,
+   struct omap_dss_output *dst)
+{
+   if (mgr->output)
+   return -EINVAL;
+
+   if ((mgr->supported_outputs & dst->id) == 0)
+   return -EINVAL;
+
+   dst->manager = mgr;
+   mgr->output = dst;
+
+   return 0;
+}
+
+static void omap_crtc_disconnect(struct omap_overlay_manager *mgr,
+   struct omap_dss_output *dst)
+{
+   mgr->output->manager = NULL;
+   mgr->output = NULL;
+}
+
 static void omap_crtc_start_update(struct omap_overlay_manager *mgr)
 {
 }
@@ -138,6 +160,8 @@ static void omap_crtc_unregister_framedone_handler(
 }
 
 static const struct dss_mgr_ops mgr_ops = {
+   .connect = omap_crtc_connect,
+   .disconnect = omap_crtc_disconnect,
.start_update = omap_crtc_start_update,
.enable = omap_crtc_enable,
.disable = omap_crtc_disable,
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index f8947f9..58bd259 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -97,6 +97,7 @@ static int omap_modeset_init(struct drm_device *dev)
int num_mgrs = dss_feat_get_num_mgrs();
int num_crtcs;
int i, id = 0;
+   int r;
 
omap_crtc_pre_init();
 
@@ -118,6 +119,7 @@ static int omap_modeset_init(struct drm_device *dev)
struct drm_connector *connector;
struct drm_encoder *encoder;
enum omap_channel channel;
+   struct omap_overlay_manager *mgr;
 
if (!dssdev->driver) {
dev_warn(dev->dev, "%s has no driver.. skipping it\n",
@@ -133,6 +135,13 @@ static int omap_modeset_init(struct drm_device *dev)
continue;
}
 
+   r = dssdev->driver->connect(dssdev);
+   if (r) {
+   dev_err(dev->dev, "could not connect display: %s\n",
+   dssdev->name);
+   continue;
+   }
+
encoder = omap_encoder_init(dev, dssdev);
 
if (!encoder) {
@@ -174,8 +183,9 @@ static int omap_modeset_init(struct drm_device *dev)
 * other possible channels to which the encoder can connect are
 * not considered.
 */
-   channel = dssdev->output->dispc_channel;
 
+   

[PATCH 15/32] OMAPDSS: DPI: cleanup pll & regulator init

2013-05-30 Thread Tomi Valkeinen
Split regulator and DSI PLL init code to their own functions for
clarity.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/dpi.c | 100 ++
 1 file changed, 53 insertions(+), 47 deletions(-)

diff --git a/drivers/video/omap2/dss/dpi.c b/drivers/video/omap2/dss/dpi.c
index 43f6b26..66ba9a6 100644
--- a/drivers/video/omap2/dss/dpi.c
+++ b/drivers/video/omap2/dss/dpi.c
@@ -545,6 +545,53 @@ static int dpi_verify_dsi_pll(struct platform_device 
*dsidev)
return 0;
 }
 
+static int dpi_init_regulator(void)
+{
+   struct regulator *vdds_dsi;
+
+   if (!dss_has_feature(FEAT_DPI_USES_VDDS_DSI))
+   return 0;
+
+   if (dpi.vdds_dsi_reg)
+   return 0;
+
+   vdds_dsi = dss_get_vdds_dsi();
+
+   if (!IS_ERR(vdds_dsi)) {
+   dpi.vdds_dsi_from_core = true;
+   dpi.vdds_dsi_reg = vdds_dsi;
+   return 0;
+   }
+
+   vdds_dsi = regulator_get(&dpi.pdev->dev, "vdds_dsi");
+   if (!IS_ERR(vdds_dsi)) {
+   dpi.vdds_dsi_from_core = false;
+   dpi.vdds_dsi_reg = vdds_dsi;
+   return 0;
+   }
+
+   return PTR_ERR(vdds_dsi);
+}
+
+static void dpi_init_pll(void)
+{
+   struct platform_device *dsidev;
+
+   if (dpi.dsidev)
+   return;
+
+   dsidev = dpi_get_dsidev(dpi.output.dispc_channel);
+   if (!dsidev)
+   return;
+
+   if (dpi_verify_dsi_pll(dsidev)) {
+   DSSWARN("DSI PLL not operational\n");
+   return;
+   }
+
+   dpi.dsidev = dsidev;
+}
+
 /*
  * Return a hardcoded channel for the DPI output. This should work for
  * current use cases, but this can be later expanded to either resolve
@@ -575,46 +622,6 @@ static enum omap_channel dpi_get_channel(void)
}
 }
 
-static int dpi_init_display(struct omap_dss_device *dssdev)
-{
-   struct platform_device *dsidev;
-
-   DSSDBG("init_display\n");
-
-   if (dss_has_feature(FEAT_DPI_USES_VDDS_DSI) &&
-   dpi.vdds_dsi_reg == NULL) {
-   struct regulator *vdds_dsi;
-
-   vdds_dsi = dss_get_vdds_dsi();
-   if (IS_ERR(vdds_dsi)) {
-   vdds_dsi = regulator_get(&dpi.pdev->dev, "vdds_dsi");
-   if (IS_ERR(vdds_dsi)) {
-   DSSERR("can't get VDDS_DSI regulator\n");
-   return PTR_ERR(vdds_dsi);
-   }
-   dpi.vdds_dsi_from_core = false;
-   } else {
-   dpi.vdds_dsi_from_core = true;
-   }
-
-   dpi.vdds_dsi_reg = vdds_dsi;
-   }
-
-   dsidev = dpi_get_dsidev(dpi.output.dispc_channel);
-
-   if (dsidev && dpi_verify_dsi_pll(dsidev)) {
-   dsidev = NULL;
-   DSSWARN("DSI PLL not operational\n");
-   }
-
-   if (dsidev)
-   DSSDBG("using DSI PLL for DPI clock\n");
-
-   dpi.dsidev = dsidev;
-
-   return 0;
-}
-
 static struct omap_dss_device *dpi_find_dssdev(struct platform_device *pdev)
 {
struct omap_dss_board_info *pdata = pdev->dev.platform_data;
@@ -654,19 +661,18 @@ static int dpi_probe_pdata(struct platform_device *dpidev)
if (!plat_dssdev)
return 0;
 
+   r = dpi_init_regulator();
+   if (r)
+   return r;
+
+   dpi_init_pll();
+
dssdev = dss_alloc_and_init_device(&dpidev->dev);
if (!dssdev)
return -ENOMEM;
 
dss_copy_device_pdata(dssdev, plat_dssdev);
 
-   r = dpi_init_display(dssdev);
-   if (r) {
-   DSSERR("device %s init failed: %d\n", dssdev->name, r);
-   dss_put_device(dssdev);
-   return r;
-   }
-
r = omapdss_output_set_device(&dpi.output, dssdev);
if (r) {
DSSERR("failed to connect output to new device: %s\n",
-- 
1.8.1.2

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


[PATCH 16/32] OMAPDSS: HDMI: add hdmi_init_regulator

2013-05-30 Thread Tomi Valkeinen
Separate regulator init code into its own function for clarity.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/hdmi.c | 42 ++
 1 file changed, 26 insertions(+), 16 deletions(-)

diff --git a/drivers/video/omap2/dss/hdmi.c b/drivers/video/omap2/dss/hdmi.c
index 99f4ab5..960083b 100644
--- a/drivers/video/omap2/dss/hdmi.c
+++ b/drivers/video/omap2/dss/hdmi.c
@@ -328,6 +328,29 @@ static void hdmi_runtime_put(void)
WARN_ON(r < 0 && r != -ENOSYS);
 }
 
+static int hdmi_init_regulator(void)
+{
+   struct regulator *reg;
+
+   if (hdmi.vdda_hdmi_dac_reg != NULL)
+   return 0;
+
+   reg = devm_regulator_get(&hdmi.pdev->dev, "vdda_hdmi_dac");
+
+   /* DT HACK: try VDAC to make omapdss work for o4 sdp/panda */
+   if (IS_ERR(reg))
+   reg = devm_regulator_get(&hdmi.pdev->dev, "VDAC");
+
+   if (IS_ERR(reg)) {
+   DSSERR("can't get VDDA_HDMI_DAC regulator\n");
+   return PTR_ERR(reg);
+   }
+
+   hdmi.vdda_hdmi_dac_reg = reg;
+
+   return 0;
+}
+
 static int hdmi_init_display(struct omap_dss_device *dssdev)
 {
int r;
@@ -342,22 +365,9 @@ static int hdmi_init_display(struct omap_dss_device 
*dssdev)
 
dss_init_hdmi_ip_ops(&hdmi.ip_data, omapdss_get_version());
 
-   if (hdmi.vdda_hdmi_dac_reg == NULL) {
-   struct regulator *reg;
-
-   reg = devm_regulator_get(&hdmi.pdev->dev, "vdda_hdmi_dac");
-
-   /* DT HACK: try VDAC to make omapdss work for o4 sdp/panda */
-   if (IS_ERR(reg))
-   reg = devm_regulator_get(&hdmi.pdev->dev, "VDAC");
-
-   if (IS_ERR(reg)) {
-   DSSERR("can't get VDDA_HDMI_DAC regulator\n");
-   return PTR_ERR(reg);
-   }
-
-   hdmi.vdda_hdmi_dac_reg = reg;
-   }
+   r = hdmi_init_regulator();
+   if (r)
+   return r;
 
r = gpio_request_array(gpios, ARRAY_SIZE(gpios));
if (r)
-- 
1.8.1.2

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


[PATCH 17/32] OMAPDSS: SDI: clean up regulator init

2013-05-30 Thread Tomi Valkeinen
Clean up the SDI driver's regulator init to remove the (unused)
omap_dss_device parameter, renaming the function to a more sensible
name, and making the code slightly clearer.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/sdi.c | 41 +
 1 file changed, 21 insertions(+), 20 deletions(-)

diff --git a/drivers/video/omap2/dss/sdi.c b/drivers/video/omap2/dss/sdi.c
index 2e3afb8..9801a6e 100644
--- a/drivers/video/omap2/dss/sdi.c
+++ b/drivers/video/omap2/dss/sdi.c
@@ -251,30 +251,31 @@ void omapdss_sdi_set_datapairs(struct omap_dss_device 
*dssdev, int datapairs)
 }
 EXPORT_SYMBOL(omapdss_sdi_set_datapairs);
 
-static int sdi_init_display(struct omap_dss_device *dssdev)
+static int sdi_init_regulator(void)
 {
-   DSSDBG("SDI init\n");
-
-   if (sdi.vdds_sdi_reg == NULL) {
-   struct regulator *vdds_sdi;
-
-   vdds_sdi = dss_get_vdds_sdi();
-
-   if (IS_ERR(vdds_sdi)) {
-   vdds_sdi = regulator_get(&sdi.pdev->dev, "vdds_sdi");
-   if (IS_ERR(vdds_sdi)) {
-   DSSERR("can't get VDDS_SDI regulator\n");
-   return PTR_ERR(vdds_sdi);
-   }
-   sdi.vdds_sdi_from_core = false;
-   } else {
-   sdi.vdds_sdi_from_core = true;
-   }
+   struct regulator *vdds_sdi;
+
+   if (sdi.vdds_sdi_reg != NULL)
+   return 0;
 
+   vdds_sdi = dss_get_vdds_sdi();
+
+   if (!IS_ERR(vdds_sdi)) {
+   sdi.vdds_sdi_from_core = true;
sdi.vdds_sdi_reg = vdds_sdi;
+   return 0;
}
 
-   return 0;
+   vdds_sdi = regulator_get(&sdi.pdev->dev, "vdds_sdi");
+
+   if (!IS_ERR(vdds_sdi)) {
+   sdi.vdds_sdi_from_core = false;
+   sdi.vdds_sdi_reg = vdds_sdi;
+   }
+
+   DSSERR("can't get VDDS_SDI regulator\n");
+
+   return PTR_ERR(vdds_sdi);
 }
 
 static struct omap_dss_device *sdi_find_dssdev(struct platform_device *pdev)
@@ -322,7 +323,7 @@ static int sdi_probe_pdata(struct platform_device *sdidev)
 
dss_copy_device_pdata(dssdev, plat_dssdev);
 
-   r = sdi_init_display(dssdev);
+   r = sdi_init_regulator();
if (r) {
DSSERR("device %s init failed: %d\n", dssdev->name, r);
dss_put_device(dssdev);
-- 
1.8.1.2

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


[PATCH 18/32] OMAPDSS: VENC: clean up regulator init

2013-05-30 Thread Tomi Valkeinen
Clean up the VENC driver's regulator init to remove the (unused)
omap_dss_device parameter, renaming the function to a more sensible
name, and making the code slightly clearer.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/venc.c | 32 ++--
 1 file changed, 14 insertions(+), 18 deletions(-)

diff --git a/drivers/video/omap2/dss/venc.c b/drivers/video/omap2/dss/venc.c
index 7b2e3ae..f484b9f 100644
--- a/drivers/video/omap2/dss/venc.c
+++ b/drivers/video/omap2/dss/venc.c
@@ -633,23 +633,22 @@ void omapdss_venc_invert_vid_out_polarity(struct 
omap_dss_device *dssdev,
mutex_unlock(&venc.venc_lock);
 }
 
-static int venc_init_display(struct omap_dss_device *dssdev)
+static int venc_init_regulator(void)
 {
-   DSSDBG("init_display\n");
+   struct regulator *vdda_dac;
 
-   if (venc.vdda_dac_reg == NULL) {
-   struct regulator *vdda_dac;
-
-   vdda_dac = regulator_get(&venc.pdev->dev, "vdda_dac");
+   if (venc.vdda_dac_reg != NULL)
+   return 0;
 
-   if (IS_ERR(vdda_dac)) {
-   DSSERR("can't get VDDA_DAC regulator\n");
-   return PTR_ERR(vdda_dac);
-   }
+   vdda_dac = regulator_get(&venc.pdev->dev, "vdda_dac");
 
-   venc.vdda_dac_reg = vdda_dac;
+   if (IS_ERR(vdda_dac)) {
+   DSSERR("can't get VDDA_DAC regulator\n");
+   return PTR_ERR(vdda_dac);
}
 
+   venc.vdda_dac_reg = vdda_dac;
+
return 0;
 }
 
@@ -765,19 +764,16 @@ static int venc_probe_pdata(struct platform_device 
*vencdev)
if (!plat_dssdev)
return 0;
 
+   r = venc_init_regulator();
+   if (r)
+   return r;
+
dssdev = dss_alloc_and_init_device(&vencdev->dev);
if (!dssdev)
return -ENOMEM;
 
dss_copy_device_pdata(dssdev, plat_dssdev);
 
-   r = venc_init_display(dssdev);
-   if (r) {
-   DSSERR("device %s init failed: %d\n", dssdev->name, r);
-   dss_put_device(dssdev);
-   return r;
-   }
-
r = omapdss_output_set_device(&venc.output, dssdev);
if (r) {
DSSERR("failed to connect output to new device: %s\n",
-- 
1.8.1.2

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


[PATCH 19/32] OMAPDSS: add videomode conversion support

2013-05-30 Thread Tomi Valkeinen
Add helper functions to convert between omapdss specific video timings
and the common videomode.

Eventually omapdss will be changed to use only the common video timings,
and these helper functions will make the transition easier.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/Kconfig   |  1 +
 drivers/video/omap2/dss/display.c | 69 +++
 include/video/omapdss.h   |  7 
 3 files changed, 77 insertions(+)

diff --git a/drivers/video/omap2/dss/Kconfig b/drivers/video/omap2/dss/Kconfig
index cb0f145..8f70a83 100644
--- a/drivers/video/omap2/dss/Kconfig
+++ b/drivers/video/omap2/dss/Kconfig
@@ -1,5 +1,6 @@
 menuconfig OMAP2_DSS
 tristate "OMAP2+ Display Subsystem support"
+   select VIDEOMODE_HELPERS
 help
  OMAP2+ Display Subsystem support.
 
diff --git a/drivers/video/omap2/dss/display.c 
b/drivers/video/omap2/dss/display.c
index 0aa8ad8..72ac058 100644
--- a/drivers/video/omap2/dss/display.c
+++ b/drivers/video/omap2/dss/display.c
@@ -219,3 +219,72 @@ void omap_dss_stop_device(struct omap_dss_device *dssdev)
 }
 EXPORT_SYMBOL(omap_dss_stop_device);
 
+void videomode_to_omap_video_timings(const struct videomode *vm,
+   struct omap_video_timings *ovt)
+{
+   memset(ovt, 0, sizeof(*ovt));
+
+   ovt->pixel_clock = vm->pixelclock / 1000;
+   ovt->x_res = vm->hactive;
+   ovt->hbp = vm->hback_porch;
+   ovt->hfp = vm->hfront_porch;
+   ovt->hsw = vm->hsync_len;
+   ovt->y_res = vm->vactive;
+   ovt->vbp = vm->vback_porch;
+   ovt->vfp = vm->vfront_porch;
+   ovt->vsw = vm->vsync_len;
+
+   ovt->vsync_level = vm->flags & DISPLAY_FLAGS_VSYNC_HIGH ?
+   OMAPDSS_SIG_ACTIVE_HIGH :
+   OMAPDSS_SIG_ACTIVE_LOW;
+   ovt->hsync_level = vm->flags & DISPLAY_FLAGS_HSYNC_HIGH ?
+   OMAPDSS_SIG_ACTIVE_HIGH :
+   OMAPDSS_SIG_ACTIVE_LOW;
+   ovt->de_level = vm->flags & DISPLAY_FLAGS_DE_HIGH ?
+   OMAPDSS_SIG_ACTIVE_HIGH :
+   OMAPDSS_SIG_ACTIVE_HIGH;
+   ovt->data_pclk_edge = vm->flags & DISPLAY_FLAGS_PIXDATA_POSEDGE ?
+   OMAPDSS_DRIVE_SIG_RISING_EDGE :
+   OMAPDSS_DRIVE_SIG_FALLING_EDGE;
+
+   ovt->sync_pclk_edge = OMAPDSS_DRIVE_SIG_OPPOSITE_EDGES;
+}
+EXPORT_SYMBOL(videomode_to_omap_video_timings);
+
+void omap_video_timings_to_videomode(const struct omap_video_timings *ovt,
+   struct videomode *vm)
+{
+   memset(vm, 0, sizeof(*vm));
+
+   vm->pixelclock = ovt->pixel_clock * 1000;
+
+   vm->hactive = ovt->x_res;
+   vm->hback_porch = ovt->hbp;
+   vm->hfront_porch = ovt->hfp;
+   vm->hsync_len = ovt->hsw;
+   vm->vactive = ovt->y_res;
+   vm->vback_porch = ovt->vbp;
+   vm->vfront_porch = ovt->vfp;
+   vm->vsync_len = ovt->vsw;
+
+   if (ovt->hsync_level == OMAPDSS_SIG_ACTIVE_HIGH)
+   vm->flags |= DISPLAY_FLAGS_HSYNC_HIGH;
+   else
+   vm->flags |= DISPLAY_FLAGS_HSYNC_LOW;
+
+   if (ovt->vsync_level == OMAPDSS_SIG_ACTIVE_HIGH)
+   vm->flags |= DISPLAY_FLAGS_VSYNC_HIGH;
+   else
+   vm->flags |= DISPLAY_FLAGS_VSYNC_LOW;
+
+   if (ovt->de_level == OMAPDSS_SIG_ACTIVE_HIGH)
+   vm->flags |= DISPLAY_FLAGS_DE_HIGH;
+   else
+   vm->flags |= DISPLAY_FLAGS_DE_LOW;
+
+   if (ovt->data_pclk_edge == OMAPDSS_DRIVE_SIG_RISING_EDGE)
+   vm->flags |= DISPLAY_FLAGS_PIXDATA_POSEDGE;
+   else
+   vm->flags |= DISPLAY_FLAGS_PIXDATA_NEGEDGE;
+}
+EXPORT_SYMBOL(omap_video_timings_to_videomode);
diff --git a/include/video/omapdss.h b/include/video/omapdss.h
index f747266..6c422f7 100644
--- a/include/video/omapdss.h
+++ b/include/video/omapdss.h
@@ -23,6 +23,8 @@
 #include 
 #include 
 
+#include 
+
 #define DISPC_IRQ_FRAMEDONE(1 << 0)
 #define DISPC_IRQ_VSYNC(1 << 1)
 #define DISPC_IRQ_EVSYNC_EVEN  (1 << 2)
@@ -767,6 +769,11 @@ const char *omapdss_get_default_display_name(void);
 int omap_dss_start_device(struct omap_dss_device *dssdev);
 void omap_dss_stop_device(struct omap_dss_device *dssdev);
 
+void videomode_to_omap_video_timings(const struct videomode *vm,
+   struct omap_video_timings *ovt);
+void omap_video_timings_to_videomode(const struct omap_video_timings *ovt,
+   struct videomode *vm);
+
 int dss_feat_get_num_mgrs(void);
 int dss_feat_get_num_ovls(void);
 enum omap_display_type dss_feat_get_supported_displays(enum omap_channel 
channel);
-- 
1.8.1.2

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


[PATCH 20/32] OMAPDSS: remove dssdev uses in trivial cases

2013-05-30 Thread Tomi Valkeinen
In the future the "dssdev" parameter passed to output drivers will
change its meaning. Instead of being a pointer to the panel device, it's
a pointer to the output instance.

To make the transition easier, some of the uses for this dssdev
parameter can be easily removed.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/hdmi.c | 6 +++---
 drivers/video/omap2/dss/rfbi.c | 8 
 drivers/video/omap2/dss/sdi.c  | 6 +++---
 drivers/video/omap2/dss/venc.c | 6 +++---
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/drivers/video/omap2/dss/hdmi.c b/drivers/video/omap2/dss/hdmi.c
index 960083b..6d1e97c 100644
--- a/drivers/video/omap2/dss/hdmi.c
+++ b/drivers/video/omap2/dss/hdmi.c
@@ -560,7 +560,7 @@ static int hdmi_power_on_full(struct omap_dss_device 
*dssdev)
 {
int r;
struct omap_video_timings *p;
-   struct omap_overlay_manager *mgr = dssdev->output->manager;
+   struct omap_overlay_manager *mgr = hdmi.output.manager;
unsigned long phy;
 
r = hdmi_power_on_core(dssdev);
@@ -623,7 +623,7 @@ err_pll_enable:
 
 static void hdmi_power_off_full(struct omap_dss_device *dssdev)
 {
-   struct omap_overlay_manager *mgr = dssdev->output->manager;
+   struct omap_overlay_manager *mgr = hdmi.output.manager;
 
dss_mgr_disable(mgr);
 
@@ -720,7 +720,7 @@ bool omapdss_hdmi_detect(void)
 
 int omapdss_hdmi_display_enable(struct omap_dss_device *dssdev)
 {
-   struct omap_dss_output *out = dssdev->output;
+   struct omap_dss_output *out = &hdmi.output;
int r = 0;
 
DSSDBG("ENTER hdmi_display_enable\n");
diff --git a/drivers/video/omap2/dss/rfbi.c b/drivers/video/omap2/dss/rfbi.c
index 1ff221e..cfcb52f 100644
--- a/drivers/video/omap2/dss/rfbi.c
+++ b/drivers/video/omap2/dss/rfbi.c
@@ -312,7 +312,7 @@ static int rfbi_transfer_area(struct omap_dss_device 
*dssdev,
 {
u32 l;
int r;
-   struct omap_overlay_manager *mgr = dssdev->output->manager;
+   struct omap_overlay_manager *mgr = rfbi.output.manager;
u16 width = rfbi.timings.x_res;
u16 height = rfbi.timings.y_res;
 
@@ -852,7 +852,7 @@ static void rfbi_dump_regs(struct seq_file *s)
 
 static void rfbi_config_lcd_manager(struct omap_dss_device *dssdev)
 {
-   struct omap_overlay_manager *mgr = dssdev->output->manager;
+   struct omap_overlay_manager *mgr = rfbi.output.manager;
struct dss_lcd_mgr_config mgr_config;
 
mgr_config.io_pad_mode = DSS_IO_PAD_MODE_RFBI;
@@ -890,7 +890,7 @@ static void rfbi_config_lcd_manager(struct omap_dss_device 
*dssdev)
 
 int omapdss_rfbi_display_enable(struct omap_dss_device *dssdev)
 {
-   struct omap_dss_output *out = dssdev->output;
+   struct omap_dss_output *out = &rfbi.output;
int r;
 
if (out == NULL || out->manager == NULL) {
@@ -933,7 +933,7 @@ EXPORT_SYMBOL(omapdss_rfbi_display_enable);
 
 void omapdss_rfbi_display_disable(struct omap_dss_device *dssdev)
 {
-   struct omap_dss_output *out = dssdev->output;
+   struct omap_dss_output *out = &rfbi.output;
 
dss_mgr_unregister_framedone_handler(out->manager,
framedone_callback, NULL);
diff --git a/drivers/video/omap2/dss/sdi.c b/drivers/video/omap2/dss/sdi.c
index 9801a6e..e723687 100644
--- a/drivers/video/omap2/dss/sdi.c
+++ b/drivers/video/omap2/dss/sdi.c
@@ -112,7 +112,7 @@ static int sdi_calc_clock_div(unsigned long pclk,
 
 static void sdi_config_lcd_manager(struct omap_dss_device *dssdev)
 {
-   struct omap_overlay_manager *mgr = dssdev->output->manager;
+   struct omap_overlay_manager *mgr = sdi.output.manager;
 
sdi.mgr_config.io_pad_mode = DSS_IO_PAD_MODE_BYPASS;
 
@@ -127,7 +127,7 @@ static void sdi_config_lcd_manager(struct omap_dss_device 
*dssdev)
 
 int omapdss_sdi_display_enable(struct omap_dss_device *dssdev)
 {
-   struct omap_dss_output *out = dssdev->output;
+   struct omap_dss_output *out = &sdi.output;
struct omap_video_timings *t = &sdi.timings;
struct dss_clock_info dss_cinfo;
struct dispc_clock_info dispc_cinfo;
@@ -224,7 +224,7 @@ EXPORT_SYMBOL(omapdss_sdi_display_enable);
 
 void omapdss_sdi_display_disable(struct omap_dss_device *dssdev)
 {
-   struct omap_overlay_manager *mgr = dssdev->output->manager;
+   struct omap_overlay_manager *mgr = sdi.output.manager;
 
dss_mgr_disable(mgr);
 
diff --git a/drivers/video/omap2/dss/venc.c b/drivers/video/omap2/dss/venc.c
index f484b9f..af404b4 100644
--- a/drivers/video/omap2/dss/venc.c
+++ b/drivers/video/omap2/dss/venc.c
@@ -429,7 +429,7 @@ static const struct venc_config *venc_timings_to_config(
 
 static int venc_power_on(struct omap_dss_device *dssdev)
 {
-   struct omap_overlay_manager *mgr = dssdev->output->manager;
+   struct omap_overlay_manager *mgr = venc.output.manager;
u32 l;
int r;
 
@@ -480,7 +480,7 @@ err0:
 
 static void venc_power_off(struct omap_dss_device *dssdev)
 {
-   s

[PATCH 21/32] OMAPDSS: add panel list

2013-05-30 Thread Tomi Valkeinen
We currently use the omapdss bus (which contains all the available
displays) to iterate the displays. As the omapdss bus is on its way out,
this needs to be changed.

Instead of using the dss bus to iterate displays, this patch adds our
own list of displays which we manage. The panels on the dss bus are
automatically added to this new list.

An "alias" field is also added to omap_dss_device. This field is
set to "display%d", the same way as omap_dss_device's dev name is set.
This alias is later used to keep backward compatibility, when the
embedded dev is no longer used.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/core.c|  2 ++
 drivers/video/omap2/dss/display.c | 32 
 include/video/omapdss.h   |  8 
 3 files changed, 42 insertions(+)

diff --git a/drivers/video/omap2/dss/core.c b/drivers/video/omap2/dss/core.c
index f64d0ac..186bc76 100644
--- a/drivers/video/omap2/dss/core.c
+++ b/drivers/video/omap2/dss/core.c
@@ -469,6 +469,7 @@ struct omap_dss_device *dss_alloc_and_init_device(struct 
device *parent)
 
 int dss_add_device(struct omap_dss_device *dssdev)
 {
+   omapdss_register_display(dssdev);
return device_add(&dssdev->dev);
 }
 
@@ -480,6 +481,7 @@ void dss_put_device(struct omap_dss_device *dssdev)
 void dss_unregister_device(struct omap_dss_device *dssdev)
 {
device_unregister(&dssdev->dev);
+   omapdss_unregister_display(dssdev);
 }
 
 static int dss_unregister_dss_dev(struct device *dev, void *data)
diff --git a/drivers/video/omap2/dss/display.c 
b/drivers/video/omap2/dss/display.c
index 72ac058..1c175a4 100644
--- a/drivers/video/omap2/dss/display.c
+++ b/drivers/video/omap2/dss/display.c
@@ -146,6 +146,38 @@ void dss_disable_all_devices(void)
bus_for_each_dev(bus, NULL, NULL, dss_disable_device);
 }
 
+static LIST_HEAD(panel_list);
+static DEFINE_MUTEX(panel_list_mutex);
+static int disp_num_counter;
+
+int omapdss_register_display(struct omap_dss_device *dssdev)
+{
+   struct omap_dss_driver *drv = dssdev->driver;
+
+   snprintf(dssdev->alias, sizeof(dssdev->alias),
+   "display%d", disp_num_counter++);
+
+   if (drv && drv->get_resolution == NULL)
+   drv->get_resolution = omapdss_default_get_resolution;
+   if (drv && drv->get_recommended_bpp == NULL)
+   drv->get_recommended_bpp = omapdss_default_get_recommended_bpp;
+   if (drv && drv->get_timings == NULL)
+   drv->get_timings = omapdss_default_get_timings;
+
+   mutex_lock(&panel_list_mutex);
+   list_add_tail(&dssdev->panel_list, &panel_list);
+   mutex_unlock(&panel_list_mutex);
+   return 0;
+}
+EXPORT_SYMBOL(omapdss_register_display);
+
+void omapdss_unregister_display(struct omap_dss_device *dssdev)
+{
+   mutex_lock(&panel_list_mutex);
+   list_del(&dssdev->panel_list);
+   mutex_unlock(&panel_list_mutex);
+}
+EXPORT_SYMBOL(omapdss_unregister_display);
 
 void omap_dss_get_device(struct omap_dss_device *dssdev)
 {
diff --git a/include/video/omapdss.h b/include/video/omapdss.h
index 6c422f7..b19a8d2 100644
--- a/include/video/omapdss.h
+++ b/include/video/omapdss.h
@@ -598,6 +598,11 @@ struct omap_dss_output {
 struct omap_dss_device {
struct device dev;
 
+   struct list_head panel_list;
+
+   /* alias in the form of "display%d" */
+   char alias[16];
+
enum omap_display_type type;
 
/* obsolete, to be removed */
@@ -758,6 +763,9 @@ enum omapdss_version omapdss_get_version(void);
 int omap_dss_register_driver(struct omap_dss_driver *);
 void omap_dss_unregister_driver(struct omap_dss_driver *);
 
+int omapdss_register_display(struct omap_dss_device *dssdev);
+void omapdss_unregister_display(struct omap_dss_device *dssdev);
+
 void omap_dss_get_device(struct omap_dss_device *dssdev);
 void omap_dss_put_device(struct omap_dss_device *dssdev);
 #define for_each_dss_dev(d) while ((d = omap_dss_get_next_device(d)) != NULL)
-- 
1.8.1.2

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


[PATCH 22/32] OMAPDSS: use the panel list in omap_dss_get_next_device

2013-05-30 Thread Tomi Valkeinen
omap_dss_get_next_device() uses the dss bus to iterate over the
displays. This patch changes omap_dss_get_next_device() to use the new
panel list instead.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/display.c | 54 ---
 1 file changed, 39 insertions(+), 15 deletions(-)

diff --git a/drivers/video/omap2/dss/display.c 
b/drivers/video/omap2/dss/display.c
index 1c175a4..ba83ec3 100644
--- a/drivers/video/omap2/dss/display.c
+++ b/drivers/video/omap2/dss/display.c
@@ -191,27 +191,51 @@ void omap_dss_put_device(struct omap_dss_device *dssdev)
 }
 EXPORT_SYMBOL(omap_dss_put_device);
 
-/* ref count of the found device is incremented. ref count
- * of from-device is decremented. */
+/*
+ * ref count of the found device is incremented.
+ * ref count of from-device is decremented.
+ */
 struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from)
 {
-   struct device *dev;
-   struct device *dev_start = NULL;
-   struct omap_dss_device *dssdev = NULL;
+   struct list_head *l;
+   struct omap_dss_device *dssdev;
+
+   mutex_lock(&panel_list_mutex);
 
-   int match(struct device *dev, void *data)
-   {
-   return 1;
+   if (list_empty(&panel_list)) {
+   dssdev = NULL;
+   goto out;
}
 
-   if (from)
-   dev_start = &from->dev;
-   dev = bus_find_device(dss_get_bus(), dev_start, NULL, match);
-   if (dev)
-   dssdev = to_dss_device(dev);
-   if (from)
-   put_device(&from->dev);
+   if (from == NULL) {
+   dssdev = list_first_entry(&panel_list, struct omap_dss_device,
+   panel_list);
+   omap_dss_get_device(dssdev);
+   goto out;
+   }
+
+   omap_dss_put_device(from);
+
+   list_for_each(l, &panel_list) {
+   dssdev = list_entry(l, struct omap_dss_device, panel_list);
+   if (dssdev == from) {
+   if (list_is_last(l, &panel_list)) {
+   dssdev = NULL;
+   goto out;
+   }
+
+   dssdev = list_entry(l->next, struct omap_dss_device,
+   panel_list);
+   omap_dss_get_device(dssdev);
+   goto out;
+   }
+   }
 
+   WARN(1, "'from' dssdev not found\n");
+
+   dssdev = NULL;
+out:
+   mutex_unlock(&panel_list_mutex);
return dssdev;
 }
 EXPORT_SYMBOL(omap_dss_get_next_device);
-- 
1.8.1.2

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


[PATCH 23/32] OMAPDSS: don't use dss bus in suspend/resume

2013-05-30 Thread Tomi Valkeinen
We have support functions to suspend and resume all the displays that
are used with system suspend. These functions use the dss bus to iterate
the display devices.

As we aim to remove the custom dss bus totally, this patch removes the
explicit use of dss bus from these functions. Instead the
for_each_dss_dev() macro is used to go through the devices.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/display.c | 77 ++-
 1 file changed, 28 insertions(+), 49 deletions(-)

diff --git a/drivers/video/omap2/dss/display.c 
b/drivers/video/omap2/dss/display.c
index ba83ec3..dfe3322 100644
--- a/drivers/video/omap2/dss/display.c
+++ b/drivers/video/omap2/dss/display.c
@@ -76,74 +76,53 @@ void omapdss_default_get_timings(struct omap_dss_device 
*dssdev,
 }
 EXPORT_SYMBOL(omapdss_default_get_timings);
 
-static int dss_suspend_device(struct device *dev, void *data)
-{
-   struct omap_dss_device *dssdev = to_dss_device(dev);
-
-   if (dssdev->state != OMAP_DSS_DISPLAY_ACTIVE) {
-   dssdev->activate_after_resume = false;
-   return 0;
-   }
-
-   dssdev->driver->disable(dssdev);
-
-   dssdev->activate_after_resume = true;
-
-   return 0;
-}
-
 int dss_suspend_all_devices(void)
 {
-   int r;
-   struct bus_type *bus = dss_get_bus();
-
-   r = bus_for_each_dev(bus, NULL, NULL, dss_suspend_device);
-   if (r) {
-   /* resume all displays that were suspended */
-   dss_resume_all_devices();
-   return r;
-   }
-
-   return 0;
-}
+   struct omap_dss_device *dssdev = NULL;
 
-static int dss_resume_device(struct device *dev, void *data)
-{
-   int r;
-   struct omap_dss_device *dssdev = to_dss_device(dev);
+   for_each_dss_dev(dssdev) {
+   if (!dssdev->driver)
+   continue;
 
-   if (dssdev->activate_after_resume) {
-   r = dssdev->driver->enable(dssdev);
-   if (r)
-   return r;
+   if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE) {
+   dssdev->driver->disable(dssdev);
+   dssdev->activate_after_resume = true;
+   } else {
+   dssdev->activate_after_resume = false;
+   }
}
 
-   dssdev->activate_after_resume = false;
-
return 0;
 }
 
 int dss_resume_all_devices(void)
 {
-   struct bus_type *bus = dss_get_bus();
-
-   return bus_for_each_dev(bus, NULL, NULL, dss_resume_device);
-}
+   struct omap_dss_device *dssdev = NULL;
 
-static int dss_disable_device(struct device *dev, void *data)
-{
-   struct omap_dss_device *dssdev = to_dss_device(dev);
+   for_each_dss_dev(dssdev) {
+   if (!dssdev->driver)
+   continue;
 
-   if (dssdev->state != OMAP_DSS_DISPLAY_DISABLED)
-   dssdev->driver->disable(dssdev);
+   if (dssdev->activate_after_resume) {
+   dssdev->driver->enable(dssdev);
+   dssdev->activate_after_resume = false;
+   }
+   }
 
return 0;
 }
 
 void dss_disable_all_devices(void)
 {
-   struct bus_type *bus = dss_get_bus();
-   bus_for_each_dev(bus, NULL, NULL, dss_disable_device);
+   struct omap_dss_device *dssdev = NULL;
+
+   for_each_dss_dev(dssdev) {
+   if (!dssdev->driver)
+   continue;
+
+   if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE)
+   dssdev->driver->disable(dssdev);
+   }
 }
 
 static LIST_HEAD(panel_list);
-- 
1.8.1.2

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


[PATCH 24/32] OMAPDSS: implement display sysfs without dss bus

2013-05-30 Thread Tomi Valkeinen
We aim to remove the custom omapdss bus totally, as it's quite a strange
construct and won't be compatible with common display framework. One
problem on the road is that we have sysfs files for each display, and
they depend on the omapdss bus.

This patch creates the display sysfs files independent of the omapdss
bus. This gives us backwards compatibility without using the omapdss bus
for the sysfs files.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/apply.c |  15 ++--
 drivers/video/omap2/dss/core.c  |  28 ---
 drivers/video/omap2/dss/display-sysfs.c | 125 ++--
 drivers/video/omap2/dss/dss.h   |   6 +-
 4 files changed, 79 insertions(+), 95 deletions(-)

diff --git a/drivers/video/omap2/dss/apply.c b/drivers/video/omap2/dss/apply.c
index dbd3c2f..ced656a 100644
--- a/drivers/video/omap2/dss/apply.c
+++ b/drivers/video/omap2/dss/apply.c
@@ -1581,7 +1581,6 @@ static DEFINE_MUTEX(compat_init_lock);
 int omapdss_compat_init(void)
 {
struct platform_device *pdev = dss_get_core_pdev();
-   struct omap_dss_device *dssdev = NULL;
int i, r;
 
mutex_lock(&compat_init_lock);
@@ -1627,12 +1626,9 @@ int omapdss_compat_init(void)
if (r)
goto err_mgr_ops;
 
-   for_each_dss_dev(dssdev) {
-   r = display_init_sysfs(pdev, dssdev);
-   /* XXX uninit sysfs files on error */
-   if (r)
-   goto err_disp_sysfs;
-   }
+   r = display_init_sysfs(pdev);
+   if (r)
+   goto err_disp_sysfs;
 
dispc_runtime_get();
 
@@ -1649,6 +1645,7 @@ out:
 
 err_init_irq:
dispc_runtime_put();
+   display_uninit_sysfs(pdev);
 
 err_disp_sysfs:
dss_uninstall_mgr_ops();
@@ -1668,7 +1665,6 @@ EXPORT_SYMBOL(omapdss_compat_init);
 void omapdss_compat_uninit(void)
 {
struct platform_device *pdev = dss_get_core_pdev();
-   struct omap_dss_device *dssdev = NULL;
 
mutex_lock(&compat_init_lock);
 
@@ -1677,8 +1673,7 @@ void omapdss_compat_uninit(void)
 
dss_dispc_uninitialize_irq();
 
-   for_each_dss_dev(dssdev)
-   display_uninit_sysfs(pdev, dssdev);
+   display_uninit_sysfs(pdev);
 
dss_uninstall_mgr_ops();
 
diff --git a/drivers/video/omap2/dss/core.c b/drivers/video/omap2/dss/core.c
index 186bc76..e88d5f0 100644
--- a/drivers/video/omap2/dss/core.c
+++ b/drivers/video/omap2/dss/core.c
@@ -284,37 +284,9 @@ static int dss_bus_match(struct device *dev, struct 
device_driver *driver)
return strcmp(dssdev->driver_name, driver->name) == 0;
 }
 
-static ssize_t device_name_show(struct device *dev,
-   struct device_attribute *attr, char *buf)
-{
-   struct omap_dss_device *dssdev = to_dss_device(dev);
-   return snprintf(buf, PAGE_SIZE, "%s\n",
-   dssdev->name ?
-   dssdev->name : "");
-}
-
-static struct device_attribute default_dev_attrs[] = {
-   __ATTR(name, S_IRUGO, device_name_show, NULL),
-   __ATTR_NULL,
-};
-
-static ssize_t driver_name_show(struct device_driver *drv, char *buf)
-{
-   struct omap_dss_driver *dssdrv = to_dss_driver(drv);
-   return snprintf(buf, PAGE_SIZE, "%s\n",
-   dssdrv->driver.name ?
-   dssdrv->driver.name : "");
-}
-static struct driver_attribute default_drv_attrs[] = {
-   __ATTR(name, S_IRUGO, driver_name_show, NULL),
-   __ATTR_NULL,
-};
-
 static struct bus_type dss_bus_type = {
.name = "omapdss",
.match = dss_bus_match,
-   .dev_attrs = default_dev_attrs,
-   .drv_attrs = default_drv_attrs,
 };
 
 static void dss_bus_release(struct device *dev)
diff --git a/drivers/video/omap2/dss/display-sysfs.c 
b/drivers/video/omap2/dss/display-sysfs.c
index 81d5dc6..58abbaf 100644
--- a/drivers/video/omap2/dss/display-sysfs.c
+++ b/drivers/video/omap2/dss/display-sysfs.c
@@ -22,17 +22,40 @@
 
 #include 
 #include 
-#include 
 #include 
+#include 
 
 #include 
 #include "dss.h"
-#include "dss_features.h"
+
+static struct omap_dss_device *to_dss_device_sysfs(struct device *dev)
+{
+   struct omap_dss_device *dssdev = NULL;
+
+   for_each_dss_dev(dssdev) {
+   if (&dssdev->dev == dev) {
+   omap_dss_put_device(dssdev);
+   return dssdev;
+   }
+   }
+
+   return NULL;
+}
+
+static ssize_t display_name_show(struct device *dev,
+   struct device_attribute *attr, char *buf)
+{
+   struct omap_dss_device *dssdev = to_dss_device_sysfs(dev);
+
+   return snprintf(buf, PAGE_SIZE, "%s\n",
+   dssdev->name ?
+   dssdev->name : "");
+}
 
 static ssize_t display_enabled_show(struct device *dev,
struct device_attribute *attr, char *buf)
 {
-   struct omap_dss_device *dssdev = to_dss_device(dev);
+   struct omap_dss_device *dssdev = to_dss_device

[PATCH 25/32] OMAPDSS: Add panel dev pointer to dssdev

2013-05-30 Thread Tomi Valkeinen
We are about to remove the dss bus support, which also means that the
omap_dss_device won't be a real device anymore. This means that the
embedded "dev" struct needs to be removed from omap_dss_device.

After we've finished the removal of the dss bus, we see the following
changes:

- struct omap_dss_device won't be a real Linux device anymore, but more
  like a "display entity".
- struct omap_dss_driver won't be a Linux device driver, but "display
  entity ops".
- The panel devices/drivers won't be omapdss devices/drivers, but
  platform/i2c/spi/etc devices/drivers, whichever fits the control
  mechanism of the panel.
- The panel drivers will create omap_dss_device and omap_dss_driver,
  fill the required fields, and register the omap_dss_device to
  omapdss.
- omap_dss_device won't have an embedded dev struct anymore, but a
  dev pointer to the actual device that manages the omap_dss_device.

The model described above resembles the model that has been discussed
with CDF (common display framework).

For the duration of the conversion, we temporarily have two devs in the
dssdev, the old "old_dev", which is a full embedded device struct, and the
new "dev", which is a pointer to the device. "old_dev" will be removed
in the future.

For devices belonging to dss bus the dev is initialized to point to
old_dev. This way all the code can just use the dev, for both old and
new style panels.

Both the new and old style panel drivers work during the conversion, and
only after the dss bus support is removed will the old style panels stop
to compile.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/displays/panel-acx565akm.c |  16 +-
 drivers/video/omap2/displays/panel-generic-dpi.c   |  26 ++--
 .../omap2/displays/panel-lgphilips-lb035q02.c  |  10 +-
 drivers/video/omap2/displays/panel-n8x0.c  |  30 ++--
 .../omap2/displays/panel-nec-nl8048hl11-01b.c  |   4 +-
 drivers/video/omap2/displays/panel-picodlp.c   |  32 ++--
 .../video/omap2/displays/panel-sharp-ls037v7dw01.c |  10 +-
 drivers/video/omap2/displays/panel-taal.c  | 164 ++---
 drivers/video/omap2/displays/panel-tfp410.c|  32 ++--
 .../video/omap2/displays/panel-tpo-td043mtea1.c|  36 ++---
 drivers/video/omap2/dss/core.c |  18 ++-
 drivers/video/omap2/dss/display-sysfs.c|   7 +-
 drivers/video/omap2/dss/display.c  |   9 +-
 drivers/video/omap2/dss/venc_panel.c   |  16 +-
 include/video/omapdss.h|   8 +-
 15 files changed, 212 insertions(+), 206 deletions(-)

diff --git a/drivers/video/omap2/displays/panel-acx565akm.c 
b/drivers/video/omap2/displays/panel-acx565akm.c
index d7f69c0..3fd100f 100644
--- a/drivers/video/omap2/displays/panel-acx565akm.c
+++ b/drivers/video/omap2/displays/panel-acx565akm.c
@@ -510,7 +510,7 @@ static int acx_panel_probe(struct omap_dss_device *dssdev)
int max_brightness, brightness;
struct backlight_properties props;
 
-   dev_dbg(&dssdev->dev, "%s\n", __func__);
+   dev_dbg(dssdev->dev, "%s\n", __func__);
 
if (!panel_data)
return -EINVAL;
@@ -519,7 +519,7 @@ static int acx_panel_probe(struct omap_dss_device *dssdev)
dssdev->panel.timings = acx_panel_timings;
 
if (gpio_is_valid(panel_data->reset_gpio)) {
-   r = devm_gpio_request_one(&dssdev->dev, panel_data->reset_gpio,
+   r = devm_gpio_request_one(dssdev->dev, panel_data->reset_gpio,
GPIOF_OUT_INIT_LOW, "lcd reset");
if (r)
return r;
@@ -538,7 +538,7 @@ static int acx_panel_probe(struct omap_dss_device *dssdev)
 
r = panel_detect(md);
if (r) {
-   dev_err(&dssdev->dev, "%s panel detect error\n", __func__);
+   dev_err(dssdev->dev, "%s panel detect error\n", __func__);
if (!md->enabled && gpio_is_valid(panel_data->reset_gpio))
gpio_set_value(panel_data->reset_gpio, 0);
 
@@ -593,7 +593,7 @@ static void acx_panel_remove(struct omap_dss_device *dssdev)
 {
struct acx565akm_device *md = &acx_dev;
 
-   dev_dbg(&dssdev->dev, "%s\n", __func__);
+   dev_dbg(dssdev->dev, "%s\n", __func__);
sysfs_remove_group(&md->bl_dev->dev.kobj, &bldev_attr_group);
backlight_device_unregister(md->bl_dev);
mutex_lock(&acx_dev.mutex);
@@ -607,7 +607,7 @@ static int acx_panel_power_on(struct omap_dss_device 
*dssdev)
struct panel_acx565akm_data *panel_data = get_panel_data(dssdev);
int r;
 
-   dev_dbg(&dssdev->dev, "%s\n", __func__);
+   dev_dbg(dssdev->dev, "%s\n", __func__);
 
if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE)
return 0;
@@ -667,7 +667,7 @@ static void acx_panel_power_off(struct omap_dss_device 
*dssdev)
struct acx565akm_device *md = &acx_dev;
struct panel_acx565akm_data *panel_data = get_panel_data(dssd

[PATCH 26/32] OMAPDSS: remove omap_dss_start/stop_device()

2013-05-30 Thread Tomi Valkeinen
The omap_dss_start_device() and omap_dss_stop_device(), called by the
DSS output drivers, are old relics. They originally did something
totally else, but nowadays they increase the module ref count for panels
that are enabled.

This model is quite broken: the panel modules may be used even before
they are enabled. For example, configuring the panel requires calls to
functions located in the panel modules.

In the following patches we try to improve the ref count management for
the modules and display devices. The first step, however, is to remove
the omap_dss_start/stop_device() totally.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/display.c | 20 
 drivers/video/omap2/dss/dpi.c | 10 --
 drivers/video/omap2/dss/dsi.c | 10 --
 drivers/video/omap2/dss/hdmi.c| 12 +---
 drivers/video/omap2/dss/rfbi.c|  9 -
 drivers/video/omap2/dss/sdi.c | 10 --
 drivers/video/omap2/dss/venc.c| 12 +---
 include/video/omapdss.h   |  3 ---
 8 files changed, 2 insertions(+), 84 deletions(-)

diff --git a/drivers/video/omap2/dss/display.c 
b/drivers/video/omap2/dss/display.c
index a9a1d55..8096764 100644
--- a/drivers/video/omap2/dss/display.c
+++ b/drivers/video/omap2/dss/display.c
@@ -233,26 +233,6 @@ struct omap_dss_device *omap_dss_find_device(void *data,
 }
 EXPORT_SYMBOL(omap_dss_find_device);
 
-int omap_dss_start_device(struct omap_dss_device *dssdev)
-{
-   if (!dssdev->driver) {
-   DSSDBG("no driver\n");
-   return -ENODEV;
-   }
-
-   if (!try_module_get(dssdev->dev->driver->owner))
-   return -ENODEV;
-
-   return 0;
-}
-EXPORT_SYMBOL(omap_dss_start_device);
-
-void omap_dss_stop_device(struct omap_dss_device *dssdev)
-{
-   module_put(dssdev->dev->driver->owner);
-}
-EXPORT_SYMBOL(omap_dss_stop_device);
-
 void videomode_to_omap_video_timings(const struct videomode *vm,
struct omap_video_timings *ovt)
 {
diff --git a/drivers/video/omap2/dss/dpi.c b/drivers/video/omap2/dss/dpi.c
index 66ba9a6..d369927 100644
--- a/drivers/video/omap2/dss/dpi.c
+++ b/drivers/video/omap2/dss/dpi.c
@@ -365,12 +365,6 @@ int omapdss_dpi_display_enable(struct omap_dss_device 
*dssdev)
goto err_no_out_mgr;
}
 
-   r = omap_dss_start_device(dssdev);
-   if (r) {
-   DSSERR("failed to start device\n");
-   goto err_start_dev;
-   }
-
if (dss_has_feature(FEAT_DPI_USES_VDDS_DSI)) {
r = regulator_enable(dpi.vdds_dsi_reg);
if (r)
@@ -425,8 +419,6 @@ err_get_dispc:
if (dss_has_feature(FEAT_DPI_USES_VDDS_DSI))
regulator_disable(dpi.vdds_dsi_reg);
 err_reg_enable:
-   omap_dss_stop_device(dssdev);
-err_start_dev:
 err_no_out_mgr:
 err_no_reg:
mutex_unlock(&dpi.lock);
@@ -453,8 +445,6 @@ void omapdss_dpi_display_disable(struct omap_dss_device 
*dssdev)
if (dss_has_feature(FEAT_DPI_USES_VDDS_DSI))
regulator_disable(dpi.vdds_dsi_reg);
 
-   omap_dss_stop_device(dssdev);
-
mutex_unlock(&dpi.lock);
 }
 EXPORT_SYMBOL(omapdss_dpi_display_disable);
diff --git a/drivers/video/omap2/dss/dsi.c b/drivers/video/omap2/dss/dsi.c
index 37ca980..892838e 100644
--- a/drivers/video/omap2/dss/dsi.c
+++ b/drivers/video/omap2/dss/dsi.c
@@ -4592,12 +4592,6 @@ int omapdss_dsi_display_enable(struct omap_dss_device 
*dssdev)
 
mutex_lock(&dsi->lock);
 
-   r = omap_dss_start_device(dssdev);
-   if (r) {
-   DSSERR("failed to start device\n");
-   goto err_start_dev;
-   }
-
r = dsi_runtime_get(dsidev);
if (r)
goto err_get_dsi;
@@ -4618,8 +4612,6 @@ err_init_dsi:
dsi_enable_pll_clock(dsidev, 0);
dsi_runtime_put(dsidev);
 err_get_dsi:
-   omap_dss_stop_device(dssdev);
-err_start_dev:
mutex_unlock(&dsi->lock);
DSSDBG("dsi_display_enable FAILED\n");
return r;
@@ -4648,8 +4640,6 @@ void omapdss_dsi_display_disable(struct omap_dss_device 
*dssdev,
dsi_runtime_put(dsidev);
dsi_enable_pll_clock(dsidev, 0);
 
-   omap_dss_stop_device(dssdev);
-
mutex_unlock(&dsi->lock);
 }
 EXPORT_SYMBOL(omapdss_dsi_display_disable);
diff --git a/drivers/video/omap2/dss/hdmi.c b/drivers/video/omap2/dss/hdmi.c
index 6d1e97c..e7fe182 100644
--- a/drivers/video/omap2/dss/hdmi.c
+++ b/drivers/video/omap2/dss/hdmi.c
@@ -735,23 +735,15 @@ int omapdss_hdmi_display_enable(struct omap_dss_device 
*dssdev)
 
hdmi.ip_data.hpd_gpio = hdmi.hpd_gpio;
 
-   r = omap_dss_start_device(dssdev);
-   if (r) {
-   DSSERR("failed to start device\n");
-   goto err0;
-   }
-
r = hdmi_power_on_full(dssdev);
if (r) {
DSSERR("failed to power on device\n");
-   goto err1;
+   goto err0;
}
 
mutex_unlock(&hdmi.lock);
  

[PATCH 27/32] OMAPDSS: combine omap_dss_output into omap_dss_device

2013-05-30 Thread Tomi Valkeinen
We currently have omap_dss_device, which represents an external display
device, sometimes an external encoder, sometimes a panel. Then we have
omap_dss_output, which represents DSS's output encoder.

In the future with new display device model, we construct a video
pipeline from the display blocks. To accomplish this, all the blocks
need to be presented by the same entity.

Thus, this patch combines omap_dss_output into omap_dss_device. Some of
the fields in omap_dss_output are already found in omap_dss_device, but
some are not. This means we'll have DSS output specific fields in
omap_dss_device, which is not very nice. However, it is easier to just
keep those output specific fields there for now, and after transition to
new display device model is made, they can be cleaned up easier than
could be done now.

Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/omap_crtc.c |  4 +--
 drivers/gpu/drm/omapdrm/omap_drv.c  |  2 +-
 drivers/video/omap2/dss/apply.c |  6 ++--
 drivers/video/omap2/dss/core.c  |  4 +--
 drivers/video/omap2/dss/dpi.c   | 12 +++
 drivers/video/omap2/dss/dsi.c   | 18 +-
 drivers/video/omap2/dss/dss.h   |  4 +--
 drivers/video/omap2/dss/hdmi.c  | 12 +++
 drivers/video/omap2/dss/output.c| 32 +-
 drivers/video/omap2/dss/rfbi.c  | 14 
 drivers/video/omap2/dss/sdi.c   | 12 +++
 drivers/video/omap2/dss/venc.c  | 12 +++
 include/video/omapdss.h | 66 +
 13 files changed, 96 insertions(+), 102 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_crtc.c 
b/drivers/gpu/drm/omapdrm/omap_crtc.c
index b2ab2f5..4cec678 100644
--- a/drivers/gpu/drm/omapdrm/omap_crtc.c
+++ b/drivers/gpu/drm/omapdrm/omap_crtc.c
@@ -95,7 +95,7 @@ static struct omap_crtc *omap_crtcs[8];
 
 /* we can probably ignore these until we support command-mode panels: */
 static int omap_crtc_connect(struct omap_overlay_manager *mgr,
-   struct omap_dss_output *dst)
+   struct omap_dss_device *dst)
 {
if (mgr->output)
return -EINVAL;
@@ -110,7 +110,7 @@ static int omap_crtc_connect(struct omap_overlay_manager 
*mgr,
 }
 
 static void omap_crtc_disconnect(struct omap_overlay_manager *mgr,
-   struct omap_dss_output *dst)
+   struct omap_dss_device *dst)
 {
mgr->output->manager = NULL;
mgr->output = NULL;
diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index 58bd259..a72100c 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -259,7 +259,7 @@ static int omap_modeset_init(struct drm_device *dev)
struct drm_encoder *encoder = priv->encoders[i];
struct omap_dss_device *dssdev =
omap_encoder_get_dssdev(encoder);
-   struct omap_dss_output *output;
+   struct omap_dss_device *output;
 
output = omapdss_find_output_from_display(dssdev);
 
diff --git a/drivers/video/omap2/dss/apply.c b/drivers/video/omap2/dss/apply.c
index ced656a..752b985 100644
--- a/drivers/video/omap2/dss/apply.c
+++ b/drivers/video/omap2/dss/apply.c
@@ -791,13 +791,13 @@ static void mgr_clear_shadow_dirty(struct 
omap_overlay_manager *mgr)
 }
 
 static int dss_mgr_connect_compat(struct omap_overlay_manager *mgr,
-   struct omap_dss_output *dst)
+   struct omap_dss_device *dst)
 {
return mgr->set_output(mgr, dst);
 }
 
 static void dss_mgr_disconnect_compat(struct omap_overlay_manager *mgr,
-   struct omap_dss_output *dst)
+   struct omap_dss_device *dst)
 {
mgr->unset_output(mgr);
 }
@@ -1166,7 +1166,7 @@ static void dss_mgr_get_info(struct omap_overlay_manager 
*mgr,
 }
 
 static int dss_mgr_set_output(struct omap_overlay_manager *mgr,
-   struct omap_dss_output *output)
+   struct omap_dss_device *output)
 {
int r;
 
diff --git a/drivers/video/omap2/dss/core.c b/drivers/video/omap2/dss/core.c
index 98a688e..44493224 100644
--- a/drivers/video/omap2/dss/core.c
+++ b/drivers/video/omap2/dss/core.c
@@ -345,7 +345,7 @@ static int dss_driver_remove(struct device *dev)
 
 static int omapdss_default_connect(struct omap_dss_device *dssdev)
 {
-   struct omap_dss_output *out;
+   struct omap_dss_device *out;
struct omap_overlay_manager *mgr;
int r;
 
@@ -367,7 +367,7 @@ static int omapdss_default_connect(struct omap_dss_device 
*dssdev)
 
 static void omapdss_default_disconnect(struct omap_dss_device *dssdev)
 {
-   struct omap_dss_output *out;
+   struct omap_dss_device *out;
struct omap_overlay_manager *mgr;
 
out = dssdev->output;
diff --git a/drivers/video/omap2/dss/dpi.c b/drivers/video/omap2/dss/dpi.c
index d369927..03d8afd 100644
--- a/drivers/video/omap2/dss/dpi.c
+++ b/drivers/video/omap2/dss/dpi.c
@@ -49,7 +49

[PATCH 29/32] OMAPDSS: add module_get/put to omap_dss_get/put_device()

2013-05-30 Thread Tomi Valkeinen
omap_dss_get_device() should be called for omap_dss_device before it is
used to increase its refcount. Currently we only increase the refcount
for the underlying device.

This patch adds managing the ref count to the underlying module also,
which contains the ops for the omap_dss_device.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/display.c | 13 +++--
 include/video/omapdss.h   |  2 +-
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/video/omap2/dss/display.c 
b/drivers/video/omap2/dss/display.c
index 8096764..0daf3e3 100644
--- a/drivers/video/omap2/dss/display.c
+++ b/drivers/video/omap2/dss/display.c
@@ -158,15 +158,24 @@ void omapdss_unregister_display(struct omap_dss_device 
*dssdev)
 }
 EXPORT_SYMBOL(omapdss_unregister_display);
 
-void omap_dss_get_device(struct omap_dss_device *dssdev)
+struct omap_dss_device *omap_dss_get_device(struct omap_dss_device *dssdev)
 {
-   get_device(dssdev->dev);
+   if (!try_module_get(dssdev->owner))
+   return NULL;
+
+   if (get_device(dssdev->dev) == NULL) {
+   module_put(dssdev->owner);
+   return NULL;
+   }
+
+   return dssdev;
 }
 EXPORT_SYMBOL(omap_dss_get_device);
 
 void omap_dss_put_device(struct omap_dss_device *dssdev)
 {
put_device(dssdev->dev);
+   module_put(dssdev->owner);
 }
 EXPORT_SYMBOL(omap_dss_put_device);
 
diff --git a/include/video/omapdss.h b/include/video/omapdss.h
index c32d90e..b2e6160 100644
--- a/include/video/omapdss.h
+++ b/include/video/omapdss.h
@@ -766,7 +766,7 @@ void omap_dss_unregister_driver(struct omap_dss_driver *);
 int omapdss_register_display(struct omap_dss_device *dssdev);
 void omapdss_unregister_display(struct omap_dss_device *dssdev);
 
-void omap_dss_get_device(struct omap_dss_device *dssdev);
+struct omap_dss_device *omap_dss_get_device(struct omap_dss_device *dssdev);
 void omap_dss_put_device(struct omap_dss_device *dssdev);
 #define for_each_dss_dev(d) while ((d = omap_dss_get_next_device(d)) != NULL)
 struct omap_dss_device *omap_dss_get_next_device(struct omap_dss_device *from);
-- 
1.8.1.2

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


[PATCH 30/32] OMAPDSS: add THIS_MODULE owner to DSS outputs

2013-05-30 Thread Tomi Valkeinen
Setup the owner field for DSS output's omap_dss_device so that module
refcounting works.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/dpi.c  | 1 +
 drivers/video/omap2/dss/dsi.c  | 1 +
 drivers/video/omap2/dss/hdmi.c | 1 +
 drivers/video/omap2/dss/rfbi.c | 1 +
 drivers/video/omap2/dss/sdi.c  | 1 +
 drivers/video/omap2/dss/venc.c | 1 +
 6 files changed, 6 insertions(+)

diff --git a/drivers/video/omap2/dss/dpi.c b/drivers/video/omap2/dss/dpi.c
index 03d8afd..0afbcd5 100644
--- a/drivers/video/omap2/dss/dpi.c
+++ b/drivers/video/omap2/dss/dpi.c
@@ -691,6 +691,7 @@ static void dpi_init_output(struct platform_device *pdev)
out->output_type = OMAP_DISPLAY_TYPE_DPI;
out->name = "dpi.0";
out->dispc_channel = dpi_get_channel();
+   out->owner = THIS_MODULE;
 
dss_register_output(out);
 }
diff --git a/drivers/video/omap2/dss/dsi.c b/drivers/video/omap2/dss/dsi.c
index 9aafefc..2f90019 100644
--- a/drivers/video/omap2/dss/dsi.c
+++ b/drivers/video/omap2/dss/dsi.c
@@ -5424,6 +5424,7 @@ static void dsi_init_output(struct platform_device 
*dsidev)
out->output_type = OMAP_DISPLAY_TYPE_DSI;
out->name = dsi->module_id == 0 ? "dsi.0" : "dsi.1";
out->dispc_channel = dsi_get_channel(dsi->module_id);
+   out->owner = THIS_MODULE;
 
dss_register_output(out);
 }
diff --git a/drivers/video/omap2/dss/hdmi.c b/drivers/video/omap2/dss/hdmi.c
index e33e708..1a7b179 100644
--- a/drivers/video/omap2/dss/hdmi.c
+++ b/drivers/video/omap2/dss/hdmi.c
@@ -1042,6 +1042,7 @@ static void hdmi_init_output(struct platform_device *pdev)
out->output_type = OMAP_DISPLAY_TYPE_HDMI;
out->name = "hdmi.0";
out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
+   out->owner = THIS_MODULE;
 
dss_register_output(out);
 }
diff --git a/drivers/video/omap2/dss/rfbi.c b/drivers/video/omap2/dss/rfbi.c
index 35836eb..f18c946 100644
--- a/drivers/video/omap2/dss/rfbi.c
+++ b/drivers/video/omap2/dss/rfbi.c
@@ -1020,6 +1020,7 @@ static void rfbi_init_output(struct platform_device *pdev)
out->output_type = OMAP_DISPLAY_TYPE_DBI;
out->name = "rfbi.0";
out->dispc_channel = OMAP_DSS_CHANNEL_LCD;
+   out->owner = THIS_MODULE;
 
dss_register_output(out);
 }
diff --git a/drivers/video/omap2/dss/sdi.c b/drivers/video/omap2/dss/sdi.c
index a226c37..10268a2 100644
--- a/drivers/video/omap2/dss/sdi.c
+++ b/drivers/video/omap2/dss/sdi.c
@@ -348,6 +348,7 @@ static void sdi_init_output(struct platform_device *pdev)
out->output_type = OMAP_DISPLAY_TYPE_SDI;
out->name = "sdi.0";
out->dispc_channel = OMAP_DSS_CHANNEL_LCD;
+   out->owner = THIS_MODULE;
 
dss_register_output(out);
 }
diff --git a/drivers/video/omap2/dss/venc.c b/drivers/video/omap2/dss/venc.c
index 7bfcba4..0deb771 100644
--- a/drivers/video/omap2/dss/venc.c
+++ b/drivers/video/omap2/dss/venc.c
@@ -792,6 +792,7 @@ static void venc_init_output(struct platform_device *pdev)
out->output_type = OMAP_DISPLAY_TYPE_VENC;
out->name = "venc.0";
out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
+   out->owner = THIS_MODULE;
 
dss_register_output(out);
 }
-- 
1.8.1.2

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


[PATCH 32/32] OMAPFB: use EPROBE_DEFER if default display is not present

2013-05-30 Thread Tomi Valkeinen
Currently omapfb returns EPROBE_DEFER if no displays have been probed at
the time omapfb is probed. However, sometimes some of the displays have
been probed at that time, but not all. We can't return EPROBE_DEFER in
that case, because then one missing driver would cause omapfb to defer
always, preventing any display from working.

However, if the user has defined a default display, we can presume that
the driver for that display is eventually loaded. Thus, this patch
changes omapfb to return EPROBE_DEFER in case default display is not
found.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/omapfb/omapfb-main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/video/omap2/omapfb/omapfb-main.c 
b/drivers/video/omap2/omapfb/omapfb-main.c
index eacbafa..0c0d078 100644
--- a/drivers/video/omap2/omapfb/omapfb-main.c
+++ b/drivers/video/omap2/omapfb/omapfb-main.c
@@ -2500,7 +2500,7 @@ static int omapfb_probe(struct platform_device *pdev)
 
if (def_display == NULL) {
dev_err(fbdev->dev, "failed to find default display\n");
-   r = -EINVAL;
+   r = -EPROBE_DEFER;
goto cleanup;
}
 
-- 
1.8.1.2

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


[PATCH 31/32] OMAPDSS: output: increase refcount in find_output funcs

2013-05-30 Thread Tomi Valkeinen
Now that omap_dss_output has been combined into omap_dss_device, we can
add ref counting for the relevant output functions also.

This patch adds omap_dss_get_device() calls to the various find_output()
style functions. This, of course, means that the users of those
find_output functions need to do a omap_dss_put_device() after use.

Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/omap_drv.c |  2 ++
 drivers/video/omap2/dss/output.c   | 13 +
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index a72100c..4c0bc40 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -277,6 +277,8 @@ static int omap_modeset_init(struct drm_device *dev)
if (supported_outputs & output->id)
encoder->possible_crtcs |= (1 << id);
}
+
+   omap_dss_put_device(output);
}
 
DBG("registered %d planes, %d crtcs, %d encoders and %d connectors\n",
diff --git a/drivers/video/omap2/dss/output.c b/drivers/video/omap2/dss/output.c
index cc81fec..9ad7d21 100644
--- a/drivers/video/omap2/dss/output.c
+++ b/drivers/video/omap2/dss/output.c
@@ -121,7 +121,7 @@ struct omap_dss_device *omap_dss_find_output(const char 
*name)
 
list_for_each_entry(out, &output_list, list) {
if (strcmp(out->name, name) == 0)
-   return out;
+   return omap_dss_get_device(out);
}
 
return NULL;
@@ -134,7 +134,7 @@ struct omap_dss_device *omap_dss_find_output_by_node(struct 
device_node *node)
 
list_for_each_entry(out, &output_list, list) {
if (out->dev->of_node == node)
-   return out;
+   return omap_dss_get_device(out);
}
 
return NULL;
@@ -143,20 +143,25 @@ EXPORT_SYMBOL(omap_dss_find_output_by_node);
 
 struct omap_dss_device *omapdss_find_output_from_display(struct 
omap_dss_device *dssdev)
 {
-   return dssdev->output;
+   return omap_dss_get_device(dssdev->output);
 }
 EXPORT_SYMBOL(omapdss_find_output_from_display);
 
 struct omap_overlay_manager *omapdss_find_mgr_from_display(struct 
omap_dss_device *dssdev)
 {
struct omap_dss_device *out;
+   struct omap_overlay_manager *mgr;
 
out = omapdss_find_output_from_display(dssdev);
 
if (out == NULL)
return NULL;
 
-   return out->manager;
+   mgr = out->manager;
+
+   omap_dss_put_device(out);
+
+   return mgr;
 }
 EXPORT_SYMBOL(omapdss_find_mgr_from_display);
 
-- 
1.8.1.2

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


[PATCH 28/32] OMAPDSS: omapdss.h: add owner field to omap_dss_device

2013-05-30 Thread Tomi Valkeinen
Add struct module *owner field to omap_dss_device, which points to the
module containing the ops for this omap_dss_device. This will be used to
manage the ref count for the module.

Signed-off-by: Tomi Valkeinen 
---
 include/video/omapdss.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/include/video/omapdss.h b/include/video/omapdss.h
index 5046264..c32d90e 100644
--- a/include/video/omapdss.h
+++ b/include/video/omapdss.h
@@ -579,6 +579,8 @@ struct omap_dss_device {
/* new device, pointer to panel device */
struct device *dev;
 
+   struct module *owner;
+
struct list_head panel_list;
 
/* alias in the form of "display%d" */
-- 
1.8.1.2

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


[PATCH 00/27] OMAPDSS: dss-dev-model (Part 2/2)

2013-05-30 Thread Tomi Valkeinen
Hi,

Here's are the first sets of patches targeting towards enabling DT for DSS and
changing the DSS device model to be more versatile. The exact division of the
sets of patches is still a bit open, and some splitting up for arch/driver
changes is needed, but most likely there will be at least the following major
sets, each based on the former one:

- base, containing cleanups and changes that do not yet really bring bigger new
  features
- dev-model, implements the new DSS device model, including new panel drivers
- dt, adds DSS DT support (not at all ready yet, although works for a few 
boards)

The patches can be found from the following branches:

git://gitorious.org/linux-omap-dss2/linux.git work/dss-dev-model-base
git://gitorious.org/linux-omap-dss2/linux.git work/dss-dev-model
git://gitorious.org/linux-omap-dss2/linux.git work/dss-dev-model-dt

The set you are looking at is the "dev-model" set.

The "dev-model" implements a new model for display drivers. The model is very
much in the direction of CDF (Common Display Framework) as has been discussed
on the mailing lists. However, it's still OMAP specific, and, for example, the
display ops have not been improved but they were just copied from the old DSS
API to make the conversion simpler.

The first main change with the "dev-model" is that display devices/drivers are
no longer special omapdss device/driver types, but they are (usually)
devices/drivers of their control bus. This means that many devices/drivers are
platform devices/drivers, but some are i2c or spi devices/drivers.

The other main change is the use of "ops" instead of direct function calls.
This allows us to create "chains" of display entities, which allows us to
(finally) create proper drivers for external encoders. As an example, a board
with an external DSI-to-LVDS encoder chip and an LVDS panel was previously
modelled with a single display driver, handling both the encoder and the panel.
Now we can have separate drivers for the encoder and for the panel.

Note that to keep the old drivers and board files working, the old drivers and
the omapdss support needed for those is not removed yet. This makes the code
quite messy in a few places. The old code can be removed after all the panels
and board files have been converted.

In this set, the following board files have been converted so far:
- OMAP4 Blaze
- OMAP4 Panda
- Overo
- Beagle
- RX51 (not tested)

The panel drivers needed for the above have been converted, but there's still a
bunch of panel drivers not converted. Also, DSS RFBI driver has not been
converted.

The "dev-model" set brings back the support to have multiple panel devices
connected to the same video output, of which only one can be enabled at a time.
For example, DVI and a panel connected to OMAP's DPI output.

Overo board has an added difficulty to support the above: Overo board file adds
two panel devices, lcd43 and lcd35 (in reality those panels are not attached at
the same time, as they are located in add-on boards). Both panels have the same
GPIO used for reset. This causes a problem as when the panel drivers are
loaded, both drivers try to acquire the same GPIO, and the latter one fails.

To solve the problem, I added kernel boot command line parsing to Overo's board
file. The code looks for "default display" parameter for omapdss, and uses that
to decide which panel device to add.

Note that the above is not Overo specific, but as far as I know, Overo is the
only board having such a setup.

 Tomi


Tomi Valkeinen (27):
  OMAPDSS: public omapdss_register_output()
  OMAPDSS: modify get/find functions to go through the device chain
  OMAPDSS: add platform data structs for new panel drivers
  ARM: OMAP: dss-common: use new display drivers
  ARM: OMAP: overo: use new display drivers
  ARM: OMAP: rx51: use new display drivers
  ARM: OMAP: beagle: use new display drivers
  OMAPDSS: add OMAP_DISPLAY_TYPE_DVI
  drm/omap: DVI connector fix
  OMAPDSS: DPI: Add ops
  OMAPDSS: SDI: Add ops
  OMAPDSS: DVI: Add ops
  OMAPDSS: AnalogTV: Add ops
  OMAPDSS: HDMI: Add ops
  OMAPDSS: DSI: Add ops
  OMAPDSS: Add new TFP410 Encoder driver
  OMAPDSS: Add new TPD12S015 Encoder driver
  OMAPDSS: Add new DVI Connector driver
  OMAPDSS: Add new HDMI Connector driver
  OMAPDSS: Add new Analog TV Connector driver
  OMAPDSS: Add new simple DPI panel driver
  OMAPDSS: Add new DSI Command Mode panel  driver
  OMAPDSS: Add Sony ACX565AKM panel driver
  OMAPDSS: Add LG.Philips LB035Q02 panel driver
  ARM: OMAP: fix dsi regulator names
  ARM: OMAP: add vdds_dsi supply for dpi.0
  ARM: OMAP: add vdds_sdi supply for sdi.0

 arch/arm/mach-omap2/board-cm-t35.c |3 +-
 arch/arm/mach-omap2/board-devkit8000.c |1 +
 arch/arm/mach-omap2/board-ldp.c|3 +-
 arch/arm/mach-omap2/board-omap3beagle.c|   56 +-
 arch/arm/mach-omap2/board-omap3pandora.c   |1 +
 arch/arm/mach-omap2/board-overo.c  |  160 ++-
 arch/arm

[PATCH 01/27] OMAPDSS: public omapdss_register_output()

2013-05-30 Thread Tomi Valkeinen
In order to allow multiple display block in a video pipeline, we need to
give the drivers way to register themselves. For now we have
the omapdss_register_display() which is used to register panels, and
dss_register_output() which is used to register DSS encoders.

This patch makes dss_register_output() public (with the name of
omapdss_register_output), which can be used to register also external
encoders. The distinction between register_output and register_display
is that a "display" is an entity at the end of the videopipeline, and
"output" is something inside the pipeline.

The registration and naming will be made saner in the future, but the
current names and functions are kept to minimize changes during the dss
device model transition.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/dpi.c| 4 ++--
 drivers/video/omap2/dss/dsi.c| 4 ++--
 drivers/video/omap2/dss/dss.h| 4 
 drivers/video/omap2/dss/hdmi.c   | 4 ++--
 drivers/video/omap2/dss/output.c | 7 +--
 drivers/video/omap2/dss/rfbi.c   | 4 ++--
 drivers/video/omap2/dss/sdi.c| 4 ++--
 drivers/video/omap2/dss/venc.c   | 4 ++--
 include/video/omapdss.h  | 2 ++
 9 files changed, 19 insertions(+), 18 deletions(-)

diff --git a/drivers/video/omap2/dss/dpi.c b/drivers/video/omap2/dss/dpi.c
index 0afbcd5..3299e27 100644
--- a/drivers/video/omap2/dss/dpi.c
+++ b/drivers/video/omap2/dss/dpi.c
@@ -693,14 +693,14 @@ static void dpi_init_output(struct platform_device *pdev)
out->dispc_channel = dpi_get_channel();
out->owner = THIS_MODULE;
 
-   dss_register_output(out);
+   omapdss_register_output(out);
 }
 
 static void __exit dpi_uninit_output(struct platform_device *pdev)
 {
struct omap_dss_device *out = &dpi.output;
 
-   dss_unregister_output(out);
+   omapdss_unregister_output(out);
 }
 
 static int omap_dpi_probe(struct platform_device *pdev)
diff --git a/drivers/video/omap2/dss/dsi.c b/drivers/video/omap2/dss/dsi.c
index 2f90019..4ecc0c1 100644
--- a/drivers/video/omap2/dss/dsi.c
+++ b/drivers/video/omap2/dss/dsi.c
@@ -5426,7 +5426,7 @@ static void dsi_init_output(struct platform_device 
*dsidev)
out->dispc_channel = dsi_get_channel(dsi->module_id);
out->owner = THIS_MODULE;
 
-   dss_register_output(out);
+   omapdss_register_output(out);
 }
 
 static void dsi_uninit_output(struct platform_device *dsidev)
@@ -5434,7 +5434,7 @@ static void dsi_uninit_output(struct platform_device 
*dsidev)
struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
struct omap_dss_device *out = &dsi->output;
 
-   dss_unregister_output(out);
+   omapdss_unregister_output(out);
 }
 
 /* DSI1 HW IP initialisation */
diff --git a/drivers/video/omap2/dss/dss.h b/drivers/video/omap2/dss/dss.h
index 67a509e..902d458 100644
--- a/drivers/video/omap2/dss/dss.h
+++ b/drivers/video/omap2/dss/dss.h
@@ -179,10 +179,6 @@ void dss_put_device(struct omap_dss_device *dssdev);
 void dss_copy_device_pdata(struct omap_dss_device *dst,
const struct omap_dss_device *src);
 
-/* output */
-void dss_register_output(struct omap_dss_device *out);
-void dss_unregister_output(struct omap_dss_device *out);
-
 /* display */
 int dss_suspend_all_devices(void);
 int dss_resume_all_devices(void);
diff --git a/drivers/video/omap2/dss/hdmi.c b/drivers/video/omap2/dss/hdmi.c
index 1a7b179..42376d1 100644
--- a/drivers/video/omap2/dss/hdmi.c
+++ b/drivers/video/omap2/dss/hdmi.c
@@ -1044,14 +1044,14 @@ static void hdmi_init_output(struct platform_device 
*pdev)
out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
out->owner = THIS_MODULE;
 
-   dss_register_output(out);
+   omapdss_register_output(out);
 }
 
 static void __exit hdmi_uninit_output(struct platform_device *pdev)
 {
struct omap_dss_device *out = &hdmi.output;
 
-   dss_unregister_output(out);
+   omapdss_unregister_output(out);
 }
 
 /* HDMI HW IP initialisation */
diff --git a/drivers/video/omap2/dss/output.c b/drivers/video/omap2/dss/output.c
index 9ad7d21..0ba168e 100644
--- a/drivers/video/omap2/dss/output.c
+++ b/drivers/video/omap2/dss/output.c
@@ -92,15 +92,18 @@ err:
 }
 EXPORT_SYMBOL(omapdss_output_unset_device);
 
-void dss_register_output(struct omap_dss_device *out)
+int omapdss_register_output(struct omap_dss_device *out)
 {
list_add_tail(&out->list, &output_list);
+   return 0;
 }
+EXPORT_SYMBOL(omapdss_register_output);
 
-void dss_unregister_output(struct omap_dss_device *out)
+void omapdss_unregister_output(struct omap_dss_device *out)
 {
list_del(&out->list);
 }
+EXPORT_SYMBOL(omapdss_unregister_output);
 
 struct omap_dss_device *omap_dss_get_output(enum omap_dss_output_id id)
 {
diff --git a/drivers/video/omap2/dss/rfbi.c b/drivers/video/omap2/dss/rfbi.c
index f18c946..fdfe6e6 100644
--- a/drivers/video/omap2/dss/rfbi.c
+++ b/drivers/video/omap2/dss/rfbi.c
@@ -1022,14 +1022,14 @@ static void rfbi_init_output(struct platform_device 
*pde

[PATCH 02/27] OMAPDSS: modify get/find functions to go through the device chain

2013-05-30 Thread Tomi Valkeinen
In the future will have arbitrarily long video pipeline chains, instead
of the current two-entities-per-pipeline model.

This patch changes the affected get/find style functions so that they
properly go through the video pipeline chain, for example when getting
the overlay manager connected to a given display.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/apply.c  | 14 +-
 drivers/video/omap2/dss/output.c |  8 +++-
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/drivers/video/omap2/dss/apply.c b/drivers/video/omap2/dss/apply.c
index 752b985..d6212d63 100644
--- a/drivers/video/omap2/dss/apply.c
+++ b/drivers/video/omap2/dss/apply.c
@@ -422,7 +422,19 @@ static void wait_pending_extra_info_updates(void)
 
 static struct omap_dss_device *dss_mgr_get_device(struct omap_overlay_manager 
*mgr)
 {
-   return mgr->output ? mgr->output->device : NULL;
+   struct omap_dss_device *dssdev;
+
+   dssdev = mgr->output;
+   if (dssdev == NULL)
+   return NULL;
+
+   while (dssdev->device)
+   dssdev = dssdev->device;
+
+   if (dssdev->driver)
+   return dssdev;
+   else
+   return NULL;
 }
 
 static struct omap_dss_device *dss_ovl_get_device(struct omap_overlay *ovl)
diff --git a/drivers/video/omap2/dss/output.c b/drivers/video/omap2/dss/output.c
index 0ba168e..3f5c0a7 100644
--- a/drivers/video/omap2/dss/output.c
+++ b/drivers/video/omap2/dss/output.c
@@ -146,7 +146,13 @@ EXPORT_SYMBOL(omap_dss_find_output_by_node);
 
 struct omap_dss_device *omapdss_find_output_from_display(struct 
omap_dss_device *dssdev)
 {
-   return omap_dss_get_device(dssdev->output);
+   while (dssdev->output)
+   dssdev = dssdev->output;
+
+   if (dssdev->id != 0)
+   return omap_dss_get_device(dssdev);
+
+   return NULL;
 }
 EXPORT_SYMBOL(omapdss_find_output_from_display);
 
-- 
1.8.1.2

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


[PATCH 03/27] OMAPDSS: add platform data structs for new panel drivers

2013-05-30 Thread Tomi Valkeinen
With the new DSS device model, we'll have new panel and encoder drivers.
This patch adds the platform data structs for all the new drivers.

Signed-off-by: Tomi Valkeinen 
---
 include/video/omap-panel-data.h | 150 
 1 file changed, 150 insertions(+)

diff --git a/include/video/omap-panel-data.h b/include/video/omap-panel-data.h
index 0c3b46d..317ee36 100644
--- a/include/video/omap-panel-data.h
+++ b/include/video/omap-panel-data.h
@@ -27,6 +27,8 @@
 #ifndef __OMAP_PANEL_DATA_H
 #define __OMAP_PANEL_DATA_H
 
+#include 
+
 struct omap_dss_device;
 
 /**
@@ -147,4 +149,152 @@ struct panel_tpo_td043_data {
int nreset_gpio;
 };
 
+/**
+ * panel_dpi platform data
+ * @name: name for this display entity
+ * @source: name of the display entity used as a video source
+ * @data_lines: number of DPI datalines
+ * @display_timing: timings for this panel
+ * @backlight_gpio: gpio to enable/disable the backlight (or -1)
+ * @enable_gpio: gpio to enable/disable the panel (or -1)
+ */
+struct panel_dpi_platform_data {
+   const char *name;
+   const char *source;
+
+   int data_lines;
+
+   const struct display_timing *display_timing;
+
+   int backlight_gpio;
+   int enable_gpio;
+};
+
+/**
+ * panel_dsicm platform data
+ * @name: name for this display entity
+ * @source: name of the display entity used as a video source
+ * @reset_gpio: gpio to reset the panel (or -1)
+ * @use_ext_te: use external TE GPIO
+ * @ext_te_gpio: external TE GPIO
+ * @ulps_timeout: time to wait before entering ULPS, 0 = disabled (ms)
+ * @use_dsi_backlight: true if panel uses DSI command to control backlight
+ * @pin_config: DSI pin configuration
+ */
+struct panel_dsicm_platform_data {
+   const char *name;
+   const char *source;
+
+   int reset_gpio;
+
+   bool use_ext_te;
+   int ext_te_gpio;
+
+   unsigned ulps_timeout;
+
+   bool use_dsi_backlight;
+
+   struct omap_dsi_pin_config pin_config;
+};
+
+/**
+ * panel_acx565akm platform data
+ * @name: name for this display entity
+ * @source: name of the display entity used as a video source
+ * @reset_gpio: gpio to reset the panel (or -1)
+ * @datapairs: number of SDI datapairs
+ */
+struct panel_acx565akm_platform_data {
+   const char *name;
+   const char *source;
+
+   int reset_gpio;
+
+   int datapairs;
+};
+
+/**
+ * panel_lb035q02 platform data
+ * @name: name for this display entity
+ * @source: name of the display entity used as a video source
+ * @data_lines: number of DPI datalines
+ * @backlight_gpio: gpio to enable/disable the backlight (or -1)
+ * @enable_gpio: gpio to enable/disable the panel (or -1)
+ */
+struct panel_lb035q02_platform_data {
+   const char *name;
+   const char *source;
+
+   int data_lines;
+
+   int backlight_gpio;
+   int enable_gpio;
+};
+
+/**
+ * connector_dvi platform data
+ * @name: name for this display entity
+ * @source: name of the display entity used as a video source
+ * @i2c_bus_num: i2c bus number to be used for reading EDID
+ */
+struct connector_dvi_platform_data {
+   const char *name;
+   const char *source;
+   int i2c_bus_num;
+};
+
+/**
+ * connector_hdmi platform data
+ * @name: name for this display entity
+ * @source: name of the display entity used as a video source
+ */
+struct connector_hdmi_platform_data {
+   const char *name;
+   const char *source;
+};
+
+/**
+ * connector_atv platform data
+ * @name: name for this display entity
+ * @source: name of the display entity used as a video source
+ * @connector_type: composite/svideo
+ * @invert_polarity: invert signal polarity
+ */
+struct connector_atv_platform_data {
+   const char *name;
+   const char *source;
+
+   enum omap_dss_venc_type connector_type;
+   bool invert_polarity;
+};
+
+/**
+ * encoder_tfp410 platform data
+ * @name: name for this display entity
+ * @power_down_gpio: gpio number for PD pin (or -1 if not available)
+ * @data_lines: number of DPI datalines
+ */
+struct encoder_tfp410_platform_data {
+   const char *name;
+   const char *source;
+   int power_down_gpio;
+   int data_lines;
+};
+
+/**
+ * encoder_tpd12s015 platform data
+ * @name: name for this display entity
+ * @ct_cp_hpd_gpio: CT_CP_HPD gpio number
+ * @ls_oe_gpio: LS_OE gpio number
+ * @hpd_gpio: HPD gpio number
+ */
+struct encoder_tpd12s015_platform_data {
+   const char *name;
+   const char *source;
+
+   int ct_cp_hpd_gpio;
+   int ls_oe_gpio;
+   int hpd_gpio;
+};
+
 #endif /* __OMAP_PANEL_DATA_H */
-- 
1.8.1.2

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


[PATCH 04/27] ARM: OMAP: dss-common: use new display drivers

2013-05-30 Thread Tomi Valkeinen
Use the new display drivers for OMAP4 Panda and OMAP4 SDP boards.

Signed-off-by: Tomi Valkeinen 
---
 arch/arm/mach-omap2/dss-common.c | 185 +++
 1 file changed, 108 insertions(+), 77 deletions(-)

diff --git a/arch/arm/mach-omap2/dss-common.c b/arch/arm/mach-omap2/dss-common.c
index 393aeef..17e0a08 100644
--- a/arch/arm/mach-omap2/dss-common.c
+++ b/arch/arm/mach-omap2/dss-common.c
@@ -25,6 +25,7 @@
 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -37,53 +38,76 @@
 #define HDMI_GPIO_LS_OE 41 /* Level shifter for HDMI */
 #define HDMI_GPIO_HPD  63 /* Hotplug detect */
 
-/* Display DVI */
 #define PANDA_DVI_TFP410_POWER_DOWN_GPIO   0
 
-/* Using generic display panel */
-static struct tfp410_platform_data omap4_dvi_panel = {
-   .i2c_bus_num= 3,
-   .power_down_gpio= PANDA_DVI_TFP410_POWER_DOWN_GPIO,
+/* DVI Connector */
+static struct connector_dvi_platform_data omap4_panda_dvi_connector_pdata = {
+   .name   = "dvi",
+   .source = "tfp410.0",
+   .i2c_bus_num= 3,
 };
 
-static struct omap_dss_device omap4_panda_dvi_device = {
-   .type   = OMAP_DISPLAY_TYPE_DPI,
-   .name   = "dvi",
-   .driver_name= "tfp410",
-   .data   = &omap4_dvi_panel,
-   .phy.dpi.data_lines = 24,
-   .channel= OMAP_DSS_CHANNEL_LCD2,
+static struct platform_device omap4_panda_dvi_connector_device = {
+   .name   = "connector-dvi",
+   .id = 0,
+   .dev.platform_data  = &omap4_panda_dvi_connector_pdata,
+};
+
+/* TFP410 DPI-to-DVI chip */
+static struct encoder_tfp410_platform_data omap4_panda_tfp410_pdata = {
+   .name   = "tfp410.0",
+   .source = "dpi.0",
+   .data_lines = 24,
+   .power_down_gpio= PANDA_DVI_TFP410_POWER_DOWN_GPIO,
+};
+
+static struct platform_device omap4_panda_tfp410_device = {
+   .name   = "tfp410",
+   .id = 0,
+   .dev.platform_data  = &omap4_panda_tfp410_pdata,
 };
 
-static struct omap_dss_hdmi_data omap4_panda_hdmi_data = {
+/* HDMI Connector */
+static struct connector_hdmi_platform_data omap4_panda_hdmi_connector_pdata = {
+   .name   = "hdmi",
+   .source = "tpd12s015.0",
+};
+
+static struct platform_device omap4_panda_hdmi_connector_device = {
+   .name   = "connector-hdmi",
+   .id = 0,
+   .dev.platform_data  = &omap4_panda_hdmi_connector_pdata,
+};
+
+/* TPD12S015 HDMI ESD protection & level shifter chip */
+static struct encoder_tpd12s015_platform_data omap4_panda_tpd_pdata = {
+   .name   = "tpd12s015.0",
+   .source = "hdmi.0",
+
.ct_cp_hpd_gpio = HDMI_GPIO_CT_CP_HPD,
.ls_oe_gpio = HDMI_GPIO_LS_OE,
.hpd_gpio = HDMI_GPIO_HPD,
 };
 
-static struct omap_dss_device  omap4_panda_hdmi_device = {
-   .name = "hdmi",
-   .driver_name = "hdmi_panel",
-   .type = OMAP_DISPLAY_TYPE_HDMI,
-   .channel = OMAP_DSS_CHANNEL_DIGIT,
-   .data = &omap4_panda_hdmi_data,
-};
-
-static struct omap_dss_device *omap4_panda_dss_devices[] = {
-   &omap4_panda_dvi_device,
-   &omap4_panda_hdmi_device,
+static struct platform_device omap4_panda_tpd_device = {
+   .name   = "tpd12s015",
+   .id = 0,
+   .dev.platform_data  = &omap4_panda_tpd_pdata,
 };
 
 static struct omap_dss_board_info omap4_panda_dss_data = {
-   .num_devices= ARRAY_SIZE(omap4_panda_dss_devices),
-   .devices= omap4_panda_dss_devices,
-   .default_device = &omap4_panda_dvi_device,
+   .default_display_name = "dvi",
 };
 
 void __init omap4_panda_display_init(void)
 {
omap_display_init(&omap4_panda_dss_data);
 
+   platform_device_register(&omap4_panda_tfp410_device);
+   platform_device_register(&omap4_panda_dvi_connector_device);
+
+   platform_device_register(&omap4_panda_tpd_device);
+   platform_device_register(&omap4_panda_hdmi_connector_device);
/*
 * OMAP4460SDP/Blaze and OMAP4430 ES2.3 SDP/Blaze boards and
 * later have external pull up on the HDMI I2C lines
@@ -109,67 +133,71 @@ void __init omap4_panda_display_init_of(void)
 #define DISPLAY_SEL_GPIO   59  /* LCD2/PicoDLP switch */
 #define DLP_POWER_ON_GPIO  40
 
-static struct nokia_dsi_panel_data dsi1_panel = {
-   .name   = "taal",
-   .reset_gpio = 102,
-   .use_ext_te = false,
-   .ext_te_gpio= 101,
-   .esd_interval   = 0,
-   .pin_config = {
-   .num_pins   = 6,
-   .pins   = { 0, 1, 2, 3, 4, 5 },
-   },
-

[PATCH 05/27] ARM: OMAP: overo: use new display drivers

2013-05-30 Thread Tomi Valkeinen
Use the new display drivers for OMAP3 Overo board.

Note that the LCD add-on boards for lcd43 and lcd35 use the same GPIOs
for the panels. This means that both panel devices cannot be probed at
the same time.

DT will handle this correctly, i.e. the DT data will contain the panel
device only for the add-on board that is attached. However, for the
board file we need a hackish solution: We parse the kernel boot command
line, and see whether lcd43 or lcd35 is set as a default display, and
add the given one. Or, if neither is given, default to lcd43.

Signed-off-by: Tomi Valkeinen 
---
 arch/arm/mach-omap2/board-overo.c | 160 --
 1 file changed, 100 insertions(+), 60 deletions(-)

diff --git a/arch/arm/mach-omap2/board-overo.c 
b/arch/arm/mach-omap2/board-overo.c
index a496774..51fdac6 100644
--- a/arch/arm/mach-omap2/board-overo.c
+++ b/arch/arm/mach-omap2/board-overo.c
@@ -71,6 +71,9 @@
 #define OVERO_SMSC911X2_CS 4
 #define OVERO_SMSC911X2_GPIO   65
 
+/* whether to register LCD35 instead of LCD43 */
+static bool overo_use_lcd35;
+
 #if defined(CONFIG_TOUCHSCREEN_ADS7846) || \
defined(CONFIG_TOUCHSCREEN_ADS7846_MODULE)
 
@@ -148,78 +151,94 @@ static inline void __init overo_init_smsc911x(void) { 
return; }
 #define OVERO_GPIO_LCD_EN 144
 #define OVERO_GPIO_LCD_BL 145
 
-static struct tfp410_platform_data dvi_panel = {
-   .i2c_bus_num= 3,
-   .power_down_gpio= -1,
+static struct connector_atv_platform_data overo_tv_pdata = {
+   .name = "tv",
+   .source = "venc.0",
+   .connector_type = OMAP_DSS_VENC_TYPE_SVIDEO,
+   .invert_polarity = false,
 };
 
-static struct omap_dss_device overo_dvi_device = {
-   .name   = "dvi",
-   .type   = OMAP_DISPLAY_TYPE_DPI,
-   .driver_name= "tfp410",
-   .data   = &dvi_panel,
-   .phy.dpi.data_lines = 24,
+static struct platform_device overo_tv_device = {
+   .name   = "connector-analog-tv",
+   .id = 0,
+   .dev.platform_data  = &overo_tv_pdata,
 };
 
-static struct omap_dss_device overo_tv_device = {
-   .name = "tv",
-   .driver_name = "venc",
-   .type = OMAP_DISPLAY_TYPE_VENC,
-   .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
+static const struct display_timing overo_lcd43_videomode = {
+   .pixelclock = { 0, 920, 0 },
+
+   .hactive = { 0, 480, 0 },
+   .hfront_porch = { 0, 8, 0 },
+   .hback_porch = { 0, 4, 0 },
+   .hsync_len = { 0, 41, 0 },
+
+   .vactive = { 0, 272, 0 },
+   .vfront_porch = { 0, 4, 0 },
+   .vback_porch = { 0, 2, 0 },
+   .vsync_len = { 0, 10, 0 },
+
+   .flags = DISPLAY_FLAGS_HSYNC_LOW | DISPLAY_FLAGS_VSYNC_LOW |
+   DISPLAY_FLAGS_DE_HIGH | DISPLAY_FLAGS_PIXDATA_POSEDGE,
 };
 
-static struct panel_generic_dpi_data lcd43_panel = {
-   .name   = "samsung_lte430wq_f0c",
-   .num_gpios  = 2,
-   .gpios  = {
-   OVERO_GPIO_LCD_EN,
-   OVERO_GPIO_LCD_BL
-   },
+static struct panel_dpi_platform_data overo_lcd43_pdata = {
+   .name   = "lcd43",
+   .source = "dpi.0",
+
+   .data_lines = 24,
+
+   .display_timing = &overo_lcd43_videomode,
+
+   .enable_gpio= OVERO_GPIO_LCD_EN,
+   .backlight_gpio = OVERO_GPIO_LCD_BL,
 };
 
-static struct omap_dss_device overo_lcd43_device = {
-   .name   = "lcd43",
-   .type   = OMAP_DISPLAY_TYPE_DPI,
-   .driver_name= "generic_dpi_panel",
-   .data   = &lcd43_panel,
-   .phy.dpi.data_lines = 24,
+static struct platform_device overo_lcd43_device = {
+   .name   = "panel-dpi",
+   .id = 0,
+   .dev.platform_data  = &overo_lcd43_pdata,
 };
 
-#if defined(CONFIG_PANEL_LGPHILIPS_LB035Q02) || \
-   defined(CONFIG_PANEL_LGPHILIPS_LB035Q02_MODULE)
-static struct panel_generic_dpi_data lcd35_panel = {
-   .num_gpios  = 2,
-   .gpios  = {
-   OVERO_GPIO_LCD_EN,
-   OVERO_GPIO_LCD_BL
-   },
+static struct connector_dvi_platform_data overo_dvi_connector_pdata = {
+   .name   = "dvi",
+   .source = "tfp410.0",
+   .i2c_bus_num= 3,
 };
 
-static struct omap_dss_device overo_lcd35_device = {
-   .type   = OMAP_DISPLAY_TYPE_DPI,
-   .name   = "lcd35",
-   .driver_name= "lgphilips_lb035q02_panel",
-   .phy.dpi.data_lines = 24,
-   .data   = &lcd35_panel,
+static struct platform_device overo_dvi_connector_device = {
+   .name   = "connector-dvi",
+   .id = 0,
+   .dev.platform_dat

[PATCH 06/27] ARM: OMAP: rx51: use new display drivers

2013-05-30 Thread Tomi Valkeinen
Use the new display drivers for RX51 board.

Signed-off-by: Tomi Valkeinen 
---
 arch/arm/mach-omap2/board-rx51-peripherals.c | 12 ++
 arch/arm/mach-omap2/board-rx51-video.c   | 35 ++--
 2 files changed, 24 insertions(+), 23 deletions(-)

diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c 
b/arch/arm/mach-omap2/board-rx51-peripherals.c
index 18ca61e..e35e0b6 100644
--- a/arch/arm/mach-omap2/board-rx51-peripherals.c
+++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -45,6 +45,8 @@
 #include 
 #include 
 
+#include 
+
 #if defined(CONFIG_IR_RX51) || defined(CONFIG_IR_RX51_MODULE)
 #include 
 #endif
@@ -226,6 +228,15 @@ static struct lp55xx_platform_data 
rx51_lp5523_platform_data = {
 };
 #endif
 
+#define RX51_LCD_RESET_GPIO90
+
+static struct panel_acx565akm_platform_data acx_pdata = {
+   .name   = "lcd",
+   .source = "sdi.0",
+   .reset_gpio = RX51_LCD_RESET_GPIO,
+   .datapairs  = 2,
+};
+
 static struct omap2_mcspi_device_config wl1251_mcspi_config = {
.turbo_mode = 0,
 };
@@ -254,6 +265,7 @@ static struct spi_board_info 
rx51_peripherals_spi_board_info[] __initdata = {
.chip_select= 2,
.max_speed_hz   = 600,
.controller_data= &mipid_mcspi_config,
+   .platform_data  = &acx_pdata,
},
[RX51_SPI_TSC2005] = {
.modalias   = "tsc2005",
diff --git a/arch/arm/mach-omap2/board-rx51-video.c 
b/arch/arm/mach-omap2/board-rx51-video.c
index bd74f9f..b007fd3 100644
--- a/arch/arm/mach-omap2/board-rx51-video.c
+++ b/arch/arm/mach-omap2/board-rx51-video.c
@@ -29,34 +29,21 @@
 
 #if defined(CONFIG_FB_OMAP2) || defined(CONFIG_FB_OMAP2_MODULE)
 
-static struct panel_acx565akm_data lcd_data = {
-   .reset_gpio = RX51_LCD_RESET_GPIO,
+static struct connector_atv_platform_data rx51_tv_pdata = {
+   .name = "tv",
+   .source = "venc.0",
+   .connector_type = OMAP_DSS_VENC_TYPE_COMPOSITE,
+   .invert_polarity = false,
 };
 
-static struct omap_dss_device rx51_lcd_device = {
-   .name   = "lcd",
-   .driver_name= "panel-acx565akm",
-   .type   = OMAP_DISPLAY_TYPE_SDI,
-   .phy.sdi.datapairs  = 2,
-   .data   = &lcd_data,
-};
-
-static struct omap_dss_device  rx51_tv_device = {
-   .name   = "tv",
-   .type   = OMAP_DISPLAY_TYPE_VENC,
-   .driver_name= "venc",
-   .phy.venc.type  = OMAP_DSS_VENC_TYPE_COMPOSITE,
-};
-
-static struct omap_dss_device *rx51_dss_devices[] = {
-   &rx51_lcd_device,
-   &rx51_tv_device,
+static struct platform_device rx51_tv_device = {
+   .name   = "connector-analog-tv",
+   .id = 0,
+   .dev.platform_data  = &rx51_tv_pdata,
 };
 
 static struct omap_dss_board_info rx51_dss_board_info = {
-   .num_devices= ARRAY_SIZE(rx51_dss_devices),
-   .devices= rx51_dss_devices,
-   .default_device = &rx51_lcd_device,
+   .default_display_name = "lcd",
 };
 
 static int __init rx51_video_init(void)
@@ -71,6 +58,8 @@ static int __init rx51_video_init(void)
 
omap_display_init(&rx51_dss_board_info);
 
+   platform_device_register(&rx51_tv_device);
+
return 0;
 }
 
-- 
1.8.1.2

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


[PATCH 07/27] ARM: OMAP: beagle: use new display drivers

2013-05-30 Thread Tomi Valkeinen
Use the new display drivers for Beagleboard.

Signed-off-by: Tomi Valkeinen 
---
 arch/arm/mach-omap2/board-omap3beagle.c | 56 +
 1 file changed, 36 insertions(+), 20 deletions(-)

diff --git a/arch/arm/mach-omap2/board-omap3beagle.c 
b/arch/arm/mach-omap2/board-omap3beagle.c
index 04c1165..30724e8 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -225,35 +225,46 @@ static struct mtd_partition omap3beagle_nand_partitions[] 
= {
 
 /* DSS */
 
-static struct tfp410_platform_data dvi_panel = {
-   .i2c_bus_num = 3,
-   .power_down_gpio = -1,
+static struct connector_dvi_platform_data beagle_dvi_connector_pdata = {
+   .name   = "dvi",
+   .source = "tfp410.0",
+   .i2c_bus_num= 3,
 };
 
-static struct omap_dss_device beagle_dvi_device = {
-   .type = OMAP_DISPLAY_TYPE_DPI,
-   .name = "dvi",
-   .driver_name = "tfp410",
-   .data = &dvi_panel,
-   .phy.dpi.data_lines = 24,
+static struct platform_device beagle_dvi_connector_device = {
+   .name   = "connector-dvi",
+   .id = 0,
+   .dev.platform_data  = &beagle_dvi_connector_pdata,
 };
 
-static struct omap_dss_device beagle_tv_device = {
+static struct encoder_tfp410_platform_data beagle_tfp410_pdata = {
+   .name   = "tfp410.0",
+   .source = "dpi.0",
+   .data_lines = 24,
+   .power_down_gpio= -1,
+};
+
+static struct platform_device beagle_tfp410_device = {
+   .name   = "tfp410",
+   .id = 0,
+   .dev.platform_data  = &beagle_tfp410_pdata,
+};
+
+static struct connector_atv_platform_data beagle_tv_pdata = {
.name = "tv",
-   .driver_name = "venc",
-   .type = OMAP_DISPLAY_TYPE_VENC,
-   .phy.venc.type = OMAP_DSS_VENC_TYPE_SVIDEO,
+   .source = "venc.0",
+   .connector_type = OMAP_DSS_VENC_TYPE_SVIDEO,
+   .invert_polarity = false,
 };
 
-static struct omap_dss_device *beagle_dss_devices[] = {
-   &beagle_dvi_device,
-   &beagle_tv_device,
+static struct platform_device beagle_tv_device = {
+   .name   = "connector-analog-tv",
+   .id = 0,
+   .dev.platform_data  = &beagle_tv_pdata,
 };
 
 static struct omap_dss_board_info beagle_dss_data = {
-   .num_devices = ARRAY_SIZE(beagle_dss_devices),
-   .devices = beagle_dss_devices,
-   .default_device = &beagle_dvi_device,
+   .default_display_name = "dvi",
 };
 
 #include "sdram-micron-mt46h32m32lf-6.h"
@@ -332,7 +343,7 @@ static int beagle_twl_gpio_setup(struct device *dev,
if (gpio_request_one(gpio + 1, GPIOF_IN, "EHCI_nOC"))
pr_err("%s: unable to configure EHCI_nOC\n", __func__);
}
-   dvi_panel.power_down_gpio = beagle_config.dvi_pd_gpio;
+   beagle_tfp410_pdata.power_down_gpio = beagle_config.dvi_pd_gpio;
 
/* TWL4030_GPIO_MAX i.e. LED_GPO controls HS USB Port 2 power */
phy_data[0].vcc_gpio = gpio + TWL4030_GPIO_MAX;
@@ -547,6 +558,11 @@ static void __init omap3_beagle_init(void)
if (gpio_is_valid(beagle_config.dvi_pd_gpio))
omap_mux_init_gpio(beagle_config.dvi_pd_gpio, OMAP_PIN_OUTPUT);
omap_display_init(&beagle_dss_data);
+
+   platform_device_register(&beagle_tfp410_device);
+   platform_device_register(&beagle_dvi_connector_device);
+   platform_device_register(&beagle_tv_device);
+
omap_serial_init();
omap_sdrc_init(mt46h32m32lf6_sdrc_params,
  mt46h32m32lf6_sdrc_params);
-- 
1.8.1.2

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


[PATCH 08/27] OMAPDSS: add OMAP_DISPLAY_TYPE_DVI

2013-05-30 Thread Tomi Valkeinen
Add new display bus type for DVI. This is not used by omapdss driver
itself, but is used by external encoder chips that output DVI.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/display.c | 1 +
 include/video/omapdss.h   | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/video/omap2/dss/display.c 
b/drivers/video/omap2/dss/display.c
index 0daf3e3..fafe7c9 100644
--- a/drivers/video/omap2/dss/display.c
+++ b/drivers/video/omap2/dss/display.c
@@ -61,6 +61,7 @@ int omapdss_default_get_recommended_bpp(struct 
omap_dss_device *dssdev)
case OMAP_DISPLAY_TYPE_VENC:
case OMAP_DISPLAY_TYPE_SDI:
case OMAP_DISPLAY_TYPE_HDMI:
+   case OMAP_DISPLAY_TYPE_DVI:
return 24;
default:
BUG();
diff --git a/include/video/omapdss.h b/include/video/omapdss.h
index 3582edf..6796b0d 100644
--- a/include/video/omapdss.h
+++ b/include/video/omapdss.h
@@ -70,6 +70,7 @@ enum omap_display_type {
OMAP_DISPLAY_TYPE_DSI   = 1 << 3,
OMAP_DISPLAY_TYPE_VENC  = 1 << 4,
OMAP_DISPLAY_TYPE_HDMI  = 1 << 5,
+   OMAP_DISPLAY_TYPE_DVI   = 1 << 6,
 };
 
 enum omap_plane {
-- 
1.8.1.2

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


[PATCH 09/27] drm/omap: DVI connector fix

2013-05-30 Thread Tomi Valkeinen
The omapdrm driver currently uses a string comparison to find out if the
display is a DVI display. This is not reliable, and as we now have a
specific display type for DVI, let's use that.

Signed-off-by: Tomi Valkeinen 
---
 drivers/gpu/drm/omapdrm/omap_drv.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/omapdrm/omap_drv.c 
b/drivers/gpu/drm/omapdrm/omap_drv.c
index 4c0bc40..8949246 100644
--- a/drivers/gpu/drm/omapdrm/omap_drv.c
+++ b/drivers/gpu/drm/omapdrm/omap_drv.c
@@ -65,10 +65,8 @@ static int get_connector_type(struct omap_dss_device *dssdev)
switch (dssdev->type) {
case OMAP_DISPLAY_TYPE_HDMI:
return DRM_MODE_CONNECTOR_HDMIA;
-   case OMAP_DISPLAY_TYPE_DPI:
-   if (!strcmp(dssdev->name, "dvi"))
-   return DRM_MODE_CONNECTOR_DVID;
-   /* fallthrough */
+   case OMAP_DISPLAY_TYPE_DVI:
+   return DRM_MODE_CONNECTOR_DVID;
default:
return DRM_MODE_CONNECTOR_Unknown;
}
-- 
1.8.1.2

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


[PATCH 10/27] OMAPDSS: DPI: Add ops

2013-05-30 Thread Tomi Valkeinen
Add "ops" style method for using DPI functionality.

Ops style calls will allow us to have arbitrarily long display
pipelines, where each entity can call ops in the previous display
entity.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/dpi.c | 70 +++
 include/video/omapdss.h   | 23 ++
 2 files changed, 93 insertions(+)

diff --git a/drivers/video/omap2/dss/dpi.c b/drivers/video/omap2/dss/dpi.c
index 3299e27..a7d40dd 100644
--- a/drivers/video/omap2/dss/dpi.c
+++ b/drivers/video/omap2/dss/dpi.c
@@ -462,6 +462,16 @@ void omapdss_dpi_set_timings(struct omap_dss_device 
*dssdev,
 }
 EXPORT_SYMBOL(omapdss_dpi_set_timings);
 
+static void dpi_get_timings(struct omap_dss_device *dssdev,
+   struct omap_video_timings *timings)
+{
+   mutex_lock(&dpi.lock);
+
+   *timings = dpi.timings;
+
+   mutex_unlock(&dpi.lock);
+}
+
 int dpi_check_timings(struct omap_dss_device *dssdev,
struct omap_video_timings *timings)
 {
@@ -682,6 +692,65 @@ static int dpi_probe_pdata(struct platform_device *dpidev)
return 0;
 }
 
+static int dpi_connect(struct omap_dss_device *dssdev,
+   struct omap_dss_device *dst)
+{
+   struct omap_overlay_manager *mgr;
+   int r;
+
+   r = dpi_init_regulator();
+   if (r)
+   return r;
+
+   dpi_init_pll();
+
+   mgr = omap_dss_get_overlay_manager(dssdev->dispc_channel);
+   if (!mgr)
+   return -ENODEV;
+
+   r = dss_mgr_connect(mgr, dssdev);
+   if (r)
+   return r;
+
+   r = omapdss_output_set_device(dssdev, dst);
+   if (r) {
+   DSSERR("failed to connect output to new device: %s\n",
+   dst->name);
+   dss_mgr_disconnect(mgr, dssdev);
+   return r;
+   }
+
+   return 0;
+}
+
+static void dpi_disconnect(struct omap_dss_device *dssdev,
+   struct omap_dss_device *dst)
+{
+   WARN_ON(dst != dssdev->device);
+
+   if (dst != dssdev->device)
+   return;
+
+   omapdss_output_unset_device(dssdev);
+
+   if (dssdev->manager)
+   dss_mgr_disconnect(dssdev->manager, dssdev);
+}
+
+static const struct omapdss_dpi_ops dpi_ops = {
+   .connect = dpi_connect,
+   .disconnect = dpi_disconnect,
+
+   .enable = omapdss_dpi_display_enable,
+   .disable = omapdss_dpi_display_disable,
+
+   .check_timings = dpi_check_timings,
+   .set_timings = omapdss_dpi_set_timings,
+   .get_timings = dpi_get_timings,
+
+   .set_data_lines = omapdss_dpi_set_data_lines,
+};
+
 static void dpi_init_output(struct platform_device *pdev)
 {
struct omap_dss_device *out = &dpi.output;
@@ -691,6 +760,7 @@ static void dpi_init_output(struct platform_device *pdev)
out->output_type = OMAP_DISPLAY_TYPE_DPI;
out->name = "dpi.0";
out->dispc_channel = dpi_get_channel();
+   out->ops.dpi = &dpi_ops;
out->owner = THIS_MODULE;
 
omapdss_register_output(out);
diff --git a/include/video/omapdss.h b/include/video/omapdss.h
index 6796b0d..d458e43 100644
--- a/include/video/omapdss.h
+++ b/include/video/omapdss.h
@@ -573,6 +573,25 @@ struct omap_dss_writeback_info {
u8 pre_mult_alpha;
 };
 
+struct omapdss_dpi_ops {
+   int (*connect)(struct omap_dss_device *dssdev,
+   struct omap_dss_device *dst);
+   void (*disconnect)(struct omap_dss_device *dssdev,
+   struct omap_dss_device *dst);
+
+   int (*enable)(struct omap_dss_device *dssdev);
+   void (*disable)(struct omap_dss_device *dssdev);
+
+   int (*check_timings)(struct omap_dss_device *dssdev,
+   struct omap_video_timings *timings);
+   void (*set_timings)(struct omap_dss_device *dssdev,
+   struct omap_video_timings *timings);
+   void (*get_timings)(struct omap_dss_device *dssdev,
+   struct omap_video_timings *timings);
+
+   void (*set_data_lines)(struct omap_dss_device *dssdev, int data_lines);
+};
+
 struct omap_dss_device {
/* old device, to be removed */
struct device old_dev;
@@ -645,6 +664,10 @@ struct omap_dss_device {
 
struct omap_dss_driver *driver;
 
+   union {
+   const struct omapdss_dpi_ops *dpi;
+   } ops;
+
/* helper variable for driver suspend/resume */
bool activate_after_resume;
 
-- 
1.8.1.2

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


[PATCH 11/27] OMAPDSS: SDI: Add ops

2013-05-30 Thread Tomi Valkeinen
Add "ops" style method for using SDI functionality.

Ops style calls will allow us to have arbitrarily long display
pipelines, where each entity can call ops in the previous display
entity.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/sdi.c | 78 +++
 include/video/omapdss.h   | 20 +++
 2 files changed, 98 insertions(+)

diff --git a/drivers/video/omap2/dss/sdi.c b/drivers/video/omap2/dss/sdi.c
index 0343d08..a676864 100644
--- a/drivers/video/omap2/dss/sdi.c
+++ b/drivers/video/omap2/dss/sdi.c
@@ -235,6 +235,26 @@ void omapdss_sdi_set_timings(struct omap_dss_device 
*dssdev,
 }
 EXPORT_SYMBOL(omapdss_sdi_set_timings);
 
+static void sdi_get_timings(struct omap_dss_device *dssdev,
+   struct omap_video_timings *timings)
+{
+   *timings = sdi.timings;
+}
+
+static int sdi_check_timings(struct omap_dss_device *dssdev,
+   struct omap_video_timings *timings)
+{
+   struct omap_overlay_manager *mgr = sdi.output.manager;
+
+   if (mgr && !dispc_mgr_timings_ok(mgr->id, timings))
+   return -EINVAL;
+
+   if (timings->pixel_clock == 0)
+   return -EINVAL;
+
+   return 0;
+}
+
 void omapdss_sdi_set_datapairs(struct omap_dss_device *dssdev, int datapairs)
 {
sdi.datapairs = datapairs;
@@ -339,6 +359,63 @@ static int sdi_probe_pdata(struct platform_device *sdidev)
return 0;
 }
 
+static int sdi_connect(struct omap_dss_device *dssdev,
+   struct omap_dss_device *dst)
+{
+   struct omap_overlay_manager *mgr;
+   int r;
+
+   r = sdi_init_regulator();
+   if (r)
+   return r;
+
+   mgr = omap_dss_get_overlay_manager(dssdev->dispc_channel);
+   if (!mgr)
+   return -ENODEV;
+
+   r = dss_mgr_connect(mgr, dssdev);
+   if (r)
+   return r;
+
+   r = omapdss_output_set_device(dssdev, dst);
+   if (r) {
+   DSSERR("failed to connect output to new device: %s\n",
+   dst->name);
+   dss_mgr_disconnect(mgr, dssdev);
+   return r;
+   }
+
+   return 0;
+}
+
+static void sdi_disconnect(struct omap_dss_device *dssdev,
+   struct omap_dss_device *dst)
+{
+   WARN_ON(dst != dssdev->device);
+
+   if (dst != dssdev->device)
+   return;
+
+   omapdss_output_unset_device(dssdev);
+
+   if (dssdev->manager)
+   dss_mgr_disconnect(dssdev->manager, dssdev);
+}
+
+static const struct omapdss_sdi_ops sdi_ops = {
+   .connect = sdi_connect,
+   .disconnect = sdi_disconnect,
+
+   .enable = omapdss_sdi_display_enable,
+   .disable = omapdss_sdi_display_disable,
+
+   .check_timings = sdi_check_timings,
+   .set_timings = omapdss_sdi_set_timings,
+   .get_timings = sdi_get_timings,
+
+   .set_datapairs = omapdss_sdi_set_datapairs,
+};
+
 static void sdi_init_output(struct platform_device *pdev)
 {
struct omap_dss_device *out = &sdi.output;
@@ -348,6 +425,7 @@ static void sdi_init_output(struct platform_device *pdev)
out->output_type = OMAP_DISPLAY_TYPE_SDI;
out->name = "sdi.0";
out->dispc_channel = OMAP_DSS_CHANNEL_LCD;
+   out->ops.sdi = &sdi_ops;
out->owner = THIS_MODULE;
 
omapdss_register_output(out);
diff --git a/include/video/omapdss.h b/include/video/omapdss.h
index d458e43..79e9ec8 100644
--- a/include/video/omapdss.h
+++ b/include/video/omapdss.h
@@ -592,6 +592,25 @@ struct omapdss_dpi_ops {
void (*set_data_lines)(struct omap_dss_device *dssdev, int data_lines);
 };
 
+struct omapdss_sdi_ops {
+   int (*connect)(struct omap_dss_device *dssdev,
+   struct omap_dss_device *dst);
+   void (*disconnect)(struct omap_dss_device *dssdev,
+   struct omap_dss_device *dst);
+
+   int (*enable)(struct omap_dss_device *dssdev);
+   void (*disable)(struct omap_dss_device *dssdev);
+
+   int (*check_timings)(struct omap_dss_device *dssdev,
+   struct omap_video_timings *timings);
+   void (*set_timings)(struct omap_dss_device *dssdev,
+   struct omap_video_timings *timings);
+   void (*get_timings)(struct omap_dss_device *dssdev,
+   struct omap_video_timings *timings);
+
+   void (*set_datapairs)(struct omap_dss_device *dssdev, int datapairs);
+};
+
 struct omap_dss_device {
/* old device, to be removed */
struct device old_dev;
@@ -666,6 +685,7 @@ struct omap_dss_device {
 
union {
const struct omapdss_dpi_ops *dpi;
+   const struct omapdss_sdi_ops *sdi;
} ops;
 
/* helper variable for driver suspend/resume */
-- 
1.8.1.2

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

[PATCH 12/27] OMAPDSS: DVI: Add ops

2013-05-30 Thread Tomi Valkeinen
Add "ops" style method for using DVI functionality.

Ops style calls will allow us to have arbitrarily long display
pipelines, where each entity can call ops in the previous display
entity.

Signed-off-by: Tomi Valkeinen 
---
 include/video/omapdss.h | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/include/video/omapdss.h b/include/video/omapdss.h
index 79e9ec8..9f87fc0 100644
--- a/include/video/omapdss.h
+++ b/include/video/omapdss.h
@@ -611,6 +611,23 @@ struct omapdss_sdi_ops {
void (*set_datapairs)(struct omap_dss_device *dssdev, int datapairs);
 };
 
+struct omapdss_dvi_ops {
+   int (*connect)(struct omap_dss_device *dssdev,
+   struct omap_dss_device *dst);
+   void (*disconnect)(struct omap_dss_device *dssdev,
+   struct omap_dss_device *dst);
+
+   int (*enable)(struct omap_dss_device *dssdev);
+   void (*disable)(struct omap_dss_device *dssdev);
+
+   int (*check_timings)(struct omap_dss_device *dssdev,
+   struct omap_video_timings *timings);
+   void (*set_timings)(struct omap_dss_device *dssdev,
+   struct omap_video_timings *timings);
+   void (*get_timings)(struct omap_dss_device *dssdev,
+   struct omap_video_timings *timings);
+};
+
 struct omap_dss_device {
/* old device, to be removed */
struct device old_dev;
@@ -686,6 +703,7 @@ struct omap_dss_device {
union {
const struct omapdss_dpi_ops *dpi;
const struct omapdss_sdi_ops *sdi;
+   const struct omapdss_dvi_ops *dvi;
} ops;
 
/* helper variable for driver suspend/resume */
-- 
1.8.1.2

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


[PATCH 13/27] OMAPDSS: AnalogTV: Add ops

2013-05-30 Thread Tomi Valkeinen
Add "ops" style method for using analog TV functionality.

Ops style calls will allow us to have arbitrarily long display
pipelines, where each entity can call ops in the previous display
entity.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/venc.c | 72 ++
 include/video/omapdss.h| 26 +++
 2 files changed, 98 insertions(+)

diff --git a/drivers/video/omap2/dss/venc.c b/drivers/video/omap2/dss/venc.c
index 291a40d..f5ee767 100644
--- a/drivers/video/omap2/dss/venc.c
+++ b/drivers/video/omap2/dss/venc.c
@@ -568,6 +568,16 @@ int omapdss_venc_check_timings(struct omap_dss_device 
*dssdev,
return -EINVAL;
 }
 
+static void venc_get_timings(struct omap_dss_device *dssdev,
+   struct omap_video_timings *timings)
+{
+   mutex_lock(&venc.venc_lock);
+
+   *timings = venc.timings;
+
+   mutex_unlock(&venc.venc_lock);
+}
+
 u32 omapdss_venc_get_wss(struct omap_dss_device *dssdev)
 {
/* Invert due to VENC_L21_WC_CTL:INV=1 */
@@ -783,6 +793,67 @@ static int venc_probe_pdata(struct platform_device 
*vencdev)
return 0;
 }
 
+static int venc_connect(struct omap_dss_device *dssdev,
+   struct omap_dss_device *dst)
+{
+   struct omap_overlay_manager *mgr;
+   int r;
+
+   r = venc_init_regulator();
+   if (r)
+   return r;
+
+   mgr = omap_dss_get_overlay_manager(dssdev->dispc_channel);
+   if (!mgr)
+   return -ENODEV;
+
+   r = dss_mgr_connect(mgr, dssdev);
+   if (r)
+   return r;
+
+   r = omapdss_output_set_device(dssdev, dst);
+   if (r) {
+   DSSERR("failed to connect output to new device: %s\n",
+   dst->name);
+   dss_mgr_disconnect(mgr, dssdev);
+   return r;
+   }
+
+   return 0;
+}
+
+static void venc_disconnect(struct omap_dss_device *dssdev,
+   struct omap_dss_device *dst)
+{
+   WARN_ON(dst != dssdev->device);
+
+   if (dst != dssdev->device)
+   return;
+
+   omapdss_output_unset_device(dssdev);
+
+   if (dssdev->manager)
+   dss_mgr_disconnect(dssdev->manager, dssdev);
+}
+
+static const struct omapdss_atv_ops venc_ops = {
+   .connect = venc_connect,
+   .disconnect = venc_disconnect,
+
+   .enable = omapdss_venc_display_enable,
+   .disable = omapdss_venc_display_disable,
+
+   .check_timings = omapdss_venc_check_timings,
+   .set_timings = omapdss_venc_set_timings,
+   .get_timings = venc_get_timings,
+
+   .set_type = omapdss_venc_set_type,
+   .invert_vid_out_polarity = omapdss_venc_invert_vid_out_polarity,
+
+   .set_wss = omapdss_venc_set_wss,
+   .get_wss = omapdss_venc_get_wss,
+};
+
 static void venc_init_output(struct platform_device *pdev)
 {
struct omap_dss_device *out = &venc.output;
@@ -792,6 +863,7 @@ static void venc_init_output(struct platform_device *pdev)
out->output_type = OMAP_DISPLAY_TYPE_VENC;
out->name = "venc.0";
out->dispc_channel = OMAP_DSS_CHANNEL_DIGIT;
+   out->ops.atv = &venc_ops;
out->owner = THIS_MODULE;
 
omapdss_register_output(out);
diff --git a/include/video/omapdss.h b/include/video/omapdss.h
index 9f87fc0..cb6c478 100644
--- a/include/video/omapdss.h
+++ b/include/video/omapdss.h
@@ -628,6 +628,31 @@ struct omapdss_dvi_ops {
struct omap_video_timings *timings);
 };
 
+struct omapdss_atv_ops {
+   int (*connect)(struct omap_dss_device *dssdev,
+   struct omap_dss_device *dst);
+   void (*disconnect)(struct omap_dss_device *dssdev,
+   struct omap_dss_device *dst);
+
+   int (*enable)(struct omap_dss_device *dssdev);
+   void (*disable)(struct omap_dss_device *dssdev);
+
+   int (*check_timings)(struct omap_dss_device *dssdev,
+   struct omap_video_timings *timings);
+   void (*set_timings)(struct omap_dss_device *dssdev,
+   struct omap_video_timings *timings);
+   void (*get_timings)(struct omap_dss_device *dssdev,
+   struct omap_video_timings *timings);
+
+   void (*set_type)(struct omap_dss_device *dssdev,
+   enum omap_dss_venc_type type);
+   void (*invert_vid_out_polarity)(struct omap_dss_device *dssdev,
+   bool invert_polarity);
+
+   int (*set_wss)(struct omap_dss_device *dssdev, u32 wss);
+   u32 (*get_wss)(struct omap_dss_device *dssdev);
+};
+
 struct omap_dss_device {
/* old device, to be removed */
struct device old_dev;
@@ -704,6 +729,7 @@ struct omap_dss_device {
const struct omapdss_dpi_ops *dpi;
const struct omapdss_sdi_ops *sdi;
const struct omapdss_dvi_ops *dvi;
+   const struct omapdss_atv_ops *atv;
} ops;
 
/* helper variable for driver suspend

[PATCH 14/27] OMAPDSS: HDMI: Add ops

2013-05-30 Thread Tomi Valkeinen
Add "ops" style method for using HDMI functionality.

Ops style calls will allow us to have arbitrarily long display
pipelines, where each entity can call ops in the previous display
entity.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/hdmi.c | 248 -
 include/video/omapdss.h|  47 +++-
 2 files changed, 284 insertions(+), 11 deletions(-)

diff --git a/drivers/video/omap2/dss/hdmi.c b/drivers/video/omap2/dss/hdmi.c
index 42376d1..9420923 100644
--- a/drivers/video/omap2/dss/hdmi.c
+++ b/drivers/video/omap2/dss/hdmi.c
@@ -70,6 +70,8 @@ static struct {
int ls_oe_gpio;
int hpd_gpio;
 
+   bool core_enabled;
+
struct omap_dss_device output;
 } hdmi;
 
@@ -521,8 +523,10 @@ static int hdmi_power_on_core(struct omap_dss_device 
*dssdev)
 {
int r;
 
-   gpio_set_value(hdmi.ct_cp_hpd_gpio, 1);
-   gpio_set_value(hdmi.ls_oe_gpio, 1);
+   if (gpio_is_valid(hdmi.ct_cp_hpd_gpio))
+   gpio_set_value(hdmi.ct_cp_hpd_gpio, 1);
+   if (gpio_is_valid(hdmi.ls_oe_gpio))
+   gpio_set_value(hdmi.ls_oe_gpio, 1);
 
/* wait 300us after CT_CP_HPD for the 5V power output to reach 90% */
udelay(300);
@@ -538,22 +542,30 @@ static int hdmi_power_on_core(struct omap_dss_device 
*dssdev)
/* Make selection of HDMI in DSS */
dss_select_hdmi_venc_clk_source(DSS_HDMI_M_PCLK);
 
+   hdmi.core_enabled = true;
+
return 0;
 
 err_runtime_get:
regulator_disable(hdmi.vdda_hdmi_dac_reg);
 err_vdac_enable:
-   gpio_set_value(hdmi.ct_cp_hpd_gpio, 0);
-   gpio_set_value(hdmi.ls_oe_gpio, 0);
+   if (gpio_is_valid(hdmi.ct_cp_hpd_gpio))
+   gpio_set_value(hdmi.ct_cp_hpd_gpio, 0);
+   if (gpio_is_valid(hdmi.ls_oe_gpio))
+   gpio_set_value(hdmi.ls_oe_gpio, 0);
return r;
 }
 
 static void hdmi_power_off_core(struct omap_dss_device *dssdev)
 {
+   hdmi.core_enabled = false;
+
hdmi_runtime_put();
regulator_disable(hdmi.vdda_hdmi_dac_reg);
-   gpio_set_value(hdmi.ct_cp_hpd_gpio, 0);
-   gpio_set_value(hdmi.ls_oe_gpio, 0);
+   if (gpio_is_valid(hdmi.ct_cp_hpd_gpio))
+   gpio_set_value(hdmi.ct_cp_hpd_gpio, 0);
+   if (gpio_is_valid(hdmi.ls_oe_gpio))
+   gpio_set_value(hdmi.ls_oe_gpio, 0);
 }
 
 static int hdmi_power_on_full(struct omap_dss_device *dssdev)
@@ -666,6 +678,18 @@ void omapdss_hdmi_display_set_timing(struct 
omap_dss_device *dssdev,
mutex_unlock(&hdmi.lock);
 }
 
+static void omapdss_hdmi_display_get_timings(struct omap_dss_device *dssdev,
+   struct omap_video_timings *timings)
+{
+   const struct hdmi_config *cfg;
+
+   cfg = hdmi_get_timings();
+   if (cfg == NULL)
+   cfg = &vesa_timings[0];
+
+   memcpy(timings, &cfg->timings, sizeof(cfg->timings));
+}
+
 static void hdmi_dump_regs(struct seq_file *s)
 {
mutex_lock(&hdmi.lock);
@@ -1033,6 +1057,213 @@ static int hdmi_probe_pdata(struct platform_device 
*pdev)
return 0;
 }
 
+static int hdmi_connect(struct omap_dss_device *dssdev,
+   struct omap_dss_device *dst)
+{
+   struct omap_overlay_manager *mgr;
+   int r;
+
+   dss_init_hdmi_ip_ops(&hdmi.ip_data, omapdss_get_version());
+
+   r = hdmi_init_regulator();
+   if (r)
+   return r;
+
+   mgr = omap_dss_get_overlay_manager(dssdev->dispc_channel);
+   if (!mgr)
+   return -ENODEV;
+
+   r = dss_mgr_connect(mgr, dssdev);
+   if (r)
+   return r;
+
+   r = omapdss_output_set_device(dssdev, dst);
+   if (r) {
+   DSSERR("failed to connect output to new device: %s\n",
+   dst->name);
+   dss_mgr_disconnect(mgr, dssdev);
+   return r;
+   }
+
+   return 0;
+}
+
+static void hdmi_disconnect(struct omap_dss_device *dssdev,
+   struct omap_dss_device *dst)
+{
+   WARN_ON(dst != dssdev->device);
+
+   if (dst != dssdev->device)
+   return;
+
+   omapdss_output_unset_device(dssdev);
+
+   if (dssdev->manager)
+   dss_mgr_disconnect(dssdev->manager, dssdev);
+}
+
+static void omapdss_hdmi_set_hpd_gpio(struct omap_dss_device *dssdev,
+   int hpd_gpio)
+{
+   hdmi.hpd_gpio = hpd_gpio;
+}
+
+static int hdmi_read_edid(struct omap_dss_device *dssdev,
+   u8 *edid, int len)
+{
+   bool need_enable;
+   int r;
+
+   need_enable = hdmi.core_enabled == false;
+
+   if (need_enable) {
+   r = omapdss_hdmi_core_enable(dssdev);
+   if (r)
+   return r;
+   }
+
+   r = omapdss_hdmi_read_edid(edid, len);
+
+   if (need_enable)
+   omapdss_hdmi_core_disable(dssdev);
+
+   return r;
+}
+
+static bool hdmi_detect(struct omap_dss_device *dssdev)
+{
+   return omapdss_hdmi_detec

[PATCH 15/27] OMAPDSS: DSI: Add ops

2013-05-30 Thread Tomi Valkeinen
Add "ops" style method for using DSI functionality.

Ops style calls will allow us to have arbitrarily long display
pipelines, where each entity can call ops in the previous display
entity.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/dss/dsi.c | 93 +++
 include/video/omapdss.h   | 58 +++
 2 files changed, 151 insertions(+)

diff --git a/drivers/video/omap2/dss/dsi.c b/drivers/video/omap2/dss/dsi.c
index 4ecc0c1..a6b7d85 100644
--- a/drivers/video/omap2/dss/dsi.c
+++ b/drivers/video/omap2/dss/dsi.c
@@ -383,6 +383,15 @@ static inline struct dsi_data *dsi_get_dsidrv_data(struct 
platform_device *dside
 
 static inline struct platform_device *dsi_get_dsidev_from_dssdev(struct 
omap_dss_device *dssdev)
 {
+   /* HACK: dssdev can be either the panel device, when using old API, or
+* the dsi device itself, when using the new API. So we solve this for
+* now by checking the dssdev->id. This will be removed when the old API
+* is removed.
+*/
+   if (dssdev->id == OMAP_DSS_OUTPUT_DSI1 ||
+   dssdev->id == OMAP_DSS_OUTPUT_DSI2)
+   return to_platform_device(dssdev->dev);
+
return to_platform_device(dssdev->output->dev);
 }
 
@@ -5412,6 +5421,89 @@ static int dsi_probe_pdata(struct platform_device 
*dsidev)
return 0;
 }
 
+static int dsi_connect(struct omap_dss_device *dssdev,
+   struct omap_dss_device *dst)
+{
+   struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev);
+   struct omap_overlay_manager *mgr;
+   int r;
+
+   r = dsi_regulator_init(dsidev);
+   if (r)
+   return r;
+
+   mgr = omap_dss_get_overlay_manager(dssdev->dispc_channel);
+   if (!mgr)
+   return -ENODEV;
+
+   r = dss_mgr_connect(mgr, dssdev);
+   if (r)
+   return r;
+
+   r = omapdss_output_set_device(dssdev, dst);
+   if (r) {
+   DSSERR("failed to connect output to new device: %s\n",
+   dssdev->name);
+   dss_mgr_disconnect(mgr, dssdev);
+   return r;
+   }
+
+   return 0;
+}
+
+static void dsi_disconnect(struct omap_dss_device *dssdev,
+   struct omap_dss_device *dst)
+{
+   WARN_ON(dst != dssdev->device);
+
+   if (dst != dssdev->device)
+   return;
+
+   omapdss_output_unset_device(dssdev);
+
+   if (dssdev->manager)
+   dss_mgr_disconnect(dssdev->manager, dssdev);
+}
+
+static const struct omapdss_dsi_ops dsi_ops = {
+   .connect = dsi_connect,
+   .disconnect = dsi_disconnect,
+
+   .bus_lock = dsi_bus_lock,
+   .bus_unlock = dsi_bus_unlock,
+
+   .enable = omapdss_dsi_display_enable,
+   .disable = omapdss_dsi_display_disable,
+
+   .enable_hs = omapdss_dsi_vc_enable_hs,
+
+   .configure_pins = omapdss_dsi_configure_pins,
+   .set_config = omapdss_dsi_set_config,
+
+   .enable_video_output = dsi_enable_video_output,
+   .disable_video_output = dsi_disable_video_output,
+
+   .update = omap_dsi_update,
+
+   .enable_te = omapdss_dsi_enable_te,
+
+   .request_vc = omap_dsi_request_vc,
+   .set_vc_id = omap_dsi_set_vc_id,
+   .release_vc = omap_dsi_release_vc,
+
+   .dcs_write = dsi_vc_dcs_write,
+   .dcs_write_nosync = dsi_vc_dcs_write_nosync,
+   .dcs_read = dsi_vc_dcs_read,
+
+   .gen_write = dsi_vc_generic_write,
+   .gen_write_nosync = dsi_vc_generic_write_nosync,
+   .gen_read = dsi_vc_generic_read,
+
+   .bta_sync = dsi_vc_send_bta_sync,
+
+   .set_max_rx_packet_size = dsi_vc_set_max_rx_packet_size,
+};
+
 static void dsi_init_output(struct platform_device *dsidev)
 {
struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev);
@@ -5424,6 +5516,7 @@ static void dsi_init_output(struct platform_device 
*dsidev)
out->output_type = OMAP_DISPLAY_TYPE_DSI;
out->name = dsi->module_id == 0 ? "dsi.0" : "dsi.1";
out->dispc_channel = dsi_get_channel(dsi->module_id);
+   out->ops.dsi = &dsi_ops;
out->owner = THIS_MODULE;
 
omapdss_register_output(out);
diff --git a/include/video/omapdss.h b/include/video/omapdss.h
index f0aee54..f8c26c5 100644
--- a/include/video/omapdss.h
+++ b/include/video/omapdss.h
@@ -694,6 +694,63 @@ struct omapdss_hdmi_ops {
void (*audio_stop)(struct omap_dss_device *dssdev);
 };
 
+struct omapdss_dsi_ops {
+   int (*connect)(struct omap_dss_device *dssdev,
+   struct omap_dss_device *dst);
+   void (*disconnect)(struct omap_dss_device *dssdev,
+   struct omap_dss_device *dst);
+
+   int (*enable)(struct omap_dss_device *dssdev);
+   void (*disable)(struct omap_dss_device *dssdev, bool disconnect_lanes,
+   bool enter_ulps);
+
+   /* bus configuration */
+   int (*set_config)(struct omap_dss_device *

[PATCH 16/27] OMAPDSS: Add new TFP410 Encoder driver

2013-05-30 Thread Tomi Valkeinen
Add TFP410 DPI-to-DVI Encoder driver which uses the new DSS device
model and DSS ops.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/Kconfig   |   1 +
 drivers/video/omap2/Makefile  |   1 +
 drivers/video/omap2/displays-new/Kconfig  |   9 +
 drivers/video/omap2/displays-new/Makefile |   1 +
 drivers/video/omap2/displays-new/encoder-tfp410.c | 270 ++
 5 files changed, 282 insertions(+)
 create mode 100644 drivers/video/omap2/displays-new/Kconfig
 create mode 100644 drivers/video/omap2/displays-new/Makefile
 create mode 100644 drivers/video/omap2/displays-new/encoder-tfp410.c

diff --git a/drivers/video/omap2/Kconfig b/drivers/video/omap2/Kconfig
index b07b2b0..56cad0f 100644
--- a/drivers/video/omap2/Kconfig
+++ b/drivers/video/omap2/Kconfig
@@ -6,5 +6,6 @@ if ARCH_OMAP2PLUS
 source "drivers/video/omap2/dss/Kconfig"
 source "drivers/video/omap2/omapfb/Kconfig"
 source "drivers/video/omap2/displays/Kconfig"
+source "drivers/video/omap2/displays-new/Kconfig"
 
 endif
diff --git a/drivers/video/omap2/Makefile b/drivers/video/omap2/Makefile
index 296e5c5..86873c2 100644
--- a/drivers/video/omap2/Makefile
+++ b/drivers/video/omap2/Makefile
@@ -2,4 +2,5 @@ obj-$(CONFIG_OMAP2_VRFB) += vrfb.o
 
 obj-$(CONFIG_OMAP2_DSS) += dss/
 obj-y += displays/
+obj-y += displays-new/
 obj-$(CONFIG_FB_OMAP2) += omapfb/
diff --git a/drivers/video/omap2/displays-new/Kconfig 
b/drivers/video/omap2/displays-new/Kconfig
new file mode 100644
index 000..92c2324
--- /dev/null
+++ b/drivers/video/omap2/displays-new/Kconfig
@@ -0,0 +1,9 @@
+menu "OMAP Display Device Drivers"
+depends on OMAP2_DSS
+
+config DISPLAY_ENCODER_TFP410
+tristate "TFP410 DPI to DVI Encoder"
+   help
+ Driver for TFP410 DPI to DVI encoder.
+
+endmenu
diff --git a/drivers/video/omap2/displays-new/Makefile 
b/drivers/video/omap2/displays-new/Makefile
new file mode 100644
index 000..b0d3457
--- /dev/null
+++ b/drivers/video/omap2/displays-new/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_DISPLAY_ENCODER_TFP410) += encoder-tfp410.o
diff --git a/drivers/video/omap2/displays-new/encoder-tfp410.c 
b/drivers/video/omap2/displays-new/encoder-tfp410.c
new file mode 100644
index 000..5fff526
--- /dev/null
+++ b/drivers/video/omap2/displays-new/encoder-tfp410.c
@@ -0,0 +1,270 @@
+/*
+ * TFP410 DPI-to-DVI encoder driver
+ *
+ * Copyright (C) 2013 Texas Instruments
+ * Author: Tomi Valkeinen 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+struct panel_drv_data {
+   struct omap_dss_device dssdev;
+   struct omap_dss_device *in;
+
+   int pd_gpio;
+   int data_lines;
+
+   struct omap_video_timings timings;
+};
+
+#define to_panel_data(x) container_of(x, struct panel_drv_data, dssdev)
+
+static int tfp410_connect(struct omap_dss_device *dssdev,
+   struct omap_dss_device *dst)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *in = ddata->in;
+   int r;
+
+   if (omapdss_device_is_connected(dssdev))
+   return -EBUSY;
+
+   r = in->ops.dpi->connect(in, dssdev);
+   if (r)
+   return r;
+
+   dst->output = dssdev;
+   dssdev->device = dst;
+
+   return 0;
+}
+
+static void tfp410_disconnect(struct omap_dss_device *dssdev,
+   struct omap_dss_device *dst)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *in = ddata->in;
+
+   WARN_ON(!omapdss_device_is_connected(dssdev));
+   if (!omapdss_device_is_connected(dssdev))
+   return;
+
+   WARN_ON(dst != dssdev->device);
+   if (dst != dssdev->device)
+   return;
+
+   dst->output = NULL;
+   dssdev->device = NULL;
+
+   in->ops.dpi->disconnect(in, &ddata->dssdev);
+}
+
+static int tfp410_enable(struct omap_dss_device *dssdev)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *in = ddata->in;
+   int r;
+
+   if (!omapdss_device_is_connected(dssdev))
+   return -ENODEV;
+
+   if (omapdss_device_is_enabled(dssdev))
+   return 0;
+
+   in->ops.dpi->set_timings(in, &ddata->timings);
+   in->ops.dpi->set_data_lines(in, ddata->data_lines);
+
+   r = in->ops.dpi->enable(in);
+   if (r)
+   return r;
+
+   if (gpio_is_valid(ddata->pd_gpio))
+   gpio_set_value_cansleep(ddata->pd_gpio, 1);
+
+   dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
+
+   return 0;
+}
+
+static void tfp410_disable(struct omap_dss_device *dssdev)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *in = ddata->in;
+
+   if (!o

[PATCH 17/27] OMAPDSS: Add new TPD12S015 Encoder driver

2013-05-30 Thread Tomi Valkeinen
Add TPD12S015 HDMI ESD protection and level shifter encoder driver which
uses the new DSS device model and DSS ops.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/displays-new/Kconfig   |   6 +
 drivers/video/omap2/displays-new/Makefile  |   1 +
 .../video/omap2/displays-new/encoder-tpd12s015.c   | 395 +
 3 files changed, 402 insertions(+)
 create mode 100644 drivers/video/omap2/displays-new/encoder-tpd12s015.c

diff --git a/drivers/video/omap2/displays-new/Kconfig 
b/drivers/video/omap2/displays-new/Kconfig
index 92c2324..6e4af85 100644
--- a/drivers/video/omap2/displays-new/Kconfig
+++ b/drivers/video/omap2/displays-new/Kconfig
@@ -6,4 +6,10 @@ config DISPLAY_ENCODER_TFP410
help
  Driver for TFP410 DPI to DVI encoder.
 
+config DISPLAY_ENCODER_TPD12S015
+tristate "TPD12S015 HDMI ESD protection and level shifter"
+   help
+ Driver for TPD12S015, which offers HDMI ESD protection and level
+ shifting.
+
 endmenu
diff --git a/drivers/video/omap2/displays-new/Makefile 
b/drivers/video/omap2/displays-new/Makefile
index b0d3457..c2ee45e 100644
--- a/drivers/video/omap2/displays-new/Makefile
+++ b/drivers/video/omap2/displays-new/Makefile
@@ -1 +1,2 @@
 obj-$(CONFIG_DISPLAY_ENCODER_TFP410) += encoder-tfp410.o
+obj-$(CONFIG_DISPLAY_ENCODER_TPD12S015) += encoder-tpd12s015.o
diff --git a/drivers/video/omap2/displays-new/encoder-tpd12s015.c 
b/drivers/video/omap2/displays-new/encoder-tpd12s015.c
new file mode 100644
index 000..d510c8e
--- /dev/null
+++ b/drivers/video/omap2/displays-new/encoder-tpd12s015.c
@@ -0,0 +1,395 @@
+/*
+ * TPD12S015 HDMI ESD protection & level shifter chip driver
+ *
+ * Copyright (C) 2013 Texas Instruments
+ * Author: Tomi Valkeinen 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+struct panel_drv_data {
+   struct omap_dss_device dssdev;
+   struct omap_dss_device *in;
+
+   int ct_cp_hpd_gpio;
+   int ls_oe_gpio;
+   int hpd_gpio;
+
+   struct omap_video_timings timings;
+};
+
+#define to_panel_data(x) container_of(x, struct panel_drv_data, dssdev)
+
+static int tpd_connect(struct omap_dss_device *dssdev,
+   struct omap_dss_device *dst)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *in = ddata->in;
+   int r;
+
+   r = gpio_request_one(ddata->ct_cp_hpd_gpio, GPIOF_OUT_INIT_LOW,
+   "hdmi_ct_cp_hpd");
+   if (r)
+   goto err_ct_cp_hpd;
+
+   if (gpio_is_valid(ddata->ls_oe_gpio)) {
+   r = gpio_request_one(ddata->ls_oe_gpio, GPIOF_OUT_INIT_LOW,
+   "hdmi_ls_oe");
+   if (r)
+   goto err_ls_oe;
+   }
+
+   r = gpio_request_one(ddata->hpd_gpio, GPIOF_DIR_IN,
+   "hdmi_hpd");
+   if (r)
+   goto err_hpd;
+
+
+   /* XXX */
+   in->ops.hdmi->set_hpd_gpio(in, ddata->hpd_gpio);
+
+   r = in->ops.hdmi->connect(in, dssdev);
+   if (r)
+   goto err_conn;
+
+   dst->output = dssdev;
+   dssdev->device = dst;
+
+   return 0;
+
+err_conn:
+   gpio_free(ddata->hpd_gpio);
+err_hpd:
+   if (gpio_is_valid(ddata->ls_oe_gpio))
+   gpio_free(ddata->ls_oe_gpio);
+err_ls_oe:
+   gpio_free(ddata->ct_cp_hpd_gpio);
+err_ct_cp_hpd:
+   return r;
+}
+
+static void tpd_disconnect(struct omap_dss_device *dssdev,
+   struct omap_dss_device *dst)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *in = ddata->in;
+
+   WARN_ON(dst != dssdev->device);
+
+   if (dst != dssdev->device)
+   return;
+
+   dst->output = NULL;
+   dssdev->device = NULL;
+
+   in->ops.hdmi->disconnect(in, &ddata->dssdev);
+
+   gpio_free(ddata->hpd_gpio);
+   if (gpio_is_valid(ddata->ls_oe_gpio))
+   gpio_free(ddata->ls_oe_gpio);
+   gpio_free(ddata->ct_cp_hpd_gpio);
+}
+
+static int tpd_enable(struct omap_dss_device *dssdev)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *in = ddata->in;
+   int r;
+
+   if (dssdev->state == OMAP_DSS_DISPLAY_ACTIVE)
+   return 0;
+
+   gpio_set_value(ddata->ct_cp_hpd_gpio, 1);
+   gpio_set_value(ddata->ls_oe_gpio, 1);
+
+   in->ops.hdmi->set_timings(in, &ddata->timings);
+
+   r = in->ops.hdmi->enable(in);
+   if (r)
+   return r;
+
+   if (gpio_is_valid(ddata->ls_oe_gpio))
+   gpio_set_value_cansleep(ddata->ls_oe_gpio, 1);
+
+   dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
+
+   return r;
+}
+
+static void tpd_disable(struct omap_dss_device *dssdev)
+{
+ 

[PATCH 18/27] OMAPDSS: Add new DVI Connector driver

2013-05-30 Thread Tomi Valkeinen
Add DVI Connector driver which uses the new DSS device model and DSS
ops.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/displays-new/Kconfig |   6 +
 drivers/video/omap2/displays-new/Makefile|   1 +
 drivers/video/omap2/displays-new/connector-dvi.c | 351 +++
 3 files changed, 358 insertions(+)
 create mode 100644 drivers/video/omap2/displays-new/connector-dvi.c

diff --git a/drivers/video/omap2/displays-new/Kconfig 
b/drivers/video/omap2/displays-new/Kconfig
index 6e4af85..76570fc 100644
--- a/drivers/video/omap2/displays-new/Kconfig
+++ b/drivers/video/omap2/displays-new/Kconfig
@@ -12,4 +12,10 @@ config DISPLAY_ENCODER_TPD12S015
  Driver for TPD12S015, which offers HDMI ESD protection and level
  shifting.
 
+config DISPLAY_CONNECTOR_DVI
+tristate "DVI Connector"
+   depends on I2C
+   help
+ Driver for a generic DVI connector.
+
 endmenu
diff --git a/drivers/video/omap2/displays-new/Makefile 
b/drivers/video/omap2/displays-new/Makefile
index c2ee45e..ed7dd06 100644
--- a/drivers/video/omap2/displays-new/Makefile
+++ b/drivers/video/omap2/displays-new/Makefile
@@ -1,2 +1,3 @@
 obj-$(CONFIG_DISPLAY_ENCODER_TFP410) += encoder-tfp410.o
 obj-$(CONFIG_DISPLAY_ENCODER_TPD12S015) += encoder-tpd12s015.o
+obj-$(CONFIG_DISPLAY_CONNECTOR_DVI) += connector-dvi.o
diff --git a/drivers/video/omap2/displays-new/connector-dvi.c 
b/drivers/video/omap2/displays-new/connector-dvi.c
new file mode 100644
index 000..a427460
--- /dev/null
+++ b/drivers/video/omap2/displays-new/connector-dvi.c
@@ -0,0 +1,351 @@
+/*
+ * Generic DVI Connector driver
+ *
+ * Copyright (C) 2013 Texas Instruments
+ * Author: Tomi Valkeinen 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+static const struct omap_video_timings dvic_default_timings = {
+   .x_res  = 640,
+   .y_res  = 480,
+
+   .pixel_clock= 23500,
+
+   .hfp= 48,
+   .hsw= 32,
+   .hbp= 80,
+
+   .vfp= 3,
+   .vsw= 4,
+   .vbp= 7,
+
+   .vsync_level= OMAPDSS_SIG_ACTIVE_HIGH,
+   .hsync_level= OMAPDSS_SIG_ACTIVE_HIGH,
+   .data_pclk_edge = OMAPDSS_DRIVE_SIG_RISING_EDGE,
+   .de_level   = OMAPDSS_SIG_ACTIVE_HIGH,
+   .sync_pclk_edge = OMAPDSS_DRIVE_SIG_OPPOSITE_EDGES,
+};
+
+struct panel_drv_data {
+   struct omap_dss_device dssdev;
+   struct omap_dss_device *in;
+
+   struct omap_video_timings timings;
+
+   struct i2c_adapter *i2c_adapter;
+};
+
+#define to_panel_data(x) container_of(x, struct panel_drv_data, dssdev)
+
+static int dvic_connect(struct omap_dss_device *dssdev)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *in = ddata->in;
+   int r;
+
+   if (omapdss_device_is_connected(dssdev))
+   return 0;
+
+   r = in->ops.dvi->connect(in, dssdev);
+   if (r)
+   return r;
+
+   return 0;
+}
+
+static void dvic_disconnect(struct omap_dss_device *dssdev)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *in = ddata->in;
+
+   if (!omapdss_device_is_connected(dssdev))
+   return;
+
+   in->ops.dvi->disconnect(in, dssdev);
+}
+
+static int dvic_enable(struct omap_dss_device *dssdev)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *in = ddata->in;
+   int r;
+
+   if (!omapdss_device_is_connected(dssdev))
+   return -ENODEV;
+
+   if (omapdss_device_is_enabled(dssdev))
+   return 0;
+
+   in->ops.dvi->set_timings(in, &ddata->timings);
+
+   r = in->ops.dvi->enable(in);
+   if (r)
+   return r;
+
+   dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
+
+   return 0;
+}
+
+static void dvic_disable(struct omap_dss_device *dssdev)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *in = ddata->in;
+
+   if (!omapdss_device_is_enabled(dssdev))
+   return;
+
+   in->ops.dvi->disable(in);
+
+   dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
+}
+
+static void dvic_set_timings(struct omap_dss_device *dssdev,
+   struct omap_video_timings *timings)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *in = ddata->in;
+
+   ddata->timings = *timings;
+   dssdev->panel.timings = *timings;
+
+   in->ops.dvi->set_timings(in, timings);
+}
+
+static void dvic_get_timings(struct omap_dss_device *dssdev,
+   struct omap_video_timings *timings)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev)

[PATCH 19/27] OMAPDSS: Add new HDMI Connector driver

2013-05-30 Thread Tomi Valkeinen
Add HDMI Connector driver which uses the new DSS device model and DSS
ops.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/displays-new/Kconfig  |   5 +
 drivers/video/omap2/displays-new/Makefile |   1 +
 drivers/video/omap2/displays-new/connector-hdmi.c | 375 ++
 3 files changed, 381 insertions(+)
 create mode 100644 drivers/video/omap2/displays-new/connector-hdmi.c

diff --git a/drivers/video/omap2/displays-new/Kconfig 
b/drivers/video/omap2/displays-new/Kconfig
index 76570fc..9a66413 100644
--- a/drivers/video/omap2/displays-new/Kconfig
+++ b/drivers/video/omap2/displays-new/Kconfig
@@ -18,4 +18,9 @@ config DISPLAY_CONNECTOR_DVI
help
  Driver for a generic DVI connector.
 
+config DISPLAY_CONNECTOR_HDMI
+tristate "HDMI Connector"
+   help
+ Driver for a generic HDMI connector.
+
 endmenu
diff --git a/drivers/video/omap2/displays-new/Makefile 
b/drivers/video/omap2/displays-new/Makefile
index ed7dd06..1007b5f 100644
--- a/drivers/video/omap2/displays-new/Makefile
+++ b/drivers/video/omap2/displays-new/Makefile
@@ -1,3 +1,4 @@
 obj-$(CONFIG_DISPLAY_ENCODER_TFP410) += encoder-tfp410.o
 obj-$(CONFIG_DISPLAY_ENCODER_TPD12S015) += encoder-tpd12s015.o
 obj-$(CONFIG_DISPLAY_CONNECTOR_DVI) += connector-dvi.o
+obj-$(CONFIG_DISPLAY_CONNECTOR_HDMI) += connector-hdmi.o
diff --git a/drivers/video/omap2/displays-new/connector-hdmi.c 
b/drivers/video/omap2/displays-new/connector-hdmi.c
new file mode 100644
index 000..c582671
--- /dev/null
+++ b/drivers/video/omap2/displays-new/connector-hdmi.c
@@ -0,0 +1,375 @@
+/*
+ * HDMI Connector driver
+ *
+ * Copyright (C) 2013 Texas Instruments
+ * Author: Tomi Valkeinen 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+#include 
+
+static const struct omap_video_timings hdmic_default_timings = {
+   .x_res  = 640,
+   .y_res  = 480,
+   .pixel_clock= 25175,
+   .hsw= 96,
+   .hfp= 16,
+   .hbp= 48,
+   .vsw= 2,
+   .vfp= 11,
+   .vbp= 31,
+
+   .vsync_level= OMAPDSS_SIG_ACTIVE_LOW,
+   .hsync_level= OMAPDSS_SIG_ACTIVE_LOW,
+
+   .interlace  = false,
+};
+
+struct panel_drv_data {
+   struct omap_dss_device dssdev;
+   struct omap_dss_device *in;
+
+   struct device *dev;
+
+   struct omap_video_timings timings;
+};
+
+#define to_panel_data(x) container_of(x, struct panel_drv_data, dssdev)
+
+static int hdmic_connect(struct omap_dss_device *dssdev)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *in = ddata->in;
+   int r;
+
+   dev_dbg(ddata->dev, "connect\n");
+
+   if (omapdss_device_is_connected(dssdev))
+   return 0;
+
+   r = in->ops.hdmi->connect(in, dssdev);
+   if (r)
+   return r;
+
+   return 0;
+}
+
+static void hdmic_disconnect(struct omap_dss_device *dssdev)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *in = ddata->in;
+
+   dev_dbg(ddata->dev, "disconnect\n");
+
+   if (!omapdss_device_is_connected(dssdev))
+   return;
+
+   in->ops.hdmi->disconnect(in, dssdev);
+}
+
+static int hdmic_enable(struct omap_dss_device *dssdev)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *in = ddata->in;
+   int r;
+
+   dev_dbg(ddata->dev, "enable\n");
+
+   if (!omapdss_device_is_connected(dssdev))
+   return -ENODEV;
+
+   if (omapdss_device_is_enabled(dssdev))
+   return 0;
+
+   in->ops.hdmi->set_timings(in, &ddata->timings);
+
+   r = in->ops.hdmi->enable(in);
+   if (r)
+   return r;
+
+   dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
+
+   return r;
+}
+
+static void hdmic_disable(struct omap_dss_device *dssdev)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *in = ddata->in;
+
+   dev_dbg(ddata->dev, "disable\n");
+
+   if (!omapdss_device_is_enabled(dssdev))
+   return;
+
+   in->ops.hdmi->disable(in);
+
+   dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
+}
+
+static void hdmic_set_timings(struct omap_dss_device *dssdev,
+   struct omap_video_timings *timings)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *in = ddata->in;
+
+   ddata->timings = *timings;
+   dssdev->panel.timings = *timings;
+
+   in->ops.hdmi->set_timings(in, timings);
+}
+
+static void hdmic_get_timings(struct omap_dss_device *dssdev,
+   struct omap_video_timings *timings)
+{
+   struct panel_drv_data *ddat

[PATCH 20/27] OMAPDSS: Add new Analog TV Connector driver

2013-05-30 Thread Tomi Valkeinen
Add Analog TV Connector driver which uses the new DSS device model and
DSS ops.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/displays-new/Kconfig   |   5 +
 drivers/video/omap2/displays-new/Makefile  |   1 +
 .../video/omap2/displays-new/connector-analog-tv.c | 265 +
 3 files changed, 271 insertions(+)
 create mode 100644 drivers/video/omap2/displays-new/connector-analog-tv.c

diff --git a/drivers/video/omap2/displays-new/Kconfig 
b/drivers/video/omap2/displays-new/Kconfig
index 9a66413..5326638 100644
--- a/drivers/video/omap2/displays-new/Kconfig
+++ b/drivers/video/omap2/displays-new/Kconfig
@@ -23,4 +23,9 @@ config DISPLAY_CONNECTOR_HDMI
help
  Driver for a generic HDMI connector.
 
+config DISPLAY_CONNECTOR_ANALOG_TV
+tristate "Analog TV Connector"
+   help
+ Driver for a generic analog TV connector.
+
 endmenu
diff --git a/drivers/video/omap2/displays-new/Makefile 
b/drivers/video/omap2/displays-new/Makefile
index 1007b5f..083bf08 100644
--- a/drivers/video/omap2/displays-new/Makefile
+++ b/drivers/video/omap2/displays-new/Makefile
@@ -2,3 +2,4 @@ obj-$(CONFIG_DISPLAY_ENCODER_TFP410) += encoder-tfp410.o
 obj-$(CONFIG_DISPLAY_ENCODER_TPD12S015) += encoder-tpd12s015.o
 obj-$(CONFIG_DISPLAY_CONNECTOR_DVI) += connector-dvi.o
 obj-$(CONFIG_DISPLAY_CONNECTOR_HDMI) += connector-hdmi.o
+obj-$(CONFIG_DISPLAY_CONNECTOR_ANALOG_TV) += connector-analog-tv.o
diff --git a/drivers/video/omap2/displays-new/connector-analog-tv.c 
b/drivers/video/omap2/displays-new/connector-analog-tv.c
new file mode 100644
index 000..5338f36
--- /dev/null
+++ b/drivers/video/omap2/displays-new/connector-analog-tv.c
@@ -0,0 +1,265 @@
+/*
+ * Analog TV Connector driver
+ *
+ * Copyright (C) 2013 Texas Instruments
+ * Author: Tomi Valkeinen 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+struct panel_drv_data {
+   struct omap_dss_device dssdev;
+   struct omap_dss_device *in;
+
+   struct device *dev;
+
+   struct omap_video_timings timings;
+
+   enum omap_dss_venc_type connector_type;
+   bool invert_polarity;
+};
+
+#define to_panel_data(x) container_of(x, struct panel_drv_data, dssdev)
+
+static int tvc_connect(struct omap_dss_device *dssdev)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *in = ddata->in;
+   int r;
+
+   dev_dbg(ddata->dev, "connect\n");
+
+   if (omapdss_device_is_connected(dssdev))
+   return 0;
+
+   r = in->ops.atv->connect(in, dssdev);
+   if (r)
+   return r;
+
+   return 0;
+}
+
+static void tvc_disconnect(struct omap_dss_device *dssdev)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *in = ddata->in;
+
+   dev_dbg(ddata->dev, "disconnect\n");
+
+   if (!omapdss_device_is_connected(dssdev))
+   return;
+
+   in->ops.atv->disconnect(in, dssdev);
+}
+
+static int tvc_enable(struct omap_dss_device *dssdev)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *in = ddata->in;
+   int r;
+
+   dev_dbg(ddata->dev, "enable\n");
+
+   if (!omapdss_device_is_connected(dssdev))
+   return -ENODEV;
+
+   if (omapdss_device_is_enabled(dssdev))
+   return 0;
+
+   in->ops.atv->set_timings(in, &ddata->timings);
+
+   in->ops.atv->set_type(in, ddata->connector_type);
+   in->ops.atv->invert_vid_out_polarity(in, ddata->invert_polarity);
+
+   r = in->ops.atv->enable(in);
+   if (r)
+   return r;
+
+   dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
+
+   return r;
+}
+
+static void tvc_disable(struct omap_dss_device *dssdev)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *in = ddata->in;
+
+   dev_dbg(ddata->dev, "disable\n");
+
+   if (!omapdss_device_is_enabled(dssdev))
+   return;
+
+   in->ops.atv->disable(in);
+
+   dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
+}
+
+static void tvc_set_timings(struct omap_dss_device *dssdev,
+   struct omap_video_timings *timings)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *in = ddata->in;
+
+   ddata->timings = *timings;
+   dssdev->panel.timings = *timings;
+
+   in->ops.atv->set_timings(in, timings);
+}
+
+static void tvc_get_timings(struct omap_dss_device *dssdev,
+   struct omap_video_timings *timings)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+
+   *timings = ddata->timings;
+}
+
+static int tvc_check_timings(struct omap_dss_device *dssdev,
+   struct omap_video_timings *timings)
+

[PATCH 21/27] OMAPDSS: Add new simple DPI panel driver

2013-05-30 Thread Tomi Valkeinen
Add simple DPI Panel driver which uses the new DSS device model and DSS
ops. A "simple" panel means one that does not require any special setup.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/displays-new/Kconfig |   5 +
 drivers/video/omap2/displays-new/Makefile|   1 +
 drivers/video/omap2/displays-new/panel-dpi.c | 270 +++
 3 files changed, 276 insertions(+)
 create mode 100644 drivers/video/omap2/displays-new/panel-dpi.c

diff --git a/drivers/video/omap2/displays-new/Kconfig 
b/drivers/video/omap2/displays-new/Kconfig
index 5326638..1435f2f 100644
--- a/drivers/video/omap2/displays-new/Kconfig
+++ b/drivers/video/omap2/displays-new/Kconfig
@@ -28,4 +28,9 @@ config DISPLAY_CONNECTOR_ANALOG_TV
help
  Driver for a generic analog TV connector.
 
+config PANEL_DPI
+   tristate "Generic DPI panel"
+   help
+ Driver for generic DPI panels.
+
 endmenu
diff --git a/drivers/video/omap2/displays-new/Makefile 
b/drivers/video/omap2/displays-new/Makefile
index 083bf08..54002d3 100644
--- a/drivers/video/omap2/displays-new/Makefile
+++ b/drivers/video/omap2/displays-new/Makefile
@@ -3,3 +3,4 @@ obj-$(CONFIG_DISPLAY_ENCODER_TPD12S015) += encoder-tpd12s015.o
 obj-$(CONFIG_DISPLAY_CONNECTOR_DVI) += connector-dvi.o
 obj-$(CONFIG_DISPLAY_CONNECTOR_HDMI) += connector-hdmi.o
 obj-$(CONFIG_DISPLAY_CONNECTOR_ANALOG_TV) += connector-analog-tv.o
+obj-$(CONFIG_PANEL_DPI) += panel-dpi.o
diff --git a/drivers/video/omap2/displays-new/panel-dpi.c 
b/drivers/video/omap2/displays-new/panel-dpi.c
new file mode 100644
index 000..5f8f7e7
--- /dev/null
+++ b/drivers/video/omap2/displays-new/panel-dpi.c
@@ -0,0 +1,270 @@
+/*
+ * Generic MIPI DPI Panel Driver
+ *
+ * Copyright (C) 2013 Texas Instruments
+ * Author: Tomi Valkeinen 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+struct panel_drv_data {
+   struct omap_dss_device dssdev;
+   struct omap_dss_device *in;
+
+   int data_lines;
+
+   struct omap_video_timings videomode;
+
+   int backlight_gpio;
+   int enable_gpio;
+};
+
+#define to_panel_data(p) container_of(p, struct panel_drv_data, dssdev)
+
+static int panel_dpi_connect(struct omap_dss_device *dssdev)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *in = ddata->in;
+   int r;
+
+   if (omapdss_device_is_connected(dssdev))
+   return 0;
+
+   r = in->ops.dpi->connect(in, dssdev);
+   if (r)
+   return r;
+
+   return 0;
+}
+
+static void panel_dpi_disconnect(struct omap_dss_device *dssdev)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *in = ddata->in;
+
+   if (!omapdss_device_is_connected(dssdev))
+   return;
+
+   in->ops.dpi->disconnect(in, dssdev);
+}
+
+static int panel_dpi_enable(struct omap_dss_device *dssdev)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *in = ddata->in;
+   int r;
+
+   if (!omapdss_device_is_connected(dssdev))
+   return -ENODEV;
+
+   if (omapdss_device_is_enabled(dssdev))
+   return 0;
+
+   in->ops.dpi->set_data_lines(in, ddata->data_lines);
+   in->ops.dpi->set_timings(in, &ddata->videomode);
+
+   r = in->ops.dpi->enable(in);
+   if (r)
+   return r;
+
+   if (gpio_is_valid(ddata->enable_gpio))
+   gpio_set_value_cansleep(ddata->enable_gpio, 1);
+
+   if (gpio_is_valid(ddata->backlight_gpio))
+   gpio_set_value_cansleep(ddata->backlight_gpio, 1);
+
+   dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
+
+   return 0;
+}
+
+static void panel_dpi_disable(struct omap_dss_device *dssdev)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *in = ddata->in;
+
+   if (!omapdss_device_is_enabled(dssdev))
+   return;
+
+   if (gpio_is_valid(ddata->enable_gpio))
+   gpio_set_value_cansleep(ddata->enable_gpio, 0);
+
+   if (gpio_is_valid(ddata->backlight_gpio))
+   gpio_set_value_cansleep(ddata->backlight_gpio, 0);
+
+   in->ops.dpi->disable(in);
+
+   dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
+}
+
+static void panel_dpi_set_timings(struct omap_dss_device *dssdev,
+   struct omap_video_timings *timings)
+{
+   struct panel_drv_data *ddata = to_panel_data(dssdev);
+   struct omap_dss_device *in = ddata->in;
+
+   ddata->videomode = *timings;
+   dssdev->panel.timings = *timings;
+
+   in->ops.dpi->set_timings(in, timings);
+}
+
+static void panel_dpi_get_timings(struct omap_dss_device *dssdev,
+   struct omap_video_timings *timings)
+{
+  

[PATCH 22/27] OMAPDSS: Add new DSI Command Mode panel driver

2013-05-30 Thread Tomi Valkeinen
Add DSI Command Mode panel driver which uses the new DSS device model
and DSS ops. This driver only supports a very basic set of features
which should be common to all DSI command mode panels.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/displays-new/Kconfig|5 +
 drivers/video/omap2/displays-new/Makefile   |1 +
 drivers/video/omap2/displays-new/panel-dsi-cm.c | 1336 +++
 3 files changed, 1342 insertions(+)
 create mode 100644 drivers/video/omap2/displays-new/panel-dsi-cm.c

diff --git a/drivers/video/omap2/displays-new/Kconfig 
b/drivers/video/omap2/displays-new/Kconfig
index 1435f2f..c899d5a 100644
--- a/drivers/video/omap2/displays-new/Kconfig
+++ b/drivers/video/omap2/displays-new/Kconfig
@@ -33,4 +33,9 @@ config PANEL_DPI
help
  Driver for generic DPI panels.
 
+config PANEL_DSI_CM
+   tristate "Generic DSI Command Mode Panel"
+   help
+ Driver for generic DSI command mode panels.
+
 endmenu
diff --git a/drivers/video/omap2/displays-new/Makefile 
b/drivers/video/omap2/displays-new/Makefile
index 54002d3..2e72ac3 100644
--- a/drivers/video/omap2/displays-new/Makefile
+++ b/drivers/video/omap2/displays-new/Makefile
@@ -4,3 +4,4 @@ obj-$(CONFIG_DISPLAY_CONNECTOR_DVI) += connector-dvi.o
 obj-$(CONFIG_DISPLAY_CONNECTOR_HDMI) += connector-hdmi.o
 obj-$(CONFIG_DISPLAY_CONNECTOR_ANALOG_TV) += connector-analog-tv.o
 obj-$(CONFIG_PANEL_DPI) += panel-dpi.o
+obj-$(CONFIG_PANEL_DSI_CM) += panel-dsi-cm.o
diff --git a/drivers/video/omap2/displays-new/panel-dsi-cm.c 
b/drivers/video/omap2/displays-new/panel-dsi-cm.c
new file mode 100644
index 000..48af47d
--- /dev/null
+++ b/drivers/video/omap2/displays-new/panel-dsi-cm.c
@@ -0,0 +1,1336 @@
+/*
+ * Generic DSI Command Mode panel driver
+ *
+ * Copyright (C) 2013 Texas Instruments
+ * Author: Tomi Valkeinen 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+/* #define DEBUG */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+#include 
+
+/* DSI Virtual channel. Hardcoded for now. */
+#define TCH 0
+
+#define DCS_READ_NUM_ERRORS0x05
+#define DCS_BRIGHTNESS 0x51
+#define DCS_CTRL_DISPLAY   0x53
+#define DCS_GET_ID10xda
+#define DCS_GET_ID20xdb
+#define DCS_GET_ID30xdc
+
+struct panel_drv_data {
+   struct omap_dss_device dssdev;
+   struct omap_dss_device *in;
+
+   struct omap_video_timings timings;
+
+   struct platform_device *pdev;
+
+   struct mutex lock;
+
+   struct backlight_device *bldev;
+
+   unsigned long   hw_guard_end;   /* next value of jiffies when we can
+* issue the next sleep in/out command
+*/
+   unsigned long   hw_guard_wait;  /* max guard time in jiffies */
+
+   /* panel HW configuration from DT or platform data */
+   int reset_gpio;
+   int ext_te_gpio;
+
+   bool use_dsi_backlight;
+
+   struct omap_dsi_pin_config pin_config;
+
+   /* runtime variables */
+   bool enabled;
+
+   bool te_enabled;
+
+   atomic_t do_update;
+   int channel;
+
+   struct delayed_work te_timeout_work;
+
+   bool intro_printed;
+
+   struct workqueue_struct *workqueue;
+
+   bool ulps_enabled;
+   unsigned ulps_timeout;
+   struct delayed_work ulps_work;
+};
+
+#define to_panel_data(p) container_of(p, struct panel_drv_data, dssdev)
+
+static irqreturn_t dsicm_te_isr(int irq, void *data);
+static void dsicm_te_timeout_work_callback(struct work_struct *work);
+static int _dsicm_enable_te(struct panel_drv_data *ddata, bool enable);
+
+static int dsicm_panel_reset(struct panel_drv_data *ddata);
+
+static void dsicm_ulps_work(struct work_struct *work);
+
+static void hw_guard_start(struct panel_drv_data *ddata, int guard_msec)
+{
+   ddata->hw_guard_wait = msecs_to_jiffies(guard_msec);
+   ddata->hw_guard_end = jiffies + ddata->hw_guard_wait;
+}
+
+static void hw_guard_wait(struct panel_drv_data *ddata)
+{
+   unsigned long wait = ddata->hw_guard_end - jiffies;
+
+   if ((long)wait > 0 && wait <= ddata->hw_guard_wait) {
+   set_current_state(TASK_UNINTERRUPTIBLE);
+   schedule_timeout(wait);
+   }
+}
+
+static int dsicm_dcs_read_1(struct panel_drv_data *ddata, u8 dcs_cmd, u8 *data)
+{
+   struct omap_dss_device *in = ddata->in;
+   int r;
+   u8 buf[1];
+
+   r = in->ops.dsi->dcs_read(in, ddata->channel, dcs_cmd, buf, 1);
+
+   if (r < 0)
+   return r;
+
+   *data = buf[0];
+
+   return 0;
+}
+
+static int dsicm_dcs_write_0(struct panel_drv_data *ddata, u8 dcs_cmd)
+{
+   struct omap_dss_device *in = ddata->in;
+   return in-

[PATCH 23/27] OMAPDSS: Add Sony ACX565AKM panel driver

2013-05-30 Thread Tomi Valkeinen
Add Sony ACX565AKM panel driver which uses the new DSS device model and
DSS ops.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/displays-new/Kconfig   |   6 +
 drivers/video/omap2/displays-new/Makefile  |   1 +
 .../omap2/displays-new/panel-sony-acx565akm.c  | 864 +
 3 files changed, 871 insertions(+)
 create mode 100644 drivers/video/omap2/displays-new/panel-sony-acx565akm.c

diff --git a/drivers/video/omap2/displays-new/Kconfig 
b/drivers/video/omap2/displays-new/Kconfig
index c899d5a..b7b13ac 100644
--- a/drivers/video/omap2/displays-new/Kconfig
+++ b/drivers/video/omap2/displays-new/Kconfig
@@ -38,4 +38,10 @@ config PANEL_DSI_CM
help
  Driver for generic DSI command mode panels.
 
+config PANEL_SONY_ACX565AKM
+   tristate "ACX565AKM Panel"
+   depends on SPI && BACKLIGHT_CLASS_DEVICE
+   help
+ This is the LCD panel used on Nokia N900
+
 endmenu
diff --git a/drivers/video/omap2/displays-new/Makefile 
b/drivers/video/omap2/displays-new/Makefile
index 2e72ac3..eff4b8a 100644
--- a/drivers/video/omap2/displays-new/Makefile
+++ b/drivers/video/omap2/displays-new/Makefile
@@ -5,3 +5,4 @@ obj-$(CONFIG_DISPLAY_CONNECTOR_HDMI) += connector-hdmi.o
 obj-$(CONFIG_DISPLAY_CONNECTOR_ANALOG_TV) += connector-analog-tv.o
 obj-$(CONFIG_PANEL_DPI) += panel-dpi.o
 obj-$(CONFIG_PANEL_DSI_CM) += panel-dsi-cm.o
+obj-$(CONFIG_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.o
diff --git a/drivers/video/omap2/displays-new/panel-sony-acx565akm.c 
b/drivers/video/omap2/displays-new/panel-sony-acx565akm.c
new file mode 100644
index 000..ca9c81e
--- /dev/null
+++ b/drivers/video/omap2/displays-new/panel-sony-acx565akm.c
@@ -0,0 +1,864 @@
+/*
+ * Sony ACX565AKM LCD Panel driver
+ *
+ * Copyright (C) 2010 Nokia Corporation
+ *
+ * Original Driver Author: Imre Deak 
+ * Based on panel-generic.c by Tomi Valkeinen 
+ * Adapted to new DSS2 framework: Roger Quadros 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+ * more details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program.  If not, see .
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#define MIPID_CMD_READ_DISP_ID 0x04
+#define MIPID_CMD_READ_RED 0x06
+#define MIPID_CMD_READ_GREEN   0x07
+#define MIPID_CMD_READ_BLUE0x08
+#define MIPID_CMD_READ_DISP_STATUS 0x09
+#define MIPID_CMD_RDDSDR   0x0F
+#define MIPID_CMD_SLEEP_IN 0x10
+#define MIPID_CMD_SLEEP_OUT0x11
+#define MIPID_CMD_DISP_OFF 0x28
+#define MIPID_CMD_DISP_ON  0x29
+#define MIPID_CMD_WRITE_DISP_BRIGHTNESS0x51
+#define MIPID_CMD_READ_DISP_BRIGHTNESS 0x52
+#define MIPID_CMD_WRITE_CTRL_DISP  0x53
+
+#define CTRL_DISP_BRIGHTNESS_CTRL_ON   (1 << 5)
+#define CTRL_DISP_AMBIENT_LIGHT_CTRL_ON(1 << 4)
+#define CTRL_DISP_BACKLIGHT_ON (1 << 2)
+#define CTRL_DISP_AUTO_BRIGHTNESS_ON   (1 << 1)
+
+#define MIPID_CMD_READ_CTRL_DISP   0x54
+#define MIPID_CMD_WRITE_CABC   0x55
+#define MIPID_CMD_READ_CABC0x56
+
+#define MIPID_VER_LPH8923  3
+#define MIPID_VER_LS041Y3  4
+#define MIPID_VER_L4F00311 8
+#define MIPID_VER_ACX565AKM9
+
+struct panel_drv_data {
+   struct omap_dss_device  dssdev;
+   struct omap_dss_device *in;
+
+   int reset_gpio;
+   int datapairs;
+
+   struct omap_video_timings videomode;
+
+   char*name;
+   int enabled;
+   int model;
+   int revision;
+   u8  display_id[3];
+   unsignedhas_bc:1;
+   unsignedhas_cabc:1;
+   unsignedcabc_mode;
+   unsigned long   hw_guard_end;   /* next value of jiffies
+  when we can issue the
+  next sleep in/out command */
+   unsigned long   hw_guard_wait;  /* max guard time in jiffies */
+
+   struct spi_device   *spi;
+   struct mutexmutex;
+
+   struct backlight_device *bl_dev;
+};
+
+static const struct omap_video_timings acx_panel_timings = {
+   .x_res  = 800,
+   .y_res  = 480,
+   .pixel_clock= 24000,
+   .hfp= 28,
+   .hsw= 4,
+   .hbp= 24,
+   .vfp= 3,
+   .vsw

[PATCH 24/27] OMAPDSS: Add LG.Philips LB035Q02 panel driver

2013-05-30 Thread Tomi Valkeinen
Add LG.Philips LB035Q02 panel driver which uses the new DSS device model
and DSS ops.

Signed-off-by: Tomi Valkeinen 
---
 drivers/video/omap2/displays-new/Kconfig   |   5 +
 drivers/video/omap2/displays-new/Makefile  |   1 +
 .../omap2/displays-new/panel-lgphilips-lb035q02.c  | 358 +
 3 files changed, 364 insertions(+)
 create mode 100644 drivers/video/omap2/displays-new/panel-lgphilips-lb035q02.c

diff --git a/drivers/video/omap2/displays-new/Kconfig 
b/drivers/video/omap2/displays-new/Kconfig
index b7b13ac..56e2496 100644
--- a/drivers/video/omap2/displays-new/Kconfig
+++ b/drivers/video/omap2/displays-new/Kconfig
@@ -44,4 +44,9 @@ config PANEL_SONY_ACX565AKM
help
  This is the LCD panel used on Nokia N900
 
+config PANEL_LGPHILIPS_LB035Q02_NEW
+   tristate "LG.Philips LB035Q02 LCD Panel"
+   depends on SPI
+   help
+ LCD Panel used on the Gumstix Overo Palo35
 endmenu
diff --git a/drivers/video/omap2/displays-new/Makefile 
b/drivers/video/omap2/displays-new/Makefile
index eff4b8a..3a1af4a 100644
--- a/drivers/video/omap2/displays-new/Makefile
+++ b/drivers/video/omap2/displays-new/Makefile
@@ -6,3 +6,4 @@ obj-$(CONFIG_DISPLAY_CONNECTOR_ANALOG_TV) += 
connector-analog-tv.o
 obj-$(CONFIG_PANEL_DPI) += panel-dpi.o
 obj-$(CONFIG_PANEL_DSI_CM) += panel-dsi-cm.o
 obj-$(CONFIG_PANEL_SONY_ACX565AKM) += panel-sony-acx565akm.o
+obj-$(CONFIG_PANEL_LGPHILIPS_LB035Q02_NEW) += panel-lgphilips-lb035q02.o
diff --git a/drivers/video/omap2/displays-new/panel-lgphilips-lb035q02.c 
b/drivers/video/omap2/displays-new/panel-lgphilips-lb035q02.c
new file mode 100644
index 000..6e8977b
--- /dev/null
+++ b/drivers/video/omap2/displays-new/panel-lgphilips-lb035q02.c
@@ -0,0 +1,358 @@
+/*
+ * LG.Philips LB035Q02 LCD Panel driver
+ *
+ * Copyright (C) 2013 Texas Instruments
+ * Author: Tomi Valkeinen 
+ * Based on a driver by: Steve Sakoman 
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 as published by
+ * the Free Software Foundation.
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+static struct omap_video_timings lb035q02_timings = {
+   .x_res = 320,
+   .y_res = 240,
+
+   .pixel_clock= 6500,
+
+   .hsw= 2,
+   .hfp= 20,
+   .hbp= 68,
+
+   .vsw= 2,
+   .vfp= 4,
+   .vbp= 18,
+
+   .vsync_level= OMAPDSS_SIG_ACTIVE_LOW,
+   .hsync_level= OMAPDSS_SIG_ACTIVE_LOW,
+   .data_pclk_edge = OMAPDSS_DRIVE_SIG_RISING_EDGE,
+   .de_level   = OMAPDSS_SIG_ACTIVE_HIGH,
+   .sync_pclk_edge = OMAPDSS_DRIVE_SIG_OPPOSITE_EDGES,
+};
+
+struct panel_drv_data {
+   struct omap_dss_device dssdev;
+   struct omap_dss_device *in;
+
+   struct spi_device *spi;
+
+   int data_lines;
+
+   struct omap_video_timings videomode;
+
+   int reset_gpio;
+   int backlight_gpio;
+   int enable_gpio;
+};
+
+#define to_panel_data(p) container_of(p, struct panel_drv_data, dssdev)
+
+static int lb035q02_write_reg(struct spi_device *spi, u8 reg, u16 val)
+{
+   struct spi_message msg;
+   struct spi_transfer index_xfer = {
+   .len= 3,
+   .cs_change  = 1,
+   };
+   struct spi_transfer value_xfer = {
+   .len= 3,
+   };
+   u8  buffer[16];
+
+   spi_message_init(&msg);
+
+   /* register index */
+   buffer[0] = 0x70;
+   buffer[1] = 0x00;
+   buffer[2] = reg & 0x7f;
+   index_xfer.tx_buf = buffer;
+   spi_message_add_tail(&index_xfer, &msg);
+
+   /* register value */
+   buffer[4] = 0x72;
+   buffer[5] = val >> 8;
+   buffer[6] = val;
+   value_xfer.tx_buf = buffer + 4;
+   spi_message_add_tail(&value_xfer, &msg);
+
+   return spi_sync(spi, &msg);
+}
+
+static void init_lb035q02_panel(struct spi_device *spi)
+{
+   /* Init sequence from page 28 of the lb035q02 spec */
+   lb035q02_write_reg(spi, 0x01, 0x6300);
+   lb035q02_write_reg(spi, 0x02, 0x0200);
+   lb035q02_write_reg(spi, 0x03, 0x0177);
+   lb035q02_write_reg(spi, 0x04, 0x04c7);
+   lb035q02_write_reg(spi, 0x05, 0xffc0);
+   lb035q02_write_reg(spi, 0x06, 0xe806);
+   lb035q02_write_reg(spi, 0x0a, 0x4008);
+   lb035q02_write_reg(spi, 0x0b, 0x);
+   lb035q02_write_reg(spi, 0x0d, 0x0030);
+   lb035q02_write_reg(spi, 0x0e, 0x2800);
+   lb035q02_write_reg(spi, 0x0f, 0x);
+   lb035q02_write_reg(spi, 0x16, 0x9f80);
+   lb035q02_write_reg(spi, 0x17, 0x0a0f);
+   lb035q02_write_reg(spi, 0x1e, 0x00c1);
+   lb035q02_write_reg(spi, 0x30, 0x0300);
+   lb035q02_write_reg(spi, 0x31, 0x0007);
+   lb035q02_write_reg(spi, 0x32, 0x);
+   lb035q02_write_reg(spi, 0x33, 0x);
+   lb035q02_write_reg(spi, 0x

[PATCH 27/27] ARM: OMAP: add vdds_sdi supply for sdi.0

2013-05-30 Thread Tomi Valkeinen
SDI driver gets currently the vdds_sdi regulator via omapdss device.
This is not correct, and we'll change the SDI driver to get the
regulator directly.

This patch changes the rx51 board file to add vdds_dsi supply for sdi.0
device.

Note that the vdds_sdi supply for omapdss device is still left there, as
the current display driver uses it. When both the board files and the
display driver has been changed, we can remove the unused supply.

Signed-off-by: Tomi Valkeinen 
---
 arch/arm/mach-omap2/board-rx51-peripherals.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/mach-omap2/board-rx51-peripherals.c 
b/arch/arm/mach-omap2/board-rx51-peripherals.c
index e35e0b6..c3270c0 100644
--- a/arch/arm/mach-omap2/board-rx51-peripherals.c
+++ b/arch/arm/mach-omap2/board-rx51-peripherals.c
@@ -565,6 +565,7 @@ static struct regulator_consumer_supply rx51_vio_supplies[] 
= {
 
 static struct regulator_consumer_supply rx51_vaux1_consumers[] = {
REGULATOR_SUPPLY("vdds_sdi", "omapdss"),
+   REGULATOR_SUPPLY("vdds_sdi", "omapdss_sdi.0"),
/* Si4713 supply */
REGULATOR_SUPPLY("vdd", "2-0063"),
/* lis3lv02d */
-- 
1.8.1.2

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


[PATCH 26/27] ARM: OMAP: add vdds_dsi supply for dpi.0

2013-05-30 Thread Tomi Valkeinen
DPI driver gets currently the vdds_dsi regulator via omapdss device.
This is not correct, and we'll change the DPI driver to get the
regulator directly.

This patch changes the relevant board files to add vdds_dsi supply for
dpi.0 device.

Note that the vdds_dsi supply for omapdss device is still left there, as
the current display driver uses it. When both the board files and the
display driver has been changed, we can remove the unused supply.

Signed-off-by: Tomi Valkeinen 
---
 arch/arm/mach-omap2/board-cm-t35.c   | 1 +
 arch/arm/mach-omap2/board-devkit8000.c   | 1 +
 arch/arm/mach-omap2/board-ldp.c  | 1 +
 arch/arm/mach-omap2/board-omap3pandora.c | 1 +
 arch/arm/mach-omap2/twl-common.c | 1 +
 5 files changed, 5 insertions(+)

diff --git a/arch/arm/mach-omap2/board-cm-t35.c 
b/arch/arm/mach-omap2/board-cm-t35.c
index ce00968..d4622ed 100644
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -293,6 +293,7 @@ static struct regulator_consumer_supply 
cm_t35_vsim_supply[] = {
 static struct regulator_consumer_supply cm_t35_vio_supplies[] = {
REGULATOR_SUPPLY("vcc", "spi1.0"),
REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
+   REGULATOR_SUPPLY("vdds_dsi", "omapdss_dpi.0"),
REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi.0"),
 };
 
diff --git a/arch/arm/mach-omap2/board-devkit8000.c 
b/arch/arm/mach-omap2/board-devkit8000.c
index 5764205..f1d91ba 100644
--- a/arch/arm/mach-omap2/board-devkit8000.c
+++ b/arch/arm/mach-omap2/board-devkit8000.c
@@ -222,6 +222,7 @@ static struct twl4030_gpio_platform_data 
devkit8000_gpio_data = {
 
 static struct regulator_consumer_supply devkit8000_vpll1_supplies[] = {
REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
+   REGULATOR_SUPPLY("vdds_dsi", "omapdss_dpi.0"),
REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi.0"),
 };
 
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
index 3dbc881..62e4f70 100644
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -272,6 +272,7 @@ static struct regulator_init_data ldp_vaux1 = {
 
 static struct regulator_consumer_supply ldp_vpll2_supplies[] = {
REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
+   REGULATOR_SUPPLY("vdds_dsi", "omapdss_dpi.0"),
REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi.0"),
 };
 
diff --git a/arch/arm/mach-omap2/board-omap3pandora.c 
b/arch/arm/mach-omap2/board-omap3pandora.c
index 28133d5..b1547a0 100644
--- a/arch/arm/mach-omap2/board-omap3pandora.c
+++ b/arch/arm/mach-omap2/board-omap3pandora.c
@@ -343,6 +343,7 @@ static struct regulator_consumer_supply 
pandora_vmmc3_supply[] = {
 static struct regulator_consumer_supply pandora_vdds_supplies[] = {
REGULATOR_SUPPLY("vdds_sdi", "omapdss"),
REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
+   REGULATOR_SUPPLY("vdds_dsi", "omapdss_dpi.0"),
REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi.0"),
 };
 
diff --git a/arch/arm/mach-omap2/twl-common.c b/arch/arm/mach-omap2/twl-common.c
index 51e138c..c05898f 100644
--- a/arch/arm/mach-omap2/twl-common.c
+++ b/arch/arm/mach-omap2/twl-common.c
@@ -140,6 +140,7 @@ static struct regulator_init_data omap3_vdac_idata = {
 
 static struct regulator_consumer_supply omap3_vpll2_supplies[] = {
REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
+   REGULATOR_SUPPLY("vdds_dsi", "omapdss_dpi.0"),
REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi.0"),
 };
 
-- 
1.8.1.2

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


[PATCH 25/27] ARM: OMAP: fix dsi regulator names

2013-05-30 Thread Tomi Valkeinen
board-cm-t35.c and board-ldp.c contain regulator supply entries for
vdds_dsi. However, the given device name is wrong.

This patch fixes the device name from omapdss_dsi1 to omapdss_dsi.0.

Note that as far as I know, DSI driver is not used on these boards, so
this should not have caused any problems.

Signed-off-by: Tomi Valkeinen 
---
 arch/arm/mach-omap2/board-cm-t35.c | 2 +-
 arch/arm/mach-omap2/board-ldp.c| 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/board-cm-t35.c 
b/arch/arm/mach-omap2/board-cm-t35.c
index ee6218c..ce00968 100644
--- a/arch/arm/mach-omap2/board-cm-t35.c
+++ b/arch/arm/mach-omap2/board-cm-t35.c
@@ -293,7 +293,7 @@ static struct regulator_consumer_supply 
cm_t35_vsim_supply[] = {
 static struct regulator_consumer_supply cm_t35_vio_supplies[] = {
REGULATOR_SUPPLY("vcc", "spi1.0"),
REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
-   REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi1"),
+   REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi.0"),
 };
 
 /* VMMC1 for MMC1 pins CMD, CLK, DAT0..DAT3 (20 mA, plus card == max 220 mA) */
diff --git a/arch/arm/mach-omap2/board-ldp.c b/arch/arm/mach-omap2/board-ldp.c
index d0d17bc..3dbc881 100644
--- a/arch/arm/mach-omap2/board-ldp.c
+++ b/arch/arm/mach-omap2/board-ldp.c
@@ -272,7 +272,7 @@ static struct regulator_init_data ldp_vaux1 = {
 
 static struct regulator_consumer_supply ldp_vpll2_supplies[] = {
REGULATOR_SUPPLY("vdds_dsi", "omapdss"),
-   REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi1"),
+   REGULATOR_SUPPLY("vdds_dsi", "omapdss_dsi.0"),
 };
 
 static struct regulator_init_data ldp_vpll2 = {
-- 
1.8.1.2

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


Re: [PATCH] ASoC: OMAP: Remove obsolete Makefile line

2013-05-30 Thread Jarkko Nikula
On Thu, 30 May 2013 09:37:40 +0200
Paul Bolle  wrote:

> Support for omap2evm was removed in v3.0. But only one of its two
> lines in this Makefile was removed. Remove the second line too.
> 
> Signed-off-by: Paul Bolle 
> ---
> Eyeball tested only.
> 
>  sound/soc/omap/Makefile | 1 -
>  1 file changed, 1 deletion(-)
> 
True, commit 91d94af ("omap: Remove support for omap2evm") removed only 
omap2evm.o.

Acked-by: Jarkko Nikula 
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" 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/3] PM / AVS: SmartReflex: driver misc fixes

2013-05-30 Thread Andrii Tseglytskyi
The following patch series contain several misc fixes to SmartReflex driver:

1. disable errgen before vpbound disable. Critical fix, needed for
proper work of AVS-VP communicaton protocol.

2. disable runtime PM on driver remove. Trivial - runtime PM cleanup.

3. fix driver name. Trivial - proper DRIVER_NAME was not defined
since SmartReflex driver was introduced with initial commit.

Patches are based on:
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
tag: v3.10-rc3

Verified on OMAP4430. Boot - OK. SmartReflex registers debug dump - OK

Changes in v2:
- rebased to v3.10-rc3
- minor comment update in "disable errgen before vpbound disable" patch

Andrii Tseglytskyi (2):
  PM / AVS: SmartReflex: disable runtime PM on driver remove
  PM / AVS: SmartReflex: fix driver name

Nishanth Menon (1):
  PM / AVS: SmartReflex: disable errgen before vpbound disable

 drivers/power/avs/smartreflex.c |   15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

-- 
1.7.9.5

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


[PATCH v2 3/3] PM / AVS: SmartReflex: fix driver name

2013-05-30 Thread Andrii Tseglytskyi
DRIVER_NAME was undefined for SmartReflex. Now it is
defined with valid value "smartreflex". It is needed
to define proper value for:
MODULE_ALIAS("platform:" DRIVER_NAME);

Signed-off-by: Andrii Tseglytskyi 
Acked-by: Nishanth Menon 
---
 drivers/power/avs/smartreflex.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/power/avs/smartreflex.c b/drivers/power/avs/smartreflex.c
index 9b56648..002005e 100644
--- a/drivers/power/avs/smartreflex.c
+++ b/drivers/power/avs/smartreflex.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 
+#define DRIVER_NAME"smartreflex"
 #define SMARTREFLEX_NAME_LEN   16
 #define NVALUE_NAME_LEN40
 #define SR_DISABLE_TIMEOUT 200
@@ -1070,7 +1071,7 @@ static struct platform_driver smartreflex_driver = {
.remove = omap_sr_remove,
.shutdown   = omap_sr_shutdown,
.driver = {
-   .name   = "smartreflex",
+   .name   = DRIVER_NAME,
},
 };
 
-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" 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/3] PM / AVS: SmartReflex: disable runtime PM on driver remove

2013-05-30 Thread Andrii Tseglytskyi
Runtime PM should be disabled for device on driver remove,
otherwise runtime PM will be not balanced, and this will cause
an error message, on next driver probe.

Signed-off-by: Andrii Tseglytskyi 
Acked-by: Nishanth Menon 
---
 drivers/power/avs/smartreflex.c |1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/power/avs/smartreflex.c b/drivers/power/avs/smartreflex.c
index f34d34d..9b56648 100644
--- a/drivers/power/avs/smartreflex.c
+++ b/drivers/power/avs/smartreflex.c
@@ -1032,6 +1032,7 @@ static int omap_sr_remove(struct platform_device *pdev)
if (sr_info->dbg_dir)
debugfs_remove_recursive(sr_info->dbg_dir);
 
+   pm_runtime_disable(&pdev->dev);
list_del(&sr_info->node);
iounmap(sr_info->base);
kfree(sr_info->name);
-- 
1.7.9.5

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


[PATCH v2 1/3] PM / AVS: SmartReflex: disable errgen before vpbound disable

2013-05-30 Thread Andrii Tseglytskyi
From: Nishanth Menon 

vpboundsintr_en is available inside the IP block as an re-sycned
version and one which is not. Due to this, there is an 1 sysclk
cycle window where the SR_SInterruptz signal could be asserted low.
IF, intr_en is cleared on the exact same cycle as the irqclr, an
additional pulse is generated which indicates for VP that
an additional adjustment of voltage is required.

This results in VP doing two voltage adjustments for the SRERR
(based on configuration, upto 4 steps), instead of the needed
1 step.
Due to the unexpected pulse from AVS which breaks the AVS-VP
communication protocol, VP also ends up in a stuck condition by
entering a state where VP module remains non-responsive
to any futher AVS adjustment events. This creates the symptom
called "TRANXDONE Timeout" scenario.

By disabling errgen prior to disable of intr_en, this situation
can be avoided.

Signed-off-by: Vincent Bour 
Signed-off-by: Leonardo Affortunati 
Signed-off-by: Nishanth Menon 
Signed-off-by: Andrii.Tseglytskyi 
---
 drivers/power/avs/smartreflex.c |   11 ---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/power/avs/smartreflex.c b/drivers/power/avs/smartreflex.c
index 6b2238b..f34d34d 100644
--- a/drivers/power/avs/smartreflex.c
+++ b/drivers/power/avs/smartreflex.c
@@ -449,12 +449,17 @@ int sr_disable_errgen(struct voltagedomain *voltdm)
return -EINVAL;
}
 
-   /* Disable the interrupts of ERROR module */
-   sr_modify_reg(sr, errconfig_offs, vpboundint_en | vpboundint_st, 0);
-
/* Disable the Sensor and errorgen */
sr_modify_reg(sr, SRCONFIG, SRCONFIG_SENENABLE | SRCONFIG_ERRGEN_EN, 0);
 
+   /*
+* Disable the interrupts of ERROR module
+* NOTE: modify is a read, modify,write - an implicit OCP barrier
+* which is required is present here - sequencing is critical
+* at this point (after errgen is disabled, vpboundint disable)
+*/
+   sr_modify_reg(sr, errconfig_offs, vpboundint_en | vpboundint_st, 0);
+
return 0;
 }
 
-- 
1.7.9.5

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


[PATCH 2/7] usb, dwc3: remove redundant D0 power state set

2013-05-30 Thread Yijing Wang
Pci_enable_device() will set device power state to D0,
so it's no need to do it again in dwc3_pci_probe().

Signed-off-by: Yijing Wang 
---
 drivers/usb/dwc3/dwc3-pci.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-pci.c b/drivers/usb/dwc3/dwc3-pci.c
index 227d4a7..c068608 100644
--- a/drivers/usb/dwc3/dwc3-pci.c
+++ b/drivers/usb/dwc3/dwc3-pci.c
@@ -133,7 +133,6 @@ static int dwc3_pci_probe(struct pci_dev *pci,
return -ENODEV;
}
 
-   pci_set_power_state(pci, PCI_D0);
pci_set_master(pci);
 
ret = dwc3_pci_register_phys(glue);
-- 
1.7.1


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


[PATCH] ARM: OMAP2: TI81XX: id: Add cpu id for TI816x ES2.0 and ES2.1

2013-05-30 Thread Aida Mynzhasova
Currently omap3xxx_check_revision() detects ES1.0 and ES1.1 only,
this patch extends it by adding ES2.0 and ES2.1 versions support.

Signed-off-by: Aida Mynzhasova 
---
 arch/arm/mach-omap2/id.c  |   11 +--
 arch/arm/mach-omap2/soc.h |2 ++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/id.c b/arch/arm/mach-omap2/id.c
index 1272c41..8b762a3 100644
--- a/arch/arm/mach-omap2/id.c
+++ b/arch/arm/mach-omap2/id.c
@@ -405,11 +405,18 @@ void __init omap3xxx_check_revision(void)
cpu_rev = "1.0";
break;
case 1:
-   /* FALLTHROUGH */
-   default:
omap_revision = TI8168_REV_ES1_1;
cpu_rev = "1.1";
break;
+   case 2:
+   omap_revision = TI8168_REV_ES2_0;
+   cpu_rev = "2.0";
+   break;
+   case 3:
+   /* FALLTHROUGH */
+   default:
+   omap_revision = TI8168_REV_ES2_1;
+   cpu_rev = "2.1";
}
break;
case 0xb944:
diff --git a/arch/arm/mach-omap2/soc.h b/arch/arm/mach-omap2/soc.h
index 197cc16..8e00226 100644
--- a/arch/arm/mach-omap2/soc.h
+++ b/arch/arm/mach-omap2/soc.h
@@ -383,6 +383,8 @@ IS_OMAP_TYPE(3430, 0x3430)
 #define TI816X_CLASS   0x81600034
 #define TI8168_REV_ES1_0   TI816X_CLASS
 #define TI8168_REV_ES1_1   (TI816X_CLASS | (0x1 << 8))
+#define TI8168_REV_ES2_0   (TI816X_CLASS | (0x2 << 8))
+#define TI8168_REV_ES2_1   (TI816X_CLASS | (0x3 << 8))
 
 #define TI814X_CLASS   0x81400034
 #define TI8148_REV_ES1_0   TI814X_CLASS
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" 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/2] PM / AVS: SmartReflex: optimization series

2013-05-30 Thread Andrii Tseglytskyi
The following patch series introduces a few optimizations for SmartReflex 
driver.

1. devm_* API usage for SmartReflex. This allows us to have brilliant resources
handling - allocation/auto free, map/auto unmap. Another benefit - lot of error 
checks
can be dropped.

2. Another small optimization resolves order of initialization between 
SmartReflex driver
and SmartReflex class. Class is initialized before driver.

Patches are based on:
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
tag: v3.10-rc3

Verified on OMAP4430. Boot - OK. SmartReflex registers debug dump - OK

Available on GitHub:
https://github.com/andriit/linux-omap-k3.8/commits/avs_sr_driver_optimization_v02

Andrii Tseglytskyi (2):
  PM / AVS: SmartReflex: use devm_* API to initialize SmartReflex
  PM / AVS: SmartReflex/class3: Fix order of initialization of SR class
and SR driver

 arch/arm/mach-omap2/smartreflex-class3.c |2 +-
 drivers/power/avs/smartreflex.c  |   86 --
 2 files changed, 23 insertions(+), 65 deletions(-)

-- 
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" 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/2] PM / AVS: SmartReflex: use devm_* API to initialize SmartReflex

2013-05-30 Thread Andrii Tseglytskyi
Use of of devm_* API for resource allocation provides benefits such
as auto handling of resource free. This reduces possibility have
memory leaks in case of wrong error handling. All direct release
calls should be removed to avoid races.

Reported-by: Grygorii Strashko 
Signed-off-by: Andrii Tseglytskyi 
---
 drivers/power/avs/smartreflex.c |   77 +++
 1 file changed, 22 insertions(+), 55 deletions(-)

diff --git a/drivers/power/avs/smartreflex.c b/drivers/power/avs/smartreflex.c
index 6b2238b..60cf0ee 100644
--- a/drivers/power/avs/smartreflex.c
+++ b/drivers/power/avs/smartreflex.c
@@ -27,7 +27,8 @@
 #include 
 #include 
 
-#define SMARTREFLEX_NAME_LEN   16
+#define DRIVER_NAME"smartreflex"
+#define SMARTREFLEX_NAME_LEN   32
 #define NVALUE_NAME_LEN40
 #define SR_DISABLE_TIMEOUT 200
 
@@ -207,12 +208,11 @@ static void sr_stop_vddautocomp(struct omap_sr *sr)
 static int sr_late_init(struct omap_sr *sr_info)
 {
struct omap_sr_data *pdata = sr_info->pdev->dev.platform_data;
-   struct resource *mem;
int ret = 0;
 
if (sr_class->notify && sr_class->notify_flags && sr_info->irq) {
-   ret = request_irq(sr_info->irq, sr_interrupt,
- 0, sr_info->name, sr_info);
+   ret = devm_request_irq(&sr_info->pdev->dev, sr_info->irq,
+  sr_interrupt, 0, sr_info->name, sr_info);
if (ret)
goto error;
disable_irq(sr_info->irq);
@@ -224,14 +224,10 @@ static int sr_late_init(struct omap_sr *sr_info)
return ret;
 
 error:
-   iounmap(sr_info->base);
-   mem = platform_get_resource(sr_info->pdev, IORESOURCE_MEM, 0);
-   release_mem_region(mem->start, resource_size(mem));
list_del(&sr_info->node);
dev_err(&sr_info->pdev->dev, "%s: ERROR in registering"
"interrupt handler. Smartreflex will"
"not function as desired\n", __func__);
-   kfree(sr_info);
 
return ret;
 }
@@ -847,34 +843,33 @@ static int __init omap_sr_probe(struct platform_device 
*pdev)
struct dentry *nvalue_dir;
int i, ret = 0;
 
-   sr_info = kzalloc(sizeof(struct omap_sr), GFP_KERNEL);
+   sr_info = devm_kzalloc(&pdev->dev, sizeof(struct omap_sr), GFP_KERNEL);
if (!sr_info) {
dev_err(&pdev->dev, "%s: unable to allocate sr_info\n",
__func__);
return -ENOMEM;
}
 
+   sr_info->name = devm_kzalloc(&pdev->dev,
+SMARTREFLEX_NAME_LEN, GFP_KERNEL);
+   if (!sr_info->name) {
+   dev_err(&pdev->dev, "%s: unable to allocate SR instance name\n",
+   __func__);
+   return -ENOMEM;
+   }
+
platform_set_drvdata(pdev, sr_info);
 
if (!pdata) {
dev_err(&pdev->dev, "%s: platform data missing\n", __func__);
-   ret = -EINVAL;
-   goto err_free_devinfo;
+   return -EINVAL;
}
 
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-   if (!mem) {
-   dev_err(&pdev->dev, "%s: no mem resource\n", __func__);
-   ret = -ENODEV;
-   goto err_free_devinfo;
-   }
-
-   mem = request_mem_region(mem->start, resource_size(mem),
-   dev_name(&pdev->dev));
-   if (!mem) {
-   dev_err(&pdev->dev, "%s: no mem region\n", __func__);
-   ret = -EBUSY;
-   goto err_free_devinfo;
+   sr_info->base = devm_ioremap_resource(&pdev->dev, mem);
+   if (IS_ERR(sr_info->base)) {
+   dev_err(&pdev->dev, "%s: ioremap fail\n", __func__);
+   return PTR_ERR(sr_info->base);
}
 
irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0);
@@ -882,13 +877,7 @@ static int __init omap_sr_probe(struct platform_device 
*pdev)
pm_runtime_enable(&pdev->dev);
pm_runtime_irq_safe(&pdev->dev);
 
-   sr_info->name = kasprintf(GFP_KERNEL, "%s", pdata->name);
-   if (!sr_info->name) {
-   dev_err(&pdev->dev, "%s: Unable to alloc SR instance name\n",
-   __func__);
-   ret = -ENOMEM;
-   goto err_release_region;
-   }
+   snprintf(sr_info->name, SMARTREFLEX_NAME_LEN, "%s", pdata->name);
 
sr_info->pdev = pdev;
sr_info->srid = pdev->id;
@@ -905,13 +894,6 @@ static int __init omap_sr_probe(struct platform_device 
*pdev)
sr_info->autocomp_active = false;
sr_info->ip_type = pdata->ip_type;
 
-   sr_info->base = ioremap(mem->start, resource_size(mem));
-   if (!sr_info->base) {
-   dev_err(&pdev->dev, "%s: ioremap fail\n", __func__);
-   ret = -ENOMEM;
-   goto err_free_name;
-   }
-
if (irq)
sr_info->irq = irq

[PATCH v1 2/2] PM / AVS: SmartReflex/class3: Fix order of initialization of SR class and SR driver

2013-05-30 Thread Andrii Tseglytskyi
SmartReflex consists of three entities: SR device, SR class and
SR driver. SmartReflex driver depends on SmartReflex class, but
order of their initialization is not clear. They both use
late_initcall(), and order depends on Makefile calls.
Patch moves initialization of SR class to device_initcall(),
and removes redundant call of sr_late_init().

This provides predictable order of SmartReflex initcalls:
1. device_initcall() -> SmartReflex class init
2. late_initcall() -> SmartReflex driver init

Signed-off-by: Andrii Tseglytskyi 
---
 arch/arm/mach-omap2/smartreflex-class3.c |2 +-
 drivers/power/avs/smartreflex.c  |9 -
 2 files changed, 1 insertion(+), 10 deletions(-)

diff --git a/arch/arm/mach-omap2/smartreflex-class3.c 
b/arch/arm/mach-omap2/smartreflex-class3.c
index aee3c89..50523b8 100644
--- a/arch/arm/mach-omap2/smartreflex-class3.c
+++ b/arch/arm/mach-omap2/smartreflex-class3.c
@@ -59,4 +59,4 @@ static int __init sr_class3_init(void)
pr_info("SmartReflex Class3 initialized\n");
return sr_register_class(&class3_data);
 }
-omap_late_initcall(sr_class3_init);
+omap_device_initcall(sr_class3_init);
diff --git a/drivers/power/avs/smartreflex.c b/drivers/power/avs/smartreflex.c
index 60cf0ee..8a68b4f 100644
--- a/drivers/power/avs/smartreflex.c
+++ b/drivers/power/avs/smartreflex.c
@@ -651,8 +651,6 @@ void sr_disable(struct voltagedomain *voltdm)
  */
 int sr_register_class(struct omap_sr_class_data *class_data)
 {
-   struct omap_sr *sr_info;
-
if (!class_data) {
pr_warning("%s:, Smartreflex class data passed is NULL\n",
__func__);
@@ -667,13 +665,6 @@ int sr_register_class(struct omap_sr_class_data 
*class_data)
 
sr_class = class_data;
 
-   /*
-* Call into late init to do intializations that require
-* both sr driver and sr class driver to be initiallized.
-*/
-   list_for_each_entry(sr_info, &sr_list, node)
-   sr_late_init(sr_info);
-
return 0;
 }
 
-- 
1.7.9.5

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


Re: [PATCH] ASoC: OMAP: Remove obsolete Makefile line

2013-05-30 Thread Mark Brown
On Thu, May 30, 2013 at 09:37:40AM +0200, Paul Bolle wrote:
> Support for omap2evm was removed in v3.0. But only one of its two
> lines in this Makefile was removed. Remove the second line too.

Applied, thanks.


signature.asc
Description: Digital signature


[PATCH] ARM: OMAP2+: Remove obsolete Makefile line

2013-05-30 Thread Paul Bolle
The OMAP runtime PM implementation was removed in v3.0. But one Makefile
line, which was used to tweak CFLAGS, was overlooked. Remove it too.

Signed-off-by: Paul Bolle 
---
Untested. This cleans up after commit 638080c37a ("OMAP2+ / PM: move
runtime PM implementation to use device power domains").

 arch/arm/mach-omap2/Makefile | 4 
 1 file changed, 4 deletions(-)

diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 55a9d67..7279fa8 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -93,10 +93,6 @@ obj-$(CONFIG_POWER_AVS_OMAP_CLASS3)+= 
smartreflex-class3.o
 AFLAGS_sleep24xx.o :=-Wa,-march=armv6
 AFLAGS_sleep34xx.o :=-Wa,-march=armv7-a$(plus_sec)
 
-ifeq ($(CONFIG_PM_VERBOSE),y)
-CFLAGS_pm_bus.o+= -DDEBUG
-endif
-
 endif
 
 ifeq ($(CONFIG_CPU_IDLE),y)
-- 
1.7.11.7

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


Re: [PATCH 05/32] OMAPDSS: fix dss_get_ctx_loss_count for DT

2013-05-30 Thread Tomi Valkeinen
On 30/05/13 14:09, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 12:34 Thu 30 May , Tomi Valkeinen wrote:
>> When using DT, dss device does not have platform data. However,
>> dss_get_ctx_loss_count() uses dss device's platform data to find the
>> get_ctx_loss_count function pointer.
>>
>> To fix this, dss_get_ctx_loss_count() needs to be changed to get the
>> platform data from the omapdss device, which is a "virtual" device and
>> always has platform data.
>>
>> Signed-off-by: Tomi Valkeinen 
>> ---
>>  drivers/video/omap2/dss/dss.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/video/omap2/dss/dss.c b/drivers/video/omap2/dss/dss.c
>> index 94f66f9..bd01608 100644
>> --- a/drivers/video/omap2/dss/dss.c
>> +++ b/drivers/video/omap2/dss/dss.c
>> @@ -157,7 +157,8 @@ static void dss_restore_context(void)
>>  
>>  int dss_get_ctx_loss_count(void)
>>  {
>> -struct omap_dss_board_info *board_data = dss.pdev->dev.platform_data;
>> +struct platform_device *core_pdev = dss_get_core_pdev();
>> +struct omap_dss_board_info *board_data = core_pdev->dev.platform_data;
> 
>   how about store the pdata in the drivers internal struct and if !dt
>   you ust do this
> 
>   dss_dev->pdata = *pdev->dev.platform_data;
> 
>   to copy it and we do not alloc it for dt

It's not quite that simple. We need some OMAP arch functions (like
get_ctx_loss_count here) that are not currently exposed via any other
method to drivers except passing a function pointer with platform data.
We need that also when booting with DT.

We have a bunch of devices for the display subsystem hardware blocks,
like the "dss" here. When booting with DT, these blocks are represented
in the DT data, and do not have platform data.

We also have a "virtual" device, "omapdss", which doesn't match any hw
block. It's created in the arch setup stage. It's really a legacy thing,
but with DT it can be used conveniently to pass the platform data.

The problem this patch fixes is that we used to pass the arch functions
for each of those HW block drivers. But with DT, we need to get the arch
functions from the "omapdss" device, gotten with dss_get_core_pdev().

 Tomi




signature.asc
Description: OpenPGP digital signature


Re: [PATCH 06/32] OMAPDSS: DPI: fix regulators for DT

2013-05-30 Thread Jean-Christophe PLAGNIOL-VILLARD
On 12:34 Thu 30 May , Tomi Valkeinen wrote:
> On some platforms DPI requires a regulator to be enabled to power up the
> output pins. This regulator is, for some reason, currently attached to
> the virtual omapdss device, instead of the DPI device. This does not
> work for DT, as the regulator mappings need to be described in the DT
> data, and the virtual omapdss device is not present there.
> 
> Fix the issue by acquiring the regulator in the DPI device. To retain
> compatibility with the current board files, the old method of getting
> the regulator is kept. The old method can be removed when the board
> files have been changed to pass the regulator to DPI.

as discuss with Arnd we should handle regular enable and disable at device
probe for every device as we do for pinctrl

Best Regards,
J.
> Signed-off-by: Tomi Valkeinen 
> ---
>  drivers/video/omap2/dss/dpi.c | 21 ++---
>  1 file changed, 18 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/video/omap2/dss/dpi.c b/drivers/video/omap2/dss/dpi.c
> index ef8fca2..43f6b26 100644
> --- a/drivers/video/omap2/dss/dpi.c
> +++ b/drivers/video/omap2/dss/dpi.c
> @@ -37,7 +37,10 @@
>  #include "dss_features.h"
>  
>  static struct {
> + struct platform_device *pdev;
> +
>   struct regulator *vdds_dsi_reg;
> + bool vdds_dsi_from_core;
>   struct platform_device *dsidev;
>  
>   struct mutex lock;
> @@ -583,10 +586,15 @@ static int dpi_init_display(struct omap_dss_device 
> *dssdev)
>   struct regulator *vdds_dsi;
>  
>   vdds_dsi = dss_get_vdds_dsi();
> -
>   if (IS_ERR(vdds_dsi)) {
> - DSSERR("can't get VDDS_DSI regulator\n");
> - return PTR_ERR(vdds_dsi);
> + vdds_dsi = regulator_get(&dpi.pdev->dev, "vdds_dsi");
> + if (IS_ERR(vdds_dsi)) {
> + DSSERR("can't get VDDS_DSI regulator\n");
> + return PTR_ERR(vdds_dsi);
> + }
> + dpi.vdds_dsi_from_core = false;
> + } else {
> + dpi.vdds_dsi_from_core = true;
>   }
>  
>   dpi.vdds_dsi_reg = vdds_dsi;
> @@ -702,6 +710,8 @@ static int omap_dpi_probe(struct platform_device *pdev)
>  {
>   int r;
>  
> + dpi.pdev = pdev;
> +
>   mutex_init(&dpi.lock);
>  
>   dpi_init_output(pdev);
> @@ -725,6 +735,11 @@ static int __exit omap_dpi_remove(struct platform_device 
> *pdev)
>  
>   dpi_uninit_output(pdev);
>  
> + if (dpi.vdds_dsi_reg != NULL && dpi.vdds_dsi_from_core == false) {
> + regulator_put(dpi.vdds_dsi_reg);
> + dpi.vdds_dsi_reg = NULL;
> + }
> +
>   return 0;
>  }
>  
> -- 
> 1.8.1.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 06/32] OMAPDSS: DPI: fix regulators for DT

2013-05-30 Thread Tomi Valkeinen
On 30/05/13 14:12, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 12:34 Thu 30 May , Tomi Valkeinen wrote:
>> On some platforms DPI requires a regulator to be enabled to power up the
>> output pins. This regulator is, for some reason, currently attached to
>> the virtual omapdss device, instead of the DPI device. This does not
>> work for DT, as the regulator mappings need to be described in the DT
>> data, and the virtual omapdss device is not present there.
>>
>> Fix the issue by acquiring the regulator in the DPI device. To retain
>> compatibility with the current board files, the old method of getting
>> the regulator is kept. The old method can be removed when the board
>> files have been changed to pass the regulator to DPI.
> 
> as discuss with Arnd we should handle regular enable and disable at device
> probe for every device as we do for pinctrl

I'm not sure what you mean. Enable of what? The regulator? Why would we
enable it in the device's probe, as the device may never even be used?

Or do you mean regulator_get()? Doing that in DPI driver's probe is
problematic, as not all boards have any panels using DPI, and thus they
may not have the regulator set up, but all boards have the DPI device
added automatically. So for those boards the DPI probe would fail,
always, if we tried to get the regulator.

 Tomi




signature.asc
Description: OpenPGP digital signature


Re: [PATCH 03/32] OMAPDSS: add omap_dss_find_output()

2013-05-30 Thread Tomi Valkeinen
On 30/05/13 14:07, Jean-Christophe PLAGNIOL-VILLARD wrote:
> On 12:34 Thu 30 May , Tomi Valkeinen wrote:
>> Add a support function to find a DSS output by given name. This is used
>> in later patches to link the panels to DSS outputs.
>>
>> Signed-off-by: Tomi Valkeinen 
>> ---
>>  drivers/video/omap2/dss/output.c | 13 +
>>  include/video/omapdss.h  |  1 +
>>  2 files changed, 14 insertions(+)
>>
>> diff --git a/drivers/video/omap2/dss/output.c 
>> b/drivers/video/omap2/dss/output.c
>> index 5214df6..3274628 100644
>> --- a/drivers/video/omap2/dss/output.c
>> +++ b/drivers/video/omap2/dss/output.c
>> @@ -115,6 +115,19 @@ struct omap_dss_output *omap_dss_get_output(enum 
>> omap_dss_output_id id)
>>  }
>>  EXPORT_SYMBOL(omap_dss_get_output);
> GPL please

The omapdss driver uses EXPORT_SYMBOL. I don't want to start mixing both
EXPORT_SYMBOLs and EXPORT_SYMBOL_GPLs.

>> +struct omap_dss_output *omap_dss_find_output(const char *name)
>> +{
>> +struct omap_dss_output *out;
>> +
>> +list_for_each_entry(out, &output_list, list) {
>> +if (strcmp(out->name, name) == 0)
>> +return out;
>> +}
>> +
>> +return NULL;
>> +}
> I this in so many drivers could we have a macro to generate such function?

What would that help? Wouldn't it just increase the code size of the kernel?

 Tomi




signature.asc
Description: OpenPGP digital signature


Re: [PATCH v2 11/14] Documentation: dt: binding: omap: am43x timer

2013-05-30 Thread Benoit Cousson
Hi Stephen,

On 05/29/2013 05:27 PM, Stephen Warren wrote:
> On 05/29/2013 02:39 AM, Benoit Cousson wrote:
>> Hi Afzal,
>>
>> On 05/29/2013 10:06 AM, Mohammed, Afzal wrote:
>>> Hi Jon,
>>>
>>> On Wed, May 29, 2013 at 03:35:10, Stephen Warren wrote:
 On 05/28/2013 03:25 PM, Jon Hunter wrote:
>>>
>>  ti,am335x-timer (applicable to AM335x devices)
>>  ti,am335x-timer-1ms (applicable to AM335x 
>> devices)
>> +"ti,am4372-timer-1ms", "ti,am335x-timer-1ms" 
>> for AM43x 1ms timer
>> +"ti,am4372-timer", "ti,am335x-timer" for AM43x 
>> timers other than 1ms one
>>>
> If you are adding more compatibility strings, then this implies that the
> AM43x timers are not 100% compatible with any other device listed (such
> as am335x or any omap device). That's fine but you should state that in
> the changelog. If the AM43x timer registers are 100% compatible with
> existing devices you should not add these.

 I'm not sure that's true; .dts files should always include a compatible
 value that describes the most specific model of the HW, plus any
 baseline compatible value that the HW is compatible with. This allows
 any required quirks/fixes/... to be applied for the specific HW model
 later even if nobody knows right now they'll be needed. Hence, defining
 new compatible values doesn't necessarily mean incompatible HW.
>>>
>>> Stephen took words out of my finger ;)
>>>  
>>> Some explanations,I don;t 
>>>
>>> 1. first compatible should be exact device [A], followed by compatible
>>> model (if one)
>>> 2. Minor effort in getting DT right the first time may help prevent
>>> difficult effort later modifying it (if a necessity comes), considering
>>> the fact that DT sources has  to move out of Kernel at some point of
>>> time. And DT is not supposed to be modified, which may cause difficulty
>>> for the users (I had been a minor victim of this during rebase).
>>>
>>> As we both were in GPMC land earlier, an example,
>>>
>>> If my memory is right, GPMC IP in am335x is rev 6, and IP has 8 chip
>>> select, but one is not pinned out. Now assume that same IP is integrated
>>> in another SoC (probably OMAP4 has rev 6). Here if we use same compatible
>>> for both, driver cannot handle it properly (w/o knowledge about platform).
>>> But if exact compatible is mentioned, without modifying DT (which should
>>> be considered as a firmware) just by modifying Kernel, deciding based on
>>> compatible would help achieve what is required.
>>
>> That's true for the DTS itself, but here your are changing the binding
>> documentation which is supposed to reflect the driver "interface" in the
>> Device Tree model description.
>>
>> Since the driver does not support any new compatible string, you should
>> not update the binding.
> 
> I don't agree here; the DT binding should define all the required and/or
> allowed values that must/should/can be present in the DT - the entire
> legal schema. The set of all compatible values is included in that,
> irrespective of whether a particular value actually (currently) defines
> a different HW interface or not.

Well, I tend to agree on the principle, but so far it was never really
done like that. That's not necessarily a good excuse, but if we start
adding new bindings for the huge number of OMAP|AM variants TI has been
introduced for 10 years, I'd rather use a wildcard than a exhaustive
list of all the devices.
Something like ti,[omap|am]*-timer for example .

Regards,
Benoit

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


Re: [PATCH 05/32] OMAPDSS: fix dss_get_ctx_loss_count for DT

2013-05-30 Thread Jean-Christophe PLAGNIOL-VILLARD
On 12:34 Thu 30 May , Tomi Valkeinen wrote:
> When using DT, dss device does not have platform data. However,
> dss_get_ctx_loss_count() uses dss device's platform data to find the
> get_ctx_loss_count function pointer.
> 
> To fix this, dss_get_ctx_loss_count() needs to be changed to get the
> platform data from the omapdss device, which is a "virtual" device and
> always has platform data.
> 
> Signed-off-by: Tomi Valkeinen 
> ---
>  drivers/video/omap2/dss/dss.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/video/omap2/dss/dss.c b/drivers/video/omap2/dss/dss.c
> index 94f66f9..bd01608 100644
> --- a/drivers/video/omap2/dss/dss.c
> +++ b/drivers/video/omap2/dss/dss.c
> @@ -157,7 +157,8 @@ static void dss_restore_context(void)
>  
>  int dss_get_ctx_loss_count(void)
>  {
> - struct omap_dss_board_info *board_data = dss.pdev->dev.platform_data;
> + struct platform_device *core_pdev = dss_get_core_pdev();
> + struct omap_dss_board_info *board_data = core_pdev->dev.platform_data;

how about store the pdata in the drivers internal struct and if !dt
you ust do this

dss_dev->pdata = *pdev->dev.platform_data;

to copy it and we do not alloc it for dt

Best Regards,
J.
>   int cnt;
>  
>   if (!board_data->get_context_loss_count)
> -- 
> 1.8.1.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 06/32] OMAPDSS: DPI: fix regulators for DT

2013-05-30 Thread Arnd Bergmann
On Thursday 30 May 2013, Tomi Valkeinen wrote:
>   On 30/05/13 14:12, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 12:34 Thu 30 May , Tomi Valkeinen wrote:
> >> On some platforms DPI requires a regulator to be enabled to power up the
> >> output pins. This regulator is, for some reason, currently attached to
> >> the virtual omapdss device, instead of the DPI device. This does not
> >> work for DT, as the regulator mappings need to be described in the DT
> >> data, and the virtual omapdss device is not present there.
> >>
> >> Fix the issue by acquiring the regulator in the DPI device. To retain
> >> compatibility with the current board files, the old method of getting
> >> the regulator is kept. The old method can be removed when the board
> >> files have been changed to pass the regulator to DPI.
> > 
> > as discuss with Arnd we should handle regular enable and disable at device
> > probe for every device as we do for pinctrl
> 
> I'm not sure what you mean. Enable of what? The regulator? Why would we
> enable it in the device's probe, as the device may never even be used?

It's an idea I had a while ago, but not yet discussed in the open.

Jean-Christophe just posted patches to move the mapping of interrupt numbers
into platform_drv_probe(), just before calling the driver ->probe() callback,
and we already have similar code to set up the default pinctrl state of
a device before calling probe().

This can be extended to further subsystems, but that has to be done
carefully to avoid regressions. Ideally we would move a lot of boilerplate
code out of the driver specific ->probe() function into common code.
Possible candidates for this include:

* calling devm_request_mem_region for the "reg" property
* calling devm_ioremap on the "reg" property"
* calling devm_gpio_request for all gpio lines
* calling devm_regulator_get on all regulators
* calling devm_reset_control_get on all reset lines
* calling devm_dma_request_slave_channel on all dma channels
* calling devm_of_pwm_get for all pwm channels
* ...

For most of these (maybe all), I think we need some form of opt-in
model on the driver side because there are cases where aquiring some
of these resources is not mandatory, and it only works if the driver
is using DT probing.

IF we want to do this, it also needs a lot of thought, and we shouldn't
do it carelessly. We might also need some extra infrastructure in revres
to simplify access to the resources we got from the OF node.

The irq resources are particularly trivial because we already claim
them in of_platform_populate, so moving that to platform_drv_probe()
is straightforward and solves existing bugs without creating a huge
regression potential, but it's harder for the others.

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


Re: [PATCH 1/1] i2c: omap: correct usage of the interrupt enable register

2013-05-30 Thread Kevin Hilman
Oleksandr Dmytryshyn  writes:

> On 05/29/2013 08:22 PM, Kevin Hilman wrote:
>> Oleksandr Dmytryshyn  writes:
>>
>>> Starting from the OMAP chips with version2 registers scheme there are
>>> 2 registers (I2C_IRQENABLE_SET and I2C_IRQENABLE_CLR) to manage
>>> interrupts instead of the older OMAP chips with old scheme which have
>>> only one register (I2C_IE).  Now we should use I2C_IRQENABLE_SET
>>> register for enabling interrupts and I2C_IRQENABLE_CLR register for
>>> disabling interrupts.
>> Why?  (changelogs should always answer the "why" question)
>>
>> IOW, what is broken without this change, how does it fail?  And equally
>> important, how is it currently working?
>>
>> Kevin
>>
>>
> Hi, Kevin.
>
> If the i2c controller during suspend will generate an interrupt, it
> can lead to unpredictable behaviour in the kernel.
>
> Based on the logic of the kernel code interrupts from i2c should be
> prohibited during suspend. Kernel writes 0 to the I2C_IE register in
> the omap_i2c_runtime_suspend() function. In the other side kernel
> writes saved interrupt flags to the I2C_IE register in
> omap_i2c_runtime_resume() function. I.e. interrupts should be disabled
> during suspend.
>
> This works for chips with version1 registers scheme. Interrupts are
> disabled during suspend. For chips with version2 scheme registers
> writting 0 to the I2C_IE register does nothing (because now the
> I2C_IRQENABLE_SET register is located at this address ). This register
> is used to enable interrupts. For disabling interrupts
> I2C_IRQENABLE_CLR register should be used.
>
> I've checked that interrupts in the i2c controller are still enabled
> after writting 0 to the I2C_IE register. But with my patch interrupts
> are disabled in the omap_i2c_runtime_suspend() function.

Yes, I understand why your patch works, and it looks correct to me.  

My main concern is that the changelog is missing a detailed description
of the problem that is being solved, as well as a summary of why this
has ever worked.  I guess we've just been lucky and not seen interrupts
during suspend?

Kevin
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" 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 1/3] gpio/omap: replace open coded read-modify-write with _gpio_rmw function.

2013-05-30 Thread Kevin Hilman
Andreas Fenkart  writes:

> By also making it return the modified value, we save the readl
> needed to update the context.
>
> Signed-off-by: Andreas Fenkart 

Great cleanups,   Thanks!

Some minor comments below...

Also, it would be nice to see a cover letter for this series describing
how it was tested, on what platforms, did it include PM testing
(off-mode, etc.).

[...]

> @@ -94,20 +107,10 @@ static int irq_to_gpio(struct gpio_bank *bank, unsigned 
> int gpio_irq)
>  
>  static void _set_gpio_direction(struct gpio_bank *bank, int gpio, int 
> is_input)
>  {
> - void __iomem *reg = bank->base;
> - u32 l;
> -
> - reg += bank->regs->direction;
> - l = __raw_readl(reg);
> - if (is_input)
> - l |= 1 << gpio;
> - else
> - l &= ~(1 << gpio);
> - __raw_writel(l, reg);
> - bank->context.oe = l;
> + bank->context.oe = _gpio_rmw(bank->base, bank->regs->direction, 1 <<
> +  gpio, is_input);

wrapping is funny here, IMO the "1 <<" should be on the next line along
with "gpio".

[...]

> @@ -450,19 +428,16 @@ static int gpio_irq_type(struct irq_data *d, unsigned 
> type)
>  
>  static void _clear_gpio_irqbank(struct gpio_bank *bank, int gpio_mask)
>  {
> - void __iomem *reg = bank->base;
> + void __iomem *base = bank->base;
>  
> - reg += bank->regs->irqstatus;
> - __raw_writel(gpio_mask, reg);
> + __raw_writel(gpio_mask, base + bank->regs->irqstatus);
>  
>   /* Workaround for clearing DSP GPIO interrupts to allow retention */
> - if (bank->regs->irqstatus2) {
> - reg = bank->base + bank->regs->irqstatus2;
> - __raw_writel(gpio_mask, reg);
> - }
> + if (bank->regs->irqstatus2)
> + __raw_writel(gpio_mask, base + bank->regs->irqstatus2);
>  
>   /* Flush posted write for the irq status to avoid spurious interrupts */
> - __raw_readl(reg);
> + __raw_readl(base + bank->regs->irqstatus);

All of the changes in this function are not related to the change
described in the changelog.  Either make a separate patch, or add a
description of this cleanup to the changelog too.

Thanks,

Kevin

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


Re: [PATCH 03/32] OMAPDSS: add omap_dss_find_output()

2013-05-30 Thread Jean-Christophe PLAGNIOL-VILLARD
On 12:34 Thu 30 May , Tomi Valkeinen wrote:
> Add a support function to find a DSS output by given name. This is used
> in later patches to link the panels to DSS outputs.
> 
> Signed-off-by: Tomi Valkeinen 
> ---
>  drivers/video/omap2/dss/output.c | 13 +
>  include/video/omapdss.h  |  1 +
>  2 files changed, 14 insertions(+)
> 
> diff --git a/drivers/video/omap2/dss/output.c 
> b/drivers/video/omap2/dss/output.c
> index 5214df6..3274628 100644
> --- a/drivers/video/omap2/dss/output.c
> +++ b/drivers/video/omap2/dss/output.c
> @@ -115,6 +115,19 @@ struct omap_dss_output *omap_dss_get_output(enum 
> omap_dss_output_id id)
>  }
>  EXPORT_SYMBOL(omap_dss_get_output);
GPL please
>  
> +struct omap_dss_output *omap_dss_find_output(const char *name)
> +{
> + struct omap_dss_output *out;
> +
> + list_for_each_entry(out, &output_list, list) {
> + if (strcmp(out->name, name) == 0)
> + return out;
> + }
> +
> + return NULL;
> +}
I this in so many drivers could we have a macro to generate such function?

> +EXPORT_SYMBOL(omap_dss_find_output);
ditto GPL

Best Regards,
J.
> +
>  static const struct dss_mgr_ops *dss_mgr_ops;
>  
>  int dss_install_mgr_ops(const struct dss_mgr_ops *mgr_ops)
> diff --git a/include/video/omapdss.h b/include/video/omapdss.h
> index d5f1fff..aad47a2 100644
> --- a/include/video/omapdss.h
> +++ b/include/video/omapdss.h
> @@ -779,6 +779,7 @@ int omap_dss_get_num_overlays(void);
>  struct omap_overlay *omap_dss_get_overlay(int num);
>  
>  struct omap_dss_output *omap_dss_get_output(enum omap_dss_output_id id);
> +struct omap_dss_output *omap_dss_find_output(const char *name);
>  int omapdss_output_set_device(struct omap_dss_output *out,
>   struct omap_dss_device *dssdev);
>  int omapdss_output_unset_device(struct omap_dss_output *out);
> -- 
> 1.8.1.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] ARM: OMAP: TI816X: add powerdomains for TI816x

2013-05-30 Thread Aida Mynzhasova
This patch adds required structures for powerdomain initialization on
the ti816x. It is impossible to use omap3430 structures in order to
initialize powerdomains on ti816x, because there are big differences
between PRCM module base address offsets on these CPUs.

Signed-off-by: Aida Mynzhasova 
---
 arch/arm/mach-omap2/powerdomains3xxx_data.c |   62 +++
 arch/arm/mach-omap2/prcm-common.h   |   11 +
 2 files changed, 73 insertions(+)

diff --git a/arch/arm/mach-omap2/powerdomains3xxx_data.c 
b/arch/arm/mach-omap2/powerdomains3xxx_data.c
index f0e14e9..e2d4bd8 100644
--- a/arch/arm/mach-omap2/powerdomains3xxx_data.c
+++ b/arch/arm/mach-omap2/powerdomains3xxx_data.c
@@ -336,6 +336,54 @@ static struct powerdomain dpll5_pwrdm = {
.voltdm   = { .name = "core" },
 };
 
+static struct powerdomain device_81xx_pwrdm = {
+   .name = "device_pwrdm",
+   .prcm_offs= TI81XX_PRM_DEVICE_MOD,
+   .voltdm   = { .name = "core" },
+};
+
+static struct powerdomain active_816x_pwrdm = {
+   .name = "active_pwrdm",
+   .prcm_offs= TI816X_PRM_ACTIVE_MOD,
+   .pwrsts   = PWRSTS_OFF_ON,
+   .voltdm   = { .name = "core" },
+};
+
+static struct powerdomain default_816x_pwrdm = {
+   .name = "default_pwrdm",
+   .prcm_offs= TI81XX_PRM_DEFAULT_MOD,
+   .pwrsts   = PWRSTS_OFF_ON,
+   .voltdm   = { .name = "core" },
+};
+
+static struct powerdomain ivahd0_816x_pwrdm = {
+   .name = "ivahd0_pwrdm",
+   .prcm_offs= TI816X_PRM_IVAHD0_MOD,
+   .pwrsts   = PWRSTS_OFF_ON,
+   .voltdm   = { .name = "mpu_iva" },
+};
+
+static struct powerdomain ivahd1_816x_pwrdm = {
+   .name = "ivahd1_pwrdm",
+   .prcm_offs= TI816X_PRM_IVAHD1_MOD,
+   .pwrsts   = PWRSTS_OFF_ON,
+   .voltdm   = { .name = "mpu_iva" },
+};
+
+static struct powerdomain ivahd2_816x_pwrdm = {
+   .name = "ivahd2_pwrdm",
+   .prcm_offs= TI816X_PRM_IVAHD2_MOD,
+   .pwrsts   = PWRSTS_OFF_ON,
+   .voltdm   = { .name = "mpu_iva" },
+};
+
+static struct powerdomain sgx_816x_pwrdm = {
+   .name = "sgx_pwrdm",
+   .prcm_offs= TI816X_PRM_SGX_MOD,
+   .pwrsts   = PWRSTS_OFF_ON,
+   .voltdm   = { .name = "core" },
+};
+
 /* As powerdomains are added or removed above, this list must also be changed 
*/
 static struct powerdomain *powerdomains_omap3430_common[] __initdata = {
&wkup_omap2_pwrdm,
@@ -393,6 +441,17 @@ static struct powerdomain *powerdomains_am35x[] __initdata 
= {
NULL
 };
 
+static struct powerdomain *powerdomains_ti81xx[] __initdata = {
+   &device_81xx_pwrdm,
+   &active_816x_pwrdm,
+   &default_816x_pwrdm,
+   &ivahd0_816x_pwrdm,
+   &ivahd1_816x_pwrdm,
+   &ivahd2_816x_pwrdm,
+   &sgx_816x_pwrdm,
+   NULL
+};
+
 void __init omap3xxx_powerdomains_init(void)
 {
unsigned int rev;
@@ -406,6 +465,9 @@ void __init omap3xxx_powerdomains_init(void)
 
if (rev == AM35XX_REV_ES1_0 || rev == AM35XX_REV_ES1_1) {
pwrdm_register_pwrdms(powerdomains_am35x);
+   } else if (rev == TI8168_REV_ES1_0 || rev == TI8168_REV_ES1_1
+   || rev == TI8168_REV_ES2_0 || rev == TI8168_REV_ES2_1) {
+   pwrdm_register_pwrdms(powerdomains_ti81xx);
} else {
pwrdm_register_pwrdms(powerdomains_omap3430_common);
 
diff --git a/arch/arm/mach-omap2/prcm-common.h 
b/arch/arm/mach-omap2/prcm-common.h
index c7d355f..ff1ac4a 100644
--- a/arch/arm/mach-omap2/prcm-common.h
+++ b/arch/arm/mach-omap2/prcm-common.h
@@ -48,6 +48,17 @@
 #define OMAP3430_NEON_MOD  0xb00
 #define OMAP3430ES2_USBHOST_MOD0xc00
 
+/*
+ * TI81XX PRM module offsets
+ */
+#define TI81XX_PRM_DEVICE_MOD  0x
+#define TI816X_PRM_ACTIVE_MOD  0x0a00
+#define TI81XX_PRM_DEFAULT_MOD 0x0b00
+#define TI816X_PRM_IVAHD0_MOD  0x0c00
+#define TI816X_PRM_IVAHD1_MOD  0x0d00
+#define TI816X_PRM_IVAHD2_MOD  0x0e00
+#define TI816X_PRM_SGX_MOD 0x0f00
+
 /* 24XX register bits shared between CM & PRM registers */
 
 /* CM_FCLKEN1_CORE, CM_ICLKEN1_CORE, PM_WKEN1_CORE shared bits */
-- 
1.7.10.4

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


Re: [PATCH 1/1] i2c: omap: correct usage of the interrupt enable register

2013-05-30 Thread Oleksandr Dmytryshyn

On 05/30/2013 05:18 PM, Kevin Hilman wrote:

Oleksandr Dmytryshyn  writes:


On 05/29/2013 08:22 PM, Kevin Hilman wrote:

Oleksandr Dmytryshyn  writes:


Starting from the OMAP chips with version2 registers scheme there are
2 registers (I2C_IRQENABLE_SET and I2C_IRQENABLE_CLR) to manage
interrupts instead of the older OMAP chips with old scheme which have
only one register (I2C_IE).  Now we should use I2C_IRQENABLE_SET
register for enabling interrupts and I2C_IRQENABLE_CLR register for
disabling interrupts.

Why?  (changelogs should always answer the "why" question)

IOW, what is broken without this change, how does it fail?  And equally
important, how is it currently working?

Kevin



Hi, Kevin.

If the i2c controller during suspend will generate an interrupt, it
can lead to unpredictable behaviour in the kernel.

Based on the logic of the kernel code interrupts from i2c should be
prohibited during suspend. Kernel writes 0 to the I2C_IE register in
the omap_i2c_runtime_suspend() function. In the other side kernel
writes saved interrupt flags to the I2C_IE register in
omap_i2c_runtime_resume() function. I.e. interrupts should be disabled
during suspend.

This works for chips with version1 registers scheme. Interrupts are
disabled during suspend. For chips with version2 scheme registers
writting 0 to the I2C_IE register does nothing (because now the
I2C_IRQENABLE_SET register is located at this address ). This register
is used to enable interrupts. For disabling interrupts
I2C_IRQENABLE_CLR register should be used.

I've checked that interrupts in the i2c controller are still enabled
after writting 0 to the I2C_IE register. But with my patch interrupts
are disabled in the omap_i2c_runtime_suspend() function.

Yes, I understand why your patch works, and it looks correct to me.

My main concern is that the changelog is missing a detailed description
of the problem that is being solved, as well as a summary of why this
has ever worked.  I guess we've just been lucky and not seen interrupts
during suspend?

Kevin

Hi, Kevin.

Yes. You are right about the interrupts.

--

Best regards,
Oleksandr Dmytryshyn | OMAP4 Platform
GlobalLogic Inc. | Innovation by Design
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 03/32] OMAPDSS: add omap_dss_find_output()

2013-05-30 Thread Jean-Christophe PLAGNIOL-VILLARD
On 14:40 Thu 30 May , Tomi Valkeinen wrote:
> On 30/05/13 14:07, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 12:34 Thu 30 May , Tomi Valkeinen wrote:
> >> Add a support function to find a DSS output by given name. This is used
> >> in later patches to link the panels to DSS outputs.
> >>
> >> Signed-off-by: Tomi Valkeinen 
> >> ---
> >>  drivers/video/omap2/dss/output.c | 13 +
> >>  include/video/omapdss.h  |  1 +
> >>  2 files changed, 14 insertions(+)
> >>
> >> diff --git a/drivers/video/omap2/dss/output.c 
> >> b/drivers/video/omap2/dss/output.c
> >> index 5214df6..3274628 100644
> >> --- a/drivers/video/omap2/dss/output.c
> >> +++ b/drivers/video/omap2/dss/output.c
> >> @@ -115,6 +115,19 @@ struct omap_dss_output *omap_dss_get_output(enum 
> >> omap_dss_output_id id)
> >>  }
> >>  EXPORT_SYMBOL(omap_dss_get_output);
> > GPL please
> 
> The omapdss driver uses EXPORT_SYMBOL. I don't want to start mixing both
> EXPORT_SYMBOLs and EXPORT_SYMBOL_GPLs.

I do not like EXPORT_SYMBOL at all
I stringly prefer to switch all of them to _GPL

but will not refuse the patch for this in this case
> 
> >> +struct omap_dss_output *omap_dss_find_output(const char *name)
> >> +{
> >> +  struct omap_dss_output *out;
> >> +
> >> +  list_for_each_entry(out, &output_list, list) {
> >> +  if (strcmp(out->name, name) == 0)
> >> +  return out;
> >> +  }
> >> +
> >> +  return NULL;
> >> +}
> > I this in so many drivers could we have a macro to generate such function?
> 
> What would that help? Wouldn't it just increase the code size of the kernel?

increase no as it's not an inline function but a macro to generate the
function
after help yes but people may not like so as you wish

Best Regards,
J.
> 
>  Tomi
> 
> 


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


Re: [PATCH 05/32] OMAPDSS: fix dss_get_ctx_loss_count for DT

2013-05-30 Thread Jean-Christophe PLAGNIOL-VILLARD
On 14:28 Thu 30 May , Tomi Valkeinen wrote:
> On 30/05/13 14:09, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > On 12:34 Thu 30 May , Tomi Valkeinen wrote:
> >> When using DT, dss device does not have platform data. However,
> >> dss_get_ctx_loss_count() uses dss device's platform data to find the
> >> get_ctx_loss_count function pointer.
> >>
> >> To fix this, dss_get_ctx_loss_count() needs to be changed to get the
> >> platform data from the omapdss device, which is a "virtual" device and
> >> always has platform data.
> >>
> >> Signed-off-by: Tomi Valkeinen 
> >> ---
> >>  drivers/video/omap2/dss/dss.c | 3 ++-
> >>  1 file changed, 2 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/video/omap2/dss/dss.c b/drivers/video/omap2/dss/dss.c
> >> index 94f66f9..bd01608 100644
> >> --- a/drivers/video/omap2/dss/dss.c
> >> +++ b/drivers/video/omap2/dss/dss.c
> >> @@ -157,7 +157,8 @@ static void dss_restore_context(void)
> >>  
> >>  int dss_get_ctx_loss_count(void)
> >>  {
> >> -  struct omap_dss_board_info *board_data = dss.pdev->dev.platform_data;
> >> +  struct platform_device *core_pdev = dss_get_core_pdev();
> >> +  struct omap_dss_board_info *board_data = core_pdev->dev.platform_data;
> > 
> > how about store the pdata in the drivers internal struct and if !dt
> > you ust do this
> > 
> > dss_dev->pdata = *pdev->dev.platform_data;
> > 
> > to copy it and we do not alloc it for dt
> 
> It's not quite that simple. We need some OMAP arch functions (like
> get_ctx_loss_count here) that are not currently exposed via any other
> method to drivers except passing a function pointer with platform data.
> We need that also when booting with DT.
> 
> We have a bunch of devices for the display subsystem hardware blocks,
> like the "dss" here. When booting with DT, these blocks are represented
> in the DT data, and do not have platform data.
> 
> We also have a "virtual" device, "omapdss", which doesn't match any hw
> block. It's created in the arch setup stage. It's really a legacy thing,
> but with DT it can be used conveniently to pass the platform data.
> 
> The problem this patch fixes is that we used to pass the arch functions
> for each of those HW block drivers. But with DT, we need to get the arch
> functions from the "omapdss" device, gotten with dss_get_core_pdev().

ok

do not take it bad is it worth the effort those 54 patches?

is not better to work on DRM?
just an open question

Best Regards,
J.
> 
>  Tomi
> 
> 


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


[PATCH v2 1/1] i2c: omap: correct usage of the interrupt enable register

2013-05-30 Thread Oleksandr Dmytryshyn
If the i2c controller during suspend will generate an interrupt, it
can lead to unpredictable behaviour in the kernel.

Based on the logic of the kernel code interrupts from i2c should be
prohibited during suspend. Kernel writes 0 to the I2C_IE register in
the omap_i2c_runtime_suspend() function. In the other side kernel
writes saved interrupt flags to the I2C_IE register in
omap_i2c_runtime_resume() function. I.e. interrupts should be disabled
during suspend.

This works for chips with version1 registers scheme. Interrupts are
disabled during suspend. For chips with version2 scheme registers
writting 0 to the I2C_IE register does nothing (because now the
I2C_IRQENABLE_SET register is located at this address). This register
is used to enable interrupts. For disabling interrupts
I2C_IRQENABLE_CLR register should be used.

Because the registers I2C_IRQENABLE_SET and I2C_IE have the same
addresses, the interrupt enabling procedure is unchanged.

Signed-off-by: Oleksandr Dmytryshyn 
---
 drivers/i2c/busses/i2c-omap.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/i2c/busses/i2c-omap.c b/drivers/i2c/busses/i2c-omap.c
index e02f9e3..2419899 100644
--- a/drivers/i2c/busses/i2c-omap.c
+++ b/drivers/i2c/busses/i2c-omap.c
@@ -180,6 +180,8 @@ enum {
 #define I2C_OMAP_ERRATA_I207   (1 << 0)
 #define I2C_OMAP_ERRATA_I462   (1 << 1)
 
+#define OMAP_I2C_INTERRUPTS_MASK   0x6FFF
+
 struct omap_i2c_dev {
spinlock_t  lock;   /* IRQ synchronization */
struct device   *dev;
@@ -193,6 +195,7 @@ struct omap_i2c_dev {
long latency);
u32 speed;  /* Speed of bus in kHz */
u32 flags;
+   u16 scheme;
u16 cmd_err;
u8  *buf;
u8  *regs;
@@ -1082,7 +1085,7 @@ omap_i2c_probe(struct platform_device *pdev)
int irq;
int r;
u32 rev;
-   u16 minor, major, scheme;
+   u16 minor, major;
 
/* NOTE: driver uses the static register mapping */
mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
@@ -1159,8 +1162,8 @@ omap_i2c_probe(struct platform_device *pdev)
 */
rev = __raw_readw(dev->base + 0x04);
 
-   scheme = OMAP_I2C_SCHEME(rev);
-   switch (scheme) {
+   dev->scheme = OMAP_I2C_SCHEME(rev);
+   switch (dev->scheme) {
case OMAP_I2C_SCHEME_0:
dev->regs = (u8 *)reg_map_ip_v1;
dev->rev = omap_i2c_read_reg(dev, OMAP_I2C_REV_REG);
@@ -1289,7 +1292,11 @@ static int omap_i2c_runtime_suspend(struct device *dev)
 
_dev->iestate = omap_i2c_read_reg(_dev, OMAP_I2C_IE_REG);
 
-   omap_i2c_write_reg(_dev, OMAP_I2C_IE_REG, 0);
+   if (_dev->scheme == OMAP_I2C_SCHEME_0)
+   omap_i2c_write_reg(_dev, OMAP_I2C_IE_REG, 0);
+   else
+   omap_i2c_write_reg(_dev, OMAP_I2C_IP_V2_IRQENABLE_CLR,
+  OMAP_I2C_INTERRUPTS_MASK);
 
if (_dev->rev < OMAP_I2C_OMAP1_REV_2) {
omap_i2c_read_reg(_dev, OMAP_I2C_IV_REG); /* Read clears */
-- 
1.8.2.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-omap" 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/1] i2c: omap: correct usage of the interrupt enable register

2013-05-30 Thread Oleksandr Dmytryshyn
I've just added a detailed description of the problem that is being solved
to the cover letter and commit message in the patch.

If the i2c controller during suspend will generate an interrupt, it
can lead to unpredictable behaviour in the kernel.

Based on the logic of the kernel code interrupts from i2c should be
prohibited during suspend. Kernel writes 0 to the I2C_IE register in
the omap_i2c_runtime_suspend() function. In the other side kernel
writes saved interrupt flags to the I2C_IE register in
omap_i2c_runtime_resume() function. I.e. interrupts should be disabled
during suspend.

This works for chips with version1 registers scheme. Interrupts are
disabled during suspend. For chips with version2 scheme registers
writting 0 to the I2C_IE register does nothing (because now the
I2C_IRQENABLE_SET register is located at this address). This register
is used to enable interrupts. For disabling interrupts
I2C_IRQENABLE_CLR register should be used.

Because the registers I2C_IRQENABLE_SET and I2C_IE have the same
addresses, the interrupt enabling procedure is unchanged.

I've checked that interrupts in the i2c controller are still enabled
after writting 0 to the I2C_IE register. But with my patch interrupts
are disabled in the omap_i2c_runtime_suspend() function. 

Next patch fixes it.

Patch is based on:
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
tag: v3.10-rc2

Verified on OMAP4430.

Oleksandr Dmytryshyn (1):
  i2c: omap: correct usage of the interrupt enable register

 drivers/i2c/busses/i2c-omap.c | 15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

-- 
1.8.2.rc2

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


Re: [PATCH 06/32] OMAPDSS: DPI: fix regulators for DT

2013-05-30 Thread Jean-Christophe PLAGNIOL-VILLARD
On 15:05 Thu 30 May , Arnd Bergmann wrote:
> On Thursday 30 May 2013, Tomi Valkeinen wrote:
> >   On 30/05/13 14:12, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > > On 12:34 Thu 30 May , Tomi Valkeinen wrote:
> > >> On some platforms DPI requires a regulator to be enabled to power up the
> > >> output pins. This regulator is, for some reason, currently attached to
> > >> the virtual omapdss device, instead of the DPI device. This does not
> > >> work for DT, as the regulator mappings need to be described in the DT
> > >> data, and the virtual omapdss device is not present there.
> > >>
> > >> Fix the issue by acquiring the regulator in the DPI device. To retain
> > >> compatibility with the current board files, the old method of getting
> > >> the regulator is kept. The old method can be removed when the board
> > >> files have been changed to pass the regulator to DPI.
> > > 
> > > as discuss with Arnd we should handle regular enable and disable at device
> > > probe for every device as we do for pinctrl
> > 
> > I'm not sure what you mean. Enable of what? The regulator? Why would we
> > enable it in the device's probe, as the device may never even be used?
> 
> It's an idea I had a while ago, but not yet discussed in the open.
> 
> Jean-Christophe just posted patches to move the mapping of interrupt numbers
> into platform_drv_probe(), just before calling the driver ->probe() callback,
> and we already have similar code to set up the default pinctrl state of
> a device before calling probe().
> 
> This can be extended to further subsystems, but that has to be done
> carefully to avoid regressions. Ideally we would move a lot of boilerplate
> code out of the driver specific ->probe() function into common code.
> Possible candidates for this include:
> 
> * calling devm_request_mem_region for the "reg" property
> * calling devm_ioremap on the "reg" property"
> * calling devm_gpio_request for all gpio lines
> * calling devm_regulator_get on all regulators
> * calling devm_reset_control_get on all reset lines
> * calling devm_dma_request_slave_channel on all dma channels
> * calling devm_of_pwm_get for all pwm channels
> * ...
> 
> For most of these (maybe all), I think we need some form of opt-in
> model on the driver side because there are cases where aquiring some
> of these resources is not mandatory, and it only works if the driver
> is using DT probing.
> 
> IF we want to do this, it also needs a lot of thought, and we shouldn't
> do it carelessly. We might also need some extra infrastructure in revres
> to simplify access to the resources we got from the OF node.
> 
> The irq resources are particularly trivial because we already claim
> them in of_platform_populate, so moving that to platform_drv_probe()
> is straightforward and solves existing bugs without creating a huge
> regression potential, but it's harder for the others.

Yeah I agree with Arnd

we need to start to move this way but for DT only first and carefully

Best Regards,
J.
> 
>   Arnd
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fbdev" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


  1   2   >