From mboxrd@z Thu Jan 1 00:00:00 1970 From: tony@atomide.com (Tony Lindgren) Date: Thu, 12 May 2011 03:37:23 -0700 Subject: [PATCH V2 13/16] OMAP: hsmmc: implement clock switcher In-Reply-To: <1304673255-31634-14-git-send-email-adrian.hunter@nokia.com> References: <1304673255-31634-1-git-send-email-adrian.hunter@nokia.com> <1304673255-31634-14-git-send-email-adrian.hunter@nokia.com> Message-ID: <20110512103723.GJ31483@atomide.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org * Adrian Hunter [110506 02:13]: > From: Andy Shevchenko > > There are 3 new platform data methods which should help us to do a clock > switching when notification is happened or request is started. > > The purpose of the patch is to avoid high frequency of MMC controller on low > OPPs due to an HW bug in OMAP 3630. ... > +static int hsmmc_clk_notifier(struct notifier_block *nb, unsigned long event, > + void *data) > +{ > + struct cpufreq_freqs *freqs = data; > + unsigned int threshold = 400000; /* between opp1 and opp2 */ > + > + switch (event) { > + case CPUFREQ_PRECHANGE: > + if (freqs->new < threshold && freqs->old >= threshold) { > + /* opp2 -> opp1 */ > + hsmmc_max_freq = HSMMC_MAX_FREQ >> 1; > + > + /* Timeout is 1 sec */ > + if (!wait_event_timeout(hsmmc_max_freq_wq, > + hsmmc_max_freq_ok(), > + msecs_to_jiffies(1000))) > + pr_err("MMC violates maximum frequency " > + "constraint\n"); > + } > + break; > + case CPUFREQ_POSTCHANGE: > + if (freqs->old < threshold && freqs->new >= threshold) { > + /* opp1 -> opp2 */ > + hsmmc_max_freq = HSMMC_MAX_FREQ; > + } > + break; > + default: > + break; > + } > + > + return NOTIFY_DONE; > +} I think the cpufreq notifier code should be in the driver, the platform init code should just prepare things for the driver. Regards, Tony