All of lore.kernel.org
 help / color / mirror / Atom feed
From: u.kleine-koenig@pengutronix.de (Uwe Kleine-König)
To: linux-arm-kernel@lists.infradead.org
Subject: [RFC PATCH 1/3] ARM: common abstraction for specifying a baseboard
Date: Fri,  1 Jul 2011 11:46:32 +0200	[thread overview]
Message-ID: <1309513594-31016-1-git-send-email-u.kleine-koenig@pengutronix.de> (raw)
In-Reply-To: <20110701094403.GT11559@pengutronix.de>

This patch unifies handling of baseboards. It allows to use the same
parameter name on all boards.

Signed-off-by: Uwe Kleine-K?nig <u.kleine-koenig@pengutronix.de>
---
 Documentation/kernel-parameters.txt |    2 +
 arch/arm/common/Kconfig             |    3 ++
 arch/arm/common/Makefile            |    1 +
 arch/arm/common/baseboard.c         |   58 +++++++++++++++++++++++++++++++++++
 arch/arm/include/asm/baseboard.h    |   31 ++++++++++++++++++
 5 files changed, 95 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/common/baseboard.c
 create mode 100644 arch/arm/include/asm/baseboard.h

diff --git a/Documentation/kernel-parameters.txt b/Documentation/kernel-parameters.txt
index fd248a31..b349a43 100644
--- a/Documentation/kernel-parameters.txt
+++ b/Documentation/kernel-parameters.txt
@@ -373,6 +373,8 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 
 	autotest	[IA64]
 
+	baseboard=	[ARM] Select a baseboard
+
 	baycom_epp=	[HW,AX25]
 			Format: <io>,<mode>
 
diff --git a/arch/arm/common/Kconfig b/arch/arm/common/Kconfig
index 4b71766..c91f7c6 100644
--- a/arch/arm/common/Kconfig
+++ b/arch/arm/common/Kconfig
@@ -39,3 +39,6 @@ config SHARP_PARAM
 
 config SHARP_SCOOP
 	bool
+
+config BASEBOARD
+	bool
diff --git a/arch/arm/common/Makefile b/arch/arm/common/Makefile
index 6ea9b6f..4020be3 100644
--- a/arch/arm/common/Makefile
+++ b/arch/arm/common/Makefile
@@ -17,3 +17,4 @@ obj-$(CONFIG_ARCH_IXP2000)	+= uengine.o
 obj-$(CONFIG_ARCH_IXP23XX)	+= uengine.o
 obj-$(CONFIG_PCI_HOST_ITE8152)  += it8152.o
 obj-$(CONFIG_ARM_TIMER_SP804)	+= timer-sp.o
+obj-$(CONFIG_BASEBOARD)		+= baseboard.o
diff --git a/arch/arm/common/baseboard.c b/arch/arm/common/baseboard.c
new file mode 100644
index 0000000..b2919a7
--- /dev/null
+++ b/arch/arm/common/baseboard.c
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2011 Pengutronix
+ * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation.
+ */
+#include <linux/errno.h>
+#include <linux/init.h>
+#include <linux/string.h>
+#include <asm/baseboard.h>
+
+static const char *baseboard_name __initdata;
+
+/**
+ * baseboard_select - set baseboard name
+ *
+ * @name: name of the board to select
+ */
+int __init baseboard_select(const char *name)
+{
+	baseboard_name = name;
+	return 0;
+}
+__setup("baseboard=", baseboard_select);
+
+/**
+ * baseboard_setup - call initfunc for the board set earlier by baseboard_select
+ *
+ * @map: array of available baseboards, sorted by name
+ * @mapsize: length of array @map
+ */
+int __init baseboard_setup(const struct baseboard_entry *map, size_t mapsize)
+{
+	size_t i;
+	int ret;
+
+	if (!baseboard_name)
+		baseboard_name = "";
+
+	for (i = 0; i < mapsize; ++i) {
+		WARN_ON(i + 1 < mapsize &&
+				strcmp(map[i].name, map[i + 1].name) >= 0);
+
+		ret = strcmp(baseboard_name, map[i].name);
+		if (!ret)
+			return map[i].initfunc(&map[i]);
+
+		if (ret < 0)
+			break;
+	}
+
+	if (*baseboard_name)
+		pr_warn("Unknown baseboard selected\n");
+
+	return -ENOENT;
+}
diff --git a/arch/arm/include/asm/baseboard.h b/arch/arm/include/asm/baseboard.h
new file mode 100644
index 0000000..9e49648
--- /dev/null
+++ b/arch/arm/include/asm/baseboard.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2011 Pengutronix
+ * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de>
+ *
+ * This program is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License version 2 as published by the
+ * Free Software Foundation.
+ */
+#ifndef __ASM_BASEBOARD_H
+#define __ASM_BASEBOARD_H
+
+#include <linux/kernel.h>
+
+/**
+ * struct baseboard_entry
+ *
+ * @name: identifying name used by baseboard_set and baseboard kernel parameter.
+ * @initfunc: function called by baseboard_setup when the corresponding
+ * 	baseboard was selected.
+ * @initdata: callback data for @initfunc.
+ */
+struct baseboard_entry {
+	const char *name;
+	int (*initfunc)(const struct baseboard_entry *);
+	void *initdata;
+};
+
+int baseboard_select(const char *name);
+int baseboard_setup(const struct baseboard_entry *map, size_t mapsize);
+
+#endif /* ifndef __ASM_BASEBOARD_H */
-- 
1.7.5.3

  reply	other threads:[~2011-07-01  9:46 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-01  9:44 [RFC PATCH 0/3] base board consolidation Uwe Kleine-König
2011-07-01  9:46 ` Uwe Kleine-König [this message]
2011-07-01  9:46   ` [RFC PATCH 2/3] ARM: imx/mx31moboard: convert to new baseboard handling Uwe Kleine-König
2011-07-01  9:46   ` [RFC PATCH 3/3] ARM: imx/mx31moboard: remove obsolete " Uwe Kleine-König
2011-07-04  8:19 ` [RFC PATCH 0/3] base board consolidation Philippe Rétornaz
2011-07-04  8:27 ` Russell King - ARM Linux
2011-07-04 10:20   ` Daniel Mack
2011-07-04 10:38     ` Russell King - ARM Linux
2011-07-04 11:55       ` Marek Vasut
2011-07-04 12:33         ` Russell King - ARM Linux

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1309513594-31016-1-git-send-email-u.kleine-koenig@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.