From patchwork Tue Feb 18 14:55:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 24876 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f69.google.com (mail-yh0-f69.google.com [209.85.213.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 938CD202B2 for ; Tue, 18 Feb 2014 15:00:11 +0000 (UTC) Received: by mail-yh0-f69.google.com with SMTP id a41sf35458465yho.0 for ; Tue, 18 Feb 2014 07:00:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:subject:date:message-id :in-reply-to:references:cc:precedence:list-id:list-unsubscribe :list-archive:list-post:list-help:list-subscribe:mime-version:sender :errors-to:x-original-sender:x-original-authentication-results :mailing-list:content-type:content-transfer-encoding; bh=9UU4KYqbKIgF3qC0b6pc9k+1U3NbOEcQ3/bz2uo0el0=; b=b/d/twFI+wp2hYw81XVDF7eXkfZVJzgYR+V5xf1BR3VjinH6e43nRSIYBPN7jaqCWk ulpxKaIhjU4CHFbm5e0ikLVNl9nO/fRdAJe1jjNypS568792/FXbsKSZhYrFdyJ7tasz 6wMQypxwNzayW8A657LNOmQlVWgemV9vFC378GdQer84jDJ6tCGBvtQZv5fmohBhIdyh 6X9sjC7kkz1Vab910lg7vGSSwHbmYz8RTKy1XUbOffpun5HoHIZovDo2j1vtxZxtIOhz DAJhlZDKLYyA6fkFCwv4CLWDD4Bs8U9sh3S1FeESPwmVczvwzjU6MTcInWQI7FCzCC4a BFKQ== X-Gm-Message-State: ALoCoQmQymByKvdb4eeUTLv9ZTlnbml9K24ut8K5M79poJvFVFUogmUuM9ZvFjkqA7d5YRsYXVdJ X-Received: by 10.236.78.232 with SMTP id g68mr11718498yhe.19.1392735610424; Tue, 18 Feb 2014 07:00:10 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.28.6 with SMTP id 6ls1293774qgy.16.gmail; Tue, 18 Feb 2014 07:00:10 -0800 (PST) X-Received: by 10.220.48.194 with SMTP id s2mr2423067vcf.43.1392735610336; Tue, 18 Feb 2014 07:00:10 -0800 (PST) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id yb7si5576998vec.77.2014.02.18.07.00.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Feb 2014 07:00:10 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.169 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.169; Received: by mail-vc0-f169.google.com with SMTP id hq11so13568901vcb.28 for ; Tue, 18 Feb 2014 07:00:10 -0800 (PST) X-Received: by 10.52.23.68 with SMTP id k4mr14763286vdf.24.1392735610250; Tue, 18 Feb 2014 07:00:10 -0800 (PST) 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.174.196 with SMTP id u4csp222743vcz; Tue, 18 Feb 2014 07:00:09 -0800 (PST) X-Received: by 10.194.62.243 with SMTP id b19mr2410834wjs.63.1392735609331; Tue, 18 Feb 2014 07:00:09 -0800 (PST) Received: from casper.infradead.org (casper.infradead.org. [2001:770:15f::2]) by mx.google.com with ESMTPS id z9si12296878wiv.52.2014.02.18.07.00.08 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Feb 2014 07:00:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2001:770:15f::2 as permitted sender) client-ip=2001:770:15f::2; Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WFm8R-0006zD-MV; Tue, 18 Feb 2014 14:59:00 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1WFm7x-0007Z2-MD; Tue, 18 Feb 2014 14:58:29 +0000 Received: from mail-we0-f180.google.com ([74.125.82.180]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1WFm6l-0007E6-Jk for linux-mtd@lists.infradead.org; Tue, 18 Feb 2014 14:57:22 +0000 Received: by mail-we0-f180.google.com with SMTP id u57so11511300wes.25 for ; Tue, 18 Feb 2014 06:56:53 -0800 (PST) X-Received: by 10.194.234.106 with SMTP id ud10mr23558883wjc.0.1392735413717; Tue, 18 Feb 2014 06:56:53 -0800 (PST) Received: from localhost.localdomain ([80.76.198.141]) by mx.google.com with ESMTPSA id h13sm46039687wjr.22.2014.02.18.06.56.51 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Feb 2014 06:56:52 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/35] mtd: st_spi_fsm: Search for preferred FSM message sequence configurations Date: Tue, 18 Feb 2014 14:55:37 +0000 Message-Id: <1392735362-1245-11-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1392735362-1245-1-git-send-email-lee.jones@linaro.org> References: <1392735362-1245-1-git-send-email-lee.jones@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140218_095715_890111_03E1CF78 X-CRM114-Status: GOOD ( 12.71 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [74.125.82.180 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Angus.Clark@st.com, lee.jones@linaro.org, DCG_UPD_stlinux_kernel@list.st.com, linux-mtd@lists.infradead.org, computersforpeace@gmail.com, dwmw2@infradead.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.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.169 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 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 90fbd64..68fa12e 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;