Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 54862bf0 authored by Stephen Warren's avatar Stephen Warren Committed by Olof Johansson
Browse files

arm/tegra: Refactor board-*-pinmux.c to share code



This moves the implementation of *_pinmux_init() into a single location.
The board-specific pinmux data is left in each board's own file. This
will allow future changes that set up the pinmux in a more complex
fashion to do so without duplicating that code in each board's pinmux
file.

Signed-off-by: default avatarStephen Warren <swarren@nvidia.com>
Signed-off-by: default avatarOlof Johansson <olof@lixom.net>
parent b49cae59
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
obj-y                                   += board-pinmux.o
obj-y                                   += common.o
obj-y                                   += devices.o
obj-y                                   += io.o
+9 −13
Original line number Diff line number Diff line
@@ -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},
@@ -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	},
@@ -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);
}
+9 −13
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@

#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},
@@ -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 },
@@ -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);
}
+52 −0
Original line number Diff line number Diff line
/*
 * 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/of.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,
};

void tegra_board_pinmux_init(struct tegra_board_pinmux_conf *conf_a,
			     struct tegra_board_pinmux_conf *conf_b)
{
	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_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);

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

	if (!of_machine_is_compatible("nvidia,tegra20"))
		platform_add_devices(devices, ARRAY_SIZE(devices));
}
+38 −0
Original line number Diff line number Diff line
/*
 * 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