temp revert rk change
[firefly-linux-kernel-4.4.55.git] / arch / arm / mach-tegra / board-harmony-sdhci.c
1 /*
2  * arch/arm/mach-tegra/board-harmony-sdhci.c
3  *
4  * Copyright (C) 2010 Google, Inc.
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
22 #include <asm/mach-types.h>
23 #include <mach/irqs.h>
24 #include <mach/iomap.h>
25 #include <mach/sdhci.h>
26 #include <mach/pinmux.h>
27
28 #include "gpio-names.h"
29
30 static struct resource sdhci_resource1[] = {
31         [0] = {
32                 .start  = INT_SDMMC1,
33                 .end    = INT_SDMMC1,
34                 .flags  = IORESOURCE_IRQ,
35         },
36         [1] = {
37                 .start  = TEGRA_SDMMC1_BASE,
38                 .end    = TEGRA_SDMMC1_BASE + TEGRA_SDMMC1_SIZE-1,
39                 .flags  = IORESOURCE_MEM,
40         },
41 };
42
43 static struct resource sdhci_resource2[] = {
44         [0] = {
45                 .start  = INT_SDMMC2,
46                 .end    = INT_SDMMC2,
47                 .flags  = IORESOURCE_IRQ,
48         },
49         [1] = {
50                 .start  = TEGRA_SDMMC2_BASE,
51                 .end    = TEGRA_SDMMC2_BASE + TEGRA_SDMMC2_SIZE-1,
52                 .flags  = IORESOURCE_MEM,
53         },
54 };
55
56 static struct resource sdhci_resource4[] = {
57         [0] = {
58                 .start  = INT_SDMMC4,
59                 .end    = INT_SDMMC4,
60                 .flags  = IORESOURCE_IRQ,
61         },
62         [1] = {
63                 .start  = TEGRA_SDMMC4_BASE,
64                 .end    = TEGRA_SDMMC4_BASE + TEGRA_SDMMC4_SIZE-1,
65                 .flags  = IORESOURCE_MEM,
66         },
67 };
68
69 static struct tegra_sdhci_platform_data tegra_sdhci_platform_data1 = {
70         .clk_id = NULL,
71         .force_hs = 1,
72         .cd_gpio = -1,
73         .wp_gpio = -1,
74         .power_gpio = -1,
75 };
76
77 static struct tegra_sdhci_platform_data tegra_sdhci_platform_data2 = {
78         .clk_id = NULL,
79         .force_hs = 1,
80         .cd_gpio = TEGRA_GPIO_PI5,
81         .wp_gpio = TEGRA_GPIO_PH1,
82         .power_gpio = TEGRA_GPIO_PT3,
83 };
84
85 static struct tegra_sdhci_platform_data tegra_sdhci_platform_data4 = {
86         .clk_id = NULL,
87         .force_hs = 0,
88         .cd_gpio = TEGRA_GPIO_PH2,
89         .wp_gpio = TEGRA_GPIO_PH3,
90         .power_gpio = TEGRA_GPIO_PI6,
91 };
92
93 static struct platform_device tegra_sdhci_device1 = {
94         .name           = "sdhci-tegra",
95         .id             = 0,
96         .resource       = sdhci_resource1,
97         .num_resources  = ARRAY_SIZE(sdhci_resource1),
98         .dev = {
99                 .platform_data = &tegra_sdhci_platform_data1,
100         },
101 };
102
103 static struct platform_device tegra_sdhci_device2 = {
104         .name           = "sdhci-tegra",
105         .id             = 1,
106         .resource       = sdhci_resource2,
107         .num_resources  = ARRAY_SIZE(sdhci_resource2),
108         .dev = {
109                 .platform_data = &tegra_sdhci_platform_data2,
110         },
111 };
112
113 static struct platform_device tegra_sdhci_device4 = {
114         .name           = "sdhci-tegra",
115         .id             = 3,
116         .resource       = sdhci_resource4,
117         .num_resources  = ARRAY_SIZE(sdhci_resource4),
118         .dev = {
119                 .platform_data = &tegra_sdhci_platform_data4,
120         },
121 };
122
123 int __init harmony_sdhci_init(void)
124 {
125         gpio_request(tegra_sdhci_platform_data2.power_gpio, "sdhci2_power");
126         gpio_request(tegra_sdhci_platform_data2.cd_gpio, "sdhci2_cd");
127         gpio_request(tegra_sdhci_platform_data2.wp_gpio, "sdhci2_wp");
128
129         tegra_gpio_enable(tegra_sdhci_platform_data2.power_gpio);
130         tegra_gpio_enable(tegra_sdhci_platform_data2.cd_gpio);
131         tegra_gpio_enable(tegra_sdhci_platform_data2.wp_gpio);
132
133         gpio_request(tegra_sdhci_platform_data4.power_gpio, "sdhci4_power");
134         gpio_request(tegra_sdhci_platform_data4.cd_gpio, "sdhci4_cd");
135         gpio_request(tegra_sdhci_platform_data4.wp_gpio, "sdhci4_wp");
136
137         tegra_gpio_enable(tegra_sdhci_platform_data4.power_gpio);
138         tegra_gpio_enable(tegra_sdhci_platform_data4.cd_gpio);
139         tegra_gpio_enable(tegra_sdhci_platform_data4.wp_gpio);
140
141         gpio_direction_output(tegra_sdhci_platform_data2.power_gpio, 1);
142         gpio_direction_output(tegra_sdhci_platform_data4.power_gpio, 1);
143
144         platform_device_register(&tegra_sdhci_device1);
145         platform_device_register(&tegra_sdhci_device2);
146         platform_device_register(&tegra_sdhci_device4);
147
148         return 0;
149 }