Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 281722
b: refs/heads/master
c: a58116f
h: refs/heads/master
v: v3
  • Loading branch information
Stephen Warren authored and Olof Johansson committed Dec 20, 2011
1 parent 6e5034f commit 318ff80
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 18 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 54862bf00968427cf8f7ffcb6dacf03161eae862
refs/heads/master: a58116f331fd30462b4a7372725e090e1a7d0eb7
14 changes: 7 additions & 7 deletions trunk/arch/arm/mach-tegra/board-dt.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,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 @@ -119,6 +112,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
72 changes: 62 additions & 10 deletions trunk/arch/arm/mach-tegra/board-pinmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,35 @@
*
*/

#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"

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

void tegra_board_pinmux_init(struct tegra_board_pinmux_conf *conf_a,
struct tegra_board_pinmux_conf *conf_b)
static void tegra_board_pinmux_setup_gpios(void)
{
struct tegra_board_pinmux_conf *confs[] = {conf_a, conf_b};
int i;

if (of_machine_is_compatible("nvidia,tegra20"))
platform_add_devices(devices, ARRAY_SIZE(devices));
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])
Expand All @@ -43,10 +51,54 @@ void tegra_board_pinmux_init(struct tegra_board_pinmux_conf *conf_a,
if (confs[i]->drives)
tegra_drive_pinmux_config_table(confs[i]->drives,
confs[i]->drive_count);
}
}

tegra_gpio_config(confs[i]->gpios, confs[i]->gpio_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));
}

0 comments on commit 318ff80

Please sign in to comment.