From patchwork Fri Aug 7 15:38:59 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 2944 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id 6278B1C05C7 for ; Fri, 7 Aug 2026 17:50:06 +0200 (CEST) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-25063-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-25063-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id A144F30EE25D for ; Fri, 7 Aug 2026 15:41:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B6D3247A889; Fri, 7 Aug 2026 15:39:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="J6cnuV8J" X-Original-To: linux-sunxi@lists.linux.dev Received: from mail-oi1-f172.google.com (mail-oi1-f172.google.com [209.85.167.172]) (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 85A23476CEC for ; Fri, 7 Aug 2026 15:39:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786117153; cv=none; b=B/GDrpjRfYd10ShwGFsoxGvoL40ahIslsbsSZW7GLEDvKK1E4qAonlKTRjGjV2YK5h2XKIQuAqU2BV2dAscj9TFUDdvEz99AglRUzF53OZ1xuwHCmaLYyOGnjKEgSqTvx9D3AzspxkfmrbFsyXJrty6/KX0rfA2mpN7EbRezsNU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786117153; c=relaxed/simple; bh=2FMplYOhzsgtvnRdbTNiLAZSTZm3+8XCX5VqoyndQro=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BjNDX3icJ/zRioslORoyF9QbOaBYZ4VFmKdGFLFX3luUoF1LmaM3b+vf2TRFLFcd+jXpnO2LFKvrBc7//MIzycUhrFReNhKuu/Z1SUFVabNS6Cc+ik6AwmvWNqjlYvM6wuudB0CFpBiuNNXKVcL0Te7xyOdTmk3rrF/NVkh1Wew= 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=J6cnuV8J; arc=none smtp.client-ip=209.85.167.172 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 Received: by mail-oi1-f172.google.com with SMTP id 5614622812f47-495b98b4f6aso1291089b6e.2 for ; Fri, 07 Aug 2026 08:39:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786117150; x=1786721950; darn=lists.linux.dev; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=BH5d83nxZVwUU/yrlx0wCDcJDqfJzuP8B2aoypwvUDg=; b=J6cnuV8JUYWIX3rHlEAgvU/vGmsSR16H27waERBA/9br2HtjhWXecQqAcIqtu3HhBc 3TNgIst7s/aIla5Es7ZxHt3A4kREe26QP81zXdbmjUvvG3Dy4cbWglVzLKhRMv0eoqtj Iyh8YN0mFZEtn1r+/5wAzdo2kKDwLF1otQVE2MDCiDzJv2CLH995AOXoXqHVkE0k/rwq 24FlpDoDloe6IZamygkY5KhUvWRFoszjzSdjyUUgYL7MFeMx0XZSL4Q/RsRbXXKAbSPT Fib0CPWacm7j3Ufo4aBYIHZzTT/M2/WupED6Ee/UiRHdkFip3axOlwylp2yt/3RYffd4 TmNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786117150; x=1786721950; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=BH5d83nxZVwUU/yrlx0wCDcJDqfJzuP8B2aoypwvUDg=; b=h+X6nrS6rfZ7hwmeXqJfgGgdwidtHyeTD8Df067MVY6gIyQ/aM4RA8ayl61/kwcHJG G8Y9mLxt8QczAmWmEnx10JL8l3jupK0wsXHpy7acytDhlUiB9bZLptVRagWP2ZnpztDq 9qbtw2nUpbN5ChUJCIiADYgY0ketAZTitEw1TkqFz3YO5RYrrvkHd+5zg8fNPtSkrAdO zxZCkCb1GQ2RG3nOrDnZ6OvNz/mrV9q4aKdDkCYkRGz2/RSHuAfchLTicntK3e8UHqxW ur6CF6zBq5RiKfhj+FM5crdrpNkIYLnjfyaF1GbxxflNRFNnD4ofv+PBKgluhud+6dCY 5y1g== X-Forwarded-Encrypted: i=1; AHgh+RruWk3b+Ps9Xa4xaGy1obF0gEqcnjP9HCR3eShTi3y0LUdEWqPfcXlOUEwF1AOhQZjofDTZfbi/IES47w==@lists.linux.dev X-Gm-Message-State: AOJu0YzKWK7gVcGkzgAjF5clnt58DIH//r6fKoXrC2ORmkojm5sEi0LT EcwSCs8XeYedBzUP6BHL9rk5Tta//jqZ0BlPKAzAf2imAE/zyrGC6QjP X-Gm-Gg: AR+sD13VOFIt4YrqQntCG7H7abiAUHCXVl55eyCWT6t6nK3YxBzjPd8WjxGXfk3vNur BzSV42lLCuMRAYU0F/bWHVu7Zg/yaCqwenbu/QsQLynUdxFTVWc53WFlxsoRHhh3YGQp2GmlwNK +wDfZuNzmaq+uBnvJciHAcXzTBEx6Ofw/hLfhO+nUfh4F6pHz31Kaab9QiVB1rHLMJIt6VnwPMR HN+s9mMFnnZl5PL9kBDTC3sLTs8ye1BrqoCFA30G5rfumtOYALJz77ZF3H94OyaakdwWAlQa2Vj S+q25/JEUsqcuNWrNQM+8T2/2WpkRhIZTBI2CSEK38LUUs4Qa3mY1tr1LjAVsdg0OCMjGtqSNYy NxlZjYby/0b8Yeq17ZqycQ0si+vh3h2B/uYAG1k1chg6KCl1LaY88i03FH0xntJR5dBaQr70MgX 5w8wZ6PLMP2QXAe4/dDcfE1973HtSlskEMUdk9KfyGg75gs190QdYyBCz4pkib/Mvfq8Yo5VvhU q1FK1tGkbtbQM5INU0KQ6z/Jrv+YI3IwzO5YF0HGkDioS9ecEEzWU0f09pF6NnbnMe2/SnVF43F IpeSGn/c7s8T99h7u9XExdNsb+lRVY/CAL6UuanZGoFrxo4+CA+y1TyGAtIKdZjMzqc/004k5mB 3MEY57J1qYE8VRc5b X-Received: by 2002:a05:6808:ec3:b0:4a4:a693:9d87 with SMTP id 5614622812f47-4afadf0e523mr11310972b6e.5.1786117150060; Fri, 07 Aug 2026 08:39:10 -0700 (PDT) Received: from [127.0.1.1] (184-96-154-59.hlrn.qwest.net. [184.96.154.59]) by smtp.gmail.com with ESMTPSA id 5614622812f47-4afae706cd5sm7353485b6e.11.2026.08.07.08.39.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2026 08:39:09 -0700 (PDT) From: James Hilliard Date: Fri, 07 Aug 2026 09:38:59 -0600 Subject: [PATCH v3 1/3] mtd: rawnand: sunxi: group controller delay tables Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20260807-submit-sunxi-nand-h6-h616-timings-v3-1-91287b543f41@gmail.com> References: <20260807-submit-sunxi-nand-h6-h616-timings-v3-0-91287b543f41@gmail.com> In-Reply-To: <20260807-submit-sunxi-nand-h6-h616-timings-v3-0-91287b543f41@gmail.com> To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Richard Genoud Cc: linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, James Hilliard , stable@vger.kernel.org X-Mailer: b4 0.15.2 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= The tWB and tRHW timing field encodings are controller properties, but they currently live in standalone lookup tables. Group them in a timing descriptor selected through the controller capability data. Point every existing controller at the legacy values so this is a pure preparation change. Fixes: 88fd4e4deae8 ("mtd: rawnand: sunxi: Add support for H616 nand controller") Cc: stable@vger.kernel.org Signed-off-by: James Hilliard --- drivers/mtd/nand/raw/sunxi_nand.c | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c index 02647565c8ba..9885248c9b85 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -237,6 +237,14 @@ struct sunxi_nand_hw_ecc { u32 ecc_ctl; }; +#define SUNXI_NFC_TIMING_STEPS 4 + +/* Delay arrays contain internal NDFC clock cycles for field values 0 to 3. */ +struct sunxi_nfc_timings { + s32 tWB[SUNXI_NFC_TIMING_STEPS]; + s32 tRHW[SUNXI_NFC_TIMING_STEPS]; +}; + /** * struct sunxi_nand_chip - stores NAND chip device related information * @@ -301,6 +309,7 @@ static inline struct sunxi_nand_chip *to_sunxi_nand(struct nand_chip *nand) * bytes to write * @nuser_data_tab: Size of @user_data_len_tab * @sram_size: Size of the NAND controller SRAM + * @timings: Controller timing characteristics */ struct sunxi_nfc_caps { bool has_mdma; @@ -327,6 +336,7 @@ struct sunxi_nfc_caps { unsigned int nuser_data_tab; unsigned int max_ecc_steps; int sram_size; + const struct sunxi_nfc_timings *timings; }; /** @@ -1667,8 +1677,10 @@ static int sunxi_nfc_hw_ecc_write_oob(struct nand_chip *nand, int page) return nand_prog_page_end_op(nand); } -static const s32 tWB_lut[] = {6, 12, 16, 20}; -static const s32 tRHW_lut[] = {4, 8, 12, 20}; +static const struct sunxi_nfc_timings sun4i_a10_nfc_timings = { + .tWB = { 6, 12, 16, 20 }, + .tRHW = { 4, 8, 12, 20 }, +}; static int _sunxi_nand_lookup_timing(const s32 *lut, int lut_size, u32 duration, u32 clk_period) @@ -1693,6 +1705,7 @@ static int sunxi_nfc_setup_interface(struct nand_chip *nand, int csline, { struct sunxi_nand_chip *sunxi_nand = to_sunxi_nand(nand); struct sunxi_nfc *nfc = to_sunxi_nfc(sunxi_nand->nand.controller); + const struct sunxi_nfc_timings *nfc_timings = nfc->caps->timings; const struct nand_sdr_timings *timings; u32 min_clk_period = 0; s32 tWB, tADL, tWHR, tRHW, tCAD; @@ -1763,8 +1776,10 @@ static int sunxi_nfc_setup_interface(struct nand_chip *nand, int csline, min_clk_period = DIV_ROUND_UP(timings->tWC_min, 2); /* T16 - T19 + tCAD */ - if (timings->tWB_max > (min_clk_period * 20)) - min_clk_period = DIV_ROUND_UP(timings->tWB_max, 20); + if (timings->tWB_max > + (min_clk_period * nfc_timings->tWB[SUNXI_NFC_TIMING_STEPS - 1])) + min_clk_period = DIV_ROUND_UP(timings->tWB_max, + nfc_timings->tWB[SUNXI_NFC_TIMING_STEPS - 1]); if (timings->tADL_min > (min_clk_period * 32)) min_clk_period = DIV_ROUND_UP(timings->tADL_min, 32); @@ -1772,8 +1787,10 @@ static int sunxi_nfc_setup_interface(struct nand_chip *nand, int csline, if (timings->tWHR_min > (min_clk_period * 32)) min_clk_period = DIV_ROUND_UP(timings->tWHR_min, 32); - if (timings->tRHW_min > (min_clk_period * 20)) - min_clk_period = DIV_ROUND_UP(timings->tRHW_min, 20); + if (timings->tRHW_min > + (min_clk_period * nfc_timings->tRHW[SUNXI_NFC_TIMING_STEPS - 1])) + min_clk_period = DIV_ROUND_UP(timings->tRHW_min, + nfc_timings->tRHW[SUNXI_NFC_TIMING_STEPS - 1]); /* * In non-EDO, tREA should be less than tRP to guarantee that the @@ -1789,7 +1806,7 @@ static int sunxi_nfc_setup_interface(struct nand_chip *nand, int csline, if (timings->tREA_max > min_clk_period && !timings->tRLOH_min) min_clk_period = timings->tREA_max; - tWB = sunxi_nand_lookup_timing(tWB_lut, timings->tWB_max, + tWB = sunxi_nand_lookup_timing(nfc_timings->tWB, timings->tWB_max, min_clk_period); if (tWB < 0) { dev_err(nfc->dev, "unsupported tWB\n"); @@ -1808,7 +1825,7 @@ static int sunxi_nfc_setup_interface(struct nand_chip *nand, int csline, return -EINVAL; } - tRHW = sunxi_nand_lookup_timing(tRHW_lut, timings->tRHW_min, + tRHW = sunxi_nand_lookup_timing(nfc_timings->tRHW, timings->tRHW_min, min_clk_period); if (tRHW < 0) { dev_err(nfc->dev, "unsupported tRHW\n"); @@ -2595,6 +2612,7 @@ static const struct sunxi_nfc_caps sunxi_nfc_a10_caps = { .nstrengths = ARRAY_SIZE(sunxi_ecc_strengths_a10), .max_ecc_steps = 16, .sram_size = 1024, + .timings = &sun4i_a10_nfc_timings, }; static const struct sunxi_nfc_caps sunxi_nfc_a23_caps = { @@ -2617,6 +2635,7 @@ static const struct sunxi_nfc_caps sunxi_nfc_a23_caps = { .nstrengths = ARRAY_SIZE(sunxi_ecc_strengths_a10), .max_ecc_steps = 16, .sram_size = 1024, + .timings = &sun4i_a10_nfc_timings, }; static const struct sunxi_nfc_caps sunxi_nfc_h616_caps = { @@ -2641,6 +2660,7 @@ static const struct sunxi_nfc_caps sunxi_nfc_h616_caps = { .nuser_data_tab = ARRAY_SIZE(sunxi_user_data_len_h6), .max_ecc_steps = 32, .sram_size = 8192, + .timings = &sun4i_a10_nfc_timings, }; static const struct of_device_id sunxi_nfc_ids[] = { From patchwork Fri Aug 7 15:39:00 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 2946 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mxe881.netcup.net (Postfix) with ESMTPS id 112D51C05C4 for ; Fri, 7 Aug 2026 18:03:03 +0200 (CEST) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.232.135.74) smtp.mailfrom=linux-sunxi+bounces-25064-noreply=patchwork.local@lists.linux.dev smtp.helo=sto.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.232.135.74 as permitted sender) client-ip=172.232.135.74; envelope-from=linux-sunxi+bounces-25064-noreply=patchwork.local@lists.linux.dev; helo=sto.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sto.lore.kernel.org (Postfix) with ESMTP id 760EE30848AF for ; Fri, 7 Aug 2026 15:41:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6B9D347ACE2; Fri, 7 Aug 2026 15:39:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="i5bvC2vI" X-Original-To: linux-sunxi@lists.linux.dev Received: from mail-oi1-f171.google.com (mail-oi1-f171.google.com [209.85.167.171]) (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 2B205476CC8 for ; Fri, 7 Aug 2026 15:39:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786117154; cv=none; b=FAfxXgnRTPouoIk21MdwONWYIdc7elgvZ3C2iqhky3+6bjNTr4YxzXGefOPDPKAtJUkSUGx/rnsY+cQkJPpapKuq7B2g1ULOQ5DTRJEovM+5064oGPdsOhk5tLRmR/vP7OMJnsiorYxI3LkQkvHAfEXshkWvwz6GTRmC44XXPnY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786117154; c=relaxed/simple; bh=GOAlpolOzUCQKB0D6s76EOdiJ4JtM3txEaAtWy2BZY4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EfEgHHA+iaW2MSvDLRfCKxBwlrZ8gGGDxD05orpuex7r5uINx17dMjx4ASzdNkzQ34oPwZ8yTe/D72JFWBOnu3B1Y7FVDdwoJEGXhP7WqRmHTDgFQQewKiOi59N8mHPD2WuvoFAN21tpxSNoMnx70fZJT2ROURCcOmcZLAl+pZA= 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=i5bvC2vI; arc=none smtp.client-ip=209.85.167.171 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 Received: by mail-oi1-f171.google.com with SMTP id 5614622812f47-4ab47c40e7eso1472015b6e.3 for ; Fri, 07 Aug 2026 08:39:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786117151; x=1786721951; darn=lists.linux.dev; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=4LVBJaFomYnqSqtZwNfhU1nsKV+qCjSwKc3i+p0HPzM=; b=i5bvC2vILJaazNnxr9BPEzVRPJx/DVQO/pz1Q4U/l6Yrri45MjT5G4SlhB0VT6W9xz l/kTvwlrJflW/pOnSrJb0MAasUH9HqARTQPKiglr6gRID1t0dYXKWc00b4kqD8vUJlxv 5wQrgt3VGLvkuBAMTkYjk5dNVH+DMGYIUYux/5xDKHzW1JNxTZ5CNqzoeo8NPxfx14u1 roOiFdWsk4SAqCbH9yFq08+2nIkvDizaZu5UCUGVjhQ6ILXp2a3D3JPioSnUV3NrKrGm 2bsxzHM5BDlsRSHvXpfsr7B6pibVdpdfe6yNSqTo5y5QJU9rxKTtsoAynykvF1rVmHsQ 7dJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786117151; x=1786721951; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=4LVBJaFomYnqSqtZwNfhU1nsKV+qCjSwKc3i+p0HPzM=; b=jyup+6uON048F6T6jjkAY7i93EUypu7DYk/Q0252aetRm16vc70Dss19bmlhkOIxq/ YQ4YKHRCR1nncPy8KKfZq8o2VhKuiG0NC5vwXS9wKKfWUaW98ihI0j1gmCv7dAeBy1hL 01TLnzTzX77KEjULpLQzw1YWVqR1uRaghkM4FGJb2h9ohRSVHUsxDZxW9MO2mflIDlXJ nc+K1lNanU3X0D3DuZo4gZADg4PYKzpvlntvI2PdB0FLDEeeePfLqbTiYRughmJwNc5+ 71Wz7YDLkvuSFgSA1ZB4B3OdHidm+adNakSoPwLt6jFALoN48E3VzbgpAdxhPLuZQugb Xo2Q== X-Forwarded-Encrypted: i=1; AHgh+RqRDSOA7aTLs0POWHQXKCCHadGlzK3BG+92RA89YzSW+1BClM1x9jhf8cEdQNfRyeJXBW1GKbyJiPiKcA==@lists.linux.dev X-Gm-Message-State: AOJu0YwwUJi4VWWX358wzKLYn+JmesBf1ibK6id8FWQHNamp9UeHM2ad Lu7g5mPWiqov/Vh3GVIbjBjj7jAaKMjtXTTRwIpNV9neFCbhJUKUre9X X-Gm-Gg: AR+sD119BW5HkOLZPkYjy+D7yUH0ZfHE4NhtjORsYlTnOV1JyADSBRSJPbebmwqz0pY 0S/WcCxTfXvTUCr39BFhlFlJEi0I9vnJVnU0j2yoURv1M48cMqxfLZBZxr7d46KUWoLxKVdOPM1 Y3e6S8M2UPNp02YjfnjR29W2uY1mUkGtjYM7mGE51ojkGxO/RN0x5G11XcaL705XjuGheg6P9Dx 8MRx6fo4av0c/x3icXnnTraYxNm1UHRO7v6LIEGmz67zg/8MajQS9zOgdxRvss8QJ0ySPAf8ojG OoTC2nN7I1Wl5U8IeUFPppiD7xsLpTDGkwBINUetAJvd/ic71MCNT5PH2JgEb3Tf5wiQe227Csx ZI+/dbEVEFOcpzxModwYoamEwm41ML+CC6Xe75kNc0co2DfiF+Ozn63NahDRcGle8QXB0OTiSLx mfr9uBRggxhhLZJ4NztkvkmEO74XExvF4QBT+pn0jYsCv1kEjUqpD/kSoI1arcfrA+XnqKtfHy9 djVBKLgguJmym3ZGxi1y9ugAdPwu1yNOIB5/OTNkjpmwlGrVa9gwQyCB0pWjMI2iagjDPAAYMMq Iz7EjE4dnTfktxf18SFKhHPWo+E6AqYRqcfMxNtyioVyDF2ht1wWGbyUMjwyygP6hKX+HtnLGeg 3TcKqGuNSo3iphdDY X-Received: by 2002:a05:6808:c1ba:b0:48a:ddd4:d36f with SMTP id 5614622812f47-4afadf16e3fmr12514228b6e.8.1786117150933; Fri, 07 Aug 2026 08:39:10 -0700 (PDT) Received: from [127.0.1.1] (184-96-154-59.hlrn.qwest.net. [184.96.154.59]) by smtp.gmail.com with ESMTPSA id 5614622812f47-4afae706cd5sm7353485b6e.11.2026.08.07.08.39.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2026 08:39:10 -0700 (PDT) From: James Hilliard Date: Fri, 07 Aug 2026 09:39:00 -0600 Subject: [PATCH v3 2/3] mtd: rawnand: sunxi: describe tADL and tWHR delays Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20260807-submit-sunxi-nand-h6-h616-timings-v3-2-91287b543f41@gmail.com> References: <20260807-submit-sunxi-nand-h6-h616-timings-v3-0-91287b543f41@gmail.com> In-Reply-To: <20260807-submit-sunxi-nand-h6-h616-timings-v3-0-91287b543f41@gmail.com> To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Richard Genoud Cc: linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, James Hilliard , stable@vger.kernel.org X-Mailer: b4 0.15.2 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= The tADL and tWHR timing fields use four encoded delays, but the driver currently derives their values with a shift. This hides the actual controller timing characteristics and lets the clock solver select a 32-cycle delay that the fields cannot encode. Describe the legacy 7, 15, 23 and 31 cycle thresholds explicitly and use the tables for both clock selection and field lookup. This prepares the driver for controllers with different encodings. Fixes: 88fd4e4deae8 ("mtd: rawnand: sunxi: Add support for H616 nand controller") Cc: stable@vger.kernel.org Signed-off-by: James Hilliard --- drivers/mtd/nand/raw/sunxi_nand.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c index 9885248c9b85..df52501c1285 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -242,6 +242,8 @@ struct sunxi_nand_hw_ecc { /* Delay arrays contain internal NDFC clock cycles for field values 0 to 3. */ struct sunxi_nfc_timings { s32 tWB[SUNXI_NFC_TIMING_STEPS]; + s32 tADL[SUNXI_NFC_TIMING_STEPS]; + s32 tWHR[SUNXI_NFC_TIMING_STEPS]; s32 tRHW[SUNXI_NFC_TIMING_STEPS]; }; @@ -1679,6 +1681,8 @@ static int sunxi_nfc_hw_ecc_write_oob(struct nand_chip *nand, int page) static const struct sunxi_nfc_timings sun4i_a10_nfc_timings = { .tWB = { 6, 12, 16, 20 }, + .tADL = { 7, 15, 23, 31 }, + .tWHR = { 7, 15, 23, 31 }, .tRHW = { 4, 8, 12, 20 }, }; @@ -1781,11 +1785,15 @@ static int sunxi_nfc_setup_interface(struct nand_chip *nand, int csline, min_clk_period = DIV_ROUND_UP(timings->tWB_max, nfc_timings->tWB[SUNXI_NFC_TIMING_STEPS - 1]); - if (timings->tADL_min > (min_clk_period * 32)) - min_clk_period = DIV_ROUND_UP(timings->tADL_min, 32); + if (timings->tADL_min > + (min_clk_period * nfc_timings->tADL[SUNXI_NFC_TIMING_STEPS - 1])) + min_clk_period = DIV_ROUND_UP(timings->tADL_min, + nfc_timings->tADL[SUNXI_NFC_TIMING_STEPS - 1]); - if (timings->tWHR_min > (min_clk_period * 32)) - min_clk_period = DIV_ROUND_UP(timings->tWHR_min, 32); + if (timings->tWHR_min > + (min_clk_period * nfc_timings->tWHR[SUNXI_NFC_TIMING_STEPS - 1])) + min_clk_period = DIV_ROUND_UP(timings->tWHR_min, + nfc_timings->tWHR[SUNXI_NFC_TIMING_STEPS - 1]); if (timings->tRHW_min > (min_clk_period * nfc_timings->tRHW[SUNXI_NFC_TIMING_STEPS - 1])) @@ -1813,16 +1821,18 @@ static int sunxi_nfc_setup_interface(struct nand_chip *nand, int csline, return tWB; } - tADL = DIV_ROUND_UP(timings->tADL_min, min_clk_period) >> 3; - if (tADL > 3) { + tADL = sunxi_nand_lookup_timing(nfc_timings->tADL, + timings->tADL_min, min_clk_period); + if (tADL < 0) { dev_err(nfc->dev, "unsupported tADL\n"); - return -EINVAL; + return tADL; } - tWHR = DIV_ROUND_UP(timings->tWHR_min, min_clk_period) >> 3; - if (tWHR > 3) { + tWHR = sunxi_nand_lookup_timing(nfc_timings->tWHR, + timings->tWHR_min, min_clk_period); + if (tWHR < 0) { dev_err(nfc->dev, "unsupported tWHR\n"); - return -EINVAL; + return tWHR; } tRHW = sunxi_nand_lookup_timing(nfc_timings->tRHW, timings->tRHW_min, From patchwork Fri Aug 7 15:39:01 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 2945 Return-Path: X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mxe881.netcup.net (Postfix) with ESMTPS id 3324E1C05C7 for ; Fri, 7 Aug 2026 17:50:24 +0200 (CEST) Authentication-Results: mxe881; dkim=pass header.d=gmail.com; spf=pass (sender IP is 172.234.253.10) smtp.mailfrom=linux-sunxi+bounces-25065-noreply=patchwork.local@lists.linux.dev smtp.helo=sea.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 172.234.253.10 as permitted sender) client-ip=172.234.253.10; envelope-from=linux-sunxi+bounces-25065-noreply=patchwork.local@lists.linux.dev; helo=sea.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sea.lore.kernel.org (Postfix) with ESMTP id C30AD30F1F13 for ; Fri, 7 Aug 2026 15:41:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4B94347A88B; Fri, 7 Aug 2026 15:39:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ahadb1IQ" X-Original-To: linux-sunxi@lists.linux.dev Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) (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 2F134478869 for ; Fri, 7 Aug 2026 15:39:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786117155; cv=none; b=Ep0oV8Qn36r0ertpvqEgWilHHTRnJ/9NzGxr/gNpK4tQiYckPSJvWq3DDG1yBLEgD7i2AdwlyDyV2xfq/RzwXIurDgFbnMpn1PhG77Krp1Y44aN56rCXU/syRs6pxOsYeb2RrEN/bO4vLA0ZLWJtuMFK2zFPZVAFOHcQowQSJaw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786117155; c=relaxed/simple; bh=fjJbOQKzguDWbLI313C9AMkwyvYLGGwqNj2+pQIqOD0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Y3jgTkBRmZtcsJvhEBk2FmwZarD7nadqsACOa1LdZX8pMs9rfAAnGbHgDw6RaZWymU2+6jDDyQVgL/1tDPJwcGg6oYDFWOtMKY2Y1u7X5Q2Wqjfm8T9Je1WGVrSFmGCPjYP0s9lyr7o3nGHvZgreL69Fn98qqTI2KmV8EP+3nT0= 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=ahadb1IQ; arc=none smtp.client-ip=209.85.167.180 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 Received: by mail-oi1-f180.google.com with SMTP id 5614622812f47-497deab2d66so1736702b6e.0 for ; Fri, 07 Aug 2026 08:39:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1786117152; x=1786721952; darn=lists.linux.dev; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=xCFnyxQ3kE94m7oA5V9nQHQf/U50pnd0oZWwoKAuPBw=; b=ahadb1IQVK6DzOHyj/WzHxGSkOUFSrUK7bJ9A5JPT/Rkwc74lhT9eQ1bNvur1gBvWz Tzl9sDZd+Lp0AlTmNkx4C7bcRIUDDiGwk5m6eNpDURKPv0s33MymQtvPM06ikC+tisTR Urs4oXl8KIo2e2Ntsw9/8/R9ZDefxziVJaYfVWLlSt8NXIvauxG9r5eOmjAv+fynZhT4 mZcA0xNSxnljQFVG0k2SQqHvPJj3AWAd/CYoaL/HVmHkvw2JX9oBm9N2Nqt6awHAYf0E cqdWJ96KiEN7mv9OpyrvaPZK/GAHJa+Pn6Xpfvo1vGDs0cxzr9r6cF9PGjV0Mqx7uvOr dnQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786117152; x=1786721952; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=xCFnyxQ3kE94m7oA5V9nQHQf/U50pnd0oZWwoKAuPBw=; b=Iq0uVWGS5GyMQ3eRtbZXnDOkrJins+o+AeM9bq70RFlsHQWBWJl9W2Cugr0Mp0DF9J 1xhiRFER/uOBTSezHO6a4lMnDO+XDTbud9e8lIr9ptJBPFECIMxkKqSDEqiZrkGhiB0U u9fQd515+VhyFW9rNHi5RwW09T2/WtbXqXVLcZ7FY4m60gejS/UEEmlkebNAf0IbSjUO k0SqQ2FS7O+U7r25SylusUW1h9i+mfR8vKhjg6vQp7YYwnhEx1sbhL4UJqr7ZvdHTa9S hdY+soJ3H8JyJKTeFHFqJUU9+DV6Sa9jrCrf8xXY+mnUyC71o6SeJpGu6tZ1n3+c/pA8 ZA6g== X-Forwarded-Encrypted: i=1; AHgh+RrviIIJi9uPw2t7RdEnhrvnExmEIk2XmYqJFlBBk6LUBdBJomTCx6cP8uc85uRlDQIiEck8XyNBF8s4fQ==@lists.linux.dev X-Gm-Message-State: AOJu0YwY53JClGYcQdd4hi7jKi0nJJy7PD48ojqrG7JPmuUUn55fIUSl d9N9wgHQ7qdIx8RBAQohq21lVkAhyzuQ9ilvF5Hq8Nj08NdYwCNAGXlh X-Gm-Gg: AR+sD11J/GrYfkH3VkbWmwi+pVLGdfzaYU9ja4Cd5kCHZ+KW7sjLPQFja1FdaHYt5il n+XQiHhoeIFMzg1hRMMzN3IkzYRMqIC9qa2CFGKvAIj3PIln06pHdXo958jgV+PTW63JyZiLohr bB+mVC5pCyfAlkifEAQrLISKZxi+D+jvqwoW3mT6lrF2XUKcVyWyj+ID91gQdIWz7ZNhF8ugKA/ eZQX8gLyDOLfBjzJe6VeUe61hFdzk4ERF76LneQHhhyHchbuqsWMTXfNBhBLVFKP6a+D1lu2y/0 PUjQVqpPxLVQO7UmCfrf8Hhmlg6m/1TTQmpb0bYX8pP6FaAm46K/ZpavTXJZSQDqGM6isLyBL12 x90vkKwtG0h+8FA+MUzlI84dL38ShVjoSS/bkQev3FZXxgHdHkf7U5UDOSFCdNL/Ee0IDVr08f0 6xS1rYw/RHR1rF/dtUDn1cPLg9qRdfiLIxzwoIVaFd2g9M5nvQBRiHCByhavV/MMZriRmpW44Bq t9PHfNvwhyM6b5MHW7l5BDAES8jMIALRA7Euob8vQl084dieaphXpk6VlFjJmktdYSq7kb8Wjlu nDnTDydN3xFa2uAiO+oxv5paOxn4AQobvtYtOLhHlWypW6z2jEOkosIBpKYcVPh1SwItiJEzypZ wT1ZKYmK+QpEFm70K X-Received: by 2002:a05:6808:ec9:b0:4a4:cedc:6859 with SMTP id 5614622812f47-4afc4df6419mr8781396b6e.4.1786117151816; Fri, 07 Aug 2026 08:39:11 -0700 (PDT) Received: from [127.0.1.1] (184-96-154-59.hlrn.qwest.net. [184.96.154.59]) by smtp.gmail.com with ESMTPSA id 5614622812f47-4afae706cd5sm7353485b6e.11.2026.08.07.08.39.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Aug 2026 08:39:11 -0700 (PDT) From: James Hilliard Date: Fri, 07 Aug 2026 09:39:01 -0600 Subject: [PATCH v3 3/3] mtd: rawnand: sunxi: fix H6/H616 controller timings Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20260807-submit-sunxi-nand-h6-h616-timings-v3-3-91287b543f41@gmail.com> References: <20260807-submit-sunxi-nand-h6-h616-timings-v3-0-91287b543f41@gmail.com> In-Reply-To: <20260807-submit-sunxi-nand-h6-h616-timings-v3-0-91287b543f41@gmail.com> To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland , Richard Genoud Cc: linux-mtd@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, James Hilliard , stable@vger.kernel.org X-Mailer: b4 0.15.2 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [-1.16 / 15.00]; BAYES_HAM(-5.50)[100.00%]; RBL_SENDERSCORE(2.00)[172.234.253.10:from]; SUSPICIOUS_RECIPS(1.50)[]; DMARC_POLICY_SOFTFAIL(1.00)[gmail.com : SPF not aligned (relaxed), No valid DKIM,none]; MAILLIST(-0.15)[generic]; BAD_REP_POLICIES(0.10)[]; MIME_GOOD(-0.10)[text/plain]; HAS_LIST_UNSUB(-0.01)[]; TAGGED_RCPT(0.00)[]; PRECEDENCE_BULK(0.00)[]; RCPT_COUNT_TWELVE(0.00)[13]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[sea.lore.kernel.org:rdns,sea.lore.kernel.org:helo]; FORGED_SENDER_MAILLIST(0.00)[]; FREEMAIL_CC(0.00)[lists.infradead.org,lists.linux.dev,vger.kernel.org,gmail.com]; FREEMAIL_FROM(0.00)[gmail.com]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc-20240116:i=1]; R_SPF_ALLOW(0.00)[+ip4:172.234.253.10:c]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_LAST(0.00)[]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; FREEMAIL_TO(0.00)[bootlin.com,nod.at,ti.com,kernel.org,gmail.com,sholland.org]; FROM_HAS_DN(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; ASN(0.00)[asn:63949, ipnet:172.234.224.0/19, country:SG]; TAGGED_FROM(0.00)[bounces-25065-noreply=patchwork.local]; RCVD_COUNT_FIVE(0.00)[6]; FROM_NEQ_ENVFROM(0.00)[jameshilliard1@gmail.com,linux-sunxi@lists.linux.dev]; RCVD_VIA_SMTP_AUTH(0.00)[] X-Rspamd-Queue-Id: 3324E1C05C7 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= The NAND timing calculation assumes that command and address setup and hold intervals T1-T4, T7 and T11 each take one controller clock. It also uses the original A10 delay encodings for tWB, tADL, tWHR and tRHW. The H6/H616 NDFC defines the setup and hold intervals as two internal clock cycles and uses different delay encodings. Add the H616 timing characteristics and select them through the controller capability data so the clock solver and timing fields match the hardware. Fixes: 88fd4e4deae8 ("mtd: rawnand: sunxi: Add support for H616 nand controller") Cc: stable@vger.kernel.org Signed-off-by: James Hilliard --- drivers/mtd/nand/raw/sunxi_nand.c | 49 ++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi_nand.c index df52501c1285..ca74c9c333e7 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -241,6 +241,8 @@ struct sunxi_nand_hw_ecc { /* Delay arrays contain internal NDFC clock cycles for field values 0 to 3. */ struct sunxi_nfc_timings { + /* Internal clock cycles used by T1-T4, T7 and T11. */ + u8 setup_cycles; s32 tWB[SUNXI_NFC_TIMING_STEPS]; s32 tADL[SUNXI_NFC_TIMING_STEPS]; s32 tWHR[SUNXI_NFC_TIMING_STEPS]; @@ -1680,12 +1682,21 @@ static int sunxi_nfc_hw_ecc_write_oob(struct nand_chip *nand, int page) } static const struct sunxi_nfc_timings sun4i_a10_nfc_timings = { + .setup_cycles = 1, .tWB = { 6, 12, 16, 20 }, .tADL = { 7, 15, 23, 31 }, .tWHR = { 7, 15, 23, 31 }, .tRHW = { 4, 8, 12, 20 }, }; +static const struct sunxi_nfc_timings sun50i_h616_nfc_timings = { + .setup_cycles = 2, + .tWB = { 28, 44, 60, 76 }, + .tADL = { 0, 12, 28, 44 }, + .tWHR = { 0, 12, 28, 44 }, + .tRHW = { 8, 24, 40, 56 }, +}; + static int _sunxi_nand_lookup_timing(const s32 *lut, int lut_size, u32 duration, u32 clk_period) { @@ -1720,20 +1731,28 @@ static int sunxi_nfc_setup_interface(struct nand_chip *nand, int csline, return -ENOTSUPP; /* T1 <=> tCLS */ - if (timings->tCLS_min > min_clk_period) - min_clk_period = timings->tCLS_min; + if (timings->tCLS_min > + min_clk_period * nfc_timings->setup_cycles) + min_clk_period = DIV_ROUND_UP(timings->tCLS_min, + nfc_timings->setup_cycles); /* T2 <=> tCLH */ - if (timings->tCLH_min > min_clk_period) - min_clk_period = timings->tCLH_min; + if (timings->tCLH_min > + min_clk_period * nfc_timings->setup_cycles) + min_clk_period = DIV_ROUND_UP(timings->tCLH_min, + nfc_timings->setup_cycles); /* T3 <=> tCS */ - if (timings->tCS_min > min_clk_period) - min_clk_period = timings->tCS_min; + if (timings->tCS_min > + min_clk_period * nfc_timings->setup_cycles) + min_clk_period = DIV_ROUND_UP(timings->tCS_min, + nfc_timings->setup_cycles); /* T4 <=> tCH */ - if (timings->tCH_min > min_clk_period) - min_clk_period = timings->tCH_min; + if (timings->tCH_min > + min_clk_period * nfc_timings->setup_cycles) + min_clk_period = DIV_ROUND_UP(timings->tCH_min, + nfc_timings->setup_cycles); /* T5 <=> tWP */ if (timings->tWP_min > min_clk_period) @@ -1744,8 +1763,10 @@ static int sunxi_nfc_setup_interface(struct nand_chip *nand, int csline, min_clk_period = timings->tWH_min; /* T7 <=> tALS */ - if (timings->tALS_min > min_clk_period) - min_clk_period = timings->tALS_min; + if (timings->tALS_min > + min_clk_period * nfc_timings->setup_cycles) + min_clk_period = DIV_ROUND_UP(timings->tALS_min, + nfc_timings->setup_cycles); /* T8 <=> tDS */ if (timings->tDS_min > min_clk_period) @@ -1760,8 +1781,10 @@ static int sunxi_nfc_setup_interface(struct nand_chip *nand, int csline, min_clk_period = DIV_ROUND_UP(timings->tRR_min, 3); /* T11 <=> tALH */ - if (timings->tALH_min > min_clk_period) - min_clk_period = timings->tALH_min; + if (timings->tALH_min > + min_clk_period * nfc_timings->setup_cycles) + min_clk_period = DIV_ROUND_UP(timings->tALH_min, + nfc_timings->setup_cycles); /* T12 <=> tRP */ if (timings->tRP_min > min_clk_period) @@ -2670,7 +2693,7 @@ static const struct sunxi_nfc_caps sunxi_nfc_h616_caps = { .nuser_data_tab = ARRAY_SIZE(sunxi_user_data_len_h6), .max_ecc_steps = 32, .sram_size = 8192, - .timings = &sun4i_a10_nfc_timings, + .timings = &sun50i_h616_nfc_timings, }; static const struct of_device_id sunxi_nfc_ids[] = {