From patchwork Wed Jan 8 13:46:54 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 22947 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f199.google.com (mail-ve0-f199.google.com [209.85.128.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2EE34202E2 for ; Wed, 8 Jan 2014 13:48:43 +0000 (UTC) Received: by mail-ve0-f199.google.com with SMTP id c14sf2466072vea.2 for ; Wed, 08 Jan 2014 05:48:42 -0800 (PST) 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=l85AJsvSO9Ecmbqq+b6jaGP+gwi4ZnJIA6yGmcTRWXg=; b=VKT364o9kZvvuo1jAXVMKRfsJiqNGauYwfXXDiTu0qXbAYe0wcxCymt14lFWH+4hI6 l1zvL5FH6UivIOrUpn8WjqNLxGwGN7E+usI/QLEmYAba4lTC0FE1n4C0Sskbmp/9kjWO ipzPPQguWY3phkhOwq2ryW7WutnCvgshAatKbRSwAPSjXqWwpCMWZ48mcrzE5yyTRYsz GzM4wsHhYWQn/ds9k2jmVfJLUA6ePQuBZ1OvF5Tv6IlgA0GJp6o4yjnieKgJCj96smKP Es05pUsgJxB/C7D4K0arvgZII3J3RYtHSynZ8RCiVB9NLHOTt9Ed16Mi4mH647jcrQfz uJsw== X-Gm-Message-State: ALoCoQkhx5jC4cShgQnKfYlooa747pIDfuGq0/AwOkDPSQ85nwP3LOJIm3Ezy+mgKHeQ4Ry8Bm2q X-Received: by 10.236.132.231 with SMTP id o67mr1061651yhi.15.1389188922323; Wed, 08 Jan 2014 05:48:42 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.110.198 with SMTP id ic6ls625233qeb.29.gmail; Wed, 08 Jan 2014 05:48:42 -0800 (PST) X-Received: by 10.58.90.230 with SMTP id bz6mr9734288veb.21.1389188922191; Wed, 08 Jan 2014 05:48:42 -0800 (PST) Received: from mail-ve0-f169.google.com (mail-ve0-f169.google.com [209.85.128.169]) by mx.google.com with ESMTPS id e3si608464vek.55.2014.01.08.05.48.42 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 08 Jan 2014 05:48:42 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.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.128.169; Received: by mail-ve0-f169.google.com with SMTP id c14so1242931vea.14 for ; Wed, 08 Jan 2014 05:48:42 -0800 (PST) X-Received: by 10.53.8.1 with SMTP id dg1mr2677737vdd.52.1389188922072; Wed, 08 Jan 2014 05:48:42 -0800 (PST) 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.59.13.131 with SMTP id ey3csp226607ved; Wed, 8 Jan 2014 05:48:41 -0800 (PST) X-Received: by 10.180.13.242 with SMTP id k18mr21630988wic.44.1389188921043; Wed, 08 Jan 2014 05:48:41 -0800 (PST) Received: from mail-we0-f172.google.com (mail-we0-f172.google.com [74.125.82.172]) by mx.google.com with ESMTPS id ca3si16038686wjc.75.2014.01.08.05.48.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 08 Jan 2014 05:48:41 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.172 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.172; Received: by mail-we0-f172.google.com with SMTP id p61so1479994wes.3 for ; Wed, 08 Jan 2014 05:48:40 -0800 (PST) X-Received: by 10.194.109.68 with SMTP id hq4mr78674967wjb.12.1389188920621; Wed, 08 Jan 2014 05:48:40 -0800 (PST) Received: from localhost.localdomain (cpc15-aztw25-2-0-cust493.aztw.cable.virginm.net. [92.233.57.238]) by mx.google.com with ESMTPSA id j9sm48125217wjx.18.2014.01.08.05.48.38 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 08 Jan 2014 05:48:39 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: computersforpeace@gmail.com, angus.clark@st.com, Lee Jones Subject: [PATCH v4 11/37] mtd: st_spi_fsm: Search for preferred FSM message sequence configurations Date: Wed, 8 Jan 2014 13:46:54 +0000 Message-Id: <1389188840-14306-12-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1389188840-14306-1-git-send-email-lee.jones@linaro.org> References: <1389188840-14306-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.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 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. 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 a70e916..efd8fdb 100644 --- a/drivers/mtd/devices/st_spi_fsm.c +++ b/drivers/mtd/devices/st_spi_fsm.c @@ -258,6 +258,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; @@ -493,6 +505,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;