blob: e8c3fda9bec2faa0665372c04ffbcb8cd22f448f [file] [log] [blame]
Mike Rapoportf2a44392010-09-27 11:26:34 +02001/*
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 Rapoportf2a44392010-09-27 11:26:34 +020025#include "board.h"
Stephen Warrenab05be02011-09-22 18:16:04 +010026#include "board-harmony.h"
Mike Rapoportf2a44392010-09-27 11:26:34 +020027
28#ifdef CONFIG_TEGRA_PCI
29
Stephen Warrena12c0ef2012-05-02 15:47:12 -060030int __init harmony_pcie_init(void)
Mike Rapoportf2a44392010-09-27 11:26:34 +020031{
Mike Rapoportce005cf2011-03-09 16:31:17 +020032 struct regulator *regulator = NULL;
Mike Rapoportf2a44392010-09-27 11:26:34 +020033 int err;
34
Stephen Warrenab05be02011-09-22 18:16:04 +010035 err = gpio_request(TEGRA_GPIO_EN_VDD_1V05_GPIO, "EN_VDD_1V05");
Mike Rapoportce005cf2011-03-09 16:31:17 +020036 if (err)
37 return err;
38
Stephen Warrenab05be02011-09-22 18:16:04 +010039 gpio_direction_output(TEGRA_GPIO_EN_VDD_1V05_GPIO, 1);
Mike Rapoportce005cf2011-03-09 16:31:17 +020040
41 regulator = regulator_get(NULL, "pex_clk");
42 if (IS_ERR_OR_NULL(regulator))
43 goto err_reg;
44
45 regulator_enable(regulator);
46
Mike Rapoportf2a44392010-09-27 11:26:34 +020047 err = tegra_pcie_init(true, true);
48 if (err)
49 goto err_pcie;
50
51 return 0;
52
53err_pcie:
Mike Rapoportce005cf2011-03-09 16:31:17 +020054 regulator_disable(regulator);
55 regulator_put(regulator);
56err_reg:
Stephen Warrenab05be02011-09-22 18:16:04 +010057 gpio_free(TEGRA_GPIO_EN_VDD_1V05_GPIO);
Mike Rapoportce005cf2011-03-09 16:31:17 +020058
Mike Rapoportf2a44392010-09-27 11:26:34 +020059 return err;
60}
61
Stephen Warrena12c0ef2012-05-02 15:47:12 -060062static int __init harmony_pcie_initcall(void)
63{
64 if (!machine_is_harmony())
65 return 0;
66
67 return harmony_pcie_init();
68}
69
Mike Rapoportce005cf2011-03-09 16:31:17 +020070/* PCI should be initialized after I2C, mfd and regulators */
Stephen Warrena12c0ef2012-05-02 15:47:12 -060071subsys_initcall_sync(harmony_pcie_initcall);
Mike Rapoportf2a44392010-09-27 11:26:34 +020072
73#endif