From patchwork Fri Dec 21 12:50:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: poonam aggrwal X-Patchwork-Id: 207808 X-Patchwork-Delegate: afleming@freescale.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id 4C85D2C0094 for ; Sat, 22 Dec 2012 00:09:53 +1100 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E2AFB4A026; Fri, 21 Dec 2012 14:09:25 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Al0VyE08jV29; Fri, 21 Dec 2012 14:09:25 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 748CC4A10D; Fri, 21 Dec 2012 14:08:43 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E87634A0F0 for ; Fri, 21 Dec 2012 14:05:27 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QecaqSgFWww1 for ; Fri, 21 Dec 2012 14:05:27 +0100 (CET) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from co9outboundpool.messaging.microsoft.com (co9ehsobe005.messaging.microsoft.com [207.46.163.28]) by theia.denx.de (Postfix) with ESMTPS id 727A84A0EF for ; Fri, 21 Dec 2012 14:05:25 +0100 (CET) Received: from mail54-co9-R.bigfish.com (10.236.132.229) by CO9EHSOBE007.bigfish.com (10.236.130.70) with Microsoft SMTP Server id 14.1.225.23; Fri, 21 Dec 2012 12:50:17 +0000 Received: from mail54-co9 (localhost [127.0.0.1]) by mail54-co9-R.bigfish.com (Postfix) with ESMTP id 40678C80214 for ; Fri, 21 Dec 2012 12:50:17 +0000 (UTC) X-Forefront-Antispam-Report: CIP:70.37.183.190; KIP:(null); UIP:(null); IPV:NLI; H:mail.freescale.net; RD:none; EFVD:NLI X-SpamScore: 0 X-BigFish: VS0(zzzz1de0h1202h1e76h1d1ah1d2ahzz8275bhz2dh87h2a8h668h839hd24he5bhf0ah107ah11b5h121eh1288h12a5h12a9h12bdh12e5h137ah139eh13b6h1441h14afh1504h1537h162dh1631h1758h1155h) X-FB-DOMAIN-IP-MATCH: fail Received: from mail54-co9 (localhost.localdomain [127.0.0.1]) by mail54-co9 (MessageSwitch) id 1356094214411789_21677; Fri, 21 Dec 2012 12:50:14 +0000 (UTC) Received: from CO9EHSMHS009.bigfish.com (unknown [10.236.132.249]) by mail54-co9.bigfish.com (Postfix) with ESMTP id 592C4900051 for ; Fri, 21 Dec 2012 12:50:14 +0000 (UTC) Received: from mail.freescale.net (70.37.183.190) by CO9EHSMHS009.bigfish.com (10.236.130.19) with Microsoft SMTP Server (TLS) id 14.1.225.23; Fri, 21 Dec 2012 12:50:12 +0000 Received: from az84smr01.freescale.net (10.64.34.197) by 039-SN1MMR1-002.039d.mgd.msft.net (10.84.1.15) with Microsoft SMTP Server (TLS) id 14.2.318.3; Fri, 21 Dec 2012 12:50:08 +0000 Received: from nmglablinux19.freescale.com (nmglablinux19.zin33.ap.freescale.net [10.232.20.241]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id qBLCo698019164; Fri, 21 Dec 2012 05:50:07 -0700 Received: by nmglablinux19.freescale.com (Postfix, from userid 5036) id 4586268097; Fri, 21 Dec 2012 18:20:06 +0530 (IST) From: Poonam Aggrwal To: Date: Fri, 21 Dec 2012 18:20:04 +0530 Message-ID: <1356094204-13062-1-git-send-email-poonam.aggrwal@freescale.com> X-Mailer: git-send-email 1.6.5.6 MIME-Version: 1.0 X-OriginatorOrg: sigmatel.com X-Mailman-Approved-At: Fri, 21 Dec 2012 14:08:39 +0100 Cc: Shaveta Leekha , Poonam Aggrwal , York Sun Subject: [U-Boot] [PATCH 07/09] powerpc/b4860qds: Add support to dump switch settings on b4860qds board X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de From: Shaveta Leekha This function is called by "qixis_reset switch" command and switch settings are calculated from FPGA/qixis registers. Signed-off-by: York Sun Signed-off-by: Shaveta Leekha Signed-off-by: Poonam Aggrwal --- board/freescale/b4860qds/b4860qds.c | 47 +++++++++++++++++++++++++++++++++++ 1 files changed, 47 insertions(+), 0 deletions(-) diff --git a/board/freescale/b4860qds/b4860qds.c b/board/freescale/b4860qds/b4860qds.c index 88bdc1f..3c470db 100644 --- a/board/freescale/b4860qds/b4860qds.c +++ b/board/freescale/b4860qds/b4860qds.c @@ -456,3 +456,50 @@ void ft_board_setup(void *blob, bd_t *bd) fdt_fixup_board_enet(blob); #endif } + +/* + * Dump board switch settings. + * The bits that cannot be read/sampled via some FPGA or some + * registers, they will be displayed as + * underscore in binary format. mask[] has those bits. + * Some bits are calculated differently than the actual switches + * if booting with overriding by FPGA. + */ +void qixis_dump_switch(void) +{ + int i; + u8 sw[5]; + + /* + * Any bit with 1 means that bit cannot be reverse engineered. + * It will be displayed as _ in binary format. + */ + static const u8 mask[] = {0x07, 0, 0, 0xff, 0}; + char buf[10]; + u8 brdcfg[16], dutcfg[16]; + + for (i = 0; i < 16; i++) { + brdcfg[i] = qixis_read(offsetof(struct qixis, brdcfg[0]) + i); + dutcfg[i] = qixis_read(offsetof(struct qixis, dutcfg[0]) + i); + } + + sw[0] = ((brdcfg[0] & 0x0f) << 4) | \ + (brdcfg[9] & 0x08); + sw[1] = ((dutcfg[1] & 0x01) << 7) | \ + ((dutcfg[2] & 0x07) << 4) | \ + ((dutcfg[6] & 0x10) >> 1) | \ + ((dutcfg[6] & 0x80) >> 5) | \ + ((dutcfg[1] & 0x40) >> 5) | \ + (dutcfg[6] & 0x01); + sw[2] = dutcfg[0]; + sw[3] = 0; + sw[4] = ((brdcfg[1] & 0x30) << 2) | \ + ((brdcfg[1] & 0xc0) >> 2) | \ + (brdcfg[1] & 0x0f); + + puts("DIP switch settings:\n"); + for (i = 0; i < 5; i++) { + printf("SW%d = 0b%s (0x%02x)\n", + i + 1, byte_to_binary_mask(sw[i], mask[i], buf), sw[i]); + } +}