From patchwork Tue Feb 18 14:55:41 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 24861 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f72.google.com (mail-yh0-f72.google.com [209.85.213.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 7634F202B2 for ; Tue, 18 Feb 2014 14:57:27 +0000 (UTC) Received: by mail-yh0-f72.google.com with SMTP id f73sf35483360yha.11 for ; Tue, 18 Feb 2014 06:57:26 -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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=UD3WPMrKxOmFKPbjWKKd/5eDcC1mraj0Z9ZFrnnUoFU=; b=XNmunxxaK+bdx0MOaeu0uSy7AsGsIqXzTpItC7nHdB6FZ0xgyToyWu+utSZRQffCu4 0AWjD/rNbJs5amcEHb8+cu+q696UT7Eu4lZ+uge52eKpXnYI2axu87TlNWNCPJLqQy3k E/HRGlcl96YYrcb/l4uNT/3XxMdRFlCNK6b7LDiy4Upk2g4VxHOVo9pdI/QCNpr5sxau EsMSF+TU5BdRU39HYeZ5861ppaicZtkvSDIux0DFRjn79v6xcrHD5V3CWSdDMkvA8f6j PVCzxM1JUfmc99xfKVsuJd/I82Cnw30l+stN/L03S311VFMxgI7yov+rbgqNI8irJK+I TpgA== X-Gm-Message-State: ALoCoQlne50NU39/qa6GolpZqs0BMQaZkXufYG1VxugFs1FLfwDP/vxQobhkTmkP2etHnVAEZLAD X-Received: by 10.224.115.18 with SMTP id g18mr4629908qaq.3.1392735446682; Tue, 18 Feb 2014 06:57:26 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.38.47 with SMTP id s44ls1329615qgs.70.gmail; Tue, 18 Feb 2014 06:57:26 -0800 (PST) X-Received: by 10.52.61.168 with SMTP id q8mr4866337vdr.40.1392735446559; Tue, 18 Feb 2014 06:57:26 -0800 (PST) Received: from mail-ve0-f172.google.com (mail-ve0-f172.google.com [209.85.128.172]) by mx.google.com with ESMTPS id f7si5560471vcz.132.2014.02.18.06.57.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Feb 2014 06:57:26 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.172 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.172; Received: by mail-ve0-f172.google.com with SMTP id c14so13692163vea.31 for ; Tue, 18 Feb 2014 06:57:26 -0800 (PST) X-Received: by 10.52.23.68 with SMTP id k4mr14757456vdf.24.1392735446363; Tue, 18 Feb 2014 06:57:26 -0800 (PST) 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.174.196 with SMTP id u4csp222556vcz; Tue, 18 Feb 2014 06:57:25 -0800 (PST) X-Received: by 10.68.139.73 with SMTP id qw9mr33138855pbb.121.1392735445179; Tue, 18 Feb 2014 06:57:25 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id cf2si18548497pad.314.2014.02.18.06.57.24; Tue, 18 Feb 2014 06:57:24 -0800 (PST) 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 S932188AbaBRO5K (ORCPT + 27 others); Tue, 18 Feb 2014 09:57:10 -0500 Received: from mail-we0-f170.google.com ([74.125.82.170]:61722 "EHLO mail-we0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932130AbaBRO5G (ORCPT ); Tue, 18 Feb 2014 09:57:06 -0500 Received: by mail-we0-f170.google.com with SMTP id w62so11859516wes.15 for ; Tue, 18 Feb 2014 06:57:05 -0800 (PST) X-Received: by 10.180.12.233 with SMTP id b9mr18181803wic.8.1392735425215; Tue, 18 Feb 2014 06:57:05 -0800 (PST) Received: from localhost.localdomain ([80.76.198.141]) by mx.google.com with ESMTPSA id h13sm46039687wjr.22.2014.02.18.06.57.02 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 18 Feb 2014 06:57:04 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: lee.jones@linaro.org, DCG_UPD_stlinux_kernel@list.st.com, dwmw2@infradead.org, linux-mtd@lists.infradead.org, computersforpeace@gmail.com, Angus.Clark@st.com Subject: [PATCH 14/35] mtd: st_spi_fsm: Fetch boot-device from mode pins Date: Tue, 18 Feb 2014 14:55:41 +0000 Message-Id: <1392735362-1245-15-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1392735362-1245-1-git-send-email-lee.jones@linaro.org> References: <1392735362-1245-1-git-send-email-lee.jones@linaro.org> 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.172 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: , 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 2cbed4b..fac6748 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; @@ -733,6 +777,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)