From: chunfeng.yun@mediatek.com (chunfeng yun)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v10 2/3] xhci: mediatek: support MTK xHCI host controller
Date: Mon, 19 Oct 2015 14:02:27 +0800 [thread overview]
Message-ID: <1445234547.28324.17.camel@mhfsdcap03> (raw)
In-Reply-To: <1445140279-18121-3-git-send-email-chunfeng.yun@mediatek.com>
On Sun, 2015-10-18 at 11:51 +0800, Chunfeng Yun wrote:
> There some vendor quirks for MTK xhci host controller:
> 1. It defines some extra SW scheduling parameters for HW
> to minimize the scheduling effort for synchronous and
> interrupt endpoints. The parameters are put into reseved
> DWs of slot context and endpoint context.
> 2. Its IMODI unit for Interrupter Moderation register is
> 8 times as much as that defined in xHCI spec.
> 3. Its TDS in Normal TRB defines a number of packets that
> remains to be transferred for a TD after processing all
> Max packets in all previous TRBs.
...
> + *
> + * This software is licensed under the terms of the GNU General Public
> + * License version 2, as published by the Free Software Foundation, and
> + * may be copied, distributed, and modified under those terms.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + */
> +
> +#include <linux/clk.h>
> +#include <linux/dma-mapping.h>
> +#include <linux/iopoll.h>
> +#include <linux/kernel.h>
> +#include <linux/mfd/syscon.h>
> +#include <linux/module.h>
> +#include <linux/of.h>
> +#include <linux/phy/phy.h>
> +#include <linux/platform_device.h>
> +#include <linux/pm_runtime.h>
> +#include <linux/regmap.h>
> +#include <linux/regulator/consumer.h>
> +#include <linux/slab.h>
> +#include <linux/usb/phy.h>
> +#include <linux/usb/xhci_pdriver.h>
above three header files no need anymore
> +
> +#include "xhci.h"
> +#include "xhci-mtk.h"
> +
> +/* ip_pw_ctrl0 register */
> +#define CTRL0_IP_SW_RST BIT(0)
> +
> +/* ip_pw_ctrl1 register */
> +#define CTRL1_IP_HOST_PDN BIT(0)
> +
...
> +/* called during probe() after chip reset completes */
> +static int xhci_mtk_setup(struct usb_hcd *hcd)
> +{
> + struct xhci_hcd_mtk *mtk = hcd_to_mtk(hcd);
> + int ret;
> +
> + if (usb_hcd_is_primary_hcd(hcd)) {
> + ret = xhci_mtk_ssusb_config(mtk);
> + if (ret)
> + return ret;
> + ret = xhci_mtk_sch_init(mtk);
> + if (ret)
> + return ret;
> + }
> +
> + return xhci_gen_setup(hcd, xhci_mtk_quirks);
> +}
> +
> +static int xhci_mtk_probe(struct platform_device *pdev)
> +{
> + struct device *dev = &pdev->dev;
> + struct device_node *node = dev->of_node;
> + struct xhci_hcd_mtk *mtk;
> + const struct hc_driver *driver;
> + struct xhci_hcd *xhci;
> + struct resource *res;
> + struct usb_hcd *hcd;
> + struct phy *phy;
> + int phy_num;
> + int ret = -ENODEV;
...
> +
> + if (HCC_MAX_PSA(xhci->hcc_params) >= 4)
> + xhci->shared_hcd->can_do_streams = 1;
> +
> + ret = usb_add_hcd(hcd, irq, IRQF_SHARED);
> + if (ret)
> + goto put_usb3_hcd;
> +
> + ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED);
> + if (ret)
> + goto dealloc_usb2_hcd;
> +
> + return 0;
> +
> +dealloc_usb2_hcd:
> + xhci_mtk_sch_exit(mtk);
> + usb_remove_hcd(hcd);
> +
> +put_usb3_hcd:
> + usb_put_hcd(xhci->shared_hcd);
need call xhci_mtk_sch_exit() for some fail cases
> +
> +power_off_phys:
> + xhci_mtk_phy_power_off(mtk);
> + device_init_wakeup(dev, 0);
use false instead of 0
> +
> +exit_phys:
> + xhci_mtk_phy_exit(mtk);
> +
> +put_usb2_hcd:
> + usb_put_hcd(hcd);
> +
> +disable_clk:
> + xhci_mtk_clks_disable(mtk);
> +
> +disable_ldos:
> + xhci_mtk_ldos_disable(mtk);
> +
> +disable_pm:
> + pm_runtime_put_sync(dev);
> + pm_runtime_disable(dev);
> + return ret;
> +}
> +
> +static int xhci_mtk_remove(struct platform_device *dev)
> +{
> + struct xhci_hcd_mtk *mtk = platform_get_drvdata(dev);
> + struct usb_hcd *hcd = mtk->hcd;
> + struct xhci_hcd *xhci = hcd_to_xhci(hcd);
> +
> + usb_remove_hcd(xhci->shared_hcd);
> + xhci_mtk_phy_power_off(mtk);
> + xhci_mtk_phy_exit(mtk);
> + device_init_wakeup(&dev->dev, 0);
use false instead of 0
I will send v11 to fix up the problems caused by my carelessness.
Sorry.
> +
> + usb_remove_hcd(hcd);
> + usb_put_hcd(xhci->shared_hcd);
> + usb_put_hcd(hcd);
> + xhci_mtk_sch_exit(mtk);
> + xhci_mtk_clks_disable(mtk);
> + xhci_mtk_ldos_disable(mtk);
> + pm_runtime_put_sync(&dev->dev);
> + pm_runtime_disable(&dev->dev);
> +
> + return 0;
> +}
> +
next prev parent reply other threads:[~2015-10-19 6:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-18 3:51 [PATCH v10 0/3] Mediatek xHCI support Chunfeng Yun
2015-10-18 3:51 ` [PATCH v10 1/3] dt-bindings: Add a binding for Mediatek xHCI host controller Chunfeng Yun
2015-10-18 3:51 ` [PATCH v10 2/3] xhci: mediatek: support MTK " Chunfeng Yun
2015-10-19 6:02 ` chunfeng yun [this message]
2015-10-18 3:51 ` [PATCH v10 3/3] arm64: dts: mediatek: add xHCI & usb phy for mt8173 Chunfeng Yun
2015-10-18 11:01 ` Sergei Shtylyov
2015-10-19 5:31 ` chunfeng yun
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=1445234547.28324.17.camel@mhfsdcap03 \
--to=chunfeng.yun@mediatek.com \
--cc=linux-arm-kernel@lists.infradead.org \
/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