public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Tom Rini <trini@konsulko.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH v3 7/7] cmd: Add bind/unbind commands to bind a device to a driver from the command line
Date: Wed, 11 Jul 2018 09:40:07 -0400	[thread overview]
Message-ID: <20180711134007.GJ27264@bill-the-cat> (raw)
In-Reply-To: <f363b3c1-e35b-f8e6-f26b-bd2463c31d07@xilinx.com>

On Wed, Jul 11, 2018 at 03:31:39PM +0200, Michal Simek wrote:
> On 11.7.2018 14:46, Tom Rini wrote:
> > On Wed, Jul 11, 2018 at 07:57:13AM +0200, Michal Simek wrote:
> >> On 10.7.2018 18:40, Tom Rini wrote:
> >>> On Mon, Jul 09, 2018 at 11:59:57AM -0500, Joe Hershberger wrote:
> >>>> On Mon, Jul 9, 2018 at 9:43 AM, Tom Rini <trini@konsulko.com> wrote:
> >>>>> On Mon, Jul 09, 2018 at 08:19:44AM +0200, Michal Simek wrote:
> >>>>>> On 30.6.2018 06:19, Simon Glass wrote:
> >>>>>>> On 27 June 2018 at 07:13, Michal Simek <michal.simek@xilinx.com> wrote:
> >>>>>>>> On 22.6.2018 14:25, Jean-Jacques Hiblot wrote:
> >>>>>>>>> In some cases it can be useful to be able to bind a device to a driver from
> >>>>>>>>> the command line.
> >>>>>>>>> The obvious example is for versatile devices such as USB gadget.
> >>>>>>>>> Another use case is when the devices are not yet ready at startup and
> >>>>>>>>> require some setup before the drivers are bound (ex: FPGA which bitsream is
> >>>>>>>>> fetched from a mass storage or ethernet)
> >>>>>>>>>
> >>>>>>>>> usage example:
> >>>>>>>>>
> >>>>>>>>> bind usb_dev_generic 0 usb_ether
> >>>>>>>>> unbind usb_dev_generic 0 usb_ether
> >>>>>>>>> or
> >>>>>>>>> unbind eth 1
> >>>>>>>>>
> >>>>>>>>> bind /ocp/omap_dwc3 at 48380000/usb at 48390000 usb_ether
> >>>>>>>>> unbind /ocp/omap_dwc3 at 48380000/usb at 48390000
> >>>>>>>>>
> >>>>>>>>> Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
> >>>>>>>>>
> >>>>>>>>> ---
> >>>>>>>>>
> >>>>>>>>> Changes in v3:
> >>>>>>>>> - factorize code based on comments from ML
> >>>>>>>>> - remove the devices before unbinding them
> >>>>>>>>> - use device_find_global_by_ofnode() to get a device by its node.
> >>>>>>>>> - Added tests
> >>>>>>>>>
> >>>>>>>>> Changes in v2:
> >>>>>>>>> - Make the bind/unbind command generic, not specific to usb device.
> >>>>>>>>> - Update the API to be able to bind/unbind based on DTS node path
> >>>>>>>>> - Add a Kconfig option to select the bind/unbind commands
> >>>>>>>>>
> >>>>>>>>>  arch/sandbox/dts/test.dts  |  11 ++
> >>>>>>>>>  cmd/Kconfig                |   9 ++
> >>>>>>>>>  cmd/Makefile               |   1 +
> >>>>>>>>>  cmd/bind.c                 | 255 +++++++++++++++++++++++++++++++++++++++++++++
> >>>>>>>>>  configs/sandbox_defconfig  |   1 +
> >>>>>>>>>  test/py/tests/test_bind.py | 178 +++++++++++++++++++++++++++++++
> >>>>>>>>>  6 files changed, 455 insertions(+)
> >>>>>>>>>  create mode 100644 cmd/bind.c
> >>>>>>>>>  create mode 100644 test/py/tests/test_bind.py
> >>>>>>>
> >>>>>>> Reviewed-by: Simon Glass <sjg@chromium.org>
> >>>>>>>
> >>>>>>> Nice work
> >>>>>>>
> >>>>>>> [...]
> >>>>>>>
> >>>>>>>>
> >>>>>>>> I have tested bind/unbind with dwc3 on zynqmp for ethernet gadget and it
> >>>>>>>> is working fine for me.
> >>>>>>>> I have also tried to use bind/unbind for gpio zynqmp driver and it is
> >>>>>>>> also working fine.
> >>>>>>>>
> >>>>>>>> It means
> >>>>>>>> Tested-by: Michal Simek <michal.simek@xilinx.com>
> >>>>>>>>
> >>>>>>>> I would prefer if these commands are called as dm bind and dm unbind
> >>>>>>>> instead of simply bind/unbind which should also fit to dm command
> >>>>>>>> description "dm - Driver model low level access".
> >>>>>>>
> >>>>>>> Yes i can see the point. But after thinking about it, maybe it is best
> >>>>>>> as it is? After all driver model is fundamental to U-Boot and it's not
> >>>>>>> clear what else we might bind/unbind.
> >>>>>>>
> >>>>>>> I'd like to get other opinions here, too.
> >>>>>>
> >>>>>> Tom/Marek: Any opinion?
> >>>>>
> >>>>> I think dm bind/unbind makes sense, yes.  "bind" and "unbind" are pretty
> >>>>> generic terms and making it clear it's part of working "inside" of DM to
> >>>>> hook/unhook things by making it a sub-command of dm sounds good.
> >>>>> Thanks!
> >>>>
> >>>> I agree with Simon here. I think bind and unbind won't have any
> >>>> plausible other meaning in U-Boot and DM is core to U-Boot
> >>>> functionality in the new world. I think it would be OK to have "dm
> >>>> bind" alias to "bind" if that's a point of confusion, but having it
> >>>> top-level seems good to me.
> >>>
> >>> They're still very generic words for something that's part of working
> >>> under the dm framework.  That said, looking at test/dm/cmd_dm.c and that
> >>> it's supposed to be only for test/debug type work, yes, OK, I'll change
> >>> my mind.
> >>
> >> I would expect that almost everybody will enable CMD_DM where symbol is
> >> in cmd/Kconfig but implementation in test/dm/cmd_dm.c (it is a question
> >> if this is the right place for this file).
> > 
> > It might well really belong as cmd/dm.c, but content wise it's debug
> > information that is also useful in the bind/unbind case (so you know
> > where U-Boot sees things as being at).
> 
> Then we should really not enable it by default for all boards with DM on.
> 
>  640 config CMD_DM
>  641         bool "dm - Access to driver model information"
>  642         depends on DM
>  643         default y

Simon?

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180711/9a298a66/attachment.sig>

  reply	other threads:[~2018-07-11 13:40 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-22 12:25 [U-Boot] [PATCH v3 0/7] Fixes/Addition to use the USB Ethernet gadget with the DWC3 gadget controller Jean-Jacques Hiblot
2018-06-22 12:25 ` [U-Boot] [PATCH v3 1/7] usb: gadget: Add bcdDevice for the DWC3 USB Gadget Controller Jean-Jacques Hiblot
2018-06-22 12:25 ` [U-Boot] [PATCH v3 2/7] net: eth-uclass: Fix for DM USB ethernet support Jean-Jacques Hiblot
2018-06-22 12:25 ` [U-Boot] [PATCH v3 3/7] uclass: Add dev_get_uclass_index() to get the uclass/index of a device Jean-Jacques Hiblot
2018-06-30  4:19   ` Simon Glass
2018-07-04 13:10     ` Jean-Jacques Hiblot
2018-06-22 12:25 ` [U-Boot] [PATCH v3 4/7] dm: print the index of the device when dumping the dm tree Jean-Jacques Hiblot
2018-06-22 12:25 ` [U-Boot] [PATCH v3 5/7] dm: convert device_get_global_by_of_offset() to device_get_global_by_ofnode() Jean-Jacques Hiblot
2018-06-30  4:19   ` Simon Glass
2018-06-22 12:25 ` [U-Boot] [PATCH v3 6/7] device: expose the functions used to remove and unbind children of a device Jean-Jacques Hiblot
2018-06-30  4:19   ` Simon Glass
2018-06-22 12:25 ` [U-Boot] [PATCH v3 7/7] cmd: Add bind/unbind commands to bind a device to a driver from the command line Jean-Jacques Hiblot
2018-06-27 14:13   ` Michal Simek
2018-06-30  4:19     ` Simon Glass
2018-07-09  6:19       ` Michal Simek
2018-07-09 14:43         ` Tom Rini
2018-07-09 16:59           ` Joe Hershberger
2018-07-10 16:40             ` Tom Rini
2018-07-11  5:57               ` Michal Simek
2018-07-11 12:46                 ` Tom Rini
2018-07-11 13:31                   ` Michal Simek
2018-07-11 13:40                     ` Tom Rini [this message]
2018-07-11 20:13                       ` Simon Glass
2018-07-16  8:33                         ` Michal Simek
2018-07-17  3:44                           ` Simon Glass
2018-07-20 12:05                             ` Michal Simek
2018-07-11 13:57   ` Jagan Teki
2018-07-11 20:59   ` Eugeniu Rosca
2018-08-08  6:35 ` [U-Boot] [PATCH v3 0/7] Fixes/Addition to use the USB Ethernet gadget with the DWC3 gadget controller Michal Simek
2018-08-08  9:17   ` Eugeniu Rosca
2018-08-08  9:58     ` Michal Simek
2018-08-08 10:26       ` Eugeniu Rosca
2018-08-08 11:36     ` Jean-Jacques Hiblot
2018-08-08 13:08       ` Eugeniu Rosca
2018-08-08 16:17         ` Jean-Jacques Hiblot
2018-08-08 16:44           ` Eugeniu Rosca
2018-08-08 16:54             ` Tom Rini
2018-08-08 18:29               ` Eugeniu Rosca
2018-08-09 14:21               ` Jean-Jacques Hiblot

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=20180711134007.GJ27264@bill-the-cat \
    --to=trini@konsulko.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox