]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/arm/mach-omap2/board-n800-usb.c
n800: usb: fix num_eps and avoid BUG()
[linux-2.6-omap-h63xx.git] / arch / arm / mach-omap2 / board-n800-usb.c
index 75243ace4f6c533e499e0d7c5dd9ee8800d2b297..fc128f245ab8eb2da3dd30d256f8cab9187227d1 100644 (file)
@@ -1,8 +1,8 @@
 /*
- * linux/arch/arm/mach-omap/omap2/board-n800-usb.c
+ * linux/arch/arm/mach-omap2/board-n800-usb.c
  *
  * Copyright (C) 2006 Nokia Corporation
- * Author: Juha Yrj?l?
+ * Author: Juha Yrjola
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License version 2 as
  */
 
 #include <linux/types.h>
-#include <linux/errno.h>
 #include <linux/delay.h>
 #include <linux/platform_device.h>
+#include <linux/clk.h>
+#include <linux/err.h>
 #include <linux/usb/musb.h>
-#include <asm/arch/gpmc.h>
-#include <asm/arch/gpio.h>
+#include <mach/gpmc.h>
+#include <mach/gpio.h>
+#include <mach/pm.h>
 
 #define TUSB_ASYNC_CS          1
 #define TUSB_SYNC_CS           4
@@ -23,6 +25,7 @@
 #define GPIO_TUSB_ENABLE       0
 
 static int tusb_set_power(int state);
+static int tusb_set_clock(struct clk *osc_ck, int state);
 
 #if    defined(CONFIG_USB_MUSB_OTG)
 #      define BOARD_MODE       MUSB_OTG
@@ -32,11 +35,58 @@ static int tusb_set_power(int state);
 #      define BOARD_MODE       MUSB_HOST
 #endif
 
+static struct musb_hdrc_eps_bits musb_eps[] = {
+       {       "ep1_tx", 5,    },
+       {       "ep1_rx", 5,    },
+       {       "ep2_tx", 5,    },
+       {       "ep2_rx", 5,    },
+       {       "ep3_tx", 3,    },
+       {       "ep3_rx", 3,    },
+       {       "ep4_tx", 3,    },
+       {       "ep4_rx", 3,    },
+       {       "ep5_tx", 2,    },
+       {       "ep5_rx", 2,    },
+       {       "ep6_tx", 2,    },
+       {       "ep6_rx", 2,    },
+       {       "ep7_tx", 2,    },
+       {       "ep7_rx", 2,    },
+       {       "ep8_tx", 2,    },
+       {       "ep8_rx", 2,    },
+       {       "ep9_tx", 2,    },
+       {       "ep9_rx", 2,    },
+       {       "ep10_tx", 2,   },
+       {       "ep10_rx", 2,   },
+       {       "ep11_tx", 2,   },
+       {       "ep11_rx", 2,   },
+       {       "ep12_tx", 2,   },
+       {       "ep12_rx", 2,   },
+       {       "ep13_tx", 2,   },
+       {       "ep13_rx", 2,   },
+       {       "ep14_tx", 2,   },
+       {       "ep14_rx", 2,   },
+       {       "ep15_tx", 2,   },
+       {       "ep15_rx", 2,   },
+};
+
+static struct musb_hdrc_config musb_config = {
+       .multipoint     = 1,
+       .dyn_fifo       = 1,
+       .soft_con       = 1,
+       .dma            = 1,
+       .num_eps        = 16,
+       .dma_channels   = 7,
+       .ram_bits       = 12,
+       .eps_bits       = musb_eps,
+};
+
 static struct musb_hdrc_platform_data tusb_data = {
        .mode           = BOARD_MODE,
-       .multipoint     = 1,
        .set_power      = tusb_set_power,
+       .set_clock      = tusb_set_clock,
        .min_power      = 25,   /* x2 = 50 mA drawn from VBUS as peripheral */
+       .power          = 100,  /* Max 100 mA VBUS for host mode */
+       .clock          = "osc_ck",
+       .config         = &musb_config,
 };
 
 /*
@@ -71,6 +121,29 @@ static int tusb_set_power(int state)
        return retval;
 }
 
+static int             osc_ck_on;
+
+static int tusb_set_clock(struct clk *osc_ck, int state)
+{
+       if (state) {
+               if (osc_ck_on > 0)
+                       return -ENODEV;
+
+               omap2_block_sleep();
+               clk_enable(osc_ck);
+               osc_ck_on = 1;
+       } else {
+               if (osc_ck_on == 0)
+                       return -ENODEV;
+
+               clk_disable(osc_ck);
+               osc_ck_on = 0;
+               omap2_allow_sleep();
+       }
+
+       return 0;
+}
+
 void __init n800_usb_init(void)
 {
        int ret = 0;