From patchwork Wed Jan 21 15:24:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 431512 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2001:1868:205::9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 9BB0D1400F1 for ; Thu, 22 Jan 2015 02:32:34 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1YDxCQ-0002YG-RI; Wed, 21 Jan 2015 15:28:06 +0000 Received: from mail-ig0-f171.google.com ([209.85.213.171]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YDx9X-00088v-4B for linux-mtd@lists.infradead.org; Wed, 21 Jan 2015 15:25:09 +0000 Received: by mail-ig0-f171.google.com with SMTP id h15so14793432igd.4 for ; Wed, 21 Jan 2015 07:24:44 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GOyB54+kINV6z2I8YwD8IjsubtqinNCd5Xw2X/QFIoI=; b=f29FPiji8CIBUac9zxjhRuXm8fAMLlqqF3wCwcULQj3ghQP6+09TIpiWVhUjAkuCo3 hh+N76Y31QfY3rEHrQaFg5ABXYBjtnfio/wxbxvydmmE23qbD6R+isFx7v9ZaAhgllwr WBAiiBigF9mB35NbOoALMW5E9MVFwdIb/boYuQb0tTZMkcvab3sw5cT+w0+rDFlXuesl Tg2uBx3JutDcbPtQvjqf/UrpQ8Bgypi73F1XCExkxJqnvdpa/eqlqhlTdOJTvIXoOJ+E Gl6LrCbAMUPbgFRS1VeC+tfIbX3EnJUfWU8j/6OKYukagC+gnYtSuFWPLZzrf9NcQrTG 5WWA== X-Gm-Message-State: ALoCoQk8OTmPUCBEy6DcK1azi19FVaehUU4R+UsQzJ6W1U9dVp4dCCEJTe2YZAKeh0+goWwyxon4 X-Received: by 10.50.43.138 with SMTP id w10mr2185486igl.19.1421853884758; Wed, 21 Jan 2015 07:24:44 -0800 (PST) Received: from localhost.localdomain (host86-181-29-86.range86-181.btcentralplus.com. [86.181.29.86]) by mx.google.com with ESMTPSA id y5sm1411873ign.7.2015.01.21.07.24.42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 21 Jan 2015 07:24:44 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 02/10] mtd: st_spi_fsm: Fetch boot device locations from DT match tables Date: Wed, 21 Jan 2015 15:24:20 +0000 Message-Id: <1421853868-8262-3-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1421853868-8262-1-git-send-email-lee.jones@linaro.org> References: <1421853868-8262-1-git-send-email-lee.jones@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150121_072507_289362_55445489 X-CRM114-Status: GOOD ( 17.74 ) X-Spam-Score: -0.7 (/) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-0.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.213.171 listed in list.dnswl.org] -0.0 RCVD_IN_MSPIKE_H2 RBL: Average reputation (+2) [209.85.213.171 listed in wl.mailspike.net] -0.0 SPF_PASS SPF: sender matches SPF record Cc: linux-mtd@lists.infradead.org, computersforpeace@gmail.com, lee.jones@linaro.org, kernel@stlinux.com, devicetree@vger.kernel.org X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org To trim down on the amount of properties used by this driver and to conform to the newly agreed method of acquiring syscfg registers/offsets, we now obtain this information using match tables. In the process we are deprecating the old generic compatible string and providing 3 shiny new ones for each of the support platforms. The deprecated compatible string will be removed in due course. Cc: devicetree@vger.kernel.org Signed-off-by: Lee Jones --- drivers/mtd/devices/st_spi_fsm.c | 74 ++++++++++++++++++++++++++++++---------- 1 file changed, 56 insertions(+), 18 deletions(-) diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c index 3060025..9e4fded 100644 --- a/drivers/mtd/devices/st_spi_fsm.c +++ b/drivers/mtd/devices/st_spi_fsm.c @@ -29,6 +29,21 @@ #include "serial_flash_cmds.h" /* + * FSM SPI Boot Mode Registers/Masks + */ +#define STID127_SYSCON_BOOT_DEV_REG 0x0D8 +#define STID127_SYSCON_BOOT_DEV_SPI 0x068 +#define STID127_SYSCON_BOOT_DEV_MASK 0x07C + +#define STIH407_SYSCON_BOOT_DEV_REG 0x8C4 +#define STIH407_SYSCON_BOOT_DEV_SPI 0x068 +#define STIH407_SYSCON_BOOT_DEV_MASK 0x07C + +#define STIH416_SYSCON_BOOT_DEV_REG 0x958 +#define STIH416_SYSCON_BOOT_DEV_SPI 0x01A +#define STIH416_SYSCON_BOOT_DEV_MASK 0x01F + +/* * FSM SPI Controller Registers */ #define SPI_CLOCKDIV 0x0010 @@ -288,6 +303,12 @@ struct seq_rw_config { uint8_t dummy_cycles; /* No. of DUMMY cycles */ }; +struct stfsm_boot_dev { + uint32_t reg; + uint32_t spi; + uint32_t mask; +}; + /* SPI Flash Device Table */ struct flash_info { char *name; @@ -313,6 +334,24 @@ struct flash_info { int (*config)(struct stfsm *); }; +static struct stfsm_boot_dev stfsm_stid127_data = { + .reg = STID127_SYSCON_BOOT_DEV_REG, + .spi = STID127_SYSCON_BOOT_DEV_SPI, + .mask = STID127_SYSCON_BOOT_DEV_MASK, +}; + +static struct stfsm_boot_dev stfsm_stih407_data = { + .reg = STIH407_SYSCON_BOOT_DEV_REG, + .spi = STIH407_SYSCON_BOOT_DEV_SPI, + .mask = STIH407_SYSCON_BOOT_DEV_MASK, +}; + +static struct stfsm_boot_dev stfsm_stih416_data = { + .reg = STIH416_SYSCON_BOOT_DEV_REG, + .spi = STIH416_SYSCON_BOOT_DEV_SPI, + .mask = STIH416_SYSCON_BOOT_DEV_MASK, +}; + static int stfsm_n25q_config(struct stfsm *fsm); static int stfsm_mx25_config(struct stfsm *fsm); static int stfsm_s25fl_config(struct stfsm *fsm); @@ -1977,14 +2016,22 @@ static int stfsm_init(struct stfsm *fsm) return 0; } +static const struct of_device_id stfsm_match[] = { + { .compatible = "st,stid127-spi-fsm", .data = &stfsm_stid127_data }, + { .compatible = "st,stih407-spi-fsm", .data = &stfsm_stih407_data }, + { .compatible = "st,stih416-spi-fsm", .data = &stfsm_stih416_data }, + {}, +}; +MODULE_DEVICE_TABLE(of, stfsm_match); + 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; + const struct stfsm_boot_dev *boot_dev; + const struct of_device_id *match; struct regmap *regmap; - uint32_t boot_device_reg; - uint32_t boot_device_spi; - uint32_t boot_device; /* Value we read from *boot_device_reg */ + uint32_t boot_device; /* Value we read from the boot dev mode pins */ int ret; /* Booting from SPI NOR Flash is the default */ @@ -1998,21 +2045,18 @@ static void stfsm_fetch_platform_configs(struct platform_device *pdev) fsm->reset_por = of_property_read_bool(np, "st,reset-por"); - /* Where in the syscon the boot device information lives */ - ret = of_property_read_u32(np, "st,boot-device-reg", &boot_device_reg); - if (ret) + match = of_match_node(stfsm_match, np); + if (!match) goto boot_device_fail; + boot_dev = match->data; - /* Boot device value when booted from SPI NOR */ - ret = of_property_read_u32(np, "st,boot-device-spi", &boot_device_spi); + ret = regmap_read(regmap, boot_dev->reg, &boot_device); if (ret) goto boot_device_fail; - ret = regmap_read(regmap, boot_device_reg, &boot_device); - if (ret) - goto boot_device_fail; + boot_device &= boot_dev->mask; - if (boot_device != boot_device_spi) + if (boot_device != boot_dev->spi) fsm->booted_from_spi = false; return; @@ -2156,12 +2200,6 @@ static int stfsmfsm_resume(struct device *dev) static SIMPLE_DEV_PM_OPS(stfsm_pm_ops, stfsmfsm_suspend, stfsmfsm_resume); -static const struct of_device_id stfsm_match[] = { - { .compatible = "st,spi-fsm", }, - {}, -}; -MODULE_DEVICE_TABLE(of, stfsm_match); - static struct platform_driver stfsm_driver = { .probe = stfsm_probe, .remove = stfsm_remove,