From patchwork Wed Dec 16 01:10:21 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Noam Camus X-Patchwork-Id: 557255 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id B14F31402BF for ; Wed, 16 Dec 2015 12:12:21 +1100 (AEDT) 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 1a90dg-0007uL-6l; Wed, 16 Dec 2015 01:12:20 +0000 Received: from mail-db3on0061.outbound.protection.outlook.com ([157.55.234.61] helo=emea01-db3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1a90dd-0007pL-K0 for linux-snps-arc@lists.infradead.org; Wed, 16 Dec 2015 01:12:18 +0000 Received: from AM3PR02CA0082.eurprd02.prod.outlook.com (10.163.180.50) by DB3PR02MB009.eurprd02.prod.outlook.com (10.242.128.27) with Microsoft SMTP Server (TLS) id 15.1.337.19; Wed, 16 Dec 2015 01:11:54 +0000 Received: from DB3FFO11FD041.protection.gbl (2a01:111:f400:7e04::165) by AM3PR02CA0082.outlook.office365.com (2a01:111:e400:5365::50) with Microsoft SMTP Server (TLS) id 15.1.355.16 via Frontend Transport; Wed, 16 Dec 2015 01:11:53 +0000 Authentication-Results: spf=fail (sender IP is 212.179.42.66) smtp.mailfrom=ezchip.com; linaro.org; dkim=none (message not signed) header.d=none; linaro.org; dmarc=none action=none header.from=ezchip.com; Received-SPF: Fail (protection.outlook.com: domain of ezchip.com does not designate 212.179.42.66 as permitted sender) receiver=protection.outlook.com; client-ip=212.179.42.66; helo=ezex10.ezchip.com; Received: from ezex10.ezchip.com (212.179.42.66) by DB3FFO11FD041.mail.protection.outlook.com (10.47.217.72) with Microsoft SMTP Server (TLS) id 15.1.346.13 via Frontend Transport; Wed, 16 Dec 2015 01:11:53 +0000 Received: from localhost.localdomain (10.1.3.132) by ezex10.ezchip.com (10.1.1.4) with Microsoft SMTP Server (TLS) id 14.3.224.2; Wed, 16 Dec 2015 03:11:30 +0200 From: Noam Camus To: Subject: [PATCH v4 02/19] soc: Support for EZchip SoC Date: Wed, 16 Dec 2015 03:10:21 +0200 Message-ID: <1450228238-4499-3-git-send-email-noamc@ezchip.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1450228238-4499-1-git-send-email-noamc@ezchip.com> References: <1450228238-4499-1-git-send-email-noamc@ezchip.com> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-11.0.0.1191-8.000.1202-22004.003 X-TM-AS-Result: No--15.658800-8.000000-31 X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; DB3FFO11FD041; 1:w+4XffKYXEPaIEenre8+tB9cTNx1v4UYTZXNFs1RRIPEPfkOEn8D938R6Lxvkl9nKqW7pbfK6kRu5Pgcd71ykOr0uO36js4Ai5r7+C9otXWB8qubMZsvtIV5uh27BAFImVzpMXv2G2Tc8CPf0knLo2OOBYEgvbcAF0i4Lz/HTqvi4tXRtaCMYAB7vfF+SPEeIwOiqwzzQ63Ci5etogFmG80SDysKlHg6edozdtGxfN62ZIVzSlY8GMOEGDNKHlO74abvtp+RAmZm22KeS3C4HmM0mdMGm8UG3DPgd4zB53RxqJgEU8iDTPFo0kyqfM7+MAE/yM2vwzGjYYLjMg0N6Bhb8JPQR77a4Auwxa4tqRaWQuHOcgDnhmdT1SJN7FInFOvl6QbVtXXVK/EIlzinJw== X-Forefront-Antispam-Report: CIP:212.179.42.66; CTRY:IL; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(1109001)(1110001)(339900001)(189002)(199003)(104016004)(5001970100001)(107886002)(49486002)(33646002)(50466002)(50226001)(2351001)(50986999)(110136002)(87936001)(189998001)(19580395003)(2950100001)(19580405001)(86362001)(77096005)(1096002)(106466001)(47776003)(85426001)(5003940100001)(229853001)(36756003)(92566002)(6806005)(48376002)(5008740100001)(105606002)(1220700001)(11100500001)(586003)(4001430100002)(76176999)(2004002); DIR:OUT; SFP:1101; SCL:1; SRVR:DB3PR02MB009; H:ezex10.ezchip.com; FPR:; SPF:Fail; PTR:ezmail.ezchip.com; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; DB3PR02MB009; 2:OjdRAv6LMwxI69TViHI7GR4cFY0N0r3eLkbOf06DyvCZcd9K309YcEjUhKb3+bZp0g/wDw6tHU5H30ftqTeuOxk+n4l3T42lsw1bGVw0VpJUJ9ZvtJQ7yTlAckzXd+j5hntMR0wK8loLiE7pmovLHQ==; 3:EGlDd/kOAG0FdmI4UPHbNQ0spAA1O/MmzUUXPYRr6E1BK/aDRszQ2pucdOuqxRBSsPv2M9Fi2CH1EipwLuI9T97q6zbgqgXF7GGiaoQ6QS/Cper+XUo1JoL6s4d/LEtQj3XgYNJC1KoaOsRA8wgTgqILPh0HNhAKEdzvjFVONznYPzBRuPE3CsbleRdpaXAK/mdFdnjKfVtog2w2yk8DUpK+DPLBAHVVDGUOj5HiI8k=; 25:myYD8g7oLDa7QGGP7Whz72cRRJzXO8/BkaFmZLUXfh6uFp7VWG4FmNY1DLVb7g0U19EQz48iaZLi1yNRV5GpI377+2dOYC20OfFJ9W3QMup4x9FfAkZSbOLkWgSM089FBmTFFJTBtSx1V6TyjSZ1G61qaECXx1TfaiX8rPH1S/eap3eawiPjbOBS9orXr8WZX7ittRY1PInr/CCnjESGRc8/GVSC4lC1XTjacVf5lhXjOMBg/wxBzA3jNU0xAdMzaXUvyZe+ZVpmjsZxRSTg8Q==; 20:4xuPxAj5YiVWHI6xdjnaJAu3oxdCZRqTRCxmOFq08Okofd0auD8CcJOm4dsubs6JMfD+JiOvXhsSZoIC4grszccKBuPGSivkpAzirP43CMBqNrCOFTRfJen/cYqp3v8CqhI7sXU360NbNVrhV+Wix5a5ZnxhvWzrC0srEhVjUeQ= X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB3PR02MB009; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(121898900299872); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(2401047)(8121501046)(5005006)(520078)(3002001)(10201501046); SRVR:DB3PR02MB009; BCL:0; PCL:0; RULEID:; SRVR:DB3PR02MB009; X-Microsoft-Exchange-Diagnostics: 1; DB3PR02MB009; 4:kd2zMD+Cb5WcP3dRcLvs6pxHmbmomRSxDD0GU3fVEAaI+TEVsD2R+Qy5LsWcAnY9EbwNxy/hzRsG+l0YEAlAeTaRMoXdawtIU6xx2NSw0PMBvkoT3opgfG4CP/CgaJZs1UeUeOBxvR+Ah/lwUhu4nR0QvQkf+v0HnOZxwqIh1X/9JvOw92PH8julbXri2n+ny1m939dm3DkWjh03ncp5EiHzpzJSMxTyw84qVdpNXeDe0xmueNfMeIg3UshJ6t5Uj8/D0YTI14wNImVyX6VqX7Q9LWOE4JVIwfRtatehQHzNH0IFZsKtqltltMm/ZsWdXd5en0GCOwy6s1qUoS3hb1wx/yzSdnFLsEuY+4OkKzkW2OZNLC/CaCTBfjKLmIoUdSFR2RspNj6vL1V21Sxr0ZN05vJT2/Y0DHxlZ5fL4KrJN4QKMq7vsRdDV3HMFQ8H X-Forefront-PRVS: 0792DBEAD0 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DB3PR02MB009; 23:ar4fJB3sY1eQyULiH8bVEGjA/gbGrXaSBmuskpKmmn?= =?us-ascii?Q?vMhU5M+ysJDfyNBa60AY2wCVWNEMXuqCutzElKD/px4SAL7tXRqgaL5mqXsE?= =?us-ascii?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CmyDmmsg2GFeIJ7ZiEOSNY5B?= =?us-ascii?Q?dNBCfJq90lLnRPv3DUjyH6ew4FLnMPF+1mocRV0ByVNxrb3WuHsKfmMDLn0I?= =?us-ascii?Q?DToAr8cfpexc1lvUSQRFf23m1vAik80zNypHlvFPN/HXkA5UdoZmRCgqlnmF?= =?us-ascii?Q?T0mIs3Eqk=3D?= X-Microsoft-Exchange-Diagnostics: 1; DB3PR02MB009; 5:5llm9DHFWRVBDXMmDrIkKL7racr4J3AsIOhL4qJlfXqN5G9jnY4ocMka+XnAatWi+tG0N56al1n4ghtxLt0BgJmyDXRaMnZcjBNGVUCSGi8bkbgh7AK6IvFQWJQfJqlpwvwkIcj/mt5/tEWd2PBgpw==; 24:h5KspGT799U9m9hhc9SreGzyBghNQoGOqqfzGn4IappCnUvryuJRs4m8+OzdV1VerPQGfaCeDyNiegnpUZ7v5h8iV3I+g/S8ulWVSoa4D0Q= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: ezchip.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Dec 2015 01:11:53.5355 (UTC) X-MS-Exchange-CrossTenant-Id: 0fc16e0a-3cd3-4092-8b2f-0a42cff122c3 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=0fc16e0a-3cd3-4092-8b2f-0a42cff122c3; Ip=[212.179.42.66]; Helo=[ezex10.ezchip.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR02MB009 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151215_171218_138764_A3569884 X-CRM114-Status: GOOD ( 15.50 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [157.55.234.61 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [157.55.234.61 listed in wl.mailspike.net] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: cmetcalf@ezchip.com, daniel.lezcano@linaro.org, Noam Camus , linux-kernel@vger.kernel.org Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Noam Camus This header file is for NPS400 SoC. It includes macros for accessing memory mapped registers. These are functional registers that core can use to configure SoC. Signed-off-by: Noam Camus --- include/soc/nps/common.h | 123 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 123 insertions(+), 0 deletions(-) create mode 100644 include/soc/nps/common.h diff --git a/include/soc/nps/common.h b/include/soc/nps/common.h new file mode 100644 index 0000000..3bc30a8 --- /dev/null +++ b/include/soc/nps/common.h @@ -0,0 +1,123 @@ +/* + * Copyright(c) 2015 EZchip Technologies. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * The full GNU General Public License is included in this distribution in + * the file called "COPYING". + */ + +#ifndef SOC_NPS_COMMON_H +#define SOC_NPS_COMMON_H + +#define NPS_HOST_REG_BASE 0xF6000000 +#define CTOP_INST_MOV2B_FLIP_R3_B1_B2_INST 0x5B60 +#define CTOP_INST_MOV2B_FLIP_R3_B1_B2_LIMM 0x00010422 + +#ifndef __ASSEMBLY__ +/* CPU global ID */ +struct global_id { + union { + struct { +#ifdef CONFIG_EZNPS_MTM_EXT + u32 __reserved:20, cluster:4, core:4, thread:4; +#else + u32 __reserved:24, cluster:4, core:4; +#endif + }; + u32 value; + }; +}; + +/* + * Convert logical to physical CPU IDs + * + * The conversion swap bits 1 and 2 of cluster id (out of 4 bits) + * Now quad of logical clusters id's are adjacent physically, + * and not like the id's physically came with each cluster. + * Below table is 4x4 mesh of core clusters as it layout on chip. + * Cluster ids are in format: logical (physical) + * + * ----------------- ------------------ + * 3 | 5 (3) 7 (7) | | 13 (11) 15 (15)| + * + * 2 | 4 (2) 6 (6) | | 12 (10) 14 (14)| + * ----------------- ------------------ + * 1 | 1 (1) 3 (5) | | 9 (9) 11 (13)| + * + * 0 | 0 (0) 2 (4) | | 8 (8) 10 (12)| + * ----------------- ------------------ + * 0 1 2 3 + */ +static inline int nps_cluster_logic_to_phys(int cluster) +{ + __asm__ __volatile__( + " mov r3,%0\n" + " .short %1\n" + " .word %2\n" + " mov %0,r3\n" + : "+r"(cluster) + : "i"(CTOP_INST_MOV2B_FLIP_R3_B1_B2_INST), + "i"(CTOP_INST_MOV2B_FLIP_R3_B1_B2_LIMM) + : "r3"); + + return cluster; +} + +#define NPS_CPU_TO_CLUSTER_NUM(cpu) \ + ({ struct global_id gid; gid.value = cpu; \ + nps_cluster_logic_to_phys(gid.cluster); }) + +struct nps_host_reg_address { + union { + struct { + u32 base:8, cl_x:4, cl_y:4, + blkid:6, reg:8, __reserved:2; + }; + u32 value; + }; +}; + +struct nps_host_reg_address_non_cl { + union { + struct { + u32 base:7, blkid:11, reg:12, __reserved:2; + }; + u32 value; + }; +}; + +static inline void *nps_host_reg_non_cl(u32 blkid, u32 reg) +{ + struct nps_host_reg_address_non_cl reg_address; + + reg_address.value = NPS_HOST_REG_BASE; + reg_address.blkid = blkid; + reg_address.reg = reg; + + return (void *)reg_address.value; +} + +static inline void *nps_host_reg(u32 cpu, u32 blkid, u32 reg) +{ + struct nps_host_reg_address reg_address; + u32 cl = NPS_CPU_TO_CLUSTER_NUM(cpu); + + reg_address.value = NPS_HOST_REG_BASE; + reg_address.cl_x = (cl >> 2) & 0x3; + reg_address.cl_y = cl & 0x3; + reg_address.blkid = blkid; + reg_address.reg = reg; + + return (void *)reg_address.value; +} +#endif /* __ASSEMBLY__ */ + +#endif /* SOC_NPS_COMMON_H */