upload tizen1.0 source
[kernel/linux-2.6.36.git] / arch / arm / mach-s5pv310 / setup-sdhci.c
1 /* linux/arch/arm/mach-s5pv310/setup-sdhci.c
2  *
3  * Copyright (c) 2009-2010 Samsung Electronics Co., Ltd.
4  *              http://www.samsung.com/
5  *
6  * S5PV310 - Helper functions for settign up SDHCI device(s) (HSMMC)
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License version 2 as
10  * published by the Free Software Foundation.
11 */
12
13 #include <linux/delay.h>
14 #include <linux/kernel.h>
15 #include <linux/types.h>
16 #include <linux/interrupt.h>
17 #include <linux/platform_device.h>
18 #include <linux/io.h>
19
20 #include <linux/mmc/card.h>
21 #include <linux/mmc/host.h>
22
23 #include <plat/regs-sdhci.h>
24 #include <mach/regs-clock.h>
25
26 /* clock sources for the mmc bus clock, order as for the ctrl2[5..4] */
27
28 char *s5pv310_hsmmc_clksrcs[4] = {
29 //      [0] = "hsmmc",          /* HCLK */
30 //      [1] = "hsmmc",          /* HCLK */
31         [2] = "sclk_mmc",       /* mmc_bus */
32         /*[4] = reserved */
33 };
34
35 void s5pv310_setup_sdhci_cfg_card(struct platform_device *dev,
36                                     void __iomem *r,
37                                     struct mmc_ios *ios,
38                                     struct mmc_card *card)
39 {
40         u32 ctrl2, ctrl3;
41
42         /* don't need to alter anything acording to card-type */
43
44         ctrl2 = __raw_readl(r + S3C_SDHCI_CONTROL2);
45         ctrl2 &= S3C_SDHCI_CTRL2_SELBASECLK_MASK;
46         ctrl2 |= (S3C64XX_SDHCI_CTRL2_ENSTAASYNCCLR |
47                   S3C64XX_SDHCI_CTRL2_ENCMDCNFMSK |
48                   S3C_SDHCI_CTRL2_ENFBCLKRX |
49                   S3C_SDHCI_CTRL2_DFCNT_NONE |
50                   S3C_SDHCI_CTRL2_ENCLKOUTHOLD);
51
52         if (ios->clock < 25 * 1000000)
53                 ctrl3 = (S3C_SDHCI_CTRL3_FCSEL3 |
54                          S3C_SDHCI_CTRL3_FCSEL2 |
55                          S3C_SDHCI_CTRL3_FCSEL1 |
56                          S3C_SDHCI_CTRL3_FCSEL0);
57         else
58                 ctrl3 = (S3C_SDHCI_CTRL3_FCSEL1 | S3C_SDHCI_CTRL3_FCSEL0);
59
60         __raw_writel(ctrl2, r + S3C_SDHCI_CONTROL2);
61         __raw_writel(ctrl3, r + S3C_SDHCI_CONTROL3);
62 }