From f5edc32b7f652cf2ff423de68aed17fa4ac5b67f Mon Sep 17 00:00:00 2001 From: Andy Green Date: Wed, 19 Nov 2008 17:11:26 +0000 Subject: debug-s3cmci-fmax.patch This patch adds the module parameter f_max to s3cmci to limit the maximum clock frequency of the SD interface. E.g., when booting with s3cmci.f_max=10000000, the kernel should say s3c2440-sdi s3c2440-sdi: f_max lowered from 50000000 to 10000000 Hz and the interface frequency should be limited accordingly. Setting the limit above the maximum frequency supported by the card or the interface has no effect, so the option is ignored (and no "f_max lowered" line is printed). Setting the limit below the minimum frequency supported by the interface sets it to that frequency. Signed-off-by: Werner Almesberger --- drivers/mmc/host/s3cmci.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'drivers/mmc') diff --git a/drivers/mmc/host/s3cmci.c b/drivers/mmc/host/s3cmci.c index bf4df3a82f8..45f5e21a100 100644 --- a/drivers/mmc/host/s3cmci.c +++ b/drivers/mmc/host/s3cmci.c @@ -56,6 +56,8 @@ static const int dbgmap_err = dbg_fail; static const int dbgmap_info = dbg_info | dbg_conf; static const int dbgmap_debug = dbg_err | dbg_debug; +static int f_max = -1; /* override maximum frequency limit */ + #define dbg(host, channels, args...) \ do { \ if (dbgmap_err & channels) \ @@ -1394,6 +1396,18 @@ static int __devinit s3cmci_probe(struct platform_device *pdev, int is2440) mmc->f_min = host->clk_rate / (host->clk_div * 256); mmc->f_max = host->clk_rate / host->clk_div; + if (f_max >= 0) { + unsigned f = f_max; + + if (f < mmc->f_min) + f = mmc->f_min; + if (mmc->f_max > f) { + dev_info(&pdev->dev, "f_max lowered from %u to %u Hz\n", + mmc->f_max, f); + mmc->f_max = f; + } + } + if (host->pdata->ocr_avail) mmc->ocr_avail = host->pdata->ocr_avail; @@ -1575,6 +1589,8 @@ static void __exit s3cmci_exit(void) module_init(s3cmci_init); module_exit(s3cmci_exit); +module_param(f_max, int, 0644) + MODULE_DESCRIPTION("Samsung S3C MMC/SD Card Interface driver"); MODULE_LICENSE("GPL v2"); MODULE_AUTHOR("Thomas Kleffel , Ben Dooks "); -- cgit v1.2.3