arm: tegra: macallan: create board file
[linux-3.10.git] / arch / arm / mach-tegra / board-macallan-sdhci.c
1 /*
2  * arch/arm/mach-tegra/board-macallan-sdhci.c
3  *
4  * Copyright (C) 2013 NVIDIA Corporation.
5  *
6  * This software is licensed under the terms of the GNU General Public
7  * License version 2, as published by the Free Software Foundation, and
8  * may be copied, distributed, and modified under those terms.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  */
16
17 #include <linux/resource.h>
18 #include <linux/platform_device.h>
19 #include <linux/delay.h>
20 #include <linux/gpio.h>
21 #include <linux/clk.h>
22 #include <linux/err.h>
23 #include <linux/regulator/consumer.h>
24 #include <linux/mmc/host.h>
25 #include <linux/platform_data/mmc-sdhci-tegra.h>
26
27 #include <asm/mach-types.h>
28 #include <mach/irqs.h>
29 #include <mach/gpio-tegra.h>
30 #include <mach/io_dpd.h>
31
32 #include "gpio-names.h"
33 #include "board.h"
34 #include "board-macallan.h"
35 #include "iomap.h"
36
37 #define MACALLAN_SD_CD          TEGRA_GPIO_PV2
38
39 static int macallan_wifi_status_register(void (*callback)(int , void *), void *);
40
41 #ifdef CONFIG_MMC_EMBEDDED_SDIO
42 static struct embedded_sdio_data embedded_sdio_data0 = {
43         .cccr   = {
44                 .sdio_vsn       = 2,
45                 .multi_block    = 1,
46                 .low_speed      = 0,
47                 .wide_bus       = 0,
48                 .high_power     = 1,
49                 .high_speed     = 1,
50         },
51         .cis  = {
52                 .vendor  = 0x02d0,
53                 .device  = 0x4329,
54         },
55 };
56 #endif
57
58 struct tegra_sdhci_platform_data macallan_tegra_sdhci_platform_data0 = {
59         .mmc_data = {
60                 .register_status_notify = macallan_wifi_status_register,
61 #ifdef CONFIG_MMC_EMBEDDED_SDIO
62                 .embedded_sdio = &embedded_sdio_data0,
63 #endif
64                 .built_in = 0,
65                 .ocr_mask = MMC_OCR_1V8_MASK,
66         },
67 #ifndef CONFIG_MMC_EMBEDDED_SDIO
68         .pm_flags = MMC_PM_KEEP_POWER,
69 #endif
70         .cd_gpio = -1,
71         .wp_gpio = -1,
72         .power_gpio = -1,
73         .tap_delay = 0x2,
74         .trim_delay = 0x2,
75         .ddr_clk_limit = 41000000,
76         .uhs_mask = MMC_UHS_MASK_SDR104 |
77                 MMC_UHS_MASK_DDR50,
78         .base_clk = 208000000,
79 };
80
81 #ifndef CONFIG_USE_OF
82 static struct resource sdhci_resource0[] = {
83         [0] = {
84                 .start  = INT_SDMMC1,
85                 .end    = INT_SDMMC1,
86                 .flags  = IORESOURCE_IRQ,
87         },
88         [1] = {
89                 .start  = TEGRA_SDMMC1_BASE,
90                 .end    = TEGRA_SDMMC1_BASE + TEGRA_SDMMC1_SIZE-1,
91                 .flags  = IORESOURCE_MEM,
92         },
93 };
94
95 static struct resource sdhci_resource2[] = {
96         [0] = {
97                 .start  = INT_SDMMC3,
98                 .end    = INT_SDMMC3,
99                 .flags  = IORESOURCE_IRQ,
100         },
101         [1] = {
102                 .start  = TEGRA_SDMMC3_BASE,
103                 .end    = TEGRA_SDMMC3_BASE + TEGRA_SDMMC3_SIZE-1,
104                 .flags  = IORESOURCE_MEM,
105         },
106 };
107
108 static struct resource sdhci_resource3[] = {
109         [0] = {
110                 .start  = INT_SDMMC4,
111                 .end    = INT_SDMMC4,
112                 .flags  = IORESOURCE_IRQ,
113         },
114         [1] = {
115                 .start  = TEGRA_SDMMC4_BASE,
116                 .end    = TEGRA_SDMMC4_BASE + TEGRA_SDMMC4_SIZE-1,
117                 .flags  = IORESOURCE_MEM,
118         },
119 };
120
121
122 static struct tegra_sdhci_platform_data tegra_sdhci_platform_data2 = {
123         .cd_gpio = MACALLAN_SD_CD,
124         .wp_gpio = -1,
125         .power_gpio = -1,
126         .tap_delay = 0x3,
127         .trim_delay = 0x3,
128         .ddr_clk_limit = 41000000,
129 };
130
131 static struct tegra_sdhci_platform_data tegra_sdhci_platform_data3 = {
132         .cd_gpio = -1,
133         .wp_gpio = -1,
134         .power_gpio = -1,
135         .is_8bit = 1,
136         .tap_delay = 0x5,
137         .trim_delay = 0,
138         .ddr_clk_limit = 41000000,
139         .mmc_data = {
140                 .built_in = 1,
141                 .ocr_mask = MMC_OCR_1V8_MASK,
142         }
143 };
144
145 static struct platform_device tegra_sdhci_device0 = {
146         .name           = "sdhci-tegra",
147         .id             = 0,
148         .resource       = sdhci_resource0,
149         .num_resources  = ARRAY_SIZE(sdhci_resource0),
150         .dev = {
151                 .platform_data = &macallan_tegra_sdhci_platform_data0,
152         },
153 };
154
155 static struct platform_device tegra_sdhci_device2 = {
156         .name           = "sdhci-tegra",
157         .id             = 2,
158         .resource       = sdhci_resource2,
159         .num_resources  = ARRAY_SIZE(sdhci_resource2),
160         .dev = {
161                 .platform_data = &tegra_sdhci_platform_data2,
162         },
163 };
164
165 static struct platform_device tegra_sdhci_device3 = {
166         .name           = "sdhci-tegra",
167         .id             = 3,
168         .resource       = sdhci_resource3,
169         .num_resources  = ARRAY_SIZE(sdhci_resource3),
170         .dev = {
171                 .platform_data = &tegra_sdhci_platform_data3,
172         },
173 };
174 #endif
175
176 static int macallan_wifi_status_register(
177                 void (*callback)(int card_present, void *dev_id),
178                 void *dev_id)
179 {
180         return 0;
181 }
182
183
184 static int __init macallan_wifi_init(void)
185 {
186         return 0;
187 }
188
189 int __init macallan_sdhci_init(void)
190 {
191 #ifndef CONFIG_USE_OF
192         platform_device_register(&tegra_sdhci_device3);
193         platform_device_register(&tegra_sdhci_device2);
194         platform_device_register(&tegra_sdhci_device0);
195 #endif
196         macallan_wifi_init();
197         return 0;
198 }