jtag: linuxgpiod: drop extra parenthesis
[openocd.git] / src / flash / nand / mxc.c
index 2c5de0394e1eded81b2a4939745211e77cda11db..845a3bb9a6997c383f7df5fd69d9668f28833282 100644 (file)
@@ -1,3 +1,5 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
 /***************************************************************************
  *   Copyright (C) 2009 by Alexei Babich                                   *
  *   Rezonans plc., Chelyabinsk, Russia                                    *
@@ -8,19 +10,6 @@
  *                                                                         *
  *   Copyright (C) 2011 by Erik Ahlen                                      *
  *   Avalon Innovation, Sweden                                             *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
  ***************************************************************************/
 
 /*
@@ -89,7 +78,7 @@ NAND_DEVICE_COMMAND_HANDLER(mxc_nand_device_command)
        int hwecc_needed;
 
        mxc_nf_info = malloc(sizeof(struct mxc_nf_controller));
-       if (mxc_nf_info == NULL) {
+       if (!mxc_nf_info) {
                LOG_ERROR("no memory for nand controller");
                return ERROR_FAIL;
        }
@@ -207,9 +196,9 @@ static int mxc_init(struct nand_device *nand)
        int validate_target_result;
        uint16_t buffsize_register_content;
        uint32_t sreg_content;
-       uint32_t SREG = MX2_FMCR;
-       uint32_t SEL_16BIT = MX2_FMCR_NF_16BIT_SEL;
-       uint32_t SEL_FMS = MX2_FMCR_NF_FMS;
+       uint32_t sreg = MX2_FMCR;
+       uint32_t sel_16bit = MX2_FMCR_NF_16BIT_SEL;
+       uint32_t sel_fms = MX2_FMCR_NF_FMS;
        int retval;
        uint16_t nand_status_content;
        /*
@@ -226,27 +215,27 @@ static int mxc_init(struct nand_device *nand)
                mxc_nf_info->flags.one_kb_sram = 0;
 
        if (mxc_nf_info->mxc_version == MXC_VERSION_MX31) {
-               SREG = MX3_PCSR;
-               SEL_16BIT = MX3_PCSR_NF_16BIT_SEL;
-               SEL_FMS = MX3_PCSR_NF_FMS;
+               sreg = MX3_PCSR;
+               sel_16bit = MX3_PCSR_NF_16BIT_SEL;
+               sel_fms = MX3_PCSR_NF_FMS;
        } else if (mxc_nf_info->mxc_version == MXC_VERSION_MX25) {
-               SREG = MX25_RCSR;
-               SEL_16BIT = MX25_RCSR_NF_16BIT_SEL;
-               SEL_FMS = MX25_RCSR_NF_FMS;
+               sreg = MX25_RCSR;
+               sel_16bit = MX25_RCSR_NF_16BIT_SEL;
+               sel_fms = MX25_RCSR_NF_FMS;
        } else if (mxc_nf_info->mxc_version == MXC_VERSION_MX35) {
-               SREG = MX35_RCSR;
-               SEL_16BIT = MX35_RCSR_NF_16BIT_SEL;
-               SEL_FMS = MX35_RCSR_NF_FMS;
+               sreg = MX35_RCSR;
+               sel_16bit = MX35_RCSR_NF_16BIT_SEL;
+               sel_fms = MX35_RCSR_NF_FMS;
        }
 
-       target_read_u32(target, SREG, &sreg_content);
+       target_read_u32(target, sreg, &sreg_content);
        if (!nand->bus_width) {
                /* bus_width not yet defined. Read it from MXC_FMCR */
-               nand->bus_width = (sreg_content & SEL_16BIT) ? 16 : 8;
+               nand->bus_width = (sreg_content & sel_16bit) ? 16 : 8;
        } else {
                /* bus_width forced in soft. Sync it to MXC_FMCR */
-               sreg_content |= ((nand->bus_width == 16) ? SEL_16BIT : 0x00000000);
-               target_write_u32(target, SREG, sreg_content);
+               sreg_content |= ((nand->bus_width == 16) ? sel_16bit : 0x00000000);
+               target_write_u32(target, sreg, sreg_content);
        }
        if (nand->bus_width == 16)
                LOG_DEBUG("MXC_NF : bus is 16-bit width");
@@ -254,10 +243,10 @@ static int mxc_init(struct nand_device *nand)
                LOG_DEBUG("MXC_NF : bus is 8-bit width");
 
        if (!nand->page_size)
-               nand->page_size = (sreg_content & SEL_FMS) ? 2048 : 512;
+               nand->page_size = (sreg_content & sel_fms) ? 2048 : 512;
        else {
-               sreg_content |= ((nand->page_size == 2048) ? SEL_FMS : 0x00000000);
-               target_write_u32(target, SREG, sreg_content);
+               sreg_content |= ((nand->page_size == 2048) ? sel_fms : 0x00000000);
+               target_write_u32(target, sreg, sreg_content);
        }
        if (mxc_nf_info->flags.one_kb_sram && (nand->page_size == 2048)) {
                LOG_ERROR("NAND controller have only 1 kb SRAM, so "
@@ -649,18 +638,18 @@ static int mxc_read_page(struct nand_device *nand, uint32_t page,
        }
 
        if (nand->page_size > 512 && mxc_nf_info->flags.biswap_enabled) {
-               uint32_t SPARE_BUFFER3;
+               uint32_t spare_buffer3;
                /* BI-swap -  work-around of mxc NFC for NAND device with page == 2k */
                target_read_u16(target, MXC_NF_MAIN_BUFFER3 + 464, &swap1);
                if (nfc_is_v1())
-                       SPARE_BUFFER3 = MXC_NF_V1_SPARE_BUFFER3 + 4;
+                       spare_buffer3 = MXC_NF_V1_SPARE_BUFFER3 + 4;
                else
-                       SPARE_BUFFER3 = MXC_NF_V2_SPARE_BUFFER3;
-               target_read_u16(target, SPARE_BUFFER3, &swap2);
+                       spare_buffer3 = MXC_NF_V2_SPARE_BUFFER3;
+               target_read_u16(target, spare_buffer3, &swap2);
                new_swap1 = (swap1 & 0xFF00) | (swap2 >> 8);
                swap2 = (swap1 << 8) | (swap2 & 0xFF);
                target_write_u16(target, MXC_NF_MAIN_BUFFER3 + 464, new_swap1);
-               target_write_u16(target, SPARE_BUFFER3, swap2);
+               target_write_u16(target, spare_buffer3, swap2);
        }
 
        if (data)
@@ -860,7 +849,7 @@ static int validate_target_state(struct nand_device *nand)
        return ERROR_OK;
 }
 
-int ecc_status_v1(struct nand_device *nand)
+static int ecc_status_v1(struct nand_device *nand)
 {
        struct mxc_nf_controller *mxc_nf_info = nand->controller_priv;
        struct target *target = nand->target;
@@ -886,7 +875,7 @@ int ecc_status_v1(struct nand_device *nand)
        return ERROR_OK;
 }
 
-int ecc_status_v2(struct nand_device *nand)
+static int ecc_status_v2(struct nand_device *nand)
 {
        struct mxc_nf_controller *mxc_nf_info = nand->controller_priv;
        struct target *target = nand->target;

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)