OMAP2PLUS:DSS2: use opt-clocks information from hwmod.
Subsystems (4)
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.
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(-)
PATCH 1/2 OMAP2PLUS: DSS2: Add dss_opt_clk_roles in pdata
Provide dss_opt_clks roles in pdata, so that it can be retrieved in dss driver, thus avoiding the hardcoding of clock role names.
(based on implementation from Senthil)
--- arch/arm/mach-omap2/display.c | 41 ++++++++++++++++++++++++++++- arch/arm/plat-omap/include/plat/display.h | 3 +- 2 files changed, 42 insertions(+), 2 deletions(-)
arch/arm/mach-omap2/display.c +40 -1
@@ -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_infoint 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 ;
arch/arm/plat-omap/include/plat/display.h +2 -1
@@ -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 {
Signature · 1 line
1.7.1
Re: [Patch 1/2] OMAP2PLUS: DSS2: Add dss_opt_clk_roles in pdata
Quoted 71 lines · Sumit
Provide
dss_opt_clksroles in pdata, so that it can be retrieved in dss driver, thus avoiding the hardcoding of clock role names.Signed-off-by Senthilvadivu Guruswamy <[email protected]>(based on implementation from Senthil)
Signed-off-by Sumit Semwal <[email protected]>--- arch/arm/mach-omap2/display.c | 41 ++++++++++++++++++++++++++++- arch/arm/plat-omap/include/plat/display.h | 3 +- 2 files changed, 42 insertions(+), 2 deletions(-)arch/arm/mach-omap2/display.c +29
-1@@ -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_infoint 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);
arch/arm/mach-omap2/display.c int __init omap_display_init(struct omap_dss_board_info · line 114
Quoted 10 lines
arch/arm/mach-omap2/display.c +10
-0+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
Re: [Patch 1/2] OMAP2PLUS: DSS2: Add dss_opt_clk_roles in pdata
Hi Tomi,
On Mon, Feb 28, 2011 at 2:40 PM, Tomi Valkeinen <[email protected]> wrote:
<snip>
Quoted 25 lines
Quoted 25 lines
+ oc =
oh->opt_clks;
+oc_count=oh->opt_clks_cnt;arch/arm/mach-omap2/display.c +23
-0+ + /* 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); +
Quoted 8 lines
Quoted 5 lines
+ 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.
Quoted 6 lines
And is there even need to create
clk_rolesarray. If I'm not mistaken, the only use for this data is for theopt_clock_available()function. We could just have anopt_clock_available()function pointer in theomap_display_platform_data, and the function itself would be indisplay.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.
Quoted 5 lines
Tomi
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [Patch 1/2] OMAP2PLUS: DSS2: Add dss_opt_clk_roles in pdata
Quoted 3 lines · Sumit
Hi Tomi,
On Mon, Feb 28, 2011 at 2:40 PM, Tomi Valkeinen <[email protected]> wrote:
<snip>
Quoted 6 lines
Quoted 5 lines
And is there even need to create
clk_rolesarray. If I'm not mistaken, the only use for this data is for theopt_clock_available()function. We could just have anopt_clock_available()function pointer in theomap_display_platform_data, and the function itself would be indisplay.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:
Quoted 2 lines
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
PATCH 2/2 OMAP2PLUS: DSS2: Use opt-clocks from hwmod
In reply to Sumit Semwalhwmod databases provide information on which optional clocks are available for a given platform. Use this information during get/enable/disable/put of clocks.
--- drivers/video/omap2/dss/dss.c | 54 ++++++++++++++++++++++++++++------------- 1 files changed, 37 insertions(+), 17 deletions(-)
drivers/video/omap2/dss/dss.c +37 -17
@@ -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;
Signature · 1 line
1.7.1