* [PATCH] usb: ehci-orion: add more constants for register values
@ 2015-03-19 10:32 Thomas Petazzoni
2015-03-19 13:42 ` Sergei Shtylyov
0 siblings, 1 reply; 2+ messages in thread
From: Thomas Petazzoni @ 2015-03-19 10:32 UTC (permalink / raw)
To: linux-arm-kernel
This commit adds new register values for the USB_CMD and USB_MODE
registers, which allows to avoid the usage of a number of magic values
in orion_usb_phy_v1_setup().
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
drivers/usb/host/ehci-orion.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
index f6eafec..0feca8a 100644
--- a/drivers/usb/host/ehci-orion.c
+++ b/drivers/usb/host/ehci-orion.c
@@ -29,7 +29,13 @@
#define wrl(off, val) writel_relaxed((val), hcd->regs + (off))
#define USB_CMD 0x140
+#define USB_CMD_RUN BIT(0)
+#define USB_CMD_RESET BIT(1)
#define USB_MODE 0x1a8
+#define USB_MODE_MASK GENMASK(1, 0)
+#define USB_MODE_DEVICE 0x2
+#define USB_MODE_HOST 0x3
+#define USB_MODE_SDIS BIT(4)
#define USB_CAUSE 0x310
#define USB_MASK 0x314
#define USB_WINDOW_CTRL(i) (0x320 + ((i) << 4))
@@ -69,8 +75,8 @@ static void orion_usb_phy_v1_setup(struct usb_hcd *hcd)
/*
* Reset controller
*/
- wrl(USB_CMD, rdl(USB_CMD) | 0x2);
- while (rdl(USB_CMD) & 0x2);
+ wrl(USB_CMD, rdl(USB_CMD) | USB_CMD_RESET);
+ while (rdl(USB_CMD) & USB_CMD_RESET);
/*
* GL# USB-10: Set IPG for non start of frame packets
@@ -112,16 +118,16 @@ static void orion_usb_phy_v1_setup(struct usb_hcd *hcd)
/*
* Stop and reset controller
*/
- wrl(USB_CMD, rdl(USB_CMD) & ~0x1);
- wrl(USB_CMD, rdl(USB_CMD) | 0x2);
- while (rdl(USB_CMD) & 0x2);
+ wrl(USB_CMD, rdl(USB_CMD) & ~USB_CMD_RUN);
+ wrl(USB_CMD, rdl(USB_CMD) | USB_CMD_RESET);
+ while (rdl(USB_CMD) & USB_CMD_RESET);
/*
* GL# USB-5 Streaming disable REG_USB_MODE[4]=1
* TBD: This need to be done after each reset!
* GL# USB-4 Setup USB Host mode
*/
- wrl(USB_MODE, 0x13);
+ wrl(USB_MODE, USB_MODE_SDIS | USB_MODE_HOST);
}
static void
--
2.1.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH] usb: ehci-orion: add more constants for register values
2015-03-19 10:32 [PATCH] usb: ehci-orion: add more constants for register values Thomas Petazzoni
@ 2015-03-19 13:42 ` Sergei Shtylyov
0 siblings, 0 replies; 2+ messages in thread
From: Sergei Shtylyov @ 2015-03-19 13:42 UTC (permalink / raw)
To: linux-arm-kernel
Hello.
On 3/19/2015 1:32 PM, Thomas Petazzoni wrote:
> This commit adds new register values for the USB_CMD and USB_MODE
> registers, which allows to avoid the usage of a number of magic values
> in orion_usb_phy_v1_setup().
> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> ---
> drivers/usb/host/ehci-orion.c | 18 ++++++++++++------
> 1 file changed, 12 insertions(+), 6 deletions(-)
> diff --git a/drivers/usb/host/ehci-orion.c b/drivers/usb/host/ehci-orion.c
> index f6eafec..0feca8a 100644
> --- a/drivers/usb/host/ehci-orion.c
> +++ b/drivers/usb/host/ehci-orion.c
> @@ -29,7 +29,13 @@
> #define wrl(off, val) writel_relaxed((val), hcd->regs + (off))
>
> #define USB_CMD 0x140
> +#define USB_CMD_RUN BIT(0)
> +#define USB_CMD_RESET BIT(1)
Please use tabs to align the values, not spaces.
> #define USB_MODE 0x1a8
> +#define USB_MODE_MASK GENMASK(1, 0)
> +#define USB_MODE_DEVICE 0x2
> +#define USB_MODE_HOST 0x3
> +#define USB_MODE_SDIS BIT(4)
Here too.
> #define USB_CAUSE 0x310
> #define USB_MASK 0x314
> #define USB_WINDOW_CTRL(i) (0x320 + ((i) << 4))
[...]
WBR, Sergei
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-03-19 13:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-19 10:32 [PATCH] usb: ehci-orion: add more constants for register values Thomas Petazzoni
2015-03-19 13:42 ` Sergei Shtylyov
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).