board-h3-mmc.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. #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 h3_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 h3_mmc_set_bus_mode(struct device *dev, int slot, int bus_mode)
  33. {
  34. int ret = 0;
  35. #ifdef CONFIG_MMC_DEBUG
  36. dev_dbg(dev, "Set slot %d bus_mode %s\n", slot + 1,
  37. bus_mode == MMC_BUSMODE_OPENDRAIN ? "open-drain" : "push-pull");
  38. #endif
  39. if (slot != 0) {
  40. dev_err(dev, "No such slot %d\n", slot + 1);
  41. return -ENODEV;
  42. }
  43. /* Treated on upper level */
  44. return bus_mode;
  45. }
  46. static int h3_mmc_get_cover_state(struct device *dev, int slot)
  47. {
  48. BUG_ON(slot != 0);
  49. return slot_cover_open;
  50. }
  51. void h3_mmc_slot_cover_handler(void *arg, int state)
  52. {
  53. if (mmc_device == NULL)
  54. return;
  55. slot_cover_open = state;
  56. omap_mmc_notify_cover_event(mmc_device, 0, state);
  57. }
  58. static int h3_mmc_late_init(struct device *dev)
  59. {
  60. int ret = 0;
  61. mmc_device = dev;
  62. return ret;
  63. }
  64. static void h3_mmc_cleanup(struct device *dev)
  65. {
  66. }
  67. static struct omap_mmc_platform_data h3_mmc_data = {
  68. .nr_slots = 1,
  69. .switch_slot = NULL,
  70. .init = h3_mmc_late_init,
  71. .cleanup = h3_mmc_cleanup,
  72. .slots[0] = {
  73. .set_power = h3_mmc_set_power,
  74. .set_bus_mode = h3_mmc_set_bus_mode,
  75. .get_ro = NULL,
  76. .get_cover_state = h3_mmc_get_cover_state,
  77. .ocr_mask = MMC_VDD_28_29 | MMC_VDD_30_31 |
  78. MMC_VDD_32_33 | MMC_VDD_33_34,
  79. .name = "mmcblk",
  80. },
  81. };
  82. void __init h3_mmc_init(void)
  83. {
  84. omap_set_mmc_info(1, &h3_mmc_data);
  85. }
  86. #else
  87. void __init h3_mmc_init(void)
  88. {
  89. }
  90. void h3_mmc_slot_cover_handler(void *arg, int state)
  91. {
  92. }
  93. #endif