From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796001960; b=1hVKNuNn8Z/oxNp7ubeIJbfkLEXosBzWcPRfuowLDAz7YJaSfY2SMKb52cyGvFtkp67b Fjh+dw943B5SjbApC2T2lEGKl99woQfXO6cfMzthiyA4nW7TqBFYQCNJM9keveX2MsnIF vBpivKMGfoW2QESkL1bypxVRKy2B88qb8YIO2G9PFr/zVNdETjy6JLGP67QUI5zzJhSRx 0fozjP/6dtiwtzPxY3nZImguk4t1f02kgjJrvlssqM1lUeNNh7G1FYwgZBzYXDQBzMpnp izYPgk845kcfom07MrPq18qH9DR4BNaKVWWeGza6vmGwO4FK4nfqb88Kz13dwB9u5vw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796001960; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=XeNH/mD/XuEnMx4dE5ho+4drptvDq8XyHkKx10G5L7Y=; b=TPlDbK5rfiK0XKtPGKVhtCvAQw2O11/rxQifNyZ8Zpl+IjMk9gozmlwFssBZALG0IvDO 9a3CTAH3MLIS4yp38DCJee6HrMoTvBIwFCW2KzPXs+8bGW7PhwaG8ILgbJt2erFD+x/7p xJLeMyXDLmKiNhhfq05Z6S2vkkPp4uUSAS7DxuTBM1XUxnwzfMxt+qCClo4mv0EoouYO/ xnAlVxSiv0kXeXFX/BhiXzpFI4BGLjIUMq2UQQ5gZ9ABLB737yqer0JAvlzJYt1H1Ad/2 4dp7/NZ7fDSTZQsP1bxBBJ2CMONGWNthtoaDwPcfbJEe3BUukAxWrD99MCVufgRr9cQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=IvmDm0zD; arc=none smtp.remote-ip=209.85.221.51 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2B61F606A33B for ; Mon, 30 Nov 2026 01:25:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2B61F606A33B Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=IvmDm0zD Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-48e20ed3b9dso8803764f8f.2 for ; Sun, 29 Nov 2026 17:25:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796001958; x=1796606758; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=XeNH/mD/XuEnMx4dE5ho+4drptvDq8XyHkKx10G5L7Y=; b=IvmDm0zDXWWZEQf1x5buU1S00ySAZaxTJzUIHsfqs3Ahua0S7zWBas7ab3j9Mk2/LB uY2YeAQs/a6qRMKyhvb60+lLMoBrdGJi/8DAYI+1WzmWc8imw7vIi2DPZHIx1bQd0/n0 aaJZ/lxcPPvfZ2tV/tPsocAY53Cdy/RRh2trzka3iXGH4uRuHNq6drBxwzUOiHC9ACvG UfyhB/7r0locKaRRfCYyZenJd3nTFMOO9a8lqrD9EgRrStPBbW4NC5yS07E13wfFs9Qe RpLzJsuaNbKCgrvxBP/Zy7exfb1e1hc3k9t1KNc9rWuazmXpy3mEvX0g8/IfBLFxT4R5 gQ6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796001958; x=1796606758; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=XeNH/mD/XuEnMx4dE5ho+4drptvDq8XyHkKx10G5L7Y=; b=K8HD726YPMIdg1ECn3QrUA73B1w4M8rrHLDFC8uTbGjpPR1le4qt6d5BbUx5pyYxVE y8N4RIwPFSsCJ7ckzvMU6XUu5Gs79r8Wnp3idWSnjAxdhcCwalcfJQDEK7qwT2WL19P5 H4debD5mRLzHFqo2Kjwkxkz0tam67HrzCl5OxWHbLtBOlde2acRM9S4/CZuEl9qYCOVJ xAMGymU7+zjvPb8cBSqDO6zNJAJYoAlh+HrtaqfwhBfb9Cx3WPSTSCCVwrJ16nzHgT0L 0Vf4dE1TeIRrhhsUMj8LMb73B1HEhD1DjLq0FnSbk+aZhTnYh8BnRGphcr9shsuspv7z SC4w== X-Forwarded-Encrypted: i=1; AL+hErEjroS2gTpiZ/7OZjDtXVKAvXK+Jmf0gJbyXAw5IHJY4Ja5xm2TkMihA7XNdHRQTXb+4E0Mx/KI72g=@vger.kernel.org X-Gm-Message-State: APuU4Z8CXrTYrjwJgqEFbQIgdLMXmMaIxSopy+9Q36b/iGDuH1YO/Sq8 F4PfK7kiH99oZ+wbIu7gsw8mJpC+kXSJCe6U56hwUZ4Ycwx41klECUoq X-Gm-Gg: AZFdTZep4DU8Q7liTmT2MM5XtoWUgU5RNI3gk71A+jH7IGaI7NxZieca+ZNL41dZDel DCGsrk1scmF7r/F3Vv8UntoV82qCkukHeoQ4KlYiFElZNL1BUydvYLNCr9VNKT4Nqbk9FxN4rqg QN7LORTB7szmaCm3aE1wQ2COWGqxWw6P4ul9pZAUQyK3jS/tV9tYrDM17+m34g4BRCOdpi9KCRt nJ9BqwGbfSGxpokVn3DQf1Xqjsw17omYN7mVqIIZbCBb4nDxeY1SFpVKQFBT96O5TKQtFS2sBpM 1I1DdxhOmkZq9RrbGf3pdGxhGy+c4bYgED9AFQzBsySechz/hcVM5ekyUn2BzEFodrusyXfF023 SZz0FQvqZJfPkU/KTYLmVGLIFJ0oCzmq3Kywz3hxX0o5mYFOCRm3JOJeNHzhshjCYMuGKC3Kt9F /8KLUoQ4HfV7ogidj2Jp0JCmLgn/8U3LKFWcBszWO8E/4OkHa8JpgwXqj4jcFOcStNtxmBAO9xi f9bIoyFbyUKnALCuOLD9Uh5CVOr+HzAtAyIueeZxUthwXAkFvnWv0Emv1iju25qZvnJvqq77dCF dgIVSs2lReG8Z+i6+v/cO+SwvfLdqe1TNMQDJACm7ry/NscTrIpgp+vJyfFEXD83RQ3ROZT3zAG /rJjynorwS0MMK52OTg== X-Received: by 2002:a05:6000:178f:b0:4bb:c85e:d565 with SMTP id ffacd0b85a97d-4bbc86e17b5mr25270498f8f.55.1796001958437; Sun, 29 Nov 2026 17:25:58 -0800 (PST) Received: from Ansuel-XPS24 (93-34-92-103.ip49.fastwebnet.it. [93.34.92.103]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-4b70c05b9desm36833570f8f.54.2026.11.29.17.25.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Nov 2026 17:25:57 -0800 (PST) From: Christian Marangi To: Stephen Boyd , Brian Masney , Jerome Brunet , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel , Felix Fietkau , linux-clk@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Christian Marangi Subject: [PATCH v16 8/8] clk: en7523: add support for Airoha AN7583 clock Date: Mon, 30 Nov 2026 02:25:06 +0100 Message-ID: <20261130012507.660547-9-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261130012507.660547-1-ansuelsmth@gmail.com> References: <20261130012507.660547-1-ansuelsmth@gmail.com> X-Mailing-List: linux-clk@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add support for Airoha AN7583 clock and reset. Airoha AN7583 SoC have the same register address of EN7581 but implement different bits and additional base clocks. Also reset are different with the introduction of 2 dedicated MDIO line and drop of some reset lines. Signed-off-by: Christian Marangi --- drivers/clk/clk-en7523.c | 237 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 237 insertions(+) diff --git a/drivers/clk/clk-en7523.c b/drivers/clk/clk-en7523.c index e91fb9c066c3..07d9e1887580 100644 --- a/drivers/clk/clk-en7523.c +++ b/drivers/clk/clk-en7523.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -253,6 +254,14 @@ static const u32 crypto_base[] = { 540000000, 480000000 }; static const u32 emmc7581_base[] = { 200000000, 150000000 }; /* EN751221 */ static const u32 gsw751221_base[] = { 500000000, 250000000, 400000000, 200000000 }; +/* AN7583 */ +static const u32 gsw7583_base[] = { 540672000, 270336000, 400000000, 200000000 }; +static const u32 emi7583_base[] = { 540672000, 480000000, 400000000, 300000000 }; +static const u32 bus7583_base[] = { 600000000, 540672000, 480000000, 400000000 }; +static const u32 spi7583_base[] = { 400000000, 12500000 }; +static const u32 npu7583_base[] = { 666000000, 800000000, 720000000, 600000000 }; +static const u32 crypto7583_base[] = { 540672000, 400000000 }; +static const u32 emmc7583_base[] = { 150000000, 200000000 }; static const struct en_clk_desc en7523_base_clks[] = { { @@ -437,6 +446,125 @@ static const struct en_clk_desc en7581_base_clks[] = { } }; +static const struct en_clk_desc an7583_base_clks[] = { + { + .id = EN7523_CLK_GSW, + .name = "gsw", + + .base_reg = REG_GSW_CLK_DIV_SEL, + .base_bits = 2, + .base_shift = 8, + .base_values = gsw7583_base, + .n_base_values = ARRAY_SIZE(gsw7583_base), + + .div_bits = 3, + .div_shift = 0, + }, { + .id = EN7523_CLK_EMI, + .name = "emi", + + .base_reg = REG_EMI_CLK_DIV_SEL, + .base_bits = 2, + .base_shift = 8, + .base_values = emi7583_base, + .n_base_values = ARRAY_SIZE(emi7583_base), + + .div_bits = 3, + .div_shift = 0, + }, { + .id = EN7523_CLK_BUS, + .name = "bus", + + .base_reg = REG_BUS_CLK_DIV_SEL, + .base_bits = 2, + .base_shift = 8, + .base_values = bus7583_base, + .n_base_values = ARRAY_SIZE(bus7583_base), + + .div_bits = 3, + .div_shift = 0, + .div_table = bus_div, + }, { + .id = EN7523_CLK_SLIC, + .name = "slic", + + .base_reg = REG_SPI_CLK_FREQ_SEL, + .base_bits = 1, + .base_shift = 1, + .base_values = slic_base, + .n_base_values = ARRAY_SIZE(slic_base), + + .div_reg = REG_SPI_CLK_DIV_SEL, + .div_bits = 5, + .div_shift = 24, + .div_table = slic_div, + }, { + .id = EN7523_CLK_SPI, + .name = "spi", + + .base_reg = REG_SPI_CLK_FREQ_SEL, + .base_bits = 1, + .base_shift = 0, + .base_values = spi7583_base, + .n_base_values = ARRAY_SIZE(spi7583_base), + + .div_reg = REG_SPI_CLK_DIV_SEL, + .div_bits = 5, + .div_shift = 8, + .div_table = spi_div, + }, { + .id = EN7523_CLK_NPU, + .name = "npu", + + .base_reg = REG_NPU_CLK_DIV_SEL, + .base_bits = 2, + .base_shift = 9, + .base_values = npu7583_base, + .n_base_values = ARRAY_SIZE(npu7583_base), + + .div_bits = 3, + .div_shift = 0, + }, { + .id = EN7523_CLK_CRYPTO, + .name = "crypto", + + .base_reg = REG_CRYPTO_CLKSRC2, + .base_bits = 1, + .base_shift = 0, + .base_values = crypto7583_base, + .n_base_values = ARRAY_SIZE(crypto7583_base), + }, { + .id = EN7581_CLK_EMMC, + .name = "emmc", + + .base_reg = REG_CRYPTO_CLKSRC2, + .base_bits = 1, + .base_shift = 13, + .base_values = emmc7583_base, + .n_base_values = ARRAY_SIZE(emmc7583_base), + }, { + .id = AN7583_CLK_MDIO0, + .name = "mdio0", + + .base_reg = REG_CRYPTO_CLKSRC2, + + .base_value = 25000000, + + .div_bits = 4, + .div_shift = 15, + }, { + .id = AN7583_CLK_MDIO1, + .name = "mdio1", + + .base_reg = REG_CRYPTO_CLKSRC2, + + .base_value = 25000000, + + .div_bits = 4, + .div_shift = 19, + } +}; + static const u16 en7581_rst_ofs[] = { REG_RST_CTRL2, REG_RST_CTRL1, @@ -612,6 +740,64 @@ static const u16 en751221_rst_map[] = { [EN751221_USB_PHY_P1_RST] = 3 * RST_NR_PER_BANK + 7, }; +static const u16 an7583_rst_map[] = { + /* RST_CTRL2 */ + [AN7583_XPON_PHY_RST] = 0, + [AN7583_GPON_OLT_RST] = 1, + [AN7583_CPU_TIMER2_RST] = 2, + [AN7583_HSUART_RST] = 3, + [AN7583_UART4_RST] = 4, + [AN7583_UART5_RST] = 5, + [AN7583_I2C2_RST] = 6, + [AN7583_XSI_MAC_RST] = 7, + [AN7583_XSI_PHY_RST] = 8, + [AN7583_NPU_RST] = 9, + [AN7583_TRNG_MSTART_RST] = 12, + [AN7583_DUAL_HSI0_RST] = 13, + [AN7583_DUAL_HSI1_RST] = 14, + [AN7583_DUAL_HSI0_MAC_RST] = 16, + [AN7583_DUAL_HSI1_MAC_RST] = 17, + [AN7583_XPON_XFI_RST] = 18, + [AN7583_WDMA_RST] = 19, + [AN7583_WOE0_RST] = 20, + [AN7583_HSDMA_RST] = 22, + [AN7583_TDMA_RST] = 24, + [AN7583_EMMC_RST] = 25, + [AN7583_SOE_RST] = 26, + [AN7583_XFP_MAC_RST] = 28, + [AN7583_MDIO0_RST] = 30, + [AN7583_MDIO1_RST] = 31, + /* RST_CTRL1 */ + [AN7583_PCM1_ZSI_ISI_RST] = RST_NR_PER_BANK + 0, + [AN7583_FE_PDMA_RST] = RST_NR_PER_BANK + 1, + [AN7583_FE_QDMA_RST] = RST_NR_PER_BANK + 2, + [AN7583_PCM_SPIWP_RST] = RST_NR_PER_BANK + 4, + [AN7583_CRYPTO_RST] = RST_NR_PER_BANK + 6, + [AN7583_TIMER_RST] = RST_NR_PER_BANK + 8, + [AN7583_PCM1_RST] = RST_NR_PER_BANK + 11, + [AN7583_UART_RST] = RST_NR_PER_BANK + 12, + [AN7583_GPIO_RST] = RST_NR_PER_BANK + 13, + [AN7583_GDMA_RST] = RST_NR_PER_BANK + 14, + [AN7583_I2C_MASTER_RST] = RST_NR_PER_BANK + 16, + [AN7583_PCM2_ZSI_ISI_RST] = RST_NR_PER_BANK + 17, + [AN7583_SFC_RST] = RST_NR_PER_BANK + 18, + [AN7583_UART2_RST] = RST_NR_PER_BANK + 19, + [AN7583_GDMP_RST] = RST_NR_PER_BANK + 20, + [AN7583_FE_RST] = RST_NR_PER_BANK + 21, + [AN7583_USB_HOST_P0_RST] = RST_NR_PER_BANK + 22, + [AN7583_GSW_RST] = RST_NR_PER_BANK + 23, + [AN7583_SFC2_PCM_RST] = RST_NR_PER_BANK + 25, + [AN7583_PCIE0_RST] = RST_NR_PER_BANK + 26, + [AN7583_PCIE1_RST] = RST_NR_PER_BANK + 27, + [AN7583_CPU_TIMER_RST] = RST_NR_PER_BANK + 28, + [AN7583_PCIE_HB_RST] = RST_NR_PER_BANK + 29, + [AN7583_XPON_MAC_RST] = RST_NR_PER_BANK + 31, + + /* RST_PCIC */ + [AN7583_PCIC_PERSTOUT0_RST] = 2 * RST_NR_PER_BANK + 29, + [AN7583_PCIC_PERSTOUT1_RST] = 2 * RST_NR_PER_BANK + 26, +}; + static int en7581_reset_register(struct device *dev, void __iomem *base, const u16 *rst_map, int nr_resets, const u16 *rst_reg_ofs); @@ -1462,6 +1648,43 @@ static int en7581_clk_hw_init(struct platform_device *pdev, return en7581_serdes_phy_register(&pdev->dev); } +static int an7583_clk_hw_init(struct platform_device *pdev, + struct clk_hw_onecell_data *clk_data) +{ + struct en_clk_priv *priv = platform_get_drvdata(pdev); + struct device *dev = &pdev->dev; + struct regmap *map; + void __iomem *base; + u32 val; + int ret; + + map = syscon_regmap_lookup_by_phandle(dev->of_node, "airoha,chip-scu"); + if (IS_ERR(map)) + return PTR_ERR(map); + + base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(base)) + return PTR_ERR(base); + + priv->base = base; + + en7581_register_clocks(dev, clk_data, map, base); + + val = readl(base + REG_RST_CTRL1); + val |= REG_PCIE_HB_RST; + writel(val, base + REG_RST_CTRL1); + val &= ~REG_PCIE_HB_RST; + writel(val, base + REG_RST_CTRL1); + + ret = en7581_reset_register(dev, base, an7583_rst_map, + ARRAY_SIZE(an7583_rst_map), + en7581_rst_ofs); + if (ret) + return ret; + + return en7581_serdes_phy_register(dev); +} + static enum en_hir get_hw_id(void __iomem *np_base) { u32 val = FIELD_GET(REG_HIR_MASK, readl(np_base + REG_HIR)); @@ -1617,6 +1840,19 @@ static const struct en_clk_soc_data en7581_data = { .hw_init = en7581_clk_hw_init, }; +static const struct en_clk_soc_data an7583_data = { + /* We increment num_clocks by 1 to account for additional PCIe clock */ + .num_clocks = ARRAY_SIZE(an7583_base_clks) + 1, + .base_clks = an7583_base_clks, + .num_base_clocks = ARRAY_SIZE(an7583_base_clks), + .pcie_ops = { + .is_enabled = en7581_pci_is_enabled, + .enable = en7581_pci_enable, + .disable = en7581_pci_disable, + }, + .hw_init = an7583_clk_hw_init, +}; + static const struct en_clk_soc_data en751221_data = { .num_clocks = EN751221_MAX_CLKS, .pcie_ops = { @@ -1631,6 +1867,7 @@ static const struct en_clk_soc_data en751221_data = { static const struct of_device_id of_match_clk_en7523[] = { { .compatible = "airoha,en7523-scu", .data = &en7523_data }, { .compatible = "airoha,en7581-scu", .data = &en7581_data }, + { .compatible = "airoha,an7583-scu", .data = &an7583_data }, { .compatible = "econet,en751221-scu", .data = &en751221_data }, { /* sentinel */ } }; -- 2.55.0