board-harmony-pcie.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * arch/arm/mach-tegra/board-harmony-pcie.c
  3. *
  4. * Copyright (C) 2010 CompuLab, Ltd.
  5. * Mike Rapoport <mike@compulab.co.il>
  6. *
  7. * This software is licensed under the terms of the GNU General Public
  8. * License version 2, as published by the Free Software Foundation, and
  9. * may be copied, distributed, and modified under those terms.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. */
  17. #include <linux/kernel.h>
  18. #include <linux/gpio.h>
  19. #include <linux/err.h>
  20. #include <linux/regulator/consumer.h>
  21. #include <asm/mach-types.h>
  22. #include "board.h"
  23. #include "board-harmony.h"
  24. #ifdef CONFIG_TEGRA_PCI
  25. int __init harmony_pcie_init(void)
  26. {
  27. struct regulator *regulator = NULL;
  28. int err;
  29. err = gpio_request(TEGRA_GPIO_EN_VDD_1V05_GPIO, "EN_VDD_1V05");
  30. if (err)
  31. return err;
  32. gpio_direction_output(TEGRA_GPIO_EN_VDD_1V05_GPIO, 1);
  33. regulator = regulator_get(NULL, "pex_clk");
  34. if (IS_ERR_OR_NULL(regulator))
  35. goto err_reg;
  36. regulator_enable(regulator);
  37. err = tegra_pcie_init(true, true);
  38. if (err)
  39. goto err_pcie;
  40. return 0;
  41. err_pcie:
  42. regulator_disable(regulator);
  43. regulator_put(regulator);
  44. err_reg:
  45. gpio_free(TEGRA_GPIO_EN_VDD_1V05_GPIO);
  46. return err;
  47. }
  48. static int __init harmony_pcie_initcall(void)
  49. {
  50. if (!machine_is_harmony())
  51. return 0;
  52. return harmony_pcie_init();
  53. }
  54. /* PCI should be initialized after I2C, mfd and regulators */
  55. subsys_initcall_sync(harmony_pcie_initcall);
  56. #endif