Received: by 2002:ab2:1347:0:b0:1f4:ac9d:b246 with SMTP id g7csp223673lqg; Thu, 11 Apr 2024 00:08:41 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXFGUzNzQLqNjEX0azyJ1ukbB10I5pvIauQRE0KW+bdCE90lxTrKKHflMs7zn1l7QLM6PzrP8CJKxrcsBe5ulNefVgQ1eiA7I5PGhC2zA== X-Google-Smtp-Source: AGHT+IHG8PbbVcrr3C7vYO8/RtWdcQLcBCLUGkp9mT6utgkLgAq/zTh8hJvwSksVCZfv0AkU9Bnc X-Received: by 2002:a81:4ec7:0:b0:618:c41:288 with SMTP id c190-20020a814ec7000000b006180c410288mr4913232ywb.7.1712819321529; Thu, 11 Apr 2024 00:08:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712819321; cv=pass; d=google.com; s=arc-20160816; b=i591WR8TY4Lrd+F3pN2wfQadFidfKQUMZDPDMbSsSRiBgXDY85JQbBEN+Dt+iTc7ne /EJgxjco6JzblOh61jxcGq8pi5OBvFYsj7oTCkbJGHL8VZk/eDMNcpAOefxlvQt7C6YW Y/q42LEAjjUnu8i0LcmkQdDOiIwPAnJ2M+xLry1RGw6QB7jxzdyKXEDgiT/vPcmdlY94 qlhoVF39NnaOYwq9M7yP4Qn00yzx6b0WZ611Xu9ZK2EPEFCOgW8eFuhaxz6lEdmGpltp dBfTj6qg9sR8ynGcpYywWBu327KoIr6+5rNRla2awcFAg+QT85LLORVAz+giEH+3F+2E jvcw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=WBwFTB23QYK27eowOhLn23rF4sWQalYXU3BNGKcydTk=; fh=Tj9tscWC0T+YKWdU/CK+aC1UJCrDBKzNjA9PkoA5STI=; b=RaOJE9q04fHllmQYVNd0JIp87ezOk+U4hpnLuz/obKBwRo9YG4LBnfyXkir8CMRBsj YOUhwmrGcj/XrvcxRA0APGGZsJlOQmVuYmYSUYYfn3m20HTLC6fAWDD+SNN2xvIKXOMa BM008wBtBg5/sir/O9kEnH85Q6Zhk4IpeJqelcGQ63Fugv3kZN1Dw9RUSBAXjdKfW28T k1kmf3EVswypioI4QuvRgfDqTY4xIz7zAFXRxBqU2HXQ78uf0xdV7deuPxfluyPiSIme SQEzgIkLeJmitUeOZtgAb8sP6Au+Nf1NvKF/Zm41TbtafDhLKaV95mpJMfp0oj1agmQz f+Fw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bUDliCPD; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-139925-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139925-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id w17-20020a05622a191100b00432c448dd2fsi945666qtc.324.2024.04.11.00.08.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 00:08:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-139925-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=bUDliCPD; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-139925-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-139925-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 2D5381C21BC4 for ; Thu, 11 Apr 2024 07:08:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A525E140364; Thu, 11 Apr 2024 07:06:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="bUDliCPD" Received: from mail-oa1-f43.google.com (mail-oa1-f43.google.com [209.85.160.43]) (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 4ADB213FD8F; Thu, 11 Apr 2024 07:06:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.43 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712819214; cv=none; b=nWBA1XQT78gNVNyV2w4kQ7XsVX5z+CEE+d5bdwf4g2bdIWJ6uMzUQ2/DTh/FMSRKbYNqei1La5Qmg7lVOtoSpDTakfVqPeK3uUxTFB9moPOfTsL7/aN8bxm6EhLWUFwMRlvsVDb2rk0iURVEACKvhm8WUZ+QiYvt3/wIcLqBM3o= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712819214; c=relaxed/simple; bh=JSqvGeRsBb75ZTjqhVvWEcNKN1Q/ASsQY9j3OSmgGIA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AzbUKruEfsF3HOlMG50HkeFPq1oGO4Jpa/gscujxR5+EXMhK8dgIl2fv9WhfYaFOBi073bBZkWaxfsuxvzrtXX7P4tOyRIf3N5O3pJ+bQurhnE35hlr4cefBhYcFlh9xbTQa7Tt/1OeUk2UB7xi9nW2k79T9qlcMXu9qI2Qb4LA= 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=bUDliCPD; arc=none smtp.client-ip=209.85.160.43 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 Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-22ed075a629so3238334fac.3; Thu, 11 Apr 2024 00:06:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712819211; x=1713424011; 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=WBwFTB23QYK27eowOhLn23rF4sWQalYXU3BNGKcydTk=; b=bUDliCPDv+mDsMedtm3YjWJdiRwn6N1zyOmnU7rTWUWCLYz1LhQ6PNIhnJijKAL+Nl ApZe9q5A1uq1F4FlEpAHosIy62p88upQYUzJ33pg5xqpq2rFHjFMyoQFgLoyghzddTiI F4XBJe4yy4zXCu6mvrr4bEa5axBtJSd/yr61Ye5fmPmwC+PJ1kG/guursAiHf3LQeZqP o9MNjHWUzpfzRNbu25ztpiktRxn7Ql9/4KnkjkyiO/ji7bxuKmr8gkrFMY3+7kl60xMC +PQWnxA4EM1MoIvx9MmKa26ZEyWteVbp/t8zVoQ1mdQE2Wj3kYLbZvZ8j1AJc1mqpQN2 G8xQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712819211; x=1713424011; 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=WBwFTB23QYK27eowOhLn23rF4sWQalYXU3BNGKcydTk=; b=oFoicSfiK9jZYo5FVu6rdX/GMNPPFyMHwUKDAOcdJ7cskn/9CqOWb7iqOyEVIJo5qh Fqg40X01vsfuKJj9+xT4Sg87w0V5Y6Oe/3tpFNo61grL9S5rH4BGf75PNjPa5p80VHUd 6sBrDjIW0or/KhV6g0l9hMDSjLqo5Qov2UYCSv6JUpqUkA6ZatbHUBD8cX5DbaAF+Lml Gl0EKJRuKRIE7lqDeWdVpQDJXy2zPF2BQcBcctYyGq6tsAKntKqu9tSVbKRQ08h4MOHv lPcq+QWP9W45/mBZWGHNzEKtP1JtnaDbFt67b2Lyv5Fwu1HFaJ8ppPLT11M1YddNu9lo kupA== X-Forwarded-Encrypted: i=1; AJvYcCXQtVsHISQCNEiHeF0jSs/EJ06pe9MZlA3CIW5IT4jTV7bDX534OQLC/Aq3X0etrrtZkIh8Tb3RkRZptTfrLvZEdU9filKxne1fDmGB X-Gm-Message-State: AOJu0YwIzp0cBsXeGOA02nGFTd233eeJvCbp83fkz91z5wIlNMdMFsuZ i3KDW9bddQL+wm/pap6APws1YODQWmE61lZ+6K/KWr1zRcpnq53butd8gpBO X-Received: by 2002:a05:6870:ac09:b0:22e:e01a:c7f7 with SMTP id kw9-20020a056870ac0900b0022ee01ac7f7mr5036275oab.16.1712819210973; Thu, 11 Apr 2024 00:06:50 -0700 (PDT) Received: from d.wok.cipunited.com ([104.28.213.200]) by smtp.gmail.com with ESMTPSA id g5-20020a056a0023c500b006e6be006637sm647402pfc.135.2024.04.11.00.06.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Apr 2024 00:06:50 -0700 (PDT) From: David Yang To: linux-clk@vger.kernel.org Cc: Michael Turquette , Stephen Boyd , linux-kernel@vger.kernel.org, David Yang Subject: [PATCH v8 09/13] clk: hisilicon: hi3620: Convert into platform driver module Date: Thu, 11 Apr 2024 15:04:54 +0800 Message-ID: <20240411070503.38093-11-mmyangfl@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240411070503.38093-2-mmyangfl@gmail.com> References: <20240411070503.38093-2-mmyangfl@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: 8bit Use common helper functions and register clks with a single of_device_id data. Signed-off-by: David Yang --- drivers/clk/hisilicon/clk-hi3620.c | 191 +++++++++++++++-------------- 1 file changed, 96 insertions(+), 95 deletions(-) diff --git a/drivers/clk/hisilicon/clk-hi3620.c b/drivers/clk/hisilicon/clk-hi3620.c index 5d0226530fdb..8832cdd6bd57 100644 --- a/drivers/clk/hisilicon/clk-hi3620.c +++ b/drivers/clk/hisilicon/clk-hi3620.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -21,48 +22,48 @@ #include "clk.h" /* clock parent list */ -static const char *const timer0_mux_p[] __initconst = { "osc32k", "timerclk01", }; -static const char *const timer1_mux_p[] __initconst = { "osc32k", "timerclk01", }; -static const char *const timer2_mux_p[] __initconst = { "osc32k", "timerclk23", }; -static const char *const timer3_mux_p[] __initconst = { "osc32k", "timerclk23", }; -static const char *const timer4_mux_p[] __initconst = { "osc32k", "timerclk45", }; -static const char *const timer5_mux_p[] __initconst = { "osc32k", "timerclk45", }; -static const char *const timer6_mux_p[] __initconst = { "osc32k", "timerclk67", }; -static const char *const timer7_mux_p[] __initconst = { "osc32k", "timerclk67", }; -static const char *const timer8_mux_p[] __initconst = { "osc32k", "timerclk89", }; -static const char *const timer9_mux_p[] __initconst = { "osc32k", "timerclk89", }; -static const char *const uart0_mux_p[] __initconst = { "osc26m", "pclk", }; -static const char *const uart1_mux_p[] __initconst = { "osc26m", "pclk", }; -static const char *const uart2_mux_p[] __initconst = { "osc26m", "pclk", }; -static const char *const uart3_mux_p[] __initconst = { "osc26m", "pclk", }; -static const char *const uart4_mux_p[] __initconst = { "osc26m", "pclk", }; -static const char *const spi0_mux_p[] __initconst = { "osc26m", "rclk_cfgaxi", }; -static const char *const spi1_mux_p[] __initconst = { "osc26m", "rclk_cfgaxi", }; -static const char *const spi2_mux_p[] __initconst = { "osc26m", "rclk_cfgaxi", }; +static const char *const timer0_mux_p[] = { "osc32k", "timerclk01", }; +static const char *const timer1_mux_p[] = { "osc32k", "timerclk01", }; +static const char *const timer2_mux_p[] = { "osc32k", "timerclk23", }; +static const char *const timer3_mux_p[] = { "osc32k", "timerclk23", }; +static const char *const timer4_mux_p[] = { "osc32k", "timerclk45", }; +static const char *const timer5_mux_p[] = { "osc32k", "timerclk45", }; +static const char *const timer6_mux_p[] = { "osc32k", "timerclk67", }; +static const char *const timer7_mux_p[] = { "osc32k", "timerclk67", }; +static const char *const timer8_mux_p[] = { "osc32k", "timerclk89", }; +static const char *const timer9_mux_p[] = { "osc32k", "timerclk89", }; +static const char *const uart0_mux_p[] = { "osc26m", "pclk", }; +static const char *const uart1_mux_p[] = { "osc26m", "pclk", }; +static const char *const uart2_mux_p[] = { "osc26m", "pclk", }; +static const char *const uart3_mux_p[] = { "osc26m", "pclk", }; +static const char *const uart4_mux_p[] = { "osc26m", "pclk", }; +static const char *const spi0_mux_p[] = { "osc26m", "rclk_cfgaxi", }; +static const char *const spi1_mux_p[] = { "osc26m", "rclk_cfgaxi", }; +static const char *const spi2_mux_p[] = { "osc26m", "rclk_cfgaxi", }; /* share axi parent */ -static const char *const saxi_mux_p[] __initconst = { "armpll3", "armpll2", }; -static const char *const pwm0_mux_p[] __initconst = { "osc32k", "osc26m", }; -static const char *const pwm1_mux_p[] __initconst = { "osc32k", "osc26m", }; -static const char *const sd_mux_p[] __initconst = { "armpll2", "armpll3", }; -static const char *const mmc1_mux_p[] __initconst = { "armpll2", "armpll3", }; -static const char *const mmc1_mux2_p[] __initconst = { "osc26m", "mmc1_div", }; -static const char *const g2d_mux_p[] __initconst = { "armpll2", "armpll3", }; -static const char *const venc_mux_p[] __initconst = { "armpll2", "armpll3", }; -static const char *const vdec_mux_p[] __initconst = { "armpll2", "armpll3", }; -static const char *const vpp_mux_p[] __initconst = { "armpll2", "armpll3", }; -static const char *const edc0_mux_p[] __initconst = { "armpll2", "armpll3", }; -static const char *const ldi0_mux_p[] __initconst = { "armpll2", "armpll4", +static const char *const saxi_mux_p[] = { "armpll3", "armpll2", }; +static const char *const pwm0_mux_p[] = { "osc32k", "osc26m", }; +static const char *const pwm1_mux_p[] = { "osc32k", "osc26m", }; +static const char *const sd_mux_p[] = { "armpll2", "armpll3", }; +static const char *const mmc1_mux_p[] = { "armpll2", "armpll3", }; +static const char *const mmc1_mux2_p[] = { "osc26m", "mmc1_div", }; +static const char *const g2d_mux_p[] = { "armpll2", "armpll3", }; +static const char *const venc_mux_p[] = { "armpll2", "armpll3", }; +static const char *const vdec_mux_p[] = { "armpll2", "armpll3", }; +static const char *const vpp_mux_p[] = { "armpll2", "armpll3", }; +static const char *const edc0_mux_p[] = { "armpll2", "armpll3", }; +static const char *const ldi0_mux_p[] = { "armpll2", "armpll4", "armpll3", "armpll5", }; -static const char *const edc1_mux_p[] __initconst = { "armpll2", "armpll3", }; -static const char *const ldi1_mux_p[] __initconst = { "armpll2", "armpll4", +static const char *const edc1_mux_p[] = { "armpll2", "armpll3", }; +static const char *const ldi1_mux_p[] = { "armpll2", "armpll4", "armpll3", "armpll5", }; -static const char *const rclk_hsic_p[] __initconst = { "armpll3", "armpll2", }; -static const char *const mmc2_mux_p[] __initconst = { "armpll2", "armpll3", }; -static const char *const mmc3_mux_p[] __initconst = { "armpll2", "armpll3", }; +static const char *const rclk_hsic_p[] = { "armpll3", "armpll2", }; +static const char *const mmc2_mux_p[] = { "armpll2", "armpll3", }; +static const char *const mmc3_mux_p[] = { "armpll2", "armpll3", }; /* fixed rate clocks */ -static struct hisi_fixed_rate_clock hi3620_fixed_rate_clks[] __initdata = { +static struct hisi_fixed_rate_clock hi3620_fixed_rate_clks[] = { { HI3620_OSC32K, "osc32k", NULL, 0, 32768, }, { HI3620_OSC26M, "osc26m", NULL, 0, 26000000, }, { HI3620_PCLK, "pclk", NULL, 0, 26000000, }, @@ -75,13 +76,13 @@ static struct hisi_fixed_rate_clock hi3620_fixed_rate_clks[] __initdata = { }; /* fixed factor clocks */ -static struct hisi_fixed_factor_clock hi3620_fixed_factor_clks[] __initdata = { +static struct hisi_fixed_factor_clock hi3620_fixed_factor_clks[] = { { HI3620_RCLK_TCXO, "rclk_tcxo", "osc26m", 1, 4, 0, }, { HI3620_RCLK_CFGAXI, "rclk_cfgaxi", "armpll2", 1, 30, 0, }, { HI3620_RCLK_PICO, "rclk_pico", "hsic_div", 1, 40, 0, }, }; -static struct hisi_mux_clock hi3620_mux_clks[] __initdata = { +static struct hisi_mux_clock hi3620_mux_clks[] = { { HI3620_TIMER0_MUX, "timer0_mux", timer0_mux_p, ARRAY_SIZE(timer0_mux_p), CLK_SET_RATE_PARENT, 0, 15, 2, 0, }, { HI3620_TIMER1_MUX, "timer1_mux", timer1_mux_p, ARRAY_SIZE(timer1_mux_p), CLK_SET_RATE_PARENT, 0, 17, 2, 0, }, { HI3620_TIMER2_MUX, "timer2_mux", timer2_mux_p, ARRAY_SIZE(timer2_mux_p), CLK_SET_RATE_PARENT, 0, 19, 2, 0, }, @@ -119,7 +120,7 @@ static struct hisi_mux_clock hi3620_mux_clks[] __initdata = { { HI3620_MMC3_MUX, "mmc3_mux", mmc3_mux_p, ARRAY_SIZE(mmc3_mux_p), CLK_SET_RATE_PARENT, 0x140, 9, 1, CLK_MUX_HIWORD_MASK, }, }; -static struct hisi_divider_clock hi3620_div_clks[] __initdata = { +static struct hisi_divider_clock hi3620_div_clks[] = { { HI3620_SHAREAXI_DIV, "saxi_div", "saxi_mux", 0, 0x100, 0, 5, CLK_DIVIDER_HIWORD_MASK, NULL, }, { HI3620_CFGAXI_DIV, "cfgaxi_div", "saxi_div", 0, 0x100, 5, 2, CLK_DIVIDER_HIWORD_MASK, NULL, }, { HI3620_SD_DIV, "sd_div", "sd_mux", 0, 0x108, 0, 4, CLK_DIVIDER_HIWORD_MASK, NULL, }, @@ -129,7 +130,7 @@ static struct hisi_divider_clock hi3620_div_clks[] __initdata = { { HI3620_MMC3_DIV, "mmc3_div", "mmc3_mux", 0, 0x140, 5, 4, CLK_DIVIDER_HIWORD_MASK, NULL, }, }; -static struct hisi_gate_clock hi3620_separated_gate_clks[] __initdata = { +static struct hisi_gate_clock hi3620_separated_gate_clks[] = { { HI3620_TIMERCLK01, "timerclk01", "timer_rclk01", CLK_SET_RATE_PARENT, 0x20, 0, 0, }, { HI3620_TIMER_RCLK01, "timer_rclk01", "rclk_tcxo", CLK_SET_RATE_PARENT, 0x20, 1, 0, }, { HI3620_TIMERCLK23, "timerclk23", "timer_rclk23", CLK_SET_RATE_PARENT, 0x20, 2, 0, }, @@ -191,29 +192,19 @@ static struct hisi_gate_clock hi3620_separated_gate_clks[] __initdata = { { HI3620_MCU_CLK, "mcu_clk", "acp_clk", CLK_SET_RATE_PARENT, 0x50, 24, 0, }, }; -static void __init hi3620_clk_init(struct device_node *np) -{ - struct hisi_clock_data *clk_data; - - clk_data = hisi_clk_init(np, HI3620_NR_CLKS); - if (!clk_data) - return; - - hisi_clk_register_fixed_rate(hi3620_fixed_rate_clks, - ARRAY_SIZE(hi3620_fixed_rate_clks), - clk_data); - hisi_clk_register_fixed_factor(hi3620_fixed_factor_clks, - ARRAY_SIZE(hi3620_fixed_factor_clks), - clk_data); - hisi_clk_register_mux(hi3620_mux_clks, ARRAY_SIZE(hi3620_mux_clks), - clk_data); - hisi_clk_register_divider(hi3620_div_clks, ARRAY_SIZE(hi3620_div_clks), - clk_data); - hisi_clk_register_gate_sep(hi3620_separated_gate_clks, - ARRAY_SIZE(hi3620_separated_gate_clks), - clk_data); -} -CLK_OF_DECLARE(hi3620_clk, "hisilicon,hi3620-clock", hi3620_clk_init); +static const struct hisi_clocks hi3620_clks = { + .nr = HI3620_NR_CLKS, + .fixed_rate_clks = hi3620_fixed_rate_clks, + .fixed_rate_clks_num = ARRAY_SIZE(hi3620_fixed_rate_clks), + .fixed_factor_clks = hi3620_fixed_factor_clks, + .fixed_factor_clks_num = ARRAY_SIZE(hi3620_fixed_factor_clks), + .mux_clks = hi3620_mux_clks, + .mux_clks_num = ARRAY_SIZE(hi3620_mux_clks), + .divider_clks = hi3620_div_clks, + .divider_clks_num = ARRAY_SIZE(hi3620_div_clks), + .gate_sep_clks = hi3620_separated_gate_clks, + .gate_sep_clks_num = ARRAY_SIZE(hi3620_separated_gate_clks), +}; struct hisi_mmc_clock { unsigned int id; @@ -251,7 +242,7 @@ struct clk_mmc { #define to_mmc(_hw) container_of(_hw, struct clk_mmc, hw) -static struct hisi_mmc_clock hi3620_mmc_clks[] __initdata = { +static struct hisi_mmc_clock hi3620_mmc_clks[] = { { HI3620_SD_CIUCLK, "sd_bclk1", "sd_clk", CLK_SET_RATE_PARENT, 0x1f8, 0, 0x1f8, 1, 3, 0x1f8, 4, 4, 0x1f8, 8, 4}, { HI3620_MMC_CIUCLK1, "mmc_bclk1", "mmc_clk1", CLK_SET_RATE_PARENT, 0x1f8, 12, 0x1f8, 13, 3, 0x1f8, 16, 4, 0x1f8, 20, 4}, { HI3620_MMC_CIUCLK2, "mmc_bclk2", "mmc_clk2", CLK_SET_RATE_PARENT, 0x1f8, 24, 0x1f8, 25, 3, 0x1f8, 28, 4, 0x1fc, 0, 4}, @@ -407,8 +398,9 @@ static const struct clk_ops clk_mmc_ops = { .recalc_rate = mmc_clk_recalc_rate, }; -static struct clk *hisi_register_clk_mmc(struct hisi_mmc_clock *mmc_clk, - void __iomem *base, struct device_node *np) +static struct clk * +clk_register_hisi_mmc(struct device *dev, const struct hisi_mmc_clock *mmc_clk, + void __iomem *base) { struct clk_mmc *mclk; struct clk *clk; @@ -444,41 +436,50 @@ static struct clk *hisi_register_clk_mmc(struct hisi_mmc_clock *mmc_clk, return clk; } -static void __init hi3620_mmc_clk_init(struct device_node *node) +static int hisi_register_clk_mmc(struct device *dev, const void *clocks, + size_t num, struct hisi_clock_data *data) { - void __iomem *base; - int i, num = ARRAY_SIZE(hi3620_mmc_clks); - struct clk_onecell_data *clk_data; + const struct hisi_mmc_clock *clks = clocks; - if (!node) { - pr_err("failed to find pctrl node in DTS\n"); - return; - } + for (int i = 0; i < num; i++) { + struct clk *clk = clk_register_hisi_mmc(dev, &clks[i], data->base); - base = of_iomap(node, 0); - if (!base) { - pr_err("failed to map pctrl\n"); - return; + if (IS_ERR(clk)) { + pr_err("%s: failed to register clock %s\n", + __func__, clks[i].name); + return PTR_ERR(clk); + } + data->clk_data.clks[clks[i].id] = clk; } - clk_data = kzalloc(sizeof(*clk_data), GFP_KERNEL); - if (WARN_ON(!clk_data)) - return; + return 0; +} - clk_data->clks = kcalloc(num, sizeof(*clk_data->clks), GFP_KERNEL); - if (!clk_data->clks) { - kfree(clk_data); - return; - } +static const struct hisi_clocks hi3620_clks_mmc = { + .customized_clks = hi3620_mmc_clks, + .customized_clks_num = ARRAY_SIZE(hi3620_mmc_clks), + .clk_register_customized = hisi_register_clk_mmc, +}; - for (i = 0; i < num; i++) { - struct hisi_mmc_clock *mmc_clk = &hi3620_mmc_clks[i]; - clk_data->clks[mmc_clk->id] = - hisi_register_clk_mmc(mmc_clk, base, node); - } +static const struct of_device_id hi3620_clk_match_table[] = { + { .compatible = "hisilicon,hi3620-clock", + .data = &hi3620_clks }, + { .compatible = "hisilicon,hi3620-mmc-clock", + .data = &hi3620_clks_mmc }, + { } +}; +MODULE_DEVICE_TABLE(of, hi3620_clk_match_table); + +static struct platform_driver hi3620_clk_driver = { + .probe = hisi_clk_probe, + .remove_new = hisi_clk_remove, + .driver = { + .name = "hi3620-clock", + .of_match_table = hi3620_clk_match_table, + }, +}; - clk_data->clk_num = num; - of_clk_add_provider(node, of_clk_src_onecell_get, clk_data); -} +module_platform_driver(hi3620_clk_driver); -CLK_OF_DECLARE(hi3620_mmc_clk, "hisilicon,hi3620-mmc-clock", hi3620_mmc_clk_init); +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("HiSilicon Hi3620 Clock Driver"); -- 2.43.0