Skip to contentSkip to conversation

OMAP2PLUS:DSS2: use opt-clocks information from hwmod.

PATCH In review Sumit Semwal 2 participants 4 messages Mar 1, 2011

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v3 cover OMAP2PLUS:DSS2: use opt-clocks information from hwmod.

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(-)
#1 lore raw

PATCH v3 1/2 OMAP2PLUS:DSS2: add opt_clock_available in pdata

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

(based on implementation from Senthil)

---
 arch/arm/mach-omap2/display.c             |   22 ++++++++++++++++++++++
 arch/arm/plat-omap/include/plat/display.h |    2 ++
 2 files changed, 24 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/display.c +22 -0
index 5ab6a74..6b1efc5 100644
@@ -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,
arch/arm/plat-omap/include/plat/display.h +2 -0
index 2fb057e..4101bcd 100644
@@ -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 {
Signature · 1 line
1.7.1
#2 lore raw

PATCH v3 2/2 OMAP2PLUS:DSS2: Use opt_clock_available from pdata

In reply to 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.

---
 drivers/video/omap2/dss/dss.c |   46 ++++++++++++++++++++++++++--------------
 1 files changed, 30 insertions(+), 16 deletions(-)
drivers/video/omap2/dss/dss.c +30 -16
index 5a93e66..3d0277d 100644
@@ -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;
Signature · 1 line
1.7.1
#3 lore raw
In reply to Sumit Semwal
Quoted 9 lines · Sumit

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.

Quoted 5 lines

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