예제 #1
0
/**
 * get_bd - get a null bd
 * @args - arg1: dir, arg2: ep number
 */
PBD get_bd(USB_DIR dir, DEV_UINT32 num)
{
	PBD ptr;

	if (dir == USB_RX) {
		ptr = (PBD) Rx_bd_List[num].pNext;

		os_printk(K_DEBUG, "%s Rx_bd_List[%d].pNext=%p\n", __func__, num,
			  (Rx_bd_List[num].pNext));

		if ((Rx_bd_List[num].pNext + 1) < Rx_bd_List[num].pEnd)
			Rx_bd_List[num].pNext++;
		else
			Rx_bd_List[num].pNext = Rx_bd_List[num].pStart;

	} else {
		ptr = (PBD) Tx_bd_List[num].pNext;

		os_printk(K_DEBUG, "%s Tx_gpd_List[%d].pNext=%p\n", __func__, num,
			  (Tx_bd_List[num].pNext));

		Tx_bd_List[num].pNext++;
		Tx_bd_List[num].pNext = Tx_bd_List[num].pNext + AT_BD_EXT_LEN;

		if (Tx_bd_List[num].pNext >= Tx_bd_List[num].pEnd) {
			Tx_bd_List[num].pNext = Tx_bd_List[num].pStart;
		}
	}
	return ptr;
}
예제 #2
0
/**
 * mu3d_hal_resume_qmu - resume qmu function
 * @args - arg1: ep number, arg2: dir
 */
void mu3d_hal_resume_qmu(DEV_INT32 q_num, USB_DIR dir)
{

#if defined(USB_RISC_CACHE_ENABLED)
	os_flushinvalidateDcache();
#endif

	if (dir == USB_TX) {
		os_writel(USB_QMU_TQCSR(q_num), QMU_Q_RESUME);
		if (!os_readl(USB_QMU_TQCSR(q_num))) {
			os_printk(K_DEBUG, "%s QMU_TQCSR[%d]=%x\n", __func__, q_num,
				  os_readl(USB_QMU_TQCSR(q_num)));
			os_writel(USB_QMU_TQCSR(q_num), QMU_Q_RESUME);
		}
	} else if (dir == USB_RX) {
		os_writel(USB_QMU_RQCSR(q_num), QMU_Q_RESUME);
		if (!os_readl(USB_QMU_RQCSR(q_num))) {
			os_printk(K_DEBUG, "%s QMU_RQCSR[%d]=%x\n", __func__, q_num,
				  os_readl(USB_QMU_RQCSR(q_num)));
			os_writel(USB_QMU_RQCSR(q_num), QMU_Q_RESUME);
		}
	} else {
		os_printk(K_INFO, "%s wrong direction!!!\n", __func__);
		BUG_ON(1);
	}
}
예제 #3
0
파일: mt_usb.c 프로젝트: Scorpio92/mediatek
void mt_usb_disconnect(void)
{
	os_printk(K_DEBUG,"%s\n", __func__);

	musb_stop(mu3d_musb);

	os_printk(K_DEBUG,"%s-\n", __func__);
}
예제 #4
0
파일: mt_usb.c 프로젝트: Scorpio92/mediatek
void mt_usb_connect(void)
{
	os_printk(K_DEBUG,"%s+\n", __func__);

	musb_start(mu3d_musb);

	os_printk(K_DEBUG,"%s-\n", __func__);
}
/*
 * print out a key in hex
 */
static void print_key(const char *tag, uint8_t *key, int bits)
{
	int bytes = (bits + 7) / 8;

	di_info("%s", tag);
	while (bytes--)
		os_printk("%02x", *key++);
	os_printk("\n");
}
예제 #6
0
static void dump(const char *name, const uint8_t * data, unsigned int len)
{
	os_printk("%s: ", name);
	while (len > 0) {
		os_printk("%02x ", (unsigned)*data++);
		len--;
	}
	os_printk("\n");
}
예제 #7
0
static inline void mtu3d_u2_common_intr_handler(u32 dwIntrUsbValue)
{
	if (dwIntrUsbValue & DISCONN_INTR) {
		mu3d_hal_pdn_ip_port(1, 0, 1, 1);

		os_printk(K_NOTICE, "[U2 DISCONN_INTR] Set SOFT_CONN=0\n");
		os_clrmsk(U3D_POWER_MANAGEMENT, SOFT_CONN);

		/*TODO-J: ADD musb_g_disconnect(musb);??*/
	}

	if (dwIntrUsbValue & LPM_INTR) 	{
		u32 rmwake ;
		rmwake = os_readl(U3D_POWER_MANAGEMENT);

		os_printk(K_NOTICE, "[U2 LPM interrupt] last rmwake is 0x%x\n", rmwake & LPM_RWP);

		if (!((os_readl(U3D_POWER_MANAGEMENT) & LPM_HRWE))) {
			mu3d_hal_pdn_ip_port(0, 0, 0, 1);
		}

#ifdef CONFIG_USBIF_COMPLIANCE
		// SW word around for USBIF test with Fresco FL1100 with LPM L1C enabling
		#if 0
		if (rmwake & LPM_RWP){
			os_writel(U3D_USB20_MISC_CONTROL, os_readl(U3D_USB20_MISC_CONTROL) | LPM_U3_ACK_EN);
			os_writel(U3D_POWER_MANAGEMENT, os_readl(U3D_POWER_MANAGEMENT) | RESUME);
		}
		#endif
#endif		
	}

	if (dwIntrUsbValue & LPM_RESUME_INTR) {
		if (!(os_readl(U3D_POWER_MANAGEMENT) & LPM_HRWE)) {
			mu3d_hal_pdn_ip_port(1, 0, 0, 1);

			os_writel(U3D_USB20_MISC_CONTROL, os_readl(U3D_USB20_MISC_CONTROL) | LPM_U3_ACK_EN);
		}
	}

	if(dwIntrUsbValue & SUSPEND_INTR) {
		os_printk(K_NOTICE, "[U2 SUSPEND_INTR]\n");
		mu3d_hal_pdn_ip_port(0, 0, 0, 1);
	}

	if (dwIntrUsbValue & RESUME_INTR) {
		os_printk(K_NOTICE,"[U2 RESUME_INTR]\n");
		mu3d_hal_pdn_ip_port(1, 0, 0, 1);
	}

	if (dwIntrUsbValue & RESET_INTR) {
		os_printk(K_NOTICE,"[U2 RESET_INTR]\n");
	}

}
예제 #8
0
/**
 * init_gpd_list - initialize gpd management list
 * @args - arg1: dir, arg2: ep number, arg3: gpd virtual addr, arg4: gpd ioremap addr, arg5: gpd number
 */
void init_gpd_list(USB_DIR dir, int num, PGPD ptr, PGPD io_ptr, DEV_UINT32 size)
{
	if (dir == USB_RX) {
		Rx_gpd_List[num].pStart = ptr;
		Rx_gpd_List[num].pEnd = (PGPD) (ptr + size);
		Rx_gpd_Offset[num] = (DEV_UINT32) ptr - (DEV_UINT32) io_ptr;	/* (DEV_UINT32)os_virt_to_phys(ptr); */
		ptr++;
		Rx_gpd_List[num].pNext = ptr;
		os_printk(K_DEBUG, "Rx_gpd_List[%d].pStart=%p, pNext=%p, pEnd=%p\n",
			  num, Rx_gpd_List[num].pStart, Rx_gpd_List[num].pNext,
			  Rx_gpd_List[num].pEnd);
		os_printk(K_DEBUG, "Rx_gpd_Offset[%d]=0x%08X\n", num, Rx_gpd_Offset[num]);
		os_printk(K_DEBUG, "virtual start=%p, end=%p\n", ptr, ptr + size);
		os_printk(K_DEBUG, "dma addr start=%p, end=%p\n", io_ptr, io_ptr + size);
	} else {
		Tx_gpd_List[num].pStart = ptr;
		Tx_gpd_List[num].pEnd = (PGPD) ((DEV_UINT8 *) (ptr + size) + AT_GPD_EXT_LEN * size);
		Tx_gpd_Offset[num] = (DEV_UINT32) ptr - (DEV_UINT32) io_ptr;	/* (DEV_UINT32)os_virt_to_phys(ptr); */
		ptr++;
		Tx_gpd_List[num].pNext = (PGPD) ((DEV_UINT8 *) ptr + AT_GPD_EXT_LEN);
		os_printk(K_DEBUG, "Tx_gpd_List[%d].pStart=%p, pNext=%p, pEnd=%p\n",
			  num, Tx_gpd_List[num].pStart, Tx_gpd_List[num].pNext,
			  Tx_gpd_List[num].pEnd);
		os_printk(K_DEBUG, "Tx_gpd_Offset[%d]=0x%08X\n", num, Tx_gpd_Offset[num]);
		os_printk(K_DEBUG, "virtual start=%p, end=%p\n", ptr, ptr + size);
		os_printk(K_DEBUG, "dma addr start=%p, end=%p\n", io_ptr, io_ptr + size);
	}
}
예제 #9
0
/**
 * mu3d_hal_init_qmu - initialize qmu
 *
 */
void mu3d_hal_init_qmu(void)
{
	DEV_UINT32 i;
	DEV_UINT32 QCR = 0;

	/* Initialize QMU Tx/Rx start address. */
	for (i = 1; i <= MAX_QMU_EP; i++) {
		os_printk(K_DEBUG, "==EP[%d]==Start addr RXQ=0x%08x, TXQ=0x%08x\n", i,
			  mu3d_hal_gpd_virt_to_phys(Rx_gpd_head[i], USB_RX, i),
			  mu3d_hal_gpd_virt_to_phys(Tx_gpd_head[i], USB_TX, i));
		QCR |= QMU_RX_EN(i);
		QCR |= QMU_TX_EN(i);
		os_writel(USB_QMU_RQSAR(i), mu3d_hal_gpd_virt_to_phys(Rx_gpd_head[i], USB_RX, i));
		os_writel(USB_QMU_TQSAR(i), mu3d_hal_gpd_virt_to_phys(Tx_gpd_head[i], USB_TX, i));
		Tx_gpd_end[i] = Tx_gpd_last[i] = Tx_gpd_head[i];
		Rx_gpd_end[i] = Rx_gpd_last[i] = Rx_gpd_head[i];
		gpd_ptr_align(USB_TX, i, Tx_gpd_end[i]);
		gpd_ptr_align(USB_RX, i, Rx_gpd_end[i]);
	}
	/* Enable QMU Tx/Rx. */
	os_writel(U3D_QGCSR, QCR);
	os_writel(U3D_QIESR0, QCR);
	/* Enable QMU interrupt. */
	os_writel(U3D_QIESR1,
		  TXQ_EMPTY_IESR | TXQ_CSERR_IESR | TXQ_LENERR_IESR | RXQ_EMPTY_IESR |
		  RXQ_CSERR_IESR | RXQ_LENERR_IESR | RXQ_ZLPERR_IESR);
	os_writel(U3D_EPIESR, EP0ISR);
}
예제 #10
0
static int hpt_attach(device_t dev)
{
	PHBA hba = (PHBA)device_get_softc(dev);
	HIM *him = hba->ldm_adapter.him;
	PCI_ID pci_id;
	HPT_UINT size;
	PVBUS vbus;
	PVBUS_EXT vbus_ext;

	KdPrint(("hpt_attach(%d/%d/%d)", pci_get_bus(dev), pci_get_slot(dev), pci_get_function(dev)));

	pci_enable_busmaster(dev);

	pci_id.vid = pci_get_vendor(dev);
	pci_id.did = pci_get_device(dev);
	pci_id.rev = pci_get_revid(dev);
	pci_id.subsys = (HPT_U32)(pci_get_subdevice(dev)) << 16 | pci_get_subvendor(dev);

	size = him->get_adapter_size(&pci_id);
	hba->ldm_adapter.him_handle = kmalloc(size, M_DEVBUF, M_WAITOK);
	if (!hba->ldm_adapter.him_handle)
		return ENXIO;

	hba->pcidev = dev;
	hba->pciaddr.tree = 0;
	hba->pciaddr.bus = pci_get_bus(dev);
	hba->pciaddr.device = pci_get_slot(dev);
	hba->pciaddr.function = pci_get_function(dev);

	if (!him->create_adapter(&pci_id, hba->pciaddr, hba->ldm_adapter.him_handle, hba)) {
		kfree(hba->ldm_adapter.him_handle, M_DEVBUF);
		return -1;
	}

	os_printk("adapter at PCI %d:%d:%d, IRQ %d",
		hba->pciaddr.bus, hba->pciaddr.device, hba->pciaddr.function, pci_get_irq(dev));

	if (!ldm_register_adapter(&hba->ldm_adapter)) {
		size = ldm_get_vbus_size();
		vbus_ext = kmalloc(sizeof(VBUS_EXT) + size, M_DEVBUF, M_WAITOK);
		if (!vbus_ext) {
			kfree(hba->ldm_adapter.him_handle, M_DEVBUF);
			return -1;
		}
		memset(vbus_ext, 0, sizeof(VBUS_EXT));
		vbus_ext->ext_type = EXT_TYPE_VBUS;
		ldm_create_vbus((PVBUS)vbus_ext->vbus, vbus_ext);
		ldm_register_adapter(&hba->ldm_adapter);
	}

	ldm_for_each_vbus(vbus, vbus_ext) {
		if (hba->ldm_adapter.vbus==vbus) {
			hba->vbus_ext = vbus_ext;
			hba->next = vbus_ext->hba_list;
			vbus_ext->hba_list = hba;
			break;
		}
	}
	return 0;
}
예제 #11
0
/**
 * Register the driver with the kernel.
 *
 * Call @c register_chrdev() to set this driver up as being
 * responsible for the SCC.  Save the major number for the driver
 * in scc2_test_major_node.
 *
 * Called from #scc2_test_init()
 *
 * @return 0 on success, -errno on failure.
 */
static os_error_code
setup_user_driver_interaction(void)
{
    os_error_code code = OS_ERROR_OK_S;

    os_driver_init_registration(reg_handle);
    os_driver_add_registration(reg_handle, OS_FN_OPEN,
                               OS_DEV_OPEN_REF(scc2_test_open));
    os_driver_add_registration(reg_handle, OS_FN_IOCTL,
                               OS_DEV_IOCTL_REF(scc2_test_ioctl));
    os_driver_add_registration(reg_handle, OS_FN_CLOSE,
                               OS_DEV_CLOSE_REF(scc2_test_release));
    code = os_driver_complete_registration(reg_handle, scc2_test_major_node,
                                               SCC2_TEST_DRIVER_NAME);

    if (code != OS_ERROR_OK_S) {
        /* failure ! */
        os_printk("SCC2 TEST Driver: register device driver failed: %d\n",
                  code);

        return code;
    }

    /* Save the major node value */
    if (scc2_test_major_node == 0) {
        /* We passed in a zero value, then one was assigned to us.  */
        scc2_test_major_node = code;
    }

    pr_debug("SCC2 TEST Driver:  Major node is %d\n", scc2_test_major_node);

    return code;
}
예제 #12
0
/*!
 * Function to handle "Security Alarm" indication from SCC.
 *
 * This function is registered with the Security Monitor ans the callback
 * function for the RNG driver.  Upon alarm, it will shut down the driver so
 * that no more random data can be retrieved.
 *
 * @return void
 */
static void rng_sec_failure(void)
{
	os_printk(KERN_ALERT "RNG Driver: Security Failure Alarm received.\n");

	rng_cleanup();

	return;
}
예제 #13
0
파일: mt_usb.c 프로젝트: Scorpio92/mediatek
/*--FOR INSTANT POWER ON USAGE--------------------------------------------------*/
static ssize_t mt_usb_show_cmode(struct device* dev, struct device_attribute *attr, char *buf)
{
	if (!dev) {
		os_printk(K_DEBUG,"dev is null!!\n");
		return 0;
	}
	return scnprintf(buf, PAGE_SIZE, "%d\n", cable_mode);
}
예제 #14
0
bool usb_cable_connected(void)
{
#ifdef CONFIG_POWER_EXT
	CHARGER_TYPE chg_type = mt_charger_type_detection();
	os_printk(K_INFO, "%s ext-chrdet=%d type=%d\n", __func__, upmu_get_rgs_chrdet(), chg_type);
	if (upmu_get_rgs_chrdet() && (chg_type == STANDARD_HOST))
#else
	os_printk(K_INFO, "%s chrdet=%d\n", __func__, upmu_is_chr_det());
	if (upmu_is_chr_det())
#endif
	{
		return true;
	} else {
		return false;
	}
	return true;
}
예제 #15
0
ssize_t musb_cmode_show(struct device* dev, struct device_attribute *attr, char *buf)
{
	if (!dev) {
		os_printk(K_ERR, "dev is null!!\n");
		return 0;
	}
	return sprintf(buf, "%s\n", usb_mode_str[cable_mode]);
}
예제 #16
0
void mt_usb_connect(void)
{
	struct delayed_work *work;

	os_printk(K_INFO, "%s+\n", __func__);
	if(_mu3d_musb) {
		work = &_mu3d_musb->connection_work;

		//if(!cancel_delayed_work(work))
		//	flush_workqueue(_mu3d_musb->wq);

		queue_delayed_work(_mu3d_musb->wq, work, 0);
	} else {
		os_printk(K_INFO, "%s musb_musb not ready\n", __func__);
	}
	os_printk(K_INFO, "%s-\n", __func__);
}
예제 #17
0
파일: mt_usb.c 프로젝트: Scorpio92/mediatek
void usb_check_connect(void)
{
	os_printk(K_DEBUG,"[MUSB] usb_check_connect\n");
#ifdef NEVER
#ifndef CONFIG_MTK_FPGA
	if (usb_cable_connected())
		mt_usb_connect();
#endif
#endif /* NEVER */
}
예제 #18
0
void musb_sync_with_bat(struct musb *musb, int usb_state)
{
	os_printk(K_INFO, "musb_sync_with_bat\n");

#ifndef CONFIG_MTK_FPGA
	BATTERY_SetUSBState(usb_state);
	wake_up_bat();
#endif

}
예제 #19
0
void usb_check_connect(void)
{
	os_printk(K_INFO, "usb_check_connect\n");

#ifndef CONFIG_MTK_FPGA
	if (usb_cable_connected())
		mt_usb_connect();
#endif

}
예제 #20
0
파일: mt_usb.c 프로젝트: Scorpio92/mediatek
void musb_sync_with_bat(struct musb *musb, int usb_state)
{
	os_printk(K_DEBUG,"[MUSB] musb_sync_with_bat\n");
#ifdef NEVER
#ifndef CONFIG_MTK_FPGA
	BATTERY_SetUSBState(usb_state);
	wake_up_bat();
#endif
#endif /* NEVER */
}
예제 #21
0
static inline void mtu3d_u2_common_intr_handler(u32 dwIntrUsbValue)
{
	if (dwIntrUsbValue & DISCONN_INTR) {
		mu3d_hal_pdn_ip_port(1, 0, 1, 1);

		os_printk(K_NOTICE, "[U2 DISCONN_INTR] Set SOFT_CONN=0\n");
		os_clrmsk(U3D_POWER_MANAGEMENT, SOFT_CONN);

		/*TODO-J: ADD musb_g_disconnect(musb);??*/
	}

	if (dwIntrUsbValue & LPM_INTR) 	{
		os_printk(K_NOTICE, "[U2 LPM interrupt]\n");

		if (!((os_readl(U3D_POWER_MANAGEMENT) & LPM_HRWE))) {
			mu3d_hal_pdn_ip_port(0, 0, 0, 1);
		}
	}

	if (dwIntrUsbValue & LPM_RESUME_INTR) {
		if (!(os_readl(U3D_POWER_MANAGEMENT) & LPM_HRWE)) {
			mu3d_hal_pdn_ip_port(1, 0, 0, 1);

			os_writel(U3D_USB20_MISC_CONTROL, os_readl(U3D_USB20_MISC_CONTROL) | LPM_U3_ACK_EN);
		}
	}

	if(dwIntrUsbValue & SUSPEND_INTR) {
		os_printk(K_NOTICE, "[U2 SUSPEND_INTR]\n");
		mu3d_hal_pdn_ip_port(0, 0, 0, 1);
	}

	if (dwIntrUsbValue & RESUME_INTR) {
		os_printk(K_NOTICE,"[U2 RESUME_INTR]\n");
		mu3d_hal_pdn_ip_port(1, 0, 0, 1);
	}

	if (dwIntrUsbValue & RESET_INTR) {
		os_printk(K_NOTICE,"[U2 RESET_INTR]\n");
	}

}
예제 #22
0
bool mt_usb_is_ready(void)
{
	os_printk(K_INFO, "USB is ready or not\n");
#ifdef NEVER
	if(!mtk_musb || !mtk_musb->is_ready)
		return false;
	else
		return true;
#endif /* NEVER */
	return true;
}
예제 #23
0
/**
 * mu3d_hal_stop_qmu - stop qmu function (after qmu stop, fifo should be flushed)
 * @args - arg1: ep number, arg2: dir
 */
void mu3d_hal_stop_qmu(DEV_INT32 q_num, USB_DIR dir)
{
	if (dir == USB_TX) {
		if (!(os_readl(USB_QMU_TQCSR(q_num)) & (QMU_Q_ACTIVE))) {
			os_printk(K_DEBUG, "Tx%d inActive Now!\n", q_num);
			return;
		}
		os_writel(USB_QMU_TQCSR(q_num), QMU_Q_STOP);
		while ((os_readl(USB_QMU_TQCSR(q_num)) & (QMU_Q_ACTIVE)));
		os_printk(K_CRIT, "Tx%d stop Now!\n", q_num);
	} else if (dir == USB_RX) {
		if (!(os_readl(USB_QMU_RQCSR(q_num)) & QMU_Q_ACTIVE)) {
			os_printk(K_DEBUG, "Rx%d inActive Now!\n", q_num);
			return;
		}
		os_writel(USB_QMU_RQCSR(q_num), QMU_Q_STOP);
		while ((os_readl(USB_QMU_RQCSR(q_num)) & (QMU_Q_ACTIVE)));
		os_printk(K_CRIT, "Rx%d stop now!\n", q_num);
	}
}
예제 #24
0
/**
 * gpd_phys_to_virt - map gpd physical address to virtual address
 * @args - arg1: physical address, arg2: dir, arg3: ep number
 * @return - virtual address
 */
void *gpd_phys_to_virt(void *paddr, USB_DIR dir, DEV_UINT32 num)
{
	DEV_UINT32 *ptr;

	os_printk(K_DEBUG, "%s paddr=%p, num=%d\n", __func__, paddr, num);

	if (dir == USB_RX) {
		os_printk(K_DEBUG, "%s Rx_gpd_Offset[%d]=0x%08X\n", __func__, num,
			  Rx_gpd_Offset[num]);
		ptr = (DEV_UINT32 *) ((DEV_UINT32) paddr + Rx_gpd_Offset[num]);
	} else {
		os_printk(K_DEBUG, "%s Tx_gpd_Offset[%d]=0x%08X\n", __func__, num,
			  Tx_gpd_Offset[num]);
		ptr = (DEV_UINT32 *) ((DEV_UINT32) paddr + Tx_gpd_Offset[num]);
	}
	/*os_printk(K_DEBUG,"%s %s[%d]phys=%p<->virt=%p\n", __func__, \
	   ((dir==USB_RX)?"RX":"TX"), num , paddr, ptr); */

	return ptr;
}
예제 #25
0
static inline void mtu3d_otg_intr_handler(u32 dwOtgIntValue)
{
	if (dwOtgIntValue & VBUS_CHG_INTR) {
		os_printk(K_NOTICE, "OTG: VBUS_CHG_INTR\n");
		os_setmsk(U3D_SSUSB_OTG_STS_CLR, SSUSB_VBUS_INTR_CLR);
	}

	//this interrupt is issued when B device becomes device
	if (dwOtgIntValue & SSUSB_CHG_B_ROLE_B) {
		os_printk(K_NOTICE, "OTG: CHG_B_ROLE_B\n");
		os_setmsk(U3D_SSUSB_OTG_STS_CLR, SSUSB_CHG_B_ROLE_B_CLR);

		//switch DMA module to device
		os_printk(K_NOTICE, "Switch DMA to device\n");
		os_clrmsk(U3D_SSUSB_U2_CTRL_0P, SSUSB_U2_PORT_HOST_SEL);
	}

	//this interrupt is issued when B device becomes host
	if (dwOtgIntValue & SSUSB_CHG_A_ROLE_B) {
		os_printk(K_NOTICE, "OTG: CHG_A_ROLE_B\n");
		os_setmsk(U3D_SSUSB_OTG_STS_CLR, SSUSB_CHG_A_ROLE_B_CLR);
	}

	//this interrupt is issued when IDDIG reads B
	if (dwOtgIntValue & SSUSB_ATTACH_B_ROLE) {
		os_printk(K_NOTICE, "OTG: CHG_ATTACH_B_ROLE\n");
		os_setmsk(U3D_SSUSB_OTG_STS_CLR, SSUSB_ATTACH_B_ROLE_CLR);

		//switch DMA module to device
		os_printk(K_NOTICE, "Switch DMA to device\n");
		os_clrmsk(U3D_SSUSB_U2_CTRL_0P, SSUSB_U2_PORT_HOST_SEL);
	}

}
/**
 * init_bd_list - initialize bd management list
 * @args - arg1: dir, arg2: ep number, arg3: bd virtual addr, arg4: bd ioremap addr, arg5: bd number
 */
void init_bd_list(USB_DIR dir, int num, PBD ptr, dma_addr_t io_ptr, DEV_UINT32 size)
{
	if (dir == USB_RX) {
		Rx_bd_List[num].pStart = ptr;
		Rx_bd_List[num].pEnd = (PBD)(ptr + size);
		rx_bd_map[num].p_desc = (void *)ptr;
		rx_bd_map[num].p_desc_dma = io_ptr;
		ptr++;
		Rx_bd_List[num].pNext = ptr;

		os_printk(K_DEBUG,"Rx_bd_List[%d].pStart=%p, pNext=%p, pEnd=%p\n", \
			num, Rx_bd_List[num].pStart, Rx_bd_List[num].pNext, Rx_bd_List[num].pEnd);

		os_printk(K_DEBUG,"rx_bd_map[%d] vir=%p dma=%08llx\n", num,
			rx_bd_map[num].p_desc, (unsigned long long) rx_bd_map[num].p_desc_dma);

		os_printk(K_DEBUG,"vir=%p dma=%08llx\n", ptr, (unsigned long long)io_ptr);
	} else {
		Tx_bd_List[num].pStart = ptr;
	 	Tx_bd_List[num].pEnd = (PBD)((DEV_UINT8*)(ptr + size) + AT_BD_EXT_LEN*size);
		tx_bd_map[num].p_desc = (void *)ptr;
		tx_bd_map[num].p_desc_dma = io_ptr;
		ptr++;
	 	Tx_bd_List[num].pNext = (PBD)((DEV_UINT8*)ptr + AT_BD_EXT_LEN);

		os_printk(K_DEBUG,"Tx_bd_List[%d].pStart=%p, pNext=%p, pEnd=%p\n", \
			num,Tx_bd_List[num].pStart, Tx_bd_List[num].pNext, Tx_bd_List[num].pEnd);

		os_printk(K_DEBUG,"tx_bd_map[%d] vir=%p dma=%08llx\n", num,
			tx_bd_map[num].p_desc, (unsigned long long) tx_bd_map[num].p_desc_dma);

		os_printk(K_DEBUG,"vir=%p, dma=%08llx\n", ptr, (unsigned long long)io_ptr);
	}
}
예제 #27
0
파일: sys_mm.c 프로젝트: LeafGrass/ousia
/*
 * @brief   dump memory
 * @param   addr -i- memory address
 *          nb -i- number of bytes to dump
 *          type -i- byte, half-word or word
 * @return  none
 * @note    TODO Only supports nb that can be divide by 8.
 *          TODO Need to complete type implementation.
 */
void _mm_dump(void *addr, int32 nb, int32 type)
{
	uint8 *m = (uint8 *) addr;
	int32 i, row;
	row = nb / 8;
	for (i = 0; i < row; i++) {
		m = (uint8 *) addr + i * 8;
		os_printk(LOG_INFO,
			  "%08x: %02x %02x %02x %02x %02x %02x %02x %02x\n",
			  m, *m, *(m + 1), *(m + 2), *(m + 3),
			  *(m + 4), *(m + 5), *(m + 6), *(m + 7));
	}
}
/**
 * mu3d_hal_gpd_virt_to_phys - map gpd virtual address to physical address
 * @args - arg1: virtual address, arg2: dir, arg3: ep number
 * @return - physical address
 */
dma_addr_t mu3d_hal_gpd_virt_to_phys(void *vaddr, USB_DIR dir, DEV_UINT32 num)
{
	uintptr_t ptr;

	if (dir == USB_RX) {
		ptr = rx_gpd_map[num].p_desc_dma + (dma_addr_t)(vaddr - rx_gpd_map[num].p_desc);
	} else {
		ptr = tx_gpd_map[num].p_desc_dma + (dma_addr_t)(vaddr - tx_gpd_map[num].p_desc);
	}
	os_printk( K_DEBUG, "%s %s[%d]phys=%lx<->virt=%p\n", __func__, \
		((dir == USB_RX) ? "RX" : "TX"), num, ptr, vaddr);

	return (dma_addr_t)ptr;
}
예제 #29
0
bool mt_usb_is_device(void)
{
	os_printk(K_INFO, "%s\n", __func__);
#ifdef NEVER
	if(!mtk_musb){
		DBG(0,"mtk_musb is NULL\n");
		return false; // don't do charger detection when usb is not ready
	} else {
		DBG(4,"is_host=%d\n",mtk_musb->is_host);
	}
	return !mtk_musb->is_host;
#endif /* NEVER */
	return true;
}
예제 #30
0
/*
 * This work is to fix IOT problem.
 * 1. PC(Lenovo MT-M5852-B88) + USB Host PCI-e TI(TUSB7340) or Fresco,
 *  --> PC enter SLERP/HIBERNATION --> USER wake up PC --> PC can not detect device.
 * 2. PC(Lenovo MT-M5852-B88) + USB Host PCI-e Fresco,
 *  --> PC COLD reboot --> PC can not detect device.
 * The root cause is that device try to link host too early. XHCI host does not ready to linkup.
 * So create a delayed work to re-tran when device is stuck at RxDetect.
 */
void check_ltssm_work(struct work_struct *data)
{
	//struct musb *musb = container_of(to_delayed_work(data), struct musb, check_ltssm_work);
#ifndef CONFIG_USBIF_COMPLIANCE
	os_printk(K_INFO, "%s %x\n", __func__, sts_ltssm);

	if(sts_ltssm == RXDET_SUCCESS_INTR) {
		sts_ltssm = 0;
		mu3d_hal_u3dev_dis();
		mdelay(10);
		mu3d_hal_u3dev_en();
	}
#endif
}