aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/musb/musb_core.c
diff options
context:
space:
mode:
authorFelipe Balbi <felipe.balbi@nokia.com>2008-08-08 05:40:54 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-08-13 20:33:01 -0400
commitca6d1b1333bc2e61e37982de1f28d8604c232414 (patch)
tree6675d284fc932e9125fc7fd083eebb7f0a1d5695 /drivers/usb/musb/musb_core.c
parentf362a47560070ec0aaf68ac6b45901eeed1c844f (diff)
usb: musb: pass configuration specifics via pdata
Use platform_data to pass musb configuration-specific details to musb driver. This patch will prevent that other platforms selecting HAVE_CLK and enabling musb won't break tree building. The other parts of it will come when linux-omap merge up more omap2/3 board-files. Signed-off-by: Felipe Balbi <felipe.balbi@nokia.com> Acked-by: Paul Mundt <lethal@linux-sh.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/musb/musb_core.c')
-rw-r--r--drivers/usb/musb/musb_core.c37
1 files changed, 16 insertions, 21 deletions
diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c
index 462586d06da..d68ec6daf33 100644
--- a/drivers/usb/musb/musb_core.c
+++ b/drivers/usb/musb/musb_core.c
@@ -990,12 +990,6 @@ static void musb_shutdown(struct platform_device *pdev)
990 * We don't currently use dynamic fifo setup capability to do anything 990 * We don't currently use dynamic fifo setup capability to do anything
991 * more than selecting one of a bunch of predefined configurations. 991 * more than selecting one of a bunch of predefined configurations.
992 */ 992 */
993#ifdef MUSB_C_DYNFIFO_DEF
994#define can_dynfifo() 1
995#else
996#define can_dynfifo() 0
997#endif
998
999#if defined(CONFIG_USB_TUSB6010) || \ 993#if defined(CONFIG_USB_TUSB6010) || \
1000 defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP34XX) 994 defined(CONFIG_ARCH_OMAP2430) || defined(CONFIG_ARCH_OMAP34XX)
1001static ushort __initdata fifo_mode = 4; 995static ushort __initdata fifo_mode = 4;
@@ -1008,8 +1002,6 @@ module_param(fifo_mode, ushort, 0);
1008MODULE_PARM_DESC(fifo_mode, "initial endpoint configuration"); 1002MODULE_PARM_DESC(fifo_mode, "initial endpoint configuration");
1009 1003
1010 1004
1011#define DYN_FIFO_SIZE (1<<(MUSB_C_RAM_BITS+2))
1012
1013enum fifo_style { FIFO_RXTX, FIFO_TX, FIFO_RX } __attribute__ ((packed)); 1005enum fifo_style { FIFO_RXTX, FIFO_TX, FIFO_RX } __attribute__ ((packed));
1014enum buf_mode { BUF_SINGLE, BUF_DOUBLE } __attribute__ ((packed)); 1006enum buf_mode { BUF_SINGLE, BUF_DOUBLE } __attribute__ ((packed));
1015 1007
@@ -1119,11 +1111,12 @@ fifo_setup(struct musb *musb, struct musb_hw_ep *hw_ep,
1119 1111
1120 c_size = size - 3; 1112 c_size = size - 3;
1121 if (cfg->mode == BUF_DOUBLE) { 1113 if (cfg->mode == BUF_DOUBLE) {
1122 if ((offset + (maxpacket << 1)) > DYN_FIFO_SIZE) 1114 if ((offset + (maxpacket << 1)) >
1115 (1 << (musb->config->ram_bits + 2)))
1123 return -EMSGSIZE; 1116 return -EMSGSIZE;
1124 c_size |= MUSB_FIFOSZ_DPB; 1117 c_size |= MUSB_FIFOSZ_DPB;
1125 } else { 1118 } else {
1126 if ((offset + maxpacket) > DYN_FIFO_SIZE) 1119 if ((offset + maxpacket) > (1 << (musb->config->ram_bits + 2)))
1127 return -EMSGSIZE; 1120 return -EMSGSIZE;
1128 } 1121 }
1129 1122
@@ -1219,13 +1212,13 @@ static int __init ep_config_from_table(struct musb *musb)
1219 /* assert(offset > 0) */ 1212 /* assert(offset > 0) */
1220 1213
1221 /* NOTE: for RTL versions >= 1.400 EPINFO and RAMINFO would 1214 /* NOTE: for RTL versions >= 1.400 EPINFO and RAMINFO would
1222 * be better than static MUSB_C_NUM_EPS and DYN_FIFO_SIZE... 1215 * be better than static musb->config->num_eps and DYN_FIFO_SIZE...
1223 */ 1216 */
1224 1217
1225 for (i = 0; i < n; i++) { 1218 for (i = 0; i < n; i++) {
1226 u8 epn = cfg->hw_ep_num; 1219 u8 epn = cfg->hw_ep_num;
1227 1220
1228 if (epn >= MUSB_C_NUM_EPS) { 1221 if (epn >= musb->config->num_eps) {
1229 pr_debug("%s: invalid ep %d\n", 1222 pr_debug("%s: invalid ep %d\n",
1230 musb_driver_name, epn); 1223 musb_driver_name, epn);
1231 continue; 1224 continue;
@@ -1242,8 +1235,8 @@ static int __init ep_config_from_table(struct musb *musb)
1242 1235
1243 printk(KERN_DEBUG "%s: %d/%d max ep, %d/%d memory\n", 1236 printk(KERN_DEBUG "%s: %d/%d max ep, %d/%d memory\n",
1244 musb_driver_name, 1237 musb_driver_name,
1245 n + 1, MUSB_C_NUM_EPS * 2 - 1, 1238 n + 1, musb->config->num_eps * 2 - 1,
1246 offset, DYN_FIFO_SIZE); 1239 offset, (1 << (musb->config->ram_bits + 2)));
1247 1240
1248#ifdef CONFIG_USB_MUSB_HDRC_HCD 1241#ifdef CONFIG_USB_MUSB_HDRC_HCD
1249 if (!musb->bulk_ep) { 1242 if (!musb->bulk_ep) {
@@ -1270,7 +1263,7 @@ static int __init ep_config_from_hw(struct musb *musb)
1270 1263
1271 /* FIXME pick up ep0 maxpacket size */ 1264 /* FIXME pick up ep0 maxpacket size */
1272 1265
1273 for (epnum = 1; epnum < MUSB_C_NUM_EPS; epnum++) { 1266 for (epnum = 1; epnum < musb->config->num_eps; epnum++) {
1274 musb_ep_select(mbase, epnum); 1267 musb_ep_select(mbase, epnum);
1275 hw_ep = musb->endpoints + epnum; 1268 hw_ep = musb->endpoints + epnum;
1276 1269
@@ -1424,14 +1417,14 @@ static int __init musb_core_init(u16 musb_type, struct musb *musb)
1424 musb->epmask = 1; 1417 musb->epmask = 1;
1425 1418
1426 if (reg & MUSB_CONFIGDATA_DYNFIFO) { 1419 if (reg & MUSB_CONFIGDATA_DYNFIFO) {
1427 if (can_dynfifo()) 1420 if (musb->config->dyn_fifo)
1428 status = ep_config_from_table(musb); 1421 status = ep_config_from_table(musb);
1429 else { 1422 else {
1430 ERR("reconfigure software for Dynamic FIFOs\n"); 1423 ERR("reconfigure software for Dynamic FIFOs\n");
1431 status = -ENODEV; 1424 status = -ENODEV;
1432 } 1425 }
1433 } else { 1426 } else {
1434 if (!can_dynfifo()) 1427 if (!musb->config->dyn_fifo)
1435 status = ep_config_from_hw(musb); 1428 status = ep_config_from_hw(musb);
1436 else { 1429 else {
1437 ERR("reconfigure software for static FIFOs\n"); 1430 ERR("reconfigure software for static FIFOs\n");
@@ -1788,7 +1781,8 @@ static void musb_irq_work(struct work_struct *data)
1788 */ 1781 */
1789 1782
1790static struct musb *__init 1783static struct musb *__init
1791allocate_instance(struct device *dev, void __iomem *mbase) 1784allocate_instance(struct device *dev,
1785 struct musb_hdrc_config *config, void __iomem *mbase)
1792{ 1786{
1793 struct musb *musb; 1787 struct musb *musb;
1794 struct musb_hw_ep *ep; 1788 struct musb_hw_ep *ep;
@@ -1820,8 +1814,9 @@ allocate_instance(struct device *dev, void __iomem *mbase)
1820 musb->mregs = mbase; 1814 musb->mregs = mbase;
1821 musb->ctrl_base = mbase; 1815 musb->ctrl_base = mbase;
1822 musb->nIrq = -ENODEV; 1816 musb->nIrq = -ENODEV;
1817 musb->config = config;
1823 for (epnum = 0, ep = musb->endpoints; 1818 for (epnum = 0, ep = musb->endpoints;
1824 epnum < MUSB_C_NUM_EPS; 1819 epnum < musb->config->num_eps;
1825 epnum++, ep++) { 1820 epnum++, ep++) {
1826 1821
1827 ep->musb = musb; 1822 ep->musb = musb;
@@ -1929,7 +1924,7 @@ bad_config:
1929 } 1924 }
1930 1925
1931 /* allocate */ 1926 /* allocate */
1932 musb = allocate_instance(dev, ctrl); 1927 musb = allocate_instance(dev, plat->config, ctrl);
1933 if (!musb) 1928 if (!musb)
1934 return -ENOMEM; 1929 return -ENOMEM;
1935 1930
@@ -1987,7 +1982,7 @@ bad_config:
1987 musb_generic_disable(musb); 1982 musb_generic_disable(musb);
1988 1983
1989 /* setup musb parts of the core (especially endpoints) */ 1984 /* setup musb parts of the core (especially endpoints) */
1990 status = musb_core_init(plat->multipoint 1985 status = musb_core_init(plat->config->multipoint
1991 ? MUSB_CONTROLLER_MHDRC 1986 ? MUSB_CONTROLLER_MHDRC
1992 : MUSB_CONTROLLER_HDRC, musb); 1987 : MUSB_CONTROLLER_HDRC, musb);
1993 if (status < 0) 1988 if (status < 0)