From patchwork Fri Jul 1 09:46:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= X-Patchwork-Id: 102886 Return-Path: X-Original-To: incoming-imx@patchwork.ozlabs.org Delivered-To: patchwork-incoming-imx@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 2DD9BB6EE9 for ; Fri, 1 Jul 2011 19:46:59 +1000 (EST) Received: from canuck.infradead.org ([2001:4978:20e::1]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QcaJI-0004Xh-IO; Fri, 01 Jul 2011 09:46:52 +0000 Received: from localhost ([127.0.0.1] helo=canuck.infradead.org) by canuck.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1QcaJI-0003Je-6N; Fri, 01 Jul 2011 09:46:52 +0000 Received: from metis.ext.pengutronix.de ([2001:6f8:1178:4:290:27ff:fe1d:cc33]) by canuck.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1QcaJF-0003JK-0w for linux-arm-kernel@lists.infradead.org; Fri, 01 Jul 2011 09:46:50 +0000 Received: from octopus.hi.pengutronix.de ([2001:6f8:1178:2:215:17ff:fe12:23b0]) by metis.ext.pengutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1QcaJB-0005IS-7g; Fri, 01 Jul 2011 11:46:45 +0200 Received: from ukl by octopus.hi.pengutronix.de with local (Exim 4.76) (envelope-from ) id 1QcaJA-00084y-Aw; Fri, 01 Jul 2011 11:46:44 +0200 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= 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 Message-Id: <1309513594-31016-1-git-send-email-u.kleine-koenig@pengutronix.de> X-Mailer: git-send-email 1.7.5.3 In-Reply-To: <20110701094403.GT11559@pengutronix.de> References: <20110701094403.GT11559@pengutronix.de> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 2001:6f8:1178:2:215:17ff:fe12:23b0 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20110701_054649_513547_A021B3D8 X-CRM114-Status: GOOD ( 24.23 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.3.1 on canuck.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain Cc: Eric Miao , kernel@pengutronix.de, Marek Vasut , Daniel Mack , =?UTF-8?q?Philippe=20R=C3=A9tornaz?= , Valentin Longchamp X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+incoming-imx=patchwork.ozlabs.org@lists.infradead.org List-Id: linux-imx-kernel.lists.patchwork.ozlabs.org This patch unifies handling of baseboards. It allows to use the same parameter name on all boards. Signed-off-by: Uwe Kleine-König --- 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: , 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 + * + * 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 +#include +#include +#include + +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 + * + * 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 + +/** + * 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 */