Example #1
0
int sunxi_usb_disable_hcd(__u32 usbc_no)
{
#ifndef  SUNXI_USB_FPGA
	if (usbc_no == 0) {
#ifndef CONFIG_ARCH_SUN9IW1
		#if defined(CONFIG_USB_SUNXI_USB0_OTG) || defined(USB_SUNXI_USB0_HOST_ONLY)
			sunxi_usb_disable_hcd0();
		#endif
#endif
	} else if (usbc_no == 1) {
		#if defined(CONFIG_USB_SUNXI_EHCI0)
			sunxi_usb_disable_ehci(usbc_no);
		#endif

		#if defined(CONFIG_USB_SUNXI_OHCI0)
			sunxi_usb_disable_ohci(usbc_no);
		#endif
	} else if (usbc_no == 2) {
		#if defined(CONFIG_USB_SUNXI_EHCI1)
			sunxi_usb_disable_ehci(usbc_no);
		#endif

		#if defined(CONFIG_USB_SUNXI_OHCI1)
			sunxi_usb_disable_ohci(usbc_no);
		#endif
	} else {
		DMSG_PANIC("ERR: unkown usbc_no(%d)\n", usbc_no);
		return -1;
	}
#endif
	return 0;
}
Example #2
0
static void rmmod_host_driver(struct usb_msg_center_info *center_info)
{
	DMSG_INFO("\n\nrmmod_host_driver\n\n");
#if defined (CONFIG_ARCH_SUN8IW8) || defined (CONFIG_ARCH_SUN8IW7)

	#if defined(CONFIG_USB_SUNXI_EHCI0)
		sunxi_usb_disable_ehci(0);
	#endif

	#if defined(CONFIG_USB_SUNXI_OHCI0)
		sunxi_usb_disable_ohci(0);
	#endif
#else
{
	int ret = 0;

	ret = sunxi_usb_host0_disable();
	if (ret != 0) {
		DMSG_PANIC("err: disable hcd0 failed\n");
		return;
	}
}
#endif

	set_usb_role(center_info, USB_ROLE_NULL);
	return;
}
Example #3
0
static int sunxi_ohci_hcd_probe(struct platform_device *pdev)
{
	int ret;
	struct usb_hcd *hcd = NULL;
	struct sunxi_hci_hcd *sunxi_ohci = NULL;

	if(pdev == NULL){
		DMSG_PANIC("ERR: Argment is invaild\n");
		return -1;
	}

	/* if usb is disabled, can not probe */
	if (usb_disabled()){
		DMSG_PANIC("ERR: usb hcd is disabled\n");
		return -ENODEV;
	}

	sunxi_ohci = pdev->dev.platform_data;
	if(!sunxi_ohci){
		DMSG_PANIC("ERR: sunxi_ohci is null\n");
		ret = -ENOMEM;
		goto ERR1;
	}

	sunxi_ohci->pdev = pdev;
	g_sunxi_ohci[sunxi_ohci->usbc_no] = sunxi_ohci;

	DMSG_INFO("[%s%d]: probe, pdev->name: %s, pdev->id: %d, sunxi_ohci: 0x%p\n",
		ohci_name, sunxi_ohci->usbc_no, pdev->name, pdev->id, sunxi_ohci);

	/* get io resource */
	sunxi_get_io_resource(pdev, sunxi_ohci);

	sunxi_ohci->ohci_base = sunxi_ohci->usb_vbase + SUNXI_USB_OHCI_BASE_OFFSET;

	sunxi_ohci->ohci_reg_length = SUNXI_USB_OHCI_LEN;

	/*creat a usb_hcd for the ohci controller*/
	hcd = usb_create_hcd(&sunxi_ohci_hc_driver, &pdev->dev, ohci_name);
	if(!hcd){
		DMSG_PANIC("ERR: usb_ohci_create_hcd failed\n");
		ret = -ENOMEM;
		goto ERR2;
	}

	hcd->rsrc_start = (u32 __force)sunxi_ohci->ohci_base;
	hcd->rsrc_len 	= sunxi_ohci->ohci_reg_length;
	hcd->regs 	= sunxi_ohci->ohci_base;
	sunxi_ohci->hcd	= hcd;

	/* ochi start to work */
	sunxi_start_ohci(sunxi_ohci);

	ohci_hcd_init(hcd_to_ohci(hcd));

	ret = usb_add_hcd(hcd, sunxi_ohci->irq_no, IRQF_DISABLED | IRQF_SHARED);
	if(ret != 0){
		DMSG_PANIC("ERR: usb_add_hcd failed\n");
		ret = -ENOMEM;
		goto ERR3;
	}

	platform_set_drvdata(pdev, hcd);

	device_enable_async_suspend(&pdev->dev);

	sunxi_ohci->probe = 1;

	/* Disable ohci, when driver probe */
	if(sunxi_ohci->host_init_state == 0){
		if(ohci_first_probe[sunxi_ohci->usbc_no]){
			sunxi_usb_disable_ohci(sunxi_ohci->usbc_no);
			ohci_first_probe[sunxi_ohci->usbc_no]--;
		}
	}

	if(sunxi_ohci->not_suspend){
		scene_lock_init(&ohci_standby_lock[sunxi_ohci->usbc_no], SCENE_USB_STANDBY,  "ohci_standby");
	}

	return 0;

ERR3:
	usb_put_hcd(hcd);

ERR2:
	sunxi_ohci->hcd = NULL;
	g_sunxi_ohci[sunxi_ohci->usbc_no] = NULL;

ERR1:
	return ret;
}