From patchwork Mon Aug 17 12:24:10 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Horia_Geant=C4=83?= X-Patchwork-Id: 7024941 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id ABAB3C05AC for ; Mon, 17 Aug 2015 12:24:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 87FE320684 for ; Mon, 17 Aug 2015 12:24:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 48E152064C for ; Mon, 17 Aug 2015 12:24:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752156AbbHQMY3 (ORCPT ); Mon, 17 Aug 2015 08:24:29 -0400 Received: from mail-bn1bon0118.outbound.protection.outlook.com ([157.56.111.118]:35698 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751427AbbHQMY2 (ORCPT ); Mon, 17 Aug 2015 08:24:28 -0400 Received: from CH1PR03CA012.namprd03.prod.outlook.com (10.255.156.157) by BN3PR03MB1398.namprd03.prod.outlook.com (10.163.34.17) with Microsoft SMTP Server (TLS) id 15.1.231.21; Mon, 17 Aug 2015 12:24:26 +0000 Received: from BN1AFFO11FD013.protection.gbl (10.255.156.132) by CH1PR03CA012.outlook.office365.com (10.255.156.157) with Microsoft SMTP Server (TLS) id 15.1.231.21 via Frontend Transport; Mon, 17 Aug 2015 12:24:25 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=freescale.com; pengutronix.de; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of freescale.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 BN1AFFO11FD013.mail.protection.outlook.com (10.58.52.73) with Microsoft SMTP Server (TLS) id 15.1.243.9 via Frontend Transport; Mon, 17 Aug 2015 12:24:25 +0000 Received: from enigma.ea.freescale.net (enigma.ea.freescale.net [10.171.77.120]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id t7HCOMSp018301; Mon, 17 Aug 2015 05:24:23 -0700 From: =?UTF-8?q?Horia=20Geant=C4=83?= To: Herbert Xu CC: , Victoria Milhoan , Alex Porosanu , Steffen Trumtrar Subject: [PATCH] crypto: caam - add support for LS1021A Date: Mon, 17 Aug 2015 15:24:10 +0300 Message-ID: <1439814250-4221-1-git-send-email-horia.geanta@freescale.com> X-Mailer: git-send-email 2.4.4 MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Microsoft-Exchange-Diagnostics: 1; BN1AFFO11FD013; 1:+wb3M1WyUudt1Eamk9jTkK0i8aC4Hs+k5VwBdQpM+bZcIH0NArAV/7xAUPtAKX3sUpkL8OOcETTJjtDkxUJL4BC54VxLkL0Dfi77pOrC2o5J/jYfregpurhJi5NWxywpXrtz4XVfNM2iYzMDCM6DU1o2+5BDPYkrfPTpGLccDXZMaIG1Tw30L4f5Hl+qnNU0u/HARyawPuq904dmgWVWfGzhfusroRqTuHnY5MGV/WNKqG6EuCFBQHLD8TsfdQRxeh5KM7t77H1hu3utoGovJh/n7Jbzo9R2y97vMtZUNllhLF1KgAOLu2QYaJFvQmQkzTuTsArotOhva1WdWMDVAXtfp7uuwCvtC+VvAW50rllFOjDlc3V/MfvFh6gpZ0fDGtqswJOBC9++sPD5B2I/MQ== X-Forefront-Antispam-Report: CIP:192.88.168.50; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10019020)(6009001)(2980300002)(3050300001)(339900001)(199003)(189002)(50226001)(85426001)(36756003)(229853001)(104016003)(64706001)(5820100001)(15975445007)(47776003)(77096005)(92566002)(62966003)(50466002)(19580395003)(23676002)(50986999)(77156002)(6806004)(189998001)(86362001)(19580405001)(68736005)(87936001)(575784001)(33646002)(46102003)(5001860100001)(5001830100001)(81156007)(97736004)(4001540100001)(105606002)(106466001)(110136002)(5001960100002); DIR:OUT; SFP:1102; SCL:1; SRVR:BN3PR03MB1398; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB1398; 2:LKKwdjrGTlWOMOvWx9OdxRJZy0aO690Cl+VP2dRYrLMy+CmgtDrUlQsdueKlv2Zjotu79069k7ti4c6fQHpYNP+hjt8paZ5k1tUcxaJgpWikNG9D17uBpS/kuzuPeoWLLLsmk8En8DM7WLDqC8ulmjn8iI3Q5zr+MZzbE0Z+vOs=; 3:4tqKsYlgAePIivRrIQKlwXjJs1Bkl4K2xzAdhAp6F3bQFNa6jAY9jkICOEuH2w36TIkeZtlOGhIkfW0R3e/7/80Ac3CyaG85bC+GCcfWptxPXe+A4JqF/MUOtlPSx4jIpMd6lCbBsofl08lmZNvZN9MpGJR9JtHCfEUpE/gG7/chy3ArP7okjWWsM2Ewd4ijJbPFTceyyLUXHSXyxUJ1IsxLlTPAGDDBQi6SiZJNeRQ=; 25:FhUO0WlTr6VfoEnlLu2ZWEyXNFVX5GEOGADQ1SCb1Qb8TFRigVDZ/ixG4FGbdV9Dxh6ddZ5/AZmBPCShBmKq6T/YSqGKZeWG41zkeI7LMPqW8XoZwDzMKGivbRCKwE4LUs4VHgpjtKqQzIBGbtAUIutgghlU/jXCOm8H+K6Lgfli4or70VLqVRPPpd+A4Yz3OTagq0fSjcU+FRwzP9cyi5e5sr7/DeS5Thk2XwEePCcUkVt2ZllKQK8y7COZB88ENYrccWFWRofv0x1HjJf7yw== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR03MB1398; X-Microsoft-Exchange-Diagnostics: 1; BN3PR03MB1398; 20:CJAi7fXy5kNgu0zhO9fL/hE4uii3hTyB6rO6qNdLWf2vYj8wozF276gOy8bxna+L0jp1091ORuxAcMcShdExyCW/4+VInEKbYRdIDTR7nS45lu27IJT8lLITwbcAAaT5yoZnuX/Furn+yVqmwdUjrOMFKl9myZjIpcxWH28lXlUC+Izv/Zvi+zXD+ySAJHy+mv0XExvBrNw/3K79Cl+9EEfdd82/YBD5/Gg/AA+QSLLJfpOAkeqE7//BFOPGtPznj72EuF/2JHEVX9jEvfdnqLK88ekciof7GRUezuZ9f3Z7yhpgc7W31MWSUgbRgYG6hSm3M9Ibz8d8X9Zj/HjvV/WR6Wuq+gfRh2fdxGt4mwg=; 4:/VVfXpV/Z9t9lZmQyXJQl3aiDk729j3BneFFqsDTbMgAPRmMCikvVUJ/UKf+8MT6ZJVHOvLAX6mCAlUaCxdRIxpciMUOEpDHrKQtuKLClnJJJV21IbiJkhGAMEp7Tvg+Wbh4h/JZ2aPknF69cD3lrKZwqCPKE+OnUrMUURdSoipHS1UOcbD2BVV0KHBoQwjWa2roxRyzOilBCZiwl3m8X0krmaFtcCAKhYrYT4ugy6VGFXrdjMWIi1wksIk/pkTI+qIVor2191Kdt4uamZ5g3lq9S4E2W0NEGnsUYfme8iMt5tsnvH0qIwNsl9UuzRyE X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(5005006)(8121501046)(3002001); SRVR:BN3PR03MB1398; BCL:0; PCL:0; RULEID:; SRVR:BN3PR03MB1398; X-Forefront-PRVS: 0671F32598 X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTjNQUjAzTUIxMzk4OzIzOlhkSEtJZ1oxVk9MWUd0Sm05Y3NBWWdSUmN3?= =?utf-8?B?TVBZY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A5srUzcRMi/aFbjHtM9w== X-OriginatorOrg: freescale.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Aug 2015 12:24:25.9157 (UTC) X-MS-Exchange-CrossTenant-Id: 710a03f5-10f6-4d38-9ff4-a80b81da590d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=710a03f5-10f6-4d38-9ff4-a80b81da590d; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN3PR03MB1398 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 LS1021A is a QorIQ SoC having little endian CAAM. There are a few differences b/w QorIQ and i.MX from CAAM perspective: 1. i.MX platforms are somewhat special wrt. 64-bit registers: -big endian format at 64-bit level: MSW at address+0 and LSW at address+4 -little endian format at 32-bit level (within MSW and LSW) and thus need special handling. 2. No CCM (clock controller module) for QorIQ. No CAAM clocks to enable / disable. A new Kconfig option - CRYPTO_DEV_FSL_CAAM_LE - is added to indicate CAAM is little endian (*). It is hidden from the user (to avoid misconfiguration); when adding support for a new platform with LE CAAM, either the Kconfig needs to be updated or the corresponding defconfig needs to indicate that CAAM is LE. (*) Using a DT property to provide CAAM endianness would not allow for the ifdeffery. In order to keep changes to a minimum, the following changes are postponed: -endianness fix of the last word in the S/G (rsvd2, bpid, offset), fields are always 0 anyway; -S/G format fix for i.MX7 (yes, i.MX7 support was not added yet, but still...) Signed-off-by: Horia Geant? --- Tested with ls1021_defconfig added by: ARM: configs: Add Freescale LS1021A defconfig https://patchwork.kernel.org/patch/6967421 and with crypto node appended to the DT: ARM: dts: ls1021a: add crypto node https://patchwork.kernel.org/patch/6997561 Also tested that patch does not break i.MX6. drivers/crypto/caam/Kconfig | 8 ++++++++ drivers/crypto/caam/ctrl.c | 4 ++-- drivers/crypto/caam/desc.h | 8 ++++---- drivers/crypto/caam/regs.h | 19 +++++++++++++++---- 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/drivers/crypto/caam/Kconfig b/drivers/crypto/caam/Kconfig index 66ef0c09af73..5652a53415dc 100644 --- a/drivers/crypto/caam/Kconfig +++ b/drivers/crypto/caam/Kconfig @@ -112,6 +112,14 @@ config CRYPTO_DEV_FSL_CAAM_RNG_API To compile this as a module, choose M here: the module will be called caamrng. +config CRYPTO_DEV_FSL_CAAM_IMX + def_bool SOC_IMX6 || SOC_IMX7D + depends on CRYPTO_DEV_FSL_CAAM + +config CRYPTO_DEV_FSL_CAAM_LE + def_bool CRYPTO_DEV_FSL_CAAM_IMX || SOC_LS1021A + depends on CRYPTO_DEV_FSL_CAAM + config CRYPTO_DEV_FSL_CAAM_DEBUG bool "Enable debug output in CAAM driver" depends on CRYPTO_DEV_FSL_CAAM diff --git a/drivers/crypto/caam/ctrl.c b/drivers/crypto/caam/ctrl.c index 4f174ee8a347..81b552d1ad91 100644 --- a/drivers/crypto/caam/ctrl.c +++ b/drivers/crypto/caam/ctrl.c @@ -16,10 +16,10 @@ #include "error.h" /* - * ARM targets tend to have clock control subsystems that can + * i.MX targets tend to have clock control subsystems that can * enable/disable clocking to our device. */ -#ifdef CONFIG_ARM +#ifdef CONFIG_CRYPTO_DEV_FSL_CAAM_IMX static inline struct clk *caam_drv_identify_clk(struct device *dev, char *clk_name) { diff --git a/drivers/crypto/caam/desc.h b/drivers/crypto/caam/desc.h index 405acbf13dac..983d663ef671 100644 --- a/drivers/crypto/caam/desc.h +++ b/drivers/crypto/caam/desc.h @@ -23,12 +23,12 @@ #define SEC4_SG_OFFS_MASK 0x00001fff struct sec4_sg_entry { -#ifdef CONFIG_ARCH_DMA_ADDR_T_64BIT - dma_addr_t ptr; -#else +#ifdef CONFIG_CRYPTO_DEV_FSL_CAAM_IMX u32 rsvd1; dma_addr_t ptr; -#endif +#else + u64 ptr; +#endif /* CONFIG_CRYPTO_DEV_FSL_CAAM_IMX */ u32 len; u8 rsvd2; u8 buf_pool_id; diff --git a/drivers/crypto/caam/regs.h b/drivers/crypto/caam/regs.h index d7c3579af791..a8a79975682f 100644 --- a/drivers/crypto/caam/regs.h +++ b/drivers/crypto/caam/regs.h @@ -108,20 +108,31 @@ /* * The only users of these wr/rd_reg64 functions is the Job Ring (JR). - * The DMA address registers in the JR are a pair of 32-bit registers. - * The layout is: + * The DMA address registers in the JR are handled differently depending on + * platform: + * + * 1. All BE CAAM platforms and i.MX platforms (LE CAAM): * * base + 0x0000 : most-significant 32 bits * base + 0x0004 : least-significant 32 bits * * The 32-bit version of this core therefore has to write to base + 0x0004 - * to set the 32-bit wide DMA address. This seems to be independent of the - * endianness of the written/read data. + * to set the 32-bit wide DMA address. + * + * 2. All other LE CAAM platforms (LS1021A etc.) + * base + 0x0000 : least-significant 32 bits + * base + 0x0004 : most-significant 32 bits */ #ifndef CONFIG_64BIT +#if !defined(CONFIG_CRYPTO_DEV_FSL_CAAM_LE) || \ + defined(CONFIG_CRYPTO_DEV_FSL_CAAM_IMX) #define REG64_MS32(reg) ((u32 __iomem *)(reg)) #define REG64_LS32(reg) ((u32 __iomem *)(reg) + 1) +#else +#define REG64_MS32(reg) ((u32 __iomem *)(reg) + 1) +#define REG64_LS32(reg) ((u32 __iomem *)(reg)) +#endif static inline void wr_reg64(u64 __iomem *reg, u64 data) {