From patchwork Wed May 4 03:24:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangbo Lu X-Patchwork-Id: 9009241 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.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 1C9489F1C1 for ; Wed, 4 May 2016 03:36:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9257420373 for ; Wed, 4 May 2016 03:36:43 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 2EBF4202FF for ; Wed, 4 May 2016 03:36:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1axnao-0001X3-6v; Wed, 04 May 2016 03:35:18 +0000 Received: from mail-bn1on0085.outbound.protection.outlook.com ([157.56.110.85] helo=na01-bn1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1axnaX-0000GV-FJ for linux-arm-kernel@lists.infradead.org; Wed, 04 May 2016 03:35:05 +0000 Received: from BLUPR0301CA0022.namprd03.prod.outlook.com (10.162.113.160) by CY1PR0301MB1226.namprd03.prod.outlook.com (10.161.212.148) with Microsoft SMTP Server (TLS) id 15.1.485.9; Wed, 4 May 2016 03:34:39 +0000 Received: from BN1BFFO11FD043.protection.gbl (2a01:111:f400:7c10::1:152) by BLUPR0301CA0022.outlook.office365.com (2a01:111:e400:5259::32) with Microsoft SMTP Server (TLS) id 15.1.485.9 via Frontend Transport; Wed, 4 May 2016 03:34:38 +0000 Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none;nxp.com; dmarc=none action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Received: from az84smr01.freescale.net (192.88.158.2) by BN1BFFO11FD043.mail.protection.outlook.com (10.58.144.106) with Microsoft SMTP Server (TLS) id 15.1.485.4 via Frontend Transport; Wed, 4 May 2016 03:34:38 +0000 Received: from titan.ap.freescale.net ([10.192.208.233]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id u443Y8X2009000; Tue, 3 May 2016 20:34:31 -0700 From: Yangbo Lu To: , , , , , , , , Subject: [v9, 3/7] soc: fsl: add GUTS driver for QorIQ platforms Date: Wed, 4 May 2016 11:24:30 +0800 Message-ID: <1462332274-13744-4-git-send-email-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.1.0.27.g96db324 In-Reply-To: <1462332274-13744-1-git-send-email-yangbo.lu@nxp.com> References: <1462332274-13744-1-git-send-email-yangbo.lu@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131068064787466886; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1109001)(1110001)(339900001)(199003)(189002)(2950100001)(76176999)(81166005)(189998001)(551934003)(86362001)(5001770100001)(5008740100001)(575784001)(50986999)(1220700001)(48376002)(33646002)(50466002)(77096005)(36756003)(5003940100001)(2906002)(87936001)(11100500001)(2201001)(586003)(4326007)(229853001)(50226002)(19580395003)(106466001)(19580405001)(105606002)(92566002)(6806005)(85426001)(8936002)(104016004)(47776003)(7059030)(2004002)(2101003)(473944003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB1226; H:az84smr01.freescale.net; FPR:; SPF:Fail; MLV:sfv; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD043; 1:3OVd/ylD68OwXYs+lsojAiK5IS2JCz8n1QqymK3oTDd5IUgTJSedWe6GE25FyU6eoATytGvTVlgJcIKthOoNl6sHWGeYl+VaOuijLX36Ae2/GOU4wts1inpqvPi0K7zNC++LRf4PXD/raTLR8lE7wtwqE14LweHHkcbx6rfG6K0MS20KGHvwaQbwGYhZQIPialZvVW/YL9q1jP6pUpLq5Q44+VvVHpSwh0XLBFZjkhrrXkFP9Y/q0q7pyWi7MG5boefVXZVKdh7e6hBuILIg1HrhPxWVex70Xa/fj2cNK0JGLUHF0Z+ZGNvcPk6HHoo0G5bsli3qCtojwc0Y1yDh+D2v8wEziG8l0dDbwqPnvPclcN5/6U3eirnzO24UJknwilkVhKj8wg6uEzXwEkrEaOIDF++H/lP+rcji/qdqwF3eu2knvLiQMwqjU2rMs4lQiOQyiYt6eBNvj0g+WfiDwmKgqUwM3mDGQEnUReVwuNqD52/T7N/XHsSzKptYMgRMn6JzWrbOAHbVx2+59pERtDSdwiFPPiHVvt29NIX0F+nXQKXS9ehaNU3YDVHfUWNv8hM1OkTKexdwFyGKtbSNKI8Rb5L/HQLJ5kZodisZzJqYUtMmyp+EeIlYMaWoPYLPV7B7/AEYjpyO2KoiTjNJZYrKvYgo2Hk4QTLePm2lgPIvHDdQxh5GW52nBFoPNHF9F4ggZYiA4VYy4gXKNcXbVsNjGfZDtnxBNcdIJgQS3n1sQeQisUX6IqaT4rtswhpa MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: d2ea3be2-cb5b-481b-a925-08d373cd0582 X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1226; 2:n+GRrN1JYe9rONi8JXlDl+34+hr508EwaM6t4LhdAavHdiUURBCW5S21kOp1Ip7bwEczNwjrRsGN+35RrF3h79eGHKRs1b3x+wyXe8VaIfMAFPXhgJK/3CkgcnCOOkY7XAsZ4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YIEDxsj8ykQqqcSM3CMFz70E60FWYjfMqmq/RTz+Tp31tGNsII2sG8x3MAg1Bi13ffW+6f3YIvKrVsrBDkY14E0noaI+Fe8N X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(13018025)(13015025)(13017025)(13024025)(13023025)(5005006)(10201501046)(3002001)(6055026); SRVR:CY1PR0301MB1226; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB1226; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1226; 4:4f0pvmftV8CEklzfMBtAmlGRl9c3gAKgq9nJBr4YGHlLujaGxGbOZhon6HERIzM0CwiwG24xDbduAnqZogM8FMyI5wA2R2pqOXfzmK94CYEQntuGkRnxRMBdbsuamMBJI+KU4etLioD5wC5vNK38upC0wYRkI2/UItFrcHVTV4wzuxQfiM22+L4X0M05Zo5OBnmtqptRXvatZ9aodbk3XoZ4GVs4e2rpRCAg3J3KXzAbYuZzUxqsJjOMB7l1UKAuJ7ATNDAGIfPoD0zoxXCgxgatECuFTYvQzOh14E5p79SUPd3FE/usnnJgGkuxBJqVQyp8I7voi6m740vPKuN8NoPCEdR3I1RwL7PsRWJlyU0zjoZm1z82F3GG6n0OOsQgv+4MYCu9sAnohoAJxDYGVQaYvuG1XgEdFwunC7pxJatSVcTg9bCO4d7pflc6wPHJChxXVC5iD5AxZo9b8//m4kVXvYPVW5u2dITczQ+Yi+U= X-Forefront-PRVS: 093290AD39 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB1226; 23:UR4Q2U0zh6jHlChy6iuHW5hrqSVea2DisQQscDe?= =?us-ascii?Q?rZj54vBm3MUQ8tn4ksBsmPC94MAOklQiUfKXJz+D9DcCQW9KAOxOwKKR6wMv?= =?us-ascii?Q?N2F8D4UYZm7VpICz4oQHAabCrW2Dac4QXhHwuTuL9vilcGfblV6On409i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Rz3urNiCQAYZ3zyYr0SPYYaNOnqc9P5xCLMBCpOy?= =?us-ascii?Q?RpNx7MRXLhTXQWz5uOVX8JsIv0uhqBOnob0vXZFwfVHdliKA3K2zrwBHnMMO?= =?us-ascii?Q?CboL6Uqjoz7We0KGAOEXsOOzVxKoScaZhkJPxFDd9z48NTwt0CzgS7j3y9UJ?= =?us-ascii?Q?AV5Qt3WvJttn1dWs=3D?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1226; 5:5f9veL/Zf8mxiLZg3dHdzCLx1DMMGjUJofTkEF07qBPJKCtjz3bIZUgEEWdVQ3whWQsQzpY/R3VFpgRmUsE9uLQR3pMCWlIiG7CtfdnfVieAXvmS16wvZKWny2yd0hlqxkpVVXhesyiKzZWR9DdD7UQK8TCbsh/HvpXUIp/Ejak=; 24:BAFBvEb+dZASlNNsHUbHdizbhDXmi05v0Nkg/4Cn4J1HJOrSOXqk/ROs4w7LbC6kg2l/PhmSvByPvmTHriL1hkDnehHfNHR6XGgp3FAymJw=; 7:4Yl7lbZ7GjwU76r1wFh1tmBTPvlhi58kXP63DQ+DqDXhEFI+cL72BOsoMnKmX0WDGOqvQbB1td8mRuzJAEjS9ZX8oLA6XvEQZaWnmZc1/zDE3qw3U5HmLWJ0rr/DCx6kBQ1ejeQoOC0DxqLG7R3fE18bPkWvi0uZFqZJnZ+3wKzpwF5G+2RZFjzWdf7CTLHm SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2016 03:34:38.2318 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.158.2]; Helo=[az84smr01.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB1226 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160503_203502_110248_D2B67334 X-CRM114-Status: GOOD ( 22.31 ) X-Spam-Score: -1.9 (-) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , ulf.hansson@linaro.org, Russell King , Yangbo Lu , Bhupesh Sharma , Joerg Roedel , Santosh Shilimkar , Jochen Friedrich , leoyang.li@nxp.com, Scott Wood , Rob Herring , Claudiu Manoil , Kumar Gala , xiaobo.xie@nxp.com, Qiang Zhao 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.2 required=5.0 tests=BAD_ENC_HEADER,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 The global utilities block controls power management, I/O device enabling, power-onreset(POR) configuration monitoring, alternate function selection for multiplexed signals,and clock control. This patch adds GUTS driver to manage and access global utilities block. Signed-off-by: Yangbo Lu Acked-by: Scott Wood --- Changes for v4: - Added this patch Changes for v5: - Modified copyright info - Changed MODULE_LICENSE to GPL - Changed EXPORT_SYMBOL_GPL to EXPORT_SYMBOL - Made FSL_GUTS user-invisible - Added a complete compatible list for GUTS - Stored guts info in file-scope variable - Added mfspr() getting SVR - Redefined GUTS APIs - Called fsl_guts_init rather than using platform driver - Removed useless parentheses - Removed useless 'extern' key words Changes for v6: - Made guts thread safe in fsl_guts_init Changes for v7: - Removed 'ifdef' for function declaration in guts.h Changes for v8: - Fixes lines longer than 80 characters checkpatch issue - Added 'Acked-by: Scott Wood' Changes for v9: - None --- drivers/soc/Kconfig | 2 +- drivers/soc/fsl/Kconfig | 8 +++ drivers/soc/fsl/Makefile | 1 + drivers/soc/fsl/guts.c | 119 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/fsl/guts.h | 126 +++++++++++++++++++++++++++++------------------ 5 files changed, 207 insertions(+), 49 deletions(-) create mode 100644 drivers/soc/fsl/Kconfig create mode 100644 drivers/soc/fsl/guts.c diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig index cb58ef0..7106463 100644 --- a/drivers/soc/Kconfig +++ b/drivers/soc/Kconfig @@ -2,7 +2,7 @@ menu "SOC (System On Chip) specific Drivers" source "drivers/soc/bcm/Kconfig" source "drivers/soc/brcmstb/Kconfig" -source "drivers/soc/fsl/qe/Kconfig" +source "drivers/soc/fsl/Kconfig" source "drivers/soc/mediatek/Kconfig" source "drivers/soc/qcom/Kconfig" source "drivers/soc/rockchip/Kconfig" diff --git a/drivers/soc/fsl/Kconfig b/drivers/soc/fsl/Kconfig new file mode 100644 index 0000000..b313759 --- /dev/null +++ b/drivers/soc/fsl/Kconfig @@ -0,0 +1,8 @@ +# +# Freescale SOC drivers +# + +source "drivers/soc/fsl/qe/Kconfig" + +config FSL_GUTS + bool diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile index 203307f..02afb7f 100644 --- a/drivers/soc/fsl/Makefile +++ b/drivers/soc/fsl/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_QUICC_ENGINE) += qe/ obj-$(CONFIG_CPM) += qe/ +obj-$(CONFIG_FSL_GUTS) += guts.o diff --git a/drivers/soc/fsl/guts.c b/drivers/soc/fsl/guts.c new file mode 100644 index 0000000..fa155e6 --- /dev/null +++ b/drivers/soc/fsl/guts.c @@ -0,0 +1,119 @@ +/* + * Freescale QorIQ Platforms GUTS Driver + * + * Copyright (C) 2016 Freescale Semiconductor, Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#include +#include +#include +#include +#include +#include +#include + +struct guts { + struct ccsr_guts __iomem *regs; + bool little_endian; +}; + +static struct guts *guts; +static DEFINE_MUTEX(guts_lock); + +u32 fsl_guts_get_svr(void) +{ + u32 svr = 0; + + if (!guts || !guts->regs) { +#ifdef CONFIG_PPC + svr = mfspr(SPRN_SVR); +#endif + return svr; + } + + if (guts->little_endian) + svr = ioread32(&guts->regs->svr); + else + svr = ioread32be(&guts->regs->svr); + + return svr; +} +EXPORT_SYMBOL(fsl_guts_get_svr); + +/* + * Table for matching compatible strings, for device tree + * guts node, for Freescale QorIQ SOCs. + */ +static const struct of_device_id guts_of_match[] = { + /* For T4 & B4 Series SOCs */ + { .compatible = "fsl,qoriq-device-config-1.0", }, + /* For P Series SOCs */ + { .compatible = "fsl,qoriq-device-config-2.0", }, + { .compatible = "fsl,p1010-guts", }, + { .compatible = "fsl,p1020-guts", }, + { .compatible = "fsl,p1021-guts", }, + { .compatible = "fsl,p1022-guts", }, + { .compatible = "fsl,p1023-guts", }, + { .compatible = "fsl,p2020-guts", }, + /* For BSC Series SOCs */ + { .compatible = "fsl,bsc9131-guts", }, + { .compatible = "fsl,bsc9132-guts", }, + /* For MPC85xx Series SOCs */ + { .compatible = "fsl,mpc8536-guts", }, + { .compatible = "fsl,mpc8544-guts", }, + { .compatible = "fsl,mpc8548-guts", }, + { .compatible = "fsl,mpc8568-guts", }, + { .compatible = "fsl,mpc8569-guts", }, + { .compatible = "fsl,mpc8572-guts", }, + /* For Layerscape Series SOCs */ + { .compatible = "fsl,ls1021a-dcfg", }, + { .compatible = "fsl,ls1043a-dcfg", }, + { .compatible = "fsl,ls2080a-dcfg", }, + {} +}; + +int fsl_guts_init(void) +{ + struct device_node *np; + int ret; + + mutex_lock(&guts_lock); + /* Initialize guts only once */ + if (guts) { + ret = guts->regs ? 0 : -ENOMEM; + goto out; + } + + np = of_find_matching_node(NULL, guts_of_match); + if (!np) { + ret = -ENODEV; + goto out; + } + + guts = kzalloc(sizeof(*guts), GFP_KERNEL); + if (!guts) { + ret = -ENOMEM; + goto out; + } + + guts->little_endian = of_property_read_bool(np, "little-endian"); + + guts->regs = of_iomap(np, 0); + if (!guts->regs) { + ret = -ENOMEM; + kfree(guts); + goto out; + } + + of_node_put(np); + ret = 0; +out: + mutex_unlock(&guts_lock); + return ret; +} +EXPORT_SYMBOL(fsl_guts_init); diff --git a/include/linux/fsl/guts.h b/include/linux/fsl/guts.h index 649e917..7e1e22b 100644 --- a/include/linux/fsl/guts.h +++ b/include/linux/fsl/guts.h @@ -29,83 +29,113 @@ * #ifdefs. */ struct ccsr_guts { - __be32 porpllsr; /* 0x.0000 - POR PLL Ratio Status Register */ - __be32 porbmsr; /* 0x.0004 - POR Boot Mode Status Register */ - __be32 porimpscr; /* 0x.0008 - POR I/O Impedance Status and Control Register */ - __be32 pordevsr; /* 0x.000c - POR I/O Device Status Register */ - __be32 pordbgmsr; /* 0x.0010 - POR Debug Mode Status Register */ - __be32 pordevsr2; /* 0x.0014 - POR device status register 2 */ + u32 porpllsr; /* 0x.0000 - POR PLL Ratio Status Register */ + u32 porbmsr; /* 0x.0004 - POR Boot Mode Status Register */ + u32 porimpscr; /* 0x.0008 - POR I/O Impedance Status and + * Control Register + */ + u32 pordevsr; /* 0x.000c - POR I/O Device Status Register */ + u32 pordbgmsr; /* 0x.0010 - POR Debug Mode Status Register */ + u32 pordevsr2; /* 0x.0014 - POR device status register 2 */ u8 res018[0x20 - 0x18]; - __be32 porcir; /* 0x.0020 - POR Configuration Information Register */ + u32 porcir; /* 0x.0020 - POR Configuration Information + * Register + */ u8 res024[0x30 - 0x24]; - __be32 gpiocr; /* 0x.0030 - GPIO Control Register */ + u32 gpiocr; /* 0x.0030 - GPIO Control Register */ u8 res034[0x40 - 0x34]; - __be32 gpoutdr; /* 0x.0040 - General-Purpose Output Data Register */ + u32 gpoutdr; /* 0x.0040 - General-Purpose Output Data + * Register + */ u8 res044[0x50 - 0x44]; - __be32 gpindr; /* 0x.0050 - General-Purpose Input Data Register */ + u32 gpindr; /* 0x.0050 - General-Purpose Input Data + * Register + */ u8 res054[0x60 - 0x54]; - __be32 pmuxcr; /* 0x.0060 - Alternate Function Signal Multiplex Control */ - __be32 pmuxcr2; /* 0x.0064 - Alternate function signal multiplex control 2 */ - __be32 dmuxcr; /* 0x.0068 - DMA Mux Control Register */ + u32 pmuxcr; /* 0x.0060 - Alternate Function Signal + * Multiplex Control + */ + u32 pmuxcr2; /* 0x.0064 - Alternate function signal + * multiplex control 2 + */ + u32 dmuxcr; /* 0x.0068 - DMA Mux Control Register */ u8 res06c[0x70 - 0x6c]; - __be32 devdisr; /* 0x.0070 - Device Disable Control */ + u32 devdisr; /* 0x.0070 - Device Disable Control */ #define CCSR_GUTS_DEVDISR_TB1 0x00001000 #define CCSR_GUTS_DEVDISR_TB0 0x00004000 - __be32 devdisr2; /* 0x.0074 - Device Disable Control 2 */ + u32 devdisr2; /* 0x.0074 - Device Disable Control 2 */ u8 res078[0x7c - 0x78]; - __be32 pmjcr; /* 0x.007c - 4 Power Management Jog Control Register */ - __be32 powmgtcsr; /* 0x.0080 - Power Management Status and Control Register */ - __be32 pmrccr; /* 0x.0084 - Power Management Reset Counter Configuration Register */ - __be32 pmpdccr; /* 0x.0088 - Power Management Power Down Counter Configuration Register */ - __be32 pmcdr; /* 0x.008c - 4Power management clock disable register */ - __be32 mcpsumr; /* 0x.0090 - Machine Check Summary Register */ - __be32 rstrscr; /* 0x.0094 - Reset Request Status and Control Register */ - __be32 ectrstcr; /* 0x.0098 - Exception reset control register */ - __be32 autorstsr; /* 0x.009c - Automatic reset status register */ - __be32 pvr; /* 0x.00a0 - Processor Version Register */ - __be32 svr; /* 0x.00a4 - System Version Register */ + u32 pmjcr; /* 0x.007c - 4 Power Management Jog Control + * Register + */ + u32 powmgtcsr; /* 0x.0080 - Power Management Status and + * Control Register + */ + u32 pmrccr; /* 0x.0084 - Power Management Reset Counter + * Configuration Register + */ + u32 pmpdccr; /* 0x.0088 - Power Management Power Down Counter + * Configuration Register + */ + u32 pmcdr; /* 0x.008c - 4Power management clock disable + * register + */ + u32 mcpsumr; /* 0x.0090 - Machine Check Summary Register */ + u32 rstrscr; /* 0x.0094 - Reset Request Status and + * Control Register + */ + u32 ectrstcr; /* 0x.0098 - Exception reset control register */ + u32 autorstsr; /* 0x.009c - Automatic reset status register */ + u32 pvr; /* 0x.00a0 - Processor Version Register */ + u32 svr; /* 0x.00a4 - System Version Register */ u8 res0a8[0xb0 - 0xa8]; - __be32 rstcr; /* 0x.00b0 - Reset Control Register */ + u32 rstcr; /* 0x.00b0 - Reset Control Register */ u8 res0b4[0xc0 - 0xb4]; - __be32 iovselsr; /* 0x.00c0 - I/O voltage select status register + u32 iovselsr; /* 0x.00c0 - I/O voltage select status register Called 'elbcvselcr' on 86xx SOCs */ u8 res0c4[0x100 - 0xc4]; - __be32 rcwsr[16]; /* 0x.0100 - Reset Control Word Status registers + u32 rcwsr[16]; /* 0x.0100 - Reset Control Word Status registers There are 16 registers */ u8 res140[0x224 - 0x140]; - __be32 iodelay1; /* 0x.0224 - IO delay control register 1 */ - __be32 iodelay2; /* 0x.0228 - IO delay control register 2 */ + u32 iodelay1; /* 0x.0224 - IO delay control register 1 */ + u32 iodelay2; /* 0x.0228 - IO delay control register 2 */ u8 res22c[0x604 - 0x22c]; - __be32 pamubypenr; /* 0x.604 - PAMU bypass enable register */ + u32 pamubypenr; /* 0x.604 - PAMU bypass enable register */ u8 res608[0x800 - 0x608]; - __be32 clkdvdr; /* 0x.0800 - Clock Divide Register */ + u32 clkdvdr; /* 0x.0800 - Clock Divide Register */ u8 res804[0x900 - 0x804]; - __be32 ircr; /* 0x.0900 - Infrared Control Register */ + u32 ircr; /* 0x.0900 - Infrared Control Register */ u8 res904[0x908 - 0x904]; - __be32 dmacr; /* 0x.0908 - DMA Control Register */ + u32 dmacr; /* 0x.0908 - DMA Control Register */ u8 res90c[0x914 - 0x90c]; - __be32 elbccr; /* 0x.0914 - eLBC Control Register */ + u32 elbccr; /* 0x.0914 - eLBC Control Register */ u8 res918[0xb20 - 0x918]; - __be32 ddr1clkdr; /* 0x.0b20 - DDR1 Clock Disable Register */ - __be32 ddr2clkdr; /* 0x.0b24 - DDR2 Clock Disable Register */ - __be32 ddrclkdr; /* 0x.0b28 - DDR Clock Disable Register */ + u32 ddr1clkdr; /* 0x.0b20 - DDR1 Clock Disable Register */ + u32 ddr2clkdr; /* 0x.0b24 - DDR2 Clock Disable Register */ + u32 ddrclkdr; /* 0x.0b28 - DDR Clock Disable Register */ u8 resb2c[0xe00 - 0xb2c]; - __be32 clkocr; /* 0x.0e00 - Clock Out Select Register */ + u32 clkocr; /* 0x.0e00 - Clock Out Select Register */ u8 rese04[0xe10 - 0xe04]; - __be32 ddrdllcr; /* 0x.0e10 - DDR DLL Control Register */ + u32 ddrdllcr; /* 0x.0e10 - DDR DLL Control Register */ u8 rese14[0xe20 - 0xe14]; - __be32 lbcdllcr; /* 0x.0e20 - LBC DLL Control Register */ - __be32 cpfor; /* 0x.0e24 - L2 charge pump fuse override register */ + u32 lbcdllcr; /* 0x.0e20 - LBC DLL Control Register */ + u32 cpfor; /* 0x.0e24 - L2 charge pump fuse override + * register + */ u8 rese28[0xf04 - 0xe28]; - __be32 srds1cr0; /* 0x.0f04 - SerDes1 Control Register 0 */ - __be32 srds1cr1; /* 0x.0f08 - SerDes1 Control Register 0 */ + u32 srds1cr0; /* 0x.0f04 - SerDes1 Control Register 0 */ + u32 srds1cr1; /* 0x.0f08 - SerDes1 Control Register 0 */ u8 resf0c[0xf2c - 0xf0c]; - __be32 itcr; /* 0x.0f2c - Internal transaction control register */ + u32 itcr; /* 0x.0f2c - Internal transaction control + * register + */ u8 resf30[0xf40 - 0xf30]; - __be32 srds2cr0; /* 0x.0f40 - SerDes2 Control Register 0 */ - __be32 srds2cr1; /* 0x.0f44 - SerDes2 Control Register 0 */ + u32 srds2cr0; /* 0x.0f40 - SerDes2 Control Register 0 */ + u32 srds2cr1; /* 0x.0f44 - SerDes2 Control Register 0 */ } __attribute__ ((packed)); +u32 fsl_guts_get_svr(void); +int fsl_guts_init(void); /* Alternate function signal multiplex control */ #define MPC85xx_PMUXCR_QE(x) (0x8000 >> (x))