示例#1
0
文件: radio-si470x.c 项目: E-LLP/n900
/*
 * si470x_get_rds_registers - read rds registers
 */
static int si470x_get_rds_registers(struct si470x_device *radio)
{
	unsigned char buf[RDS_REPORT_SIZE];
	int retval;
	int size;
	unsigned char regnr;

	buf[0] = RDS_REPORT;

	retval = usb_interrupt_msg(radio->usbdev,
		usb_rcvintpipe(radio->usbdev, 1),
		(void *) &buf, sizeof(buf), &size, usb_timeout);
	if (size != sizeof(buf))
		printk(KERN_WARNING DRIVER_NAME ": si470x_get_rds_registers: "
			"return size differs: %d != %zu\n", size, sizeof(buf));
	if (retval < 0)
		printk(KERN_WARNING DRIVER_NAME ": si470x_get_rds_registers: "
			"usb_interrupt_msg returned %d\n", retval);

	if (retval >= 0)
		for (regnr = 0; regnr < RDS_REGISTER_NUM; regnr++)
			radio->registers[STATUSRSSI + regnr] =
				get_unaligned_be16(
				&buf[regnr * RADIO_REGISTER_SIZE + 1]);

	return (retval < 0) ? -EINVAL : 0;
}
示例#2
0
static int metrousb_send_unidirectional_cmd(u8 cmd, struct usb_serial_port *port)
{
	int ret;
	int actual_len;
	u8 *buffer_cmd = NULL;

	if (!metrousb_is_unidirectional_mode(port))
		return 0;

	buffer_cmd = kzalloc(sizeof(cmd), GFP_KERNEL);
	if (!buffer_cmd)
		return -ENOMEM;

	*buffer_cmd = cmd;

	ret = usb_interrupt_msg(port->serial->dev,
		usb_sndintpipe(port->serial->dev, port->interrupt_out_endpointAddress),
		buffer_cmd, sizeof(cmd),
		&actual_len, USB_CTRL_SET_TIMEOUT);

	kfree(buffer_cmd);

	if (ret < 0)
		return ret;
	else if (actual_len != sizeof(cmd))
		return -EIO;
	return 0;
}
示例#3
0
/*
	Transmit Line6 control parameter.
*/
int line6_transmit_parameter(struct usb_line6 *line6, int param, u8 value)
{
	int retval;
	unsigned char *buffer;
	int partial;

	buffer = kmalloc(3, GFP_KERNEL);

	if (!buffer) {
		dev_err(line6->ifcdev, "out of memory\n");
		return -ENOMEM;
	}

	buffer[0] = LINE6_PARAM_CHANGE | LINE6_CHANNEL_HOST;
	buffer[1] = param;
	buffer[2] = value;

	retval = usb_interrupt_msg(line6->usbdev,
				   usb_sndintpipe(line6->usbdev,
						  line6->ep_control_write),
				   buffer, 3, &partial, LINE6_TIMEOUT * HZ);

	if (retval)
		dev_err(line6->ifcdev, "usb_interrupt_msg failed (%d)\n",
			retval);

	kfree(buffer);
	return retval;
}
示例#4
0
/*
	Send raw message in pieces of wMaxPacketSize bytes.
*/
int line6_send_raw_message(struct usb_line6 *line6, const char *buffer,
			   int size)
{
	int i, done = 0;

	for (i = 0; i < size; i += line6->max_packet_size) {
		int partial;
		const char *frag_buf = buffer + i;
		int frag_size = min(line6->max_packet_size, size - i);
		int retval;

		retval = usb_interrupt_msg(line6->usbdev,
					   usb_sndintpipe(line6->usbdev,
							  line6->ep_control_write),
					   (char *)frag_buf, frag_size,
					   &partial, LINE6_TIMEOUT * HZ);

		if (retval) {
			dev_err(line6->ifcdev,
				"usb_interrupt_msg failed (%d)\n", retval);
			break;
		}

		done += frag_size;
	}

	return done;
}
示例#5
0
文件: driver.c 项目: 383530895/linux
/*
	Send channel number (i.e., switch to a different sound).
*/
int line6_send_program(struct usb_line6 *line6, u8 value)
{
	int retval;
	unsigned char *buffer;
	int partial;

	buffer = kmalloc(2, GFP_KERNEL);
	if (!buffer)
		return -ENOMEM;

	buffer[0] = LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_HOST;
	buffer[1] = value;

	retval = usb_interrupt_msg(line6->usbdev,
				   usb_sndintpipe(line6->usbdev,
						  line6->ep_control_write),
				   buffer, 2, &partial, LINE6_TIMEOUT * HZ);

	if (retval)
		dev_err(line6->ifcdev, "usb_interrupt_msg failed (%d)\n",
			retval);

	kfree(buffer);
	return retval;
}
示例#6
0
/*
	Send channel number (i.e., switch to a different sound).
*/
int line6_send_program(struct usb_line6 *line6, int value)
{
	int retval;
	unsigned char *buffer;
	unsigned int partial;

	buffer = kmalloc(2, GFP_KERNEL);

	if (!buffer) {
		dev_err(line6->ifcdev, "out of memory\n");
		return -ENOMEM;
	}

	buffer[0] = LINE6_PROGRAM_CHANGE | LINE6_CHANNEL_HOST;
	buffer[1] = value;

#if DO_DUMP_URB_SEND
	line6_write_hexdump(line6, 'S', buffer, 2);
#endif

	retval = usb_interrupt_msg(line6->usbdev,
				   usb_sndintpipe(line6->usbdev,
						  line6->ep_control_write),
				   buffer, 2, &partial, LINE6_TIMEOUT * HZ);

	if (retval)
		dev_err(line6->ifcdev, "usb_interrupt_msg failed (%d)\n", retval);

	kfree(buffer);
	return retval;
}
示例#7
0
static int usb6fire_comm_send_buffer(u8 *buffer, struct usb_device *dev)
{
	int ret;
	int actual_len;

	ret = usb_interrupt_msg(dev, usb_sndintpipe(dev, COMM_EP),
			buffer, buffer[1] + 2, &actual_len, HZ);
	if (ret < 0)
		return ret;
	else if (actual_len != buffer[1] + 2)
		return -EIO;
	return 0;
}
static int get_temp_value(struct usb_temper *temper_dev)
{
	int rc = 0;
	int l;

	memset(temper_dev->int_in_buffer, 0, TEMPER_INT_BUFFER_SIZE);

	rc = usb_control_msg(temper_dev->udev,
		usb_sndctrlpipe(temper_dev->udev, 0),
		TEMPER_CTRL_REQUEST,
		TEMPER_CTRL_REQUEST_TYPE,
		TEMPER_CTRL_VALUE,
		TEMPER_CTRL_INDEX,
		temper_dev->ctrl_out_buffer,
		TEMPER_CTRL_BUFFER_SIZE,
		HZ * 2);

	if (rc < 0) {
	        printk(KERN_ERR "temper: control message failed (%d)", rc);
		return rc;
        }

	rc = usb_interrupt_msg (temper_dev->udev,
		usb_rcvintpipe(temper_dev->udev, 2),
		temper_dev->int_in_buffer,
		TEMPER_INT_BUFFER_SIZE,
		&l,
		2 * HZ);
	if (rc < 0) {
	        printk(KERN_ERR "temper: interrupt message failed (%d)", rc);
	        temper_dev->temp_in = -1;
	        temper_dev->temp_out = -1;
		return rc;
        }

	temper_dev->temp_in =
		(temper_dev->int_in_buffer[3] & 0xff) + 
		((temper_dev->int_in_buffer[2] & 0xff) << 8); /* Raw */
	temper_dev->temp_in *= 125 / 32; /* m°C */

	temper_dev->temp_out =
		(temper_dev->int_in_buffer[5] & 0xff) + 
		((temper_dev->int_in_buffer[4] & 0xff) << 8); /* Raw */
	temper_dev->temp_out *= 125 / 32; /* m°C */

	return rc;
}
示例#9
0
/*
 * RPC done RNDIS-style.  Caller guarantees:
 * - message is properly byteswapped
 * - there's no other request pending
 * - buf can hold up to 1KB response (required by RNDIS spec)
 * On return, the first few entries are already byteswapped.
 *
 * Call context is likely probe(), before interface name is known,
 * which is why we won't try to use it in the diagnostics.
 */
int rndis_command(struct usbnet *dev, struct rndis_msg_hdr *buf, int buflen)
{
    struct cdc_state	*info = (void *) &dev->data;
    struct usb_cdc_notification notification;
    int			master_ifnum;
    int			retval;
    int			partial;
    unsigned		count;
    u32			xid = 0, msg_len, request_id, msg_type, rsp,
                status;

    /* REVISIT when this gets called from contexts other than probe() or
     * disconnect(): either serialize, or dispatch responses on xid
     */

    msg_type = le32_to_cpu(buf->msg_type);

    /* Issue the request; xid is unique, don't bother byteswapping it */
    if (likely(msg_type != RNDIS_MSG_HALT && msg_type != RNDIS_MSG_RESET)) {
        xid = dev->xid++;
        if (!xid)
            xid = dev->xid++;
        buf->request_id = (__force __le32) xid;
    }
    master_ifnum = info->control->cur_altsetting->desc.bInterfaceNumber;
    retval = usb_control_msg(dev->udev,
                             usb_sndctrlpipe(dev->udev, 0),
                             USB_CDC_SEND_ENCAPSULATED_COMMAND,
                             USB_TYPE_CLASS | USB_RECIP_INTERFACE,
                             0, master_ifnum,
                             buf, le32_to_cpu(buf->msg_len),
                             RNDIS_CONTROL_TIMEOUT_MS);
    if (unlikely(retval < 0 || xid == 0))
        return retval;

    /* Some devices don't respond on the control channel until
     * polled on the status channel, so do that first. */
    if (dev->driver_info->data & RNDIS_DRIVER_DATA_POLL_STATUS) {
        retval = usb_interrupt_msg(
                     dev->udev,
                     usb_rcvintpipe(dev->udev,
                                    dev->status->desc.bEndpointAddress),
                     &notification, sizeof(notification), &partial,
                     RNDIS_CONTROL_TIMEOUT_MS);
        if (unlikely(retval < 0))
            return retval;
    }

    /* Poll the control channel; the request probably completed immediately */
    rsp = le32_to_cpu(buf->msg_type) | RNDIS_MSG_COMPLETION;
    for (count = 0; count < 10; count++) {
        memset(buf, 0, CONTROL_BUFFER_SIZE);
        retval = usb_control_msg(dev->udev,
                                 usb_rcvctrlpipe(dev->udev, 0),
                                 USB_CDC_GET_ENCAPSULATED_RESPONSE,
                                 USB_DIR_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
                                 0, master_ifnum,
                                 buf, buflen,
                                 RNDIS_CONTROL_TIMEOUT_MS);
        if (likely(retval >= 8)) {
            msg_type = le32_to_cpu(buf->msg_type);
            msg_len = le32_to_cpu(buf->msg_len);
            status = le32_to_cpu(buf->status);
            request_id = (__force u32) buf->request_id;
            if (likely(msg_type == rsp)) {
                if (likely(request_id == xid)) {
                    if (unlikely(rsp == RNDIS_MSG_RESET_C))
                        return 0;
                    if (likely(RNDIS_STATUS_SUCCESS ==
                               status))
                        return 0;
                    dev_dbg(&info->control->dev,
                            "rndis reply status %08x\n",
                            status);
                    return -EL3RST;
                }
                dev_dbg(&info->control->dev,
                        "rndis reply id %d expected %d\n",
                        request_id, xid);
                /* then likely retry */
            } else switch (msg_type) {
                case RNDIS_MSG_INDICATE: /* fault/event */
                    rndis_msg_indicate(dev, (void *)buf, buflen);
                    break;
                case RNDIS_MSG_KEEPALIVE: { /* ping */
                    struct rndis_keepalive_c *msg = (void *)buf;

                    msg->msg_type = cpu_to_le32(RNDIS_MSG_KEEPALIVE_C);
                    msg->msg_len = cpu_to_le32(sizeof *msg);
                    msg->status = cpu_to_le32(RNDIS_STATUS_SUCCESS);
                    retval = usb_control_msg(dev->udev,
                                             usb_sndctrlpipe(dev->udev, 0),
                                             USB_CDC_SEND_ENCAPSULATED_COMMAND,
                                             USB_TYPE_CLASS | USB_RECIP_INTERFACE,
                                             0, master_ifnum,
                                             msg, sizeof *msg,
                                             RNDIS_CONTROL_TIMEOUT_MS);
                    if (unlikely(retval < 0))
                        dev_dbg(&info->control->dev,
                                "rndis keepalive err %d\n",
                                retval);
                }
                break;
                default:
                    dev_dbg(&info->control->dev,
                            "unexpected rndis msg %08x len %d\n",
                            le32_to_cpu(buf->msg_type), msg_len);
                }
        } else {
            /* device probably issued a protocol stall; ignore */
            dev_dbg(&info->control->dev,
                    "rndis response error, code %d\n", retval);
        }
        msleep(20);
    }
    dev_dbg(&info->control->dev, "rndis response timeout\n");
    return -ETIMEDOUT;
}
示例#10
0
static int p54u_upload_firmware_net2280(struct ieee80211_hw *dev)
{
	struct p54u_priv *priv = dev->priv;
	const struct firmware *fw_entry = NULL;
	const struct p54p_csr *devreg = (const struct p54p_csr *) P54U_DEV_BASE;
	int err, alen;
	void *buf;
	__le32 reg;
	unsigned int remains, offset;
	const u8 *data;

	buf = kmalloc(512, GFP_KERNEL);
	if (!buf) {
		printk(KERN_ERR "p54usb: firmware buffer alloc failed!\n");
		return -ENOMEM;
	}

	err = request_firmware(&fw_entry, "isl3890usb", &priv->udev->dev);
	if (err) {
		printk(KERN_ERR "p54usb: cannot find firmware (isl3890usb)!\n");
		kfree(buf);
		return err;
	}

	p54_parse_firmware(dev, fw_entry);

#define P54U_WRITE(type, addr, data) \
	do {\
		err = p54u_write(priv, buf, type,\
				 cpu_to_le32((u32)(unsigned long)addr), data);\
		if (err) \
			goto fail;\
	} while (0)

#define P54U_READ(type, addr) \
	do {\
		err = p54u_read(priv, buf, type,\
				cpu_to_le32((u32)(unsigned long)addr), &reg);\
		if (err)\
			goto fail;\
	} while (0)

	/* power down net2280 bridge */
	P54U_READ(NET2280_BRG_U32, NET2280_GPIOCTL);
	reg |= cpu_to_le32(P54U_BRG_POWER_DOWN);
	reg &= cpu_to_le32(~P54U_BRG_POWER_UP);
	P54U_WRITE(NET2280_BRG_U32, NET2280_GPIOCTL, reg);

	mdelay(100);

	/* power up bridge */
	reg |= cpu_to_le32(P54U_BRG_POWER_UP);
	reg &= cpu_to_le32(~P54U_BRG_POWER_DOWN);
	P54U_WRITE(NET2280_BRG_U32, NET2280_GPIOCTL, reg);

	mdelay(100);

	P54U_WRITE(NET2280_BRG_U32, NET2280_DEVINIT,
		   cpu_to_le32(NET2280_CLK_30Mhz |
			       NET2280_PCI_ENABLE |
			       NET2280_PCI_SOFT_RESET));

	mdelay(20);

	P54U_WRITE(NET2280_BRG_CFG_U16, PCI_COMMAND,
		   cpu_to_le32(PCI_COMMAND_MEMORY |
			       PCI_COMMAND_MASTER));

	P54U_WRITE(NET2280_BRG_CFG_U32, PCI_BASE_ADDRESS_0,
		   cpu_to_le32(NET2280_BASE));

	P54U_READ(NET2280_BRG_CFG_U16, PCI_STATUS);
	reg |= cpu_to_le32(PCI_STATUS_REC_MASTER_ABORT);
	P54U_WRITE(NET2280_BRG_CFG_U16, PCI_STATUS, reg);

	// TODO: we really need this?
	P54U_READ(NET2280_BRG_U32, NET2280_RELNUM);

	P54U_WRITE(NET2280_BRG_U32, NET2280_EPA_RSP,
		   cpu_to_le32(NET2280_CLEAR_NAK_OUT_PACKETS_MODE));
	P54U_WRITE(NET2280_BRG_U32, NET2280_EPC_RSP,
		   cpu_to_le32(NET2280_CLEAR_NAK_OUT_PACKETS_MODE));

	P54U_WRITE(NET2280_BRG_CFG_U32, PCI_BASE_ADDRESS_2,
		   cpu_to_le32(NET2280_BASE2));

	/* finally done setting up the bridge */

	P54U_WRITE(NET2280_DEV_CFG_U16, 0x10000 | PCI_COMMAND,
		   cpu_to_le32(PCI_COMMAND_MEMORY |
			       PCI_COMMAND_MASTER));

	P54U_WRITE(NET2280_DEV_CFG_U16, 0x10000 | 0x40 /* TRDY timeout */, 0);
	P54U_WRITE(NET2280_DEV_CFG_U32, 0x10000 | PCI_BASE_ADDRESS_0,
		   cpu_to_le32(P54U_DEV_BASE));

	P54U_WRITE(NET2280_BRG_U32, NET2280_USBIRQENB1, 0);
	P54U_WRITE(NET2280_BRG_U32, NET2280_IRQSTAT1,
		   cpu_to_le32(NET2280_PCI_INTA_INTERRUPT));

	/* do romboot */
	P54U_WRITE(NET2280_DEV_U32, &devreg->int_enable, 0);

	P54U_READ(NET2280_DEV_U32, &devreg->ctrl_stat);
	reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_RESET);
	reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_RAMBOOT);
	reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_CLKRUN);
	P54U_WRITE(NET2280_DEV_U32, &devreg->ctrl_stat, reg);

	mdelay(20);

	reg |= cpu_to_le32(ISL38XX_CTRL_STAT_RESET);
	P54U_WRITE(NET2280_DEV_U32, &devreg->ctrl_stat, reg);

	mdelay(20);

	reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_RESET);
	P54U_WRITE(NET2280_DEV_U32, &devreg->ctrl_stat, reg);

	mdelay(100);

	P54U_READ(NET2280_DEV_U32, &devreg->int_ident);
	P54U_WRITE(NET2280_DEV_U32, &devreg->int_ack, reg);

	/* finally, we can upload firmware now! */
	remains = fw_entry->size;
	data = fw_entry->data;
	offset = ISL38XX_DEV_FIRMWARE_ADDR;

	while (remains) {
		unsigned int block_len = min(remains, (unsigned int)512);
		memcpy(buf, data, block_len);

		err = p54u_bulk_msg(priv, P54U_PIPE_DATA, buf, block_len);
		if (err) {
			printk(KERN_ERR "prism54usb: firmware block upload "
			       "failed\n");
			goto fail;
		}

		P54U_WRITE(NET2280_DEV_U32, &devreg->direct_mem_base,
			   cpu_to_le32(0xc0000f00));

		P54U_WRITE(NET2280_DEV_U32,
			   0x0020 | (unsigned long)&devreg->direct_mem_win, 0);
		P54U_WRITE(NET2280_DEV_U32,
			   0x0020 | (unsigned long)&devreg->direct_mem_win,
			   cpu_to_le32(1));

		P54U_WRITE(NET2280_DEV_U32,
			   0x0024 | (unsigned long)&devreg->direct_mem_win,
			   cpu_to_le32(block_len));
		P54U_WRITE(NET2280_DEV_U32,
			   0x0028 | (unsigned long)&devreg->direct_mem_win,
			   cpu_to_le32(offset));

		P54U_WRITE(NET2280_DEV_U32, &devreg->dma_addr,
			   cpu_to_le32(NET2280_EPA_FIFO_PCI_ADDR));
		P54U_WRITE(NET2280_DEV_U32, &devreg->dma_len,
			   cpu_to_le32(block_len >> 2));
		P54U_WRITE(NET2280_DEV_U32, &devreg->dma_ctrl,
			   cpu_to_le32(ISL38XX_DMA_MASTER_CONTROL_TRIGGER));

		mdelay(10);

		P54U_READ(NET2280_DEV_U32,
			  0x002C | (unsigned long)&devreg->direct_mem_win);
		if (!(reg & cpu_to_le32(ISL38XX_DMA_STATUS_DONE)) ||
		    !(reg & cpu_to_le32(ISL38XX_DMA_STATUS_READY))) {
			printk(KERN_ERR "prism54usb: firmware DMA transfer "
			       "failed\n");
			goto fail;
		}

		P54U_WRITE(NET2280_BRG_U32, NET2280_EPA_STAT,
			   cpu_to_le32(NET2280_FIFO_FLUSH));

		remains -= block_len;
		data += block_len;
		offset += block_len;
	}

	/* do ramboot */
	P54U_READ(NET2280_DEV_U32, &devreg->ctrl_stat);
	reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_RESET);
	reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_CLKRUN);
	reg |= cpu_to_le32(ISL38XX_CTRL_STAT_RAMBOOT);
	P54U_WRITE(NET2280_DEV_U32, &devreg->ctrl_stat, reg);

	mdelay(20);

	reg |= cpu_to_le32(ISL38XX_CTRL_STAT_RESET);
	P54U_WRITE(NET2280_DEV_U32, &devreg->ctrl_stat, reg);

	reg &= cpu_to_le32(~ISL38XX_CTRL_STAT_RESET);
	P54U_WRITE(NET2280_DEV_U32, &devreg->ctrl_stat, reg);

	mdelay(100);

	P54U_READ(NET2280_DEV_U32, &devreg->int_ident);
	P54U_WRITE(NET2280_DEV_U32, &devreg->int_ack, reg);

	/* start up the firmware */
	P54U_WRITE(NET2280_DEV_U32, &devreg->int_enable,
		   cpu_to_le32(ISL38XX_INT_IDENT_INIT));

	P54U_WRITE(NET2280_BRG_U32, NET2280_IRQSTAT1,
		   cpu_to_le32(NET2280_PCI_INTA_INTERRUPT));

	P54U_WRITE(NET2280_BRG_U32, NET2280_USBIRQENB1,
		   cpu_to_le32(NET2280_PCI_INTA_INTERRUPT_ENABLE |
			       NET2280_USB_INTERRUPT_ENABLE));

	P54U_WRITE(NET2280_DEV_U32, &devreg->dev_int,
		   cpu_to_le32(ISL38XX_DEV_INT_RESET));

	err = usb_interrupt_msg(priv->udev,
				usb_rcvbulkpipe(priv->udev, P54U_PIPE_INT),
				buf, sizeof(__le32), &alen, 1000);
	if (err || alen != sizeof(__le32))
		goto fail;

	P54U_READ(NET2280_DEV_U32, &devreg->int_ident);
	P54U_WRITE(NET2280_DEV_U32, &devreg->int_ack, reg);

	if (!(reg & cpu_to_le32(ISL38XX_INT_IDENT_INIT)))
		err = -EINVAL;

	P54U_WRITE(NET2280_BRG_U32, NET2280_USBIRQENB1, 0);
	P54U_WRITE(NET2280_BRG_U32, NET2280_IRQSTAT1,
		   cpu_to_le32(NET2280_PCI_INTA_INTERRUPT));

#undef P54U_WRITE
#undef P54U_READ

 fail:
	release_firmware(fw_entry);
	kfree(buf);
	return err;
}
static int InterfaceAbortIdlemode(struct bcm_mini_adapter *Adapter, unsigned int Pattern)
{
	int 	status = STATUS_SUCCESS;
	unsigned int value;
	unsigned int chip_id ;
	unsigned long timeout = 0, itr = 0;

	int 	lenwritten = 0;
	unsigned char aucAbortPattern[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
	struct bcm_interface_adapter *psInterfaceAdapter = Adapter->pvInterfaceAdapter;

	/* Abort Bus suspend if its already suspended */
	if ((TRUE == psInterfaceAdapter->bSuspended) && (TRUE == Adapter->bDoSuspend)) {
		status = usb_autopm_get_interface(psInterfaceAdapter->interface);
		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "Bus got wakeup..Aborting Idle mode... status:%d \n", status);

	}

	if ((Adapter->ulPowerSaveMode == DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING)
									||
	   (Adapter->ulPowerSaveMode == DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE)) {
		/* write the SW abort pattern. */
		BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "Writing pattern<%d> to SW_ABORT_IDLEMODE_LOC\n", Pattern);
		status = wrmalt(Adapter, SW_ABORT_IDLEMODE_LOC, &Pattern, sizeof(Pattern));
		if (status) {
				BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "WRM to Register SW_ABORT_IDLEMODE_LOC failed..");
				return status;
		}
	}

	if (Adapter->ulPowerSaveMode == DEVICE_POWERSAVE_MODE_AS_MANUAL_CLOCK_GATING) {
		value = 0x80000000;
		status = wrmalt(Adapter, DEBUG_INTERRUPT_GENERATOR_REGISTOR, &value, sizeof(value));
		if (status)
		{
			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "WRM to DEBUG_INTERRUPT_GENERATOR_REGISTOR Register failed");
			return status;
		}
	} else if (Adapter->ulPowerSaveMode != DEVICE_POWERSAVE_MODE_AS_PROTOCOL_IDLE_MODE) {
		/*
		 * Get a Interrupt Out URB and send 8 Bytes Down
		 * To be Done in Thread Context.
		 * Not using Asynchronous Mechanism.
		 */
		status = usb_interrupt_msg (psInterfaceAdapter->udev,
			usb_sndintpipe(psInterfaceAdapter->udev,
			psInterfaceAdapter->sIntrOut.int_out_endpointAddr),
			aucAbortPattern,
			8,
			&lenwritten,
			5000);
		if (status) {
			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "Sending Abort pattern down fails with status:%d..\n", status);
			return status;
		} else {
			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "NOB Sent down :%d", lenwritten);
		}

		/* mdelay(25); */

		timeout = jiffies +  msecs_to_jiffies(50) ;
		while ( timeout > jiffies ) {
			itr++ ;
			rdmalt(Adapter, CHIP_ID_REG, &chip_id, sizeof(UINT));
			if (0xbece3200 == (chip_id&~(0xF0)))
				chip_id = chip_id&~(0xF0);
			if (chip_id == Adapter->chip_id)
				break;
		}
		if (timeout < jiffies )
			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "Not able to read chip-id even after 25 msec");
		else
			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_OTHERS, IDLE_MODE, DBG_LVL_ALL, "Number of completed iteration to read chip-id :%lu", itr);

		status = wrmalt(Adapter, SW_ABORT_IDLEMODE_LOC, &Pattern, sizeof(status));
		if (status) {
			BCM_DEBUG_PRINT(Adapter, DBG_TYPE_PRINTK, 0, 0, "WRM to Register SW_ABORT_IDLEMODE_LOC failed..");
			return status;
		}
	}
	return status;
}