From patchwork Thu Jan 23 10:30:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 23582 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 DA05C218BD for ; Thu, 23 Jan 2014 10:32:10 +0000 (UTC) Received: by mail-ob0-f200.google.com with SMTP id wo20sf5902807obc.3 for ; Thu, 23 Jan 2014 02:32: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: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=hvXK20LRB6qLzXBdfL5s3Euu7BIRyF/R9PQ4j4fOjRkK7kS3sDdZeImPceAyMWygPM UmgB4UivXfuIIG0D2rkV2jaH8ZuN1OsEx2kUO3EDPayRvNQUCwqgZ1bPOcHVfKNiV4AG 35EopCzFLCQf4UI6xKhS6igRWPCAsdNkqF9Mxz7R2nSgPk451C1LckZ1FfwqYN8TxJ+C czrkE7UDEhOUr36ZBnr3kYvxgONC0x8zC6iKeg2VP4kdj7mJIAOaRVLY6p/APN1lGEF5 Kgwk3o2JIyjC2eM5Tlqf/0zQ9Kikfn3T1PLv9sGWFWru7fv0LUXZuQOCTUGOnlVmTbkk Aybw== X-Gm-Message-State: ALoCoQldYi4mkaMteuQX3xa6t0a9is9njX8ZVzwEL97meiCyI5wO7Zg2ZxxjB00+PZkhXo49oday X-Received: by 10.182.87.2 with SMTP id t2mr2811563obz.2.1390473130004; Thu, 23 Jan 2014 02:32:10 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.132.196 with SMTP id ow4ls260978qeb.40.gmail; Thu, 23 Jan 2014 02:32:09 -0800 (PST) X-Received: by 10.220.225.71 with SMTP id ir7mr48623vcb.50.1390473129875; Thu, 23 Jan 2014 02:32:09 -0800 (PST) Received: from mail-ve0-f175.google.com (mail-ve0-f175.google.com [209.85.128.175]) by mx.google.com with ESMTPS id c2si6416290vct.142.2014.01.23.02.32.09 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 Jan 2014 02:32:09 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.175 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.175; Received: by mail-ve0-f175.google.com with SMTP id c14so986116vea.34 for ; Thu, 23 Jan 2014 02:32:09 -0800 (PST) X-Received: by 10.58.211.130 with SMTP id nc2mr4006291vec.7.1390473129801; Thu, 23 Jan 2014 02:32:09 -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.220.174.196 with SMTP id u4csp15933vcz; Thu, 23 Jan 2014 02:32:09 -0800 (PST) X-Received: by 10.194.92.164 with SMTP id cn4mr809425wjb.74.1390473128499; Thu, 23 Jan 2014 02:32:08 -0800 (PST) Received: from mail-we0-f178.google.com (mail-we0-f178.google.com [74.125.82.178]) by mx.google.com with ESMTPS id i8si8784235wje.55.2014.01.23.02.32.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 Jan 2014 02:32:08 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.178 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.178; Received: by mail-we0-f178.google.com with SMTP id t60so925036wes.23 for ; Thu, 23 Jan 2014 02:32:08 -0800 (PST) X-Received: by 10.194.23.201 with SMTP id o9mr1114569wjf.67.1390473128086; Thu, 23 Jan 2014 02:32:08 -0800 (PST) Received: from localhost.localdomain ([80.76.198.141]) by mx.google.com with ESMTPSA id ay6sm21257831wjb.23.2014.01.23.02.32.05 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 Jan 2014 02:32:07 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: linus.walleij@linaro.org, dwmw2@infradead.org, linux-mtd@lists.infradead.org, computersforpeace@gmail.com, Angus.Clark@st.com, DCG_UPD_stlinux_kernel@list.st.com, olivier.clergeaud@st.com, Lee Jones Subject: [PATCH RESEND v4 11/37] mtd: st_spi_fsm: Search for preferred FSM message sequence configurations Date: Thu, 23 Jan 2014 10:30:59 +0000 Message-Id: <1390473085-24626-12-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1390473085-24626-1-git-send-email-lee.jones@linaro.org> References: <1390473085-24626-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.175 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;