board-h2-mmc.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * linux/arch/arm/mach-omap1/board-h2-mmc.c
  4. *
  5. * Copyright (C) 2007 Instituto Nokia de Tecnologia - INdT
  6. * Author: Felipe Balbi <[email protected]>
  7. *
  8. * This code is based on linux/arch/arm/mach-omap2/board-n800-mmc.c, which is:
  9. * Copyright (C) 2006 Nokia Corporation
  10. */
  11. #include <linux/gpio.h>
  12. #include <linux/platform_device.h>
  13. #include <linux/platform_data/gpio-omap.h>
  14. #include <linux/mfd/tps65010.h>
  15. #include "board-h2.h"
  16. #include "mmc.h"
  17. #if IS_ENABLED(CONFIG_MMC_OMAP)
  18. static int mmc_set_power(struct device *dev, int slot, int power_on,
  19. int vdd)
  20. {
  21. gpio_set_value(H2_TPS_GPIO_MMC_PWR_EN, power_on);
  22. return 0;
  23. }
  24. static int mmc_late_init(struct device *dev)
  25. {
  26. int ret = gpio_request(H2_TPS_GPIO_MMC_PWR_EN, "MMC power");
  27. if (ret < 0)
  28. return ret;
  29. gpio_direction_output(H2_TPS_GPIO_MMC_PWR_EN, 0);
  30. return ret;
  31. }
  32. static void mmc_cleanup(struct device *dev)
  33. {
  34. gpio_free(H2_TPS_GPIO_MMC_PWR_EN);
  35. }
  36. /*
  37. * H2 could use the following functions tested:
  38. * - mmc_get_cover_state that uses OMAP_MPUIO(1)
  39. * - mmc_get_wp that uses OMAP_MPUIO(3)
  40. */
  41. static struct omap_mmc_platform_data mmc1_data = {
  42. .nr_slots = 1,
  43. .init = mmc_late_init,
  44. .cleanup = mmc_cleanup,
  45. .slots[0] = {
  46. .set_power = mmc_set_power,
  47. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  48. .name = "mmcblk",
  49. },
  50. };
  51. static struct omap_mmc_platform_data *mmc_data[OMAP16XX_NR_MMC];
  52. void __init h2_mmc_init(void)
  53. {
  54. mmc_data[0] = &mmc1_data;
  55. omap1_init_mmc(mmc_data, OMAP16XX_NR_MMC);
  56. }
  57. #else
  58. void __init h2_mmc_init(void)
  59. {
  60. }
  61. #endif