upload tizen1.0 source
[kernel/linux-2.6.36.git] / arch / arm / mach-s5pv310 / board-storage.c
1 /*
2  * linux/arch/arm/mach-s5pv310/board-storage.c
3  *
4  * Copyright (c) 2011 Samsung Electronics Co., Ltd.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  */
10
11 #include <linux/platform_device.h>
12 #include <linux/mmc/host.h>
13
14 #include <mach/gpio.h>
15
16 #include <plat/devs.h>
17 #include <plat/gpio-cfg.h>
18 #include <plat/sdhci.h>
19
20 #include "bcm4330.h"
21 #include "gpio-mobile.h"
22
23 /* eMMC */
24 #ifndef CONFIG_S3C_DEV_HSMMC4
25 static struct s3c_sdhci_platdata hsmmc0_data __initdata = {
26         .max_width              = 8,
27         .host_caps              = (MMC_CAP_8_BIT_DATA | MMC_CAP_4_BIT_DATA |
28                            MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |
29                            MMC_CAP_DISABLE | MMC_CAP_ERASE),
30         .cd_type                = S3C_SDHCI_CD_PERMANENT,
31         .clk_type               = S3C_SDHCI_CLK_DIV_EXTERNAL,
32 };
33 #endif
34
35 /* SD */
36 static struct s3c_sdhci_platdata hsmmc2_data __initdata = {
37         .max_width              = 4,
38         .host_caps              = MMC_CAP_4_BIT_DATA |
39                                 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED |
40                                 MMC_CAP_DISABLE,
41         .ext_cd_gpio            = S5PV310_GPX3(4),      /* XEINT_28 */
42         .ext_cd_gpio_invert     = 1,
43         .wakeup                 = 1,
44         .cd_type                = S3C_SDHCI_CD_GPIO,
45         .clk_type               = S3C_SDHCI_CLK_DIV_EXTERNAL,
46 };
47
48 /* WLAN */
49 static void (*wlan_notify_change_cb)(struct platform_device *dev, int state);
50
51 static int wlan_ext_cd_init(void (*cb)(struct platform_device *dev, int state))
52 {
53         wlan_notify_change_cb = cb;
54         return 0;
55 }
56
57 static int wlan_ext_cd_cleanup(void (*cb)(struct platform_device *dev, int state))
58 {
59         wlan_notify_change_cb = NULL;
60         return 0;
61 }
62
63 int wlan_host_enable(int on)
64 {
65         if (wlan_notify_change_cb)
66                 (*wlan_notify_change_cb)(&s3c_device_hsmmc3, on);
67         return 0;
68 }
69
70 static struct s3c_sdhci_platdata hsmmc3_data __initdata = {
71         .max_width              = 4,
72         .host_caps              = (MMC_CAP_4_BIT_DATA |
73                                 MMC_CAP_MMC_HIGHSPEED | MMC_CAP_SD_HIGHSPEED),
74         .pm_caps                = MMC_PM_KEEP_POWER,
75         .cd_type                = S3C_SDHCI_CD_EXTERNAL,
76         .ext_cd_init            = &wlan_ext_cd_init,
77         .ext_cd_cleanup         = &wlan_ext_cd_cleanup,
78         .clk_type               = S3C_SDHCI_CLK_DIV_EXTERNAL,
79 };
80
81 void __init s5pv310_sdhci_init(void)
82 {
83         unsigned int gpio;
84
85 #ifndef CONFIG_S3C_DEV_HSMMC4
86         s3c_sdhci0_set_platdata(&hsmmc0_data);
87 #endif
88         s3c_sdhci3_set_platdata(&hsmmc3_data);
89
90         /* T-Flash card detect pin - XEINT_28 */
91         gpio = hsmmc2_data.ext_cd_gpio;
92         s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(0xf));
93         s3c_gpio_setpull(gpio, S3C_GPIO_PULL_NONE);
94
95         s3c_sdhci2_set_platdata(&hsmmc2_data);
96 }