From patchwork Fri Aug 2 15:51:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Cooper X-Patchwork-Id: 2838086 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id C1A8B9F492 for ; Fri, 2 Aug 2013 17:06:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4C8F520454 for ; Fri, 2 Aug 2013 17:06:09 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A100520452 for ; Fri, 2 Aug 2013 17:06:07 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V5Hg4-0006zR-So; Fri, 02 Aug 2013 15:54:06 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1V5HfJ-0006ro-Mg; Fri, 02 Aug 2013 15:53:17 +0000 Received: from mho-03-ewr.mailhop.org ([204.13.248.66] helo=mho-01-ewr.mailhop.org) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1V5HeK-0006ir-4K for linux-arm-kernel@lists.infradead.org; Fri, 02 Aug 2013 15:52:29 +0000 Received: from pool-72-84-113-162.nrflva.fios.verizon.net ([72.84.113.162] helo=titan) by mho-01-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1V5Hdx-000Lp9-Du; Fri, 02 Aug 2013 15:51:53 +0000 Received: from triton.localdomain (omega.lakedaemon.net [10.16.5.5]) by titan (Postfix) with ESMTP id 7DB4747A215; Fri, 2 Aug 2013 11:51:42 -0400 (EDT) X-Mail-Handler: Dyn Standard SMTP by Dyn X-Originating-IP: 72.84.113.162 X-Report-Abuse-To: abuse@dyndns.com (see http://www.dyndns.com/services/sendlabs/outbound_abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX18E63RJuUt3jl0SoG+0a5ZVo7TDiPEy+pc= From: Jason Cooper To: zonque@gmail.com, nico@fluxnic.net Subject: [RFC PATCH V2 3/9] rename board.c to board-raumfeld.c Date: Fri, 2 Aug 2013 15:51:10 +0000 Message-Id: <31d8fb76052462b837e972828fd312d2f9d91739.1375457714.git.jason@lakedaemon.net> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: References: In-Reply-To: References: <51F2A014.7000209@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130802_115217_091480_645E9307 X-CRM114-Status: GOOD ( 17.21 ) X-Spam-Score: -1.9 (-) Cc: stigge@antcom.de, thomas.petazzoni@free-electrons.com, swarren@nvidia.com, Jason Cooper , devicetree@vger.kernel.org, s.neumann@raumfeld.com, broonie@kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-5.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Jason Cooper --- Makefile | 6 ++- board-raumfeld.c | 153 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ board.c | 153 ------------------------------------------------------- 3 files changed, 158 insertions(+), 154 deletions(-) create mode 100644 board-raumfeld.c delete mode 100644 board.c diff --git a/Makefile b/Makefile index 814326d..bb3a154 100644 --- a/Makefile +++ b/Makefile @@ -6,6 +6,10 @@ LD=$(CROSS_COMPILE)ld LOADADDR=0xa0008000 BINFMT=elf32-littlearm +MFG=raumfeld + +BOARD_OBJ = board-$(MFG).o + COMMON_OBJS = \ main.o \ print.o \ @@ -34,7 +38,7 @@ zimage.o: input/zImage %.o: %.c $(GCC) $(CFLAGS) -c $^ -matcher: $(COMMON_OBJS) board.o $(INPUT_OBJS) +matcher: $(COMMON_OBJS) $(BOARD_OBJ) $(INPUT_OBJS) $(LD) $(LDFLAGS) -T matcher.lds -o $@ $^ matcher.bin: matcher diff --git a/board-raumfeld.c b/board-raumfeld.c new file mode 100644 index 0000000..fe51bcb --- /dev/null +++ b/board-raumfeld.c @@ -0,0 +1,153 @@ +#include "atags.h" +#include "board.h" +#include "print.h" +#include "register.h" +#include "types.h" + +extern __u32 _binary_input_zImage_start; +extern __u32 _binary_input_raumfeld_controller_0_dtb_start; +extern __u32 _binary_input_raumfeld_controller_1_dtb_start; +extern __u32 _binary_input_raumfeld_controller_2_dtb_start; +extern __u32 _binary_input_raumfeld_connector_0_dtb_start; +extern __u32 _binary_input_raumfeld_connector_1_dtb_start; +extern __u32 _binary_input_raumfeld_connector_2_dtb_start; +extern __u32 _binary_input_raumfeld_speaker_0_dtb_start; +extern __u32 _binary_input_raumfeld_speaker_1_dtb_start; +extern __u32 _binary_input_raumfeld_speaker_2_dtb_start; + +static struct board boards[] = { + /* Controller */ + { + .machid = 2413, + .system_rev = 0, + .dtb = &_binary_input_raumfeld_controller_0_dtb_start, + .name = "Raumfeld Controller, revision 0", + }, + { + .machid = 2413, + .system_rev = 1, + .dtb = &_binary_input_raumfeld_controller_1_dtb_start, + .name = "Raumfeld Controller, revision 1", + }, + { + .machid = 2413, + .system_rev = 2, + .dtb = &_binary_input_raumfeld_controller_2_dtb_start, + .name = "Raumfeld Controller, revision 2", + }, + + /* Controller */ + { + .machid = 2414, + .system_rev = 0, + .dtb = &_binary_input_raumfeld_connector_0_dtb_start, + .name = "Raumfeld Connector, revision 0", + }, + { + .machid = 2414, + .system_rev = 1, + .dtb = &_binary_input_raumfeld_connector_1_dtb_start, + .name = "Raumfeld Connector, revision 1", + }, + { + .machid = 2414, + .system_rev = 2, + .dtb = &_binary_input_raumfeld_connector_2_dtb_start, + .name = "Raumfeld Connector, revision 2", + }, + + /* Speaker */ + { + .machid = 2415, + .system_rev = 0, + .dtb = &_binary_input_raumfeld_speaker_0_dtb_start, + .name = "Raumfeld Speaker, revision 0", + }, + { + .machid = 2415, + .system_rev = 1, + .dtb = &_binary_input_raumfeld_speaker_1_dtb_start, + .name = "Raumfeld Speaker, revision 1", + }, + { + .machid = 2415, + .system_rev = 2, + .dtb = &_binary_input_raumfeld_speaker_2_dtb_start, + .name = "Raumfeld Speaker, revision 2", + }, + { 0, 0, NULL, NULL } /* sentinel */ +}; + +static void wait(__u32 ticks) +{ + __u32 v; + + /* OSCR */ + writel(0, 0x40A00010); + + do { + v = readl(0x40A00010); + } while (ticks > v); +} + +static void led_init(void) +{ + writel(0, 0x40e10420); /* GPIO35 */ + writel(0, 0x40e10424); /* GPIO36 */ + writel(0x18, 0x40e00010); /* GPDR1 */ +} + +static void led_set(__u32 index, __u32 state) +{ + __u32 v = 1 << (index ? 3 : 4); + + if (state) + writel(v, 0x40e0001c); + else + writel(v, 0x40e00028); +} + +static void led_panic(void) +{ + int i; + + led_init(); + + for (i = 0;; i++) { + led_set(0, i & 1); + led_set(1, ~i & 1); + wait(500000); + } +} +struct board *match_board(__u32 machid, const struct tag *tags) +{ + const struct tag *t; + struct board *board; + __u32 system_rev = 0; + + /* walk the atags to determine the system revision */ + for_each_tag(t, tags) + switch (t->hdr.tag) { + case ATAG_REVISION: + system_rev = t->u.rev.rev; + break; + } + + + for (board = boards; board->machid; board++) + if (board->machid == machid && board->system_rev == system_rev) + break; + + if (board->compatible == NULL) { + putstr("ERROR MATCHING BOARD!\n"); + putstr("MACHID: 0x"); + printhex(machid); + putstr("\n"); + putstr("SYSTEM_REV: 0x"); + printhex(system_rev); + putstr("\n"); + led_panic(); /* doesn't return */ + } + + return board; +} diff --git a/board.c b/board.c deleted file mode 100644 index fe51bcb..0000000 --- a/board.c +++ /dev/null @@ -1,153 +0,0 @@ -#include "atags.h" -#include "board.h" -#include "print.h" -#include "register.h" -#include "types.h" - -extern __u32 _binary_input_zImage_start; -extern __u32 _binary_input_raumfeld_controller_0_dtb_start; -extern __u32 _binary_input_raumfeld_controller_1_dtb_start; -extern __u32 _binary_input_raumfeld_controller_2_dtb_start; -extern __u32 _binary_input_raumfeld_connector_0_dtb_start; -extern __u32 _binary_input_raumfeld_connector_1_dtb_start; -extern __u32 _binary_input_raumfeld_connector_2_dtb_start; -extern __u32 _binary_input_raumfeld_speaker_0_dtb_start; -extern __u32 _binary_input_raumfeld_speaker_1_dtb_start; -extern __u32 _binary_input_raumfeld_speaker_2_dtb_start; - -static struct board boards[] = { - /* Controller */ - { - .machid = 2413, - .system_rev = 0, - .dtb = &_binary_input_raumfeld_controller_0_dtb_start, - .name = "Raumfeld Controller, revision 0", - }, - { - .machid = 2413, - .system_rev = 1, - .dtb = &_binary_input_raumfeld_controller_1_dtb_start, - .name = "Raumfeld Controller, revision 1", - }, - { - .machid = 2413, - .system_rev = 2, - .dtb = &_binary_input_raumfeld_controller_2_dtb_start, - .name = "Raumfeld Controller, revision 2", - }, - - /* Controller */ - { - .machid = 2414, - .system_rev = 0, - .dtb = &_binary_input_raumfeld_connector_0_dtb_start, - .name = "Raumfeld Connector, revision 0", - }, - { - .machid = 2414, - .system_rev = 1, - .dtb = &_binary_input_raumfeld_connector_1_dtb_start, - .name = "Raumfeld Connector, revision 1", - }, - { - .machid = 2414, - .system_rev = 2, - .dtb = &_binary_input_raumfeld_connector_2_dtb_start, - .name = "Raumfeld Connector, revision 2", - }, - - /* Speaker */ - { - .machid = 2415, - .system_rev = 0, - .dtb = &_binary_input_raumfeld_speaker_0_dtb_start, - .name = "Raumfeld Speaker, revision 0", - }, - { - .machid = 2415, - .system_rev = 1, - .dtb = &_binary_input_raumfeld_speaker_1_dtb_start, - .name = "Raumfeld Speaker, revision 1", - }, - { - .machid = 2415, - .system_rev = 2, - .dtb = &_binary_input_raumfeld_speaker_2_dtb_start, - .name = "Raumfeld Speaker, revision 2", - }, - { 0, 0, NULL, NULL } /* sentinel */ -}; - -static void wait(__u32 ticks) -{ - __u32 v; - - /* OSCR */ - writel(0, 0x40A00010); - - do { - v = readl(0x40A00010); - } while (ticks > v); -} - -static void led_init(void) -{ - writel(0, 0x40e10420); /* GPIO35 */ - writel(0, 0x40e10424); /* GPIO36 */ - writel(0x18, 0x40e00010); /* GPDR1 */ -} - -static void led_set(__u32 index, __u32 state) -{ - __u32 v = 1 << (index ? 3 : 4); - - if (state) - writel(v, 0x40e0001c); - else - writel(v, 0x40e00028); -} - -static void led_panic(void) -{ - int i; - - led_init(); - - for (i = 0;; i++) { - led_set(0, i & 1); - led_set(1, ~i & 1); - wait(500000); - } -} -struct board *match_board(__u32 machid, const struct tag *tags) -{ - const struct tag *t; - struct board *board; - __u32 system_rev = 0; - - /* walk the atags to determine the system revision */ - for_each_tag(t, tags) - switch (t->hdr.tag) { - case ATAG_REVISION: - system_rev = t->u.rev.rev; - break; - } - - - for (board = boards; board->machid; board++) - if (board->machid == machid && board->system_rev == system_rev) - break; - - if (board->compatible == NULL) { - putstr("ERROR MATCHING BOARD!\n"); - putstr("MACHID: 0x"); - printhex(machid); - putstr("\n"); - putstr("SYSTEM_REV: 0x"); - printhex(system_rev); - putstr("\n"); - led_panic(); /* doesn't return */ - } - - return board; -}