From patchwork Thu Mar 20 09:20:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 26643 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f197.google.com (mail-ob0-f197.google.com [209.85.214.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 0D3A6202E0 for ; Thu, 20 Mar 2014 09:21:42 +0000 (UTC) Received: by mail-ob0-f197.google.com with SMTP id wp18sf2314170obc.0 for ; Thu, 20 Mar 2014 02:21:42 -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=Q46LsqakaaViNqf0TOmwxbjgaNrProrFE86yCKRtf+U=; b=hCyvHufCrVeYTDh3AmZSz1NejJ24yzor+JNe6zRtma1TCNyFUU+HtKjmm17xNLkgxe G7ByaqTRLOn1cx3B+hiNj0nCgNPYwSZlvs0GRTmJz6FEnrw+k3kiCkvCQxKUPayIfgpd F7pXWZErgMqsFdanQgTneQ85ODp/TwrHeHEo17Br3EXHE4Ovk5C8Nh/YRMrPKCT/P0XK N4OoVK4eM3SMl9roHSSBqO5vzpcMRP3Igg1sQfrreGAR7fKu2tgPqZL9MrOvJYBg+2Mi annRalZ7XDSptGZsBEJqZipFT5O5Epi+z+TqLzZIJOTl+BWWmGRJoGH46CyL0pNnrq49 Y3fw== X-Gm-Message-State: ALoCoQkcENOs+ARQngrC/XqFfEY1l4Z+mSYkzOVVzKDz5svBZNPlvHfl2uGRyjgElDCNRU6/xsXu X-Received: by 10.182.55.102 with SMTP id r6mr3210894obp.7.1395307302394; Thu, 20 Mar 2014 02:21:42 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.33.203 with SMTP id j69ls152931qgj.27.gmail; Thu, 20 Mar 2014 02:21:42 -0700 (PDT) X-Received: by 10.220.10.2 with SMTP id n2mr4481733vcn.26.1395307302274; Thu, 20 Mar 2014 02:21:42 -0700 (PDT) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id xg17si284197vcb.190.2014.03.20.02.21.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Mar 2014 02:21:42 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.176; Received: by mail-ve0-f176.google.com with SMTP id cz12so586682veb.21 for ; Thu, 20 Mar 2014 02:21:42 -0700 (PDT) X-Received: by 10.58.34.101 with SMTP id y5mr33349167vei.8.1395307302202; Thu, 20 Mar 2014 02:21:42 -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.78.9 with SMTP id i9csp372512vck; Thu, 20 Mar 2014 02:21:41 -0700 (PDT) X-Received: by 10.180.101.230 with SMTP id fj6mr1690604wib.27.1395307300913; Thu, 20 Mar 2014 02:21:40 -0700 (PDT) Received: from mail-wg0-f42.google.com (mail-wg0-f42.google.com [74.125.82.42]) by mx.google.com with ESMTPS id pe2si832379wjb.132.2014.03.20.02.21.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Mar 2014 02:21:40 -0700 (PDT) Received-SPF: neutral (google.com: 74.125.82.42 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.42; Received: by mail-wg0-f42.google.com with SMTP id y10so366509wgg.1 for ; Thu, 20 Mar 2014 02:21:40 -0700 (PDT) X-Received: by 10.194.2.194 with SMTP id 2mr6005474wjw.73.1395307300270; Thu, 20 Mar 2014 02:21:40 -0700 (PDT) Received: from lee--X1.home (host109-148-116-196.range109-148.btcentralplus.com. [109.148.116.196]) by mx.google.com with ESMTPSA id di9sm4735120wid.6.2014.03.20.02.21.38 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Mar 2014 02:21:39 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, computersforpeace@gmail.com Cc: linux-mtd@lists.infradead.org, dwmw2@infradead.org, Angus.Clark@st.com, Lee Jones Subject: [PATCH v6 10/36] mtd: st_spi_fsm: Search for preferred FSM message sequence configurations Date: Thu, 20 Mar 2014 09:20:42 +0000 Message-Id: <1395307268-12721-11-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1395307268-12721-1-git-send-email-lee.jones@linaro.org> References: <1395307268-12721-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: 209.85.128.176 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 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: , Here we provide a means to traverse though all supplied FSM message sequence configurations and pick one based on our chip's capabilities. The first one we match will be the preferred one, as they are presented in order of preference. Acked-by Angus Clark Signed-off-by: Lee Jones --- drivers/mtd/devices/st_spi_fsm.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c index 9467585..2740ae1 100644 --- a/drivers/mtd/devices/st_spi_fsm.c +++ b/drivers/mtd/devices/st_spi_fsm.c @@ -222,6 +222,18 @@ struct stfsm_seq { uint32_t seq_cfg; } __packed __aligned(4); +/* Parameters to configure a READ or WRITE FSM sequence */ +struct seq_rw_config { + uint32_t flags; /* flags to support config */ + uint8_t cmd; /* FLASH command */ + int write; /* Write Sequence */ + uint8_t addr_pads; /* No. of addr pads (MODE & DUMMY) */ + uint8_t data_pads; /* No. of data pads */ + uint8_t mode_data; /* MODE data */ + uint8_t mode_cycles; /* No. of MODE cycles */ + uint8_t dummy_cycles; /* No. of DUMMY cycles */ +}; + /* SPI Flash Device Table */ struct flash_info { char *name; @@ -462,6 +474,21 @@ static void stfsm_read_fifo(struct stfsm *fsm, uint32_t *buf, } } +/* Search for preferred configuration based on available flags */ +static struct seq_rw_config * +stfsm_search_seq_rw_configs(struct stfsm *fsm, + struct seq_rw_config cfgs[]) +{ + struct seq_rw_config *config; + int flags = fsm->info->flags; + + for (config = cfgs; config->cmd != 0; config++) + if ((config->flags & flags) == config->flags) + return config; + + return NULL; +} + static void stfsm_read_jedec(struct stfsm *fsm, uint8_t *const jedec) { const struct stfsm_seq *seq = &stfsm_seq_read_jedec;