Commit 928c4bdf9b069be218436d25b96721395c4d671f
Committed by
Albert ARIBAUD
1 parent
3e6e809f56
Exists in
master
and in
54 other branches
usb: ulpi: Add omap-ulpi-view port support
Based on discussion from this thread [1]. Adding omap-view port that helps us in using the generic ulpi framework for any ulpi phy ops using the INSNREG05_ULPI viewport reg available on omap platform. Currently ehci ports are available on omap3/4 platforms so enable the same for beagle and panda, patch is tested on the same boards. Thanks to Igor Grinberg <grinberg@compulab.co.il> for reviewing the omap-ehci patches and suggesting this approach. [1]: http://www.mail-archive.com/u-boot@lists.denx.de/msg76076.html Tested-by: Stefano Babic <sbabic@denx.de> Acked-by: Igor Grinberg <grinberg@compulab.co.il> Signed-off-by: Govindraj.R <govindraj.raja@ti.com>
Showing 5 changed files with 140 additions and 0 deletions Side-by-side Diff
doc/README.omap-ulpi-viewport
1 | +Reference code ""drivers/usb/ulpi/omap-ulpi-viewport.c" | |
2 | + | |
3 | +Contains the ulpi read write api's to perform | |
4 | +any ulpi phy port access on omap platform. | |
5 | + | |
6 | +On omap ehci reg map contains INSNREG05_ULPI | |
7 | +register which offers the ulpi phy access so | |
8 | +any ulpi phy commands should be passsed using this | |
9 | +register. | |
10 | + | |
11 | +omap-ulpi-viewport.c is a low level function | |
12 | +implementation of "drivers/usb/ulpi/ulpi.c" | |
13 | + | |
14 | +To enable and use omap-ulpi-viewport.c | |
15 | +we require CONFIG_USB_ULPI_VIEWPORT_OMAP and | |
16 | +CONFIG_USB_ULPI be enabled in config file. | |
17 | + | |
18 | +Any ulpi ops request can be done with ulpi.c | |
19 | +and soc specific binding and usage is done with | |
20 | +omap-ulpi-viewport implementation. | |
21 | + | |
22 | +Ex: scenario: | |
23 | +omap-ehci driver code requests for ulpi phy reset if | |
24 | +ehci is used in phy mode, which will call ulpi phy reset | |
25 | +the ulpi phy reset does ulpi_read/write from viewport | |
26 | +implementation which will do ulpi reset using the | |
27 | +INSNREG05_ULPI register. |
drivers/usb/ulpi/Makefile
drivers/usb/ulpi/omap-ulpi-viewport.c
1 | +/* | |
2 | + * OMAP ulpi viewport support | |
3 | + * Based on drivers/usb/ulpi/ulpi-viewport.c | |
4 | + * | |
5 | + * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com | |
6 | + * Author: Govindraj R <govindraj.raja@ti.com> | |
7 | + * | |
8 | + * This program is free software: you can redistribute it and/or modify | |
9 | + * it under the terms of the GNU General Public License version 2 of | |
10 | + * the License as published by the Free Software Foundation. | |
11 | + * | |
12 | + * This program is distributed in the hope that it will be useful, | |
13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | + * GNU General Public License for more details. | |
16 | + * | |
17 | + * You should have received a copy of the GNU General Public License | |
18 | + * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | + */ | |
20 | + | |
21 | +#include <common.h> | |
22 | +#include <asm/io.h> | |
23 | +#include <usb/ulpi.h> | |
24 | + | |
25 | +#define OMAP_ULPI_WR_OPSEL (3 << 21) | |
26 | +#define OMAP_ULPI_ACCESS (1 << 31) | |
27 | + | |
28 | +/* | |
29 | + * Wait for the ULPI Access to complete | |
30 | + */ | |
31 | +static int ulpi_wait(struct ulpi_viewport *ulpi_vp, u32 mask) | |
32 | +{ | |
33 | + int timeout = CONFIG_USB_ULPI_TIMEOUT; | |
34 | + | |
35 | + while (--timeout) { | |
36 | + if ((readl(ulpi_vp->viewport_addr) & mask)) | |
37 | + return 0; | |
38 | + | |
39 | + udelay(1); | |
40 | + } | |
41 | + | |
42 | + return ULPI_ERROR; | |
43 | +} | |
44 | + | |
45 | +/* | |
46 | + * Wake the ULPI PHY up for communication | |
47 | + * | |
48 | + * returns 0 on success. | |
49 | + */ | |
50 | +static int ulpi_wakeup(struct ulpi_viewport *ulpi_vp) | |
51 | +{ | |
52 | + int err; | |
53 | + | |
54 | + if (readl(ulpi_vp->viewport_addr) & OMAP_ULPI_ACCESS) | |
55 | + return 0; /* already awake */ | |
56 | + | |
57 | + writel(OMAP_ULPI_ACCESS, ulpi_vp->viewport_addr); | |
58 | + | |
59 | + err = ulpi_wait(ulpi_vp, OMAP_ULPI_ACCESS); | |
60 | + if (err) | |
61 | + debug("ULPI wakeup timed out\n"); | |
62 | + | |
63 | + return err; | |
64 | +} | |
65 | + | |
66 | +/* | |
67 | + * Issue a ULPI read/write request | |
68 | + */ | |
69 | +static int ulpi_request(struct ulpi_viewport *ulpi_vp, u32 value) | |
70 | +{ | |
71 | + int err; | |
72 | + | |
73 | + err = ulpi_wakeup(ulpi_vp); | |
74 | + if (err) | |
75 | + return err; | |
76 | + | |
77 | + writel(value, ulpi_vp->viewport_addr); | |
78 | + | |
79 | + err = ulpi_wait(ulpi_vp, OMAP_ULPI_ACCESS); | |
80 | + if (err) | |
81 | + debug("ULPI request timed out\n"); | |
82 | + | |
83 | + return err; | |
84 | +} | |
85 | + | |
86 | +int ulpi_write(struct ulpi_viewport *ulpi_vp, u8 *reg, u32 value) | |
87 | +{ | |
88 | + u32 val = ((ulpi_vp->port_num & 0xf) << 24) | | |
89 | + OMAP_ULPI_WR_OPSEL | ((u32)reg << 16) | (value & 0xff); | |
90 | + | |
91 | + return ulpi_request(ulpi_vp, val); | |
92 | +} | |
93 | + | |
94 | +u32 ulpi_read(struct ulpi_viewport *ulpi_vp, u8 *reg) | |
95 | +{ | |
96 | + int err; | |
97 | + u32 val = ((ulpi_vp->port_num & 0xf) << 24) | | |
98 | + OMAP_ULPI_WR_OPSEL | ((u32)reg << 16); | |
99 | + | |
100 | + err = ulpi_request(ulpi_vp, val); | |
101 | + if (err) | |
102 | + return err; | |
103 | + | |
104 | + return readl(ulpi_vp->viewport_addr) & 0xff; | |
105 | +} |
include/configs/omap3_beagle.h
... | ... | @@ -129,6 +129,10 @@ |
129 | 129 | /* USB EHCI */ |
130 | 130 | #define CONFIG_CMD_USB |
131 | 131 | #define CONFIG_USB_EHCI |
132 | + | |
133 | +#define CONFIG_USB_ULPI | |
134 | +#define CONFIG_USB_ULPI_VIEWPORT_OMAP | |
135 | + | |
132 | 136 | #define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 3 |
133 | 137 | #define CONFIG_USB_HOST_ETHER |
134 | 138 | #define CONFIG_USB_ETHER_SMSC95XX |