From nobody Sat Nov 30 10:33:30 2024 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (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 EA28016BE23; Tue, 10 Sep 2024 04:40:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725943230; cv=none; b=rtlMkacqEJFLKUgrwwLYelEMe92rhi41XvgizwoensBcoUHHxUwVmBibifqf/CseboxsWIahyrKShWXZ/8GGuy7Fn7e0oOG/0X0swJSwLK49QMRJK2kHtBXgT/JVKa876UbEK0ATr/9rHBxFj46B4yoGlzTmTlaVzlxNe6C64Ro= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725943230; c=relaxed/simple; bh=03NJV2IjFFRVtnOUi61Rts7+B2w0enc00fFfqAjqIfE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tuwvj19FKxZE+MlHi7ldPQd2uO4+ZWa4WjfcB5ZNZWrfCN8uLrvB1LTzGfQA8d14zs5BjCXgN4jbQ0ubPxeOULJTB334MPt0Zf7L5SGTjMeji4m1QzateuZmNTm3iQNXWEPePBNK/mgC1gdeCVFnhj4K0ruJYkx0+kLAgOgADw4= 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=Q2DVRiGw; arc=none smtp.client-ip=209.85.128.53 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="Q2DVRiGw" Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-42cb2191107so16946625e9.1; Mon, 09 Sep 2024 21:40:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725943227; x=1726548027; 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=4tRmeZ7ssDDYlSOX1HCpNp+tOOHoJskFLu0y5AxWZio=; b=Q2DVRiGwgnkGW5KOjsc70cEYNyLATfnPIp3iKba0Epqm4qbe3MMOZXEL0sDUrqDig7 cRTeTSvZaXA/WLcye3RvUcT3HiT8Ewl4tsVaUyGOnISXLj4kw5Xef0Zs7HXexDwHt+gj NL7yHmECOW6wv641kfXtREAAWPbcsjKBM0jr6qYTeYNrri/qklSGgSF4jQUBx6QvQLka H3NedDXJsDEC7dQjvTklesShyAKn3OT9BmDezS2F49RS4DLgIteNZWDdx57mCkEUbkC8 x1PfAn525BAg4Wl1ZU+fDNq3+62qhe0YgfiN5KcjKisgcdeSgH7i48Z9jOw31uUFAR6v IsgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725943227; x=1726548027; 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=4tRmeZ7ssDDYlSOX1HCpNp+tOOHoJskFLu0y5AxWZio=; b=ld4yC5/CYikSGq2MwEZ4aJCFBp6XdnbnhwV1QI32l/NVCW0c6ozHElzIun2BhBBnsv ejdNcw4MAohXCeUaXNHv5KG/jqOU0wbRi2VHrdepDU32pxUvW+ID+/5ixCECTIhKCdKh 2MeMDRTErIhw0mQWBQ96F5GT0AU7vEshrS4smNM+w3B3T6cJEH8IIa7rieq6WBY3d9u8 gWDkH8owyFnTkhjEGy/oYaHCCotVv6sNmT7A86UUusb2/VBh8todRjOs3jI6E3epUo62 LI3ssO9VWGV8gxs0K9WUTcOB8HsrTbn/tEVNrKiI7clKvD9hTmG11G5vKxwCPl9uf2PI IAmw== X-Forwarded-Encrypted: i=1; AJvYcCWToZzauhRpCOGs8XrOI5e4mvTKJFCdKi88+uJd5GRF5Xbwy4K2M3RqEpSlyILhWUr6GohqcFf4bAFcEBY=@vger.kernel.org X-Gm-Message-State: AOJu0Yx6v5fU35L0+OCmJcha2yvo2kXWNVFJkznlmM18fu686gx6SDi3 UmIRtIv6jIxwbuqAM/pbOg8vvyeJdVbQjlwXnq1lpTPPXeOGC6JqBuETuQ== X-Google-Smtp-Source: AGHT+IFL2GmeTsj+/nDdBemioOcPl2tlnn1ZJlaH+DfX1s3gCut+oBqayM+UQpJPrikDRrpSD4PIbw== X-Received: by 2002:a05:600c:1c86:b0:428:150e:4f13 with SMTP id 5b1f17b1804b1-42cadb6a2d2mr70793595e9.33.1725943226864; Mon, 09 Sep 2024 21:40:26 -0700 (PDT) Received: from localhost.localdomain (201.red-88-10-59.dynamicip.rima-tde.net. [88.10.59.201]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42cc01cae3asm5516055e9.0.2024.09.09.21.40.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 21:40:26 -0700 (PDT) From: Sergio Paracuellos To: linux-clk@vger.kernel.org Cc: sboyd@kernel.org, mturquette@baylibre.com, tsbogend@alpha.franken.de, yangshiji66@outlook.com, linux-kernel@vger.kernel.org Subject: [PATCH 1/3] clk: ralink: mtmips: fix clock plan for Ralink SoC RT3883 Date: Tue, 10 Sep 2024 06:40:22 +0200 Message-Id: <20240910044024.120009-2-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240910044024.120009-1-sergio.paracuellos@gmail.com> References: <20240910044024.120009-1-sergio.paracuellos@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" Clock plan for Ralink SoC RT3883 needs an extra 'periph' clock to properly set some peripherals that has this clock as their parent. When this driver was mainlined we could not find any active users of this SoC so we cannot perform any real tests for it. Now, one user of a Belkin f9k1109 version 1 device which uses this SoC appear and reported some issues in openWRT: - https://github.com/openwrt/openwrt/issues/16054 The peripherals that are wrong are 'uart', 'i2c', 'i2s' and 'uartlite' which has a not defined 'periph' clock as parent. Hence, introduce it to have a properly working clock plan for this SoC. Fixes: 6f3b15586eef ("clk: ralink: add clock and reset driver for MTMIPS So= Cs") Signed-off-by: Sergio Paracuellos --- drivers/clk/ralink/clk-mtmips.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/clk/ralink/clk-mtmips.c b/drivers/clk/ralink/clk-mtmip= s.c index 50a443bf79ec..62f9801ecd3a 100644 --- a/drivers/clk/ralink/clk-mtmips.c +++ b/drivers/clk/ralink/clk-mtmips.c @@ -267,6 +267,11 @@ static struct mtmips_clk_fixed rt305x_fixed_clocks[] = =3D { CLK_FIXED("xtal", NULL, 40000000) }; =20 +static struct mtmips_clk_fixed rt3883_fixed_clocks[] =3D { + CLK_FIXED("xtal", NULL, 40000000), + CLK_FIXED("periph", "xtal", 40000000) +}; + static struct mtmips_clk_fixed rt3352_fixed_clocks[] =3D { CLK_FIXED("periph", "xtal", 40000000) }; @@ -779,8 +784,8 @@ static const struct mtmips_clk_data rt3352_clk_data =3D= { static const struct mtmips_clk_data rt3883_clk_data =3D { .clk_base =3D rt3883_clks_base, .num_clk_base =3D ARRAY_SIZE(rt3883_clks_base), - .clk_fixed =3D rt305x_fixed_clocks, - .num_clk_fixed =3D ARRAY_SIZE(rt305x_fixed_clocks), + .clk_fixed =3D rt3883_fixed_clocks, + .num_clk_fixed =3D ARRAY_SIZE(rt3883_fixed_clocks), .clk_factor =3D NULL, .num_clk_factor =3D 0, .clk_periph =3D rt5350_pherip_clks, --=20 2.25.1 From nobody Sat Nov 30 10:33:30 2024 Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) (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 A20051791ED; Tue, 10 Sep 2024 04:40:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725943233; cv=none; b=GS+L4JiD/ztVuP7e00b0zO4MUVxXVqmdV4bSDV3ZL+nLHjZdWsFVL2zmnJQ0sOoHFuSB+a3KPmzDAm1dapO45Ba6xIEwpyIhNY/pmAhr93EEJyqfKKH3oqseLrGK4X5FEe32Dd3tm5Isb6nsw38fpS9SvrIFUCxHlDnax+Qi5Mo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725943233; c=relaxed/simple; bh=uFcq3JpVglbm/vn58dOu9mXfKwR+0Mlgd0MqGKM8DWw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=oxNKVn914/fEbcF96+zIla0dKMZQNJGFDbjDZAB3XE8aNBpH+qdu+giReuOOLH87IkUy3LEF/aOtV7Sp+UdVTM6EAkvgwSvUoXyBedZUZBlQdUO+Nt8cyYZDHF1DFqkdWfxpVnbPjNN86jFCnEiYrRke05uNKoIBGEh1oQOMLQw= 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=LJYbfpui; arc=none smtp.client-ip=209.85.128.47 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="LJYbfpui" Received: by mail-wm1-f47.google.com with SMTP id 5b1f17b1804b1-42cae6bb895so26879465e9.1; Mon, 09 Sep 2024 21:40:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725943228; x=1726548028; 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=Mf8AEG2Lor2UnvVeXxILUX9a2RTDHKINg+SUWYbAxo0=; b=LJYbfpui/tYvvTeyT5206NyCzovgac33PuzSjIeFpfDo1l+dcbFxrn8t8vrv6EA6uP ZtPJE343J4HI19TofuTE8AF5+ieYxIOpfA3+gYLQmQMcyTeSHeo3vn14s8lWB9meS+MH Pan9w0tezFPYj/lY8rZ9eaza60ikcIdZlY8Yc1oJo+jawXrbR7mY6mPUe5kOybOMhWvO aJf0Ju63txtPxDahfWjGr7RJmy8a2HUDxQwkM8CQ5iRIEz6CLOQBVeCdx3OuisMjykKc lCL+dY2zR85e6LNyMdxIoAxTwCCZKXZi/VUd0wRLJlQ0yeNt6Fu8XYQc4pIRq/18qkiF YVvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725943228; x=1726548028; 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=Mf8AEG2Lor2UnvVeXxILUX9a2RTDHKINg+SUWYbAxo0=; b=k1ZUtAZk5GvR+1CSD+BmN01vn61taHhteiBkRittW4jlnoM8KHEqKDlpOk28QHlUQv ujeAv+8x9SS7OdokIukSBFsXp/yNQz5lALmHYp44el48WwwPK2PyPHqLIVOvOJMe3vZN 6y/Hi52o6NssKRi1W97N2/tQlGGDbaSSb6424AplF5y6swXUTpjwJU/GDOoGdJCVhLf5 9tazRdq97S/N5QI4499mOoiWQRqyFp+HJqsRhiXUM5bNb5S21sYJNWJAg4qnchZLA6QY wB9d9rOEwJfCeHWeMifga0wsORHctsP6PHdXzUlDsloPV6IxpqD+R3iJMOoJc2dQmmKd 9omQ== X-Forwarded-Encrypted: i=1; AJvYcCXNN7YVYYeDt+AFhG0vTh7MwnhW+ei8NR+tJAdP8JNB6TBz5woFNLaQv/7tOAL9RgEdj9VhzazLgGyzyO8=@vger.kernel.org X-Gm-Message-State: AOJu0Yy3bPR2OLwCJ7spYhxEs4ynLMKin7rkbEG8kQkpt0YSitst0sE8 B73t5q5J7B/x3jcbrwwcgNgw6rBFXC7XNkC+ZO99B0gSILzokEJdlMPrhQ== X-Google-Smtp-Source: AGHT+IH60/1Q7HkwUlh+ivF2isDLAPFAc1kXwlT4gCJ2F3H4hy6/EmXYH8GGHysb2uGB/lBDOsu+UA== X-Received: by 2002:a05:600c:3ac6:b0:42c:c28c:e477 with SMTP id 5b1f17b1804b1-42cc28ce642mr807915e9.23.1725943227987; Mon, 09 Sep 2024 21:40:27 -0700 (PDT) Received: from localhost.localdomain (201.red-88-10-59.dynamicip.rima-tde.net. [88.10.59.201]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42cc01cae3asm5516055e9.0.2024.09.09.21.40.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 21:40:27 -0700 (PDT) From: Sergio Paracuellos To: linux-clk@vger.kernel.org Cc: sboyd@kernel.org, mturquette@baylibre.com, tsbogend@alpha.franken.de, yangshiji66@outlook.com, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] clk: ralink: mtmips: fix clocks probe order in oldest ralink SoCs Date: Tue, 10 Sep 2024 06:40:23 +0200 Message-Id: <20240910044024.120009-3-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240910044024.120009-1-sergio.paracuellos@gmail.com> References: <20240910044024.120009-1-sergio.paracuellos@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" Base clocks are the first in being probed and are real dependencies of the rest of fixed, factor and peripheral clocks. For old ralink SoCs RT2880, RT305x and RT3883 'xtal' must be defined first since in any other case, when fixed clocks are probed they are delayed until 'xtal' is probed so the following warning appears: WARNING: CPU: 0 PID: 0 at drivers/clk/ralink/clk-mtmips.c:499 rt3883_bus_r= ecalc_rate+0x98/0x138 Modules linked in: CPU: 0 PID: 0 Comm: swapper Not tainted 6.6.43 #0 Stack : 805e58d0 00000000 00000004 8004f950 00000000 00000004 00000000 000= 00000 80669c54 80830000 80700000 805ae570 80670068 00000001 80669bf8 00000000 00000000 00000000 805ae570 80669b38 00000020 804db7dc 00000000 00000000 203a6d6d 80669b78 80669e48 70617773 00000000 805ae570 00000000 00000009 00000000 00000001 00000004 00000001 00000000 00000000 83fe43b0 00000000 ... Call Trace: [<800065d0>] show_stack+0x64/0xf4 [<804bca14>] dump_stack_lvl+0x38/0x60 [<800218ac>] __warn+0x94/0xe4 [<8002195c>] warn_slowpath_fmt+0x60/0x94 [<80259ff8>] rt3883_bus_recalc_rate+0x98/0x138 [<80254530>] __clk_register+0x568/0x688 [<80254838>] of_clk_hw_register+0x18/0x2c [<8070b910>] rt2880_clk_of_clk_init_driver+0x18c/0x594 [<8070b628>] of_clk_init+0x1c0/0x23c [<806fc448>] plat_time_init+0x58/0x18c [<806fdaf0>] time_init+0x10/0x6c [<806f9bc4>] start_kernel+0x458/0x67c ---[ end trace 0000000000000000 ]--- When this driver was mainlined we could not find any active users of old ralink SoCs so we cannot perform any real tests for them. Now, one user of a Belkin f9k1109 version 1 device which uses RT3883 SoC appeared and reported some issues in openWRT: - https://github.com/openwrt/openwrt/issues/16054 Thus, define a 'rt2880_xtal_recalc_rate()' just returning the expected frequency 40Mhz and use it along the old ralink SoCs to have a correct boot trace with no warnings and a working clock plan from the beggining. Fixes: 6f3b15586eef ("clk: ralink: add clock and reset driver for MTMIPS So= Cs") Signed-off-by: Sergio Paracuellos --- drivers/clk/ralink/clk-mtmips.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/drivers/clk/ralink/clk-mtmips.c b/drivers/clk/ralink/clk-mtmip= s.c index 62f9801ecd3a..76285fbbdeaa 100644 --- a/drivers/clk/ralink/clk-mtmips.c +++ b/drivers/clk/ralink/clk-mtmips.c @@ -263,10 +263,6 @@ static int mtmips_register_pherip_clocks(struct device= _node *np, .rate =3D _rate \ } =20 -static struct mtmips_clk_fixed rt305x_fixed_clocks[] =3D { - CLK_FIXED("xtal", NULL, 40000000) -}; - static struct mtmips_clk_fixed rt3883_fixed_clocks[] =3D { CLK_FIXED("xtal", NULL, 40000000), CLK_FIXED("periph", "xtal", 40000000) @@ -371,6 +367,12 @@ static inline struct mtmips_clk *to_mtmips_clk(struct = clk_hw *hw) return container_of(hw, struct mtmips_clk, hw); } =20 +static unsigned long rt2880_xtal_recalc_rate(struct clk_hw *hw, + unsigned long parent_rate) +{ + return 40000000; +} + static unsigned long rt5350_xtal_recalc_rate(struct clk_hw *hw, unsigned long parent_rate) { @@ -682,10 +684,12 @@ static unsigned long mt76x8_cpu_recalc_rate(struct cl= k_hw *hw, } =20 static struct mtmips_clk rt2880_clks_base[] =3D { + { CLK_BASE("xtal", NULL, rt2880_xtal_recalc_rate) }, { CLK_BASE("cpu", "xtal", rt2880_cpu_recalc_rate) } }; =20 static struct mtmips_clk rt305x_clks_base[] =3D { + { CLK_BASE("xtal", NULL, rt2880_xtal_recalc_rate) }, { CLK_BASE("cpu", "xtal", rt305x_cpu_recalc_rate) } }; =20 @@ -695,6 +699,7 @@ static struct mtmips_clk rt3352_clks_base[] =3D { }; =20 static struct mtmips_clk rt3883_clks_base[] =3D { + { CLK_BASE("xtal", NULL, rt2880_xtal_recalc_rate) }, { CLK_BASE("cpu", "xtal", rt3883_cpu_recalc_rate) }, { CLK_BASE("bus", "cpu", rt3883_bus_recalc_rate) } }; @@ -751,8 +756,8 @@ static int mtmips_register_clocks(struct device_node *n= p, static const struct mtmips_clk_data rt2880_clk_data =3D { .clk_base =3D rt2880_clks_base, .num_clk_base =3D ARRAY_SIZE(rt2880_clks_base), - .clk_fixed =3D rt305x_fixed_clocks, - .num_clk_fixed =3D ARRAY_SIZE(rt305x_fixed_clocks), + .clk_fixed =3D NULL, + .num_clk_fixed =3D 0, .clk_factor =3D rt2880_factor_clocks, .num_clk_factor =3D ARRAY_SIZE(rt2880_factor_clocks), .clk_periph =3D rt2880_pherip_clks, @@ -762,8 +767,8 @@ static const struct mtmips_clk_data rt2880_clk_data =3D= { static const struct mtmips_clk_data rt305x_clk_data =3D { .clk_base =3D rt305x_clks_base, .num_clk_base =3D ARRAY_SIZE(rt305x_clks_base), - .clk_fixed =3D rt305x_fixed_clocks, - .num_clk_fixed =3D ARRAY_SIZE(rt305x_fixed_clocks), + .clk_fixed =3D NULL, + .num_clk_fixed =3D 0, .clk_factor =3D rt305x_factor_clocks, .num_clk_factor =3D ARRAY_SIZE(rt305x_factor_clocks), .clk_periph =3D rt305x_pherip_clks, --=20 2.25.1 From nobody Sat Nov 30 10:33:30 2024 Received: from mail-wm1-f49.google.com (mail-wm1-f49.google.com [209.85.128.49]) (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 D264B17ADF1; Tue, 10 Sep 2024 04:40:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.49 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725943233; cv=none; b=E9+3Av9YbgArXN3MkfnNDahLddctLrTigxA6TRwrXE/v8RM8yAOV/AD4L16ApyXNQsELiEdMSlQyezRhU40F16ZjMcR18qbSMJVzsdPrnPYJuncLpIbTKFK4I6NE8/bIHm5TKMdLc5iOzFueO3bLVdNNQRj/hcD1lGPd3/z34PY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725943233; c=relaxed/simple; bh=koJBg8yzwhtGzGx9x9JJA/nipZE2WzOP8mnJFes4NBs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MNQSR+xz2f4RlUTysAm2d6qOou56+jafdIwzexoG7L/7WN14RSJURS0I5FM/QFVUgS8zj7nW0Jb8rybwJRN7a5MMFexE5HuPIERpctM4LNmWmc0ubXThJnefWJF3aNJLrwdkhHmWofDow0ZaTGKof0hxcA+Yt+D/Ebt937BT78A= 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=mAoHkugf; arc=none smtp.client-ip=209.85.128.49 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="mAoHkugf" Received: by mail-wm1-f49.google.com with SMTP id 5b1f17b1804b1-42cba0dc922so10807875e9.3; Mon, 09 Sep 2024 21:40:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725943229; x=1726548029; 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=7579wdpHag2FewCMXqF+ybgeA198ZT0CN/Gcy3G4QeE=; b=mAoHkugfxl0X3O0lHBT5HIa4HCCY2C64RJ82Oh3kIOPUBDxKQB++F3gyHDi2hc/+yP Ta8J+dW8zReLA/RK37UuZUqZ1IoCLn2Wct/rZyVwZ4AFurvZNbXezzvv6xXzAeDah7u5 MdoSnuxF3S425O2rrsS80F3Jb3DVub825Zo76TRi6T0NniuUanQ+X48rkmyb8lEeUOgw eNR7RqSv5076fNM9NKNGfndVENEeZFt60F07abs+Sl1SKunuCGAGNJ0plXvptRGQwxRd 1ZhdLtQlmtHny2KzTQZXQGaOgMY49fzz9J34a6fF+te3Sjm/QcRVmiyxQ7N6FltViTVS XDqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725943229; x=1726548029; 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=7579wdpHag2FewCMXqF+ybgeA198ZT0CN/Gcy3G4QeE=; b=Tr8JEnBChZQlnXZH0hIYtzEwQjfOXWxtxvDl1VtmBgmy9DmCGrBEB/oawdV++GsP+D ow8L3aW4WC8se2OvUe60GBqyGjFLK+FvB8nX751wMB3UOhmZA50EJflZnqFu3rZskCOZ sj3U29s/JHG1UsMx3uxomEqlvIxcW2TzHjnHfA0v7bL6nXrTqdSZzRRrTOGCJcg4yCzv F6YGd1jCcMdBGyMvOR2iWtlNsxedaUljsoV3h+DXDJiDWuzqkaVwH4/f33Axd1IrPllO Seww+nNxRK/8iNBRaX1p7nXUhCbkaPI9VEln4mmMa01gPR5KCIE+tRqpBomAEh6sBlqK rk7A== X-Forwarded-Encrypted: i=1; AJvYcCWiyIkCCb9qS9JUid1qT4SjmhwpFt9py08JxdHTl6R399ZLplpHCCSg0GbsCC1WNo8YFO6LBXGol5gi2/o=@vger.kernel.org X-Gm-Message-State: AOJu0Yx+8v9C2fnU94Nhjpv1ygDmFU6KvI4EqejM4acQjdxKnbjKFvhQ CHRpI4+b8QqB5rf4gfgVdYRo/AEliumz4j1AgSNmK9l4/30QK3dKzvWhPw== X-Google-Smtp-Source: AGHT+IHK8xVxjDQwjj3c2e+y3trQYkf/C6Ra0KJNdd53Eniy+vtfLtzIXpLrCh2LZffNsljAIXWLwA== X-Received: by 2002:a05:600c:354a:b0:428:1e8c:ff75 with SMTP id 5b1f17b1804b1-42cadb6a47cmr61619375e9.35.1725943229024; Mon, 09 Sep 2024 21:40:29 -0700 (PDT) Received: from localhost.localdomain (201.red-88-10-59.dynamicip.rima-tde.net. [88.10.59.201]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-42cc01cae3asm5516055e9.0.2024.09.09.21.40.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 21:40:28 -0700 (PDT) From: Sergio Paracuellos To: linux-clk@vger.kernel.org Cc: sboyd@kernel.org, mturquette@baylibre.com, tsbogend@alpha.franken.de, yangshiji66@outlook.com, linux-kernel@vger.kernel.org Subject: [PATCH 3/3] clk: ralink: mtmips: add mmc related clocks for SoCs MT7620, MT7628 and MT7688 Date: Tue, 10 Sep 2024 06:40:24 +0200 Message-Id: <20240910044024.120009-4-sergio.paracuellos@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240910044024.120009-1-sergio.paracuellos@gmail.com> References: <20240910044024.120009-1-sergio.paracuellos@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" Original architecture clock code from where this driver was derived did not include nothing related to mmc clocks. OpenWRT people started to use mtk-sd upstream driver recently and they were forced to use a dts 'fixed-clock' node with 48 MHz clock: - https://github.com/openwrt/openwrt/pull/15896 The proper thing to do to avoid that is to add the mmc related clocks to the driver to avoid a dts with fixed clocks nodes. The minimal documentation in the mt7620 programming guide says that there is a BBP_PLL clock of 480 MHz derived from the 40 MHz XTAL and from there a clock divider by ten produces the desired SDHC clock of 48 MHz for the mmc. Hence add a fixed clock 'bbpp= ll' and factor clock 'sdhc' ten divider child to properly set the 'mmc' periphe= ral clock with the desired 48 Mhz rate. Signed-off-by: Sergio Paracuellos --- drivers/clk/ralink/clk-mtmips.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/drivers/clk/ralink/clk-mtmips.c b/drivers/clk/ralink/clk-mtmip= s.c index 76285fbbdeaa..97b8ca0f9181 100644 --- a/drivers/clk/ralink/clk-mtmips.c +++ b/drivers/clk/ralink/clk-mtmips.c @@ -207,6 +207,7 @@ static struct mtmips_clk mt7620_pherip_clks[] =3D { { CLK_PERIPH("10000b00.spi", "bus") }, { CLK_PERIPH("10000b40.spi", "bus") }, { CLK_PERIPH("10000c00.uartlite", "periph") }, + { CLK_PERIPH("10130000.mmc", "sdhc") }, { CLK_PERIPH("10180000.wmac", "xtal") } }; =20 @@ -220,6 +221,7 @@ static struct mtmips_clk mt76x8_pherip_clks[] =3D { { CLK_PERIPH("10000c00.uart0", "periph") }, { CLK_PERIPH("10000d00.uart1", "periph") }, { CLK_PERIPH("10000e00.uart2", "periph") }, + { CLK_PERIPH("10130000.mmc", "sdhc") }, { CLK_PERIPH("10300000.wmac", "xtal") } }; =20 @@ -272,8 +274,13 @@ static struct mtmips_clk_fixed rt3352_fixed_clocks[] = =3D { CLK_FIXED("periph", "xtal", 40000000) }; =20 +static struct mtmips_clk_fixed mt7620_fixed_clocks[] =3D { + CLK_FIXED("bbppll", "xtal", 480000000) +}; + static struct mtmips_clk_fixed mt76x8_fixed_clocks[] =3D { - CLK_FIXED("pcmi2s", "xtal", 480000000), + CLK_FIXED("bbppll", "xtal", 480000000), + CLK_FIXED("pcmi2s", "bbppll", 480000000), CLK_FIXED("periph", "xtal", 40000000) }; =20 @@ -328,6 +335,15 @@ static struct mtmips_clk_factor rt305x_factor_clocks[]= =3D { CLK_FACTOR("bus", "cpu", 1, 3) }; =20 +static struct mtmips_clk_factor mt7620_factor_clocks[] =3D { + CLK_FACTOR("sdhc", "bbppll", 1, 10) +}; + +static struct mtmips_clk_factor mt76x8_factor_clocks[] =3D { + CLK_FACTOR("bus", "cpu", 1, 3), + CLK_FACTOR("sdhc", "bbppll", 1, 10) +}; + static int mtmips_register_factor_clocks(struct clk_hw_onecell_data *clk_d= ata, struct mtmips_clk_priv *priv) { @@ -811,10 +827,10 @@ static const struct mtmips_clk_data rt5350_clk_data = =3D { static const struct mtmips_clk_data mt7620_clk_data =3D { .clk_base =3D mt7620_clks_base, .num_clk_base =3D ARRAY_SIZE(mt7620_clks_base), - .clk_fixed =3D NULL, - .num_clk_fixed =3D 0, - .clk_factor =3D NULL, - .num_clk_factor =3D 0, + .clk_fixed =3D mt7620_fixed_clocks, + .num_clk_fixed =3D ARRAY_SIZE(mt7620_fixed_clocks), + .clk_factor =3D mt7620_factor_clocks, + .num_clk_factor =3D ARRAY_SIZE(mt7620_factor_clocks), .clk_periph =3D mt7620_pherip_clks, .num_clk_periph =3D ARRAY_SIZE(mt7620_pherip_clks), }; @@ -824,8 +840,8 @@ static const struct mtmips_clk_data mt76x8_clk_data =3D= { .num_clk_base =3D ARRAY_SIZE(mt76x8_clks_base), .clk_fixed =3D mt76x8_fixed_clocks, .num_clk_fixed =3D ARRAY_SIZE(mt76x8_fixed_clocks), - .clk_factor =3D rt305x_factor_clocks, - .num_clk_factor =3D ARRAY_SIZE(rt305x_factor_clocks), + .clk_factor =3D mt76x8_factor_clocks, + .num_clk_factor =3D ARRAY_SIZE(mt76x8_factor_clocks), .clk_periph =3D mt76x8_pherip_clks, .num_clk_periph =3D ARRAY_SIZE(mt76x8_pherip_clks), }; --=20 2.25.1