upload tizen1.0 source
[kernel/linux-2.6.36.git] / arch / arm / plat-samsung / dev-hsmmc4.c
1 /* linux/arch/arm/plat-samsung/dev-dw_mmc.c
2  *
3  * Copyright (c) 2011 Samsung Electronics Co., Ltd.
4  *              http://www.samsung.com
5  *
6  * Samsung device definition for DesingWare mobile storage
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/kernel.h>
14 #include <linux/platform_device.h>
15 #include <linux/mmc/host.h>
16 #include <linux/mmc/dw_mmc.h>
17 #include <linux/dma-mapping.h>
18
19 #include <mach/map.h>
20 #include <plat/devs.h>
21 #include <plat/cpu.h>
22 #include <plat/dw_mmc.h>
23
24 #define S3C_SZ_DW_MMC   (0x1000)
25
26 static struct resource s3c_hsmmc4_resource[] = {
27         [0] = {
28                 .start  = S3C_PA_DW_MMC,
29                 .end    = S3C_PA_DW_MMC + S3C_SZ_DW_MMC - 1,
30                 .flags  = IORESOURCE_MEM,
31         },
32         [1] = {
33                 .start  = IRQ_DW_MMC,
34                 .end    = IRQ_DW_MMC,
35                 .flags  = IORESOURCE_IRQ,
36         }
37 };
38
39 static u64 s3c_device_hsmmc4_dmamask = DMA_BIT_MASK(32);
40
41 /* FIXME move to s5pc210 directory */
42 #include <mach/gpio.h>
43 #include <plat/gpio-cfg.h>
44 static int hsmmc4_init(u32 slot_id, irq_handler_t dummy, void *data)
45 {
46         unsigned int gpio;
47
48         for (gpio = S5PV310_GPK0(0); gpio <= S5PV310_GPK0(6); gpio++) {
49                 if (gpio == S5PV310_GPK0(2))
50                         continue;
51                 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(3));
52                 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
53                 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
54         }
55         for (gpio = S5PV310_GPK1(3); gpio <= S5PV310_GPK1(6); gpio++) {
56                 s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(4));
57                 s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
58                 s5p_gpio_set_drvstr(gpio, S5P_GPIO_DRVSTR_LV4);
59         }
60
61         return 0;
62 }
63
64 struct dw_mci_board s3c_hsmmc4_def_platdata = {
65         .quirks         = DW_MCI_QUIRK_HIGHSPEED | DW_MCI_QUIRK_IDMAC_DTO |
66                         DW_MCI_QUIRK_BROKEN_CARD_DETECTION |
67                         DW_MCI_QUIRK_AUTO_SEND_STOP |
68                         DW_MCI_QUIRK_CLK_GATING,
69         .caps           = MMC_CAP_8_BIT_DATA | MMC_CAP_4_BIT_DATA |
70                         MMC_CAP_MMC_HIGHSPEED | MMC_CAP_DDR |
71                         MMC_CAP_NONREMOVABLE | MMC_CAP_ERASE,
72         .num_slots      = 1,
73         .init           = hsmmc4_init,
74         .bus_hz         = 200000000,
75         .page_size      = PAGE_SIZE << 2,
76 };
77
78 struct platform_device s3c_device_hsmmc4 = {
79         .name                   = "dw_mmc",
80         .id                     = -1,
81         .num_resources          = ARRAY_SIZE(s3c_hsmmc4_resource),
82         .resource               = s3c_hsmmc4_resource,
83         .dev                    = {
84                 .dma_mask               = &s3c_device_hsmmc4_dmamask,
85                 .platform_data          = &s3c_hsmmc4_def_platdata,
86                 .coherent_dma_mask      = DMA_BIT_MASK(32),
87         },
88 };
89
90 void s3c_dwmmc_set_platdata(struct dw_mci_board *b)
91 {
92         struct dw_mci_board *set = &s3c_hsmmc4_def_platdata;
93
94         if (b->quirks)
95                 set->quirks = b->quirks;
96         if (b->init)
97                 set->init = b->init;
98         if (b->bus_hz)
99                 set->bus_hz = b->bus_hz;
100 }