From patchwork Tue Mar 25 08:19:47 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 27005 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f200.google.com (mail-ob0-f200.google.com [209.85.214.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id CE29020062 for ; Tue, 25 Mar 2014 08:44:23 +0000 (UTC) Received: by mail-ob0-f200.google.com with SMTP id gq1sf578212obb.3 for ; Tue, 25 Mar 2014 01:44:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=MHhkYwIPqRpYY1mgyb9H4MKghTJ8mTpZdWGLwcAr7h8=; b=JiJ193B45B0Rel/EdqobeSHW2hRYKDs6mwiMxL5cBDFiGWOqzAQaSnQ353MN+wr78H tIK8EOD2SbbDXSNul6sFYims/4AcFxTW8C8B0cMnGYzfK7T7uXHCVbY2NsSnKP+3YVr2 g/Tq99PO+kVq6kz5P8vnDwbVdeLLOv9OnZXw3OlyHutXbdzfZXUCagzXG15Patn/lXpQ +zOIU1Uy85VBR+uf8Q8mEa9Hr4pkilR7w9Z+SWLmoBeCIQrCS4yGASZK7dtD4ku6ylUd jkcaLME7HrRuarsuvmHi/7mT11r6Tq0CGQCJId+lHFNFwZmBIkZDVFWnRsQFDHfasmNO UL7w== X-Gm-Message-State: ALoCoQkVO1QmVHGMxLW8BnTFEH4sGM2dnYtQG6W49zJ0c9224WBjAyXz0Zf7wOVKcFEaVnEztJgN X-Received: by 10.182.194.71 with SMTP id hu7mr14729708obc.37.1395737063313; Tue, 25 Mar 2014 01:44:23 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.31.230 with SMTP id f93ls123719qgf.67.gmail; Tue, 25 Mar 2014 01:44:23 -0700 (PDT) X-Received: by 10.52.175.166 with SMTP id cb6mr45654021vdc.1.1395737063167; Tue, 25 Mar 2014 01:44:23 -0700 (PDT) Received: from mail-vc0-f170.google.com (mail-vc0-f170.google.com [209.85.220.170]) by mx.google.com with ESMTPS id sq9si3680662vdc.125.2014.03.25.01.44.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Mar 2014 01:44:23 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.170; Received: by mail-vc0-f170.google.com with SMTP id hu19so155076vcb.15 for ; Tue, 25 Mar 2014 01:44:23 -0700 (PDT) X-Received: by 10.58.188.52 with SMTP id fx20mr124932vec.28.1395737063080; Tue, 25 Mar 2014 01:44:23 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.78.9 with SMTP id i9csp286570vck; Tue, 25 Mar 2014 01:44:22 -0700 (PDT) X-Received: by 10.66.232.7 with SMTP id tk7mr77883655pac.94.1395737061957; Tue, 25 Mar 2014 01:44:21 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id nc6si10918355pbc.324.2014.03.25.01.44.21; Tue, 25 Mar 2014 01:44:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754384AbaCYIoJ (ORCPT + 26 others); Tue, 25 Mar 2014 04:44:09 -0400 Received: from mail-wi0-f178.google.com ([209.85.212.178]:47216 "EHLO mail-wi0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753076AbaCYIVQ (ORCPT ); Tue, 25 Mar 2014 04:21:16 -0400 Received: by mail-wi0-f178.google.com with SMTP id bs8so339578wib.5 for ; Tue, 25 Mar 2014 01:21:15 -0700 (PDT) X-Received: by 10.180.189.139 with SMTP id gi11mr21193272wic.53.1395735675583; Tue, 25 Mar 2014 01:21:15 -0700 (PDT) Received: from lee--X1.home (host109-148-113-193.range109-148.btcentralplus.com. [109.148.113.193]) by mx.google.com with ESMTPSA id k4sm5567676wib.19.2014.03.25.01.21.13 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 25 Mar 2014 01:21:14 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: lee.jones@linaro.org, kernel@stlinux.com, computersforpeace@gmail.com, linux-mtd@lists.infradead.org, dwmw2@infradead.org, angus.clark@st.com, pekon@ti.com Subject: [RFC 30/47] mtd: nand: stm_nand_bch: read and write raw (FLEX) Date: Tue, 25 Mar 2014 08:19:47 +0000 Message-Id: <1395735604-26706-31-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1395735604-26706-1-git-send-email-lee.jones@linaro.org> References: <1395735604-26706-1-git-send-email-lee.jones@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Once the correct READ/WRITE(SEQIN) commands and address locations have been sent to the Controller, these calls are able to read/write the requested information from the FLEX_DATA register. Signed-off-by: Lee Jones --- drivers/mtd/nand/stm_nand_bch.c | 77 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/drivers/mtd/nand/stm_nand_bch.c b/drivers/mtd/nand/stm_nand_bch.c index baecc40..4812431 100644 --- a/drivers/mtd/nand/stm_nand_bch.c +++ b/drivers/mtd/nand/stm_nand_bch.c @@ -537,6 +537,83 @@ static void flex_addr(struct nandi_controller *nandi, writel(addr, nandi->base + NANDHAM_FLEX_ADD); } +static int flex_read_raw(struct nandi_controller *nandi, + uint32_t page_addr, + uint32_t col_addr, + uint8_t *buf, uint32_t len) +{ + dev_dbg(nandi->dev, "%s %u bytes at [0x%06x,0x%04x]\n", + __func__, len, page_addr, col_addr); + + BUG_ON(len & 0x3); + BUG_ON((unsigned long)buf & 0x3); + + emiss_nandi_select(STM_NANDI_HAMMING); + nandi_enable_interrupts(nandi, NAND_INT_RBN); + reinit_completion(&nandi->rbn_completed); + + writel(FLEX_DATA_CFG_BEATS_4 | FLEX_DATA_CFG_CSN, + nandi->base + NANDHAM_FLEX_DATAREAD_CONFIG); + + flex_cmd(nandi, NAND_CMD_READ0); + flex_addr(nandi, col_addr, 2); + flex_addr(nandi, page_addr, nandi->extra_addr ? 3 : 2); + flex_cmd(nandi, NAND_CMD_READSTART); + + flex_wait_rbn(nandi); + + readsl(nandi->base + NANDHAM_FLEX_DATA, buf, len / 4); + + nandi_disable_interrupts(nandi, NAND_INT_RBN); + + writel(FLEX_DATA_CFG_BEATS_1 | FLEX_DATA_CFG_CSN, + nandi->base + NANDHAM_FLEX_DATAREAD_CONFIG); + + return 0; +} + +static int flex_write_raw(struct nandi_controller *nandi, + uint32_t page_addr, + uint32_t col_addr, + uint8_t *buf, uint32_t len) +{ + uint8_t status; + + dev_dbg(nandi->dev, "%s %u bytes at [0x%06x,0x%04x]\n", + __func__, len, page_addr, col_addr); + + BUG_ON(len & 0x3); + BUG_ON((unsigned long)buf & 0x3); + + emiss_nandi_select(STM_NANDI_HAMMING); + nandi_enable_interrupts(nandi, NAND_INT_RBN); + reinit_completion(&nandi->rbn_completed); + + writel(FLEX_DATA_CFG_BEATS_4 | FLEX_DATA_CFG_CSN, + nandi->base + NANDHAM_FLEX_DATAWRITE_CONFIG); + + flex_cmd(nandi, NAND_CMD_SEQIN); + flex_addr(nandi, col_addr, 2); + flex_addr(nandi, page_addr, nandi->extra_addr ? 3 : 2); + + writesl(nandi->base + NANDHAM_FLEX_DATA, buf, len / 4); + + flex_cmd(nandi, NAND_CMD_PAGEPROG); + + flex_wait_rbn(nandi); + + nandi_disable_interrupts(nandi, NAND_INT_RBN); + + writel(FLEX_DATA_CFG_BEATS_1 | FLEX_DATA_CFG_CSN, + nandi->base + NANDHAM_FLEX_DATAWRITE_CONFIG); + + flex_cmd(nandi, NAND_CMD_STATUS); + + status = (uint8_t)(readl(nandi->base + NANDHAM_FLEX_DATA) & 0xff); + + return status; +} + /* * Bad Block Tables/Bad Block Markers */