From patchwork Fri Nov 29 12:19:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 21869 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f71.google.com (mail-qe0-f71.google.com [209.85.128.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id DEB3923FC4 for ; Fri, 29 Nov 2013 12:19:59 +0000 (UTC) Received: by mail-qe0-f71.google.com with SMTP id b10sf15509884qen.6 for ; Fri, 29 Nov 2013 04:19:59 -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=sR/97dby5nIXv7lZ65JpZTMagCfXWYrTDuekvlaYMQo=; b=W2UE4FDQ2FnczirfquMusvCmbH5IBgQxCvvJa33chFI3r6ixR4nQMXv9SWvshlxEWP LwPt0zj0X4Qu+1sWcXyfnYqhYs7JFkQgFM/13aDhHPsb5f+O3UJVd6R7AB8I14cKyx2z wa18gmAP02JVjH0xIX3g6sCSWS4CImMOWB7lVCGtS6PAfSGzPf8wCqF4/iMxwRiIYDs6 49fTE35T/RF/Pe7E7VmPUPHlPuRs/LFK3lLHo0lD83Wr9Eh2Q+zPvmUQDGYQI84XoXIe A4buqLIlijKxjzEeECXTyJoFJjYMaXPgt+CYDNASZjFUvTPHpxngWhz3cFJ4L06tztce amMw== X-Gm-Message-State: ALoCoQm0Gy6QK/oemuBvcYv2UfbnBFzAu1pnQeOXDc20UaEA4Ad3mWijuf+sdnMIXdqcZdxGPvd5 X-Received: by 10.236.51.9 with SMTP id a9mr22885498yhc.41.1385727599792; Fri, 29 Nov 2013 04:19:59 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.41.66 with SMTP id d2ls313501qel.10.gmail; Fri, 29 Nov 2013 04:19:59 -0800 (PST) X-Received: by 10.221.19.5 with SMTP id qi5mr41154056vcb.15.1385727598095; Fri, 29 Nov 2013 04:19:58 -0800 (PST) Received: from mail-vc0-f171.google.com (mail-vc0-f171.google.com [209.85.220.171]) by mx.google.com with ESMTPS id gs2si10275155vdc.44.2013.11.29.04.19.58 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 29 Nov 2013 04:19:58 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.171 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.171; Received: by mail-vc0-f171.google.com with SMTP id ik5so6770870vcb.30 for ; Fri, 29 Nov 2013 04:19:58 -0800 (PST) X-Received: by 10.58.75.164 with SMTP id d4mr220577vew.53.1385727597883; Fri, 29 Nov 2013 04:19:57 -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 u4csp87405vcz; Fri, 29 Nov 2013 04:19:57 -0800 (PST) X-Received: by 10.229.185.6 with SMTP id cm6mr33137318qcb.10.1385727597354; Fri, 29 Nov 2013 04:19:57 -0800 (PST) Received: from mail-yh0-f43.google.com (mail-yh0-f43.google.com [209.85.213.43]) by mx.google.com with ESMTPS id 4si2777532qeq.93.2013.11.29.04.19.57 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 29 Nov 2013 04:19:57 -0800 (PST) Received-SPF: neutral (google.com: 209.85.213.43 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.213.43; Received: by mail-yh0-f43.google.com with SMTP id a41so6144993yho.16 for ; Fri, 29 Nov 2013 04:19:57 -0800 (PST) X-Received: by 10.236.134.139 with SMTP id s11mr808479yhi.133.1385727597126; Fri, 29 Nov 2013 04:19:57 -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 m29sm101911689yho.14.2013.11.29.04.19.55 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 29 Nov 2013 04:19:56 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dwmw2@infradead.org Cc: linus.walleij@linaro.org, linux-mtd@lists.infradead.org, angus.clark@st.com, Lee Jones Subject: [PATCH v3 11/36] mtd: st_spi_fsm: Search for preferred FSM message sequence configurations Date: Fri, 29 Nov 2013 12:19:00 +0000 Message-Id: <1385727565-25794-12-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1385727565-25794-1-git-send-email-lee.jones@linaro.org> References: <1385727565-25794-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.220.171 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 | 15 +++++++++++++++ drivers/mtd/devices/st_spi_fsm.h | 12 ++++++++++++ 2 files changed, 27 insertions(+) diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c index ef177e5..5f21d14 100644 --- a/drivers/mtd/devices/st_spi_fsm.c +++ b/drivers/mtd/devices/st_spi_fsm.c @@ -124,6 +124,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; cfgs->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; diff --git a/drivers/mtd/devices/st_spi_fsm.h b/drivers/mtd/devices/st_spi_fsm.h index 0a6272c..6fafa07 100644 --- a/drivers/mtd/devices/st_spi_fsm.h +++ b/drivers/mtd/devices/st_spi_fsm.h @@ -254,6 +254,18 @@ struct stfsm_seq { } __attribute__((__packed__, aligned(4))); #define STFSM_SEQ_SIZE sizeof(struct stfsm_seq) +/* 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;