From patchwork Fri Nov 22 16:22:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 21692 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f69.google.com (mail-oa0-f69.google.com [209.85.219.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2A51B23FDC for ; Fri, 22 Nov 2013 16:23:56 +0000 (UTC) Received: by mail-oa0-f69.google.com with SMTP id h16sf4561318oag.8 for ; Fri, 22 Nov 2013 08:23:55 -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=XwTnRN5nXJOW8dSQOrMWTeJ2E+JHBRlP3ycA52qrVpg=; b=WUKIFE3Hod+bdeZYxDtuyYi3i0UafDZITjmWNzJ9pccCF6lu8FCwGGYKp/DpGmSLRF qIzGhPuGM7cmVZO12YNwDgUxrI+A7K2B+Gk2PPHEEHW0/uH8gIFMAgTmBHDqEPbgh0ug 7ltKz3tIJTtfPiPUCyGYqRV/gMODv6C78T5spvZaLuonWCgI+CxmNbtAnrVyl893fzf6 kXyztyC2cTwOxZrelJIxhzjI0CqQ/QmTWdIY1CDEdf+2h6+0+cxqyR7pm4JAC3TcnMmz Jtu76I4AU4T+kAnQ9aVA/rUZmUynZfU2WiP8CH+9U1OsVdrfIZVV01AQ7iK6jLFk1Qpu cGow== X-Gm-Message-State: ALoCoQnQ2HV9NIE4sJ+ZveBycShrcUlCRRd2/qtMbyQ9cKFusySyiLAS49zB3IcQ1BAeVoE0orPv X-Received: by 10.43.112.138 with SMTP id es10mr390499icc.33.1385137435709; Fri, 22 Nov 2013 08:23:55 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.38.105 with SMTP id f9ls984839qek.81.gmail; Fri, 22 Nov 2013 08:23:55 -0800 (PST) X-Received: by 10.52.227.6 with SMTP id rw6mr10152255vdc.19.1385137435522; Fri, 22 Nov 2013 08:23:55 -0800 (PST) Received: from mail-vb0-f42.google.com (mail-vb0-f42.google.com [209.85.212.42]) by mx.google.com with ESMTPS id ti3si6636075vdc.145.2013.11.22.08.23.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 22 Nov 2013 08:23:55 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.42 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.42; Received: by mail-vb0-f42.google.com with SMTP id w18so1050041vbj.1 for ; Fri, 22 Nov 2013 08:23:55 -0800 (PST) X-Received: by 10.58.67.168 with SMTP id o8mr12276214vet.22.1385137435451; Fri, 22 Nov 2013 08:23:55 -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 u4csp51530vcz; Fri, 22 Nov 2013 08:23:55 -0800 (PST) X-Received: by 10.66.197.164 with SMTP id iv4mr12908620pac.18.1385137434630; Fri, 22 Nov 2013 08:23:54 -0800 (PST) Received: from mail-pd0-f179.google.com (mail-pd0-f179.google.com [209.85.192.179]) by mx.google.com with ESMTPS id 7si7278583pad.157.2013.11.22.08.23.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 22 Nov 2013 08:23:54 -0800 (PST) Received-SPF: neutral (google.com: 209.85.192.179 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.192.179; Received: by mail-pd0-f179.google.com with SMTP id r10so1464662pdi.10 for ; Fri, 22 Nov 2013 08:23:54 -0800 (PST) X-Received: by 10.66.118.71 with SMTP id kk7mr13243734pab.14.1385137434248; Fri, 22 Nov 2013 08:23:54 -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 qz9sm52962938pbc.3.2013.11.22.08.23.51 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 22 Nov 2013 08:23:53 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dwmw2@infradead.org, linux-mtd@lists.infradead.org, angus.clark@st.com Cc: linus.walleij@linaro.org, Lee Jones Subject: [PATCH 12/23] mtd: st_spi_fsm: Search for preferred FSM message sequence configurations Date: Fri, 22 Nov 2013 16:22:49 +0000 Message-Id: <1385137380-28968-13-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1385137380-28968-1-git-send-email-lee.jones@linaro.org> References: <1385137380-28968-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.212.42 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 a66dbac..0b32fef 100644 --- a/drivers/mtd/devices/st_spi_fsm.c +++ b/drivers/mtd/devices/st_spi_fsm.c @@ -82,6 +82,21 @@ static void stfsm_wait_seq(struct stfsm *fsm) dev_err(fsm->dev, "timeout on sequence completion\n"); } +/* 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_fifo(struct stfsm *fsm, uint32_t *buf, const uint32_t size) { diff --git a/drivers/mtd/devices/st_spi_fsm.h b/drivers/mtd/devices/st_spi_fsm.h index 60341f2..737ecd9 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;