From patchwork Tue Mar 11 08:23:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 26015 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yk0-f197.google.com (mail-yk0-f197.google.com [209.85.160.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 428932054B for ; Tue, 11 Mar 2014 08:23:36 +0000 (UTC) Received: by mail-yk0-f197.google.com with SMTP id 19sf44792075ykq.0 for ; Tue, 11 Mar 2014 01:23:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:date:from:to:cc:subject:message-id :references:mime-version:in-reply-to:user-agent:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe :content-type:content-disposition:content-transfer-encoding; bh=+Nwq8cxQ3hh9VHyNNJC7P34sUo4SXpXTf85S/mk4xOM=; b=A67KjGxZcGUpCKbACpRO45d/sCnm3HsRbioTJ2mmIOjO4zkNVIe7GuhwzUfj9jnbcn CWe+OKbQo3U/zgNq/6FccBtgaZGiy4x9zav7q/DhV9BhjDbci2k9uOUssbDDUcfKqcG+ cRrsf/lJj4ob5xYY74P5EFnDRSnnu7m9Mv1pELUb93eMvQslQ6iUvvnmJX6Lsaku7a5v CANNNfYxdm5htOzRK5Au4yHifeSHWUGRhmY0/btRSF01EFP6NFpVzPEUh+9e21SZgqxj /tucVFURl0UII5GWJdZMGK4oBXTU3+AvNDpCxl2bDfWA0hcGtT/rhUUGSVVk/DqXmqo4 zsfg== X-Gm-Message-State: ALoCoQkUhFJygLwFUeF4fP2t/BShUEjYKNoXY1cTtDQroM8MFyqH4rtQn0cFv9R3k7hXdWZhINIa X-Received: by 10.58.178.81 with SMTP id cw17mr3400561vec.37.1394526215935; Tue, 11 Mar 2014 01:23:35 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.32.181 with SMTP id h50ls2442605qgh.15.gmail; Tue, 11 Mar 2014 01:23:35 -0700 (PDT) X-Received: by 10.220.191.134 with SMTP id dm6mr26809219vcb.16.1394526215787; Tue, 11 Mar 2014 01:23:35 -0700 (PDT) Received: from mail-ve0-f182.google.com (mail-ve0-f182.google.com [209.85.128.182]) by mx.google.com with ESMTPS id uq6si5546259vcb.0.2014.03.11.01.23.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 11 Mar 2014 01:23:35 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.128.182 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.182; Received: by mail-ve0-f182.google.com with SMTP id jw12so8368357veb.13 for ; Tue, 11 Mar 2014 01:23:35 -0700 (PDT) X-Received: by 10.220.250.203 with SMTP id mp11mr26131454vcb.2.1394526215647; Tue, 11 Mar 2014 01:23:35 -0700 (PDT) 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.78.9 with SMTP id i9csp187902vck; Tue, 11 Mar 2014 01:23:34 -0700 (PDT) X-Received: by 10.68.224.195 with SMTP id re3mr46034577pbc.93.1394526214224; Tue, 11 Mar 2014 01:23:34 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id iu9si3291972pac.2.2014.03.11.01.23.33; Tue, 11 Mar 2014 01:23:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753577AbaCKIXZ (ORCPT + 26 others); Tue, 11 Mar 2014 04:23:25 -0400 Received: from mail-we0-f169.google.com ([74.125.82.169]:46353 "EHLO mail-we0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751689AbaCKIXV (ORCPT ); Tue, 11 Mar 2014 04:23:21 -0400 Received: by mail-we0-f169.google.com with SMTP id w62so9800805wes.14 for ; Tue, 11 Mar 2014 01:23:20 -0700 (PDT) X-Received: by 10.194.192.233 with SMTP id hj9mr74416wjc.78.1394526200122; Tue, 11 Mar 2014 01:23:20 -0700 (PDT) Received: from lee--X1 (host109-148-116-196.range109-148.btcentralplus.com. [109.148.116.196]) by mx.google.com with ESMTPSA id j8sm717794wjn.13.2014.03.11.01.23.18 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Tue, 11 Mar 2014 01:23:19 -0700 (PDT) Date: Tue, 11 Mar 2014 08:23:16 +0000 From: Lee Jones To: Brian Norris Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, DCG_UPD_stlinux_kernel@list.st.com, dwmw2@infradead.org, linux-mtd@lists.infradead.org, Angus.Clark@st.com Subject: [PATCH v6 01/35] mtd: st_spi_fsm: Allocate resources and register with MTD framework Message-ID: <20140311082316.GJ2839@lee--X1> References: <1392735362-1245-1-git-send-email-lee.jones@linaro.org> <1392735362-1245-2-git-send-email-lee.jones@linaro.org> <20140309053306.GL31517@norris-Latitude-E6410> MIME-Version: 1.0 In-Reply-To: <20140309053306.GL31517@norris-Latitude-E6410> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.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.182 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 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Content-Disposition: inline This is a new driver. It's used to communicate with a special type of optimised Serial Flash Controller called the FSM. The FSM uses a subset of the SPI protocol to communicate with supported NOR-Flash devices. Acked-by Angus Clark Signed-off-by: Lee Jones --- Hi Brian, Sorry about the previous fixup misses. There were a couple of patches which I had failed to squash into the pack. Hopefully the rest of the review will go more smoothly. Kind regards, Lee drivers/mtd/devices/Kconfig | 8 +++ drivers/mtd/devices/Makefile | 1 + drivers/mtd/devices/st_spi_fsm.c | 107 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+) diff --git a/drivers/mtd/devices/Kconfig b/drivers/mtd/devices/Kconfig index 0128138..1210bc2 100644 --- a/drivers/mtd/devices/Kconfig +++ b/drivers/mtd/devices/Kconfig @@ -210,6 +210,14 @@ config MTD_DOCG3 M-Systems and now Sandisk. The support is very experimental, and doesn't give access to any write operations. +config MTD_ST_SPI_FSM + tristate "ST Microelectronics SPI FSM Serial Flash Controller" + depends on ARM || SH + help + This provides an MTD device driver for the ST Microelectronics + SPI Fast Sequence Mode (FSM) Serial Flash Controller and support + for a subset of connected Serial Flash devices. + if MTD_DOCG3 config BCH_CONST_M default 14 diff --git a/drivers/mtd/devices/Makefile b/drivers/mtd/devices/Makefile index d83bd73..c68868f 100644 --- a/drivers/mtd/devices/Makefile +++ b/drivers/mtd/devices/Makefile @@ -16,6 +16,7 @@ obj-$(CONFIG_MTD_NAND_OMAP_BCH) += elm.o obj-$(CONFIG_MTD_SPEAR_SMI) += spear_smi.o obj-$(CONFIG_MTD_SST25L) += sst25l.o obj-$(CONFIG_MTD_BCM47XXSFLASH) += bcm47xxsflash.o +obj-$(CONFIG_MTD_ST_SPI_FSM) += st_spi_fsm.o CFLAGS_docg3.o += -I$(src) diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c new file mode 100644 index 0000000..0de9648 --- /dev/null +++ b/drivers/mtd/devices/st_spi_fsm.c @@ -0,0 +1,107 @@ +/* + * st_spi_fsm.c - ST Fast Sequence Mode (FSM) Serial Flash Controller + * + * Author: Angus Clark + * + * Copyright (C) 2010-2014 STicroelectronics Limited + * + * JEDEC probe based on drivers/mtd/devices/m25p80.c + * + * This code is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + */ +#include +#include +#include +#include +#include +#include +#include +#include + +struct stfsm { + struct device *dev; + void __iomem *base; + struct resource *region; + struct mtd_info mtd; + struct mutex lock; +}; + +static int stfsm_probe(struct platform_device *pdev) +{ + struct device_node *np = pdev->dev.of_node; + struct resource *res; + struct stfsm *fsm; + + if (!np) { + dev_err(&pdev->dev, "No DT found\n"); + return -EINVAL; + } + + fsm = devm_kzalloc(&pdev->dev, sizeof(*fsm), GFP_KERNEL); + if (!fsm) + return -ENOMEM; + + fsm->dev = &pdev->dev; + + platform_set_drvdata(pdev, fsm); + + res = platform_get_resource(pdev, IORESOURCE_MEM, 0); + if (!res) { + dev_err(&pdev->dev, "Resource not found\n"); + return -ENODEV; + } + + fsm->base = devm_ioremap_resource(&pdev->dev, res); + if (IS_ERR(fsm->base)) { + dev_err(&pdev->dev, + "Failed to reserve memory region [0x%08x-0x%08x]\n", + res->start, res->end); + return PTR_ERR(fsm->base); + } + + mutex_init(&fsm->lock); + + fsm->mtd.dev.parent = &pdev->dev; + fsm->mtd.type = MTD_NORFLASH; + fsm->mtd.writesize = 4; + fsm->mtd.writebufsize = fsm->mtd.writesize; + fsm->mtd.flags = MTD_CAP_NORFLASH; + + return mtd_device_parse_register(&fsm->mtd, NULL, NULL, NULL, 0); +} + +static int stfsm_remove(struct platform_device *pdev) +{ + struct stfsm *fsm = platform_get_drvdata(pdev); + int err; + + err = mtd_device_unregister(&fsm->mtd); + if (err) + return err; + + return 0; +} + +static struct of_device_id stfsm_match[] = { + { .compatible = "st,spi-fsm", }, + {}, +}; +MODULE_DEVICE_TABLE(of, stfsm_match); + +static struct platform_driver stfsm_driver = { + .probe = stfsm_probe, + .remove = stfsm_remove, + .driver = { + .name = "st-spi-fsm", + .owner = THIS_MODULE, + .of_match_table = stfsm_match, + }, +}; +module_platform_driver(stfsm_driver); + +MODULE_AUTHOR("Angus Clark "); +MODULE_DESCRIPTION("ST SPI FSM driver"); +MODULE_LICENSE("GPL");