コード例 #1
0
static int s5pc110_stop_otg(void)
{
	struct sec_otghost *otghost = NULL;
	struct sec_otghost_data *otgdata = NULL;

	pr_info("+++++ OTG STOP\n");

	otg_dbg(OTG_DBG_OTGHCDI_DRIVER, "s5pc110_stop_otg\n");

	otghost = hcd_to_sec_otghost(g_pUsbHcd);

#ifdef CONFIG_USB_HOST_NOTIFY
	host_notify_dev_unregister(&g_pUsbHcd->ndev);
#endif

	otg_hcd_deinit_modules(otghost);

	destroy_workqueue(otghost->wq);

	wake_unlock(&otghost->wake_lock);
	wake_lock_destroy(&otghost->wake_lock);

	usb_remove_hcd(g_pUsbHcd);

#if 1
	if (g_pUDCBase == S3C_VA_HSOTG) {
		pr_info("otg release_mem_region\n");
		release_mem_region(g_pUsbHcd->rsrc_start, g_pUsbHcd->rsrc_len);
	}
#endif

	usb_put_hcd(g_pUsbHcd);

	otgdata = otghost->otg_data;
	if (otgdata && otgdata->phy_exit && otgdata->pdev) {
		pr_info("otg phy_off\n");
		otgdata->phy_exit(0);
	}

	return 0;
}
コード例 #2
0
/**
 * static int s3c6410_otg_drv_remove (struct platform_device *dev)
 * 
 * @brief remove function of OTG hcd platform_driver
 * 
 * @param [in] pdev : pointer of platform_device of otg hcd platform_driver
 * 
 * @return USB_ERR_SUCCESS : If success \n
 *         USB_ERR_FAIL : If fail \n
 * @remark 
 * This function is called when the otg device unregistered with the
 * s3c6410_otg_driver. This happens, for example, when the rmmod command is
 * executed. The device may or may not be electrically present. If it is
 * present, the driver stops device processing. Any resources used on behalf
 * of this device are freed.
 */
static int s3c6410_otg_drv_remove (struct platform_device *dev) 
{     
	otg_dbg(OTG_DBG_OTGHCDI_DRIVER, "s3c6410_otg_drv_remove \n");		

	otg_hcd_deinit_modules();

	usb_remove_hcd(g_pUsbHcd);
	
	release_mem_region(g_pUsbHcd->rsrc_start, g_pUsbHcd->rsrc_len);

	usb_put_hcd(g_pUsbHcd);

	if (otg_clock != NULL) {
		clk_disable(otg_clock);
		clk_put(otg_clock);
		otg_clock = NULL;
	}

	
	return USB_ERR_SUCCESS;
} 
コード例 #3
0
static int s3c6410_otg_drv_probe (struct platform_device *pdev)
{

	int ret_val = 0;
	u32 reg_val = 0;
	
	otg_dbg(OTG_DBG_OTGHCDI_DRIVER, "s3c_otg_drv_probe \n");
	
	otg_clock = clk_get(&pdev->dev, "otg");
	if (otg_clock == NULL) {
		printk(KERN_INFO "failed to find otg clock source\n");
		return -ENOENT;
	}
	clk_enable(otg_clock);

///init for host mode
/** 
	Allocate memory for the base HCD &	Initialize the base HCD.
*/
	g_pUsbHcd = usb_create_hcd(&s3c6410_otg_hc_driver, &pdev->dev, dev_name(&pdev->dev));
	if (g_pUsbHcd == NULL) 
	{
		ret_val = -ENOMEM;
		otg_err(OTG_DBG_OTGHCDI_DRIVER, "failed to usb_create_hcd\n");
		goto err_out_clk;
	}


//	mapping hcd resource & device resource
	
	g_pUsbHcd->rsrc_start = pdev->resource[0].start;
	g_pUsbHcd->rsrc_len   = pdev->resource[0].end - pdev->resource[0].start + 1;

	if (!request_mem_region(g_pUsbHcd->rsrc_start, g_pUsbHcd->rsrc_len, gHcdName)) 
	{
		otg_err(OTG_DBG_OTGHCDI_DRIVER, "failed to request_mem_region\n");
		reg_val = -EBUSY;
		goto err_out_create_hcd;
	}


//Physical address => Virtual address
	g_pUsbHcd->regs = S3C_VA_OTG; 
	g_pUsbHcd->self.otg_port = 1;
	
	g_pUDCBase = (u8 *)g_pUsbHcd->regs;

	/// call others' init()
	reg_val = otg_hcd_init_modules();
	if( reg_val != USB_ERR_SUCCESS)
	{		
		otg_err(OTG_DBG_OTGHCDI_DRIVER, "failed to otg_hcd_init_modules\n");
		reg_val = USB_ERR_FAIL;
		goto err_out_create_hcd;
	}

	/**
	 * Attempt to ensure this device is really a s3c6410 USB-OTG Controller.
	 * Read and verify the SNPSID register contents. The value should be
	 * 0x45F42XXX, which corresponds to "OT2", as in "OTG version 2.XX".
	 */
	//reg_val = read_reg_32((unsigned int *)((u8 *)g_pUsbHcd->regs + 0x40)); 
	
	reg_val = read_reg_32(0x40); 
	if ((reg_val & 0xFFFFF000) != 0x4F542000) 
	{
		otg_err(OTG_DBG_OTGHCDI_DRIVER, "Bad value for SNPSID: 0x%x\n", reg_val);
		ret_val = -EINVAL;
		goto err_out_create_hcd_init;
	}

	/*
	 * Finish generic HCD initialization and start the HCD. This function
	 * allocates the DMA buffer pool, registers the USB bus, requests the
	 * IRQ line, and calls s3c6410_otghcd_start method.
	 */
	ret_val = usb_add_hcd(g_pUsbHcd, pdev->resource[1].start, IRQF_DISABLED);
	if (ret_val < 0) 
	{
		goto err_out_create_hcd_init;
	}

	otg_dbg(OTG_DBG_OTGHCDI_DRIVER,"OTG HCD Initialized HCD, bus=%s, usbbus=%d\n", 
		    "EMSP OTG Controller", g_pUsbHcd->self.busnum);
	return USB_ERR_SUCCESS;

err_out_create_hcd_init:	
	otg_hcd_deinit_modules();
	release_mem_region(g_pUsbHcd->rsrc_start, g_pUsbHcd->rsrc_len);

err_out_create_hcd: 
	usb_put_hcd(g_pUsbHcd);
	
err_out_clk:
	
	return ret_val;
}
コード例 #4
0
static int s5pc110_start_otg(u32 regs)
{
	int ret_val = 0;
	u32 reg_val = 0;
	struct platform_device *pdev = g_pdev;
	struct sec_otghost *otghost = NULL;
	struct sec_otghost_data *otg_data = dev_get_platdata(&pdev->dev);

	otg_dbg(OTG_DBG_OTGHCDI_DRIVER, "s3c_otg_drv_probe\n");
	pr_info("otg probe start : 0x%x\n", regs);


	/*init for host mode*/
	/**
	Allocate memory for the base HCD &	Initialize the base HCD.
	*/
	g_pUsbHcd = usb_create_hcd(&s5pc110_otg_hc_driver, &pdev->dev,
					"s3cotg");/*pdev->dev.bus_id*/
	if (g_pUsbHcd == NULL) {
		ret_val = -ENOMEM;
		otg_err(OTG_DBG_OTGHCDI_DRIVER,
			"failed to usb_create_hcd\n");
		goto err_out_clk;
	}

#if 1
	pr_info("otg probe regs : 0x%p\n", otg_data->regs);

	if (!regs) {
		pr_info("otg mapping hcd resource\n");
		/* mapping hcd resource & device resource*/

		g_pUsbHcd->rsrc_start = pdev->resource[0].start;
		g_pUsbHcd->rsrc_len   = pdev->resource[0].end -
			pdev->resource[0].start + 1;

		if (!request_mem_region(g_pUsbHcd->rsrc_start,
					g_pUsbHcd->rsrc_len, gHcdName)) {
			otg_err(OTG_DBG_OTGHCDI_DRIVER,
					"failed to request_mem_region\n");
			ret_val = -EBUSY;
			goto err_out_create_hcd;
		}

		pr_info("otg rsrc_start %llu, ren %llu\n",
				g_pUsbHcd->rsrc_start,
				g_pUsbHcd->rsrc_len);

		pr_info("otg regs : %p\n", S3C_VA_HSOTG);

		/* Physical address => Virtual address */
		g_pUsbHcd->regs = S3C_VA_HSOTG;
		g_pUDCBase = (u8 *)g_pUsbHcd->regs;

	} else
		g_pUDCBase = (u8 *)regs;
#endif
	pr_info("otg g_pUDCBase 0x%p\n", g_pUDCBase);

	g_pUsbHcd->self.otg_port = 1;

	otghost = hcd_to_sec_otghost(g_pUsbHcd);

	if (otghost == NULL) {
		otg_err(true, "failed to get otghost hcd\n");
		ret_val = USB_ERR_FAIL;
		goto err_out_create_hcd;
	}
	otghost->otg_data = otg_data;

	INIT_WORK(&otghost->work, otg_power_work);
	otghost->wq = create_singlethread_workqueue("sec_otghostd");

	/* call others' init() */
	ret_val = otg_hcd_init_modules(otghost);
	if (ret_val != USB_ERR_SUCCESS) {
		otg_err(OTG_DBG_OTGHCDI_DRIVER,
			"failed to otg_hcd_init_modules\n");
		ret_val = USB_ERR_FAIL;
		goto err_out_create_hcd;
	}

	/**
	 * Attempt to ensure this device is really a s5pc110 USB-OTG Controller.
	 * Read and verify the SNPSID register contents. The value should be
	 * 0x45F42XXX, which corresponds to "OT2", as in "OTG version 2.XX".
	 */
	reg_val = read_reg_32(0x40);
	pr_info("otg reg 0x40 = %x\n", reg_val);
	if ((reg_val & 0xFFFFF000) != 0x4F542000) {
		otg_err(OTG_DBG_OTGHCDI_DRIVER,
			"Bad value for SNPSID: 0x%x\n", reg_val);
		ret_val = -EINVAL;
		goto err_out_create_hcd_init;
	}
#ifdef CONFIG_USB_HOST_NOTIFY
	if (otg_data->host_notify) {
		g_pUsbHcd->host_notify = otg_data->host_notify;
		g_pUsbHcd->ndev.name = dev_name(&pdev->dev);
		ret_val = host_notify_dev_register(&g_pUsbHcd->ndev);
		if (ret_val) {
			otg_err(OTG_DBG_OTGHCDI_DRIVER,
				"Failed to host_notify_dev_register\n");
			goto err_out_create_hcd_init;
		}
	}
#endif
#ifdef CONFIG_USB_SEC_WHITELIST
	if (otg_data->sec_whlist_table_num)
		g_pUsbHcd->sec_whlist_table_num =
			otg_data->sec_whlist_table_num;
#endif

	/*
	 * Finish generic HCD initialization and start the HCD. This function
	 * allocates the DMA buffer pool, registers the USB bus, requests the
	 * IRQ line, and calls s5pc110_otghcd_start method.
	 */
	ret_val = usb_add_hcd(g_pUsbHcd,
			pdev->resource[1].start, IRQF_DISABLED);
	if (ret_val < 0) {
		otg_err(OTG_DBG_OTGHCDI_DRIVER,
			"Failed to add hcd driver\n");
		goto err_out_host_notify_register;
	}

	otg_dbg(OTG_DBG_OTGHCDI_DRIVER,
		"OTG HCD Initialized HCD, bus=%s, usbbus=%d\n",
		"C110 OTG Controller", g_pUsbHcd->self.busnum);

	/* otg_print_registers(); */

	wake_lock_init(&otghost->wake_lock, WAKE_LOCK_SUSPEND, "usb_otg");
	wake_lock(&otghost->wake_lock);

	return USB_ERR_SUCCESS;

err_out_host_notify_register:
#ifdef CONFIG_USB_HOST_NOTIFY
	host_notify_dev_unregister(&g_pUsbHcd->ndev);
#endif

err_out_create_hcd_init:
	otg_hcd_deinit_modules(otghost);
	if (!regs)
		release_mem_region(g_pUsbHcd->rsrc_start, g_pUsbHcd->rsrc_len);

err_out_create_hcd:
	usb_put_hcd(g_pUsbHcd);

err_out_clk:

	return ret_val;
}