board-sx1-mmc.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * linux/arch/arm/mach-omap1/board-sx1-mmc.c
  3. *
  4. * Copyright (C) 2007 Instituto Nokia de Tecnologia - INdT
  5. * Author: Carlos Eduardo Aguiar <carlos.aguiar@indt.org.br>
  6. *
  7. * This code is based on linux/arch/arm/mach-omap1/board-h2-mmc.c, which is:
  8. * Copyright (C) 2007 Instituto Nokia de Tecnologia - INdT
  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 <linux/gpio.h>
  15. #include <linux/platform_device.h>
  16. #include <mach/hardware.h>
  17. #include "board-sx1.h"
  18. #include "mmc.h"
  19. #if IS_ENABLED(CONFIG_MMC_OMAP)
  20. static int mmc_set_power(struct device *dev, int slot, int power_on,
  21. int vdd)
  22. {
  23. int err;
  24. u8 dat = 0;
  25. err = sx1_i2c_read_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, &dat);
  26. if (err < 0)
  27. return err;
  28. if (power_on)
  29. dat |= SOFIA_MMC_POWER;
  30. else
  31. dat &= ~SOFIA_MMC_POWER;
  32. return sx1_i2c_write_byte(SOFIA_I2C_ADDR, SOFIA_POWER1_REG, dat);
  33. }
  34. /* Cover switch is at OMAP_MPUIO(3) */
  35. static struct omap_mmc_platform_data mmc1_data = {
  36. .nr_slots = 1,
  37. .slots[0] = {
  38. .set_power = mmc_set_power,
  39. .ocr_mask = MMC_VDD_32_33 | MMC_VDD_33_34,
  40. .name = "mmcblk",
  41. },
  42. };
  43. static struct omap_mmc_platform_data *mmc_data[OMAP15XX_NR_MMC];
  44. void __init sx1_mmc_init(void)
  45. {
  46. mmc_data[0] = &mmc1_data;
  47. omap1_init_mmc(mmc_data, OMAP15XX_NR_MMC);
  48. }
  49. #else
  50. void __init sx1_mmc_init(void)
  51. {
  52. }
  53. #endif