]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap1/board-h3-mmc.c
Revert "ARM: OMAP: Get rid of controller vs slot confusion, initialize MMC devices...
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap1 / board-h3-mmc.c
1 /*
2  * linux/arch/arm/mach-omap1/board-h3-mmc.c
3  *
4  * Copyright (C) 2007 Instituto Nokia de Tecnologia - INdT
5  * Author: Felipe Balbi <felipe.lima@indt.org.br>
6  *
7  * This code is based on linux/arch/arm/mach-omap2/board-n800-mmc.c, which is:
8  * Copyright (C) 2006 Nokia Corporation
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License version 2 as
12  * published by the Free Software Foundation.
13  */
14
15 #include <mach/mmc.h>
16 #include <mach/gpio.h>
17 #include <mach/mmc.h>
18
19 #ifdef CONFIG_MMC_OMAP
20 static int slot_cover_open;
21 static struct device *mmc_device;
22
23 static int h3_mmc_set_power(struct device *dev, int slot, int power_on,
24                                 int vdd)
25 {
26 #ifdef CONFIG_MMC_DEBUG
27         dev_dbg(dev, "Set slot %d power: %s (vdd %d)\n", slot + 1,
28                 power_on ? "on" : "off", vdd);
29 #endif
30         if (slot != 0) {
31                 dev_err(dev, "No such slot %d\n", slot + 1);
32                 return -ENODEV;
33         }
34
35         return 0;
36 }
37
38 static int h3_mmc_set_bus_mode(struct device *dev, int slot, int bus_mode)
39 {
40         int ret = 0;
41
42 #ifdef CONFIG_MMC_DEBUG
43         dev_dbg(dev, "Set slot %d bus_mode %s\n", slot + 1,
44                 bus_mode == MMC_BUSMODE_OPENDRAIN ? "open-drain" : "push-pull");
45 #endif
46         if (slot != 0) {
47                 dev_err(dev, "No such slot %d\n", slot + 1);
48                 return -ENODEV;
49         }
50
51         /* Treated on upper level */
52
53         return bus_mode;
54 }
55
56 static int h3_mmc_get_cover_state(struct device *dev, int slot)
57 {
58         BUG_ON(slot != 0);
59
60         return slot_cover_open;
61 }
62
63 void h3_mmc_slot_cover_handler(void *arg, int state)
64 {
65         if (mmc_device == NULL)
66                 return;
67
68         slot_cover_open = state;
69         omap_mmc_notify_cover_event(mmc_device, 0, state);
70 }
71
72 static int h3_mmc_late_init(struct device *dev)
73 {
74         int ret = 0;
75
76         mmc_device = dev;
77
78         return ret;
79 }
80
81 static void h3_mmc_cleanup(struct device *dev)
82 {
83 }
84
85 static struct omap_mmc_platform_data h3_mmc_data = {
86         .nr_slots                       = 1,
87         .switch_slot                    = NULL,
88         .init                           = h3_mmc_late_init,
89         .cleanup                        = h3_mmc_cleanup,
90         .slots[0]       = {
91                 .enabled                = 1,
92                 .wire4                  = 1,
93                 .set_power              = h3_mmc_set_power,
94                 .set_bus_mode           = h3_mmc_set_bus_mode,
95                 .get_ro                 = NULL,
96                 .get_cover_state        = h3_mmc_get_cover_state,
97                 .ocr_mask               = MMC_VDD_28_29 | MMC_VDD_30_31 |
98                                           MMC_VDD_32_33 | MMC_VDD_33_34,
99                 .name                   = "mmcblk",
100         },
101 };
102
103 void __init h3_mmc_init(void)
104 {
105         omap1_init_mmc(&h3_mmc_data);
106 }
107
108 #else
109
110 void __init h3_mmc_init(void)
111 {
112 }
113
114 void h3_mmc_slot_cover_handler(void *arg, int state)
115 {
116 }
117 #endif