From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA89FC4332F for ; Tue, 26 Oct 2021 06:10:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AA77D6109D for ; Tue, 26 Oct 2021 06:10:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232718AbhJZGMq (ORCPT ); Tue, 26 Oct 2021 02:12:46 -0400 Received: from mx3.molgen.mpg.de ([141.14.17.11]:44775 "EHLO mx1.molgen.mpg.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231134AbhJZGMo (ORCPT ); Tue, 26 Oct 2021 02:12:44 -0400 Received: from [192.168.0.2] (ip5f5aef4c.dynamic.kabel-deutschland.de [95.90.239.76]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) (Authenticated sender: pmenzel) by mx.molgen.mpg.de (Postfix) with ESMTPSA id 5DC7F61E6478B; Tue, 26 Oct 2021 08:10:18 +0200 (CEST) Message-ID: <24f55e7d-2f2d-2181-2265-7365d648be8f@molgen.mpg.de> Date: Tue, 26 Oct 2021 08:10:18 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Subject: Re: [PATCH 01/10] clk: aspeed: ast2600: Porting sdhci clock source Content-Language: en-US To: Chin-Ting Kuo Cc: robh+dt@kernel.org, joel@jms.id.au, mturquette@baylibre.com, sboyd@kernel.org, adrian.hunter@intel.com, linux-aspeed@lists.ozlabs.org, openbmc@lists.ozlabs.org, linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, andrew@aj.id.au, BMC-SW@aspeedtech.com, steven_lee@aspeedtech.com References: <20210922103116.30652-1-chin-ting_kuo@aspeedtech.com> <20210922103116.30652-2-chin-ting_kuo@aspeedtech.com> From: Paul Menzel In-Reply-To: <20210922103116.30652-2-chin-ting_kuo@aspeedtech.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Dear Chin-Ting, Thank you for your patch. Some small things. Please use imperative mood in the commit messages summary [1]: clk: aspeed: ast2600: Port SDHCI clock source On 22.09.21 12:31, Chin-Ting Kuo wrote: > - There are two clock sources used to generate > SD/SDIO clock, APLL clock and HCLK (200MHz). > User can select which clock source should be used > by configuring SCU310[8]. > - The SD/SDIO clock divider selection table SCU310[30:28] > is different between AST2600-A1 and AST2600-A2/A3. > For AST2600-A1, 200MHz SD/SDIO clock cannot be > gotten by the dividers in SCU310[30:28] if APLL > is not the multiple of 200MHz and HCLK is 200MHz. > For AST2600-A2/A3, a new divider, "1", is added and > 200MHz SD/SDIO clock can be obtained by adopting HCLK > as clock source and setting SCU310[30:28] to 3b'111. Please reference the datasheet name and version, and please reflow the commit message for 75 characters per line. > Signed-off-by: Chin-Ting Kuo > --- > drivers/clk/clk-ast2600.c | 69 ++++++++++++++++++++++++++++++++++----- > 1 file changed, 61 insertions(+), 8 deletions(-) > > diff --git a/drivers/clk/clk-ast2600.c b/drivers/clk/clk-ast2600.c > index bc3be5f3eae1..a6778c18274a 100644 > --- a/drivers/clk/clk-ast2600.c > +++ b/drivers/clk/clk-ast2600.c > @@ -168,6 +168,30 @@ static const struct clk_div_table ast2600_div_table[] = { > { 0 } > }; > > +static const struct clk_div_table ast2600_sd_div_a1_table[] = { > + { 0x0, 2 }, > + { 0x1, 4 }, > + { 0x2, 6 }, > + { 0x3, 8 }, > + { 0x4, 10 }, > + { 0x5, 12 }, > + { 0x6, 14 }, > + { 0x7, 16 }, > + { 0 } > +}; > + > +static const struct clk_div_table ast2600_sd_div_a2_table[] = { > + { 0x0, 2 }, > + { 0x1, 4 }, > + { 0x2, 6 }, > + { 0x3, 8 }, > + { 0x4, 10 }, > + { 0x5, 12 }, > + { 0x6, 14 }, > + { 0x7, 1 }, > + { 0 } > +}; > + > /* For hpll/dpll/epll/mpll */ > static struct clk_hw *ast2600_calc_pll(const char *name, u32 val) > { > @@ -424,6 +448,11 @@ static const char *const emmc_extclk_parent_names[] = { > "mpll", > }; > > +static const char *const sd_extclk_parent_names[] = { > + "hclk", > + "apll", > +}; > + > static const char * const vclk_parent_names[] = { > "dpll", > "d1pll", > @@ -523,18 +552,42 @@ static int aspeed_g6_clk_probe(struct platform_device *pdev) > return PTR_ERR(hw); > aspeed_g6_clk_data->hws[ASPEED_CLK_EMMC] = hw; > > - /* SD/SDIO clock divider and gate */ > - hw = clk_hw_register_gate(dev, "sd_extclk_gate", "hpll", 0, > - scu_g6_base + ASPEED_G6_CLK_SELECTION4, 31, 0, > - &aspeed_g6_clk_lock); > + clk_hw_register_fixed_rate(NULL, "hclk", NULL, 0, 200000000); > + > + regmap_read(map, 0x310, &val); > + hw = clk_hw_register_mux(dev, "sd_extclk_mux", > + sd_extclk_parent_names, > + ARRAY_SIZE(sd_extclk_parent_names), 0, > + scu_g6_base + ASPEED_G6_CLK_SELECTION4, 8, 1, > + 0, &aspeed_g6_clk_lock); > if (IS_ERR(hw)) > return PTR_ERR(hw); > - hw = clk_hw_register_divider_table(dev, "sd_extclk", "sd_extclk_gate", > - 0, scu_g6_base + ASPEED_G6_CLK_SELECTION4, 28, 3, 0, > - ast2600_div_table, > - &aspeed_g6_clk_lock); > + > + hw = clk_hw_register_gate(dev, "sd_extclk_gate", "sd_extclk_mux", > + 0, scu_g6_base + ASPEED_G6_CLK_SELECTION4, > + 31, 0, &aspeed_g6_clk_lock); > if (IS_ERR(hw)) > return PTR_ERR(hw); > + > + regmap_read(map, 0x14, &val); > + /* AST2600-A2/A3 clock divisor is different from AST2600-A1 */ > + if (((val & GENMASK(23, 16)) >> 16) >= 2) { > + /* AST2600-A2/A3 */ > + hw = clk_hw_register_divider_table(dev, "sd_extclk", "sd_extclk_gate", > + 0, scu_g6_base + ASPEED_G6_CLK_SELECTION4, 28, 3, 0, > + ast2600_sd_div_a2_table, > + &aspeed_g6_clk_lock); > + if (IS_ERR(hw)) > + return PTR_ERR(hw); > + } else { > + /* AST2600-A1 */ > + hw = clk_hw_register_divider_table(dev, "sd_extclk", "sd_extclk_gate", > + 0, scu_g6_base + ASPEED_G6_CLK_SELECTION4, 28, 3, 0, > + ast2600_sd_div_a1_table, > + &aspeed_g6_clk_lock); > + if (IS_ERR(hw)) > + return PTR_ERR(hw); > + } > aspeed_g6_clk_data->hws[ASPEED_CLK_SDIO] = hw; > > /* MAC1/2 RMII 50MHz RCLK */ > Does Linux already log, if A1 or A2/A3 is detected? Should a debug message be added, what clock divisor is used? Kind regards, Paul From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D4967C433F5 for ; Tue, 26 Oct 2021 06:10:52 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E2EA160F9D for ; Tue, 26 Oct 2021 06:10:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E2EA160F9D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=molgen.mpg.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.ozlabs.org Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4HdhJp4J0xz2yPs for ; Tue, 26 Oct 2021 17:10:50 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=molgen.mpg.de (client-ip=141.14.17.11; helo=mx1.molgen.mpg.de; envelope-from=pmenzel@molgen.mpg.de; receiver=) Received: from mx1.molgen.mpg.de (mx3.molgen.mpg.de [141.14.17.11]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4HdhJJ2mLWz2xX6; Tue, 26 Oct 2021 17:10:23 +1100 (AEDT) Received: from [192.168.0.2] (ip5f5aef4c.dynamic.kabel-deutschland.de [95.90.239.76]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) (Authenticated sender: pmenzel) by mx.molgen.mpg.de (Postfix) with ESMTPSA id 5DC7F61E6478B; Tue, 26 Oct 2021 08:10:18 +0200 (CEST) Message-ID: <24f55e7d-2f2d-2181-2265-7365d648be8f@molgen.mpg.de> Date: Tue, 26 Oct 2021 08:10:18 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Subject: Re: [PATCH 01/10] clk: aspeed: ast2600: Porting sdhci clock source Content-Language: en-US To: Chin-Ting Kuo References: <20210922103116.30652-1-chin-ting_kuo@aspeedtech.com> <20210922103116.30652-2-chin-ting_kuo@aspeedtech.com> From: Paul Menzel In-Reply-To: <20210922103116.30652-2-chin-ting_kuo@aspeedtech.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-clk@vger.kernel.org, linux-aspeed@lists.ozlabs.org, BMC-SW@aspeedtech.com, sboyd@kernel.org, steven_lee@aspeedtech.com, mturquette@baylibre.com, linux-mmc@vger.kernel.org, adrian.hunter@intel.com, linux-kernel@vger.kernel.org, andrew@aj.id.au, robh+dt@kernel.org, openbmc@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org Errors-To: openbmc-bounces+openbmc=archiver.kernel.org@lists.ozlabs.org Sender: "openbmc" Dear Chin-Ting, Thank you for your patch. Some small things. Please use imperative mood in the commit messages summary [1]: clk: aspeed: ast2600: Port SDHCI clock source On 22.09.21 12:31, Chin-Ting Kuo wrote: > - There are two clock sources used to generate > SD/SDIO clock, APLL clock and HCLK (200MHz). > User can select which clock source should be used > by configuring SCU310[8]. > - The SD/SDIO clock divider selection table SCU310[30:28] > is different between AST2600-A1 and AST2600-A2/A3. > For AST2600-A1, 200MHz SD/SDIO clock cannot be > gotten by the dividers in SCU310[30:28] if APLL > is not the multiple of 200MHz and HCLK is 200MHz. > For AST2600-A2/A3, a new divider, "1", is added and > 200MHz SD/SDIO clock can be obtained by adopting HCLK > as clock source and setting SCU310[30:28] to 3b'111. Please reference the datasheet name and version, and please reflow the commit message for 75 characters per line. > Signed-off-by: Chin-Ting Kuo > --- > drivers/clk/clk-ast2600.c | 69 ++++++++++++++++++++++++++++++++++----- > 1 file changed, 61 insertions(+), 8 deletions(-) > > diff --git a/drivers/clk/clk-ast2600.c b/drivers/clk/clk-ast2600.c > index bc3be5f3eae1..a6778c18274a 100644 > --- a/drivers/clk/clk-ast2600.c > +++ b/drivers/clk/clk-ast2600.c > @@ -168,6 +168,30 @@ static const struct clk_div_table ast2600_div_table[] = { > { 0 } > }; > > +static const struct clk_div_table ast2600_sd_div_a1_table[] = { > + { 0x0, 2 }, > + { 0x1, 4 }, > + { 0x2, 6 }, > + { 0x3, 8 }, > + { 0x4, 10 }, > + { 0x5, 12 }, > + { 0x6, 14 }, > + { 0x7, 16 }, > + { 0 } > +}; > + > +static const struct clk_div_table ast2600_sd_div_a2_table[] = { > + { 0x0, 2 }, > + { 0x1, 4 }, > + { 0x2, 6 }, > + { 0x3, 8 }, > + { 0x4, 10 }, > + { 0x5, 12 }, > + { 0x6, 14 }, > + { 0x7, 1 }, > + { 0 } > +}; > + > /* For hpll/dpll/epll/mpll */ > static struct clk_hw *ast2600_calc_pll(const char *name, u32 val) > { > @@ -424,6 +448,11 @@ static const char *const emmc_extclk_parent_names[] = { > "mpll", > }; > > +static const char *const sd_extclk_parent_names[] = { > + "hclk", > + "apll", > +}; > + > static const char * const vclk_parent_names[] = { > "dpll", > "d1pll", > @@ -523,18 +552,42 @@ static int aspeed_g6_clk_probe(struct platform_device *pdev) > return PTR_ERR(hw); > aspeed_g6_clk_data->hws[ASPEED_CLK_EMMC] = hw; > > - /* SD/SDIO clock divider and gate */ > - hw = clk_hw_register_gate(dev, "sd_extclk_gate", "hpll", 0, > - scu_g6_base + ASPEED_G6_CLK_SELECTION4, 31, 0, > - &aspeed_g6_clk_lock); > + clk_hw_register_fixed_rate(NULL, "hclk", NULL, 0, 200000000); > + > + regmap_read(map, 0x310, &val); > + hw = clk_hw_register_mux(dev, "sd_extclk_mux", > + sd_extclk_parent_names, > + ARRAY_SIZE(sd_extclk_parent_names), 0, > + scu_g6_base + ASPEED_G6_CLK_SELECTION4, 8, 1, > + 0, &aspeed_g6_clk_lock); > if (IS_ERR(hw)) > return PTR_ERR(hw); > - hw = clk_hw_register_divider_table(dev, "sd_extclk", "sd_extclk_gate", > - 0, scu_g6_base + ASPEED_G6_CLK_SELECTION4, 28, 3, 0, > - ast2600_div_table, > - &aspeed_g6_clk_lock); > + > + hw = clk_hw_register_gate(dev, "sd_extclk_gate", "sd_extclk_mux", > + 0, scu_g6_base + ASPEED_G6_CLK_SELECTION4, > + 31, 0, &aspeed_g6_clk_lock); > if (IS_ERR(hw)) > return PTR_ERR(hw); > + > + regmap_read(map, 0x14, &val); > + /* AST2600-A2/A3 clock divisor is different from AST2600-A1 */ > + if (((val & GENMASK(23, 16)) >> 16) >= 2) { > + /* AST2600-A2/A3 */ > + hw = clk_hw_register_divider_table(dev, "sd_extclk", "sd_extclk_gate", > + 0, scu_g6_base + ASPEED_G6_CLK_SELECTION4, 28, 3, 0, > + ast2600_sd_div_a2_table, > + &aspeed_g6_clk_lock); > + if (IS_ERR(hw)) > + return PTR_ERR(hw); > + } else { > + /* AST2600-A1 */ > + hw = clk_hw_register_divider_table(dev, "sd_extclk", "sd_extclk_gate", > + 0, scu_g6_base + ASPEED_G6_CLK_SELECTION4, 28, 3, 0, > + ast2600_sd_div_a1_table, > + &aspeed_g6_clk_lock); > + if (IS_ERR(hw)) > + return PTR_ERR(hw); > + } > aspeed_g6_clk_data->hws[ASPEED_CLK_SDIO] = hw; > > /* MAC1/2 RMII 50MHz RCLK */ > Does Linux already log, if A1 or A2/A3 is detected? Should a debug message be added, what clock divisor is used? Kind regards, Paul From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E30BBC433EF for ; Tue, 26 Oct 2021 06:11:59 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AE8F460F9D for ; Tue, 26 Oct 2021 06:11:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org AE8F460F9D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=molgen.mpg.de Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=azROOfBWD0Abc29olD0RMoQWWpPPSDkBIZdM1uTa/n8=; b=CORbHz8UJIpKhT +uZnQdgxyWBqgmLCXkmzwcC9DyQGHIAGx/XHZIZ85zNWaasc964IR51U6SmPQAIYHwy+5uo6wvflM ABH7QFgknOixLM/lEMRxB/BgqfNO6A0PlOp/+CgIw9PWcKQpK4PZflADoSNK8sChGFVgCUEYCeAA6 gXHHtbryPY9HVYSZn4xSUqmMFY2HJUh/UxOFfd86mEsab6nmGUAKDer9yy8PixtEemaY6IUw7/AKU WSJgswa/k/Iimdkcwsf8cbwUdmDJxN8rKDIkr9YG9SfTn7/I38YKo/4TWcr5FdH9kcrQg7i/rGspH rH9k4Vr3ZMdPWLJ1UlVw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfFfJ-000lkX-8p; Tue, 26 Oct 2021 06:10:29 +0000 Received: from mx3.molgen.mpg.de ([141.14.17.11] helo=mx1.molgen.mpg.de) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mfFfE-000ljZ-8F for linux-arm-kernel@lists.infradead.org; Tue, 26 Oct 2021 06:10:26 +0000 Received: from [192.168.0.2] (ip5f5aef4c.dynamic.kabel-deutschland.de [95.90.239.76]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) (Authenticated sender: pmenzel) by mx.molgen.mpg.de (Postfix) with ESMTPSA id 5DC7F61E6478B; Tue, 26 Oct 2021 08:10:18 +0200 (CEST) Message-ID: <24f55e7d-2f2d-2181-2265-7365d648be8f@molgen.mpg.de> Date: Tue, 26 Oct 2021 08:10:18 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.1 Subject: Re: [PATCH 01/10] clk: aspeed: ast2600: Porting sdhci clock source Content-Language: en-US To: Chin-Ting Kuo Cc: robh+dt@kernel.org, joel@jms.id.au, mturquette@baylibre.com, sboyd@kernel.org, adrian.hunter@intel.com, linux-aspeed@lists.ozlabs.org, openbmc@lists.ozlabs.org, linux-mmc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-clk@vger.kernel.org, andrew@aj.id.au, BMC-SW@aspeedtech.com, steven_lee@aspeedtech.com References: <20210922103116.30652-1-chin-ting_kuo@aspeedtech.com> <20210922103116.30652-2-chin-ting_kuo@aspeedtech.com> From: Paul Menzel In-Reply-To: <20210922103116.30652-2-chin-ting_kuo@aspeedtech.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211025_231024_488992_673EF026 X-CRM114-Status: GOOD ( 25.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Dear Chin-Ting, Thank you for your patch. Some small things. Please use imperative mood in the commit messages summary [1]: clk: aspeed: ast2600: Port SDHCI clock source On 22.09.21 12:31, Chin-Ting Kuo wrote: > - There are two clock sources used to generate > SD/SDIO clock, APLL clock and HCLK (200MHz). > User can select which clock source should be used > by configuring SCU310[8]. > - The SD/SDIO clock divider selection table SCU310[30:28] > is different between AST2600-A1 and AST2600-A2/A3. > For AST2600-A1, 200MHz SD/SDIO clock cannot be > gotten by the dividers in SCU310[30:28] if APLL > is not the multiple of 200MHz and HCLK is 200MHz. > For AST2600-A2/A3, a new divider, "1", is added and > 200MHz SD/SDIO clock can be obtained by adopting HCLK > as clock source and setting SCU310[30:28] to 3b'111. Please reference the datasheet name and version, and please reflow the commit message for 75 characters per line. > Signed-off-by: Chin-Ting Kuo > --- > drivers/clk/clk-ast2600.c | 69 ++++++++++++++++++++++++++++++++++----- > 1 file changed, 61 insertions(+), 8 deletions(-) > > diff --git a/drivers/clk/clk-ast2600.c b/drivers/clk/clk-ast2600.c > index bc3be5f3eae1..a6778c18274a 100644 > --- a/drivers/clk/clk-ast2600.c > +++ b/drivers/clk/clk-ast2600.c > @@ -168,6 +168,30 @@ static const struct clk_div_table ast2600_div_table[] = { > { 0 } > }; > > +static const struct clk_div_table ast2600_sd_div_a1_table[] = { > + { 0x0, 2 }, > + { 0x1, 4 }, > + { 0x2, 6 }, > + { 0x3, 8 }, > + { 0x4, 10 }, > + { 0x5, 12 }, > + { 0x6, 14 }, > + { 0x7, 16 }, > + { 0 } > +}; > + > +static const struct clk_div_table ast2600_sd_div_a2_table[] = { > + { 0x0, 2 }, > + { 0x1, 4 }, > + { 0x2, 6 }, > + { 0x3, 8 }, > + { 0x4, 10 }, > + { 0x5, 12 }, > + { 0x6, 14 }, > + { 0x7, 1 }, > + { 0 } > +}; > + > /* For hpll/dpll/epll/mpll */ > static struct clk_hw *ast2600_calc_pll(const char *name, u32 val) > { > @@ -424,6 +448,11 @@ static const char *const emmc_extclk_parent_names[] = { > "mpll", > }; > > +static const char *const sd_extclk_parent_names[] = { > + "hclk", > + "apll", > +}; > + > static const char * const vclk_parent_names[] = { > "dpll", > "d1pll", > @@ -523,18 +552,42 @@ static int aspeed_g6_clk_probe(struct platform_device *pdev) > return PTR_ERR(hw); > aspeed_g6_clk_data->hws[ASPEED_CLK_EMMC] = hw; > > - /* SD/SDIO clock divider and gate */ > - hw = clk_hw_register_gate(dev, "sd_extclk_gate", "hpll", 0, > - scu_g6_base + ASPEED_G6_CLK_SELECTION4, 31, 0, > - &aspeed_g6_clk_lock); > + clk_hw_register_fixed_rate(NULL, "hclk", NULL, 0, 200000000); > + > + regmap_read(map, 0x310, &val); > + hw = clk_hw_register_mux(dev, "sd_extclk_mux", > + sd_extclk_parent_names, > + ARRAY_SIZE(sd_extclk_parent_names), 0, > + scu_g6_base + ASPEED_G6_CLK_SELECTION4, 8, 1, > + 0, &aspeed_g6_clk_lock); > if (IS_ERR(hw)) > return PTR_ERR(hw); > - hw = clk_hw_register_divider_table(dev, "sd_extclk", "sd_extclk_gate", > - 0, scu_g6_base + ASPEED_G6_CLK_SELECTION4, 28, 3, 0, > - ast2600_div_table, > - &aspeed_g6_clk_lock); > + > + hw = clk_hw_register_gate(dev, "sd_extclk_gate", "sd_extclk_mux", > + 0, scu_g6_base + ASPEED_G6_CLK_SELECTION4, > + 31, 0, &aspeed_g6_clk_lock); > if (IS_ERR(hw)) > return PTR_ERR(hw); > + > + regmap_read(map, 0x14, &val); > + /* AST2600-A2/A3 clock divisor is different from AST2600-A1 */ > + if (((val & GENMASK(23, 16)) >> 16) >= 2) { > + /* AST2600-A2/A3 */ > + hw = clk_hw_register_divider_table(dev, "sd_extclk", "sd_extclk_gate", > + 0, scu_g6_base + ASPEED_G6_CLK_SELECTION4, 28, 3, 0, > + ast2600_sd_div_a2_table, > + &aspeed_g6_clk_lock); > + if (IS_ERR(hw)) > + return PTR_ERR(hw); > + } else { > + /* AST2600-A1 */ > + hw = clk_hw_register_divider_table(dev, "sd_extclk", "sd_extclk_gate", > + 0, scu_g6_base + ASPEED_G6_CLK_SELECTION4, 28, 3, 0, > + ast2600_sd_div_a1_table, > + &aspeed_g6_clk_lock); > + if (IS_ERR(hw)) > + return PTR_ERR(hw); > + } > aspeed_g6_clk_data->hws[ASPEED_CLK_SDIO] = hw; > > /* MAC1/2 RMII 50MHz RCLK */ > Does Linux already log, if A1 or A2/A3 is detected? Should a debug message be added, what clock divisor is used? Kind regards, Paul _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel