]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/arm/mach-omap1/board-h2-mmc.c
ARM: OMAP: Clean-up MMC device init
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap1 / board-h2-mmc.c
1 /*
2  * linux/arch/arm/mach-omap1/board-h2-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 h2_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 h2_mmc_set_bus_mode(struct device *dev, int slot, int bus_mode)
39 {
40 #ifdef CONFIG_MMC_DEBUG
41         dev_dbg(dev, "Set slot %d bus_mode %s\n", slot + 1,
42                 bus_mode == MMC_BUSMODE_OPENDRAIN ? "open-drain" : "push-pull");
43 #endif
44         if (slot != 0) {
45                 dev_err(dev, "No such slot %d\n", slot + 1);
46                 return -ENODEV;
47         }
48
49         return 0;
50 }
51
52 static int h2_mmc_get_cover_state(struct device *dev, int slot)
53 {
54         BUG_ON(slot != 0);
55
56         return slot_cover_open;
57 }
58
59 void h2_mmc_slot_cover_handler(void *arg, int state)
60 {
61         if (mmc_device == NULL)
62                 return;
63
64         slot_cover_open = state;
65         omap_mmc_notify_cover_event(mmc_device, 0, state);
66 }
67
68 static int h2_mmc_late_init(struct device *dev)
69 {
70         int ret = 0;
71
72         mmc_device = dev;
73
74         return ret;
75 }
76
77 static void h2_mmc_cleanup(struct device *dev)
78 {
79 }
80
81 static struct omap_mmc_platform_data h2_mmc_data = {
82         .nr_slots                       = 1,
83         .switch_slot                    = NULL,
84         .init                           = h2_mmc_late_init,
85         .cleanup                        = h2_mmc_cleanup,
86         .slots[0]       = {
87                 .enabled                = 1,
88                 .wire4                  = 1,
89                 .set_power              = h2_mmc_set_power,
90                 .set_bus_mode           = h2_mmc_set_bus_mode,
91                 .get_ro                 = NULL,
92                 .get_cover_state        = h2_mmc_get_cover_state,
93                 .ocr_mask               = MMC_VDD_28_29 | MMC_VDD_30_31 |
94                                           MMC_VDD_32_33 | MMC_VDD_33_34,
95                 .name                   = "mmcblk",
96         },
97 };
98
99 void __init h2_mmc_init(void)
100 {
101         omap1_init_mmc(&h2_mmc_data);
102 }
103
104 #else
105
106 void __init h2_mmc_init(void)
107 {
108 }
109
110 void h2_mmc_slot_cover_handler(void *arg, int state)
111 {
112 }
113 #endif