From nobody Fri Oct 10 13:59:18 2025 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 475F12F2C6B; Tue, 17 Jun 2025 13:05:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750165544; cv=none; b=jwuTgy4lqHTqVa43RlhAH+BOkdSxXQRpMIYCDqfxIONUnY5JMFlO6H4EpA9HtphhDMGNk7gNpq7nqa/6AqNYrvfaXQNhPTb1xu08bML/4kNYh5hM+VpFl16QGxlnNFCugtM3Jk2MHbNZwlnFyUWVmTRydBHYRcF4I8ep3Epe6Ms= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750165544; c=relaxed/simple; bh=e/F7CSb5q9Iv7jtPL8jwYVDok8lnuwP3rSuHIKMSxLI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=upaBhKXNXR8NDOUe5nkVirWzNqAbxjkoQAu8qOcJqYyvhGNaek7YwOBso6X3uRMR67EfkTOh2eqzwS6DdhyX3xj3U8pEjY6WBFstdjMs9NkilxxSwoB6s+wYCGUNMWJkoh2ivTLx8UD2Rl/1/IIUnzamePsa4GxEXBXIZuPJAKM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=JwwMGfvQ; arc=none smtp.client-ip=209.85.128.52 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.b="JwwMGfvQ" Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4530921461aso49156385e9.0; Tue, 17 Jun 2025 06:05:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750165540; x=1750770340; 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; bh=gYjXOWBGgYfaMv6O4g8QrkNs2QKEZyJzUrDyrW4A5gU=; b=JwwMGfvQ+C/Mh8DUjNJAF5b8xQJgRExCCauLleTGhG9Gj8b7k9T+lbQPZX/5T9Xn8w WMVWiNc22oTLfKoDTJgsrzqLiHUw/mydbr6lZOAgj2X46vxbe/Zv/4IJW84y+qFtHSWk CKBL92MbHLIpZ8omDES+Gx/6gVUz4/lNs0EN7iBa1EpO1pes9gWUs0uf8TxObFgdnfeY v6caDr9wWHMFtTjPDaooNG5OCgbEe/F1RKxnpT/0Sy2n3/Ev9c1no+rbEvxzZ6eFTp9N nC/rYbxo4fFTZGZPc55T2vPdz680mxBFeUF3S6yyZt3JhpmzMIE9VC5Z2fI1mjeWums8 WRlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750165540; x=1750770340; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gYjXOWBGgYfaMv6O4g8QrkNs2QKEZyJzUrDyrW4A5gU=; b=ePjODAw5FyD38g7DaX7+FBoIKxvXVucJ3lSXBB3juvnaxPi67U0N5DbedjRHCbN2mz QNoF5agSoblt/mVmgvHLWqxsPoPRCa8cuB3qYcZOybp1DREDQLPv0xRLuxhLvLH+edHE WOYGRqlq//oQLZYDb38O4q1oSqXJO85orYvsqMaxeGAnVkprUujOtc9MQWWAoH+3VJoq 08eJrb46I7sVtej3XXErUEzle0mC/jY3yJoX7E5DTijPqcjTm7y3tHK5YFOxNee4SGoT OJyuDKIA1O7Dt6gC5RM8hF2roVJLegRpOuM4KXDDcct0CRo9iEbOguFgyhS9B3Wj9pyV HRkw== X-Forwarded-Encrypted: i=1; AJvYcCU41pV1BVOkeCg68TA1VipWfuyOb3QojHOvHkH4FRt3X1tG0hk4UVudS8o44q3TFoJUGmucSi5ScFmbAgod@vger.kernel.org, AJvYcCVe1u6DzbK60H6CQPybVMQU1LOjnRFqoqs2FYIjEHGFEKIe7iLigq844Y3qhOO+f2D7AMKg7RAROjvo@vger.kernel.org, AJvYcCXL5Vad+jaM5+JpJdyktxDLTP407ZCRYTTFzHClBXuoV1o7ZO7jWIFKHGjOoePnlroBkHGid59MonH6@vger.kernel.org X-Gm-Message-State: AOJu0YwMAEGm63sZ5cJCbm/q8Lj9ei2CqyyIMIZ26N7EP50yyCrBsRKc Z2iNTqRXiXLwbzAy9IAueIG97Wja8J50ifFk6gyLctA0B8GxuWjGiBEy X-Gm-Gg: ASbGncvAoAJqnHU/sS8wAcO8FZm/VvblyQbwK3+5VahrTnEVDJcJppl+eDi1j9V+0JI njCqtcgZR94MkNz+Ln59BezEGzaIX5B4n2llSMcE7bBAEXThPHxhJ3hwKrqansw9Uu3eQDTeCrk O8aRQzWAx3O5ydDjeXFk1BaG3lw3P0S2RkhXozjhpZzHMuxI8v2c6HHz863qHc0bj2mASt4ljx+ j1/NfdKBDJDIo1wLfHrOcBox451U4gvamWKyoy3ggq8CbjmC4RSfRj4ZZJBPPTERaQev7VnEmb3 nZ9A70befBent6ShgNGJF/cs4tzbzskPyZ2gSCytXYUbEkE2/kALTmZ6kig5Vl2Zpd5iOr1q2lQ w50zm9hIA2V4siOHcwDfzSHLBdBKRmgrncd9JsTK/dw== X-Google-Smtp-Source: AGHT+IFw68kXSseN36WGxcZYcEabAqwFl6+31ozVchgpDrBvfgCostRS1kFCQVrTxSJQFYDxRYh2aA== X-Received: by 2002:a05:600c:1f10:b0:442:e0f9:394d with SMTP id 5b1f17b1804b1-453560d2fe9mr9485545e9.24.1750165538145; Tue, 17 Jun 2025 06:05:38 -0700 (PDT) Received: from localhost.localdomain (93-34-88-225.ip49.fastwebnet.it. [93.34.88.225]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-4532e24b0c8sm173809435e9.24.2025.06.17.06.05.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Jun 2025 06:05:37 -0700 (PDT) From: Christian Marangi To: Michael Turquette , Stephen Boyd , 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 v2 10/10] clk: en7523: add support for Airoha AN7583 clock Date: Tue, 17 Jun 2025 15:04:53 +0200 Message-ID: <20250617130455.32682-11-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250617130455.32682-1-ansuelsmth@gmail.com> References: <20250617130455.32682-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 | 264 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 264 insertions(+) diff --git a/drivers/clk/clk-en7523.c b/drivers/clk/clk-en7523.c index 00c80221a274..b3c57aac8480 100644 --- a/drivers/clk/clk-en7523.c +++ b/drivers/clk/clk-en7523.c @@ -12,6 +12,7 @@ #include #include #include +#include =20 #define RST_NR_PER_BANK 32 =20 @@ -104,6 +105,14 @@ static const u32 bus7581_base[] =3D { 600000000, 54000= 0000 }; static const u32 npu7581_base[] =3D { 800000000, 750000000, 720000000, 600= 000000 }; static const u32 crypto_base[] =3D { 540000000, 480000000 }; static const u32 emmc7581_base[] =3D { 200000000, 150000000 }; +/* AN7583 */ +static const u32 gsw7583_base[] =3D { 540672000, 270336000, 400000000, 200= 000000 }; +static const u32 emi7583_base[] =3D { 540672000, 480000000, 400000000, 300= 000000 }; +static const u32 bus7583_base[] =3D { 600000000, 540672000, 480000000, 400= 000000 }; +static const u32 spi7583_base[] =3D { 100000000, 12500000 }; +static const u32 npu7583_base[] =3D { 666000000, 800000000, 720000000, 600= 000000 }; +static const u32 crypto7583_base[] =3D { 540672000, 400000000 }; +static const u32 emmc7583_base[] =3D { 150000000, 200000000 }; =20 static const struct en_clk_desc en7523_base_clks[] =3D { { @@ -306,6 +315,138 @@ static const struct en_clk_desc en7581_base_clks[] = =3D { } }; =20 +static const struct en_clk_desc an7583_base_clks[] =3D { + { + .id =3D EN7523_CLK_GSW, + .name =3D "gsw", + + .base_reg =3D REG_GSW_CLK_DIV_SEL, + .base_bits =3D 2, + .base_shift =3D 8, + .base_values =3D gsw7583_base, + .n_base_values =3D ARRAY_SIZE(gsw7583_base), + + .div_bits =3D 3, + .div_shift =3D 0, + .div_step =3D 1, + .div_offset =3D 1, + }, { + .id =3D EN7523_CLK_EMI, + .name =3D "emi", + + .base_reg =3D REG_EMI_CLK_DIV_SEL, + .base_bits =3D 2, + .base_shift =3D 8, + .base_values =3D emi7583_base, + .n_base_values =3D ARRAY_SIZE(emi7583_base), + + .div_bits =3D 3, + .div_shift =3D 0, + .div_step =3D 1, + .div_offset =3D 1, + }, { + .id =3D EN7523_CLK_BUS, + .name =3D "bus", + + .base_reg =3D REG_BUS_CLK_DIV_SEL, + .base_bits =3D 2, + .base_shift =3D 8, + .base_values =3D bus7583_base, + .n_base_values =3D ARRAY_SIZE(bus7583_base), + + .div_bits =3D 3, + .div_shift =3D 0, + .div_step =3D 1, + .div_offset =3D 1, + }, { + .id =3D EN7523_CLK_SLIC, + .name =3D "slic", + + .base_reg =3D REG_SPI_CLK_FREQ_SEL, + .base_bits =3D 1, + .base_shift =3D 0, + .base_values =3D slic_base, + .n_base_values =3D ARRAY_SIZE(slic_base), + + .div_reg =3D REG_SPI_CLK_DIV_SEL, + .div_bits =3D 5, + .div_shift =3D 24, + .div_val0 =3D 20, + .div_step =3D 2, + }, { + .id =3D EN7523_CLK_SPI, + .name =3D "spi", + + .base_reg =3D REG_SPI_CLK_FREQ_SEL, + .base_bits =3D 1, + .base_shift =3D 1, + .base_values =3D spi7583_base, + .n_base_values =3D ARRAY_SIZE(spi7583_base), + + .div_reg =3D REG_SPI_CLK_DIV_SEL, + .div_bits =3D 5, + .div_shift =3D 8, + .div_val0 =3D 40, + .div_step =3D 2, + }, { + .id =3D EN7523_CLK_NPU, + .name =3D "npu", + + .base_reg =3D REG_NPU_CLK_DIV_SEL, + .base_bits =3D 2, + .base_shift =3D 9, + .base_values =3D npu7583_base, + .n_base_values =3D ARRAY_SIZE(npu7583_base), + + .div_bits =3D 3, + .div_shift =3D 0, + .div_step =3D 1, + .div_offset =3D 1, + }, { + .id =3D EN7523_CLK_CRYPTO, + .name =3D "crypto", + + .base_reg =3D REG_CRYPTO_CLKSRC2, + .base_bits =3D 1, + .base_shift =3D 0, + .base_values =3D crypto7583_base, + .n_base_values =3D ARRAY_SIZE(crypto7583_base), + }, { + .id =3D EN7581_CLK_EMMC, + .name =3D "emmc", + + .base_reg =3D REG_CRYPTO_CLKSRC2, + .base_bits =3D 1, + .base_shift =3D 13, + .base_values =3D emmc7583_base, + .n_base_values =3D ARRAY_SIZE(emmc7583_base), + }, { + .id =3D AN7583_CLK_MDIO0, + .name =3D "mdio0", + + .base_reg =3D REG_CRYPTO_CLKSRC2, + + .base_value =3D 25000000, + + .div_bits =3D 4, + .div_shift =3D 15, + .div_step =3D 1, + .div_offset =3D 1, + }, { + .id =3D AN7583_CLK_MDIO1, + .name =3D "mdio1", + + .base_reg =3D REG_CRYPTO_CLKSRC2, + + .base_value =3D 25000000, + + .div_bits =3D 4, + .div_shift =3D 19, + .div_step =3D 1, + .div_offset =3D 1, + } +}; + static const u16 en7581_rst_ofs[] =3D { REG_RST_CTRL2, REG_RST_CTRL1, @@ -369,6 +510,59 @@ static const u16 en7581_rst_map[] =3D { [EN7581_XPON_MAC_RST] =3D RST_NR_PER_BANK + 31, }; =20 +static const u16 an7583_rst_map[] =3D { + /* RST_CTRL2 */ + [AN7583_XPON_PHY_RST] =3D 0, + [AN7583_GPON_OLT_RST] =3D 1, + [AN7583_CPU_TIMER2_RST] =3D 2, + [AN7583_HSUART_RST] =3D 3, + [AN7583_UART4_RST] =3D 4, + [AN7583_UART5_RST] =3D 5, + [AN7583_I2C2_RST] =3D 6, + [AN7583_XSI_MAC_RST] =3D 7, + [AN7583_XSI_PHY_RST] =3D 8, + [AN7583_NPU_RST] =3D 9, + [AN7583_TRNG_MSTART_RST] =3D 12, + [AN7583_DUAL_HSI0_RST] =3D 13, + [AN7583_DUAL_HSI1_RST] =3D 14, + [AN7583_DUAL_HSI0_MAC_RST] =3D 16, + [AN7583_DUAL_HSI1_MAC_RST] =3D 17, + [AN7583_WDMA_RST] =3D 19, + [AN7583_WOE0_RST] =3D 20, + [AN7583_HSDMA_RST] =3D 22, + [AN7583_TDMA_RST] =3D 24, + [AN7583_EMMC_RST] =3D 25, + [AN7583_SOE_RST] =3D 26, + [AN7583_XFP_MAC_RST] =3D 28, + [AN7583_MDIO0] =3D 30, + [AN7583_MDIO1] =3D 31, + /* RST_CTRL1 */ + [AN7583_PCM1_ZSI_ISI_RST] =3D RST_NR_PER_BANK + 0, + [AN7583_FE_PDMA_RST] =3D RST_NR_PER_BANK + 1, + [AN7583_FE_QDMA_RST] =3D RST_NR_PER_BANK + 2, + [AN7583_PCM_SPIWP_RST] =3D RST_NR_PER_BANK + 4, + [AN7583_CRYPTO_RST] =3D RST_NR_PER_BANK + 6, + [AN7583_TIMER_RST] =3D RST_NR_PER_BANK + 8, + [AN7583_PCM1_RST] =3D RST_NR_PER_BANK + 11, + [AN7583_UART_RST] =3D RST_NR_PER_BANK + 12, + [AN7583_GPIO_RST] =3D RST_NR_PER_BANK + 13, + [AN7583_GDMA_RST] =3D RST_NR_PER_BANK + 14, + [AN7583_I2C_MASTER_RST] =3D RST_NR_PER_BANK + 16, + [AN7583_PCM2_ZSI_ISI_RST] =3D RST_NR_PER_BANK + 17, + [AN7583_SFC_RST] =3D RST_NR_PER_BANK + 18, + [AN7583_UART2_RST] =3D RST_NR_PER_BANK + 19, + [AN7583_GDMP_RST] =3D RST_NR_PER_BANK + 20, + [AN7583_FE_RST] =3D RST_NR_PER_BANK + 21, + [AN7583_USB_HOST_P0_RST] =3D RST_NR_PER_BANK + 22, + [AN7583_GSW_RST] =3D RST_NR_PER_BANK + 23, + [AN7583_SFC2_PCM_RST] =3D RST_NR_PER_BANK + 25, + [AN7583_PCIE0_RST] =3D RST_NR_PER_BANK + 26, + [AN7583_PCIE1_RST] =3D RST_NR_PER_BANK + 27, + [AN7583_CPU_TIMER_RST] =3D RST_NR_PER_BANK + 28, + [AN7583_PCIE_HB_RST] =3D RST_NR_PER_BANK + 29, + [AN7583_XPON_MAC_RST] =3D RST_NR_PER_BANK + 31, +}; + static u32 en7523_get_base_rate(const struct en_clk_desc *desc, u32 val) { if (!desc->base_bits) @@ -881,6 +1075,62 @@ static int en7581_clk_hw_init(struct platform_device = *pdev, return en7581_reset_register(&pdev->dev, clk_map); } =20 +static int an7583_reset_register(struct device *dev, struct regmap *map) +{ + struct en_rst_data *rst_data; + + rst_data =3D devm_kzalloc(dev, sizeof(*rst_data), GFP_KERNEL); + if (!rst_data) + return -ENOMEM; + + rst_data->bank_ofs =3D en7581_rst_ofs; + rst_data->idx_map =3D an7583_rst_map; + rst_data->map =3D map; + + rst_data->rcdev.nr_resets =3D ARRAY_SIZE(an7583_rst_map); + rst_data->rcdev.of_xlate =3D en7523_reset_xlate; + rst_data->rcdev.ops =3D &en7581_reset_ops; + rst_data->rcdev.of_node =3D dev->of_node; + rst_data->rcdev.of_reset_n_cells =3D 1; + rst_data->rcdev.owner =3D THIS_MODULE; + rst_data->rcdev.dev =3D dev; + + return devm_reset_controller_register(dev, &rst_data->rcdev); +} + +static int an7583_clk_hw_init(struct platform_device *pdev, + const struct en_clk_soc_data *soc_data, + struct clk_hw_onecell_data *clk_data) +{ + struct device *dev =3D &pdev->dev; + struct regmap *map, *clk_map; + void __iomem *base; + int err; + + map =3D syscon_regmap_lookup_by_phandle(dev->of_node, "airoha,chip-scu"); + if (IS_ERR(map)) + return PTR_ERR(map); + + base =3D devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(base)) + return PTR_ERR(base); + + clk_map =3D devm_regmap_init_mmio(&pdev->dev, base, &en7523_clk_regmap_co= nfig); + if (IS_ERR(clk_map)) + return PTR_ERR(clk_map); + + err =3D en75xx_register_clocks(dev, soc_data, clk_data, map, clk_map); + if (err) + return err; + + regmap_clear_bits(clk_map, REG_NP_SCU_SSTR, + REG_PCIE_XSI0_SEL_MASK | REG_PCIE_XSI1_SEL_MASK); + regmap_update_bits(clk_map, REG_NP_SCU_PCIC, REG_PCIE_CTRL, + FIELD_PREP(REG_PCIE_CTRL, 3)); + + return an7583_reset_register(dev, clk_map); +} + static int en7523_clk_probe(struct platform_device *pdev) { const struct en_clk_soc_data *soc_data; @@ -940,9 +1190,23 @@ static const struct en_clk_soc_data en7581_data =3D { .hw_init =3D en7581_clk_hw_init, }; =20 +static const struct en_clk_soc_data an7583_data =3D { + .probe_child =3D true, + .base_clks =3D an7583_base_clks, + /* We increment num_clocks by 1 to account for additional PCIe clock */ + .num_clocks =3D ARRAY_SIZE(an7583_base_clks) + 1, + .pcie_ops =3D { + .is_enabled =3D en7581_pci_is_enabled, + .enable =3D en7581_pci_enable, + .disable =3D en7581_pci_disable, + }, + .hw_init =3D an7583_clk_hw_init, +}; + static const struct of_device_id of_match_clk_en7523[] =3D { { .compatible =3D "airoha,en7523-scu", .data =3D &en7523_data }, { .compatible =3D "airoha,en7581-scu", .data =3D &en7581_data }, + { .compatible =3D "airoha,an7583-scu", .data =3D &an7583_data }, { /* sentinel */ } }; =20 --=20 2.48.1