* [Patch 0/2] OMAP2PLUS:DSS2: use opt-clocks information from hwmod.
@ 2011-02-25 8:27 Sumit Semwal
2011-02-25 8:27 ` [Patch 1/2] OMAP2PLUS: DSS2: Add dss_opt_clk_roles in pdata Sumit Semwal
2011-02-25 8:27 ` [Patch 2/2] OMAP2PLUS: DSS2: Use opt-clocks from hwmod Sumit Semwal
0 siblings, 2 replies; 6+ messages in thread
From: Sumit Semwal @ 2011-02-25 8:27 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.
The clock roles returned by hwmod database are added to pdata, and 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, panda(OMAP4430)
Sumit Semwal (2):
OMAP2PLUS: DSS2: Add dss_opt_clk_roles in pdata
OMAP2PLUS: DSS2: Use opt-clocks from hwmod
arch/arm/mach-omap2/display.c | 41 +++++++++++++++++++++-
arch/arm/plat-omap/include/plat/display.h | 3 +-
drivers/video/omap2/dss/dss.c | 54 ++++++++++++++++++++---------
3 files changed, 79 insertions(+), 19 deletions(-)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [Patch 1/2] OMAP2PLUS: DSS2: Add dss_opt_clk_roles in pdata
2011-02-25 8:27 [Patch 0/2] OMAP2PLUS:DSS2: use opt-clocks information from hwmod Sumit Semwal
@ 2011-02-25 8:27 ` Sumit Semwal
2011-02-28 9:10 ` Tomi Valkeinen
2011-02-25 8:27 ` [Patch 2/2] OMAP2PLUS: DSS2: Use opt-clocks from hwmod Sumit Semwal
1 sibling, 1 reply; 6+ messages in thread
From: Sumit Semwal @ 2011-02-25 8:27 UTC (permalink / raw)
To: tomi.valkeinen, linux-omap; +Cc: Sumit Semwal, Senthilvadivu Guruswamy
Provide dss_opt_clks roles in pdata, so that it can be retrieved
in dss driver, thus avoiding the hardcoding of clock role names.
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 | 41 ++++++++++++++++++++++++++++-
arch/arm/plat-omap/include/plat/display.h | 3 +-
2 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/arch/arm/mach-omap2/display.c b/arch/arm/mach-omap2/display.c
index cc7b4f3..f189c07 100644
--- a/arch/arm/mach-omap2/display.c
+++ b/arch/arm/mach-omap2/display.c
@@ -21,6 +21,7 @@
#include <linux/io.h>
#include <linux/clk.h>
#include <linux/err.h>
+#include <linux/slab.h>
#include <plat/display.h>
#include <plat/omap_hwmod.h>
@@ -48,6 +49,7 @@ int __init omap_display_init(struct omap_dss_board_info
int r = 0;
struct omap_hwmod *oh;
struct omap_device *od;
+ struct omap_hwmod_opt_clk *oc = NULL;
int i;
struct omap_display_platform_data pdata;
@@ -61,7 +63,7 @@ int __init omap_display_init(struct omap_dss_board_info
"dss_dsi2", "dss_hdmi"};
char *dev_name[] = {"omap_dss", "omap_dispc", "omap_rfbi", "omap_venc", "omap_dsi1",
"omap_dsi2", "omap_hdmi"};
- int oh_count;
+ int oh_count, oc_count;
memset(&pdata, 0, sizeof(pdata));
@@ -74,7 +76,44 @@ int __init omap_display_init(struct omap_dss_board_info
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 = omap_hwmod_lookup("dss_core");
+ if (!oh) {
+ pr_err("Could not look up %s\n", oh_name[0]);
+ return -ENODEV;
+ }
+ oc = oh->opt_clks;
+ oc_count = oh->opt_clks_cnt;
+
+ /* copy roles of opt_clocks available from hwmod into pdata */
+ pdata.dss_opt_clk_roles = kzalloc(sizeof(char *) * oc_count,
+ GFP_KERNEL);
+ if (!pdata.dss_opt_clk_roles) {
+ pr_err("could not allocate memory for dss_opt_clk_roles\n");
+ return -ENOMEM;
+ }
+
+ for (i = 0; i < oc_count; i++) {
+ int oc_length = strlen(oc[i].role);
+
+ pdata.dss_opt_clk_roles[i] = kzalloc(oc_length + 1,
+ GFP_KERNEL);
+ if (!pdata.dss_opt_clk_roles[i]) {
+ int j = i - 1;
+
+ pr_err("kzalloc failed for dss_opt_clk[%i]\n", i);
+ for (; j >= 0; j--)
+ kfree(pdata.dss_opt_clk_roles[j]);
+
+ kfree(pdata.dss_opt_clk_roles);
+
+ return -ENOMEM;
+ }
+
+ strncpy(pdata.dss_opt_clk_roles[i], oc[i].role, oc_length+1);
+ }
+ pdata.dss_opt_clks_count = oc_count;
pdata.board_data = board_data;
pdata.board_data->get_last_off_on_transaction_id = NULL;
diff --git a/arch/arm/plat-omap/include/plat/display.h b/arch/arm/plat-omap/include/plat/display.h
index 2fb057e..5f5fc0d 100644
--- a/arch/arm/plat-omap/include/plat/display.h
+++ b/arch/arm/plat-omap/include/plat/display.h
@@ -239,7 +239,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 */
+ char **dss_opt_clk_roles;
+ int dss_opt_clks_count;
};
struct omap_video_timings {
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [Patch 2/2] OMAP2PLUS: DSS2: Use opt-clocks from hwmod
2011-02-25 8:27 [Patch 0/2] OMAP2PLUS:DSS2: use opt-clocks information from hwmod Sumit Semwal
2011-02-25 8:27 ` [Patch 1/2] OMAP2PLUS: DSS2: Add dss_opt_clk_roles in pdata Sumit Semwal
@ 2011-02-25 8:27 ` Sumit Semwal
1 sibling, 0 replies; 6+ messages in thread
From: Sumit Semwal @ 2011-02-25 8:27 UTC (permalink / raw)
To: tomi.valkeinen, linux-omap; +Cc: Sumit Semwal
hwmod databases provide information on which optional clocks are available for
a given platform. 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 | 54 ++++++++++++++++++++++++++++-------------
1 files changed, 37 insertions(+), 17 deletions(-)
diff --git a/drivers/video/omap2/dss/dss.c b/drivers/video/omap2/dss/dss.c
index 921ff91..9a85f9d 100644
--- a/drivers/video/omap2/dss/dss.c
+++ b/drivers/video/omap2/dss/dss.c
@@ -706,6 +706,18 @@ static int dss_get_clock(struct clk **clock, const char *clk_name)
return 0;
}
+static inline bool opt_clock_available(const char *clk_role)
+{
+ int i;
+ struct omap_display_platform_data *pdata = dss.pdev->dev.platform_data;
+
+ for (i = 0; i < pdata->dss_opt_clks_count; i++) {
+ if (strcmp(pdata->dss_opt_clk_roles[i], clk_role) == 0)
+ return true;
+ }
+ return false;
+}
+
static int dss_get_clocks(void)
{
int r;
@@ -724,17 +736,23 @@ static int dss_get_clocks(void)
if (r)
goto err;
- r = dss_get_clock(&dss.dss_sys_clk, "sys_clk");
- if (r)
- goto err;
+ if (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_tv_fck, "tv_clk");
- if (r)
- goto err;
+ if (opt_clock_available("tv_clk")) {
+ r = dss_get_clock(&dss.dss_tv_fck, "tv_clk");
+ if (r)
+ goto err;
+ }
- r = dss_get_clock(&dss.dss_video_fck, "video_clk");
- if (r)
- goto err;
+ if (opt_clock_available("video_clk")) {
+ r = dss_get_clock(&dss.dss_video_fck, "video_clk");
+ if (r)
+ goto err;
+ }
return 0;
@@ -757,9 +775,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);
}
@@ -808,11 +828,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;
@@ -836,11 +856,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] 6+ messages in thread
* Re: [Patch 1/2] OMAP2PLUS: DSS2: Add dss_opt_clk_roles in pdata
2011-02-25 8:27 ` [Patch 1/2] OMAP2PLUS: DSS2: Add dss_opt_clk_roles in pdata Sumit Semwal
@ 2011-02-28 9:10 ` Tomi Valkeinen
2011-02-28 9:17 ` Semwal, Sumit
0 siblings, 1 reply; 6+ messages in thread
From: Tomi Valkeinen @ 2011-02-28 9:10 UTC (permalink / raw)
To: Semwal, Sumit; +Cc: linux-omap@vger.kernel.org, Guruswamy, Senthilvadivu
On Fri, 2011-02-25 at 02:27 -0600, Semwal, Sumit wrote:
> Provide dss_opt_clks roles in pdata, so that it can be retrieved
> in dss driver, thus avoiding the hardcoding of clock role names.
>
> 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 | 41 ++++++++++++++++++++++++++++-
> arch/arm/plat-omap/include/plat/display.h | 3 +-
> 2 files changed, 42 insertions(+), 2 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/display.c b/arch/arm/mach-omap2/display.c
> index cc7b4f3..f189c07 100644
> --- a/arch/arm/mach-omap2/display.c
> +++ b/arch/arm/mach-omap2/display.c
> @@ -21,6 +21,7 @@
> #include <linux/io.h>
> #include <linux/clk.h>
> #include <linux/err.h>
> +#include <linux/slab.h>
>
> #include <plat/display.h>
> #include <plat/omap_hwmod.h>
> @@ -48,6 +49,7 @@ int __init omap_display_init(struct omap_dss_board_info
> int r = 0;
> struct omap_hwmod *oh;
> struct omap_device *od;
> + struct omap_hwmod_opt_clk *oc = NULL;
> int i;
> struct omap_display_platform_data pdata;
>
> @@ -61,7 +63,7 @@ int __init omap_display_init(struct omap_dss_board_info
> "dss_dsi2", "dss_hdmi"};
> char *dev_name[] = {"omap_dss", "omap_dispc", "omap_rfbi", "omap_venc", "omap_dsi1",
> "omap_dsi2", "omap_hdmi"};
> - int oh_count;
> + int oh_count, oc_count;
>
> memset(&pdata, 0, sizeof(pdata));
>
> @@ -74,7 +76,44 @@ int __init omap_display_init(struct omap_dss_board_info
> 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 = omap_hwmod_lookup("dss_core");
> + if (!oh) {
> + pr_err("Could not look up %s\n", oh_name[0]);
> + return -ENODEV;
> + }
> + oc = oh->opt_clks;
> + oc_count = oh->opt_clks_cnt;
> +
> + /* copy roles of opt_clocks available from hwmod into pdata */
> + pdata.dss_opt_clk_roles = kzalloc(sizeof(char *) * oc_count,
> + GFP_KERNEL);
> + if (!pdata.dss_opt_clk_roles) {
> + pr_err("could not allocate memory for dss_opt_clk_roles\n");
> + return -ENOMEM;
> + }
> +
> + for (i = 0; i < oc_count; i++) {
> + int oc_length = strlen(oc[i].role);
> +
> + pdata.dss_opt_clk_roles[i] = kzalloc(oc_length + 1,
> + GFP_KERNEL);
> + if (!pdata.dss_opt_clk_roles[i]) {
> + int j = i - 1;
> +
> + pr_err("kzalloc failed for dss_opt_clk[%i]\n", i);
> + for (; j >= 0; j--)
> + kfree(pdata.dss_opt_clk_roles[j]);
> +
> + kfree(pdata.dss_opt_clk_roles);
> +
> + return -ENOMEM;
> + }
> +
> + strncpy(pdata.dss_opt_clk_roles[i], oc[i].role, oc_length+1);
> + }
Do you actually need to copy the role strings? Can they every change? If
they are const data, you could just point to the original strings.
And is there even need to create clk_roles array. If I'm not mistaken,
the only use for this data is for the opt_clock_available() function. We
could just have an opt_clock_available() function pointer in the
omap_display_platform_data, and the function itself would be in
display.c. And the function could use the original hwmod data.
Tomi
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch 1/2] OMAP2PLUS: DSS2: Add dss_opt_clk_roles in pdata
2011-02-28 9:10 ` Tomi Valkeinen
@ 2011-02-28 9:17 ` Semwal, Sumit
2011-02-28 9:23 ` Tomi Valkeinen
0 siblings, 1 reply; 6+ messages in thread
From: Semwal, Sumit @ 2011-02-28 9:17 UTC (permalink / raw)
To: Tomi Valkeinen; +Cc: linux-omap@vger.kernel.org, Guruswamy, Senthilvadivu
Hi Tomi,
On Mon, Feb 28, 2011 at 2:40 PM, Tomi Valkeinen <tomi.valkeinen@ti.com> wrote:
<snip>
>> + oc = oh->opt_clks;
>> + oc_count = oh->opt_clks_cnt;
>> +
>> + /* copy roles of opt_clocks available from hwmod into pdata */
>> + pdata.dss_opt_clk_roles = kzalloc(sizeof(char *) * oc_count,
>> + GFP_KERNEL);
>> + if (!pdata.dss_opt_clk_roles) {
>> + pr_err("could not allocate memory for dss_opt_clk_roles\n");
>> + return -ENOMEM;
>> + }
>> +
>> + for (i = 0; i < oc_count; i++) {
>> + int oc_length = strlen(oc[i].role);
>> +
>> + pdata.dss_opt_clk_roles[i] = kzalloc(oc_length + 1,
>> + GFP_KERNEL);
>> + if (!pdata.dss_opt_clk_roles[i]) {
>> + int j = i - 1;
>> +
>> + pr_err("kzalloc failed for dss_opt_clk[%i]\n", i);
>> + for (; j >= 0; j--)
>> + kfree(pdata.dss_opt_clk_roles[j]);
>> +
>> + kfree(pdata.dss_opt_clk_roles);
>> +
>> + return -ENOMEM;
>> + }
>> +
>> + strncpy(pdata.dss_opt_clk_roles[i], oc[i].role, oc_length+1);
>> + }
>
> Do you actually need to copy the role strings? Can they every change? If
> they are const data, you could just point to the original strings.
Right; no, I don't think they can change, so I could point to the
original strings.
>
> And is there even need to create clk_roles array. If I'm not mistaken,
> the only use for this data is for the opt_clock_available() function. We
> could just have an opt_clock_available() function pointer in the
> omap_display_platform_data, and the function itself would be in
> display.c. And the function could use the original hwmod data.
Ok, but in that case, we do the same hwmod lookup everytime, is it?
That may not be so bad though, considering we check that very rarely
[in dsshw_probe=>dss_get_clocks() path].
Ok, will do and send the updated one soon.
~Sumit.
>
> Tomi
>
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Patch 1/2] OMAP2PLUS: DSS2: Add dss_opt_clk_roles in pdata
2011-02-28 9:17 ` Semwal, Sumit
@ 2011-02-28 9:23 ` Tomi Valkeinen
0 siblings, 0 replies; 6+ messages in thread
From: Tomi Valkeinen @ 2011-02-28 9:23 UTC (permalink / raw)
To: Semwal, Sumit; +Cc: linux-omap@vger.kernel.org, Guruswamy, Senthilvadivu
On Mon, 2011-02-28 at 03:17 -0600, Semwal, Sumit wrote:
> Hi Tomi,
>
> On Mon, Feb 28, 2011 at 2:40 PM, Tomi Valkeinen <tomi.valkeinen@ti.com> wrote:
<snip>
> > And is there even need to create clk_roles array. If I'm not mistaken,
> > the only use for this data is for the opt_clock_available() function. We
> > could just have an opt_clock_available() function pointer in the
> > omap_display_platform_data, and the function itself would be in
> > display.c. And the function could use the original hwmod data.
> Ok, but in that case, we do the same hwmod lookup everytime, is it?
Yes. I have no idea if hwmod lookup is heavy or not. But:
> That may not be so bad though, considering we check that very rarely
> [in dsshw_probe=>dss_get_clocks() path].
Yep, we do it once (if we're not unloading & loading modules). So I
don't think it matters. But if you want, you could do
omap_hwmod_lookup("dss_core") in omap_display_init(), and store the
return value somewhere.
Tomi
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-02-28 9:23 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-25 8:27 [Patch 0/2] OMAP2PLUS:DSS2: use opt-clocks information from hwmod Sumit Semwal
2011-02-25 8:27 ` [Patch 1/2] OMAP2PLUS: DSS2: Add dss_opt_clk_roles in pdata Sumit Semwal
2011-02-28 9:10 ` Tomi Valkeinen
2011-02-28 9:17 ` Semwal, Sumit
2011-02-28 9:23 ` Tomi Valkeinen
2011-02-25 8:27 ` [Patch 2/2] OMAP2PLUS: DSS2: Use opt-clocks from hwmod Sumit Semwal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox