From: Imre Deak Date: Tue, 20 Apr 2010 12:00:39 +0000 (+0300) Subject: gpu: pvr: round the SGX fclock rate to the nearest supported X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7e6cfa329b2bd826bcaac839a36a751dc8ae9c12;p=sgx.git gpu: pvr: round the SGX fclock rate to the nearest supported This is needed since clk_set_rate accepts only exact values. Signed-off-by: Imre Deak --- diff --git a/pvr/sysutils.c b/pvr/sysutils.c index 874692d..0f803d0 100644 --- a/pvr/sysutils.c +++ b/pvr/sysutils.c @@ -457,6 +457,7 @@ static enum PVRSRV_ERROR InitSgxClocks(struct SYS_DATA *psSysData) struct SYS_SPECIFIC_DATA *psSysSpecData = psSysData->pvSysSpecificData; struct clk *psCLK; struct clk *core_ck = NULL; + unsigned long rate; int r; psCLK = clk_get(NULL, "sgx_fck"); @@ -478,17 +479,18 @@ static enum PVRSRV_ERROR InitSgxClocks(struct SYS_DATA *psSysData) } clk_put(core_ck); - r = clk_set_rate(psSysSpecData->psSGX_FCK, - sgx_get_max_freq()); + /* +1 to account for rounding errors */ + rate = clk_round_rate(psSysSpecData->psSGX_FCK, sgx_get_max_freq() + 1); + r = clk_set_rate(psSysSpecData->psSGX_FCK, rate); if (r < 0) { - unsigned long rate; - rate = clk_get_rate(psSysSpecData->psSGX_FCK); rate /= 1000000; pr_warning("error %d when setting SGX fclk to %luMHz, " "falling back to %luMHz\n", r, sgx_get_max_freq() / 1000000, rate); - } + } else { + pr_info("SGX clock rate %lu MHz\n", rate / 1000000); + }; RegisterConstraintNotifications(psSysSpecData); return PVRSRV_OK;