board-harmony-pcie.c 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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/of_gpio.h>
  21. #include <linux/regulator/consumer.h>
  22. #include <asm/mach-types.h>
  23. #include "board.h"
  24. #ifdef CONFIG_TEGRA_PCI
  25. int __init harmony_pcie_init(void)
  26. {
  27. struct device_node *np;
  28. int en_vdd_1v05;
  29. struct regulator *regulator = NULL;
  30. int err;
  31. np = of_find_node_by_path("/regulators/regulator@3");
  32. if (!np) {
  33. pr_err("%s: of_find_node_by_path failed\n", __func__);
  34. return -ENODEV;
  35. }
  36. en_vdd_1v05 = of_get_named_gpio(np, "gpio", 0);
  37. if (en_vdd_1v05 < 0) {
  38. pr_err("%s: of_get_named_gpio failed: %d\n", __func__,
  39. en_vdd_1v05);
  40. return en_vdd_1v05;
  41. }
  42. err = gpio_request(en_vdd_1v05, "EN_VDD_1V05");
  43. if (err) {
  44. pr_err("%s: gpio_request failed: %d\n", __func__, err);
  45. return err;
  46. }
  47. gpio_direction_output(en_vdd_1v05, 1);
  48. regulator = regulator_get(NULL, "vdd_ldo0,vddio_pex_clk");
  49. if (IS_ERR_OR_NULL(regulator)) {
  50. pr_err("%s: regulator_get failed: %d\n", __func__,
  51. (int)PTR_ERR(regulator));
  52. goto err_reg;
  53. }
  54. regulator_enable(regulator);
  55. err = tegra_pcie_init(true, true);
  56. if (err) {
  57. pr_err("%s: tegra_pcie_init failed: %d\n", __func__, err);
  58. goto err_pcie;
  59. }
  60. return 0;
  61. err_pcie:
  62. regulator_disable(regulator);
  63. regulator_put(regulator);
  64. err_reg:
  65. gpio_free(en_vdd_1v05);
  66. return err;
  67. }
  68. #endif