From patchwork Thu May 1 09:56:51 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 29487 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f199.google.com (mail-pd0-f199.google.com [209.85.192.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 592C0203F3 for ; Thu, 1 May 2014 09:58:37 +0000 (UTC) Received: by mail-pd0-f199.google.com with SMTP id fp1sf12373579pdb.6 for ; Thu, 01 May 2014 02:58:36 -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:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=9e/XR9/RLiMKNUECsG9hYQTmYldmlwIW3VGFz7wAp7U=; b=IyWLhQWYTdEx6Kn7xg+PnGnuEGOrgTXCNHrMD0LjZZW0dV8xxCmbVui9/pTiDNyuV6 xl6cSPzmhDFt/d3axkzdFTh/DRqbrtPtzT87dWoKYfqPlE87vG+OPKRvFXQz56vi1w8U pYcv77+NY9nppiyurKzZ3WcM5pNgJy4jCLHOlxz3i9qr0m5UNOsgIc7X7eUzvyyWcXjp f+v35YGJX8EbMyfUdbCuSJiMmGbzPlNY4iPONpDr+iIVNeHwgH5Gdr7CHdZCWGXiKMP2 TWC+kWr9BJN084rts2kIgAyUvl2hJGWUOWYb5qY+4ay1rU+xSJGPWH2ux4QRPyfWPZ9z daIg== X-Gm-Message-State: ALoCoQlQwu7Frjr7bqCcdRLY1TkeQ0SuvB3zxiiR3jHuRCyFIWvgBoqJ2bHLvAcKujET/kYgeA3g X-Received: by 10.66.222.129 with SMTP id qm1mr5171240pac.6.1398938316466; Thu, 01 May 2014 02:58:36 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.82.145 with SMTP id h17ls1041608qgd.31.gmail; Thu, 01 May 2014 02:58:36 -0700 (PDT) X-Received: by 10.220.105.130 with SMTP id t2mr8136097vco.18.1398938316295; Thu, 01 May 2014 02:58:36 -0700 (PDT) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by mx.google.com with ESMTPS id u5si5951403vdo.22.2014.05.01.02.58.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 02:58:36 -0700 (PDT) Received-SPF: none (google.com: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) client-ip=209.85.128.177; Received: by mail-ve0-f177.google.com with SMTP id sa20so3585232veb.36 for ; Thu, 01 May 2014 02:58:36 -0700 (PDT) X-Received: by 10.58.1.97 with SMTP id 1mr8407182vel.23.1398938316232; Thu, 01 May 2014 02:58:36 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.221.72 with SMTP id ib8csp12983vcb; Thu, 1 May 2014 02:58:35 -0700 (PDT) X-Received: by 10.180.72.179 with SMTP id e19mr1424915wiv.61.1398938315032; Thu, 01 May 2014 02:58:35 -0700 (PDT) Received: from mail-wi0-f179.google.com (mail-wi0-f179.google.com [209.85.212.179]) by mx.google.com with ESMTPS id be3si583882wib.9.2014.05.01.02.58.34 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 02:58:35 -0700 (PDT) Received-SPF: none (google.com: lee.jones@linaro.org does not designate permitted sender hosts) client-ip=209.85.212.179; Received: by mail-wi0-f179.google.com with SMTP id bs8so387783wib.0 for ; Thu, 01 May 2014 02:58:34 -0700 (PDT) X-Received: by 10.180.212.48 with SMTP id nh16mr1442530wic.49.1398938314524; Thu, 01 May 2014 02:58:34 -0700 (PDT) Received: from lee--X1.home (host109-148-238-223.range109-148.btcentralplus.com. [109.148.238.223]) by mx.google.com with ESMTPSA id bj5sm2696494wib.3.2014.05.01.02.58.32 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 01 May 2014 02:58:33 -0700 (PDT) From: Lee Jones To: linux-kernel@vger.kernel.org Cc: computersforpeace@gmail.com, linux-mtd@lists.infradead.org, kernel@stlinux.com, Lee Jones Subject: [PATCH 44/47] mtd: nand: mtd_nand_bch: add remaining FLEX functions Date: Thu, 1 May 2014 10:56:51 +0100 Message-Id: <1398938214-17847-45-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1398938214-17847-1-git-send-email-lee.jones@linaro.org> References: <1398938214-17847-1-git-send-email-lee.jones@linaro.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: patch+caf_=patchwork-forward=linaro.org@linaro.org does not designate permitted sender hosts) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Including a dummy function for selecting chips which isn't supported by our driver, the wait function as requested by the NAND sub system, a read Byte function also requested by NAND and finally a command function which provides a partial implementation of MTD/NAND Interface, based on Hamming-FLEX operation which allows us to make use of nand_base.c functions where possible (i.e.nand_scan_ident()). Signed-off-by: Lee Jones --- drivers/mtd/nand/stm_nand_bch.c | 101 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) diff --git a/drivers/mtd/nand/stm_nand_bch.c b/drivers/mtd/nand/stm_nand_bch.c index ba6ac8f..89f1263 100644 --- a/drivers/mtd/nand/stm_nand_bch.c +++ b/drivers/mtd/nand/stm_nand_bch.c @@ -770,6 +770,103 @@ static void flex_addr(struct nandi_controller *nandi, writel(addr, nandi->base + NANDHAM_FLEX_ADD); } +/* + * Partial implementation of MTD/NAND Interface, based on Hamming-FLEX + * operation. + * + * Allows us to make use of nand_base.c functions where possible + * (e.g. nand_scan_ident() and friends). + */ +static void flex_command_lp(struct mtd_info *mtd, unsigned int command, + int column, int page) +{ + struct nand_chip *chip = mtd->priv; + struct nandi_controller *nandi = chip->priv; + + emiss_nandi_select(STM_NANDI_HAMMING); + + switch (command) { + case NAND_CMD_READOOB: + /* Emulate NAND_CMD_READOOB */ + column += mtd->writesize; + command = NAND_CMD_READ0; + break; + case NAND_CMD_READ0: + case NAND_CMD_ERASE1: + case NAND_CMD_SEQIN: + case NAND_CMD_RESET: + case NAND_CMD_PARAM: + /* Prime RBn wait */ + nandi_enable_interrupts(nandi, NAND_INT_RBN); + reinit_completion(&nandi->rbn_completed); + break; + case NAND_CMD_READID: + case NAND_CMD_STATUS: + case NAND_CMD_ERASE2: + break; + default: + /* Catch unexpected commands */ + BUG(); + } + + /* + * Command Cycle + */ + flex_cmd(nandi, command); + + /* + * Address Cycles + */ + if (column != -1) + flex_addr(nandi, column, + (command == NAND_CMD_READID) ? 1 : 2); + + if (page != -1) + flex_addr(nandi, page, nandi->extra_addr ? 3 : 2); + + /* Complete 'READ0' command */ + if (command == NAND_CMD_READ0) + flex_cmd(nandi, NAND_CMD_READSTART); + + /* Wait for RBn, if required */ + /* (Note, other commands may handle wait elsewhere) */ + if (command == NAND_CMD_RESET || + command == NAND_CMD_READ0 || + command == NAND_CMD_PARAM) { + flex_wait_rbn(nandi); + nandi_disable_interrupts(nandi, NAND_INT_RBN); + } +} + +static uint8_t flex_read_byte(struct mtd_info *mtd) +{ + struct nand_chip *chip = mtd->priv; + struct nandi_controller *nandi = chip->priv; + + emiss_nandi_select(STM_NANDI_HAMMING); + + return (uint8_t)(readl(nandi->base + NANDHAM_FLEX_DATA) & 0xff); +} + +static int flex_wait_func(struct mtd_info *mtd, struct nand_chip *chip) +{ + struct nandi_controller *nandi = chip->priv; + + emiss_nandi_select(STM_NANDI_HAMMING); + + flex_wait_rbn(nandi); + + flex_cmd(nandi, NAND_CMD_STATUS); + + return (int)(readl(nandi->base + NANDHAM_FLEX_DATA) & 0xff); +} + +/* Multi-CS devices not supported */ +static void flex_select_chip(struct mtd_info *mtd, int chipnr) +{ + +} + static void flex_read_buf(struct mtd_info *mtd, uint8_t *buf, int len) { struct nand_chip *chip = mtd->priv; @@ -1485,6 +1582,10 @@ static void nandi_set_mtd_defaults(struct nandi_controller *nandi, chip->ecc.layout = &info->ecclayout; chip->options |= NAND_NO_SUBPAGE_WRITE; + chip->cmdfunc = flex_command_lp; + chip->read_byte = flex_read_byte; + chip->select_chip = flex_select_chip; + chip->waitfunc = flex_wait_func; chip->read_buf = flex_read_buf; chip->write_buf = flex_write_buf;