From: Andrew Lunn <andrew@lunn.ch>
To: Daniel Schultz <d.schultz@phytec.de>
Cc: robh+dt@kernel.org, mark.rutland@arm.com, f.fainelli@gmail.com,
netdev@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] net: phy: dp83867: Add binding for the CLK_OUT pin muxing option
Date: Tue, 13 Feb 2018 14:42:26 +0100 [thread overview]
Message-ID: <20180213134226.GA31407@lunn.ch> (raw)
In-Reply-To: <1518514952-22392-1-git-send-email-d.schultz@phytec.de>
On Tue, Feb 13, 2018 at 10:42:31AM +0100, Daniel Schultz wrote:
> From: Wadim Egorov <w.egorov@phytec.de>
>
> The DP83867 has a muxing option for the CLK_OUT pin. It is possible
> to set CLK_OUT for different channels.
> Create a binding to select a specific clock for CLK_OUT pin.
>
> Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
> Signed-off-by: Daniel Schultz <d.schultz@phytec.de>
> ---
> drivers/net/phy/dp83867.c | 14 ++++++++++++++
> include/dt-bindings/net/ti-dp83867.h | 14 ++++++++++++++
> 2 files changed, 28 insertions(+)
>
> diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c
> index c1ab976..ffb97c2 100644
> --- a/drivers/net/phy/dp83867.c
> +++ b/drivers/net/phy/dp83867.c
> @@ -75,6 +75,8 @@
>
> #define DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX 0x0
> #define DP83867_IO_MUX_CFG_IO_IMPEDANCE_MIN 0x1f
> +#define DP83867_IO_MUX_CFG_CLK_O_SEL_MASK (0x1f << 8)
> +#define DP83867_IO_MUX_CFG_CLK_O_SEL_SHIFT 8
>
> /* CFG4 bits */
> #define DP83867_CFG4_PORT_MIRROR_EN BIT(0)
> @@ -92,6 +94,7 @@ struct dp83867_private {
> int io_impedance;
> int port_mirroring;
> bool rxctrl_strap_quirk;
> + int clk_output_sel;
> };
>
> static int dp83867_ack_interrupt(struct phy_device *phydev)
> @@ -160,6 +163,11 @@ static int dp83867_of_init(struct phy_device *phydev)
> dp83867->io_impedance = -EINVAL;
>
> /* Optional configuration */
> + if (of_property_read_u32(of_node, "ti,clk-output-sel",
> + &dp83867->clk_output_sel))
> + /* Keep the default value if ti,clk-output-sel is not set */
> + dp83867->clk_output_sel = DP83867_CLK_O_SEL_REF_CLK;
> +
Hi Daniel
Normally you don't put registers values into device tree. But in this
case, i don't see a better alternative.
Please add a range check. Values > 01101 are reserved.
> if (of_property_read_bool(of_node, "ti,max-output-impedance"))
> dp83867->io_impedance = DP83867_IO_MUX_CFG_IO_IMPEDANCE_MAX;
> else if (of_property_read_bool(of_node, "ti,min-output-impedance"))
> @@ -295,6 +303,12 @@ static int dp83867_config_init(struct phy_device *phydev)
> if (dp83867->port_mirroring != DP83867_PORT_MIRROING_KEEP)
> dp83867_config_port_mirroring(phydev);
>
> + /* Clock output selection */
> + val = phy_read_mmd(phydev, DP83867_DEVADDR, DP83867_IO_MUX_CFG);
> + val &= ~DP83867_IO_MUX_CFG_CLK_O_SEL_MASK;
This could be a problem. If i'm reading the datasheet correctly,
clearing this bit will override the strapping. A hardware engineer
might of included a resistor to disable the clock output, saving some
power. And here you unconditionally turn it back on again. Since
ti,clk-output-sel is optional, i would prefer that you don't touch
this register if the property is not present.
Andrew
prev parent reply other threads:[~2018-02-13 13:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-02-13 9:42 [PATCH 1/2] net: phy: dp83867: Add binding for the CLK_OUT pin muxing option Daniel Schultz
2018-02-13 9:42 ` [PATCH 2/2] net: phy: dp83867: Add documentation for CLK_OUT pin muxing Daniel Schultz
2018-02-13 13:42 ` Andrew Lunn [this message]
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=20180213134226.GA31407@lunn.ch \
--to=andrew@lunn.ch \
--cc=d.schultz@phytec.de \
--cc=devicetree@vger.kernel.org \
--cc=f.fainelli@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=netdev@vger.kernel.org \
--cc=robh+dt@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).