From patchwork Thu Jan 23 10:31:03 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 23586 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f198.google.com (mail-ob0-f198.google.com [209.85.214.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 3E740218BD for ; Thu, 23 Jan 2014 10:32:21 +0000 (UTC) Received: by mail-ob0-f198.google.com with SMTP id wp4sf5891045obc.9 for ; Thu, 23 Jan 2014 02:32:20 -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=9COprZ2PwEj7ZlIkFOTN+OMYjPedsDbHfX+Bv1tS8A4=; b=BS5qQrz8sALllHuSVaNxDaorvX4FzBzFnZqb7nQvtSAmXVvvVYN5ByMLmKGIgB3+Jb nrsqeRW3khQggsQhrrWdP2MLLCbbPejQ4HwnLzXaodifkpdWJ8pNRWRPYCeeg+bF/n2V KyRGmWLgmGNO2lYlSeX6r6rfoABym4ghL5fazD+htKQMep4Uv6PPRhuRHEqo+7p0hMTC JDvHUE5nCx1T3rknuTjmceHfMPSUKQArXi1XGymcbXL3+pXv4tHPzR80Hv/rNWF58xGN j8+E1ggxGnnhRSotp8rGHaFnNf8M95Oq2LYNuIe+j1vf61aZ5G4GJ97QyttEEv0gugAK SseA== X-Gm-Message-State: ALoCoQl7HjZcWHdsFprK6BPc9Mk09NU7S9rnOhItK8D/X6sn9kgWBSPSXItBdRXHbp5Z9O/W3R/a X-Received: by 10.43.103.136 with SMTP id di8mr849295icc.14.1390473140444; Thu, 23 Jan 2014 02:32:20 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.85.129 with SMTP id h1ls292655qez.15.gmail; Thu, 23 Jan 2014 02:32:20 -0800 (PST) X-Received: by 10.220.186.202 with SMTP id ct10mr4139178vcb.14.1390473140334; Thu, 23 Jan 2014 02:32:20 -0800 (PST) Received: from mail-ve0-f178.google.com (mail-ve0-f178.google.com [209.85.128.178]) by mx.google.com with ESMTPS id uh1si6430344vcb.25.2014.01.23.02.32.20 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 Jan 2014 02:32:20 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.178 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.178; Received: by mail-ve0-f178.google.com with SMTP id oy12so970492veb.23 for ; Thu, 23 Jan 2014 02:32:20 -0800 (PST) X-Received: by 10.58.132.203 with SMTP id ow11mr4175479veb.1.1390473140260; Thu, 23 Jan 2014 02:32:20 -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 u4csp15946vcz; Thu, 23 Jan 2014 02:32:19 -0800 (PST) X-Received: by 10.180.95.105 with SMTP id dj9mr24116013wib.22.1390473139290; Thu, 23 Jan 2014 02:32:19 -0800 (PST) Received: from mail-wg0-f52.google.com (mail-wg0-f52.google.com [74.125.82.52]) by mx.google.com with ESMTPS id bx17si8771754wjb.122.2014.01.23.02.32.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 Jan 2014 02:32:19 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.52 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=74.125.82.52; Received: by mail-wg0-f52.google.com with SMTP id b13so1277693wgh.19 for ; Thu, 23 Jan 2014 02:32:18 -0800 (PST) X-Received: by 10.195.12.164 with SMTP id er4mr386370wjd.92.1390473138867; Thu, 23 Jan 2014 02:32:18 -0800 (PST) Received: from localhost.localdomain ([80.76.198.141]) by mx.google.com with ESMTPSA id ay6sm21257831wjb.23.2014.01.23.02.32.16 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 23 Jan 2014 02:32:18 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: linus.walleij@linaro.org, dwmw2@infradead.org, linux-mtd@lists.infradead.org, computersforpeace@gmail.com, Angus.Clark@st.com, DCG_UPD_stlinux_kernel@list.st.com, olivier.clergeaud@st.com, Lee Jones Subject: [PATCH RESEND v4 15/37] mtd: st_spi_fsm: Fetch boot-device from mode pins Date: Thu, 23 Jan 2014 10:31:03 +0000 Message-Id: <1390473085-24626-16-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1390473085-24626-1-git-send-email-lee.jones@linaro.org> References: <1390473085-24626-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.128.178 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. Signed-off-by: Lee Jones --- drivers/mtd/devices/st_spi_fsm.c | 41 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c index 961abfd..94840b5 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 @@ -243,6 +245,7 @@ struct stfsm { struct flash_info *info; uint32_t fifo_dir_delay; + bool booted_from_spi; }; struct stfsm_seq { @@ -727,10 +730,48 @@ static void stfsm_fetch_platform_configs(struct platform_device *pdev) { struct stfsm *fsm = platform_get_drvdata(pdev); struct flash_info *info = fsm->info; + 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; /* Use device size to determine address width */ if (info->sector_size * info->n_sectors > 0xFFFFFF) info->flags |= FLASH_FLAG_32BIT_ADDR; + + regmap = syscon_regmap_lookup_by_phandle(np, "st,syscfg"); + if (!IS_ERR(regmap)) { + ret = PTR_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)