コード例 #1
0
static int host_notifier_probe(struct platform_device *pdev)
{
	int ret = 0;

	dev_info(&pdev->dev, "notifier_prove\n");

	ninfo.pdata = pdev->dev.platform_data;
	if (!ninfo.pdata)
		return -ENODEV;

	ret = gpio_request(ninfo.pdata->gpio, "host_notifier");
	if (ret) {
		dev_err(&pdev->dev, "failed to request %d\n",
				ninfo.pdata->gpio);
		return -EPERM;
	}
	gpio_direction_input(ninfo.pdata->gpio);
	dev_info(&pdev->dev, "gpio = %d\n", ninfo.pdata->gpio);

	ninfo.pdata->ndev.set_booster = host_notifier_booster;
	ninfo.pdata->usbhostd_start = start_usbhostd_thread;
	ninfo.pdata->usbhostd_stop = stop_usbhostd_thread;

	host_notify_dev_register(&ninfo.pdata->ndev);
	wake_lock_init(&ninfo.wlock, WAKE_LOCK_SUSPEND, "hostd");

	return 0;
}
コード例 #2
0
static int host_notifier_probe(struct platform_device *pdev)
{
	int ret = 0;

	if (pdev && pdev->dev.platform_data)
		ninfo.pdata = pdev->dev.platform_data;
	else {
		pr_err("host_notifier: platform_data is null.\n");
		return -ENODEV;
	}

	dev_info(&pdev->dev, "notifier_probe\n");

	if (ninfo.pdata->thread_enable) {
		ret = gpio_request(ninfo.pdata->gpio, "host_notifier");
		if (ret) {
			dev_err(&pdev->dev, "failed to request %d\n",
				ninfo.pdata->gpio);
			return -EPERM;
		}
		gpio_direction_input(ninfo.pdata->gpio);
		dev_info(&pdev->dev, "gpio = %d\n", ninfo.pdata->gpio);

		ninfo.pdata->ndev.set_booster = host_notifier_booster;
		ninfo.pdata->usbhostd_start = start_usbhostd_thread;
		ninfo.pdata->usbhostd_stop = stop_usbhostd_thread;
	} else if (ninfo.pdata->irq_enable) {
		INIT_DELAYED_WORK(&ninfo.current_dwork, currentlimit_irq_work);
		schedule_delayed_work(&ninfo.current_dwork,
				msecs_to_jiffies(10000));
		ninfo.pdata->ndev.set_booster = host_notifier_booster;
		ninfo.pdata->usbhostd_start = start_usbhostd_notify;
		ninfo.pdata->usbhostd_stop = stop_usbhostd_notify;
	} else {
		ninfo.pdata->ndev.set_booster = host_notifier_booster;
		ninfo.pdata->usbhostd_start = start_usbhostd_notify;
		ninfo.pdata->usbhostd_stop = stop_usbhostd_notify;
	}

	ret = host_notify_dev_register(&ninfo.pdata->ndev);
	if (ret < 0) {
		dev_err(&pdev->dev, "Failed to host_notify_dev_register\n");
		return ret;
	}

	ovc_init(&ninfo);

#if defined(CONFIG_HAS_EARLYSUSPEND) && defined(CONFIG_FAST_BOOT)
	early_suspend.level = EARLY_SUSPEND_LEVEL_DISABLE_FB - 1;
	early_suspend.suspend = host_notifier_early_suspend;
	early_suspend.resume = host_notifier_late_resume;
	register_early_suspend(&early_suspend);
#endif
	wake_lock_init(&ninfo.wlock, WAKE_LOCK_SUSPEND, "hostd");

	return 0;
}
コード例 #3
0
ファイル: msm_otg_sec.c プロジェクト: sombree/Hulk-Kernel-V2
static int msm_host_notify_init(struct device *dev, struct msm_otg *motg)
{
	int ret = 0;

	INIT_WORK(&motg->otg_power_work, msm_otg_power_work);
	if (motg->pdata->otg_test_gpio) {
		int otg_test_irq = gpio_to_irq(motg->pdata->otg_test_gpio);

		ret = request_threaded_irq(otg_test_irq, NULL,
						msm_otg_test_irq,
						IRQF_TRIGGER_RISING |
						IRQF_TRIGGER_FALLING,
						"gpio_vbus", motg);
		if (ret)
			pr_err("request irq failed for otg_test\n");
		else
			pr_err("request irq succeed for otg_test\n");
	}

	motg->ndev.name = "usb_otg";
	motg->ndev.set_booster = msm_otg_set_id_state_pbatest;
	ret = host_notify_dev_register(&motg->ndev);
	if (ret)
		dev_err(dev, "Failed to host_notify_dev_register\n");
	else
		dev_info(dev, "success to host_notify_dev_register\n");

	INIT_WORK(&motg->notify_work, msm_otg_notify_work);
#ifdef MSM_OTG_LATE_INIT
	INIT_DELAYED_WORK(&motg->late_power_work,
					msm_otg_late_power_work);
	motg->notify_state = ACC_POWER_OFF;
#endif
	motg->init_state = true ;
	return 0;
}
コード例 #4
0
int set_otg_notify(struct otg_notify *n)
{
	int ret = 0;

	if (!u_notify) {
		ret = create_usb_notify();
		if (ret) {
			pr_err("unable create_usb_notify\n");
			goto err;
		}
	}

	if (u_notify->o_notify && n) {
		pr_err("error : already set o_notify\n");
		goto err;
	}

	pr_info("registered otg_notify +\n");
	if (!n) {
		pr_err("otg notify structure is null\n");
		ret = -EFAULT;
		goto err1;
	}
	u_notify->o_notify = n;

	ATOMIC_INIT_NOTIFIER_HEAD(&u_notify->o_notify->otg_notifier);
	u_notify->otg_nb.notifier_call = otg_notifier_callback;
	ret = atomic_notifier_chain_register(&u_notify->o_notify->otg_notifier,
				&u_notify->otg_nb);
	if (ret < 0) {
		pr_err("atomic_notifier_chain_register failed\n");
		goto err1;
	}

	BLOCKING_INIT_NOTIFIER_HEAD(&u_notify->o_notify->extra_notifier);
	u_notify->extra_nb.notifier_call = extra_notifier_callback;
	ret = blocking_notifier_chain_register
		(&u_notify->o_notify->extra_notifier, &u_notify->extra_nb);
	if (ret < 0) {
		pr_err("blocking_notifier_chain_register failed\n");
		goto err2;
	}

	if (!n->unsupport_host) {
		u_notify->ndev.name = "usb_otg";
		u_notify->ndev.set_booster = n->vbus_drive;
		ret = host_notify_dev_register(&u_notify->ndev);
		if (ret < 0) {
			pr_err("host_notify_dev_register is failed\n");
			goto err3;
		}

		if (!n->vbus_drive) {
			pr_err("vbus_drive is null\n");
			goto err4;
		}
	}

	if (gpio_is_valid(n->vbus_detect_gpio) ||
			gpio_is_valid(n->redriver_en_gpio)) {
		ret = register_gpios(n);
		if (ret < 0) {
			pr_err("register_gpios is failed\n");
			goto err4;
		}
	}

	if (n->is_wakelock)
		wake_lock_init(&u_notify->wlock,
			WAKE_LOCK_SUSPEND, "usb_notify");

	if (n->booting_delay_sec) {
		INIT_DELAYED_WORK(&u_notify->b_delay.booting_work,
				  reserve_state_check);
		schedule_delayed_work(&u_notify->b_delay.booting_work,
				n->booting_delay_sec*HZ);
	}
	register_usbdev_notify();

	pr_info("registered otg_notify -\n");
	return 0;
err4:
	if (!n->unsupport_host)
		host_notify_dev_unregister(&u_notify->ndev);
err3:
	blocking_notifier_chain_unregister(&u_notify->o_notify->extra_notifier,
				&u_notify->extra_nb);
err2:
	atomic_notifier_chain_unregister(&u_notify->o_notify->otg_notifier,
				&u_notify->otg_nb);
err1:
	u_notify->o_notify = NULL;
err:
	return ret;
}
コード例 #5
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;
}
コード例 #6
0
static int host_notifier_probe(struct platform_device *pdev)
{
	int ret = 0;
	int err = 0;
	int current_limit_irq = 0;

	dev_info(&pdev->dev, "notifier_prove\n");

	ninfo.pdata = pdev->dev.platform_data;
	if (!ninfo.pdata)
		return -ENODEV;

	if (!(ninfo.pdata->gpio < 0)) {
		ret = gpio_request(ninfo.pdata->gpio, "host_notifier");
		if (ret) {
			dev_err(&pdev->dev, "failed to request %d\n",
				ninfo.pdata->gpio);
		}
		gpio_direction_input(ninfo.pdata->gpio);
		dev_info(&pdev->dev, "gpio = %d\n", ninfo.pdata->gpio);
	}

	spin_lock_init(&ninfo.vbus_gpio.lock);

	if (ninfo.pdata->thread_enable) {
		ninfo.pdata->ndev.set_booster = host_notifier_booster;
		ninfo.pdata->usbhostd_start = start_usbhostd_thread;
		ninfo.pdata->usbhostd_stop = stop_usbhostd_thread;
		ninfo.pdata->usbhostd_wakeup = wakeup_usbhostd_thread;
	} else {
		if (!(ninfo.pdata->gpio < 0)) {
			ninfo.vbus_gpio.gpio_status
				= __gpio_get_value(ninfo.pdata->gpio);
			current_limit_irq = gpio_to_irq(ninfo.pdata->gpio);
			err = request_threaded_irq(current_limit_irq,
					host_notifier_currentlimit_irq_isr,
					host_notifier_currentlimit_irq_thread,
					(IRQF_TRIGGER_FALLING |
						IRQF_TRIGGER_RISING |
							IRQF_ONESHOT),
					dev_name(&pdev->dev),
					NULL);
			if (err)
				dev_err(&pdev->dev, "Failed to register IRQ\n");
		}
		ninfo.pdata->ndev.set_booster = host_notifier_booster;
		ninfo.pdata->usbhostd_start = start_usbhostd_notify;
		ninfo.pdata->usbhostd_stop = stop_usbhostd_notify;
	}

	ret = host_notify_dev_register(&ninfo.pdata->ndev);
	if (ret < 0) {
		dev_err(&pdev->dev, "Failed to host_notify_dev_register\n");
		if (!err && current_limit_irq)
			free_irq(current_limit_irq, NULL);
		return ret;
	}
	wake_lock_init(&ninfo.wlock, WAKE_LOCK_SUSPEND, "hostd");

	return 0;
}
コード例 #7
0
static int __devinit ehci_msm_probe(struct platform_device *pdev)
{
	struct usb_hcd *hcd;
	struct resource *res;
	struct msm_usb_host_platform_data *pdata;
	int retval;
	struct msmusb_hcd *mhcd;

	hcd = usb_create_hcd(&msm_hc_driver, &pdev->dev, dev_name(&pdev->dev));
	if (!hcd)
		return  -ENOMEM;

	hcd->irq = platform_get_irq(pdev, 0);
	if (hcd->irq < 0) {
		usb_put_hcd(hcd);
		return hcd->irq;
	}

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	if (!res) {
		usb_put_hcd(hcd);
		return -ENODEV;
	}

	hcd->rsrc_start = res->start;
	hcd->rsrc_len = resource_size(res);

	mhcd = hcd_to_mhcd(hcd);
	spin_lock_init(&mhcd->lock);
	mhcd->in_lpm = 0;
	mhcd->running = 0;
	device_init_wakeup(&pdev->dev, 1);

	pdata = pdev->dev.platform_data;
	if (PHY_TYPE(pdata->phy_info) == USB_PHY_UNDEFINED) {
		usb_put_hcd(hcd);
		return -ENODEV;
	}
	hcd->power_budget = pdata->power_budget;
	mhcd->pdata = pdata;
	INIT_WORK(&mhcd->lpm_exit_work, usb_lpm_exit_w);

	wake_lock_init(&mhcd->wlock, WAKE_LOCK_SUSPEND, dev_name(&pdev->dev));
	pdata->ebi1_clk = clk_get(&pdev->dev, "core_clk");
	if (IS_ERR(pdata->ebi1_clk))
		pdata->ebi1_clk = NULL;
	else
		clk_set_rate(pdata->ebi1_clk, INT_MAX);

#ifdef CONFIG_USB_HOST_NOTIFY
		if (pdata->host_notify) {
			hcd->host_notify = pdata->host_notify;
			hcd->ndev.name = dev_name(&pdev->dev);
			retval = host_notify_dev_register(&hcd->ndev);
			if (retval) {
				dev_err(&pdev->dev, "Failed to host_notify_dev_register\n");
				return -ENODEV;
			}
		}
#endif
	retval = msm_xusb_init_host(pdev, mhcd);

	if (retval < 0) {
		wake_lock_destroy(&mhcd->wlock);
		usb_put_hcd(hcd);
		clk_put(pdata->ebi1_clk);
	}

	pm_runtime_enable(&pdev->dev);

	return retval;
}