From patchwork Thu Mar 20 09:20:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 26647 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f199.google.com (mail-ob0-f199.google.com [209.85.214.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3B9FE202E0 for ; Thu, 20 Mar 2014 09:21:51 +0000 (UTC) Received: by mail-ob0-f199.google.com with SMTP id wo20sf2298905obc.6 for ; Thu, 20 Mar 2014 02:21:50 -0700 (PDT) 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=+Yq3YAsI7rl7TpFKWlkhvnrswA83dqYwkKJDcS4X9AA=; b=T9Jyb+JViUYRLQZpFIyugrOMuB55SMzUnWD/v7v2Scud7+7eP75iWLML5693nprsL0 +FK75DPbD4FqxBP+9PouvHZR02uO4wMHGs0JQtU5dgHp09/PQXFCXYwR2jmWwexyRD4u dbgUELI546bYyZCaA7lBZzSSRDazfY/kophbuCho3e8d2vyQJIbsGrYJrc8enzTye7gX Jne0zTm1Af8QbGFvmOu1aIqHPmsf5ZptYOg4tur6UNdUfml7d52efa2BJdYgsZqVgStN h/1XOC72Ai3n44HWJ0ey+Izc0Fr8Zj7A2QxTjNi0VI5O2vucsSedtvh3DGQ9bqGTIw7T WpCA== X-Gm-Message-State: ALoCoQlZS6ZIeJCGJRJCByJUx50z3jAEoCa0yRzffVxnjoogVRSJXrFeu5zqOOKd3IpqKn/8ihro X-Received: by 10.182.81.7 with SMTP id v7mr3229030obx.28.1395307310772; Thu, 20 Mar 2014 02:21:50 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.88.101 with SMTP id s92ls178918qgd.82.gmail; Thu, 20 Mar 2014 02:21:50 -0700 (PDT) X-Received: by 10.58.247.193 with SMTP id yg1mr1216711vec.41.1395307310666; Thu, 20 Mar 2014 02:21:50 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id tz5si293639vdc.187.2014.03.20.02.21.50 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Mar 2014 02:21:50 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.180 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.180; Received: by mail-vc0-f180.google.com with SMTP id lf12so586107vcb.25 for ; Thu, 20 Mar 2014 02:21:50 -0700 (PDT) X-Received: by 10.221.74.65 with SMTP id yv1mr3514041vcb.31.1395307310585; Thu, 20 Mar 2014 02:21:50 -0700 (PDT) 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.78.9 with SMTP id i9csp372523vck; Thu, 20 Mar 2014 02:21:49 -0700 (PDT) X-Received: by 10.180.100.72 with SMTP id ew8mr1811702wib.16.1395307309257; Thu, 20 Mar 2014 02:21:49 -0700 (PDT) Received: from mail-wi0-f174.google.com (mail-wi0-f174.google.com [209.85.212.174]) by mx.google.com with ESMTPS id j6si826639wje.154.2014.03.20.02.21.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Mar 2014 02:21:49 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.174 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.212.174; Received: by mail-wi0-f174.google.com with SMTP id d1so5971927wiv.1 for ; Thu, 20 Mar 2014 02:21:48 -0700 (PDT) X-Received: by 10.194.186.170 with SMTP id fl10mr6318401wjc.67.1395307308584; Thu, 20 Mar 2014 02:21:48 -0700 (PDT) Received: from lee--X1.home (host109-148-116-196.range109-148.btcentralplus.com. [109.148.116.196]) by mx.google.com with ESMTPSA id di9sm4735120wid.6.2014.03.20.02.21.46 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 20 Mar 2014 02:21:47 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, computersforpeace@gmail.com Cc: linux-mtd@lists.infradead.org, dwmw2@infradead.org, Angus.Clark@st.com, Lee Jones Subject: [PATCH v6 14/36] mtd: st_spi_fsm: Fetch boot-device from mode pins Date: Thu, 20 Mar 2014 09:20:46 +0000 Message-Id: <1395307268-12721-15-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1395307268-12721-1-git-send-email-lee.jones@linaro.org> References: <1395307268-12721-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.180 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: , It's important for us to determine which device was used to boot from in order to make some correct decisions surrounding Power Management. On each of the platforms which support the FSM this is communicated via a set of mode pins held in the system configuration area. This patch determine the boot device and stores the result. Acked-by Angus Clark Signed-off-by: Lee Jones --- drivers/mtd/devices/st_spi_fsm.c | 46 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c index 83cf9df..6be2672 100644 --- a/drivers/mtd/devices/st_spi_fsm.c +++ b/drivers/mtd/devices/st_spi_fsm.c @@ -14,7 +14,9 @@ */ #include #include +#include #include +#include #include #include #include @@ -207,6 +209,7 @@ struct stfsm { struct flash_info *info; uint32_t fifo_dir_delay; + bool booted_from_spi; }; struct stfsm_seq { @@ -692,6 +695,47 @@ static int stfsm_init(struct stfsm *fsm) return 0; } +static void stfsm_fetch_platform_configs(struct platform_device *pdev) +{ + struct stfsm *fsm = platform_get_drvdata(pdev); + struct device_node *np = pdev->dev.of_node; + struct regmap *regmap; + uint32_t boot_device_reg; + uint32_t boot_device_spi; + uint32_t boot_device; /* Value we read from *boot_device_reg */ + int ret; + + /* Booting from SPI NOR Flash is the default */ + fsm->booted_from_spi = true; + + regmap = syscon_regmap_lookup_by_phandle(np, "st,syscfg"); + if (IS_ERR(regmap)) + goto boot_device_fail; + + /* Where in the syscon the boot device information lives */ + ret = of_property_read_u32(np, "st,boot-device-reg", &boot_device_reg); + if (ret) + goto boot_device_fail; + + /* Boot device value when booted from SPI NOR */ + ret = of_property_read_u32(np, "st,boot-device-spi", &boot_device_spi); + if (ret) + goto boot_device_fail; + + ret = regmap_read(regmap, boot_device_reg, &boot_device); + if (ret) + goto boot_device_fail; + + if (boot_device != boot_device_spi) + fsm->booted_from_spi = false; + + return; + +boot_device_fail: + dev_warn(&pdev->dev, + "failed to fetch boot device, assuming boot from SPI\n"); +} + static int stfsm_probe(struct platform_device *pdev) { struct device_node *np = pdev->dev.of_node; @@ -734,6 +778,8 @@ static int stfsm_probe(struct platform_device *pdev) return ret; } + stfsm_fetch_platform_configs(pdev); + /* Detect SPI FLASH device */ info = stfsm_jedec_probe(fsm); if (!info)