[uClinux-dev] [PATCH] isp1362: merge updates in blackfin linux

Thomas Chou thomas at wytron.com.tw
Tue Nov 20 21:58:49 EST 2007


relocate linux/usb_isp1362.h to linux/usb/isp1362.h
remove bandwidth related code from isp1362 driver for upstream API
change

Signed-off-by: Thomas Chou <thomas at wytron.com.tw>

diff --git a/linux-2.6.x/drivers/usb/host/isp1362-hcd.c b/linux-2.6.x/drivers/usb/host/isp1362-hcd.c
index e672a99..676dab1 100644
--- a/linux-2.6.x/drivers/usb/host/isp1362-hcd.c
+++ b/linux-2.6.x/drivers/usb/host/isp1362-hcd.c
@@ -20,7 +20,7 @@
   1. Configure your memory controller if it can accomodate such delays (the best)
   2. Implement platform-specific delay function possibly
      combined with configuring the memory controller; see
-     include/linux/usb_isp1362.h for more info.
+     include/linux/usb/isp1362.h for more info.
   3. Use ndelay (easiest, poorest).
 
   Use the corresponding macros USE_PLATFORM_DELAY and USE_NDELAY in the
@@ -76,7 +76,7 @@
 #include <linux/list.h>
 #include <linux/interrupt.h>
 #include <linux/usb.h>
-#include <linux/usb_isp1362.h>
+#include <linux/usb/isp1362.h>
 #include <linux/platform_device.h>
 #include <linux/pm.h>
 
@@ -541,11 +541,6 @@ static void finish_request(struct isp1362_hcd *isp1362_hcd, struct isp1362_ep *e
 		    isp1362_hcd->load[ep->branch] - ep->load);
 		isp1362_hcd->load[ep->branch] -= ep->load;
 		ep->branch = PERIODIC_SIZE;
-		if (urb->bandwidth) {
-			DBG(0, "%s: Releasing bandwidth for urb %p ep %p req %d\n",
-			    __FUNCTION__, urb, ep, ep->num_req);
-			usb_release_bandwidth(urb->dev, urb, usb_pipeisoc(urb->pipe));
-		}
 	}
 	// async deschedule
 	if (!list_empty(&ep->schedule)) {
@@ -1127,7 +1122,7 @@ static irqreturn_t isp1362_irq(struct usb_hcd *hcd)
 		svc_mask &= ~HCuPINT_ISTL0;
 		isp1362_clr_mask16(isp1362_hcd, HCBUFSTAT, HCBUFSTAT_ISTL0_FULL);
 		DBG(1, "%s: ISTL0\n", __FUNCTION__);
-		// WARN_ON(isp1362_hcd->istl_flip);
+		WARN_ON((int)isp1362_hcd->istl_flip);
 		WARN_ON(isp1362_read_reg16(isp1362_hcd, HCBUFSTAT) & HCBUFSTAT_ISTL0_ACTIVE);
 		WARN_ON(!isp1362_read_reg16(isp1362_hcd, HCBUFSTAT) & HCBUFSTAT_ISTL0_DONE);
 		isp1362_hcd->irqenb &= ~HCuPINT_ISTL0;
@@ -1139,7 +1134,7 @@ static irqreturn_t isp1362_irq(struct usb_hcd *hcd)
 		svc_mask &= ~HCuPINT_ISTL1;
 		isp1362_clr_mask16(isp1362_hcd, HCBUFSTAT, HCBUFSTAT_ISTL1_FULL);
 		DBG(1, "%s: ISTL1\n", __FUNCTION__);
-		WARN_ON(!isp1362_hcd->istl_flip);
+		WARN_ON(!(int)isp1362_hcd->istl_flip);
 		WARN_ON(isp1362_read_reg16(isp1362_hcd, HCBUFSTAT) & HCBUFSTAT_ISTL1_ACTIVE);
 		WARN_ON(!isp1362_read_reg16(isp1362_hcd, HCBUFSTAT) & HCBUFSTAT_ISTL1_DONE);
 		isp1362_hcd->irqenb &= ~HCuPINT_ISTL1;
@@ -1437,7 +1432,6 @@ static int isp1362_urb_enqueue(struct usb_hcd *hcd, struct usb_host_endpoint *he
 		} else {
 			DBG(1, "%s: ep %p already scheduled\n", __func__, ep);
 		}
-		usb_claim_bandwidth(udev, urb, ep->load / ep->interval, type == PIPE_ISOCHRONOUS);
 		DBG(2, "%s: load %d bandwidth %d -> %d\n", __FUNCTION__,
 		    ep->load / ep->interval, isp1362_hcd->load[ep->branch],
 		    isp1362_hcd->load[ep->branch] + ep->load);
@@ -1581,15 +1575,21 @@ static int isp1362_hub_status_data(struct usb_hcd *hcd, char *buf)
 {
 	struct isp1362_hcd *isp1362_hcd = hcd_to_isp1362_hcd(hcd);
 	int ports, i, changed = 0;
-	int can_suspend = 0; // hcd->can_wakeup;
+	unsigned long flags;
 
 	if (!HC_IS_RUNNING(hcd->state)) {
 		return -ESHUTDOWN;
 	}
 
+	/* Report no status change now, if we are scheduled to be
+	   called later */
+	if (timer_pending(&hcd->rh_timer))
+		return 0;
+
 	ports = isp1362_hcd->rhdesca & RH_A_NDP;
 	BUG_ON(ports > 2);
 
+	spin_lock_irqsave(&isp1362_hcd->lock, flags);
 	/* init status */
 	if (isp1362_hcd->rhstatus & (RH_HS_LPSC | RH_HS_OCIC)) {
 		buf[0] = changed = 1;
@@ -1610,26 +1610,8 @@ static int isp1362_hub_status_data(struct usb_hcd *hcd, char *buf)
 		if (!(status & RH_PS_CCS)) {
 			continue;
 		}
-		// if ((status & RH_PS_PSS) && hcd->remote_wakeup) {
-		//	continue;
-		// }
-		can_suspend = 0;
-	}
-#if defined(CONFIG_USB_SUSPEND) || defined(CONFIG_PM)
-	if (can_suspend && !changed &&
-	    list_empty(&isp1362_hcd->async) &&
-	    list_empty(&isp1362_hcd->periodic) &&
-	    list_empty(&isp1362_hcd->isoc) &&
-	    (isp1362_read_reg32(isp1362_hcd, HCCONTROL) & OHCI_CTRL_HCFS) == OHCI_USB_OPER &&
-	    time_after(jiffies, isp1362_hcd->next_statechange) &&
-	    usb_trylock_device(hcd->self.root_hub)) {
-		DBG(0, "%s: Autosuspending root hub\n", __FUNCTION__);
-		isp1362_set_mask16(isp1362_hcd, HCHWCFG, HCHWCFG_CLKNOTSTOP);
-		(void) isp1362_bus_suspend(hcd);
-		hcd->state = HC_STATE_RUNNING;
-		usb_unlock_device(hcd->self.root_hub);
 	}
-#endif
+	spin_unlock_irqrestore(&isp1362_hcd->lock, flags);
 	return changed;
 }
 
@@ -1897,17 +1879,17 @@ static int isp1362_bus_suspend(struct usb_hcd *hcd)
 		mdelay(7);
 		if (isp1362_read_reg16(isp1362_hcd, HCuPINT) & HCuPINT_ATL) {
 			u32 done_map = isp1362_read_reg32(isp1362_hcd, HCATLDONE);
-			finish_transfers(isp1362_hcd, done_map, &isp1362_hcd->atl_queue, NULL);
+			finish_transfers(isp1362_hcd, done_map, &isp1362_hcd->atl_queue);
 		}
 		if (isp1362_read_reg16(isp1362_hcd, HCuPINT) & HCuPINT_INTL) {
 			u32 done_map = isp1362_read_reg32(isp1362_hcd, HCINTLDONE);
-			finish_transfers(isp1362_hcd, done_map, &isp1362_hcd->intl_queue, NULL);
+			finish_transfers(isp1362_hcd, done_map, &isp1362_hcd->intl_queue);
 		}
 		if (isp1362_read_reg16(isp1362_hcd, HCuPINT) & HCuPINT_ISTL0) {
-			finish_iso_transfers(isp1362_hcd, &isp1362_hcd->istl_queue[0] , NULL);
+			finish_iso_transfers(isp1362_hcd, &isp1362_hcd->istl_queue[0]);
 		}
 		if (isp1362_read_reg16(isp1362_hcd, HCuPINT) & HCuPINT_ISTL1) {
-			finish_iso_transfers(isp1362_hcd, &isp1362_hcd->istl_queue[1], NULL);
+			finish_iso_transfers(isp1362_hcd, &isp1362_hcd->istl_queue[1]);
 		}
 	}
 	DBG(0, "%s: HCINTSTAT: %08x\n", __FUNCTION__,
@@ -1917,11 +1899,6 @@ static int isp1362_bus_suspend(struct usb_hcd *hcd)
 
 	/* Suspend hub */
 	isp1362_hcd->hc_control = OHCI_USB_SUSPEND;
-	/* maybe resume can wake root hub */
-	if (hcd->remote_wakeup) {
-		DBG(0, "%s: Enabling RWE\n", __FUNCTION__);
-		isp1362_hcd->hc_control |= OHCI_CTRL_RWE;
-	}
 	isp1362_show_reg(isp1362_hcd, HCCONTROL);
 	isp1362_write_reg32(isp1362_hcd, HCCONTROL, isp1362_hcd->hc_control);
 	isp1362_show_reg(isp1362_hcd, HCCONTROL);
@@ -2015,9 +1992,6 @@ static int isp1362_bus_resume(struct usb_hcd *hcd)
 	mdelay(20 /* usb 11.5.1.10 */ + 15);
 
 	isp1362_hcd->hc_control = OHCI_USB_OPER;
-	if (hcd->can_wakeup) {
-		isp1362_hcd->hc_control |= OHCI_CTRL_RWC;
-	}
 	spin_lock_irqsave(&isp1362_hcd->lock, flags);
 	isp1362_show_reg(isp1362_hcd, HCCONTROL);
 	isp1362_write_reg32(isp1362_hcd, HCCONTROL, isp1362_hcd->hc_control);
@@ -2392,10 +2366,10 @@ static int isp1362_mem_config(struct usb_hcd *hcd)
 	dev_info(hcd->self.controller, "ISP1362 Memory usage:\n");
 	dev_info(hcd->self.controller, "  ISTL:    2 * %4d:     %4d @ $%04x:$%04x\n",
 		 istl_size / 2, istl_size, 0, istl_size / 2);
-	dev_info(hcd->self.controller, "  INTL: %4d * (%3d+8):  %4d @ $%04x\n",
+	dev_info(hcd->self.controller, "  INTL: %4d * (%3ld+8):  %4d @ $%04x\n",
 		 ISP1362_INTL_BUFFERS, intl_blksize - PTD_HEADER_SIZE,
 		 intl_size, istl_size);
-	dev_info(hcd->self.controller, "  ATL : %4d * (%3d+8):  %4d @ $%04x\n",
+	dev_info(hcd->self.controller, "  ATL : %4d * (%3ld+8):  %4d @ $%04x\n",
 		 atl_buffers, atl_blksize - PTD_HEADER_SIZE,
 		 atl_size, istl_size + intl_size);
 	dev_info(hcd->self.controller, "  USED/FREE:   %4d      %4d\n", total,
@@ -2516,7 +2490,7 @@ static int isp1362_hc_reset(struct usb_hcd *hcd)
 		ERR("Clock not ready after %lums\n", timeout);
 		ret = -ENODEV;
 	}
-	return 0;   //  SKIP ret;
+	return ret;
 }
 
 static void isp1362_hc_stop(struct usb_hcd *hcd)
@@ -2747,10 +2721,6 @@ static int isp1362_hc_start(struct usb_hcd *hcd)
 	}
 
 	isp1362_hcd->hc_control = OHCI_USB_OPER;
-	if (board->remote_wakeup_connected) {
-	        // hcd->can_wakeup = 1;
-		isp1362_hcd->hc_control |= OHCI_CTRL_RWC;
-	}
 
 	udev->speed = USB_SPEED_FULL;
 	hcd->state = HC_STATE_RUNNING;
@@ -2999,8 +2969,7 @@ static int isp1362_resume(struct platform_device *pdev)
 
 	DBG(0, "%s: Resuming\n", __FUNCTION__);
 
-	if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND
-			|| !hcd->can_wakeup) {
+	if (pdev->dev.power.power_state.event == PM_EVENT_SUSPEND) {
 		DBG(0, "%s: Resume RH ports\n", __FUNCTION__);
 		spin_lock_irqsave(&isp1362_hcd->lock, flags);
 		isp1362_write_reg32(isp1362_hcd, HCRHSTATUS, RH_HS_LPSC);
diff --git a/linux-2.6.x/drivers/usb/host/isp1362.h b/linux-2.6.x/drivers/usb/host/isp1362.h
index 5d2b523..b9d1020 100644
--- a/linux-2.6.x/drivers/usb/host/isp1362.h
+++ b/linux-2.6.x/drivers/usb/host/isp1362.h
@@ -33,7 +33,7 @@
 
 // insert platform specific definitions for other machines here
 //#elif defined(CONFIG_ARCH_)
-#elif defined(CONFIG_BFIN)
+#elif defined(CONFIG_BLACKFIN)
 
 #include <asm/io.h>
 #define USE_32BIT		0
@@ -63,7 +63,7 @@ static inline void delayed_insw(unsigned int addr, void *buf, int len)
   unsigned short *bp = (unsigned short *) buf;
   while (len--){
     DUMMY_DELAY_ACCESS;
-    *bp++ = inw(addr);
+    *bp++ = inw((void*)addr);
   }
 }
 
@@ -785,7 +785,7 @@ static void isp1362_read_fifo(struct isp1362_hcd *isp1362_hcd, void *buf, u16 le
 #endif
 	if (len >= 2) {
 		RDBG("%s: Using readsw for %d words\n", __FUNCTION__, len >> 1);
-#if 1		
+#if 1
 		insw((unsigned long)isp1362_hcd->data_reg, dp, len >> 1);
 		dp += len & ~1;
 		len &= 1;
@@ -812,8 +812,18 @@ static void isp1362_write_fifo(struct isp1362_hcd *isp1362_hcd, void *buf, u16 l
 {
 	u8 *dp = buf;
 	u16 data;
+	u8 *temp = NULL;
 
 	_BUG_ON(!irqs_disabled());
+	if((unsigned)dp & 0x1) {
+		temp = kmalloc(len, GFP_KERNEL);
+		if (temp == NULL) {
+			printk(KERN_ERR "No memory available\n");
+			return;
+		}
+		memcpy(temp, dp, len);
+		dp = temp;
+	}
 	if (!len) {
 		return;
 	}
@@ -851,6 +861,9 @@ static void isp1362_write_fifo(struct isp1362_hcd *isp1362_hcd, void *buf, u16 l
 	  DUMMY_DELAY_ACCESS;
 		isp1362_write_data16(isp1362_hcd, data);
 	}
+	if (temp) {
+		kfree(temp);
+	}
 }
 
 #define isp1362_read_reg16(d, r)		({			\
diff --git a/linux-2.6.x/include/linux/usb/isp1362.h b/linux-2.6.x/include/linux/usb/isp1362.h
new file mode 100644
index 0000000..c516715
--- /dev/null
+++ b/linux-2.6.x/include/linux/usb/isp1362.h
@@ -0,0 +1,42 @@
+
+/*
+ * board initialization code should put one of these into dev->platform_data
+ * and place the isp1362 onto platform_bus.
+ */
+
+struct isp1362_platform_data {
+	/* Enable internal pulldown resistors on downstream ports */
+	unsigned sel15Kres:1;
+	/* Clock cannot be stopped */
+	unsigned clknotstop:1;
+	/* On-chip overcurrent protection */
+	unsigned oc_enable:1;
+	/* INT output polarity */
+	unsigned int_act_high:1;
+	/* INT edge or level triggered */
+	unsigned int_edge_triggered:1;
+	/* DREQ output polarity */
+	unsigned dreq_act_high:1;
+	/* DACK input polarity */
+	unsigned dack_act_high:1;
+	/* chip can be resumed via H_WAKEUP pin */
+	unsigned remote_wakeup_connected:1;
+	/* Switch or not to switch (keep always powered) */
+	unsigned no_power_switching:1;
+	/* Ganged port power switching (0) or individual port power switching (1) */
+	unsigned power_switching_mode:1;
+	/* Given port_power, msec/2 after power on till power good */
+	u8 potpg;
+	/* Hardware reset set/clear */
+	void (*reset) (struct device *dev, int set);
+	/* Clock start/stop */
+	void (*clock) (struct device *dev, int start);
+	/* Inter-io delay (ns). The chip is picky about access timings; it
+	   expects at least:
+	   110ns delay between consecutive accesses to DATA_REG,
+	   300ns delay between access to ADDR_REG and DATA_REG (registers)
+	   462ns delay between access to ADDR_REG and DATA_REG (buffer memory)
+	   WE MUST NOT be activated during these intervals (even without CS!)
+	 */
+	void (*delay) (struct device *dev, unsigned int delay);
+};
diff --git a/linux-2.6.x/include/linux/usb_isp1362.h b/linux-2.6.x/include/linux/usb_isp1362.h
deleted file mode 100644
index 381c3af..0000000
--- a/linux-2.6.x/include/linux/usb_isp1362.h
+++ /dev/null
@@ -1,42 +0,0 @@
-
-/*
- * board initialization code should put one of these into dev->platform_data
- * and place the isp1362 onto platform_bus.
- */
-
-struct isp1362_platform_data {
-	// Enable internal pulldown resistors on downstream ports 
-	unsigned sel15Kres:1;
-	// Clock cannot be stopped 
-	unsigned clknotstop:1;
-	// On-chip overcurrent protection 
-	unsigned oc_enable:1;
-	// INT output polarity
-	unsigned int_act_high:1;
-	// INT edge or level triggered
-	unsigned int_edge_triggered:1;
-	// DREQ output polarity
-	unsigned dreq_act_high:1;
-	// DACK input polarity
-	unsigned dack_act_high:1;
-	// chip can be resumed via H_WAKEUP pin
-	unsigned remote_wakeup_connected:1;
-	// Switch or not to switch (keep always powered)
-	unsigned no_power_switching:1;
-	// Ganged port power switching (0) or individual port power switching (1)
-	unsigned power_switching_mode:1;
-	// Given port_power, msec/2 after power on till power good
-	u8 potpg;
-	// Hardware reset set/clear
-	void (*reset) (struct device *dev, int set);
-	// Clock start/stop
-	void (*clock) (struct device *dev, int start);
-	/* Inter-io delay (ns). The chip is picky about access timings; it
-	   expects at least:
-	   110ns delay between consecutive accesses to DATA_REG,
-	   300ns delay between access to ADDR_REG and DATA_REG (registers)
-	   462ns delay between access to ADDR_REG and DATA_REG (buffer memory)
-	   WE MUST NOT be activated during these intervals (even without CS!)
-	 */
-	void (*delay) (struct device *dev, unsigned int delay);
-};
-- 
1.5.3.3



More information about the uClinux-dev mailing list