Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp595436pxb; Wed, 27 Jan 2021 16:11:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJwPEVQAg5JEP2/ZE5mlKMdTloDgUqu4Dq45z0rXgX1uuxTx2VCw5ERLjfm5cdekHOQN8Kys X-Received: by 2002:a17:906:46d3:: with SMTP id k19mr8470779ejs.546.1611792707732; Wed, 27 Jan 2021 16:11:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611792707; cv=none; d=google.com; s=arc-20160816; b=IqSkPovtPxailYPSOfCG+hCl6opKOwUt23iyEIAJAtukuBLzrmnW+kLemD+u+feoVR WtQgL8rVotSeOPJ2CV68bUkL5fwWrRH3xLMrj/s3lFUi5nP77KEqIKlNngI4s0RC7H5M NWXjbbhOmy5aPeiVIXhtMj/NJalOFYZLWGGoRNt4s98etFbeXWSOoMxmQ1A1xVDGPUVG viePrnbcwTWMcBm81zaWTO1L5mu3kdqxmo+QRJ3CzTS+gtQL69iGYtsknusjpCMo15Wj Ii08vf7TWj2XtYkkrZJnHfIu0B+TW3Bv4RReB7QJbMDXP0kycoNTHzv3Ukjoe4sQwAS9 pf7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from; bh=EW9naTnPvXVjGNcb5ky7zY7K3RW/D3btVL5B99oURVg=; b=fT/Y2HvLP+I0hIrcN3vePXBLrap8oP3LSq2AKNpjtB6fXcecVrx+edOIC69bqXfeJr LKnXT/DUUffwbhmTC13eRAe4ZhOq8mw+TAUlzHvO46NO/2wZCNortxsMOkpcMKE6OQTM cwSmMLQ60wF0wXmSp6M4TkBmad983X7piR5W6qq21922E89WRwjvRAAYrG9y4HF7vNM0 L4bpw4md8ZL22JoMRDxiXODpvAJP9S1UinzktCPsy3VxfeuczrCZuk/+ssALZ2OdWsG+ RSBiOGB7YZGNPJhKel8dOASsX/WyWqJuEVPgzfOx5kPu0vIth6YgN94/X0aZ9jdg29Jl +PVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hr15si1483636ejc.287.2021.01.27.16.11.23; Wed, 27 Jan 2021 16:11:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344310AbhA0Ryg (ORCPT + 99 others); Wed, 27 Jan 2021 12:54:36 -0500 Received: from foss.arm.com ([217.140.110.172]:56888 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343628AbhA0R1W (ORCPT ); Wed, 27 Jan 2021 12:27:22 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0A0B91424; Wed, 27 Jan 2021 09:26:07 -0800 (PST) Received: from localhost.localdomain (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1BA433F66E; Wed, 27 Jan 2021 09:26:04 -0800 (PST) From: Andre Przywara To: Maxime Ripard , Chen-Yu Tsai Cc: Jernej Skrabec , Samuel Holland , Icenowy Zheng , Rob Herring , =?UTF-8?q?Cl=C3=A9ment=20P=C3=A9ron?= , Shuosheng Huang , Yangtao Li , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-sunxi@googlegroups.com Subject: [PATCH v5 08/20] soc: sunxi: sram: Add support for more than one EMAC clock Date: Wed, 27 Jan 2021 17:24:48 +0000 Message-Id: <20210127172500.13356-9-andre.przywara@arm.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20210127172500.13356-1-andre.przywara@arm.com> References: <20210127172500.13356-1-andre.przywara@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The Allwinner H616 adds a second EMAC clock register at offset 0x34, for controlling the second EMAC in this chip. Allow to extend the regmap in this case, to cover more than the current 4 bytes exported. Signed-off-by: Andre Przywara --- drivers/soc/sunxi/sunxi_sram.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/soc/sunxi/sunxi_sram.c b/drivers/soc/sunxi/sunxi_sram.c index d4c7bd59429e..42833e33a96c 100644 --- a/drivers/soc/sunxi/sunxi_sram.c +++ b/drivers/soc/sunxi/sunxi_sram.c @@ -283,7 +283,7 @@ int sunxi_sram_release(struct device *dev) EXPORT_SYMBOL(sunxi_sram_release); struct sunxi_sramc_variant { - bool has_emac_clock; + int num_emac_clocks; }; static const struct sunxi_sramc_variant sun4i_a10_sramc_variant = { @@ -291,20 +291,31 @@ static const struct sunxi_sramc_variant sun4i_a10_sramc_variant = { }; static const struct sunxi_sramc_variant sun8i_h3_sramc_variant = { - .has_emac_clock = true, + .num_emac_clocks = 1, }; static const struct sunxi_sramc_variant sun50i_a64_sramc_variant = { - .has_emac_clock = true, + .num_emac_clocks = 1, +}; + +static const struct sunxi_sramc_variant sun50i_h616_sramc_variant = { + .num_emac_clocks = 2, }; #define SUNXI_SRAM_EMAC_CLOCK_REG 0x30 static bool sunxi_sram_regmap_accessible_reg(struct device *dev, unsigned int reg) { - if (reg == SUNXI_SRAM_EMAC_CLOCK_REG) - return true; - return false; + const struct sunxi_sramc_variant *variant; + + variant = of_device_get_match_data(dev); + + if (reg < SUNXI_SRAM_EMAC_CLOCK_REG) + return false; + if (reg > SUNXI_SRAM_EMAC_CLOCK_REG + variant->num_emac_clocks * 4) + return false; + + return true; } static struct regmap_config sunxi_sram_emac_clock_regmap = { @@ -312,7 +323,7 @@ static struct regmap_config sunxi_sram_emac_clock_regmap = { .val_bits = 32, .reg_stride = 4, /* last defined register */ - .max_register = SUNXI_SRAM_EMAC_CLOCK_REG, + .max_register = SUNXI_SRAM_EMAC_CLOCK_REG + 4, /* other devices have no business accessing other registers */ .readable_reg = sunxi_sram_regmap_accessible_reg, .writeable_reg = sunxi_sram_regmap_accessible_reg, @@ -343,7 +354,7 @@ static int sunxi_sram_probe(struct platform_device *pdev) if (!d) return -ENOMEM; - if (variant->has_emac_clock) { + if (variant->num_emac_clocks > 0) { emac_clock = devm_regmap_init_mmio(&pdev->dev, base, &sunxi_sram_emac_clock_regmap); @@ -387,6 +398,10 @@ static const struct of_device_id sunxi_sram_dt_match[] = { .compatible = "allwinner,sun50i-h5-system-control", .data = &sun50i_a64_sramc_variant, }, + { + .compatible = "allwinner,sun50i-h616-system-control", + .data = &sun50i_h616_sramc_variant, + }, { }, }; MODULE_DEVICE_TABLE(of, sunxi_sram_dt_match); -- 2.17.5