source: trunk/target/linux/xburst/patches-3.2/0013-MMC-JZ4740-Added-support-for-CPU-frequency-changing.patch @ 31222

Last change on this file since 31222 was 31222, checked in by jogo, 5 years ago

kernel: update linux 3.2 to 3.2.14

File size: 3.7 KB
  • drivers/mmc/host/jz4740_mmc.c

    From b95144c1b702f98c7902c75beb83f323701eb7c5 Mon Sep 17 00:00:00 2001
    From: Maarten ter Huurne <maarten@treewalker.org>
    Date: Sun, 19 Jun 2011 10:57:18 +0200
    Subject: [PATCH 13/21] MMC: JZ4740: Added support for CPU frequency changing.
    
    The MSC device clock is stopped before the frequency change.
    After the change a new divider is computed and the clock is restarted.
    Also the frequency change is postponed if an I/O operation is in progress.
    ---
     drivers/mmc/host/jz4740_mmc.c |   69 +++++++++++++++++++++++++++++++++++++++-
     1 files changed, 67 insertions(+), 2 deletions(-)
    
    a b  
    2323#include <linux/delay.h> 
    2424#include <linux/scatterlist.h> 
    2525#include <linux/clk.h> 
     26#include <linux/cpufreq.h> 
    2627 
    2728#include <linux/bitops.h> 
    2829#include <linux/gpio.h> 
    static void jz4740_mmc_enable_sdio_irq(s 
    685686        jz4740_mmc_set_irq_enabled(host, JZ_MMC_IRQ_SDIO, enable); 
    686687} 
    687688 
     689#ifdef CONFIG_CPU_FREQ 
     690 
     691static struct jz4740_mmc_host *cpufreq_host; 
     692 
     693static int jz4740_mmc_cpufreq_transition(struct notifier_block *nb, 
     694                                         unsigned long val, void *data) 
     695{ 
     696        /* TODO: We only have to take action when the PLL freq changes: 
     697                 the main dividers have no influence on the MSC device clock. */ 
     698 
     699        if (val == CPUFREQ_PRECHANGE) { 
     700                mmc_claim_host(cpufreq_host->mmc); 
     701                clk_disable(cpufreq_host->clk); 
     702        } else if (val == CPUFREQ_POSTCHANGE) { 
     703                struct mmc_ios *ios = &cpufreq_host->mmc->ios; 
     704                if (ios->clock) 
     705                        jz4740_mmc_set_clock_rate(cpufreq_host, ios->clock); 
     706                if (ios->power_mode != MMC_POWER_OFF) 
     707                        clk_enable(cpufreq_host->clk); 
     708                mmc_release_host(cpufreq_host->mmc); 
     709        } 
     710        return 0; 
     711} 
     712 
     713static struct notifier_block jz4740_mmc_cpufreq_nb = { 
     714        .notifier_call = jz4740_mmc_cpufreq_transition, 
     715}; 
     716 
     717static inline int jz4740_mmc_cpufreq_register(struct jz4740_mmc_host *host) 
     718{ 
     719        cpufreq_host = host; 
     720        return cpufreq_register_notifier(&jz4740_mmc_cpufreq_nb, 
     721                                         CPUFREQ_TRANSITION_NOTIFIER); 
     722} 
     723 
     724static inline void jz4740_mmc_cpufreq_unregister(void) 
     725{ 
     726        cpufreq_unregister_notifier(&jz4740_mmc_cpufreq_nb, 
     727                                    CPUFREQ_TRANSITION_NOTIFIER); 
     728} 
     729 
     730#else 
     731 
     732static inline int jz4740_mmc_cpufreq_register(struct jz4740_mmc_host *host) 
     733{ 
     734        return 0; 
     735} 
     736 
     737static inline void jz4740_mmc_cpufreq_unregister(void) 
     738{ 
     739} 
     740 
     741#endif 
     742 
    688743static const struct mmc_host_ops jz4740_mmc_ops = { 
    689744        .request        = jz4740_mmc_request, 
    690745        .set_ios        = jz4740_mmc_set_ios, 
    static int __devinit jz4740_mmc_probe(st 
    834889                goto err_free_host; 
    835890        } 
    836891 
     892        ret = jz4740_mmc_cpufreq_register(host); 
     893        if (ret) { 
     894                dev_err(&pdev->dev, 
     895                        "Failed to register cpufreq transition notifier\n"); 
     896                goto err_clk_put; 
     897        } 
     898 
    837899        host->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 
    838900        if (!host->mem) { 
    839901                ret = -ENOENT; 
    840902                dev_err(&pdev->dev, "Failed to get base platform memory\n"); 
    841                 goto err_clk_put; 
     903                goto err_cpufreq_unreg; 
    842904        } 
    843905 
    844906        host->mem = request_mem_region(host->mem->start, 
    static int __devinit jz4740_mmc_probe(st 
    846908        if (!host->mem) { 
    847909                ret = -EBUSY; 
    848910                dev_err(&pdev->dev, "Failed to request base memory region\n"); 
    849                 goto err_clk_put; 
     911                goto err_cpufreq_unreg; 
    850912        } 
    851913 
    852914        host->base = ioremap_nocache(host->mem->start, resource_size(host->mem)); 
    err_iounmap: 
    929991        iounmap(host->base); 
    930992err_release_mem_region: 
    931993        release_mem_region(host->mem->start, resource_size(host->mem)); 
     994err_cpufreq_unreg: 
     995        jz4740_mmc_cpufreq_unregister(); 
    932996err_clk_put: 
    933997        clk_put(host->clk); 
    934998err_free_host: 
    static int __devexit jz4740_mmc_remove(s 
    9581022        iounmap(host->base); 
    9591023        release_mem_region(host->mem->start, resource_size(host->mem)); 
    9601024 
     1025        jz4740_mmc_cpufreq_unregister(); 
    9611026        clk_put(host->clk); 
    9621027 
    9631028        platform_set_drvdata(pdev, NULL); 
Note: See TracBrowser for help on using the repository browser.