From patchwork Fri Oct 28 03:32:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangbo Lu X-Patchwork-Id: 9401047 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CDC5D6022E for ; Fri, 28 Oct 2016 03:49:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B918B2A53E for ; Fri, 28 Oct 2016 03:49:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB9332A542; Fri, 28 Oct 2016 03:49:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAD_ENC_HEADER,BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 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.wl.linuxfoundation.org (Postfix) with ESMTPS id 9421C2A53E for ; Fri, 28 Oct 2016 03:49:42 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bzy96-000884-TG; Fri, 28 Oct 2016 03:47:56 +0000 Received: from mail-by2nam03on0066.outbound.protection.outlook.com ([104.47.42.66] helo=NAM03-BY2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bzy7V-0007FS-I7 for linux-arm-kernel@lists.infradead.org; Fri, 28 Oct 2016 03:46:22 +0000 Received: from BN6PR03CA0001.namprd03.prod.outlook.com (10.168.230.139) by CY1PR0301MB1628.namprd03.prod.outlook.com (10.162.166.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.679.12; Fri, 28 Oct 2016 03:46:01 +0000 Received: from BY2FFO11FD043.protection.gbl (2a01:111:f400:7c0c::151) by BN6PR03CA0001.outlook.office365.com (2603:10b6:404:23::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.679.12 via Frontend Transport; Fri, 28 Oct 2016 03:46:00 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; nxp.com; dkim=none (message not signed) header.d=none; nxp.com; dmarc=fail action=none header.from=nxp.com; nxp.com; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11FD043.mail.protection.outlook.com (10.1.14.228) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.679.5 via Frontend Transport; Fri, 28 Oct 2016 03:45:59 +0000 Received: from titan.ap.freescale.net ([10.192.208.233]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id u9S3jA01026194; Thu, 27 Oct 2016 20:45:52 -0700 From: Yangbo Lu To: , , Scott Wood , Arnd Bergmann Subject: [v13, 5/8] soc: fsl: add GUTS driver for QorIQ platforms Date: Fri, 28 Oct 2016 11:32:31 +0800 Message-ID: <1477625554-46700-6-git-send-email-yangbo.lu@nxp.com> X-Mailer: git-send-email 2.1.0.27.g96db324 In-Reply-To: <1477625554-46700-1-git-send-email-yangbo.lu@nxp.com> References: <1477625554-46700-1-git-send-email-yangbo.lu@nxp.com> X-EOPAttributedMessage: 0 X-Matching-Connectors: 131220999604259507; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(979002)(6009001)(7916002)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(5003940100001)(8936002)(2950100002)(33646002)(106466001)(229853001)(92566002)(19580405001)(50226002)(105606002)(19580395003)(7416002)(68736007)(50986999)(76176999)(6666003)(626004)(97736004)(575784001)(5001770100001)(86362001)(50466002)(48376002)(5660300001)(104016004)(77096005)(4326007)(36756003)(551934003)(8676002)(87936001)(2906002)(85426001)(47776003)(81166006)(81156014)(8666005)(356003)(305945005)(586003)(7846002)(189998001)(7059030)(2004002)(473944003)(414714003)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB1628; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD043; 1:pD8r9tCmIlnxUm0tMlpc/0XjUtQpRtgbg+06o0vscHfILz/g8uvTp4+Ertn7C7NDgkjiPV1+p1IJboS+8Fu0UvFKgzeMp9sS6tgZ7mwlwveglIqnrutNWcRk6jbsONcQ2Esp7OODp4Fb97WrwH2US18nS065iu9zlCz/CZrbQ5RyCgEoJsqamiTSB7T5DcXqiD6XZsD13VMD4QE4V2IVSwySm3mkUyfj9eN/F17J94RB8eVhe+vB4+1ONx84jMlmenZwhy4a+ljaknZ3sXXF/TGJ3M0PJUDXF7aeKmyE5KB740nVPdZXCJ2q/idvCT3zeRNnqCSY+9DcHXZ6LQ56Ndk+gQULGRtsjeBN3vDMfCRssxTbBWczdXdP6+gPHZREyyog3gi4lN8PLfyVKnN32aTXSvJ8Xx6D2C+G0AJA741VlIrwNsCjN86zlHqxpGX7RlVFx0Iqbd2AYsEaFyr4Au4Eia6hCskF3joV6D8nIQwodpBN78rMXVH14ZZ4W8fcxDq07khNINJIgG3gczUrLb1OPQj0NwHhygYqqjL2i9o2DkTibxCZQQ/9MEBuI4bMTaslLDMaIZLgZlWIXPvlW42kem6xT9/UA+txB87srjwBkHL7eROGVzO23xj8iNP0FntXh7rHwplfXP9TKiEsuOCi/tJovaPk4DhPM8nmjKY38SpKkEmzNa0fvOSB2XLX2QOSY7GyXEE6ImL2rh5TGqX1fPaqVbUR7wWU8p2c16UFAaL9/Psa8+tg/dpZEr6q MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: cebd4831-3daa-490c-bfab-08d3fee4eedf X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1628; 2:BuVbN0cJcldOxmIP9GxYOH4+XghRf+XDUBjrUCx7eTxYwThgc51OjoDEN0VngDVqKN5o9l1XDkKd+PUBIIQTEFAMJt2xBsBwg3U9vICmB6CkI7Gma2O6NuwePy10ruDcfQdWGl0e9NlLbl5Q5Y9qxxkt9zb8FTIZPpFOMInSBGx4SDn8sv2fjABULVW451bxqzuzZxlhf/TB/fXS+oSUpg==; 3:kJTkJ6x4RIVyOCvow0fuO0md8Ux0NqEclKy1YeiOMhOoAtkkARK4EogHjdL0quNCMFxLkLJQkSNXv3Z+eV7Y/q8Hm5eyvU8PZOkXT999rwTcRijYN3R3OqBtYtxY2R7gtjD8/DXPZPPn9WA5H8mOKWb9MhM++AMvY/78+Ixci/+KcRsAWRstaDmH9i7gsIzQpFkAxYSUI1Bf81E7bQ3M8CgGZbI1dnG6CHvBSpYNPiSDAMKhmqj9x3Wl3zcuvFkQ X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:CY1PR0301MB1628; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1628; 25:PsE9/YAG0M/UPnohRqQTui6LOkS44uh2D7B2ZJnxIwhRZfYTu5oo9zFk+m583vbITi/FDo4bwJzWxOxaenrhFHAd3et0HxX6SJZ6XO3N0szCv16Z0cUe20Dc6Ii+t7QqyWR8PSRSeE/pU6dpI145admNxyIWIP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dNHI1Ty8mZeh5LdJK0se5TVOaa+7x6EgPCH6Wk9cYB7T8awr29hIWfMNJAaodIDAiSMK3GXkyQqdt9bPQp3Pu0KFiZ7++WY9eqva5YPoocBukgQ6ulLtQxHUJg4gCaxrCjtrZsjSx9Ue4m8ikjXwLtBwDLUfNw1/qaMRKmmPcqPgWt5T0KHJlyGcrOsUo6rbYLwt0OfZ3YCw87r9lm5nHepjNxOauGZsWhM+RB8OECD+vnb4/mcRNFAu8GVk6t0ZArTbvq3EcsJXMrLF1UOawhWwQH3LKe6LSuhI+puPa0OfH7taxBuLRYB/NaMffrWlHIc0NvbFHbP7eXcCxdcEcVLen/Dpuon9OyAF86GoWCGjht5g/5prqXFXj7NuMfis4zh9YIlmzt4uDv/CeMqzxK0lgKCVb2/JtltiJh7bKmngyp5Z6fPDlkEwjyebPmCiKXfk6gX69yvAGpNlNfg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(72170088055959)(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(13015025)(13017025)(13023025)(13018025)(13024025)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:CY1PR0301MB1628; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB1628; X-Forefront-PRVS: 0109D382B0 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB1628; 23:yAJRrzVR6d7bsbmzQMSux6brBDrwt8nfimQ9k4X?= =?us-ascii?Q?Uup5mSacJNzCgcUgyUELpP/lu0Gb3PLUqDiOGesKb6hOlOkbgZhZpLDXVXfc?= =?us-ascii?Q?zQbzL2UYa7irl/Li2Wf8Xry/43Fn1sMc8gHuORXAx5bLP5EIx3yIYA1JmvG5?= =?us-ascii?Q?DkoiKN8Y55azDG6KN33Z95oYMO0YPi1pUaZ9kEU5j/KKlYBIAdK0zV2o2K6Q?= =?us-ascii?Q?QKWZcz8lt3EKWEY15ratsjBWViv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?8NG/HoE90obq9whfKrRSln78QpbtsyC9Ji5Ir9t03tXUEIUskTl+fC7O5sDG?= =?us-ascii?Q?XJeg1KL0tFiQsk+B4lNZ0Ra5w65R/MC2Bz3BImRfNNI/+bmGbrS6dWs2NRxx?= =?us-ascii?Q?WEtThtSKCn1ybSvwZOQtR7bEJIiC6JX/V4nhG1pcR38HW8gQGphcZgM8BY6y?= =?us-ascii?Q?g7I8FDz20OKNMH8ZjiRXHdna9oOS+nQARe/mNlgk5FLN/IxqQL01eJ66FF4+?= =?us-ascii?Q?1Qq9Zir0KnRYNFskXfZJvf9j7fEq61WSpS+a8gXyxaNh6DPBV?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1628; 6:opW3jpM7IYqmZPwYMaFEu8VBzadmcTvgZd3aSDHvWGQCXMu3O9uxjSW69OHLvOaWYBvY2JET/Q5xykS8GDtIdVAJCY/wZxHfkvC/vcJdGdHcNXEyE1GfEp28W6FME8ACQDRADA4grxaRw18sMM0DChqHdjlglzD7yS5WPdygQZj22Rn8NAFrK8n/4I2kMSD8hCVG6AqPHAKfSoUWB9LVH8bTU7PMNrDkn4AVzLqJ2xd1bhfnwfFzSZKICN8n0tCkBg57r5XesQEJvB6oBeqnXtu+nAQu/4/9HDxklhbA4vkzzbzUVfncwqP8sfPEecBy; 5:WGaePIE2THf9CRav6/X8OPwf1l+4yN2n5vWqVQMUBiLMAjPhBVTmsmCo43U0dBG0yXaYrwg+0olCtwYflZQFaSUMh9V4O6ELJgbzsn5c9VqE9uIHj0UuTGnPTPF09pfMPglJfM1u/lC5hetI9UhRurAeIkerQH0bhqog2oItYWjxSPsXdvUbW9EE8gmTgiHL; 24:QRoC5SVi0Hl3jyJLlACWovQyKP+iPB+YPQGMUcivXj+VuOeAJeGUPnq3PmUYN4pTTq2zyhf1rONQ3zKqSd0HVqBvRen5xaEB1AVb+qUprAA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB1628; 7:qBIovMvMs7hzLHwNX4CwdznfMMDTqW3lOfMk2AwfnBS10pRrvb61muC8+cBUb3uzWXJX4nZY12aKtiMduJeopaZKGrd6GVthmNhqIZGio0uN6sT7KDm2dNGDjxUz/PB/w8hQ/bdCk2PX4+WcSRHl+3Ku8vDefAlrMPgqhDzB3Zr+L+vBB4qheEmdmeS0z54AtTrCE4+8UYckJhtZEucprg54urlID6TIzTebOCVyWnw/tAfeGqoJCsTV8kWSDeDugrA2i4ffC6tJyGqAcC7HdhmIR+LBtGF07oLRG7duDBCpl+xsw79x8aJgXCh/WgNfoTFEGigYEOGmvwFJ3Py6bz+mmd5yBdaQ2GWY/PMtXrw= X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Oct 2016 03:45:59.8955 (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.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB1628 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161027_204617_826634_C5017A98 X-CRM114-Status: GOOD ( 22.61 ) 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 , Greg Kroah-Hartman , Xiaobo Xie , Minghuan Lian , linux-i2c@vger.kernel.org, linux-clk@vger.kernel.org, Qiang Zhao , Russell King , Bhupesh Sharma , Joerg Roedel , Jochen Friedrich , Claudiu Manoil , devicetree@vger.kernel.org, Yangbo Lu , Rob Herring , Santosh Shilimkar , linux-arm-kernel@lists.infradead.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Leo Li , iommu@lists.linux-foundation.org, Kumar Gala , linuxppc-dev@lists.ozlabs.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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 a driver to manage and access global utilities block. Initially only reading SVR and registering soc device are supported. Other guts accesses, such as reading RCW, should eventually be moved into this driver as well. Signed-off-by: Yangbo Lu --- 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 Changes for v10: - None Changes for v11: - Changed to platform driver Changes for v12: - Removed "signed-off-by: Scott" - Defined fsl_soc_die_attr struct array instead of soc_device_attribute - Re-designed soc_device_attribute for QorIQ SoC - Other minor fixes Changes for v13: - Rebased - Removed text after 'bool' in Kconfig - Removed ARCH ifdefs - Added more bits for ls1021a mask - Used devm --- drivers/soc/Kconfig | 3 +- drivers/soc/fsl/Kconfig | 18 ++++ drivers/soc/fsl/Makefile | 1 + drivers/soc/fsl/guts.c | 236 +++++++++++++++++++++++++++++++++++++++++++++++ include/linux/fsl/guts.h | 125 +++++++++++++++---------- 5 files changed, 333 insertions(+), 50 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 e6e90e8..f31bceb 100644 --- a/drivers/soc/Kconfig +++ b/drivers/soc/Kconfig @@ -1,8 +1,7 @@ menu "SOC (System On Chip) specific Drivers" source "drivers/soc/bcm/Kconfig" -source "drivers/soc/fsl/qbman/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..7a9fb9b --- /dev/null +++ b/drivers/soc/fsl/Kconfig @@ -0,0 +1,18 @@ +# +# Freescale SOC drivers +# + +source "drivers/soc/fsl/qbman/Kconfig" +source "drivers/soc/fsl/qe/Kconfig" + +config FSL_GUTS + bool + select SOC_BUS + help + 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 driver is to manage and access global utilities block. + Initially only reading SVR and registering soc device are supported. + Other guts accesses, such as reading RCW, should eventually be moved + into this driver as well. diff --git a/drivers/soc/fsl/Makefile b/drivers/soc/fsl/Makefile index 75e1f53..44b3beb 100644 --- a/drivers/soc/fsl/Makefile +++ b/drivers/soc/fsl/Makefile @@ -5,3 +5,4 @@ obj-$(CONFIG_FSL_DPAA) += qbman/ 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..1f356ed --- /dev/null +++ b/drivers/soc/fsl/guts.c @@ -0,0 +1,236 @@ +/* + * 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 +#include +#include + +struct guts { + struct ccsr_guts __iomem *regs; + bool little_endian; +}; + +struct fsl_soc_die_attr { + char *die; + u32 svr; + u32 mask; +}; + +static struct guts *guts; +static struct soc_device_attribute soc_dev_attr; +static struct soc_device *soc_dev; + + +/* SoC die attribute definition for QorIQ platform */ +static const struct fsl_soc_die_attr fsl_soc_die[] = { + /* + * Power Architecture-based SoCs T Series + */ + + /* Die: T4240, SoC: T4240/T4160/T4080 */ + { .die = "T4240", + .svr = 0x82400000, + .mask = 0xfff00000, + }, + /* Die: T1040, SoC: T1040/T1020/T1042/T1022 */ + { .die = "T1040", + .svr = 0x85200000, + .mask = 0xfff00000, + }, + /* Die: T2080, SoC: T2080/T2081 */ + { .die = "T2080", + .svr = 0x85300000, + .mask = 0xfff00000, + }, + /* Die: T1024, SoC: T1024/T1014/T1023/T1013 */ + { .die = "T1024", + .svr = 0x85400000, + .mask = 0xfff00000, + }, + + /* + * ARM-based SoCs LS Series + */ + + /* Die: LS1043A, SoC: LS1043A/LS1023A */ + { .die = "LS1043A", + .svr = 0x87920000, + .mask = 0xffff0000, + }, + /* Die: LS2080A, SoC: LS2080A/LS2040A/LS2085A */ + { .die = "LS2080A", + .svr = 0x87010000, + .mask = 0xff3f0000, + }, + /* Die: LS1088A, SoC: LS1088A/LS1048A/LS1084A/LS1044A */ + { .die = "LS1088A", + .svr = 0x87030000, + .mask = 0xff3f0000, + }, + /* Die: LS1012A, SoC: LS1012A */ + { .die = "LS1012A", + .svr = 0x87040000, + .mask = 0xffff0000, + }, + /* Die: LS1046A, SoC: LS1046A/LS1026A */ + { .die = "LS1046A", + .svr = 0x87070000, + .mask = 0xffff0000, + }, + /* Die: LS2088A, SoC: LS2088A/LS2048A/LS2084A/LS2044A */ + { .die = "LS2088A", + .svr = 0x87090000, + .mask = 0xff3f0000, + }, + /* Die: LS1021A, SoC: LS1021A/LS1020A/LS1022A */ + { .die = "LS1021A", + .svr = 0x87000000, + .mask = 0xfff70000, + }, + { }, +}; + +static const struct fsl_soc_die_attr *fsl_soc_die_match( + u32 svr, const struct fsl_soc_die_attr *matches) +{ + while (matches->svr) { + if (matches->svr == (svr & matches->mask)) + return matches; + matches++; + }; + return NULL; +} + +u32 fsl_guts_get_svr(void) +{ + u32 svr = 0; + + if (!guts || !guts->regs) + 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); + +static int fsl_guts_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct device *dev = &pdev->dev; + const struct fsl_soc_die_attr *soc_die; + const char *machine; + u32 svr; + + /* Initialize guts */ + guts = devm_kzalloc(dev, sizeof(*guts), GFP_KERNEL); + if (!guts) + return -ENOMEM; + + guts->little_endian = of_property_read_bool(np, "little-endian"); + + guts->regs = of_iomap(np, 0); + if (!guts->regs) + return -ENOMEM; + + /* Register soc device */ + machine = of_flat_dt_get_machine_name(); + if (machine) + soc_dev_attr.machine = devm_kstrdup(dev, machine, GFP_KERNEL); + + svr = fsl_guts_get_svr(); + soc_die = fsl_soc_die_match(svr, fsl_soc_die); + if (soc_die) { + soc_dev_attr.family = devm_kasprintf(dev, GFP_KERNEL, + "QorIQ %s", soc_die->die); + } else { + soc_dev_attr.family = devm_kasprintf(dev, GFP_KERNEL, "QorIQ"); + } + soc_dev_attr.soc_id = devm_kasprintf(dev, GFP_KERNEL, + "svr:0x%08x", svr); + soc_dev_attr.revision = devm_kasprintf(dev, GFP_KERNEL, "%d.%d", + SVR_MAJ(svr), SVR_MIN(svr)); + + soc_dev = soc_device_register(&soc_dev_attr); + if (IS_ERR(soc_dev)) + return PTR_ERR(soc_dev); + + pr_info("Machine: %s\n", soc_dev_attr.machine); + pr_info("SoC family: %s\n", soc_dev_attr.family); + pr_info("SoC ID: %s, Revision: %s\n", + soc_dev_attr.soc_id, soc_dev_attr.revision); + return 0; +} + +static int fsl_guts_remove(struct platform_device *dev) +{ + soc_device_unregister(soc_dev); + iounmap(guts->regs); + return 0; +} + +/* + * Table for matching compatible strings, for device tree + * guts node, for Freescale QorIQ SOCs. + */ +static const struct of_device_id fsl_guts_of_match[] = { + { .compatible = "fsl,qoriq-device-config-1.0", }, + { .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", }, + { .compatible = "fsl,bsc9131-guts", }, + { .compatible = "fsl,bsc9132-guts", }, + { .compatible = "fsl,mpc8536-guts", }, + { .compatible = "fsl,mpc8544-guts", }, + { .compatible = "fsl,mpc8548-guts", }, + { .compatible = "fsl,mpc8568-guts", }, + { .compatible = "fsl,mpc8569-guts", }, + { .compatible = "fsl,mpc8572-guts", }, + { .compatible = "fsl,ls1021a-dcfg", }, + { .compatible = "fsl,ls1043a-dcfg", }, + { .compatible = "fsl,ls2080a-dcfg", }, + {} +}; +MODULE_DEVICE_TABLE(of, fsl_guts_of_match); + +static struct platform_driver fsl_guts_driver = { + .driver = { + .name = "fsl-guts", + .of_match_table = fsl_guts_of_match, + }, + .probe = fsl_guts_probe, + .remove = fsl_guts_remove, +}; + +static int __init fsl_guts_init(void) +{ + return platform_driver_register(&fsl_guts_driver); +} +core_initcall(fsl_guts_init); + +static void __exit fsl_guts_exit(void) +{ + platform_driver_unregister(&fsl_guts_driver); +} +module_exit(fsl_guts_exit); diff --git a/include/linux/fsl/guts.h b/include/linux/fsl/guts.h index 649e917..3efa3b8 100644 --- a/include/linux/fsl/guts.h +++ b/include/linux/fsl/guts.h @@ -29,83 +29,112 @@ * #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); /* Alternate function signal multiplex control */ #define MPC85xx_PMUXCR_QE(x) (0x8000 >> (x))