Commit | Line | Data |
---|---|---|
f2a44393 MR |
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 | ||
18 | #include <linux/kernel.h> | |
19 | #include <linux/gpio.h> | |
20 | #include <linux/err.h> | |
3cc404de | 21 | #include <linux/of_gpio.h> |
f2a44393 MR |
22 | #include <linux/regulator/consumer.h> |
23 | ||
24 | #include <asm/mach-types.h> | |
25 | ||
f2a44393 MR |
26 | #include "board.h" |
27 | ||
28 | #ifdef CONFIG_TEGRA_PCI | |
29 | ||
a12c0efc | 30 | int __init harmony_pcie_init(void) |
f2a44393 | 31 | { |
3cc404de LD |
32 | struct device_node *np; |
33 | int en_vdd_1v05; | |
ce005cf4 | 34 | struct regulator *regulator = NULL; |
f2a44393 MR |
35 | int err; |
36 | ||
3cc404de LD |
37 | np = of_find_node_by_path("/regulators/regulator@3"); |
38 | if (!np) { | |
39 | pr_err("%s: of_find_node_by_path failed\n", __func__); | |
40 | return -ENODEV; | |
41 | } | |
42 | ||
43 | en_vdd_1v05 = of_get_named_gpio(np, "gpio", 0); | |
44 | if (en_vdd_1v05 < 0) { | |
45 | pr_err("%s: of_get_named_gpio failed: %d\n", __func__, | |
46 | en_vdd_1v05); | |
47 | return en_vdd_1v05; | |
48 | } | |
49 | ||
50 | err = gpio_request(en_vdd_1v05, "EN_VDD_1V05"); | |
51 | if (err) { | |
52 | pr_err("%s: gpio_request failed: %d\n", __func__, err); | |
ce005cf4 | 53 | return err; |
3cc404de | 54 | } |
ce005cf4 | 55 | |
3cc404de | 56 | gpio_direction_output(en_vdd_1v05, 1); |
ce005cf4 | 57 | |
3cc404de | 58 | regulator = regulator_get(NULL, "vdd_ldo0,vddio_pex_clk"); |
f863440d RK |
59 | if (IS_ERR(regulator)) { |
60 | err = PTR_ERR(regulator); | |
61 | pr_err("%s: regulator_get failed: %d\n", __func__, err); | |
ce005cf4 | 62 | goto err_reg; |
3cc404de | 63 | } |
ce005cf4 | 64 | |
84b808da SW |
65 | err = regulator_enable(regulator); |
66 | if (err) { | |
67 | pr_err("%s: regulator_enable failed: %d\n", __func__, err); | |
68 | goto err_en; | |
69 | } | |
ce005cf4 | 70 | |
f2a44393 | 71 | err = tegra_pcie_init(true, true); |
3cc404de LD |
72 | if (err) { |
73 | pr_err("%s: tegra_pcie_init failed: %d\n", __func__, err); | |
f2a44393 | 74 | goto err_pcie; |
3cc404de | 75 | } |
f2a44393 MR |
76 | |
77 | return 0; | |
78 | ||
79 | err_pcie: | |
ce005cf4 | 80 | regulator_disable(regulator); |
84b808da | 81 | err_en: |
ce005cf4 MR |
82 | regulator_put(regulator); |
83 | err_reg: | |
3cc404de | 84 | gpio_free(en_vdd_1v05); |
ce005cf4 | 85 | |
f2a44393 MR |
86 | return err; |
87 | } | |
88 | ||
f2a44393 | 89 | #endif |