board-harmony-pcie.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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(regulator)) {
  50. err = PTR_ERR(regulator);
  51. pr_err("%s: regulator_get failed: %d\n", __func__, err);
  52. goto err_reg;
  53. }
  54. err = regulator_enable(regulator);
  55. if (err) {
  56. pr_err("%s: regulator_enable failed: %d\n", __func__, err);
  57. goto err_en;
  58. }
  59. err = tegra_pcie_init(true, true);
  60. if (err) {
  61. pr_err("%s: tegra_pcie_init failed: %d\n", __func__, err);
  62. goto err_pcie;
  63. }
  64. return 0;
  65. err_pcie:
  66. regulator_disable(regulator);
  67. err_en:
  68. regulator_put(regulator);
  69. err_reg:
  70. gpio_free(en_vdd_1v05);
  71. return err;
  72. }
  73. #endif