Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2786754imu; Mon, 17 Dec 2018 07:50:04 -0800 (PST) X-Google-Smtp-Source: AFSGD/UdCMVHynRFdBbnEntkURChag7KlLqzpe+ExXT2Oyne7yNwZO7xnOrhPldpOidNb/lNLJ07 X-Received: by 2002:a63:1560:: with SMTP id 32mr12329921pgv.383.1545061804156; Mon, 17 Dec 2018 07:50:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545061804; cv=none; d=google.com; s=arc-20160816; b=S33DaGEghXIXZiQLY3hSSBN51BKYpIAUK9ygF6vkcOdDLdwVrff9XD2rlB5Cy2BOKN w0KJFe7EU8+xBOVtwaxo4db/PUKDWUsUgX6+QD60RII0YnQliXjL3k7tZymjS5ezah21 m61jy+oTekNWHO2htUdTbwaDSht+o1RZC+lBxbWzFK363ELht7JNgUdC48kputjd8Uj3 pcECJayODglXmasQeycC74naFlmy1Oj70a001WpiackvOdeNcxrydl6D1gAgVj5bRlTU a4f/HeBri1T4YyYQEnaWDjG/7yjr+BQfz/Xi+LDTKGdT9oRrtKhyqKc1DLKeVa45K743 UaDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=9I/xPB4Y0cqV12qjFH+ohxJh1d3RR5ieESc8rLL9bh4=; b=n8uXXguqKR4Y+t5clfBa5gXNhqA6xIC/MGjHL5fcL8Vdx070nMvscvFnDKIKO8TlnH XL8dV501DUyFRiELzzHzTyrE/ITIB9SGr9WEho+Mc57aCLFPm1RhCpgQm02WYrGScFQ+ dTGf1d2QjJkalB4MWDpG5SF7pNwvTCgqQQOS7c/AhLwe02WECs5FHJ9a9Uv1CYKt+Hc7 CfNQsYRH3o71WLfmWA9KnlWuh54YDpayALtcrHkrjjedmpWhH6nWVzwJTBfjeEIEH3gL Su3j4z4o+0wddWpzOeQEpyYPcwJdMyHS8e5/EkJjqNAVeBk0hwcA68ngafmjz/5pwy/k AhuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DlaoE5Ac; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m187si11699557pfm.51.2018.12.17.07.49.49; Mon, 17 Dec 2018 07:50:04 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=DlaoE5Ac; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387834AbeLQPsU (ORCPT + 99 others); Mon, 17 Dec 2018 10:48:20 -0500 Received: from mail-it1-f195.google.com ([209.85.166.195]:50868 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727617AbeLQPsH (ORCPT ); Mon, 17 Dec 2018 10:48:07 -0500 Received: by mail-it1-f195.google.com with SMTP id z7so19220250iti.0; Mon, 17 Dec 2018 07:48:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=9I/xPB4Y0cqV12qjFH+ohxJh1d3RR5ieESc8rLL9bh4=; b=DlaoE5AcE15BULt2jv+Zge8SWSW2X3Xe537noFwkIQpWb0msmABxRJZGDtBwxphAxn IGDBYO/Fi/yRYauL4tbgrWJkayKeLyNvsh8U90VhYlcaxBOFqbFS7AiI7FVU5XeLaRyY TjANnlbV59RiHeqZ+/bYeJbuUNyFE0JYMQWS/laJy5IhW35Iot7yPlqdrdhY34hPqQQ1 uqpEM1T+RX3qjIs5VAkvZ05tMk9NfYxdA7WzBwVoTPj1A8/0FTU/yCjoguXBijt4RJ32 QGONXfU5R+0uP10v9CO9iE7JUoLlNvdwdBJkJqTsEWTAvswMClyKaUmVseMRRdvkKrld MbsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=9I/xPB4Y0cqV12qjFH+ohxJh1d3RR5ieESc8rLL9bh4=; b=IczBG8rugGnnCV9NHRfcIvDOmcOSA1MNxkGXFPisEZGH/p1uESufvjHdcBwWz1bWm2 PzDla9oa75QjxNvlBDw2Pig3DEufkVuu9JhcXeoX2X2CvbsjqJaPaBPYZdoUFodmcGYM asPFWMZSa0zD8/dNbr+TZ4El6zykrteAqx0T99lwLGanxU5J16EvnUOIiYvsqm/fDQx2 +ZcZjkjgRo+HSbU9OSwZUZmz9OZ/+CLRLGwnuq95n/50Tl2t5D5TocJIJaRi9QzMGlWR sl0jv/G3XdLPHE1MZSHwADuFGB2lySC9bAMHdw5ahyGAl69odXwxLasDwt1y5PySbMjZ 0m+Q== X-Gm-Message-State: AA+aEWbXbndPha2LC0EutLHccNuxtKNv7ZRuZHAChng3ouJCyqaLDU9/ tBoCambI2t8NEj8/yjuaE1s= X-Received: by 2002:a24:5493:: with SMTP id t141mr12748457ita.57.1545061686847; Mon, 17 Dec 2018 07:48:06 -0800 (PST) Received: from svens-asus.arcx.com ([184.94.50.30]) by smtp.gmail.com with ESMTPSA id y23sm18824174ita.1.2018.12.17.07.48.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Dec 2018 07:48:06 -0800 (PST) From: Sven Van Asbroeck X-Google-Original-From: Sven Van Asbroeck To: TheSven73@googlemail.com, Shawn Guo , Kees Cook , Arnd Bergmann Cc: linux-kernel@vger.kernel.org, Rob Herring , devicetree@vger.kernel.org Subject: [PATCH v4 2/3] bus: imx-weim: support multiple address ranges per child node Date: Mon, 17 Dec 2018 10:47:59 -0500 Message-Id: <20181217154800.7448-3-TheSven73@googlemail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181217154800.7448-1-TheSven73@googlemail.com> References: <20181217154800.7448-1-TheSven73@googlemail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ensure that timing values for the child node are applied to all chip selects in the child's address ranges. Note that this does not support multiple timing settings per child; this can be added in the future if required. Example: &weim { acme@0 { compatible = "acme,whatever"; reg = <0 0 0x100>, <0 0x400000 0x800>, <1 0x400000 0x800>; fsl,weim-cs-timing = <0x024400b1 0x00001010 0x20081100 0x00000000 0xa0000240 0x00000000>; }; }; Signed-off-by: Sven Van Asbroeck --- drivers/bus/imx-weim.c | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/drivers/bus/imx-weim.c b/drivers/bus/imx-weim.c index d84996a4528e..1a0e0277a404 100644 --- a/drivers/bus/imx-weim.c +++ b/drivers/bus/imx-weim.c @@ -46,6 +46,7 @@ static const struct imx_weim_devtype imx51_weim_devtype = { }; #define MAX_CS_REGS_COUNT 6 +#define OF_REG_SIZE 3 static const struct of_device_id weim_id_table[] = { /* i.MX1/21 */ @@ -116,26 +117,40 @@ static int __init weim_timing_setup(struct device_node *np, void __iomem *base, { u32 cs_idx, value[MAX_CS_REGS_COUNT]; int i, ret; + int reg_idx, num_regs; if (WARN_ON(devtype->cs_regs_count > MAX_CS_REGS_COUNT)) return -EINVAL; - /* get the CS index from this child node's "reg" property. */ - ret = of_property_read_u32(np, "reg", &cs_idx); + ret = of_property_read_u32_array(np, "fsl,weim-cs-timing", + value, devtype->cs_regs_count); if (ret) return ret; - if (cs_idx >= devtype->cs_count) + /* + * the child node's "reg" property may contain multiple address ranges, + * extract the chip select for each. + */ + num_regs = of_property_count_elems_of_size(np, "reg", OF_REG_SIZE); + if (num_regs < 0) + return num_regs; + if (!num_regs) return -EINVAL; + for (reg_idx = 0; reg_idx < num_regs; reg_idx++) { + /* get the CS index from this child node's "reg" property. */ + ret = of_property_read_u32_index(np, "reg", + reg_idx * OF_REG_SIZE, &cs_idx); + if (ret) + break; - ret = of_property_read_u32_array(np, "fsl,weim-cs-timing", - value, devtype->cs_regs_count); - if (ret) - return ret; + if (cs_idx >= devtype->cs_count) + return -EINVAL; - /* set the timing for WEIM */ - for (i = 0; i < devtype->cs_regs_count; i++) - writel(value[i], base + cs_idx * devtype->cs_stride + i * 4); + /* set the timing for WEIM */ + for (i = 0; i < devtype->cs_regs_count; i++) + writel(value[i], + base + cs_idx * devtype->cs_stride + i * 4); + } return 0; } -- 2.17.1