board-h2-mmc.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. #include <mach/mmc.h>
  15. #include <mach/gpio.h>
  16. #ifdef CONFIG_MMC_OMAP
  17. static int slot_cover_open;
  18. static struct device *mmc_device;
  19. static int h2_mmc_set_power(struct device *dev, int slot, int power_on,
  20. int vdd)
  21. {
  22. #ifdef CONFIG_MMC_DEBUG
  23. dev_dbg(dev, "Set slot %d power: %s (vdd %d)\n", slot + 1,
  24. power_on ? "on" : "off", vdd);
  25. #endif
  26. if (slot != 0) {
  27. dev_err(dev, "No such slot %d\n", slot + 1);
  28. return -ENODEV;
  29. }
  30. return 0;
  31. }
  32. static int h2_mmc_set_bus_mode(struct device *dev, int slot, int bus_mode)
  33. {
  34. #ifdef CONFIG_MMC_DEBUG
  35. dev_dbg(dev, "Set slot %d bus_mode %s\n", slot + 1,
  36. bus_mode == MMC_BUSMODE_OPENDRAIN ? "open-drain" : "push-pull");
  37. #endif
  38. if (slot != 0) {
  39. dev_err(dev, "No such slot %d\n", slot + 1);
  40. return -ENODEV;
  41. }
  42. return 0;
  43. }
  44. static int h2_mmc_get_cover_state(struct device *dev, int slot)
  45. {
  46. BUG_ON(slot != 0);
  47. return slot_cover_open;
  48. }
  49. void h2_mmc_slot_cover_handler(void *arg, int state)
  50. {
  51. if (mmc_device == NULL)
  52. return;
  53. slot_cover_open = state;
  54. omap_mmc_notify_cover_event(mmc_device, 0, state);
  55. }
  56. static int h2_mmc_late_init(struct device *dev)
  57. {
  58. int ret = 0;
  59. mmc_device = dev;
  60. return ret;
  61. }
  62. static void h2_mmc_cleanup(struct device *dev)
  63. {
  64. }
  65. static struct omap_mmc_platform_data h2_mmc_data = {
  66. .nr_slots = 1,
  67. .switch_slot = NULL,
  68. .init = h2_mmc_late_init,
  69. .cleanup = h2_mmc_cleanup,
  70. .slots[0] = {
  71. .set_power = h2_mmc_set_power,
  72. .set_bus_mode = h2_mmc_set_bus_mode,
  73. .get_ro = NULL,
  74. .get_cover_state = h2_mmc_get_cover_state,
  75. .ocr_mask = MMC_VDD_28_29 | MMC_VDD_30_31 |
  76. MMC_VDD_32_33 | MMC_VDD_33_34,
  77. .name = "mmcblk",
  78. },
  79. };
  80. void __init h2_mmc_init(void)
  81. {
  82. omap_set_mmc_info(1, &h2_mmc_data);
  83. }
  84. #else
  85. void __init h2_mmc_init(void)
  86. {
  87. }
  88. void h2_mmc_slot_cover_handler(void *arg, int state)
  89. {
  90. }
  91. #endif