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