board-harmony-pcie.c 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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 <mach/pinmux.h>
  23. #include "board.h"
  24. #include "board-harmony.h"
  25. #ifdef CONFIG_TEGRA_PCI
  26. static int __init harmony_pcie_init(void)
  27. {
  28. struct regulator *regulator = NULL;
  29. int err;
  30. if (!machine_is_harmony())
  31. return 0;
  32. err = gpio_request(TEGRA_GPIO_EN_VDD_1V05_GPIO, "EN_VDD_1V05");
  33. if (err)
  34. return err;
  35. gpio_direction_output(TEGRA_GPIO_EN_VDD_1V05_GPIO, 1);
  36. regulator = regulator_get(NULL, "pex_clk");
  37. if (IS_ERR_OR_NULL(regulator))
  38. goto err_reg;
  39. regulator_enable(regulator);
  40. tegra_pinmux_set_tristate(TEGRA_PINGROUP_GPV, TEGRA_TRI_NORMAL);
  41. tegra_pinmux_set_tristate(TEGRA_PINGROUP_SLXA, TEGRA_TRI_NORMAL);
  42. tegra_pinmux_set_tristate(TEGRA_PINGROUP_SLXK, TEGRA_TRI_NORMAL);
  43. err = tegra_pcie_init(true, true);
  44. if (err)
  45. goto err_pcie;
  46. return 0;
  47. err_pcie:
  48. tegra_pinmux_set_tristate(TEGRA_PINGROUP_GPV, TEGRA_TRI_TRISTATE);
  49. tegra_pinmux_set_tristate(TEGRA_PINGROUP_SLXA, TEGRA_TRI_TRISTATE);
  50. tegra_pinmux_set_tristate(TEGRA_PINGROUP_SLXK, TEGRA_TRI_TRISTATE);
  51. regulator_disable(regulator);
  52. regulator_put(regulator);
  53. err_reg:
  54. gpio_free(TEGRA_GPIO_EN_VDD_1V05_GPIO);
  55. return err;
  56. }
  57. /* PCI should be initialized after I2C, mfd and regulators */
  58. subsys_initcall_sync(harmony_pcie_init);
  59. #endif