All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bin Meng <bmeng.cn@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/4 v3] net: add MDIO_MUX DM class
Date: Mon, 8 Jul 2019 15:40:42 +0800	[thread overview]
Message-ID: <CAEUhbmUKhtogbBVpcED4v+uwCRANg0NFq2bpG5Ecjm2px4Lnog@mail.gmail.com> (raw)
In-Reply-To: <20190618145823.606-1-alexandru.marginean@nxp.com>

On Tue, Jun 18, 2019 at 10:58 PM Alexandru Marginean
<alexandru.marginean@nxp.com> wrote:
>
> Adds a class for MDIO MUXes, which control access to a series of
> downstream child MDIOs.
> MDIO MUX drivers are required to implement a select function used to switch
> between child buses.
> MUX children are registered as MDIO buses and they can be used just like
> regular MDIOs.
>
> Signed-off-by: Alex Marginean <alexm.osslist@gmail.com>
> ---
>
> Changes in v2:
>         - no change
> Changes in v3:
>         - no change, just fighting with the email server
>
>  drivers/net/Kconfig    |  12 +++
>  include/dm/uclass-id.h |   1 +
>  include/miiphy.h       |  20 ++++
>  net/Makefile           |   1 +
>  net/mdio-mux-uclass.c  | 232 +++++++++++++++++++++++++++++++++++++++++
>  5 files changed, 266 insertions(+)
>  create mode 100644 net/mdio-mux-uclass.c
>
> diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig
> index 635f8d72c2..0dc26ac254 100644
> --- a/drivers/net/Kconfig
> +++ b/drivers/net/Kconfig
> @@ -24,6 +24,18 @@ config DM_MDIO
>           This is currently implemented in net/mdio-uclass.c
>           Look in include/miiphy.h for details.
>
> +config DM_MDIO_MUX
> +       bool "Enable Driver Model for MDIO MUX devices"
> +       depends on DM_MDIO
> +       help
> +         Enable driver model for MDIO MUX devices
> +
> +         Adds UCLASS_MDIO_MUX DM class supporting MDIO MUXes.  Useful for
> +         systems that support DM_MDIO and integrate one or multiple muxes on
> +         the MDIO bus.
> +         This is currently implemented in net/mdio-mux-uclass.c
> +         Look in include/miiphy.h for details.
> +
>  config MDIO_SANDBOX
>         depends on DM_MDIO && SANDBOX
>         default y
> diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
> index 90667e62cf..b859a9ec04 100644
> --- a/include/dm/uclass-id.h
> +++ b/include/dm/uclass-id.h
> @@ -59,6 +59,7 @@ enum uclass_id {
>         UCLASS_MAILBOX,         /* Mailbox controller */
>         UCLASS_MASS_STORAGE,    /* Mass storage device */
>         UCLASS_MDIO,            /* MDIO bus */
> +       UCLASS_MDIO_MUX,        /* MDIO MUX/switch */
>         UCLASS_MISC,            /* Miscellaneous device */
>         UCLASS_MMC,             /* SD / MMC card or chip */
>         UCLASS_MOD_EXP,         /* RSA Mod Exp device */
> diff --git a/include/miiphy.h b/include/miiphy.h
> index e6dd441983..9b97d09f18 100644
> --- a/include/miiphy.h
> +++ b/include/miiphy.h
> @@ -167,4 +167,24 @@ struct phy_device *dm_mdio_phy_connect(struct udevice *dev, int addr,
>
>  #endif
>
> +#ifdef CONFIG_DM_MDIO_MUX
> +
> +/* indicates none of the child buses is selected */
> +#define MDIO_MUX_SELECT_NONE   -1
> +
> +/**
> + * struct mdio_mux_ops - MDIO MUX operations
> + *
> + * @select: Selects a child bus
> + * @deselect: Clean up selection.  Optional, can be NULL
> + */
> +struct mdio_mux_ops {
> +       int (*select)(struct udevice *mux, int cur, int sel);
> +       int (*deselect)(struct udevice *mux, int sel);
> +};
> +
> +#define mdio_mux_get_ops(dev) ((struct mdio_mux_ops *)(dev)->driver->ops)
> +
> +#endif
> +
>  #endif
> diff --git a/net/Makefile b/net/Makefile
> index 6251ff3991..826544f05f 100644
> --- a/net/Makefile
> +++ b/net/Makefile
> @@ -16,6 +16,7 @@ else
>  obj-$(CONFIG_NET)      += eth_legacy.o
>  endif
>  obj-$(CONFIG_DM_MDIO)  += mdio-uclass.o
> +obj-$(CONFIG_DM_MDIO_MUX) += mdio-mux-uclass.o
>  obj-$(CONFIG_NET)      += eth_common.o
>  obj-$(CONFIG_CMD_LINK_LOCAL) += link_local.o
>  obj-$(CONFIG_NET)      += net.o
> diff --git a/net/mdio-mux-uclass.c b/net/mdio-mux-uclass.c
> new file mode 100644
> index 0000000000..e3fe12a531
> --- /dev/null
> +++ b/net/mdio-mux-uclass.c
> @@ -0,0 +1,232 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +/*
> + * (C) Copyright 2019
> + * Alex Marginean, NXP
> + */
> +
> +#include <common.h>
> +#include <dm.h>
> +#include <miiphy.h>
> +#include <dm/device-internal.h>
> +#include <dm/uclass-internal.h>
> +#include <dm/lists.h>
> +
> +#define MDIO_MUX_CHILD_DRV_NAME        "mdio-mux-bus-drv"
> +
> +/**
> + * struct mdio_mux_perdev_priv - Per-device class data for MDIO MUX DM
> + *
> + * @parent_mdio: Parent DM MDIO device, this is called for actual MDIO I/O after
> + *               setting up the mux.  Typically this is a real MDIO device,
> + *               unless there are cascaded muxes.
> + * @selected:    Current child bus selection.  Defaults to -1
> + */
> +struct mdio_mux_perdev_priv {
> +       struct udevice *mdio_parent;
> +       int selected;
> +};
> +
> +/*
> + * This source file uses three types of devices, as follows:
> + * - mux is the hardware MDIO MUX which selects between the existing child MDIO
> + * buses, this is the device relevant for MDIO MUX class of drivers.
> + * - ch is a child MDIO bus, this is just a representation of an mux selection,

nits: a mux selection

> + * not a real piece of hardware.
> + * - mdio_parent is the actual MDIO bus called to perform reads/writes  after

nits: 2 spaces before "after"

> + * the MUX is configured.  Typically this is a real MDIO device, unless there
> + * are cascaded muxes.
> + */
> +

[snip]

Other than above,
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>

Regards,
Bin

  parent reply	other threads:[~2019-07-08  7:40 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-18 14:58 [U-Boot] [PATCH 1/4 v3] net: add MDIO_MUX DM class Alexandru Marginean
2019-06-18 14:58 ` [U-Boot] [PATCH 2/4 v3] doc: bindings: Add description for MDIO MUX dts nodes Alexandru Marginean
2019-07-08  7:40   ` Bin Meng
2019-07-08 14:33     ` Alex Marginean
2019-06-18 14:58 ` [U-Boot] [PATCH 3/4 v3] test: dm_mdio: add a 2nd register to the emulated PHY Alexandru Marginean
2019-07-08  7:40   ` Bin Meng
2019-07-09 23:54   ` Joe Hershberger
2019-06-18 14:58 ` [U-Boot] [PATCH 4/4 v3] test: dm: add a test for MDIO MUX DM uclass Alexandru Marginean
2019-07-08  7:40   ` Bin Meng
2019-07-08 15:43     ` Alex Marginean
2019-07-08  7:40 ` Bin Meng [this message]
2019-07-09 23:49 ` [U-Boot] [PATCH 1/4 v3] net: add MDIO_MUX DM class Joe Hershberger

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=CAEUhbmUKhtogbBVpcED4v+uwCRANg0NFq2bpG5Ecjm2px4Lnog@mail.gmail.com \
    --to=bmeng.cn@gmail.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.