From patchwork Fri Nov 29 12:19:04 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 21872 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f69.google.com (mail-vb0-f69.google.com [209.85.212.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 14F2E23FC4 for ; Fri, 29 Nov 2013 12:20:08 +0000 (UTC) Received: by mail-vb0-f69.google.com with SMTP id m10sf21394510vbh.4 for ; Fri, 29 Nov 2013 04:20:07 -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=JOxaSEcbZoCy3grVmS534zeN0/n0Iwi0MqXRAAFkijM=; b=ZCuaBe1ohb4/vruZZUtunniXfPQLwW+2r9Esew/xy6+c/AS2MRvMVAACOOYO2vCTb7 HHg49Vc2q8RqsnFwYG8PihXYwAcSemop5v8mS7E1jj/ScKJ8nhHrNoxRDgC/xGmj4vLH z7D0A/lqyYo8/xHh96QeDwQ3xA6tOrsNTxhrkD2nw4/C3+x54xRzY6edVAWY8zFL5D9n HycJWhfpRRrTst0k3os5Jsx+T1RMrLQKDrYQKrOyEFJ9I0FM8Cdw9XPLl277/n/dihQp qXP3Vfudjw65/QbRumFnO7L+08Zvjm8oqA7VhqcWRoank6tbOgFILj+2/SYiPOksgWDR LetA== X-Gm-Message-State: ALoCoQkg0+BfoNEg8wlLndgPTt1JFj1TiVizpGnz05dESziBSzI9qG5rfBOBl3/0kEao2T/zNtqR X-Received: by 10.52.227.99 with SMTP id rz3mr5547162vdc.0.1385727607899; Fri, 29 Nov 2013 04:20:07 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.12.11 with SMTP id u11ls3792200qeb.25.gmail; Fri, 29 Nov 2013 04:20:07 -0800 (PST) X-Received: by 10.221.46.134 with SMTP id uo6mr28405vcb.72.1385727607809; Fri, 29 Nov 2013 04:20:07 -0800 (PST) Received: from mail-vc0-f176.google.com (mail-vc0-f176.google.com [209.85.220.176]) by mx.google.com with ESMTPS id tq4si24728444vdc.103.2013.11.29.04.20.07 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 29 Nov 2013 04:20:07 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.176 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.176; Received: by mail-vc0-f176.google.com with SMTP id lf12so6491879vcb.21 for ; Fri, 29 Nov 2013 04:20:07 -0800 (PST) X-Received: by 10.221.37.9 with SMTP id tc9mr1753430vcb.39.1385727606127; Fri, 29 Nov 2013 04:20:06 -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 u4csp87414vcz; Fri, 29 Nov 2013 04:20:05 -0800 (PST) X-Received: by 10.49.15.104 with SMTP id w8mr7663761qec.49.1385727605621; Fri, 29 Nov 2013 04:20:05 -0800 (PST) Received: from mail-yh0-f46.google.com (mail-yh0-f46.google.com [209.85.213.46]) by mx.google.com with ESMTPS id n4si10261811qac.128.2013.11.29.04.20.05 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 29 Nov 2013 04:20:05 -0800 (PST) Received-SPF: neutral (google.com: 209.85.213.46 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.213.46; Received: by mail-yh0-f46.google.com with SMTP id l109so6590113yhq.5 for ; Fri, 29 Nov 2013 04:20:04 -0800 (PST) X-Received: by 10.236.74.73 with SMTP id w49mr1939926yhd.87.1385727604773; Fri, 29 Nov 2013 04:20:04 -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 m29sm101911689yho.14.2013.11.29.04.20.02 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 29 Nov 2013 04:20:04 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dwmw2@infradead.org Cc: linus.walleij@linaro.org, linux-mtd@lists.infradead.org, angus.clark@st.com, Lee Jones Subject: [PATCH v3 15/36] mtd: st_spi_fsm: Fetch boot-device from mode pins Date: Fri, 29 Nov 2013 12:19:04 +0000 Message-Id: <1385727565-25794-16-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1385727565-25794-1-git-send-email-lee.jones@linaro.org> References: <1385727565-25794-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.176 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 ++++++++++++++++++++++++++++++++++++++++ drivers/mtd/devices/st_spi_fsm.h | 1 + 2 files changed, 42 insertions(+) diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c index e04de62..bb642a1 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 @@ -346,9 +348,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, "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, "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) diff --git a/drivers/mtd/devices/st_spi_fsm.h b/drivers/mtd/devices/st_spi_fsm.h index 6fafa07..a0eafa9 100644 --- a/drivers/mtd/devices/st_spi_fsm.h +++ b/drivers/mtd/devices/st_spi_fsm.h @@ -238,6 +238,7 @@ struct stfsm { struct flash_info *info; uint32_t fifo_dir_delay; + bool booted_from_spi; }; struct stfsm_seq {