From patchwork Tue Sep 27 10:24:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dario Binacchi X-Patchwork-Id: 2392 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-qk1-f200.google.com (mail-qk1-f200.google.com [209.85.222.200]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 4C5AB3F1C8 for ; Tue, 27 Sep 2022 12:25:54 +0200 (CEST) Received: by mail-qk1-f200.google.com with SMTP id f12-20020a05620a408c00b006ced53b80e5sf6984656qko.17 for ; Tue, 27 Sep 2022 03:25:54 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1664274353; cv=pass; d=google.com; s=arc-20160816; b=G+4U7MXnz2tmW3I7fD/d2g4IRWF7qZuunKDEP7EQAdRX2gBotsALuL4+mKnA8KkkAm Z071KSnGF6rh0nrKuJ3BrZBnQqfPYVD8P1QFNn5DO+bkROTBdlvICu/hsZwsZq3yHI3n irrSaiUPh0HwZu5T+Q+0KpN/dn1UzpXlulIQ6PMltyhgKYzB5ZMIgcguscpwZBQs1Eef RPGUemWJTaWrxsZzLhR5Ao2U68iSasr6RsiliakBy7LY0APB6d/lPxvgFEdoxU25tkKr Siv91TvQ0VKJC2p899nsoeFN7hADxbfrTM7OT33xvmX8fT9f2hA4Cn5XtK7sXHsBGJxI DF6A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=IEAU1bo4TM6+E16rIDOjMSOIYjwCsfBozn3lJ3qjKyc=; b=tJS0kAfKQG9ZLX9zNYOsoERoSqcOl0U7+kCOCNrUqPy4GGvL0V8kpF2YJj3rapmv8d QZDb3JlytlJw14LbHsj/ytywXFoCRxmvNbWk3s61CsnjHpf6f5VxvaUjHlRxGYdog/MP EJVDDHCzWkGkbFn5xNVoL5ca3DslIBC3+VCi/g8xXbK4hZfjEZ+jWMwZIMVL3LE3rE8W DlbhdvzTB1KSdR4tuum3ZU+LjdaUUX416pb4ZFPg+srR29ZPo1+W2TYRbmGBCAL+PsDg JWNUQCo8SodiR1qWZ/KW+rTEfd5f6iY8I8EsMPzLQ60mz4nWQTb+noTmEjsGbdNbTcJt LGhA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=pg28ZVXV; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:x-original-authentication-results :x-original-sender:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:from:to:cc:subject:date; bh=IEAU1bo4TM6+E16rIDOjMSOIYjwCsfBozn3lJ3qjKyc=; b=UO1RiIA8jUYMs7KGx881TWxGvPIN+2GKVCgVIJp/2gMVXe4OwlPrhb+Fe5/hf9A9fc /ODHO6DlJS8Qm9UQULwu9dctFxBoxHp93VMyHwmIQboxw8dPR/GgVbfLiE6pzZoYLMv2 YLHOAIEo7BnbjiZppjgJ9YRznV8saUIX3gp/g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=list-unsubscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence :x-original-authentication-results:x-original-sender:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :x-gm-message-state:from:to:cc:subject:date; bh=IEAU1bo4TM6+E16rIDOjMSOIYjwCsfBozn3lJ3qjKyc=; b=UFOneBGVIPLql6XhEo5c3cfEVE/+1HKTA//MB3e7j5UZuOFXPCc/6u1nq5W1n449pf zX+R0KTdpYnFf/sabrHd0vOpekWJbjbsy+SGj33uTaQZ/8eLDnNPTIckVmRQmbrx38tE Mc1/s7tbz55ShkavCLp+6RnJebxNx4jIH+x80rW+Ng+fYnvlkvWreOTz7fYWpRxJ/LUi rYsNcQeDuYORc4ch2aeY0+u6GLPxc7LY8+/cHqQacMvwUhQ4lsrd541hZQGJ/q4cv7na icL10bMYiyyxIahUKgLu5cyiNqv74vtkZAgWaNCRKZCJV4OalHnXjSTDNnUr5oM/uDHI NVEQ== X-Gm-Message-State: ACrzQf1dh8lehDLCUvBEdW++DFeBS4bQJbTRMbX7vZ2lZyHhHNFEPqnd 4bvg2wAM93mKdBI81UzdP1+dvL4U X-Google-Smtp-Source: AMsMyM60dWwJpuzA15xnDE7gm0uwlbAI1lBc4BHS3P3ui7jt/YdjBXeOHEAahAxaqzTa/iLwW3Hxxw== X-Received: by 2002:a05:6214:20a6:b0:4ac:ba17:e20f with SMTP id 6-20020a05621420a600b004acba17e20fmr21139470qvd.101.1664274353336; Tue, 27 Sep 2022 03:25:53 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:ac8:5298:0:b0:35c:f240:4bfd with SMTP id s24-20020ac85298000000b0035cf2404bfdls1407850qtn.4.-pod-prod-gmail; Tue, 27 Sep 2022 03:25:52 -0700 (PDT) X-Received: by 2002:a05:622a:3d4:b0:35c:fc79:684d with SMTP id k20-20020a05622a03d400b0035cfc79684dmr21813370qtx.331.1664274352704; Tue, 27 Sep 2022 03:25:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664274352; cv=none; d=google.com; s=arc-20160816; b=rHU1uSpXDeooO0+aLpTEHFOqyAGo5xztiJnvEkEnXbvmgzmYnLRh2q55P0XurD0YO/ C9TcR349D/rDjGMe4oNtMzxvqGFxu2oSv2S1kUFUZ6ccFO+NzetBYGquyJNM1JCm8vLj eXuZC21NPmNl5sX52QBzG2VlfDkae9GESor/cN3JlkvVvRQj8bJL1QWC8hXFuqSKJc2e lDKkR7xUjfbDWyKv8gykq5j+2f5HeRoNSUzA8OHm6ZMwxcyxPxXwuhaAjfV84XF4sSJd MbfQUazORzaY+oE1ItKs/sHm294ZxD2Y95p+Vmfbs8UkyRfVsfiVGgwhv50w5Q4zH62x sklA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=1drZW2xETy3lTFU3GTxoZL8qNeiXk22X8/XCBPr1lx0=; b=FqgimBLGtBCjYmrurJiGcauNw7PMAm1LCKk4vMkhcSnabM/DK9Ue7ilGXLWKakuoh+ M+8oEcGp9O0MvIq5IDuZGXeZvw3OhxIlSF3Y/3XDTakP1PHYjnFUMxEGBz2sk7LC+pjJ NURgMFKhFRJBP7ZgJvJvNZe4YYuI6xiBobtfAsT2qh6PEWGXLJVmsVr5lx4BC8H40cPd m3PTly5e2OgVIoHUgwolnzABGYTENXGQ/r6OCGq8V0aBh/z7n0rLwwm/lJ4wvw5tugi+ cAUQXM359DLHk2Oz/iw3dtCIabdgCjkYka+WpTy6BZSK0bTP0PpTOKuXNudJ5XJ6f/jM 2znQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=pg28ZVXV; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Received: from mail-sor-f41.google.com (mail-sor-f41.google.com. [209.85.220.41]) by mx.google.com with SMTPS id q15-20020a056214194f00b004ad77b613bfsor781384qvk.31.2022.09.27.03.25.52 for (Google Transport Security); Tue, 27 Sep 2022 03:25:52 -0700 (PDT) Received-SPF: pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) client-ip=209.85.220.41; X-Received: by 2002:a05:6214:2aaa:b0:4ac:acbd:7ef8 with SMTP id js10-20020a0562142aaa00b004acacbd7ef8mr20466699qvb.126.1664274351995; Tue, 27 Sep 2022 03:25:51 -0700 (PDT) Received: from dario-ThinkPad-T14s-Gen-2i.pdxnet.pdxeng.ch (host-95-232-92-192.retail.telecomitalia.it. [95.232.92.192]) by smtp.gmail.com with ESMTPSA id d11-20020a05620a240b00b006be8713f742sm752220qkn.38.2022.09.27.03.25.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Sep 2022 03:25:51 -0700 (PDT) From: Dario Binacchi To: linux-amarula@amarulasolutions.com Cc: michael@amarulasolutions.com, Dario Binacchi Subject: [PATCH 6/6] mtd: mxs_nand: Support EDO mode for imx8mn architecture Date: Tue, 27 Sep 2022 12:24:43 +0200 Message-Id: <20220927102443.1816168-6-dario.binacchi@amarulasolutions.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220927102443.1816168-1-dario.binacchi@amarulasolutions.com> References: <20220927102443.1816168-1-dario.binacchi@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: dario.binacchi@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=pg28ZVXV; spf=pass (google.com: domain of dario.binacchi@amarulasolutions.com designates 209.85.220.41 as permitted sender) smtp.mailfrom=dario.binacchi@amarulasolutions.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , From: Michael Trimarchi Add support for imx8mn architecture in order to run the NAND in fast edo mode Signed-off-by: Michael Trimarchi Signed-off-by: Dario Binacchi --- drivers/mtd/nand/raw/mxs_nand.c | 202 +++++++++++++++++++++++++++++ drivers/mtd/nand/raw/mxs_nand_dt.c | 66 ++++++---- include/mxs_nand.h | 3 + 3 files changed, 244 insertions(+), 27 deletions(-) diff --git a/drivers/mtd/nand/raw/mxs_nand.c b/drivers/mtd/nand/raw/mxs_nand.c index 7893e9d7e343..4439f9846013 100644 --- a/drivers/mtd/nand/raw/mxs_nand.c +++ b/drivers/mtd/nand/raw/mxs_nand.c @@ -14,6 +14,7 @@ */ #include +#include #include #include #include @@ -26,10 +27,12 @@ #include #include #include +#include #include #include #include #include +#include #define MXS_NAND_DMA_DESCRIPTOR_COUNT 4 @@ -49,6 +52,10 @@ #endif #define MXS_NAND_BCH_TIMEOUT 10000 +#define USEC_PER_SEC 1000000 +#define NSEC_PER_SEC 1000000000L + +#define TO_CYCLES(duration, period) DIV_ROUND_UP_ULL(duration, period) struct nand_ecclayout fake_ecc_layout; @@ -1344,6 +1351,198 @@ err1: return ret; } +/* + * <1> Firstly, we should know what's the GPMI-clock means. + * The GPMI-clock is the internal clock in the gpmi nand controller. + * If you set 100MHz to gpmi nand controller, the GPMI-clock's period + * is 10ns. Mark the GPMI-clock's period as GPMI-clock-period. + * + * <2> Secondly, we should know what's the frequency on the nand chip pins. + * The frequency on the nand chip pins is derived from the GPMI-clock. + * We can get it from the following equation: + * + * F = G / (DS + DH) + * + * F : the frequency on the nand chip pins. + * G : the GPMI clock, such as 100MHz. + * DS : GPMI_HW_GPMI_TIMING0:DATA_SETUP + * DH : GPMI_HW_GPMI_TIMING0:DATA_HOLD + * + * <3> Thirdly, when the frequency on the nand chip pins is above 33MHz, + * the nand EDO(extended Data Out) timing could be applied. + * The GPMI implements a feedback read strobe to sample the read data. + * The feedback read strobe can be delayed to support the nand EDO timing + * where the read strobe may deasserts before the read data is valid, and + * read data is valid for some time after read strobe. + * + * The following figure illustrates some aspects of a NAND Flash read: + * + * |<---tREA---->| + * | | + * | | | + * |<--tRP-->| | + * | | | + * __ ___|__________________________________ + * RDN \________/ | + * | + * /---------\ + * Read Data --------------< >--------- + * \---------/ + * | | + * |<-D->| + * FeedbackRDN ________ ____________ + * \___________/ + * + * D stands for delay, set in the HW_GPMI_CTRL1:RDN_DELAY. + * + * + * <4> Now, we begin to describe how to compute the right RDN_DELAY. + * + * 4.1) From the aspect of the nand chip pins: + * Delay = (tREA + C - tRP) {1} + * + * tREA : the maximum read access time. + * C : a constant to adjust the delay. default is 4000ps. + * tRP : the read pulse width, which is exactly: + * tRP = (GPMI-clock-period) * DATA_SETUP + * + * 4.2) From the aspect of the GPMI nand controller: + * Delay = RDN_DELAY * 0.125 * RP {2} + * + * RP : the DLL reference period. + * if (GPMI-clock-period > DLL_THRETHOLD) + * RP = GPMI-clock-period / 2; + * else + * RP = GPMI-clock-period; + * + * Set the HW_GPMI_CTRL1:HALF_PERIOD if GPMI-clock-period + * is greater DLL_THRETHOLD. In other SOCs, the DLL_THRETHOLD + * is 16000ps, but in mx6q, we use 12000ps. + * + * 4.3) since {1} equals {2}, we get: + * + * (tREA + 4000 - tRP) * 8 + * RDN_DELAY = ----------------------- {3} + * RP + */ +static void mxs_compute_timings(struct nand_chip *chip, + const struct nand_sdr_timings *sdr) +{ + struct mxs_nand_info *nand_info = nand_get_controller_data(chip); + unsigned long int clk_rate; + unsigned int dll_wait_time_us; + unsigned int dll_threshold_ps = nand_info->max_chain_delay; + unsigned int period_ps, reference_period_ps; + unsigned int data_setup_cycles, data_hold_cycles, addr_setup_cycles; + unsigned int tRP_ps; + bool use_half_period; + int sample_delay_ps, sample_delay_factor; + u16 busy_timeout_cycles; + u8 wrn_dly_sel; + u32 timing0; + u32 timing1; + u32 ctrl1n; + + if (sdr->tRC_min >= 30000) { + /* ONFI non-EDO modes [0-3] */ + clk_rate = 22000000; + wrn_dly_sel = GPMI_CTRL1_WRN_DLY_SEL_4_TO_8NS; + } else if (sdr->tRC_min >= 25000) { + /* ONFI EDO mode 4 */ + clk_rate = 80000000; + wrn_dly_sel = GPMI_CTRL1_WRN_DLY_SEL_NO_DELAY; + debug("%s, setting ONFI onfi edo 4\n", __func__); + } else { + /* ONFI EDO mode 5 */ + clk_rate = 100000000; + wrn_dly_sel = GPMI_CTRL1_WRN_DLY_SEL_NO_DELAY; + debug("%s, setting ONFI onfi edo 5\n", __func__); + } + + /* SDR core timings are given in picoseconds */ + period_ps = div_u64((u64)NSEC_PER_SEC * 1000, clk_rate); + + addr_setup_cycles = TO_CYCLES(sdr->tALS_min, period_ps); + data_setup_cycles = TO_CYCLES(sdr->tDS_min, period_ps); + data_hold_cycles = TO_CYCLES(sdr->tDH_min, period_ps); + busy_timeout_cycles = TO_CYCLES(sdr->tWB_max + sdr->tR_max, period_ps); + + timing0 = (addr_setup_cycles << GPMI_TIMING0_ADDRESS_SETUP_OFFSET) | + (data_hold_cycles << GPMI_TIMING0_DATA_HOLD_OFFSET) | + (data_setup_cycles << GPMI_TIMING0_DATA_SETUP_OFFSET); + timing1 = (busy_timeout_cycles * 4096) << GPMI_TIMING1_DEVICE_BUSY_TIMEOUT_OFFSET; + + /* + * Derive NFC ideal delay from {3}: + * + * (tREA + 4000 - tRP) * 8 + * RDN_DELAY = ----------------------- + * RP + */ + if (period_ps > dll_threshold_ps) { + use_half_period = true; + reference_period_ps = period_ps / 2; + } else { + use_half_period = false; + reference_period_ps = period_ps; + } + + tRP_ps = data_setup_cycles * period_ps; + sample_delay_ps = (sdr->tREA_max + 4000 - tRP_ps) * 8; + if (sample_delay_ps > 0) + sample_delay_factor = sample_delay_ps / reference_period_ps; + else + sample_delay_factor = 0; + + ctrl1n = (wrn_dly_sel << GPMI_CTRL1_WRN_DLY_SEL_OFFSET); + if (sample_delay_factor) + ctrl1n |= (sample_delay_factor << GPMI_CTRL1_RDN_DELAY_OFFSET) | + GPMI_CTRL1_DLL_ENABLE | + (use_half_period ? GPMI_CTRL1_HALF_PERIOD : 0); + + + writel(timing0, &nand_info->gpmi_regs->hw_gpmi_timing0); + writel(timing1, &nand_info->gpmi_regs->hw_gpmi_timing1); + + /* + * Clear several CTRL1 fields, DLL must be disabled when setting + * RDN_DELAY or HALF_PERIOD. + */ + writel(GPMI_CTRL1_CLEAR_MASK, &nand_info->gpmi_regs->hw_gpmi_ctrl1_clr); + writel(ctrl1n, &nand_info->gpmi_regs->hw_gpmi_ctrl1_set); + + clk_set_rate(nand_info->gpmi_clk, clk_rate); + + /* Wait 64 clock cycles before using the GPMI after enabling the DLL */ + dll_wait_time_us = USEC_PER_SEC / clk_rate * 64; + if (!dll_wait_time_us) + dll_wait_time_us = 1; + + /* Wait for the DLL to settle. */ + udelay(dll_wait_time_us); +} + +static int mxs_nand_setup_interface(struct mtd_info *mtd, int chipnr, + const struct nand_data_interface *conf) +{ + struct nand_chip *chip = mtd_to_nand(mtd); + const struct nand_sdr_timings *sdr; + + + sdr = nand_get_sdr_timings(conf); + if (IS_ERR(sdr)) + return PTR_ERR(sdr); + + /* Stop here if this call was just a check */ + if (chipnr < 0) + return 0; + + /* Do the actual derivation of the controller timings */ + mxs_compute_timings(chip, sdr); + + return 0; +} + int mxs_nand_init_spl(struct nand_chip *nand) { struct mxs_nand_info *nand_info; @@ -1432,6 +1631,9 @@ int mxs_nand_init_ctrl(struct mxs_nand_info *nand_info) nand->read_buf = mxs_nand_read_buf; nand->write_buf = mxs_nand_write_buf; + if (nand_info->gpmi_clk) + nand->setup_data_interface = mxs_nand_setup_interface; + /* first scan to find the device and get the page size */ if (nand_scan_ident(mtd, CONFIG_SYS_MAX_NAND_DEVICE, NULL)) goto err_free_buffers; diff --git a/drivers/mtd/nand/raw/mxs_nand_dt.c b/drivers/mtd/nand/raw/mxs_nand_dt.c index 94ee7ed9ec83..102143d28a81 100644 --- a/drivers/mtd/nand/raw/mxs_nand_dt.c +++ b/drivers/mtd/nand/raw/mxs_nand_dt.c @@ -22,22 +22,27 @@ struct mxs_nand_dt_data { unsigned int max_ecc_strength_supported; + int max_chain_delay; /* See the async EDO mode */ }; static const struct mxs_nand_dt_data mxs_nand_imx6q_data = { .max_ecc_strength_supported = 40, + .max_chain_delay = 12000, }; static const struct mxs_nand_dt_data mxs_nand_imx6sx_data = { .max_ecc_strength_supported = 62, + .max_chain_delay = 12000, }; static const struct mxs_nand_dt_data mxs_nand_imx7d_data = { .max_ecc_strength_supported = 62, + .max_chain_delay = 12000, }; static const struct mxs_nand_dt_data mxs_nand_imx8qxp_data = { .max_ecc_strength_supported = 62, + .max_chain_delay = 12000, }; static const struct udevice_id mxs_nand_dt_ids[] = { @@ -72,8 +77,10 @@ static int mxs_nand_dt_probe(struct udevice *dev) int ret; data = (void *)dev_get_driver_data(dev); - if (data) + if (data) { info->max_ecc_strength_supported = data->max_ecc_strength_supported; + info->max_chain_delay = data->max_chain_delay; + } info->dev = dev; @@ -92,44 +99,49 @@ static int mxs_nand_dt_probe(struct udevice *dev) info->use_minimum_ecc = dev_read_bool(dev, "fsl,use-minimum-ecc"); - if (IS_ENABLED(CONFIG_CLK) && IS_ENABLED(CONFIG_IMX8)) { + if (IS_ENABLED(CONFIG_CLK) && + (IS_ENABLED(CONFIG_IMX8) || IS_ENABLED(CONFIG_IMX8M))) { /* Assigned clock already set clock */ struct clk gpmi_clk; - ret = clk_get_by_name(dev, "gpmi_io", &gpmi_clk); - if (ret < 0) { + info->gpmi_clk = devm_clk_get(dev, "gpmi_io"); + + if (IS_ERR(info->gpmi_clk)) { + ret = PTR_ERR(info->gpmi_clk); debug("Can't get gpmi io clk: %d\n", ret); return ret; } - ret = clk_enable(&gpmi_clk); + ret = clk_enable(info->gpmi_clk); if (ret < 0) { debug("Can't enable gpmi io clk: %d\n", ret); return ret; } - ret = clk_get_by_name(dev, "gpmi_apb", &gpmi_clk); - if (ret < 0) { - debug("Can't get gpmi_apb clk: %d\n", ret); - return ret; - } - - ret = clk_enable(&gpmi_clk); - if (ret < 0) { - debug("Can't enable gpmi_apb clk: %d\n", ret); - return ret; - } - - ret = clk_get_by_name(dev, "gpmi_bch", &gpmi_clk); - if (ret < 0) { - debug("Can't get gpmi_bch clk: %d\n", ret); - return ret; - } - - ret = clk_enable(&gpmi_clk); - if (ret < 0) { - debug("Can't enable gpmi_bch clk: %d\n", ret); - return ret; + if (IS_ENABLED(CONFIG_IMX8)) { + ret = clk_get_by_name(dev, "gpmi_apb", &gpmi_clk); + if (ret < 0) { + debug("Can't get gpmi_apb clk: %d\n", ret); + return ret; + } + + ret = clk_enable(&gpmi_clk); + if (ret < 0) { + debug("Can't enable gpmi_apb clk: %d\n", ret); + return ret; + } + + ret = clk_get_by_name(dev, "gpmi_bch", &gpmi_clk); + if (ret < 0) { + debug("Can't get gpmi_bch clk: %d\n", ret); + return ret; + } + + ret = clk_enable(&gpmi_clk); + if (ret < 0) { + debug("Can't enable gpmi_bch clk: %d\n", ret); + return ret; + } } ret = clk_get_by_name(dev, "gpmi_bch_apb", &gpmi_clk); diff --git a/include/mxs_nand.h b/include/mxs_nand.h index 741dc8734eae..bb5b84b8c26e 100644 --- a/include/mxs_nand.h +++ b/include/mxs_nand.h @@ -12,6 +12,7 @@ #include #include #include +#include /** * @gf_len: The length of Galois Field. (e.g., 13 or 14) @@ -43,6 +44,7 @@ struct mxs_nand_info { struct nand_chip chip; struct udevice *dev; unsigned int max_ecc_strength_supported; + int max_chain_delay; bool use_minimum_ecc; int cur_chip; @@ -59,6 +61,7 @@ struct mxs_nand_info { struct mxs_gpmi_regs *gpmi_regs; struct mxs_bch_regs *bch_regs; + struct clk *gpmi_clk; /* Functions with altered behaviour */ int (*hooked_read_oob)(struct mtd_info *mtd,