lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <B521A8659CBF426297A6B0D2EB3281DB@kosagi.com>
Date:	Mon, 5 Aug 2013 15:54:51 +0800
From:	Sean Cross <xobs@...agi.com>
To:	Duan Fugang-B38611 <B38611@...escale.com>
Cc:	Sascha Hauer <s.hauer@...gutronix.de>,
	"netdev@...r.kernel.org" <netdev@...r.kernel.org>,
	"devicetree@...r.kernel.org" 
	<devicetree@...r.kernel.org>, David Miller <davem@...emloft.net>,
	"stephen@...workplumber.org" 
	<stephen@...workplumber.org>, Steven Rostedt <rostedt@...dmis.org>
Subject: Re: [PATCH v5] net/phy: micrel: Add OF configuration support
 for ksz9021



-- 
Sean Cross


On Monday, August 5, 2013 at 3:41 PM, Duan Fugang-B38611 wrote:

> From: Sean Cross [mailto:xobs@...agi.com]
> Data: Monday, August 05, 2013 3:04 PM
> > To: Sascha Hauer; Duan Fugang-B38611; netdev@...r.kernel.org (mailto:netdev@...r.kernel.org);
> > devicetree@...r.kernel.org (mailto:devicetree@...r.kernel.org)
> > Cc: David Miller; stephen@...workplumber.org (mailto:stephen@...workplumber.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@...agi.com (mailto:xobs@...agi.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); }
> 

If all four fields are updated, then newval will start out as 0.  If only a few fields are updated, then newval will start out with the previous value.

If a given field is mentioned in the device tree file, then its value will change to something other than -1.  If the value remains at -1, then that particular field could not be found, and it should not be modified. 


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ