netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Duan Fugang-B38611 <B38611@freescale.com>
To: Sean Cross <xobs@kosagi.com>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>
Cc: David Miller <davem@davemloft.net>,
	"stephen@networkplumber.org" <stephen@networkplumber.org>,
	Steven Rostedt <rostedt@goodmis.org>
Subject: RE: [PATCH v5] net/phy: micrel: Add OF configuration support for ksz9021
Date: Mon, 5 Aug 2013 07:41:11 +0000	[thread overview]
Message-ID: <9848F2DB572E5649BA045B288BE08FBE015EECA0@039-SN2MPN1-023.039d.mgd.msft.net> (raw)
In-Reply-To: <1375686248-17995-2-git-send-email-xobs@kosagi.com>

From: Sean Cross [mailto:xobs@kosagi.com]
Data: Monday, August 05, 2013 3:04 PM
> To: Sascha Hauer; Duan Fugang-B38611; netdev@vger.kernel.org;
> devicetree@vger.kernel.org
> Cc: David Miller; stephen@networkplumber.org; Steven Rostedt; Sean Cross
> Subject: [PATCH v5] net/phy: micrel: Add OF configuration support for
> ksz9021
> 
> Some boards require custom PHY configuration, for example due to trace
> length differences.  Add the ability to configure these registers in order
> to get the PHY to function on boards that need it.
> 
> Because PHYs are auto-detected based on MDIO device IDs, allow PHY
> configuration to be specified in the parent Ethernet device node if no PHY
> device node is present.
> 
> Signed-off-by: Sean Cross <xobs@kosagi.com>
> ---
> +static int ksz9021_load_values_from_of(struct phy_device *phydev,
> +				       struct device_node *of_node, u16 reg,
> +				       char *field1, char *field2,
> +				       char *field3, char *field4)
> +{
> +	int val1 = -1;
> +	int val2 = -2;
> +	int val3 = -3;
> +	int val4 = -4;
> +	int newval;
> +	int matches = 0;
> +
> +	if (!of_property_read_u32(of_node, field1, &val1))
> +		matches++;
> +
> +	if (!of_property_read_u32(of_node, field2, &val2))
> +		matches++;
> +
> +	if (!of_property_read_u32(of_node, field3, &val3))
> +		matches++;
> +
> +	if (!of_property_read_u32(of_node, field4, &val4))
> +		matches++;
> +
> +	if (!matches)
> +		return 0;
> +
> +	if (matches < 4)
> +		newval = kszphy_extended_read(phydev, reg);
> +	else
> +		newval = 0;
> +
> +	if (val1 != -1)
> +		newval = ((newval & 0xfff0) | ((val1/200)&0xf) << 0);
> +
> +	if (val2 != -1)
> +		newval = ((newval & 0xff0f) | ((val2/200)&0xf) << 4);
Must be :  Newval |= ...
> +
> +	if (val3 != -1)
> +		newval = ((newval & 0xf0ff) | ((val3/200)&0xf) << 8);
Must be :  Newval |= ...
> +
> +	if (val4 != -1)
> +		newval = ((newval & 0x0fff) | ((val4/200)&0xf) << 12);
Must be :  Newval |= ...
> +
> +	return kszphy_extended_write(phydev, reg, newval); }

  reply	other threads:[~2013-08-05  7:42 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-05  7:04 [PATCH v5] Add OF bindings to Micrel ksz9021 PHY Sean Cross
2013-08-05  7:04 ` [PATCH v5] net/phy: micrel: Add OF configuration support for ksz9021 Sean Cross
2013-08-05  7:41   ` Duan Fugang-B38611 [this message]
2013-08-05  7:54     ` Sean Cross
2013-08-05  7:58   ` Sascha Hauer
2013-08-05  8:12     ` Sean Cross
2013-08-20  8:34       ` Sean Cross
2013-08-20  8:50         ` Duan Fugang-B38611
2013-08-20 18:35         ` David Miller
2013-08-20  9:17   ` Sascha Hauer

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=9848F2DB572E5649BA045B288BE08FBE015EECA0@039-SN2MPN1-023.039d.mgd.msft.net \
    --to=b38611@freescale.com \
    --cc=davem@davemloft.net \
    --cc=devicetree@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=s.hauer@pengutronix.de \
    --cc=stephen@networkplumber.org \
    --cc=xobs@kosagi.com \
    /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).