From: zhangfei <zhangfei.gao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
To: Peter Chen <peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
Cc: balbi-l0cyMroinI0@public.gmane.org,
john.youn-HKixBCOQz3hWk0Htik3J/w@public.gmane.org,
Mian Yousaf Kaukab
<yousaf.kaukab-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
"dan . zhao" <dan.zhao-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org>,
Sergei Shtylyov
<sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org>,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v2 4/4] usb: phy: add phy-hi6220-usb
Date: Mon, 09 Feb 2015 22:26:25 +0800 [thread overview]
Message-ID: <54D8C391.1080603@linaro.org> (raw)
In-Reply-To: <20150209021133.GB3045@shlinux2>
On 02/09/2015 10:11 AM, Peter Chen wrote:
>> +static void hi6220_detect_work(struct work_struct *work)
>> +{
>> + struct hi6220_priv *priv =
>> + container_of(work, struct hi6220_priv, work.work);
>> + int gpio_id, gpio_vubs;
>
> %s/gpio_vubs/gpio_vbus
Yes, typo
>> +static void hi6220_phy_setup(struct hi6220_priv *priv, bool on)
>> +{
>> + struct regmap *reg = priv->reg;
>> + u32 val, mask;
>> + int ret;
>> +
>> + if (priv->reg == NULL)
>> + return;
>> +
>> + if (on) {
>> + val = RST0_USBOTG_BUS | RST0_POR_PICOPHY |
>> + RST0_USBOTG | RST0_USBOTG_32K;
>> + mask = val;
>> + ret = regmap_update_bits(reg, SC_PERIPH_RSTDIS0, mask, val);
>> + if (ret)
>> + return;
>> +
>> + ret = regmap_read(reg, SC_PERIPH_CTRL5, &val);
>> + val = CTRL5_USBOTG_RES_SEL | CTRL5_PICOPHY_ACAENB;
>> + mask = val | CTRL5_PICOPHY_BC_MODE;
>> + ret = regmap_update_bits(reg, SC_PERIPH_CTRL5, mask, val);
>> + if (ret)
>> + return;
>> +
>> + val = CTRL4_PICO_VBUSVLDEXT | CTRL4_PICO_VBUSVLDEXTSEL |
>> + CTRL4_OTG_PHY_SEL;
>> + mask = val | CTRL4_PICO_SIDDQ | CTRL4_PICO_OGDISABLE;
>> + ret = regmap_update_bits(reg, SC_PERIPH_CTRL4, mask, val);
>> + if (ret)
>> + return;
>> +
>> + ret = regmap_write(reg, SC_PERIPH_CTRL8, EYE_PATTERN_PARA);
>> + if (ret)
>> + return;
>> + } else {
>> + val = CTRL4_PICO_SIDDQ;
>> + mask = val;
>> + ret = regmap_update_bits(reg, SC_PERIPH_CTRL4, mask, val);
>> + if (ret)
>> + return;
>> +
>> + ret = regmap_read(reg, SC_PERIPH_CTRL4, &val);
>> +
>> + val = RST0_USBOTG_BUS | RST0_POR_PICOPHY |
>> + RST0_USBOTG | RST0_USBOTG_32K;
>> + mask = val;
>> + ret = regmap_update_bits(reg, SC_PERIPH_RSTEN0, mask, val);
>> + if (ret)
>> + return;
>> + }
>
> You have return value check for regmap API, but no error message or
> return value for hi6220_phy_setup, it looks strange.
There was dev_err(priv->dev, "failed to setup phy\n");
Then I found priv->dev is the only one place to use, so I remove this
for simple.
>
>> +}
>> +
>> +static int hi6220_phy_probe(struct platform_device *pdev)
>> +{
>> + struct hi6220_priv *priv;
>> + struct usb_otg *otg;
>> + struct device_node *np = pdev->dev.of_node;
>> + int ret, irq;
>> +
>> + priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
>> + if (!priv)
>> + return -ENOMEM;
>> +
>> + otg = devm_kzalloc(&pdev->dev, sizeof(*otg), GFP_KERNEL);
>> + if (!otg)
>> + return -ENOMEM;
>> +
>> + priv->phy.dev = &pdev->dev;
>> + priv->phy.otg = otg;
>> + priv->phy.label = "hi6220";
>> + priv->phy.type = USB_PHY_TYPE_USB2;
>> + otg->set_peripheral = hi6220_set_peripheral;
>> + platform_set_drvdata(pdev, priv);
>> +
>> + priv->gpio_vbus = of_get_named_gpio(np, "hisilicon,gpio-vbus", 0);
>> + if (priv->gpio_vbus == -EPROBE_DEFER)
>> + return -EPROBE_DEFER;
>> + if (!gpio_is_valid(priv->gpio_vbus)) {
>> + dev_err(&pdev->dev, "invalid gpio %d\n", priv->gpio_vbus);
>> + return -ENODEV;
>> + }
>> +
>> + priv->gpio_id = of_get_named_gpio(np, "hisilicon,gpio-id", 0);
>> + if (priv->gpio_id == -EPROBE_DEFER)
>> + return -EPROBE_DEFER;
>> + if (!gpio_is_valid(priv->gpio_id)) {
>> + dev_err(&pdev->dev, "invalid gpio %d\n", priv->gpio_id);
>> + return -ENODEV;
>> + }
>> +
>> + priv->reg = syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
>> + "hisilicon,peripheral-syscon");
>> + if (IS_ERR(priv->reg))
>> + priv->reg = NULL;
>> +
>
> see my comments at your v1.
As replied in v1, EPROBE_DEFER does not needed.
syscon is register far earlier.
>
>> + INIT_DELAYED_WORK(&priv->work, hi6220_detect_work);
>> +
>> + ret = devm_gpio_request_one(&pdev->dev, priv->gpio_vbus,
>> + GPIOF_IN, "gpio_vbus");
>> + if (ret < 0) {
>> + dev_err(&pdev->dev, "gpio request failed for gpio_vbus\n");
>> + return ret;
>> + }
>> +
>> + ret = devm_gpio_request_one(&pdev->dev, priv->gpio_id,
>> + GPIOF_IN, "gpio_id");
>> + if (ret < 0) {
>> + dev_err(&pdev->dev, "gpio request failed for gpio_id\n");
>> + return ret;
>> + }
>> +
>> + priv->vcc = devm_regulator_get(&pdev->dev, "vcc");
>> + if (!IS_ERR(priv->vcc)) {
>
> EPROBE_DEFER?
No, this is not needed, since regulator is registered earlier than device.
drivers/Makefile
# regulators early, since some subsystems rely on them to initialize
obj-$(CONFIG_REGULATOR) += regulator/
EPROBE_DEFER should be the last option we rely on.
Thanks
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2015-02-09 14:26 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-07 4:56 [PATCH v2 0/4] add usb support for hi6220 Zhangfei Gao
[not found] ` <1423284966-3485-1-git-send-email-zhangfei.gao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-02-07 4:56 ` [PATCH v2 1/4] Documentation: dt-bindings: add dt binding info for hi6220 dwc2 Zhangfei Gao
2015-02-07 4:56 ` [PATCH v2 2/4] Documentation: dt-bindings: add dt binding info for hi6220 Zhangfei Gao
2015-02-07 4:56 ` [PATCH v2 3/4] usb: dwc2: platform: add hi6220 support Zhangfei Gao
2015-02-07 4:56 ` [PATCH v2 4/4] usb: phy: add phy-hi6220-usb Zhangfei Gao
[not found] ` <1423284966-3485-5-git-send-email-zhangfei.gao-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-02-09 2:11 ` Peter Chen
2015-02-09 14:26 ` zhangfei [this message]
[not found] ` <54D8C391.1080603-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
2015-02-09 16:00 ` Zhangfei Gao
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=54D8C391.1080603@linaro.org \
--to=zhangfei.gao-qsej5fyqhm4dnm+yrofe0a@public.gmane.org \
--cc=balbi-l0cyMroinI0@public.gmane.org \
--cc=dan.zhao-C8/M+/jPZTeaMJb+Lgu22Q@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=john.youn-HKixBCOQz3hWk0Htik3J/w@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org \
--cc=sergei.shtylyov-M4DtvfQ/ZS1MRgGoP+s0PdBPR1lH4CV8@public.gmane.org \
--cc=yousaf.kaukab-ral2JQCrhuEAvxtiuMwx3w@public.gmane.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;
as well as URLs for NNTP newsgroup(s).