From patchwork Fri May 24 16:26:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 165139 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp3814196ili; Fri, 24 May 2019 09:27:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqx1wPr/yhwTSA9VNhi1ye/jkNPSYJJat61GY0rlo+cbWDSA5IEb+nsLSxxb4shEckX3qT/f X-Received: by 2002:a63:4753:: with SMTP id w19mr33608199pgk.421.1558715261938; Fri, 24 May 2019 09:27:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558715261; cv=none; d=google.com; s=arc-20160816; b=jcY4FWpliEyrYGXmXHdP1cAZwlsjj2dgadtbYjTV+cqBBA1xqOeg4vkWBX7NuGeGvX DoqT1hJtXRloY8ffOB7US2BBgIRdbcX6n8yl3WdRbvQTRCuqN6J6xXy4E0k11naXL24D awfzBOGRf8UdZO30y82Ugbuv+jYRfEeqPTulbn1fSKQR+x9a7uqBpe6QlgNyNylxw8k3 JQLbZeQkTwOoT9EwxpEXKSmJDkQDuwWCO489cbN9c/5vnSj/5TAmHGzfW6X87b6qaeId bX3Txu9cs2WIHRSnT3VPaC5lpf8rW0OWW0xHXnR3VehLZKAB2K041/ZIyziQjWQRbE6w DEvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=OpsVci6NS0D6Bf/3Go8WTx/jss3RyzyovCrA3zpdENw=; b=CSNz8bRm78bzyWSGzshX4i2nxUTpDnqL4KQel+48CqLoA/ZGFOYO/qvM3/uIvfB1w7 yMTe0ivZyW3vwDFuQIOr0MfEBtQIXOP3tZoFcHT705VO5AyUdFbMxxBmmXCwgRuN+qD3 mzaetm1tpXHb4sS9qi7BYjKpXuIoJDICG+OHSb7zDMnZqyl7bEyaBlK7Kpm+Ahv2u0b0 y0pZ/26JF9w3AEoS4prVpMQwIkC7ONP/B0qdrAaF14lyvwjr9wwPvgeuSzGvYq6YCOUX rYrKb/dF8PUbbNkkU5IzMZdcPRgZ78OjsICrZRR6TZgyWZx9sMTBn6L9JRGPq5hOTh7k D6qQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HTvI2d+K; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r69si4906966pgr.120.2019.05.24.09.27.41; Fri, 24 May 2019 09:27:41 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HTvI2d+K; spf=pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390337AbfEXQ1l (ORCPT + 7 others); Fri, 24 May 2019 12:27:41 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:35545 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390354AbfEXQ1l (ORCPT ); Fri, 24 May 2019 12:27:41 -0400 Received: by mail-wr1-f66.google.com with SMTP id m3so10638847wrv.2 for ; Fri, 24 May 2019 09:27:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=OpsVci6NS0D6Bf/3Go8WTx/jss3RyzyovCrA3zpdENw=; b=HTvI2d+KNikWYtCfyv9ErbQwk9U7SN4mNO0FU31r9IcRKjdCFOiEcfX3ljB4rfrA7R yNGT8C22B7n34+vtuGrX0SE/9+OZk7/YSy95mqEufDiSS3QtYDIWRpn06g5wDqHGarzk VuJ8l5PyKvcxzI+r0snAiTATtmCo0eQ1MjuCyGnc2IOntuJCoLmTOVwwxUzP7T+UZ2/w cKka3JVXHe4l873jUF1KaU6L2vm+jRkc1Abj3aOtTx4wDUfleGbOcmdq29+P0kMlfTtZ bnAErkDLh1l1nPQaT/eKmolaXaddGRqUPRn2sgqfrP9tT+UPY2slGZ8DoELeVWsyuHTu +DYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=OpsVci6NS0D6Bf/3Go8WTx/jss3RyzyovCrA3zpdENw=; b=JEaDM/8vE4NA6dHqt0fHmCN4tD8Ja1cEqtNZS5V6FeduYZIphMOlAo91rv5yzlSNDt ecqjhCM5A6JQhvCQcDgp+3e/lSQioYOOeFcWMId0BorZiUSczHF2SFOXKIkSPBVwkWe4 hPWQSyza6URUIvaQL2Yc3kCch521Ce5lYHvaUJfzXJNu7lZgZpIsrdEbROylcZqqE2i5 3/2Mfa+cm3hYF9NLJ1zfwIXU9HeNzpPKADHJ84I+fFlphAFx5Vn1a4miPDdditcSCRc5 QBAfY+kp4LDqjCvfJri4IkYv961uZx69AfzkjGxU4nxqJA0Juz2z+L/lBn3Cg0bz+DPc rNMw== X-Gm-Message-State: APjAAAWuW1fD7GS0q247v7FAHPGpgN0xKTXPBXJiJsxKYlX7DIu53lD0 PUPQFO47IxBgU7LgnRzU18exPw== X-Received: by 2002:adf:edce:: with SMTP id v14mr59665675wro.94.1558715259395; Fri, 24 May 2019 09:27:39 -0700 (PDT) Received: from sudo.home ([2a01:cb1d:112:6f00:2042:d8f2:ded8:fa95]) by smtp.gmail.com with ESMTPSA id l6sm2200320wmi.24.2019.05.24.09.27.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 24 May 2019 09:27:38 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Herbert Xu , Tudor Ambarus , Linus Walleij , Mika Westerberg Subject: [PATCH v2 2/6] crypto: atmel-ecc: add support for ACPI probing on non-AT91 platforms Date: Fri, 24 May 2019 18:26:47 +0200 Message-Id: <20190524162651.28189-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190524162651.28189-1-ard.biesheuvel@linaro.org> References: <20190524162651.28189-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org The Atmel/Microchip EC508A is a I2C device that could be wired into any platform, and is being used on the Linaro/96boards Secure96 mezzanine adapter. This means it could be found on any platform, even on ones that use ACPI enumeration (via PRP0001 devices). So update the code to enable this use case. This involves tweaking the bus rate discovery code to take ACPI probing into account, which records the maximum bus rate as a property of the slave device. For the atmel-ecc code, this means that the effective bus rate should never exceed the maximum rate, unless we are dealing with buggy firmware. Nonetheless, let's just use the existing plumbing to discover the bus rate and keep the existing logic intact. Signed-off-by: Ard Biesheuvel --- drivers/crypto/Kconfig | 1 - drivers/crypto/atmel-ecc.c | 13 ++++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) -- 2.20.1 Reviewed-by: Linus Walleij diff --git a/drivers/crypto/Kconfig b/drivers/crypto/Kconfig index 0af08081e305..97ec8107eeef 100644 --- a/drivers/crypto/Kconfig +++ b/drivers/crypto/Kconfig @@ -522,7 +522,6 @@ config CRYPTO_DEV_ATMEL_SHA config CRYPTO_DEV_ATMEL_ECC tristate "Support for Microchip / Atmel ECC hw accelerator" - depends on ARCH_AT91 || COMPILE_TEST depends on I2C select CRYPTO_ECDH select CRC16 diff --git a/drivers/crypto/atmel-ecc.c b/drivers/crypto/atmel-ecc.c index ba00e4563ca0..5705348f540f 100644 --- a/drivers/crypto/atmel-ecc.c +++ b/drivers/crypto/atmel-ecc.c @@ -657,11 +657,14 @@ static int atmel_ecc_probe(struct i2c_client *client, return -ENODEV; } - ret = of_property_read_u32(client->adapter->dev.of_node, - "clock-frequency", &bus_clk_rate); - if (ret) { - dev_err(dev, "of: failed to read clock-frequency property\n"); - return ret; + clk_rate = i2c_acpi_find_bus_speed(&client->adapter->dev); + if (!clk_rate) { + ret = device_property_read_u32(&client->adapter->dev, + "clock-frequency", &bus_clk_rate); + if (ret) { + dev_err(dev, "failed to read clock-frequency property\n"); + return ret; + } } if (bus_clk_rate > 1000000L) {