All of lore.kernel.org
 help / color / mirror / Atom feed
From: andrew@lunn.ch (Andrew Lunn)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 5/7] net: phy: Add support to configure clock in Broadcom iProc mdio mux
Date: Thu, 26 Jul 2018 21:26:51 +0200	[thread overview]
Message-ID: <20180726192651.GK10686@lunn.ch> (raw)
In-Reply-To: <1532630184-29450-6-git-send-email-arun.parameswaran@broadcom.com>

> +static void mdio_mux_iproc_config_clk(struct iproc_mdiomux_desc *md)
> +{
> +	u32 val;
> +	u32 divisor;
> +
> +	if (md->core_clk) {
> +		divisor = clk_get_rate(md->core_clk) / MDIO_OPERATING_FREQUENCY;

/**
 * clk_get_rate - obtain the current clock rate (in Hz) for a clock source.
 * 		  This is only valid once the clock source has been enabled.
 * @clk: clock source
 */
unsigned long clk_get_rate(struct clk *clk);

It is generally good practice to call clk_prepare_enable() sometime
before clk_get_rate() to ensure the clock is ticking, and to show this
driver is making use of the clock, so it does not get turned off.

> +		divisor = divisor / (MDIO_RATE_ADJ_DIVIDENT + 1);
> +		val = divisor;
> +		val |= MDIO_RATE_ADJ_DIVIDENT << MDIO_RATE_ADJ_DIVIDENT_SHIFT;
> +		writel(val, md->base + MDIO_RATE_ADJ_EXT_OFFSET);
> +		writel(val, md->base + MDIO_RATE_ADJ_INT_OFFSET);
> +	}
> +}

WARNING: multiple messages have this Message-ID (diff)
From: Andrew Lunn <andrew@lunn.ch>
To: Arun Parameswaran <arun.parameswaran@broadcom.com>
Cc: "David S. Miller" <davem@davemloft.net>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Rob Herring <robh+dt@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>, Ray Jui <rjui@broadcom.com>,
	Scott Branden <sbranden@broadcom.com>,
	Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	netdev@vger.kernel.org, devicetree@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org,
	bcm-kernel-feedback-list@broadcom.com
Subject: Re: [PATCH 5/7] net: phy: Add support to configure clock in Broadcom iProc mdio mux
Date: Thu, 26 Jul 2018 21:26:51 +0200	[thread overview]
Message-ID: <20180726192651.GK10686@lunn.ch> (raw)
In-Reply-To: <1532630184-29450-6-git-send-email-arun.parameswaran@broadcom.com>

> +static void mdio_mux_iproc_config_clk(struct iproc_mdiomux_desc *md)
> +{
> +	u32 val;
> +	u32 divisor;
> +
> +	if (md->core_clk) {
> +		divisor = clk_get_rate(md->core_clk) / MDIO_OPERATING_FREQUENCY;

/**
 * clk_get_rate - obtain the current clock rate (in Hz) for a clock source.
 * 		  This is only valid once the clock source has been enabled.
 * @clk: clock source
 */
unsigned long clk_get_rate(struct clk *clk);

It is generally good practice to call clk_prepare_enable() sometime
before clk_get_rate() to ensure the clock is ticking, and to show this
driver is making use of the clock, so it does not get turned off.

> +		divisor = divisor / (MDIO_RATE_ADJ_DIVIDENT + 1);
> +		val = divisor;
> +		val |= MDIO_RATE_ADJ_DIVIDENT << MDIO_RATE_ADJ_DIVIDENT_SHIFT;
> +		writel(val, md->base + MDIO_RATE_ADJ_EXT_OFFSET);
> +		writel(val, md->base + MDIO_RATE_ADJ_INT_OFFSET);
> +	}
> +}

  parent reply	other threads:[~2018-07-26 19:26 UTC|newest]

Thread overview: 50+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-26 18:36 [PATCH 0/7] Add clock config and pm support to bcm iProc mdio mux Arun Parameswaran
2018-07-26 18:36 ` Arun Parameswaran
2018-07-26 18:36 ` [PATCH 1/7] dt-bindings: net: Fix Broadcom iProc mdio mux driver base address Arun Parameswaran
2018-07-26 18:36   ` Arun Parameswaran
2018-07-26 19:01   ` Andrew Lunn
2018-07-26 19:01     ` Andrew Lunn
2018-07-26 19:15     ` Arun Parameswaran
2018-07-26 19:15       ` Arun Parameswaran
2018-07-26 18:36 ` [PATCH 2/7] net: phy: Fix the register offsets in Broadcom iProc mdio mux driver Arun Parameswaran
2018-07-26 18:36   ` Arun Parameswaran
2018-07-26 19:06   ` Andrew Lunn
2018-07-26 19:06     ` Andrew Lunn
2018-07-26 19:16     ` Arun Parameswaran
2018-07-26 19:16       ` Arun Parameswaran
2018-07-26 19:25       ` Ray Jui
2018-07-26 19:25         ` Ray Jui
2018-07-26 19:29         ` Andrew Lunn
2018-07-26 19:29           ` Andrew Lunn
2018-07-26 18:36 ` [PATCH 3/7] arm64: dts: Fix the base address of the Broadcom iProc mdio mux Arun Parameswaran
2018-07-26 18:36   ` Arun Parameswaran
2018-07-26 18:36 ` [PATCH 4/7] dt-bindings: net: Add clock handle to " Arun Parameswaran
2018-07-26 18:36   ` Arun Parameswaran
2018-07-26 18:36 ` [PATCH 5/7] net: phy: Add support to configure clock in " Arun Parameswaran
2018-07-26 18:36   ` Arun Parameswaran
2018-07-26 19:13   ` Andrew Lunn
2018-07-26 19:13     ` Andrew Lunn
2018-07-26 19:20     ` Arun Parameswaran
2018-07-26 19:20       ` Arun Parameswaran
2018-07-26 19:26   ` Andrew Lunn [this message]
2018-07-26 19:26     ` Andrew Lunn
2018-07-26 20:00     ` Arun Parameswaran
2018-07-26 20:00       ` Arun Parameswaran
2018-07-26 18:36 ` [PATCH 6/7] net: phy: Add pm support to Broadcom iProc mdio mux driver Arun Parameswaran
2018-07-26 18:36   ` Arun Parameswaran
2018-07-26 19:16   ` Andrew Lunn
2018-07-26 19:16     ` Andrew Lunn
2018-07-26 18:36 ` [PATCH 7/7] net: phy: Add pm support for scan ctrl register to bcm mdio mux Arun Parameswaran
2018-07-26 18:36   ` Arun Parameswaran
2018-07-26 19:20   ` Andrew Lunn
2018-07-26 19:20     ` Andrew Lunn
2018-07-26 19:33     ` Arun Parameswaran
2018-07-26 19:33       ` Arun Parameswaran
2018-07-26 19:36       ` Andrew Lunn
2018-07-26 19:36         ` Andrew Lunn
2018-07-26 19:51         ` Arun Parameswaran
2018-07-26 19:51           ` Arun Parameswaran
2018-07-26 18:52 ` [PATCH 0/7] Add clock config and pm support to bcm iProc " Andrew Lunn
2018-07-26 18:52   ` Andrew Lunn
2018-07-26 19:00   ` Arun Parameswaran
2018-07-26 19:00     ` Arun Parameswaran

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180726192651.GK10686@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.