[PATCH V2 13/16] OMAP: hsmmc: implement clock switcher
From: tony@atomide.com (Tony Lindgren)
Date: 2011-05-12 10:37:23
Also in:
linux-mmc, linux-omap
From: tony@atomide.com (Tony Lindgren)
Date: 2011-05-12 10:37:23
Also in:
linux-mmc, linux-omap
* Adrian Hunter [off-list ref] [110506 02:13]:
From: Andy Shevchenko <redacted> 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