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