-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaml --- r: 172463 b: refs/heads/master c: f4f8bda h: refs/heads/master i: 172461: d07ebe9 172459: 7617265 172455: 1db5017 172447: 6056a15 v: v3
- Loading branch information
Daniel Mack
authored and
Sascha Hauer
committed
Nov 14, 2009
1 parent
290cdeb
commit 76c37f2
Showing
5 changed files
with
125 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
--- | ||
refs/heads/master: 04ea3c801905a4562cc89af78eba40dec0f960a9 | ||
refs/heads/master: f4f8bda2321d5ecbfeef878a50c996e3a32a75e6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#ifndef __MACH_ULPI_H | ||
#define __MACH_ULPI_H | ||
|
||
extern struct otg_io_access_ops mxc_ulpi_access_ops; | ||
|
||
#endif /* __MACH_ULPI_H */ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/* | ||
* Copyright 2008 Sascha Hauer, Pengutronix <s.hauer@pengutronix.de> | ||
* Copyright 2009 Daniel Mack <daniel@caiaq.de> | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License | ||
* as published by the Free Software Foundation; either version 2 | ||
* of the License, or (at your option) any later version. | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, | ||
* MA 02110-1301, USA. | ||
*/ | ||
|
||
#include <linux/module.h> | ||
#include <linux/kernel.h> | ||
#include <linux/io.h> | ||
#include <linux/delay.h> | ||
#include <linux/usb/otg.h> | ||
|
||
#include <mach/ulpi.h> | ||
|
||
/* ULPIVIEW register bits */ | ||
#define ULPIVW_WU (1 << 31) /* Wakeup */ | ||
#define ULPIVW_RUN (1 << 30) /* read/write run */ | ||
#define ULPIVW_WRITE (1 << 29) /* 0 = read 1 = write */ | ||
#define ULPIVW_SS (1 << 27) /* SyncState */ | ||
#define ULPIVW_PORT_MASK 0x07 /* Port field */ | ||
#define ULPIVW_PORT_SHIFT 24 | ||
#define ULPIVW_ADDR_MASK 0xff /* data address field */ | ||
#define ULPIVW_ADDR_SHIFT 16 | ||
#define ULPIVW_RDATA_MASK 0xff /* read data field */ | ||
#define ULPIVW_RDATA_SHIFT 8 | ||
#define ULPIVW_WDATA_MASK 0xff /* write data field */ | ||
#define ULPIVW_WDATA_SHIFT 0 | ||
|
||
static int ulpi_poll(void __iomem *view, u32 bit) | ||
{ | ||
int timeout = 10000; | ||
|
||
while (timeout--) { | ||
u32 data = __raw_readl(view); | ||
|
||
if (!(data & bit)) | ||
return 0; | ||
|
||
cpu_relax(); | ||
}; | ||
|
||
printk(KERN_WARNING "timeout polling for ULPI device\n"); | ||
|
||
return -ETIMEDOUT; | ||
} | ||
|
||
static int ulpi_read(struct otg_transceiver *otg, u32 reg) | ||
{ | ||
int ret; | ||
void __iomem *view = otg->io_priv; | ||
|
||
/* make sure interface is running */ | ||
if (!(__raw_readl(view) & ULPIVW_SS)) { | ||
__raw_writel(ULPIVW_WU, view); | ||
|
||
/* wait for wakeup */ | ||
ret = ulpi_poll(view, ULPIVW_WU); | ||
if (ret) | ||
return ret; | ||
} | ||
|
||
/* read the register */ | ||
__raw_writel((ULPIVW_RUN | (reg << ULPIVW_ADDR_SHIFT)), view); | ||
|
||
/* wait for completion */ | ||
ret = ulpi_poll(view, ULPIVW_RUN); | ||
if (ret) | ||
return ret; | ||
|
||
return (__raw_readl(view) >> ULPIVW_RDATA_SHIFT) & ULPIVW_RDATA_MASK; | ||
} | ||
|
||
static int ulpi_write(struct otg_transceiver *otg, u32 val, u32 reg) | ||
{ | ||
int ret; | ||
void __iomem *view = otg->io_priv; | ||
|
||
/* make sure the interface is running */ | ||
if (!(__raw_readl(view) & ULPIVW_SS)) { | ||
__raw_writel(ULPIVW_WU, view); | ||
/* wait for wakeup */ | ||
ret = ulpi_poll(view, ULPIVW_WU); | ||
if (ret) | ||
return ret; | ||
} | ||
|
||
__raw_writel((ULPIVW_RUN | ULPIVW_WRITE | | ||
(reg << ULPIVW_ADDR_SHIFT) | | ||
((val & ULPIVW_WDATA_MASK) << ULPIVW_WDATA_SHIFT)), view); | ||
|
||
/* wait for completion */ | ||
return ulpi_poll(view, ULPIVW_RUN); | ||
} | ||
|
||
struct otg_io_access_ops mxc_ulpi_access_ops = { | ||
.read = ulpi_read, | ||
.write = ulpi_write, | ||
}; | ||
EXPORT_SYMBOL_GPL(mxc_ulpi_access_ops); | ||
|