From patchwork Mon Dec 15 11:59:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 42245 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f69.google.com (mail-ee0-f69.google.com [74.125.83.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4873221772 for ; Mon, 15 Dec 2014 11:59:52 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id d49sf7439801eek.8 for ; Mon, 15 Dec 2014 03:59:51 -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:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=hVbSOHr0BfHv/0NyjeMBFDdNmT1PFh5eLlxn1Aa8SKw=; b=BDSBsYMOi+1C2ggUxvIVZIiM1qZi8vb+EwmdNRAwpElLAX1C+J82HTLBTm5MD2e68v ISmgJGL+KvNOyFsgXC4BlMfRHcuS/wSeKkvX/lzq+vdJ2xCnuvfIwLeEPHs4YILI4TiN hs2Ed/+eIHyiMT3xUOXT/XwmycEjzDevsvUDK8UmobtYJiAWadnwn5JnENKG0Fm/mTJM RL/SOonq1b+rBigc6thOtMmlfr5DlCl5pSld65sblD36rC268ZI8dVtwjmptQOd6MQqW qfi531GIwkNKh63FCsnb6NQWc+LMDoNlcQks3G8JI+6HKgZE24gHE+l+XpBd8+8DjOwp R2lw== X-Gm-Message-State: ALoCoQlaXIcyGu1TTfTUQNcXBSWev0OZsUamLSu5V7+4LdeMUyn6ktsTrr6gXC8+hc1XTcvToR86 X-Received: by 10.180.24.131 with SMTP id u3mr230455wif.4.1418644791546; Mon, 15 Dec 2014 03:59:51 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.87.176 with SMTP id az16ls579038lab.87.gmail; Mon, 15 Dec 2014 03:59:51 -0800 (PST) X-Received: by 10.112.12.65 with SMTP id w1mr29805264lbb.68.1418644791092; Mon, 15 Dec 2014 03:59:51 -0800 (PST) Received: from mail-la0-f51.google.com (mail-la0-f51.google.com. [209.85.215.51]) by mx.google.com with ESMTPS id s4si10172613las.118.2014.12.15.03.59.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 15 Dec 2014 03:59:51 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) client-ip=209.85.215.51; Received: by mail-la0-f51.google.com with SMTP id ms9so9159479lab.24 for ; Mon, 15 Dec 2014 03:59:51 -0800 (PST) X-Received: by 10.152.43.103 with SMTP id v7mr29988111lal.29.1418644790982; Mon, 15 Dec 2014 03:59:50 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.142.69 with SMTP id ru5csp691802lbb; Mon, 15 Dec 2014 03:59:50 -0800 (PST) X-Received: by 10.70.88.231 with SMTP id bj7mr49680816pdb.168.1418644788631; Mon, 15 Dec 2014 03:59:48 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id lm4si13495752pab.217.2014.12.15.03.59.47 for ; Mon, 15 Dec 2014 03:59:48 -0800 (PST) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751225AbaLOL7m (ORCPT + 27 others); Mon, 15 Dec 2014 06:59:42 -0500 Received: from mail-yk0-f180.google.com ([209.85.160.180]:49969 "EHLO mail-yk0-f180.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751105AbaLOL7i (ORCPT ); Mon, 15 Dec 2014 06:59:38 -0500 Received: by mail-yk0-f180.google.com with SMTP id 9so4889476ykp.11 for ; Mon, 15 Dec 2014 03:59:37 -0800 (PST) X-Received: by 10.170.124.16 with SMTP id q16mr23985353ykb.107.1418644777399; Mon, 15 Dec 2014 03:59:37 -0800 (PST) Received: from localhost.localdomain (host109-148-232-11.range109-148.btcentralplus.com. [109.148.232.11]) by mx.google.com with ESMTPSA id d91sm5783468yhq.53.2014.12.15.03.59.35 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 15 Dec 2014 03:59:36 -0800 (PST) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, computersforpeace@gmail.com, linux-mtd@lists.infradead.org Cc: lee.jones@linaro.org, kernel@stlinux.com Subject: [PATCH v3 04/13] mtd: st_spi_fsm: Fetch boot device locations from DT match tables Date: Mon, 15 Dec 2014 11:59:11 +0000 Message-Id: <1418644760-18773-5-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1418644760-18773-1-git-send-email-lee.jones@linaro.org> References: <1418644760-18773-1-git-send-email-lee.jones@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.51 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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. Signed-off-by: Lee Jones --- drivers/mtd/devices/st_spi_fsm.c | 75 ++++++++++++++++++++++++++++++---------- 1 file changed, 57 insertions(+), 18 deletions(-) diff --git a/drivers/mtd/devices/st_spi_fsm.c b/drivers/mtd/devices/st_spi_fsm.c index fac0fe9..d82394a 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,23 @@ static int stfsm_init(struct stfsm *fsm) return 0; } +static const struct of_device_id stfsm_match[] = { + { .compatible = "st,spi-fsm" }, /* DEPRECATED */ + { .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 +2046,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 +2201,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,