[ar71xx] preliminary support for the Ubiquiti RouterStation Pro
[openwrt.git] / target / linux / s3c24xx / patches-2.6.24 / 1250-add-glamo-mci-slower-clocking-dynamic-switching.patc.patch
1 From 6d8e14dc4253f3921aff1bbbeb3caf073aa6a7b2 Mon Sep 17 00:00:00 2001
2 From: Andy Green <andy@openmoko.com>
3 Date: Wed, 30 Jul 2008 12:46:44 +0100
4 Subject: [PATCH] add-glamo-mci-slower-clocking-dynamic-switching.patch
5
6 This patch gives glamo-mci a concept of a platform-defined
7 dynamic clock slowing callback. It means that platform code
8 can associate some completely external state to decide if
9 we run the SD clock at normal rate or a rate divided by a
10 module parameter "sd_slow_ratio", which you can set on
11 kernel commandline like this:
12
13 glamo_mci.sd_slow_ratio=8
14
15 you can also change it at runtime by
16
17 echo 8 > /sys/module/glamo_mci/parameters/sd_slow_ratio
18
19 If no platform callback is defined, then no slow mode
20 is used. If it is defined, then the default division
21 action is / 8, eg, 16MHz normal -> 2MHz slow mode.
22
23 Signed-off-by: Andy Green <andy@openmoko.com>
24 ---
25 drivers/mfd/glamo/glamo-core.c | 2 ++
26 drivers/mfd/glamo/glamo-core.h | 2 ++
27 drivers/mfd/glamo/glamo-mci.c | 30 ++++++++++++++++++++++++++++--
28 include/linux/glamofb.h | 2 ++
29 4 files changed, 34 insertions(+), 2 deletions(-)
30
31 diff --git a/drivers/mfd/glamo/glamo-core.c b/drivers/mfd/glamo/glamo-core.c
32 index f411446..c094a8c 100644
33 --- a/drivers/mfd/glamo/glamo-core.c
34 +++ b/drivers/mfd/glamo/glamo-core.c
35 @@ -1114,6 +1114,8 @@ static int __init glamo_probe(struct platform_device *pdev)
36 /* bring MCI specific stuff over from our MFD platform data */
37 glamo_mci_def_pdata.glamo_set_mci_power =
38 glamo->pdata->glamo_set_mci_power;
39 + glamo_mci_def_pdata.glamo_mci_use_slow =
40 + glamo->pdata->glamo_mci_use_slow;
41 glamo_mci_def_pdata.glamo_irq_is_wired =
42 glamo->pdata->glamo_irq_is_wired;
43 glamo_mci_def_pdata.mci_suspending =
44 diff --git a/drivers/mfd/glamo/glamo-core.h b/drivers/mfd/glamo/glamo-core.h
45 index 8d647ec..d3f4309 100644
46 --- a/drivers/mfd/glamo/glamo-core.h
47 +++ b/drivers/mfd/glamo/glamo-core.h
48 @@ -72,6 +72,8 @@ struct glamo_mci_pdata {
49 unsigned long ocr_avail;
50 void (*glamo_set_mci_power)(unsigned char power_mode,
51 unsigned short vdd);
52 + /* glamo-mci asking if it should use the slow clock to card */
53 + int (*glamo_mci_use_slow)(void);
54 int (*glamo_irq_is_wired)(void);
55 void (*mci_suspending)(struct platform_device *dev);
56 int (*mci_all_dependencies_resumed)(struct platform_device
57 diff --git a/drivers/mfd/glamo/glamo-mci.c b/drivers/mfd/glamo/glamo-mci.c
58 index 54ba613..577021e 100644
59 --- a/drivers/mfd/glamo/glamo-mci.c
60 +++ b/drivers/mfd/glamo/glamo-mci.c
61 @@ -57,6 +57,23 @@ static int sd_max_clk = 50000000 / 3;
62 module_param(sd_max_clk, int, 0644);
63
64 /*
65 + * Slow SD clock rate
66 + *
67 + * you can override this on kernel commandline using
68 + *
69 + * glamo_mci.sd_slow_ratio=8
70 + *
71 + * for example
72 + *
73 + * platform callback is used to decide effective clock rate, if not
74 + * defined then max is used, if defined and returns nonzero, rate is
75 + * divided by this factor
76 + */
77 +
78 +static int sd_slow_ratio = 8;
79 +module_param(sd_slow_ratio, int, 0644);
80 +
81 +/*
82 * SD Signal drive strength
83 *
84 * you can override this on kernel commandline using
85 @@ -554,8 +571,17 @@ static void glamo_mci_send_request(struct mmc_host *mmc)
86 cmd->opcode, cmd->arg, cmd->data, cmd->mrq->stop,
87 cmd->flags);
88
89 - /* resume requested clock rate */
90 - __glamo_mci_fix_card_div(host, host->clk_div);
91 + /* resume requested clock rate
92 + * scale it down by sd_slow_ratio if platform requests it
93 + */
94 + if (host->pdata->glamo_mci_use_slow)
95 + if ((host->pdata->glamo_mci_use_slow)())
96 + __glamo_mci_fix_card_div(host, host->clk_div *
97 + sd_slow_ratio);
98 + else
99 + __glamo_mci_fix_card_div(host, host->clk_div);
100 + else
101 + __glamo_mci_fix_card_div(host, host->clk_div);
102
103 if (glamo_mci_send_command(host, cmd))
104 goto bail;
105 diff --git a/include/linux/glamofb.h b/include/linux/glamofb.h
106 index efd315b..b101e9c 100644
107 --- a/include/linux/glamofb.h
108 +++ b/include/linux/glamofb.h
109 @@ -31,6 +31,8 @@ struct glamofb_platform_data {
110 /* glamo mmc platform specific info */
111 void (*glamo_set_mci_power)(unsigned char power_mode,
112 unsigned short vdd);
113 + /* glamo-mci asking if it should use the slow clock to card */
114 + int (*glamo_mci_use_slow)(void);
115 int (*glamo_irq_is_wired)(void);
116 void (*mci_suspending)(struct platform_device *dev);
117 int (*mci_all_dependencies_resumed)(struct platform_device
118 --
119 1.5.6.5
120
This page took 0.051501 seconds and 5 git commands to generate.