From patchwork Fri Nov 22 16:22:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 21695 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B3B1C23FDC for ; Fri, 22 Nov 2013 16:24:04 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id hu19sf2646692vcb.3 for ; Fri, 22 Nov 2013 08:24:04 -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=Xu+BETjeNfoa7ETq93f3+fphvdDt+6m6iS8pESYKLWA=; b=bBEZEMAwox6R1He/hn/TcNxBasJmqMpOsErfQ43zcZ/1qSNiHtTsH1ailBmmjF9GG7 xyT5QNY0gbkCYbakk7+CelpGrnZqnXYIcq0FL6c2vyLp9YTCFjhCsYvhiTAaOMlP83sz L16Q+vG/0rB+Hrdb0qIl767CNoiRobMQGplzvqSieDyUkwTC3XDpXjyoQ2lw22QRzRCu gMhkL0U315ibqy0iE6z78hZSH1Ad0pntdrceFgi1pGnJkRX2DtuCGhy3vlkRXqY1oX6A 1Fxa9C0NHYujzEgElmylk1jVB6DDhQcB9QyBwHqw+sMMqBYnuZEuhXdm4ew8UrT2Q3iL Ieng== X-Gm-Message-State: ALoCoQkxpGl6XFUZoeb5WYRwEU0c2lBCJ8/Gp7YnScOfFxCtlO578AcpGga4WPcw0aLweL/NKnDR X-Received: by 10.58.50.161 with SMTP id d1mr4000969veo.24.1385137444541; Fri, 22 Nov 2013 08:24:04 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.4.138 with SMTP id k10ls998205qek.13.gmail; Fri, 22 Nov 2013 08:24:04 -0800 (PST) X-Received: by 10.220.11.7 with SMTP id r7mr12123707vcr.12.1385137444399; Fri, 22 Nov 2013 08:24:04 -0800 (PST) Received: from mail-ve0-f173.google.com (mail-ve0-f173.google.com [209.85.128.173]) by mx.google.com with ESMTPS id h7si12871840vee.109.2013.11.22.08.24.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 22 Nov 2013 08:24:04 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.173 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.173; Received: by mail-ve0-f173.google.com with SMTP id oz11so1064230veb.32 for ; Fri, 22 Nov 2013 08:24:04 -0800 (PST) X-Received: by 10.221.40.10 with SMTP id to10mr12119489vcb.22.1385137444253; Fri, 22 Nov 2013 08:24:04 -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 u4csp51541vcz; Fri, 22 Nov 2013 08:24:03 -0800 (PST) X-Received: by 10.68.190.169 with SMTP id gr9mr6010535pbc.30.1385137443383; Fri, 22 Nov 2013 08:24:03 -0800 (PST) Received: from mail-pb0-f42.google.com (mail-pb0-f42.google.com [209.85.160.42]) by mx.google.com with ESMTPS id yg5si20183642pbc.26.2013.11.22.08.24.03 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 22 Nov 2013 08:24:03 -0800 (PST) Received-SPF: neutral (google.com: 209.85.160.42 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.160.42; Received: by mail-pb0-f42.google.com with SMTP id uo5so1524769pbc.1 for ; Fri, 22 Nov 2013 08:24:03 -0800 (PST) X-Received: by 10.68.163.132 with SMTP id yi4mr3624509pbb.152.1385137442931; Fri, 22 Nov 2013 08:24:02 -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 qz9sm52962938pbc.3.2013.11.22.08.24.00 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 22 Nov 2013 08:24:02 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, dwmw2@infradead.org, linux-mtd@lists.infradead.org, angus.clark@st.com Cc: linus.walleij@linaro.org, Lee Jones Subject: [PATCH 15/23] mtd: st_spi_fsm: Fetch boot-device from mode pins Date: Fri, 22 Nov 2013 16:22:52 +0000 Message-Id: <1385137380-28968-16-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1385137380-28968-1-git-send-email-lee.jones@linaro.org> References: <1385137380-28968-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.173 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 80657a4..dec2f83 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_32BITADDR; + + 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 737ecd9..2e12bff 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 {