public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Patrice CHOTARD <patrice.chotard@st.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 06/21] usb: ehci: Add STi ehci support
Date: Thu, 23 Mar 2017 09:59:38 +0000	[thread overview]
Message-ID: <5363586d-a30a-44ea-e9a3-46997e6dbebe@st.com> (raw)
In-Reply-To: <CAPnjgZ2RRWOfdA5erpCtOJr8w7_MnqWFxtXthymcYJw6fDavMw@mail.gmail.com>

Hi Simon

On 03/22/2017 02:05 PM, Simon Glass wrote:
> Hi,
>
> On 17 March 2017 at 10:25,  <patrice.chotard@st.com> wrote:
>> From: Patrice Chotard <patrice.chotard@st.com>
>>
>> Add support for on-chip ehci controller available
>> on STMicrolectronics SoCs.
>> ehci support will be then available on both type A
>> USB 2.0 connectors.
>>
>> Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
>> ---
>>  drivers/usb/host/Kconfig    |  9 +++++
>>  drivers/usb/host/Makefile   |  1 +
>>  drivers/usb/host/ehci-sti.c | 91 +++++++++++++++++++++++++++++++++++++++++++++
>>  3 files changed, 101 insertions(+)
>>  create mode 100644 drivers/usb/host/ehci-sti.c
>>
>> diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
>> index 5129a57..d66f49e 100644
>> --- a/drivers/usb/host/Kconfig
>> +++ b/drivers/usb/host/Kconfig
>> @@ -120,6 +120,15 @@ config USB_EHCI_MSM
>>           This driver supports combination of Chipidea USB controller
>>           and Synapsys USB PHY in host mode only.
>>
>> +config USB_EHCI_STI
>> +       bool "Support for STMicroelectronics on-chip EHCI USB controller"
>> +       depends on ARCH_STI
>> +       select STI_PHY_USB
>> +       default y
>> +       ---help---
>> +         Enables support for the on-chip EHCI controller on
>> +         STMicroelectronics SoCs.
>> +
>>  config USB_EHCI_ZYNQ
>>         bool "Support for Xilinx Zynq on-chip EHCI USB controller"
>>         depends on ARCH_ZYNQ
>> diff --git a/drivers/usb/host/Makefile b/drivers/usb/host/Makefile
>> index 58c0cf5..303aa32 100644
>> --- a/drivers/usb/host/Makefile
>> +++ b/drivers/usb/host/Makefile
>> @@ -46,6 +46,7 @@ obj-$(CONFIG_USB_EHCI_MARVELL) += ehci-marvell.o
>>  obj-$(CONFIG_USB_EHCI_MSM) += ehci-msm.o
>>  obj-$(CONFIG_USB_EHCI_PCI) += ehci-pci.o
>>  obj-$(CONFIG_USB_EHCI_SPEAR) += ehci-spear.o
>> +obj-$(CONFIG_USB_EHCI_STI) += ehci-sti.o
>>  obj-$(CONFIG_USB_EHCI_SUNXI) += ehci-sunxi.o
>>  obj-$(CONFIG_USB_EHCI_TEGRA) += ehci-tegra.o
>>  obj-$(CONFIG_USB_EHCI_VCT) += ehci-vct.o
>> diff --git a/drivers/usb/host/ehci-sti.c b/drivers/usb/host/ehci-sti.c
>> new file mode 100644
>> index 0000000..89ca66a
>> --- /dev/null
>> +++ b/drivers/usb/host/ehci-sti.c
>> @@ -0,0 +1,91 @@
>> +/*
>> + * Copyright (c) 2017
>> + * Patrice Chotard <patrice.chotard@st.com>
>> + *
>> + * SPDX-License-Identifier:    GPL-2.0+
>> + */
>> +
>> +#include <common.h>
>> +#include <asm/io.h>
>> +#include <dm.h>
>> +#include <errno.h>
>> +#include "ehci.h"
>> +#include <reset-uclass.h>
>> +#include <usb.h>
>> +
>> +DECLARE_GLOBAL_DATA_PTR;
>> +
>> +struct sti_ehci_priv {
>> +       struct ehci_ctrl ctrl;
>> +       struct reset_ctl power_ctl;
>> +       struct reset_ctl softreset_ctl;
>> +};
>> +
>> +static int sti_ehci_probe(struct udevice *dev)
>> +{
>> +       struct sti_ehci_priv *priv = dev_get_priv(dev);
>> +       struct ehci_hccr *hccr = priv->ctrl.hccr;
>> +       struct ehci_hcor *hcor;
>> +       struct udevice *dev_phy;
>> +       int ret, phy_node;
>> +
>> +       hccr = (struct ehci_hccr *)dev_get_addr(dev);
>> +
>> +       if (hccr == (void *)FDT_ADDR_T_NONE)
>> +               return -EINVAL;
>> +
>> +       ret = reset_get_by_name(dev, "power", &priv->power_ctl);
>
> This is OK, but can you instead access it via a phandle in the device's node?

Sorry i didn't get your point. Why getting it using a phandle ?

>
>> +       if (ret) {
>> +               error("can't get power reset for %s (%d)", dev->name, ret);
>> +               return ret;
>> +       }
>> +
>> +       ret = reset_get_by_name(dev, "softreset", &priv->softreset_ctl);
>> +       if (ret) {
>> +               error("can't get soft reset for %s (%d)", dev->name, ret);
>> +               return ret;
>> +       }
>> +
>> +       ret = reset_deassert(&priv->power_ctl);
>> +       if (ret < 0) {
>> +               error("EHCI power reset deassert failed: %d", ret);
>> +               return ret;
>> +       }
>> +
>> +       ret = reset_deassert(&priv->softreset_ctl);
>> +       if (ret < 0) {
>> +               error("EHCI soft reset deassert failed: %d", ret);
>> +               return ret;
>> +       }
>> +
>> +       /* get phy node */
>> +       phy_node = fdtdec_lookup_phandle(gd->fdt_blob, dev->of_offset, "phys");
>> +       if (phy_node <= 0) {
>> +               error("Not found usb phy device\n");
>> +               return -ENODEV;
>> +       }
>> +
>> +       /* probe associated phy */
>> +       ret = uclass_get_device_by_of_offset(UCLASS_MISC, phy_node, &dev_phy);
>
> Instead of the above two calls, can you use uclass_get_device_by_phandle()?

Yes, agree, i will also apply this to ohci-sti.c and xhci-sti.c which 
are similar .

Thanks

Patrice

>
>> +
>> +       hcor = (struct ehci_hcor *)((phys_addr_t)hccr +
>> +                       HC_LENGTH(ehci_readl(&(hccr)->cr_capbase)));
>> +
>> +       return ehci_register(dev, hccr, hcor, NULL, 0, USB_INIT_HOST);
>> +}
>> +
>> +static const struct udevice_id sti_usb_ids[] = {
>> +       { .compatible = "st,st-ehci-300x" },
>> +       { }
>> +};
>> +
>> +U_BOOT_DRIVER(ehci_sti) = {
>> +       .name = "ehci_sti",
>> +       .id = UCLASS_USB,
>> +       .of_match = sti_usb_ids,
>> +       .probe = sti_ehci_probe,
>> +       .remove = ehci_deregister,
>> +       .ops = &ehci_usb_ops,
>> +       .priv_auto_alloc_size = sizeof(struct sti_ehci_priv),
>> +       .flags  = DM_FLAG_ALLOC_PRIV_DMA,
>> +};
>> --
>> 1.9.1
>>
>
> Regards,
> Simon
>

  reply	other threads:[~2017-03-23  9:59 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-17 16:25 [U-Boot] [PATCH 00/21] STiH410-B2260: add reset, usb and fastboot support patrice.chotard at st.com
2017-03-17 16:25 ` [U-Boot] [PATCH 01/21] reset: Add STi reset support patrice.chotard at st.com
2017-03-22 13:05   ` Simon Glass
2017-03-17 16:25 ` [U-Boot] [PATCH 02/21] mmc: sti_sdhci: Rework sti_mmc_core_config() patrice.chotard at st.com
2017-03-21 22:31   ` Jaehoon Chung
2017-03-17 16:25 ` [U-Boot] [PATCH 03/21] ARM: dts: stih410-family: Add missing reset_names for mmc1 node patrice.chotard at st.com
2017-03-21 22:31   ` Jaehoon Chung
2017-03-17 16:25 ` [U-Boot] [PATCH 04/21] mmc: sti_sdhci: Use reset framework patrice.chotard at st.com
2017-03-21 22:33   ` Jaehoon Chung
2017-03-17 16:25 ` [U-Boot] [PATCH 05/21] phy: Add STi phy usb support patrice.chotard at st.com
2017-03-17 16:38   ` Marek Vasut
2017-03-20 10:14     ` Patrice CHOTARD
2017-03-22 13:06   ` Simon Glass
2017-03-23  8:09     ` Patrice CHOTARD
2017-03-17 16:25 ` [U-Boot] [PATCH 06/21] usb: ehci: Add STi ehci support patrice.chotard at st.com
2017-03-17 16:40   ` Marek Vasut
2017-03-20  8:39     ` Patrice CHOTARD
2017-03-22 13:05   ` Simon Glass
2017-03-23  9:59     ` Patrice CHOTARD [this message]
2017-04-01  4:21       ` Simon Glass
2017-04-03  9:39         ` Patrice CHOTARD
2017-04-09 19:27           ` Simon Glass
2017-04-18  6:56             ` Patrice CHOTARD
2017-04-19  0:12               ` Simon Glass
2017-03-17 16:25 ` [U-Boot] [PATCH 07/21] STiH410-B2260: enable USB related flags patrice.chotard at st.com
2017-03-17 16:25 ` [U-Boot] [PATCH 08/21] usb: ohci: Add STi ohci support patrice.chotard at st.com
2017-03-17 16:41   ` Marek Vasut
2017-03-20  8:41     ` Patrice CHOTARD
2017-03-17 16:25 ` [U-Boot] [PATCH 09/21] STiH410-B2260: enable OHCI related flags patrice.chotard at st.com
2017-03-17 16:25 ` [U-Boot] [PATCH 10/21] usb: xhci: Add STi xhci support patrice.chotard at st.com
2017-03-17 16:25 ` [U-Boot] [PATCH 11/21] STiH410-B2260: enable XHCI related flags patrice.chotard at st.com
2017-03-17 16:25 ` [U-Boot] [PATCH 12/21] STiH410-B2260: Enabling USB Host Networking patrice.chotard at st.com
2017-03-17 16:25 ` [U-Boot] [PATCH 13/21] usb: dwc3: Add dwc3 support for STi patrice.chotard at st.com
2017-03-17 16:42   ` Marek Vasut
2017-03-20 13:45     ` Patrice CHOTARD
2017-03-17 16:25 ` [U-Boot] [PATCH 14/21] STiH410-B2260: enable DWC3 support patrice.chotard at st.com
2017-03-17 16:25 ` [U-Boot] [PATCH 15/21] board: STiH410-B2260: add fastboot support patrice.chotard at st.com
2017-03-17 16:25 ` [U-Boot] [PATCH 16/21] STiH410-B2260: enable USB download gadget related flags patrice.chotard at st.com
2017-03-17 16:25 ` [U-Boot] [PATCH 17/21] STiH410-B2260: enable FASTBOOT " patrice.chotard at st.com
2017-03-17 16:25 ` [U-Boot] [PATCH 18/21] STiH410-B2260: enable OF_LIBFDT_OVERLAY patrice.chotard at st.com
2017-03-17 16:25 ` [U-Boot] [PATCH 19/21] STiH410-B2260: enable CMD_EXT4_WRITE patrice.chotard at st.com
2017-03-17 16:25 ` [U-Boot] [PATCH 20/21] STiH410-B2260: enable CMD_GPT patrice.chotard at st.com
2017-03-17 16:25 ` [U-Boot] [PATCH 21/21] STiH410-B2260: enable CMD_PART patrice.chotard at st.com
2017-03-17 16:42   ` Marek Vasut
2017-03-20 13:45     ` Patrice CHOTARD
2017-03-22  9:56 ` [U-Boot] [PATCH 00/21] STiH410-B2260: add reset, usb and fastboot support Patrice CHOTARD

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=5363586d-a30a-44ea-e9a3-46997e6dbebe@st.com \
    --to=patrice.chotard@st.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