From patchwork Wed Jan 8 13:46:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 22951 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 7C3A5202E2 for ; Wed, 8 Jan 2014 13:48:49 +0000 (UTC) Received: by mail-ob0-f198.google.com with SMTP id wo20sf6082929obc.9 for ; Wed, 08 Jan 2014 05:48:48 -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=RbtM21tYFflXPXKN6Porh+/cYcmUoPRXhhhaFkdXD//LBVreKPm6IjA8sBJUJMtrOW PjgkgWUNIGyYGQlcEzEQ8zqzUPjGE95v7lbKrr/029Hla2H5yO7Eb8QrxZiFsKVipkp6 RWKBFn0IsIwEJEFHhZxHHmexN1k9aA+BSyTiBvxvXt1gTIxw33rEAEI1DdkvbOCI3a9L wD1URCS+pCOZJn6u04Emh4johWZ6VRBbjZTTh81gjehh4Sxy05Fqjc+vNg+F4z9Xp/2j MbsfVmkQjMKdWi0tLiRPipwBNvpr5dJRqAgkVEeDpivH/Yn0bgzx5PqtpZYWZxx6OkD8 1B/Q== X-Gm-Message-State: ALoCoQkiAQQXnAZPXNqa0jV1HlInV/wsa/SaI9b8S6kExOctOhZL5v658ClvuMjBSWDuOUjtsecP X-Received: by 10.43.100.129 with SMTP id cw1mr16560574icc.30.1389188928607; Wed, 08 Jan 2014 05:48:48 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.95.229 with SMTP id dn5ls484579qeb.48.gmail; Wed, 08 Jan 2014 05:48:48 -0800 (PST) X-Received: by 10.52.24.20 with SMTP id q20mr2702930vdf.54.1389188928516; Wed, 08 Jan 2014 05:48:48 -0800 (PST) Received: from mail-vb0-f46.google.com (mail-vb0-f46.google.com [209.85.212.46]) by mx.google.com with ESMTPS id gx6si612398vdc.37.2014.01.08.05.48.48 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 08 Jan 2014 05:48:48 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.46 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.46; Received: by mail-vb0-f46.google.com with SMTP id w20so1124234vbb.5 for ; Wed, 08 Jan 2014 05:48:48 -0800 (PST) X-Received: by 10.58.146.5 with SMTP id sy5mr3251572veb.43.1389188928386; Wed, 08 Jan 2014 05:48:48 -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.59.13.131 with SMTP id ey3csp226615ved; Wed, 8 Jan 2014 05:48:47 -0800 (PST) X-Received: by 10.180.84.166 with SMTP id a6mr21495588wiz.49.1389188927416; Wed, 08 Jan 2014 05:48:47 -0800 (PST) Received: from mail-wi0-f178.google.com (mail-wi0-f178.google.com [209.85.212.178]) by mx.google.com with ESMTPS id kt10si30455957wjc.124.2014.01.08.05.48.46 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 08 Jan 2014 05:48:47 -0800 (PST) Received-SPF: neutral (google.com: 209.85.212.178 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=209.85.212.178; Received: by mail-wi0-f178.google.com with SMTP id bz8so2083829wib.5 for ; Wed, 08 Jan 2014 05:48:46 -0800 (PST) X-Received: by 10.180.14.37 with SMTP id m5mr20164168wic.46.1389188926850; Wed, 08 Jan 2014 05:48:46 -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 j9sm48125217wjx.18.2014.01.08.05.48.45 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 08 Jan 2014 05:48:45 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: computersforpeace@gmail.com, angus.clark@st.com, Lee Jones Subject: [PATCH v4 15/37] mtd: st_spi_fsm: Fetch boot-device from mode pins Date: Wed, 8 Jan 2014 13:46:58 +0000 Message-Id: <1389188840-14306-16-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1389188840-14306-1-git-send-email-lee.jones@linaro.org> References: <1389188840-14306-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.212.46 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)