public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [Patch v3 0/2] OMAP2PLUS:DSS2: use opt-clocks information from hwmod.
@ 2011-03-01  8:42 Sumit Semwal
  2011-03-01  8:42 ` [Patch v3 1/2] OMAP2PLUS:DSS2: add opt_clock_available in pdata Sumit Semwal
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sumit Semwal @ 2011-03-01  8:42 UTC (permalink / raw)
  To: tomi.valkeinen, linux-omap; +Cc: Sumit Semwal

This series uses information about opt-clocks provided by omap_hwmod framework
to select which of the non-mandatory DSS clocks are available on a given
platform.

A function pointer opt_clock_available is exported via pdata, which checks the
clock roles returned by hwmod database.
In the driver, while doing clk-get, it is checked if as per hwmod a given clock
is an opt-clock or not, and is handled accordingly.

Tested on: OMAP3430sdp

Sumit Semwal (2):
  OMAP2PLUS:DSS2: add opt_clock_available in pdata
  OMAP2PLUS:DSS2: Use opt_clock_available from pdata

changes from v2:
- made oh_core a static variable, looked up only once in omap_display_init.

changes from v1:
- made opt_clock_available a function pointer in the omap_display_platform_data
  to avoid having to copy the opt-clock role names.


 arch/arm/mach-omap2/display.c             |   22 ++++++++++++++
 arch/arm/plat-omap/include/plat/display.h |    2 +
 drivers/video/omap2/dss/dss.c             |   46 +++++++++++++++++++----------
 3 files changed, 54 insertions(+), 16 deletions(-)


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Patch v3 1/2] OMAP2PLUS:DSS2: add opt_clock_available in pdata
  2011-03-01  8:42 [Patch v3 0/2] OMAP2PLUS:DSS2: use opt-clocks information from hwmod Sumit Semwal
@ 2011-03-01  8:42 ` Sumit Semwal
  2011-03-01  8:42 ` [Patch v3 2/2] OMAP2PLUS:DSS2: Use opt_clock_available from pdata Sumit Semwal
  2011-03-01 16:26 ` [Patch v3 0/2] OMAP2PLUS:DSS2: use opt-clocks information from hwmod Tomi Valkeinen
  2 siblings, 0 replies; 4+ messages in thread
From: Sumit Semwal @ 2011-03-01  8:42 UTC (permalink / raw)
  To: tomi.valkeinen, linux-omap; +Cc: Sumit Semwal, Senthilvadivu Guruswamy

Provide a function in pdata to allow dss submodules to check if a given
clock is available on a platform as an optional clock.

Signed-off-by: Senthilvadivu Guruswamy <svadivu@ti.com>
(based on implementation from Senthil)

Signed-off-by: Sumit Semwal <sumit.semwal@ti.com>
---
 arch/arm/mach-omap2/display.c             |   22 ++++++++++++++++++++++
 arch/arm/plat-omap/include/plat/display.h |    2 ++
 2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/arch/arm/mach-omap2/display.c b/arch/arm/mach-omap2/display.c
index 5ab6a74..6b1efc5 100644
--- a/arch/arm/mach-omap2/display.c
+++ b/arch/arm/mach-omap2/display.c
@@ -42,6 +42,20 @@ static struct omap_device_pm_latency omap_dss_latency[] = {
 	},
 };
 
+/* oh_core is used for getting opt-clocks */
+static struct omap_hwmod	*oh_core;
+
+static bool opt_clock_available(const char *clk_role)
+{
+	int i;
+
+	for (i = 0; i < oh_core->opt_clks_cnt; i++) {
+		if (!strcmp(oh_core->opt_clks[i].role, clk_role))
+			return true;
+	}
+	return false;
+}
+
 int __init omap_display_init(struct omap_dss_board_info *board_data)
 {
 	int r = 0;
@@ -73,9 +87,16 @@ int __init omap_display_init(struct omap_dss_board_info *board_data)
 		oh_count = ARRAY_SIZE(oh_name) - 2;
 		/* last 2 hwmod dev in oh_name are not available for omap3 */
 
+	/* opt_clks are always associated with dss hwmod */
+	oh_core = omap_hwmod_lookup("dss_core");
+	if (!oh_core) {
+		pr_err("Could not look up dss_core.\n");
+		return -ENODEV;
+	}
 
 	pdata.board_data = board_data;
 	pdata.board_data->get_last_off_on_transaction_id = NULL;
+	pdata.opt_clock_available = opt_clock_available;
 
 	for (i = 0; i < oh_count; i++) {
 		oh = omap_hwmod_lookup(oh_name[i]);
@@ -83,6 +104,7 @@ int __init omap_display_init(struct omap_dss_board_info *board_data)
 			pr_err("Could not look up %s\n", oh_name[i]);
 			return -ENODEV;
 		}
+
 		od = omap_device_build(dev_name[i], -1, oh, &pdata,
 				sizeof(struct omap_display_platform_data),
 				omap_dss_latency,
diff --git a/arch/arm/plat-omap/include/plat/display.h b/arch/arm/plat-omap/include/plat/display.h
index 2fb057e..4101bcd 100644
--- a/arch/arm/plat-omap/include/plat/display.h
+++ b/arch/arm/plat-omap/include/plat/display.h
@@ -240,6 +240,8 @@ static inline int omap_display_init(struct omap_dss_board_info *board_data)
 struct omap_display_platform_data {
 	struct omap_dss_board_info *board_data;
 	/* TODO: Additional members to be added when PM is considered */
+
+	bool (*opt_clock_available)(const char *clk_role);
 };
 
 struct omap_video_timings {
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Patch v3 2/2] OMAP2PLUS:DSS2: Use opt_clock_available from pdata
  2011-03-01  8:42 [Patch v3 0/2] OMAP2PLUS:DSS2: use opt-clocks information from hwmod Sumit Semwal
  2011-03-01  8:42 ` [Patch v3 1/2] OMAP2PLUS:DSS2: add opt_clock_available in pdata Sumit Semwal
@ 2011-03-01  8:42 ` Sumit Semwal
  2011-03-01 16:26 ` [Patch v3 0/2] OMAP2PLUS:DSS2: use opt-clocks information from hwmod Tomi Valkeinen
  2 siblings, 0 replies; 4+ messages in thread
From: Sumit Semwal @ 2011-03-01  8:42 UTC (permalink / raw)
  To: tomi.valkeinen, linux-omap; +Cc: Sumit Semwal

hwmod databases provide information about which optional clocks are available
for a given platform. This is available via a function pointer opt_clock_enable
in pdata.

Use this information during get/enable/disable/put of clocks.

Signed-off-by: Sumit Semwal <sumit.semwal@ti.com>
---
 drivers/video/omap2/dss/dss.c |   46 ++++++++++++++++++++++++++--------------
 1 files changed, 30 insertions(+), 16 deletions(-)

diff --git a/drivers/video/omap2/dss/dss.c b/drivers/video/omap2/dss/dss.c
index 5a93e66..3d0277d 100644
--- a/drivers/video/omap2/dss/dss.c
+++ b/drivers/video/omap2/dss/dss.c
@@ -699,6 +699,7 @@ static int dss_get_clock(struct clk **clock, const char *clk_name)
 static int dss_get_clocks(void)
 {
 	int r;
+	struct omap_display_platform_data *pdata = dss.pdev->dev.platform_data;
 
 	dss.dss_ick = NULL;
 	dss.dss_fck = NULL;
@@ -714,17 +715,28 @@ static int dss_get_clocks(void)
 	if (r)
 		goto err;
 
-	r = dss_get_clock(&dss.dss_sys_clk, "sys_clk");
-	if (r)
+	if (!pdata->opt_clock_available) {
+		r = -ENODEV;
 		goto err;
+	}
 
-	r = dss_get_clock(&dss.dss_tv_fck, "tv_clk");
-	if (r)
-		goto err;
+	if (pdata->opt_clock_available("sys_clk")) {
+		r = dss_get_clock(&dss.dss_sys_clk, "sys_clk");
+		if (r)
+			goto err;
+	}
 
-	r = dss_get_clock(&dss.dss_video_fck, "video_clk");
-	if (r)
-		goto err;
+	if (pdata->opt_clock_available("tv_clk")) {
+		r = dss_get_clock(&dss.dss_tv_fck, "tv_clk");
+		if (r)
+			goto err;
+	}
+
+	if (pdata->opt_clock_available("video_clk")) {
+		r = dss_get_clock(&dss.dss_video_fck, "video_clk");
+		if (r)
+			goto err;
+	}
 
 	return 0;
 
@@ -747,9 +759,11 @@ static void dss_put_clocks(void)
 {
 	if (dss.dss_video_fck)
 		clk_put(dss.dss_video_fck);
-	clk_put(dss.dss_tv_fck);
+	if (dss.dss_tv_fck)
+		clk_put(dss.dss_tv_fck);
+	if (dss.dss_sys_clk)
+		clk_put(dss.dss_sys_clk);
 	clk_put(dss.dss_fck);
-	clk_put(dss.dss_sys_clk);
 	clk_put(dss.dss_ick);
 }
 
@@ -798,11 +812,11 @@ static void dss_clk_enable_no_ctx(enum dss_clock clks)
 		clk_enable(dss.dss_ick);
 	if (clks & DSS_CLK_FCK)
 		clk_enable(dss.dss_fck);
-	if (clks & DSS_CLK_SYSCK)
+	if ((clks & DSS_CLK_SYSCK) && dss.dss_sys_clk)
 		clk_enable(dss.dss_sys_clk);
-	if (clks & DSS_CLK_TVFCK)
+	if ((clks & DSS_CLK_TVFCK) && dss.dss_tv_fck)
 		clk_enable(dss.dss_tv_fck);
-	if (clks & DSS_CLK_VIDFCK)
+	if ((clks & DSS_CLK_VIDFCK) && dss.dss_video_fck)
 		clk_enable(dss.dss_video_fck);
 
 	dss.num_clks_enabled += num_clks;
@@ -826,11 +840,11 @@ static void dss_clk_disable_no_ctx(enum dss_clock clks)
 		clk_disable(dss.dss_ick);
 	if (clks & DSS_CLK_FCK)
 		clk_disable(dss.dss_fck);
-	if (clks & DSS_CLK_SYSCK)
+	if ((clks & DSS_CLK_SYSCK) && dss.dss_sys_clk)
 		clk_disable(dss.dss_sys_clk);
-	if (clks & DSS_CLK_TVFCK)
+	if ((clks & DSS_CLK_TVFCK) && dss.dss_tv_fck)
 		clk_disable(dss.dss_tv_fck);
-	if (clks & DSS_CLK_VIDFCK)
+	if ((clks & DSS_CLK_VIDFCK) && dss.dss_video_fck)
 		clk_disable(dss.dss_video_fck);
 
 	dss.num_clks_enabled -= num_clks;
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Patch v3 0/2] OMAP2PLUS:DSS2: use opt-clocks information from hwmod.
  2011-03-01  8:42 [Patch v3 0/2] OMAP2PLUS:DSS2: use opt-clocks information from hwmod Sumit Semwal
  2011-03-01  8:42 ` [Patch v3 1/2] OMAP2PLUS:DSS2: add opt_clock_available in pdata Sumit Semwal
  2011-03-01  8:42 ` [Patch v3 2/2] OMAP2PLUS:DSS2: Use opt_clock_available from pdata Sumit Semwal
@ 2011-03-01 16:26 ` Tomi Valkeinen
  2 siblings, 0 replies; 4+ messages in thread
From: Tomi Valkeinen @ 2011-03-01 16:26 UTC (permalink / raw)
  To: Semwal, Sumit; +Cc: linux-omap@vger.kernel.org

On Tue, 2011-03-01 at 02:42 -0600, Semwal, Sumit wrote:
> This series uses information about opt-clocks provided by omap_hwmod framework
> to select which of the non-mandatory DSS clocks are available on a given
> platform.
> 
> A function pointer opt_clock_available is exported via pdata, which checks the
> clock roles returned by hwmod database.
> In the driver, while doing clk-get, it is checked if as per hwmod a given clock
> is an opt-clock or not, and is handled accordingly.
> 
> Tested on: OMAP3430sdp
> 
> Sumit Semwal (2):
>   OMAP2PLUS:DSS2: add opt_clock_available in pdata
>   OMAP2PLUS:DSS2: Use opt_clock_available from pdata

I think this set looks fine now. Applying.

 Tomi



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-03-01 16:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-01  8:42 [Patch v3 0/2] OMAP2PLUS:DSS2: use opt-clocks information from hwmod Sumit Semwal
2011-03-01  8:42 ` [Patch v3 1/2] OMAP2PLUS:DSS2: add opt_clock_available in pdata Sumit Semwal
2011-03-01  8:42 ` [Patch v3 2/2] OMAP2PLUS:DSS2: Use opt_clock_available from pdata Sumit Semwal
2011-03-01 16:26 ` [Patch v3 0/2] OMAP2PLUS:DSS2: use opt-clocks information from hwmod Tomi Valkeinen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox