From patchwork Fri May 3 21:10:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lothar Rubusch X-Patchwork-Id: 13653423 X-Patchwork-Delegate: herbert@gondor.apana.org.au Received: from mail-lf1-f49.google.com (mail-lf1-f49.google.com [209.85.167.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DAC9C1E4B2; Fri, 3 May 2024 21:11:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714770663; cv=none; b=CoWJ1WHwBU0hysETIXuthPG2gL9/m/dLkMmZNHE29z+77mzVyaZsc2YyTYCt95MncVUN8Fup3zxZ8FcakJ6kkTzTUX3JTRQ6APQDjqbKBu4lRFsQN0iP83nDEvOdyLmmSwhx0cXih4whyFPYev1SNumXg4MRpZ/zh46oFeM2gjE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714770663; c=relaxed/simple; bh=XLdC5qn7NUj7ZNF45m9HMk56tLA1bORESFIZhcKt7pc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=b6GBy603jJq33lvsuwZwr+XqMRhtbmF24mIDJ2ZkY3hGM3nyglv7EXZum4UHSCWMP+Bt6gz0PQ6gcxbKZ+eL7WNHatXiP3w9iXIup3hkmHTizzWo9FhOCVoU0BBEi1peIE5mvv0NUo8FzDQIFKJScwStnwtxQhRbavyflHhhBmA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Tb0ApT9D; arc=none smtp.client-ip=209.85.167.49 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Tb0ApT9D" Received: by mail-lf1-f49.google.com with SMTP id 2adb3069b0e04-518a56cdbcfso120436e87.2; Fri, 03 May 2024 14:11:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714770660; x=1715375460; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=9UWU2Pj2wFPOsyzBavdjQBrnHrxoTktVx14vmK/kvmM=; b=Tb0ApT9D2GtKPGjvqZM3tb+BuLRXRTcYNkkXzYnyhIv+vUT27kjryqnWAcIJD2YfUu 723YrZernzmOkBZCMdFWl5IzghCat1bS9JA781sOA2ghpxb0SbLpqqADk4pMS8AR6C8r BjGegO4zuTlwe3hyDN7RsvqbQo27PQXaAgL5gHI0VeNbhw8EqABEUaCm0MJVFz8ByK9k XZFicStCTVl2uMqCHVyQFGwElU8PSf8LNxFE7lstipMtp4CDjt2wwsL2c2V0ILGZdAqz MsUA6VqVTCoFLZrk2XUd1ByiPamtbTLnfGKnpXttgGO8m72pV+egL1O4lS92NmwZQcdy WaOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714770660; x=1715375460; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9UWU2Pj2wFPOsyzBavdjQBrnHrxoTktVx14vmK/kvmM=; b=R1HbvFY4any+dPgYLlBwew6sW0sP4d5BKy5rO7xKn+HXT4lbEbJJn+EWdfFH2JNT2l FNgy0cfi3N4AWRXwLg0JGeKdf1m/w/YPRJBayatKM8LpTHJ/17jHkGm/DDJ0GypfS5aI PAXQV/FR69NLmEQRZMZAYoGI98cl84n+/R6iRy3PX2uZznHtaHrNOusG6TvrFYJrotJJ R1zG1eVCgLkIPWt+Ts0uUK2dF6Q6hHZQaVQrZSm6mfOHFaFogrze5sj5QNlWqLhRC/n1 4sWW0zneZrORpRZYKZwS1OOuU8VOL/gPplygX79zXwq9R4bvxkS3BgW+eYmlF/2GGHhY 2XVw== X-Forwarded-Encrypted: i=1; AJvYcCWOtH5AQrCPTYLSWdA2zMNBNxvM/9Ea+HmcV1IENdkBwjwyt7k9Xjn4m1K1jd5pF49hzoxOTMlBSOoihGL35/3JIqS/VSniaFlmhIWUEs8s6e1Om7GYnbA0KP9qssGIIHZwGhanuhWHcC6D X-Gm-Message-State: AOJu0YxDS3zygvWVxne/9r0eVpmChz3auDRgxRzq3hAYsE5BlXD3iXoL 1TMaqKLFNXjOfMrPB30+dKBD/qQl4YdiMESNNJYFdCGYFSCuDYqr X-Google-Smtp-Source: AGHT+IHSQxDQ8eUemresl9Z39QyNfJCgSf9VzmanaY47hjqfPs+A4iCrX+xpQtCza2tsN+44zftjvA== X-Received: by 2002:a05:6512:6d5:b0:51f:6ab6:9e5b with SMTP id u21-20020a05651206d500b0051f6ab69e5bmr4280357lff.36.1714770659798; Fri, 03 May 2024 14:10:59 -0700 (PDT) Received: from 58b9ec80ce2f.v.cablecom.net (84-72-156-211.dclient.hispeed.ch. [84.72.156.211]) by smtp.gmail.com with ESMTPSA id jy9-20020a170907762900b00a598646f173sm1475948ejc.191.2024.05.03.14.10.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 14:10:59 -0700 (PDT) From: Lothar Rubusch To: herbert@gondor.apana.org.au, davem@davemloft.net Cc: nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, claudiu.beznea@tuxon.dev, linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, l.rubusch@gmail.com Subject: [PATCH v2 1/4] crypto: atmel-i2c - add missing arg description Date: Fri, 3 May 2024 21:10:51 +0000 Message-Id: <20240503211054.1231-2-l.rubusch@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503211054.1231-1-l.rubusch@gmail.com> References: <20240503211054.1231-1-l.rubusch@gmail.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add missing description for argument hwrng. Signed-off-by: Lothar Rubusch --- drivers/crypto/atmel-i2c.h | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/crypto/atmel-i2c.h b/drivers/crypto/atmel-i2c.h index c0bd429ee..a442b47a4 100644 --- a/drivers/crypto/atmel-i2c.h +++ b/drivers/crypto/atmel-i2c.h @@ -124,6 +124,7 @@ struct atmel_ecc_driver_data { * @wake_token : wake token array of zeros * @wake_token_sz : size in bytes of the wake_token * @tfm_count : number of active crypto transformations on i2c client + * @hwrng : hold the hardware generated rng * * Reads and writes from/to the i2c client are sequential. The first byte * transmitted to the device is treated as the byte size. Any attempt to send From patchwork Fri May 3 21:10:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lothar Rubusch X-Patchwork-Id: 13653424 X-Patchwork-Delegate: herbert@gondor.apana.org.au Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B9042EB1D; Fri, 3 May 2024 21:11:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714770664; cv=none; b=pwC8v3+EZz9YUjqdlANi8snedAAXbT2g+klQDCXc6juOiVaM0vyzQDRgsFr85egcQe92TYDnT9q4p/Z8IVEZAPXjATLNjaZjdeqTsr/xSDJFTIlv6GMs/JKW/DNBrYEVyFPBqGHfiV//bEifOtbKJBkTpO2jyTnhBVGzYe++m7o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714770664; c=relaxed/simple; bh=fT8B95NRJxqic4ZvNvr5JKZtgUDAm//fNrBmj/4//Lg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ov1D74aLAtspvfSff/EZUEVElZsfgb4ua56/9Fb1BLYniwbSaQ6+XmskttfE+RoAEgLIGnggUG9W8+1GHxsCfGIflKLgtMhoGV4dpQypqF8Yc6SQ8mMDBLmsW2erC54kVR2aHh6T1UAVOf+C09YhnH1Q+abc5LHsLkou0oX7Pu4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KUotV8Of; arc=none smtp.client-ip=209.85.218.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KUotV8Of" Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a59a17fcc6bso10832766b.1; Fri, 03 May 2024 14:11:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714770661; x=1715375461; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=HXa9fPa1AxHYExyv0RgoVDFXes46QUKMk33/XZTly4I=; b=KUotV8OfQTg0C/eTfcvIQ9gQnvudHYGJmMB2ZFCmgxAuiTaO1txs3D32d5153Apj9+ 9VHSneigfp8IoetZMOuq8tp4MlqVqqacoh/LZrtF6DkBCSqQSk2/droSUy0NJYzc1icG 2iIroconWnvTGzM4VSGpKue4nbA6y+CPaZ20LWE/b2A3E77MxQqDpYEDvBp98nusHywk /TfgfuDpb/HBrDYtOuIjpd81zcyzFU8FzxdI3JB5WPNtO2V8u9JfpeldT8PslngZIZhE yldpFV0F6lnZnnXgfzZcDr9BLdir0K5BM0E2ZMUwNdByU1JbX7cOaAtyCsrsJ0BlL0qk TKqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714770661; x=1715375461; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HXa9fPa1AxHYExyv0RgoVDFXes46QUKMk33/XZTly4I=; b=lIgUgdKJ4PJa82+AFXGLSe2VznTUPlDyJ2AZ2h2+Yusv+eOFzBggB1DFaWgBur6l27 Vhsu41/f/ySXsMIuzsI/0lQ5+dYlDB34i3Tn3Bc06+eWCn6WZ4foeLE5AP95w1Sm0A1E 58M+Fo5uNktrHYMxZxwDGYVXipG4QuiLtvOkpe6Bg5MkGebOanbz9JE348p9TgIvjNE3 2iNqVBj5J+xVLvnMPZiKyxMWayI8ipOzVi6J/JYgO0NQOe6JHEDEPnTwnhdTlHOHdVo7 AhWlW+ra/gQj0rDe3PB7PzV2qsCAEk2HV4wFruFc8O93H4KmufycINrWtMkItdyWwH8W JEsA== X-Forwarded-Encrypted: i=1; AJvYcCVj26yWpQ6SkxMtmAH0CTw+doPZ9J3J5Y6IdpRqWILHU/aFX2mqKA+zoGXU+Z6X7HDIYQ0bSVsJPLq0xouyZ3vn6DpAtiHWKhbeXAz2fXPcdGm6iOuzah9sRK1WJZc6D/NHbw7vZylyjRIF X-Gm-Message-State: AOJu0YzNrcz4i++vs4im5da1xtRgZgHfIIYX5Y0ZPo1U/5kBDuO8HNwR 5NcQQHR6KGq16nJ/7zEuJzzrWgH8GGykpBEcaK45XdyPHd8gWIE1 X-Google-Smtp-Source: AGHT+IE7qqgvE0fP2T/+O+VL8NFjFrS9LATJ6wFJOuDSRRWMoIk8xtI2DU7KT+zaZLoloRufqZBusg== X-Received: by 2002:a17:907:1109:b0:a59:9f3e:b1ca with SMTP id qu9-20020a170907110900b00a599f3eb1camr953896ejb.55.1714770660765; Fri, 03 May 2024 14:11:00 -0700 (PDT) Received: from 58b9ec80ce2f.v.cablecom.net (84-72-156-211.dclient.hispeed.ch. [84.72.156.211]) by smtp.gmail.com with ESMTPSA id jy9-20020a170907762900b00a598646f173sm1475948ejc.191.2024.05.03.14.10.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 14:11:00 -0700 (PDT) From: Lothar Rubusch To: herbert@gondor.apana.org.au, davem@davemloft.net Cc: nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, claudiu.beznea@tuxon.dev, linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, l.rubusch@gmail.com Subject: [PATCH v2 2/4] crypto: atmel-i2c - rename read function Date: Fri, 3 May 2024 21:10:52 +0000 Message-Id: <20240503211054.1231-3-l.rubusch@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503211054.1231-1-l.rubusch@gmail.com> References: <20240503211054.1231-1-l.rubusch@gmail.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Make the memory read function name more specific to the read memory zone. The Atmel SHA204 chips provide config, otp and data zone. The implemented read function in fact only reads some fields in zone config. The function renaming allows for a uniform naming scheme when reading from other memory zones. Signed-off-by: Lothar Rubusch --- drivers/crypto/atmel-i2c.c | 6 +++--- drivers/crypto/atmel-i2c.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/crypto/atmel-i2c.c b/drivers/crypto/atmel-i2c.c index 83a9093ef..a0d0d4f2a 100644 --- a/drivers/crypto/atmel-i2c.c +++ b/drivers/crypto/atmel-i2c.c @@ -51,7 +51,7 @@ static void atmel_i2c_checksum(struct atmel_i2c_cmd *cmd) *__crc16 = cpu_to_le16(bitrev16(crc16(0, data, len))); } -void atmel_i2c_init_read_cmd(struct atmel_i2c_cmd *cmd) +void atmel_i2c_init_read_config_cmd(struct atmel_i2c_cmd *cmd) { cmd->word_addr = COMMAND; cmd->opcode = OPCODE_READ; @@ -68,7 +68,7 @@ void atmel_i2c_init_read_cmd(struct atmel_i2c_cmd *cmd) cmd->msecs = MAX_EXEC_TIME_READ; cmd->rxsize = READ_RSP_SIZE; } -EXPORT_SYMBOL(atmel_i2c_init_read_cmd); +EXPORT_SYMBOL(atmel_i2c_init_read_config_cmd); void atmel_i2c_init_random_cmd(struct atmel_i2c_cmd *cmd) { @@ -301,7 +301,7 @@ static int device_sanity_check(struct i2c_client *client) if (!cmd) return -ENOMEM; - atmel_i2c_init_read_cmd(cmd); + atmel_i2c_init_read_config_cmd(cmd); ret = atmel_i2c_send_receive(client, cmd); if (ret) diff --git a/drivers/crypto/atmel-i2c.h b/drivers/crypto/atmel-i2c.h index a442b47a4..275297a82 100644 --- a/drivers/crypto/atmel-i2c.h +++ b/drivers/crypto/atmel-i2c.h @@ -178,7 +178,7 @@ void atmel_i2c_flush_queue(void); int atmel_i2c_send_receive(struct i2c_client *client, struct atmel_i2c_cmd *cmd); -void atmel_i2c_init_read_cmd(struct atmel_i2c_cmd *cmd); +void atmel_i2c_init_read_config_cmd(struct atmel_i2c_cmd *cmd); void atmel_i2c_init_random_cmd(struct atmel_i2c_cmd *cmd); void atmel_i2c_init_genkey_cmd(struct atmel_i2c_cmd *cmd, u16 keyid); int atmel_i2c_init_ecdh_cmd(struct atmel_i2c_cmd *cmd, From patchwork Fri May 3 21:10:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lothar Rubusch X-Patchwork-Id: 13653425 X-Patchwork-Delegate: herbert@gondor.apana.org.au Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C257841C92; Fri, 3 May 2024 21:11:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714770665; cv=none; b=LxrOaYp8hpZQjTuFZ8IvQjRc8+nc2GLtcn7LSbnYRaIOLhRPvHTZ6hqMHXyQ+8U8IKoFlNG5DmL6rU+Lvxqa0RxIl9DEMrrudMCiUguwIMNbA8IwQZNuHYSZIt2b+U+ptx/cgYyCmyDZmjfOWBPH6YctDSW7QVXOD5vzOvUJJec= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714770665; c=relaxed/simple; bh=EM2kQIWp7A2DBI7dldPxTG7tiHmQrcc+lqxRDW/TXW0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ECFXBkhLFimfQZFCWh0pceA8tw7K9egzNLcFm6cLK1+13SOYYYPO4qhaQtlj8vhOPOFgH0Kr/k+amlofyrviilsJHnXqAfoTi+DgnPOH79yCDNbhYaMX3zt/SiEp5yScyPKcdtNQ9ckq2uesvMI6Rzi8MEpdNU17z7bH2NEIxN8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=flKj0Dom; arc=none smtp.client-ip=209.85.167.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="flKj0Dom" Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-51f60817e34so81499e87.2; Fri, 03 May 2024 14:11:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714770662; x=1715375462; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nL9kJ3wI1BHKgVHcnOLEHEX6FzjxHvxmkut4qqZfeuQ=; b=flKj0DomZiOmQ2Ni3svUK+Ou8qX8zATnNEq0xivnWquOLkyOLAWYyRWzUH8XztAVIR IAPtwfuGiAYvfLLMHUx9uqdRYTwRj5eX7Pq4wCWuXSW3elW9X3oLmJTPO+hf5tCQSuvt DGDgRvVWsXLelslqXaRyX9U2xjAZCUkpiOjvFy+DW9uf5yDlZtJt8W2B0MM7nmEpVS1e ny3ItwMyDNCcvpMmlftOJUOzCNeTNCH7fth2aCi01mWSv6FklRVjJTKwHAJ4qMOXFEdU CRSuV+QGadipq/HrBPmjfiI7UDlM9PPBb207RVWmfxUlmu1HN5rySPKHYeV1wuHaTNQD WC5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714770662; x=1715375462; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nL9kJ3wI1BHKgVHcnOLEHEX6FzjxHvxmkut4qqZfeuQ=; b=YMANR/B7uPKNxF9gSNDcROjXv/c8XQew2ekM6qvNnUhgy8VcF66hrKc1SArMLNNwgv 2sPL7H+Y7dVUKKS8RFJ6t0uKf9kALnsJbKCeAeNaRcKgAgXjLukMkx69SoxxzGKz6vD0 d8rcxgh8GR5DXnx7zOR8ph6T7gW5cj9VgQjERrplZBFj4lKMPNl8HpARSguWOY12iqH4 tkjAzsz+VzZGygfzf7gV9LTFJGrrQC9ynFYfxOuZAdF38pHYG/+ZH0KSiRQ2WT1/B4Be 0zIqHHcTNlsfiqM7EOvovqSTpF9v/6DRPHDqwk/dP/B9od0Oo7ucCu69hizhZBkVg7bN sjLQ== X-Forwarded-Encrypted: i=1; AJvYcCW8EThZtPS5qqB+TabSBtQRRvHyA22H1fBHBRhnI2w5hdOCqocrZlUVHYG/Q7wXiP1n6F7fEILxDQ90Zp6mT2KUznwedd899nWhgyWzEmgQZe4QqZ2NuKcRnOkknNvPW7yMfyfXf4oLPMT+ X-Gm-Message-State: AOJu0YxOsdWGDIXcX1FAfYhi/6T9eQ9neAFdBkv5pPv7cCOFvzDWUNyP 5jKRBH07r4XDfHv/R1+aAZiEoWaARC51R7rNHTpuqr8ZVoldaTqa X-Google-Smtp-Source: AGHT+IGu3BjGOP7NuDBPEDOHCG5GXD+7VSwqemrg8eHk9tYcT2FHfx4XMsLrtjU+TYEpyjHmwNoEkw== X-Received: by 2002:a05:6512:2205:b0:51f:2709:3641 with SMTP id h5-20020a056512220500b0051f27093641mr2984635lfu.26.1714770662041; Fri, 03 May 2024 14:11:02 -0700 (PDT) Received: from 58b9ec80ce2f.v.cablecom.net (84-72-156-211.dclient.hispeed.ch. [84.72.156.211]) by smtp.gmail.com with ESMTPSA id jy9-20020a170907762900b00a598646f173sm1475948ejc.191.2024.05.03.14.11.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 14:11:01 -0700 (PDT) From: Lothar Rubusch To: herbert@gondor.apana.org.au, davem@davemloft.net Cc: nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, claudiu.beznea@tuxon.dev, linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, l.rubusch@gmail.com Subject: [PATCH v2 3/4] crypto: atmel-sha204a - add reading from otp zone Date: Fri, 3 May 2024 21:10:53 +0000 Message-Id: <20240503211054.1231-4-l.rubusch@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503211054.1231-1-l.rubusch@gmail.com> References: <20240503211054.1231-1-l.rubusch@gmail.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Provide a read function reading the otp zone. The otp zone can be used for storing serial numbers. The otp zone, as also data zone, are only accessible if the chip was locked before. Locking the chip is a post production customization and has to be done manually i.e. not by this driver. Without this step the chip is pretty much not usable, where putting or not putting data into the otp zone is optional. Signed-off-by: Lothar Rubusch --- drivers/crypto/atmel-i2c.c | 24 ++++++++++++++++++++++++ drivers/crypto/atmel-i2c.h | 5 +++++ drivers/crypto/atmel-sha204a.c | 23 +++++++++++++++++++++++ 3 files changed, 52 insertions(+) diff --git a/drivers/crypto/atmel-i2c.c b/drivers/crypto/atmel-i2c.c index a0d0d4f2a..a895e4289 100644 --- a/drivers/crypto/atmel-i2c.c +++ b/drivers/crypto/atmel-i2c.c @@ -70,6 +70,30 @@ void atmel_i2c_init_read_config_cmd(struct atmel_i2c_cmd *cmd) } EXPORT_SYMBOL(atmel_i2c_init_read_config_cmd); +int atmel_i2c_init_read_otp_cmd(struct atmel_i2c_cmd *cmd, u16 addr) +{ + if (addr < 0 || addr > OTP_ZONE_SIZE) + return -1; + + cmd->word_addr = COMMAND; + cmd->opcode = OPCODE_READ; + /* + * Read the word from OTP zone that may contain e.g. serial + * numbers or similar if persistently pre-initialized and locked + */ + cmd->param1 = OTP_ZONE; + cmd->param2 = cpu_to_le16(addr); + cmd->count = READ_COUNT; + + atmel_i2c_checksum(cmd); + + cmd->msecs = MAX_EXEC_TIME_READ; + cmd->rxsize = READ_RSP_SIZE; + + return 0; +} +EXPORT_SYMBOL(atmel_i2c_init_read_otp_cmd); + void atmel_i2c_init_random_cmd(struct atmel_i2c_cmd *cmd) { cmd->word_addr = COMMAND; diff --git a/drivers/crypto/atmel-i2c.h b/drivers/crypto/atmel-i2c.h index 275297a82..72f04c156 100644 --- a/drivers/crypto/atmel-i2c.h +++ b/drivers/crypto/atmel-i2c.h @@ -64,6 +64,10 @@ struct atmel_i2c_cmd { /* Definitions for eeprom organization */ #define CONFIGURATION_ZONE 0 +#define OTP_ZONE 1 + +/* Definitions for eeprom zone sizes */ +#define OTP_ZONE_SIZE 64 /* Definitions for Indexes common to all commands */ #define RSP_DATA_IDX 1 /* buffer index of data in response */ @@ -179,6 +183,7 @@ void atmel_i2c_flush_queue(void); int atmel_i2c_send_receive(struct i2c_client *client, struct atmel_i2c_cmd *cmd); void atmel_i2c_init_read_config_cmd(struct atmel_i2c_cmd *cmd); +int atmel_i2c_init_read_otp_cmd(struct atmel_i2c_cmd *cmd, u16 addr); void atmel_i2c_init_random_cmd(struct atmel_i2c_cmd *cmd); void atmel_i2c_init_genkey_cmd(struct atmel_i2c_cmd *cmd, u16 keyid); int atmel_i2c_init_ecdh_cmd(struct atmel_i2c_cmd *cmd, diff --git a/drivers/crypto/atmel-sha204a.c b/drivers/crypto/atmel-sha204a.c index c77f482d2..563a0493b 100644 --- a/drivers/crypto/atmel-sha204a.c +++ b/drivers/crypto/atmel-sha204a.c @@ -91,6 +91,29 @@ static int atmel_sha204a_rng_read(struct hwrng *rng, void *data, size_t max, return max; } +static int atmel_sha204a_otp_read(struct i2c_client *client, u16 addr, u8 *otp) +{ + struct atmel_i2c_cmd cmd; + int ret = -1; + + if (atmel_i2c_init_read_otp_cmd(&cmd, addr) < 0) { + dev_err(&client->dev, "failed, invalid otp address %04X\n", + addr); + return ret; + } + + ret = atmel_i2c_send_receive(client, &cmd); + + if (cmd.data[0] == 0xff) { + dev_err(&client->dev, "failed, device not ready\n"); + return -ret; + } + + memcpy(otp, cmd.data+1, 4); + + return ret; +} + static int atmel_sha204a_probe(struct i2c_client *client) { struct atmel_i2c_client_priv *i2c_priv; From patchwork Fri May 3 21:10:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lothar Rubusch X-Patchwork-Id: 13653426 X-Patchwork-Delegate: herbert@gondor.apana.org.au Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A4FA84CDE0; Fri, 3 May 2024 21:11:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714770666; cv=none; b=loHxHegscyesY+Eq1CJwDAeVgLAN2HbY4XCQEET/uH0ePLuZdaa5jqQgo8xklIoqmcY2LffgombhvAq283uvyTLytcMaUM5K+FA6LPrV4V0a0TOPW53ZENyox4ZOZe+HpLP0DyTPu7q6IOiCjBZ9cZix42woZdRCQVFSDerlQEQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714770666; c=relaxed/simple; bh=/ytmHdvFHRgBzTtgyEnBN+dR5abXDd4ZX2hL9w20UK0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=m36kJPVRx6vh/GnZ7j14A4OAtNi+kz+EbGcGzbmc4eysR3lTtBdbzp1EOiL3GAccM7523NEW1s6/NQVCUnBRvcXp+yymVi1qrtRHCWWoJ898WPjEhkG03cFpUN17V+VuO6KgJ77i4N00DcQNcZAl1fs5y9jSDWuCdM1HlCxECsA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NHTYllCk; arc=none smtp.client-ip=209.85.218.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NHTYllCk" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a599c55055dso11897766b.0; Fri, 03 May 2024 14:11:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1714770663; x=1715375463; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=w9qQDpvAvfKRu8qLDslBuxd5B2UXk46RBnF6wvfi1D4=; b=NHTYllCkiQGDQNnk6P6mdGNZxjCGeKfucavWm2kRj5f+GRKfbge3SfXS0H1d6iPkkd QBY4aD2qTjBy03ioPFXT+LzARfmKnchVltQ9WKD6Ne0HB3UydtkFJtKB2RiPFQOkcaLn eX+/fqnhzrBgtLrbajQmcr5J0Wu10rJmLZVrVK8HA5upMh+elgpFcPCAe7vVq33ESlOk QG8B6ZiWhfCoXx8bGCaNTH7vDT7yWWq67hr3fUDSqs2bx74J2JtADE7ng1A93NaFEm1R gIRTZqWteuEPNy4u8oj/+lc9Z0a2vI1CuOUnsIQm9ZvhKllL3Z0+YCwPPspaHaRagSNK K5bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714770663; x=1715375463; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=w9qQDpvAvfKRu8qLDslBuxd5B2UXk46RBnF6wvfi1D4=; b=i97raZsoTbAJAN7yoZZRoanJFvGziTsbWyaIVDyg3xms01DN0J4+dQMUL9jcHtSrtk VeSg/1PKHHPEQo9mq+f7H+d3/cva5/3ROkCf6Q/gnR1H4RsDTYF7jRb3VQmOCvk489E+ iV12aH5akhp7A0UHN83f7vLPN2M9weRoE6syPBKUQ4RFJjAUrYDF6LcZFLFom6cFGrpV ob8X4WWKQVH97xrLX942R1EXnRw61+Bek6gvVBTa5HYF1VAnLAqIztCfTAkFQMA8cL08 bSg3NcR9nhrt7/2ic9dwBc9JqtvcMQCbZNXo9NbCXXY9MCs2SFa5yiaZvB6DIIEotI5H AtpA== X-Forwarded-Encrypted: i=1; AJvYcCW1adTYw3QpbMamI0QQkZSLn6zjf6pC9eKZGrSZv/JxoW1dG4XykfJt4QKvsFDzC4t1RjkNpMJnVBnIOhD1yNrS2N/OhlQGUjvGxDu5ga/S3ho0cDGOb1kxb7qwONAyGVl6ecuZKVzL1s7U X-Gm-Message-State: AOJu0YwfFz0vsB4FuXGBO1UD7BvIzx9KnjC/nDz6+898GIasSEnHkqcO 7+nuOaqfAMxkP4cNR2hpxewtmxwteuEvLqH/MCVi7DFA/Hoe6pGRYUgk42JA X-Google-Smtp-Source: AGHT+IGQBHowAMt1VfarNtWX6H7l9qKYH+O1pO94CXBV/3quyL6tynl7ApxlTtNnPHq53oTyMFLy3w== X-Received: by 2002:a17:907:1b06:b0:a59:9a68:7283 with SMTP id mp6-20020a1709071b0600b00a599a687283mr1869686ejc.12.1714770663111; Fri, 03 May 2024 14:11:03 -0700 (PDT) Received: from 58b9ec80ce2f.v.cablecom.net (84-72-156-211.dclient.hispeed.ch. [84.72.156.211]) by smtp.gmail.com with ESMTPSA id jy9-20020a170907762900b00a598646f173sm1475948ejc.191.2024.05.03.14.11.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 May 2024 14:11:02 -0700 (PDT) From: Lothar Rubusch To: herbert@gondor.apana.org.au, davem@davemloft.net Cc: nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, claudiu.beznea@tuxon.dev, linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, l.rubusch@gmail.com Subject: [PATCH v2 4/4] crypto: atmel-sha204a - provide the otp content Date: Fri, 3 May 2024 21:10:54 +0000 Message-Id: <20240503211054.1231-5-l.rubusch@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240503211054.1231-1-l.rubusch@gmail.com> References: <20240503211054.1231-1-l.rubusch@gmail.com> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Set up sysfs for the Atmel SHA204a. Provide the content of the otp zone as an attribute field on the sysfs entry. Thereby make sure that if the chip is locked, not connected or trouble with the i2c bus, the sysfs device is not set up. This is mostly already handled in atmel-i2c. Signed-off-by: Lothar Rubusch --- drivers/crypto/atmel-sha204a.c | 45 ++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/drivers/crypto/atmel-sha204a.c b/drivers/crypto/atmel-sha204a.c index 563a0493b..24ffdf505 100644 --- a/drivers/crypto/atmel-sha204a.c +++ b/drivers/crypto/atmel-sha204a.c @@ -114,6 +114,39 @@ static int atmel_sha204a_otp_read(struct i2c_client *client, u16 addr, u8 *otp) return ret; } +static ssize_t otp_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + u16 addr; + u8 otp[OTP_ZONE_SIZE]; + char *str = buf; + struct i2c_client *client = to_i2c_client(dev); + int i; + + for (addr = 0; addr < OTP_ZONE_SIZE/4; addr++) { + if (atmel_sha204a_otp_read(client, addr, otp + addr * 4) < 0) { + dev_err(dev, "failed to read otp zone\n"); + break; + } + } + + for (i = 0; i < addr*2; i++) + str += sprintf(str, "%02X", otp[i]); + str += sprintf(str, "\n"); + return str - buf; +} +static DEVICE_ATTR_RO(otp); + +static struct attribute *atmel_sha204a_attrs[] = { + &dev_attr_otp.attr, + NULL +}; + +static const struct attribute_group atmel_sha204a_groups = { + .name = "atsha204a", + .attrs = atmel_sha204a_attrs, +}; + static int atmel_sha204a_probe(struct i2c_client *client) { struct atmel_i2c_client_priv *i2c_priv; @@ -134,6 +167,16 @@ static int atmel_sha204a_probe(struct i2c_client *client) if (ret) dev_warn(&client->dev, "failed to register RNG (%d)\n", ret); + /* otp read out */ + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) + return -ENODEV; + + ret = sysfs_create_group(&client->dev.kobj, &atmel_sha204a_groups); + if (ret) { + dev_err(&client->dev, "failed to register sysfs entry\n"); + return ret; + } + return ret; } @@ -146,6 +189,8 @@ static void atmel_sha204a_remove(struct i2c_client *client) return; } + sysfs_remove_group(&client->dev.kobj, &atmel_sha204a_groups); + kfree((void *)i2c_priv->hwrng.priv); }