From: Maxime Ripard <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
To: Hans de Goede <hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
Cc: Chen-Yu Tsai <wens-jdAy2FN1RRM@public.gmane.org>,
Kishon Vijay Abraham I <kishon-l0cyMroinI0@public.gmane.org>,
"Reinder E.N. de Haan"
<reinder-I1/eAgTnXDYAvxtiuMwx3w@public.gmane.org>,
linux-usb <linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
linux-arm-kernel
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
devicetree <devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
linux-sunxi <linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org>
Subject: Re: [linux-sunxi] Re: [PATCH v3 1/2] phy-sun4i-usb: Use of_match_node to get model specific config data
Date: Fri, 27 Nov 2015 09:53:32 +0100 [thread overview]
Message-ID: <20151127085332.GU32142@lukather> (raw)
In-Reply-To: <5656F6F4.1040801-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
[-- Attachment #1: Type: text/plain, Size: 2376 bytes --]
On Thu, Nov 26, 2015 at 01:11:32PM +0100, Hans de Goede wrote:
> >>+enum sun4i_usb_phy_type {
> >>+ sun4i_a10_phy,
> >>+ sun8i_a33_phy,
> >>+};
> >>+
> >>+struct sun4i_usb_phy_cfg {
> >>+ int num_phys;
> >>+ u32 disc_thresh;
> >>+ enum sun4i_usb_phy_type type;
> >>+ bool dedicated_clocks;
> >>+};
> >>+
> >> struct sun4i_usb_phy_data {
> >> void __iomem *base;
> >>+ const struct sun4i_usb_phy_cfg *cfg;
> >> struct mutex mutex;
> >>- int num_phys;
> >>- u32 disc_thresh;
> >>- bool has_a33_phyctl;
> >> struct sun4i_usb_phy {
> >> struct phy *phy;
> >> void __iomem *pmu;
> >>@@ -164,12 +174,15 @@ static void sun4i_usb_phy_write(struct sun4i_usb_phy *phy, u32 addr, u32 data,
> >>
> >> mutex_lock(&phy_data->mutex);
> >>
> >>- if (phy_data->has_a33_phyctl) {
> >>+ switch (phy_data->cfg->type) {
> >>+ case sun4i_a10_phy:
> >>+ phyctl = phy_data->base + REG_PHYCTL_A10;
> >
> >Any reason why this offset isn't incorporated into phy_data?
>
> You mean in phy_data->cfg I assume, the difference needed for
> the "sun4i_usb_phy_write" functionality are not just the phyctl
> register offset...
>
> >
> >>+ break;
> >>+ case sun8i_a33_phy:
> >> phyctl = phy_data->base + REG_PHYCTL_A33;
> >> /* A33 needs us to set phyctl to 0 explicitly */
> >> writel(0, phyctl);
>
> e.g. the A33 needs this extra write, and on the H3 we need to do
> similar bitbanging, but slightly different, see:
>
> https://github.com/allwinner-zh/linux-3.4-sunxi/blob/master/drivers/usb/host/sunxi_hci.c#L899
>
> Notice how it uses different addr and write register addresses
> their through the usb_phy_csr_add and usb_phy_csr_write helper
> functions as well as directly poking offset 0x20.
Then it easy to support: one u8 for each register that changes, one
bool to tell if you need to clear the phyctl register or not, And you
don't have to duplicate the switch everywhere, and basically just
reimplement of_device_is_compatible without an actual compatible to
workaround the review ;)
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2015-11-27 8:53 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-11-25 16:50 [PATCH v3 1/2] phy-sun4i-usb: Use of_match_node to get model specific config data Hans de Goede
[not found] ` <1448470202-3628-1-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-11-25 16:50 ` [PATCH v3 2/2] phy-sun4i-usb: Add support for the host usb-phys found on the H3 SoC Hans de Goede
[not found] ` <1448470202-3628-2-git-send-email-hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-11-25 22:11 ` Rob Herring
2015-11-26 12:03 ` Hans de Goede
2015-12-01 15:56 ` Priit Laes
2015-11-26 4:22 ` [PATCH v3 1/2] phy-sun4i-usb: Use of_match_node to get model specific config data Chen-Yu Tsai
[not found] ` <CAGb2v64XL=bptxoCwiVkf8u-EfckpuASS3Foo=Q3i4a_6CaJYA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2015-11-26 7:14 ` LABBE Corentin
2015-11-26 12:11 ` [linux-sunxi] " Hans de Goede
[not found] ` <5656F6F4.1040801-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-11-27 8:53 ` Maxime Ripard [this message]
2015-11-27 10:37 ` Hans de Goede
[not found] ` <56583260.1080106-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
2015-11-27 10:41 ` Hans de Goede
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=20151127085332.GU32142@lukather \
--to=maxime.ripard-wi1+55scjutkeb57/3fjtnbpr1lh4cv8@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=hdegoede-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
--cc=kishon-l0cyMroinI0@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-sunxi-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org \
--cc=linux-usb-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=reinder-I1/eAgTnXDYAvxtiuMwx3w@public.gmane.org \
--cc=wens-jdAy2FN1RRM@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).