All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chin Liang See <clsee@altera.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/7] net: phy: micrel: Configure KSZ9021/KSZ9031 skew from OF
Date: Mon, 7 Dec 2015 18:00:21 +0800	[thread overview]
Message-ID: <1449482421.2061.3.camel@altera.com> (raw)
In-Reply-To: <1449348111-18341-1-git-send-email-marex@denx.de>

On Sat, 2015-12-05 at 21:41 +0100, Marek Vasut wrote:
> Add code to process the KSZ9021/KSZ9031 OF props if they are present
> and configure skew registers based on the information from the OF.
> This code is only enabled if the DM support for ethernet is also
> enabled.
> 

Nice as I noticed the value in dts was not used previously.


> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: Chin Liang See <clsee@altera.com>
> Cc: Dinh Nguyen <dinguyen@opensource.altera.com>
> ---
>  drivers/net/phy/micrel.c | 127
> ++++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 126 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
> index 5e49666..a379230 100644
> --- a/drivers/net/phy/micrel.c
> +++ b/drivers/net/phy/micrel.c
> @@ -9,9 +9,14 @@
>   */
>  #include <config.h>
>  #include <common.h>
> +#include <dm.h>
> +#include <errno.h>
> +#include <fdtdec.h>
>  #include <micrel.h>
>  #include <phy.h>
>  
> +DECLARE_GLOBAL_DATA_PTR;
> +
>  static struct phy_driver KSZ804_driver = {
>  	.name = "Micrel KSZ804",
>  	.uid = 0x221510,
> @@ -174,6 +179,58 @@ static int ksz90xx_startup(struct phy_device
> *phydev)
>  	return 0;
>  }
>  
> +/* Common OF config bits for KSZ9021 and KSZ9031 */
> +#if defined(CONFIG_PHY_MICREL_KSZ9021) ||
> defined(CONFIG_PHY_MICREL_KSZ9031)
> +#ifdef CONFIG_DM_ETH
> +struct ksz90x1_ofcfg {
> +	u16		reg;
> +	u16		devad;
> +	const char	**grp;
> +	u16		grpsz;
> +};
> +
> +static const char *ksz90x1_rxd_grp[] =
> +	{ "rxd0-skew-ps", "rxd1-skew-ps", "rxd2-skew-ps", "rxd3-skew
> -ps" };
> +static const char *ksz90x1_txd_grp[] =
> +	{ "txd0-skew-ps", "txd1-skew-ps", "txd2-skew-ps", "txd3-skew
> -ps" };
> +
> +static int ksz90x1_of_config_group(struct phy_device *phydev,
> +				   struct ksz90x1_ofcfg *ofcfg)
> +{
> +	struct udevice *dev = phydev->dev;
> +	struct phy_driver *drv = phydev->drv;
> +	const int ps_to_regval = 200;
> +	int val[4];
> +	int i, changed = 0;
> +	u16 regval = 0;
> +
> +	if (!drv || !drv->writeext)
> +		return -EOPNOTSUPP;
> +
> +	for (i = 0; i < ofcfg->grpsz; i++) {
> +		val[i] = fdtdec_get_uint(gd->fdt_blob, dev
> ->of_offset,
> +					 ofcfg->grp[i], -1);
> +		if (val[i] == -1) {
> +			/* Default register value for KSZ9021 */
> +			regval |= 0x7 << (4 * i);

I noticed the KSZ9031 clock skew is having 5 bit with default value 0xF
instead 0x7. Probably this default value and bit width should part of
structure?


> +		} else {
> +			changed = 1;	/* Value was changed in
> OF */
> +			/* Calculate the register value and fix
> corner cases */
> +			if (val[i] > ps_to_regval * 0xf)
> +				regval |= 0xf << (4 * i);
> +			else
> +				regval |= (val[i] / ps_to_regval) <<
> (4 * i);

Same as above where 9031 clock skew field is 5 bit.

Thanks
Chin Liang

  parent reply	other threads:[~2015-12-07 10:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-05 20:41 [U-Boot] [PATCH 1/7] net: phy: micrel: Configure KSZ9021/KSZ9031 skew from OF Marek Vasut
2015-12-05 20:41 ` [U-Boot] [PATCH 2/7] arm: socfpga: socrates: Add missing PHY skew config Marek Vasut
2015-12-07  7:00   ` Chin Liang See
2015-12-05 20:41 ` [U-Boot] [PATCH 3/7] arm: socfpga: arria5-socdk: Remove Micrel PHY configuration Marek Vasut
2015-12-07 12:10   ` Chin Liang See
2015-12-05 20:41 ` [U-Boot] [PATCH 4/7] arm: socfpga: cyclone5-socdk: " Marek Vasut
2015-12-07 12:12   ` Chin Liang See
2015-12-05 20:41 ` [U-Boot] [PATCH 5/7] arm: socfpga: de0_nano: " Marek Vasut
2015-12-07 12:13   ` Chin Liang See
2015-12-05 20:41 ` [U-Boot] [PATCH 6/7] arm: socfpga: sockit: " Marek Vasut
2015-12-07 12:14   ` Chin Liang See
2015-12-05 20:41 ` [U-Boot] [PATCH 7/7] arm: socfpga: socrates: " Marek Vasut
2015-12-07 12:14   ` Chin Liang See
2015-12-07 10:00 ` Chin Liang See [this message]
2015-12-07 12:21   ` [U-Boot] [PATCH 1/7] net: phy: micrel: Configure KSZ9021/KSZ9031 skew from OF Marek Vasut
2015-12-07 13:18 ` [U-Boot] [PATCH V2 " Marek Vasut
2015-12-07 13:39   ` Chin Liang See

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=1449482421.2061.3.camel@altera.com \
    --to=clsee@altera.com \
    --cc=u-boot@lists.denx.de \
    /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.