Skip to content

Commit

Permalink
Merge branch 'tegra/boards' into next/boards
Browse files Browse the repository at this point in the history
* tegra/boards:
  arm/tegra: remove __initdata annotation from pinmux tables
  arm/tegra: Use bus notifiers to trigger pinmux setup
  arm/tegra: Refactor board-*-pinmux.c to share code
  arm/tegra: Fix mistake in Trimslice's pinmux
  arm/tegra: Rework Seaboard-vs-Ventana pinmux table
  arm/tegra: Remove useless entries from ventana_pinmux[]
  arm/tegra: PCIe: Remove include of mach/pinmux.h
  arm/tegra: Harmony PCIe: Don't touch pinmux
  arm/tegra: Add AUXDATA for tegra-pinmux and tegra-gpio
  arm/tegra: Split Seaboard GPIO table to allow for Ventana
  ARM: tegra: paz00: Fix board pinmux table.
  ARM: tegra: paz00: add support for wakeup gpio key
  • Loading branch information
Arnd Bergmann committed Dec 27, 2011
2 parents 8df9749 + 16d9362 commit 75f7dd8
Show file tree
Hide file tree
Showing 12 changed files with 269 additions and 122 deletions.
1 change: 1 addition & 0 deletions arch/arm/mach-tegra/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
obj-y += board-pinmux.o
obj-y += common.o
obj-y += devices.o
obj-y += io.o
Expand Down
16 changes: 9 additions & 7 deletions arch/arm/mach-tegra/board-dt.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ void seaboard_pinmux_init(void);
void ventana_pinmux_init(void);

struct of_dev_auxdata tegra20_auxdata_lookup[] __initdata = {
OF_DEV_AUXDATA("nvidia,tegra20-pinmux", TEGRA_APB_MISC_BASE + 0x14, "tegra-pinmux", NULL),
OF_DEV_AUXDATA("nvidia,tegra20-gpio", TEGRA_GPIO_BASE, "tegra-gpio", NULL),
OF_DEV_AUXDATA("nvidia,tegra20-sdhci", TEGRA_SDMMC1_BASE, "sdhci-tegra.0", NULL),
OF_DEV_AUXDATA("nvidia,tegra20-sdhci", TEGRA_SDMMC2_BASE, "sdhci-tegra.1", NULL),
OF_DEV_AUXDATA("nvidia,tegra20-sdhci", TEGRA_SDMMC3_BASE, "sdhci-tegra.2", NULL),
Expand Down Expand Up @@ -102,13 +104,6 @@ static void __init tegra_dt_init(void)

tegra_clk_init_from_table(tegra_dt_clk_init_table);

/*
* Finished with the static registrations now; fill in the missing
* devices
*/
of_platform_populate(NULL, tegra_dt_match_table,
tegra20_auxdata_lookup, NULL);

for (i = 0; i < ARRAY_SIZE(pinmux_configs); i++) {
if (of_machine_is_compatible(pinmux_configs[i].machine)) {
pinmux_configs[i].init();
Expand All @@ -118,6 +113,13 @@ static void __init tegra_dt_init(void)

WARN(i == ARRAY_SIZE(pinmux_configs),
"Unknown platform! Pinmuxing not initialized\n");

/*
* Finished with the static registrations now; fill in the missing
* devices
*/
of_platform_populate(NULL, tegra_dt_match_table,
tegra20_auxdata_lookup, NULL);
}

static const char * tegra_dt_board_compat[] = {
Expand Down
9 changes: 0 additions & 9 deletions arch/arm/mach-tegra/board-harmony-pcie.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

#include <asm/mach-types.h>

#include <mach/pinmux.h>
#include "board.h"
#include "board-harmony.h"

Expand All @@ -48,21 +47,13 @@ static int __init harmony_pcie_init(void)

regulator_enable(regulator);

tegra_pinmux_set_tristate(TEGRA_PINGROUP_GPV, TEGRA_TRI_NORMAL);
tegra_pinmux_set_tristate(TEGRA_PINGROUP_SLXA, TEGRA_TRI_NORMAL);
tegra_pinmux_set_tristate(TEGRA_PINGROUP_SLXK, TEGRA_TRI_NORMAL);

err = tegra_pcie_init(true, true);
if (err)
goto err_pcie;

return 0;

err_pcie:
tegra_pinmux_set_tristate(TEGRA_PINGROUP_GPV, TEGRA_TRI_TRISTATE);
tegra_pinmux_set_tristate(TEGRA_PINGROUP_SLXA, TEGRA_TRI_TRISTATE);
tegra_pinmux_set_tristate(TEGRA_PINGROUP_SLXK, TEGRA_TRI_TRISTATE);

regulator_disable(regulator);
regulator_put(regulator);
err_reg:
Expand Down
22 changes: 9 additions & 13 deletions arch/arm/mach-tegra/board-harmony-pinmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include "gpio-names.h"
#include "board-harmony.h"
#include "devices.h"
#include "board-pinmux.h"

static struct tegra_pingroup_config harmony_pinmux[] = {
{TEGRA_PINGROUP_ATA, TEGRA_MUX_IDE, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL},
Expand Down Expand Up @@ -143,11 +143,6 @@ static struct tegra_pingroup_config harmony_pinmux[] = {
{TEGRA_PINGROUP_XM2D, TEGRA_MUX_NONE, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL},
};

static struct platform_device *pinmux_devices[] = {
&tegra_gpio_device,
&tegra_pinmux_device,
};

static struct tegra_gpio_table gpio_table[] = {
{ .gpio = TEGRA_GPIO_SD2_CD, .enable = true },
{ .gpio = TEGRA_GPIO_SD2_WP, .enable = true },
Expand All @@ -161,13 +156,14 @@ static struct tegra_gpio_table gpio_table[] = {
{ .gpio = TEGRA_GPIO_EXT_MIC_EN, .enable = true },
};

static struct tegra_board_pinmux_conf conf = {
.pgs = harmony_pinmux,
.pg_count = ARRAY_SIZE(harmony_pinmux),
.gpios = gpio_table,
.gpio_count = ARRAY_SIZE(gpio_table),
};

void harmony_pinmux_init(void)
{
if (!of_machine_is_compatible("nvidia,tegra20"))
platform_add_devices(pinmux_devices,
ARRAY_SIZE(pinmux_devices));

tegra_pinmux_config_table(harmony_pinmux, ARRAY_SIZE(harmony_pinmux));

tegra_gpio_config(gpio_table, ARRAY_SIZE(gpio_table));
tegra_board_pinmux_init(&conf, NULL);
}
24 changes: 10 additions & 14 deletions arch/arm/mach-tegra/board-paz00-pinmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@

#include "gpio-names.h"
#include "board-paz00.h"
#include "devices.h"
#include "board-pinmux.h"

static struct tegra_pingroup_config paz00_pinmux[] = {
{TEGRA_PINGROUP_ATA, TEGRA_MUX_GMI, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL},
{TEGRA_PINGROUP_ATB, TEGRA_MUX_SDIO4, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL},
{TEGRA_PINGROUP_ATC, TEGRA_MUX_GMI, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL},
{TEGRA_PINGROUP_ATD, TEGRA_MUX_GMI, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL},
{TEGRA_PINGROUP_ATE, TEGRA_MUX_GMI, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL},
{TEGRA_PINGROUP_CDEV1, TEGRA_MUX_PLLA_OUT, TEGRA_PUPD_PULL_DOWN, TEGRA_TRI_TRISTATE},
{TEGRA_PINGROUP_CDEV1, TEGRA_MUX_PLLA_OUT, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL},
{TEGRA_PINGROUP_CDEV2, TEGRA_MUX_PLLP_OUT4, TEGRA_PUPD_PULL_DOWN, TEGRA_TRI_NORMAL},
{TEGRA_PINGROUP_CRTP, TEGRA_MUX_CRT, TEGRA_PUPD_NORMAL, TEGRA_TRI_TRISTATE},
{TEGRA_PINGROUP_CSUS, TEGRA_MUX_PLLC_OUT1, TEGRA_PUPD_PULL_DOWN, TEGRA_TRI_TRISTATE},
Expand Down Expand Up @@ -143,11 +143,6 @@ static struct tegra_pingroup_config paz00_pinmux[] = {
{TEGRA_PINGROUP_XM2D, TEGRA_MUX_NONE, TEGRA_PUPD_NORMAL, TEGRA_TRI_NORMAL},
};

static struct platform_device *pinmux_devices[] = {
&tegra_gpio_device,
&tegra_pinmux_device,
};

static struct tegra_gpio_table gpio_table[] = {
{ .gpio = TEGRA_GPIO_SD1_CD, .enable = true },
{ .gpio = TEGRA_GPIO_SD1_WP, .enable = true },
Expand All @@ -158,13 +153,14 @@ static struct tegra_gpio_table gpio_table[] = {
{ .gpio = TEGRA_WIFI_LED, .enable = true },
};

static struct tegra_board_pinmux_conf conf = {
.pgs = paz00_pinmux,
.pg_count = ARRAY_SIZE(paz00_pinmux),
.gpios = gpio_table,
.gpio_count = ARRAY_SIZE(gpio_table),
};

void paz00_pinmux_init(void)
{
if (!of_machine_is_compatible("nvidia,tegra20"))
platform_add_devices(pinmux_devices,
ARRAY_SIZE(pinmux_devices));

tegra_pinmux_config_table(paz00_pinmux, ARRAY_SIZE(paz00_pinmux));

tegra_gpio_config(gpio_table, ARRAY_SIZE(gpio_table));
tegra_board_pinmux_init(&conf, NULL);
}
27 changes: 27 additions & 0 deletions arch/arm/mach-tegra/board-paz00.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
#include <linux/serial_8250.h>
#include <linux/clk.h>
#include <linux/dma-mapping.h>
#include <linux/gpio_keys.h>
#include <linux/pda_power.h>
#include <linux/io.h>
#include <linux/input.h>
#include <linux/i2c.h>
#include <linux/gpio.h>
#include <linux/rfkill-gpio.h>
Expand Down Expand Up @@ -115,12 +117,37 @@ static struct platform_device leds_gpio = {
},
};

static struct gpio_keys_button paz00_gpio_keys_buttons[] = {
{
.code = KEY_POWER,
.gpio = TEGRA_GPIO_POWERKEY,
.active_low = 1,
.desc = "Power",
.type = EV_KEY,
.wakeup = 1,
},
};

static struct gpio_keys_platform_data paz00_gpio_keys = {
.buttons = paz00_gpio_keys_buttons,
.nbuttons = ARRAY_SIZE(paz00_gpio_keys_buttons),
};

static struct platform_device gpio_keys_device = {
.name = "gpio-keys",
.id = -1,
.dev = {
.platform_data = &paz00_gpio_keys,
},
};

static struct platform_device *paz00_devices[] __initdata = {
&debug_uart,
&tegra_sdhci_device4,
&tegra_sdhci_device1,
&wifi_rfkill_device,
&leds_gpio,
&gpio_keys_device,
};

static void paz00_i2c_init(void)
Expand Down
3 changes: 3 additions & 0 deletions arch/arm/mach-tegra/board-paz00.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
#define TEGRA_WIFI_RST TEGRA_GPIO_PD1
#define TEGRA_WIFI_LED TEGRA_GPIO_PD0

/* WakeUp */
#define TEGRA_GPIO_POWERKEY TEGRA_GPIO_PJ7

void paz00_pinmux_init(void);

#endif
104 changes: 104 additions & 0 deletions arch/arm/mach-tegra/board-pinmux.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* Copyright (c) 2011, NVIDIA CORPORATION. All rights reserved.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/

#include <linux/device.h>
#include <linux/kernel.h>
#include <linux/notifier.h>
#include <linux/of.h>
#include <linux/string.h>

#include <mach/gpio-tegra.h>
#include <mach/pinmux.h>

#include "board-pinmux.h"
#include "devices.h"

struct tegra_board_pinmux_conf *confs[2];

static void tegra_board_pinmux_setup_gpios(void)
{
int i;

for (i = 0; i < ARRAY_SIZE(confs); i++) {
if (!confs[i])
continue;

tegra_gpio_config(confs[i]->gpios, confs[i]->gpio_count);
}
}

static void tegra_board_pinmux_setup_pinmux(void)
{
int i;

for (i = 0; i < ARRAY_SIZE(confs); i++) {
if (!confs[i])
continue;

tegra_pinmux_config_table(confs[i]->pgs, confs[i]->pg_count);

if (confs[i]->drives)
tegra_drive_pinmux_config_table(confs[i]->drives,
confs[i]->drive_count);
}
}

static int tegra_board_pinmux_bus_notify(struct notifier_block *nb,
unsigned long event, void *vdev)
{
static bool had_gpio;
static bool had_pinmux;

struct device *dev = vdev;
const char *devname;

if (event != BUS_NOTIFY_BOUND_DRIVER)
return NOTIFY_DONE;

devname = dev_name(dev);

if (!had_gpio && !strcmp(devname, GPIO_DEV)) {
tegra_board_pinmux_setup_gpios();
had_gpio = true;
} else if (!had_pinmux && !strcmp(devname, PINMUX_DEV)) {
tegra_board_pinmux_setup_pinmux();
had_pinmux = true;
}

if (had_gpio && had_pinmux)
return NOTIFY_STOP_MASK;
else
return NOTIFY_DONE;
}

static struct notifier_block nb = {
.notifier_call = tegra_board_pinmux_bus_notify,
};

static struct platform_device *devices[] = {
&tegra_gpio_device,
&tegra_pinmux_device,
};

void tegra_board_pinmux_init(struct tegra_board_pinmux_conf *conf_a,
struct tegra_board_pinmux_conf *conf_b)
{
confs[0] = conf_a;
confs[1] = conf_b;

bus_register_notifier(&platform_bus_type, &nb);

if (!of_machine_is_compatible("nvidia,tegra20"))
platform_add_devices(devices, ARRAY_SIZE(devices));
}
38 changes: 38 additions & 0 deletions arch/arm/mach-tegra/board-pinmux.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2011, NVIDIA CORPORATION. All rights reserved.
*
* This software is licensed under the terms of the GNU General Public
* License version 2, as published by the Free Software Foundation, and
* may be copied, distributed, and modified under those terms.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*/

#ifndef __MACH_TEGRA_BOARD_PINMUX_H
#define __MACH_TEGRA_BOARD_PINMUX_H

#define GPIO_DEV "tegra-gpio"
#define PINMUX_DEV "tegra-pinmux"

struct tegra_pingroup_config;
struct tegra_gpio_table;

struct tegra_board_pinmux_conf {
struct tegra_pingroup_config *pgs;
int pg_count;

struct tegra_drive_pingroup_config *drives;
int drive_count;

struct tegra_gpio_table *gpios;
int gpio_count;
};

void tegra_board_pinmux_init(struct tegra_board_pinmux_conf *conf_a,
struct tegra_board_pinmux_conf *conf_b);

#endif
Loading

0 comments on commit 75f7dd8

Please sign in to comment.