diff options
author | Igor Grinberg <grinberg@compulab.co.il> | 2010-10-10 11:59:18 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-10-22 13:22:10 -0400 |
commit | a9138192d0e716c3e9714b3fe03543d93ebbad9f (patch) | |
tree | 9846352e032cf59df136953f1fb36d27839af9b1 /drivers/usb/otg | |
parent | c6f694af8318a526c639306d9d07ee33cb7c168a (diff) |
USB: otg/ulpi: improve ulpi phy detection.
Improve ulpi phy detection by utilizing the "scratch" register.
Allow unknown ulpi phy work without the need to hard-code the id.
Signed-off-by: Igor Grinberg <grinberg@compulab.co.il>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/otg')
-rw-r--r-- | drivers/usb/otg/ulpi.c | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/drivers/usb/otg/ulpi.c b/drivers/usb/otg/ulpi.c index ccc81950822b..e0d2a5c504cc 100644 --- a/drivers/usb/otg/ulpi.c +++ b/drivers/usb/otg/ulpi.c | |||
@@ -137,6 +137,32 @@ static int ulpi_set_flags(struct otg_transceiver *otg) | |||
137 | return ulpi_set_fc_flags(otg); | 137 | return ulpi_set_fc_flags(otg); |
138 | } | 138 | } |
139 | 139 | ||
140 | static int ulpi_check_integrity(struct otg_transceiver *otg) | ||
141 | { | ||
142 | int ret, i; | ||
143 | unsigned int val = 0x55; | ||
144 | |||
145 | for (i = 0; i < 2; i++) { | ||
146 | ret = otg_io_write(otg, val, ULPI_SCRATCH); | ||
147 | if (ret < 0) | ||
148 | return ret; | ||
149 | |||
150 | ret = otg_io_read(otg, ULPI_SCRATCH); | ||
151 | if (ret < 0) | ||
152 | return ret; | ||
153 | |||
154 | if (ret != val) { | ||
155 | pr_err("ULPI integrity check: failed!"); | ||
156 | return -ENODEV; | ||
157 | } | ||
158 | val = val << 1; | ||
159 | } | ||
160 | |||
161 | pr_info("ULPI integrity check: passed.\n"); | ||
162 | |||
163 | return 0; | ||
164 | } | ||
165 | |||
140 | static int ulpi_init(struct otg_transceiver *otg) | 166 | static int ulpi_init(struct otg_transceiver *otg) |
141 | { | 167 | { |
142 | int i, vid, pid, ret; | 168 | int i, vid, pid, ret; |
@@ -155,10 +181,13 @@ static int ulpi_init(struct otg_transceiver *otg) | |||
155 | 181 | ||
156 | for (i = 0; i < ARRAY_SIZE(ulpi_ids); i++) | 182 | for (i = 0; i < ARRAY_SIZE(ulpi_ids); i++) |
157 | if (ulpi_ids[i] == ULPI_ID(vid, pid)) | 183 | if (ulpi_ids[i] == ULPI_ID(vid, pid)) |
158 | return ulpi_set_flags(otg); | 184 | break; |
185 | |||
186 | ret = ulpi_check_integrity(otg); | ||
187 | if (ret) | ||
188 | return ret; | ||
159 | 189 | ||
160 | pr_err("ULPI ID does not match any known transceiver.\n"); | 190 | return ulpi_set_flags(otg); |
161 | return -ENODEV; | ||
162 | } | 191 | } |
163 | 192 | ||
164 | static int ulpi_set_host(struct otg_transceiver *otg, struct usb_bus *host) | 193 | static int ulpi_set_host(struct otg_transceiver *otg, struct usb_bus *host) |