Mike Rapoport | f2a4439 | 2010-09-27 11:26:34 +0200 | [diff] [blame] | 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> |
| 21 | #include <linux/regulator/consumer.h> |
| 22 | |
| 23 | #include <asm/mach-types.h> |
| 24 | |
| 25 | #include <mach/pinmux.h> |
| 26 | #include "board.h" |
| 27 | |
| 28 | #ifdef CONFIG_TEGRA_PCI |
| 29 | |
Mike Rapoport | ce005cf | 2011-03-09 16:31:17 +0200 | [diff] [blame] | 30 | /* GPIO 3 of the PMIC */ |
| 31 | #define EN_VDD_1V05_GPIO (TEGRA_NR_GPIOS + 2) |
| 32 | |
Mike Rapoport | f2a4439 | 2010-09-27 11:26:34 +0200 | [diff] [blame] | 33 | static int __init harmony_pcie_init(void) |
| 34 | { |
Mike Rapoport | ce005cf | 2011-03-09 16:31:17 +0200 | [diff] [blame] | 35 | struct regulator *regulator = NULL; |
Mike Rapoport | f2a4439 | 2010-09-27 11:26:34 +0200 | [diff] [blame] | 36 | int err; |
| 37 | |
| 38 | if (!machine_is_harmony()) |
| 39 | return 0; |
| 40 | |
Mike Rapoport | ce005cf | 2011-03-09 16:31:17 +0200 | [diff] [blame] | 41 | err = gpio_request(EN_VDD_1V05_GPIO, "EN_VDD_1V05"); |
| 42 | if (err) |
| 43 | return err; |
| 44 | |
| 45 | gpio_direction_output(EN_VDD_1V05_GPIO, 1); |
| 46 | |
| 47 | regulator = regulator_get(NULL, "pex_clk"); |
| 48 | if (IS_ERR_OR_NULL(regulator)) |
| 49 | goto err_reg; |
| 50 | |
| 51 | regulator_enable(regulator); |
| 52 | |
Mike Rapoport | f2a4439 | 2010-09-27 11:26:34 +0200 | [diff] [blame] | 53 | tegra_pinmux_set_tristate(TEGRA_PINGROUP_GPV, TEGRA_TRI_NORMAL); |
| 54 | tegra_pinmux_set_tristate(TEGRA_PINGROUP_SLXA, TEGRA_TRI_NORMAL); |
| 55 | tegra_pinmux_set_tristate(TEGRA_PINGROUP_SLXK, TEGRA_TRI_NORMAL); |
| 56 | |
| 57 | err = tegra_pcie_init(true, true); |
| 58 | if (err) |
| 59 | goto err_pcie; |
| 60 | |
| 61 | return 0; |
| 62 | |
| 63 | err_pcie: |
| 64 | tegra_pinmux_set_tristate(TEGRA_PINGROUP_GPV, TEGRA_TRI_TRISTATE); |
| 65 | tegra_pinmux_set_tristate(TEGRA_PINGROUP_SLXA, TEGRA_TRI_TRISTATE); |
| 66 | tegra_pinmux_set_tristate(TEGRA_PINGROUP_SLXK, TEGRA_TRI_TRISTATE); |
| 67 | |
Mike Rapoport | ce005cf | 2011-03-09 16:31:17 +0200 | [diff] [blame] | 68 | regulator_disable(regulator); |
| 69 | regulator_put(regulator); |
| 70 | err_reg: |
| 71 | gpio_free(EN_VDD_1V05_GPIO); |
| 72 | |
Mike Rapoport | f2a4439 | 2010-09-27 11:26:34 +0200 | [diff] [blame] | 73 | return err; |
| 74 | } |
| 75 | |
Mike Rapoport | ce005cf | 2011-03-09 16:31:17 +0200 | [diff] [blame] | 76 | /* PCI should be initialized after I2C, mfd and regulators */ |
| 77 | subsys_initcall_sync(harmony_pcie_init); |
Mike Rapoport | f2a4439 | 2010-09-27 11:26:34 +0200 | [diff] [blame] | 78 | |
| 79 | #endif |