当前位置: 首页>>代码示例>>C++>>正文


C++ enable_irq_wake函数代码示例

本文整理汇总了C++中enable_irq_wake函数的典型用法代码示例。如果您正苦于以下问题:C++ enable_irq_wake函数的具体用法?C++ enable_irq_wake怎么用?C++ enable_irq_wake使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了enable_irq_wake函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: msm_otg_suspend

static int msm_otg_suspend(struct msm_otg *motg)
{
	struct usb_phy *phy = &motg->phy;
	struct usb_bus *bus = phy->otg->host;
	struct msm_otg_platform_data *pdata = motg->pdata;
	void __iomem *addr;
	int cnt = 0;

	if (atomic_read(&motg->in_lpm))
		return 0;

	disable_irq(motg->irq);
	/*
	 * Chipidea 45-nm PHY suspend sequence:
	 *
	 * Interrupt Latch Register auto-clear feature is not present
	 * in all PHY versions. Latch register is clear on read type.
	 * Clear latch register to avoid spurious wakeup from
	 * low power mode (LPM).
	 *
	 * PHY comparators are disabled when PHY enters into low power
	 * mode (LPM). Keep PHY comparators ON in LPM only when we expect
	 * VBUS/Id notifications from USB PHY. Otherwise turn off USB
	 * PHY comparators. This save significant amount of power.
	 *
	 * PLL is not turned off when PHY enters into low power mode (LPM).
	 * Disable PLL for maximum power savings.
	 */

	if (motg->pdata->phy_type == CI_45NM_INTEGRATED_PHY) {
		ulpi_read(phy, 0x14);
		if (pdata->otg_control == OTG_PHY_CONTROL)
			ulpi_write(phy, 0x01, 0x30);
		ulpi_write(phy, 0x08, 0x09);
	}

	/*
	 * PHY may take some time or even fail to enter into low power
	 * mode (LPM). Hence poll for 500 msec and reset the PHY and link
	 * in failure case.
	 */
	writel(readl(USB_PORTSC) | PORTSC_PHCD, USB_PORTSC);
	while (cnt < PHY_SUSPEND_TIMEOUT_USEC) {
		if (readl(USB_PORTSC) & PORTSC_PHCD)
			break;
		udelay(1);
		cnt++;
	}

	if (cnt >= PHY_SUSPEND_TIMEOUT_USEC) {
		dev_err(phy->dev, "Unable to suspend PHY\n");
		msm_otg_reset(phy);
		enable_irq(motg->irq);
		return -ETIMEDOUT;
	}

	/*
	 * PHY has capability to generate interrupt asynchronously in low
	 * power mode (LPM). This interrupt is level triggered. So USB IRQ
	 * line must be disabled till async interrupt enable bit is cleared
	 * in USBCMD register. Assert STP (ULPI interface STOP signal) to
	 * block data communication from PHY.
	 */
	writel(readl(USB_USBCMD) | ASYNC_INTR_CTRL | ULPI_STP_CTRL, USB_USBCMD);

	addr = USB_PHY_CTRL;
	if (motg->phy_number)
		addr = USB_PHY_CTRL2;

	if (motg->pdata->phy_type == SNPS_28NM_INTEGRATED_PHY &&
			motg->pdata->otg_control == OTG_PMIC_CONTROL)
		writel(readl(addr) | PHY_RETEN, addr);

	clk_disable_unprepare(motg->pclk);
	clk_disable_unprepare(motg->clk);
	if (!IS_ERR(motg->core_clk))
		clk_disable_unprepare(motg->core_clk);

	if (motg->pdata->phy_type == SNPS_28NM_INTEGRATED_PHY &&
			motg->pdata->otg_control == OTG_PMIC_CONTROL) {
		msm_hsusb_ldo_set_mode(motg, 0);
		msm_hsusb_config_vddcx(motg, 0);
	}

	if (device_may_wakeup(phy->dev))
		enable_irq_wake(motg->irq);
	if (bus)
		clear_bit(HCD_FLAG_HW_ACCESSIBLE, &(bus_to_hcd(bus))->flags);

	atomic_set(&motg->in_lpm, 1);
	enable_irq(motg->irq);

	dev_info(phy->dev, "USB in low power mode\n");

	return 0;
}
开发者ID:pgurenko,项目名称:VAR-SOM-AM33-Kernel-3-14,代码行数:96,代码来源:phy-msm-usb.c

示例2: pmic8xxx_kp_probe


//.........这里部分代码省略.........
    free_irq(kp->key_stuck_irq, kp);
err_pmic_reg_read:
    free_irq(kp->key_stuck_irq, kp);
err_req_stuck_irq:
    free_irq(kp->key_sense_irq, kp);
err_gpio_config:
err_get_irq:
    input_free_device(kp->input);
err_alloc_device:
    platform_set_drvdata(pdev, NULL);
    kfree(kp);
    return rc;
}

static int __devexit pmic8xxx_kp_remove(struct platform_device *pdev)
{
    struct pmic8xxx_kp *kp = platform_get_drvdata(pdev);

    device_init_wakeup(&pdev->dev, 0);
    free_irq(kp->key_stuck_irq, kp);
    free_irq(kp->key_sense_irq, kp);
    input_unregister_device(kp->input);
    kfree(kp);

    platform_set_drvdata(pdev, NULL);
    return 0;
}

#ifdef CONFIG_PM_SLEEP
static int pmic8xxx_kp_suspend(struct device *dev)
{
    struct platform_device *pdev = to_platform_device(dev);
    struct pmic8xxx_kp *kp = platform_get_drvdata(pdev);
    struct input_dev *input_dev = kp->input;

    if (device_may_wakeup(dev)) {
        enable_irq_wake(kp->key_sense_irq);
    } else {
        mutex_lock(&input_dev->mutex);

        if (input_dev->users)
            pmic8xxx_kp_disable(kp);

        mutex_unlock(&input_dev->mutex);
    }

    return 0;
}

static int pmic8xxx_kp_resume(struct device *dev)
{
    struct platform_device *pdev = to_platform_device(dev);
    struct pmic8xxx_kp *kp = platform_get_drvdata(pdev);
    struct input_dev *input_dev = kp->input;

    if (device_may_wakeup(dev)) {
        disable_irq_wake(kp->key_sense_irq);
    } else {
        mutex_lock(&input_dev->mutex);

        if (input_dev->users)
            pmic8xxx_kp_enable(kp);

        mutex_unlock(&input_dev->mutex);
    }

    return 0;
}
#endif

static SIMPLE_DEV_PM_OPS(pm8xxx_kp_pm_ops,
                         pmic8xxx_kp_suspend, pmic8xxx_kp_resume);

static struct platform_driver pmic8xxx_kp_driver = {
    .probe		= pmic8xxx_kp_probe,
    .remove		= __devexit_p(pmic8xxx_kp_remove),
    .driver		= {
        .name = PM8XXX_KEYPAD_DEV_NAME,
        .owner = THIS_MODULE,
        .pm = &pm8xxx_kp_pm_ops,
    },
};

static int __init pmic8xxx_kp_init(void)
{
    return platform_driver_register(&pmic8xxx_kp_driver);
}
module_init(pmic8xxx_kp_init);

static void __exit pmic8xxx_kp_exit(void)
{
    platform_driver_unregister(&pmic8xxx_kp_driver);
}
module_exit(pmic8xxx_kp_exit);

MODULE_LICENSE("GPL v2");
MODULE_DESCRIPTION("PMIC8XXX keypad driver");
MODULE_VERSION("1.0");
MODULE_ALIAS("platform:pmic8xxx_keypad");
MODULE_AUTHOR("Trilok Soni <[email protected]>");
开发者ID:ptmr3,项目名称:Skyrocket_JB_Kernel,代码行数:101,代码来源:pmic8xxx-keypad.c

示例3: baseband_xmm_power_driver_probe


//.........这里部分代码省略.........
		->modem.xmm.ipc_bb_force_crash;
	err = gpio_request_array(tegra_baseband_gpios,
		ARRAY_SIZE(tegra_baseband_gpios));
	if (err < 0) {
		pr_err("%s - request gpio(s) failed\n", __func__);
		return -ENODEV;
	}

	/* location is at /sys/devices/platform/baseband_xmm_power */
	for (i = 0; i < (ARRAY_SIZE(xmm_device_attr) - 1); i++) {
		err = device_create_file(dev, &xmm_device_attr[i]);
		if (err) {
			pr_err("create file %d failed, err = %d\n", i, err);
			goto failed_create_file;
		}
	}

	/* get regulator LDO7 for hsic power */
	if (!reg_grouper_hsic) {
		reg_grouper_hsic = regulator_get(NULL, "vddio_hsic");
		if (IS_ERR_OR_NULL(reg_grouper_hsic)) {
			pr_err("grouper 3G HSIC power on LDO7 failed\n");
			reg_grouper_hsic = NULL;
			return PTR_ERR(reg_grouper_hsic);
		}
		regulator_set_voltage(reg_grouper_hsic, 1200000, 1200000);
	}

	/* request baseband irq(s) */
	if (modem_flash && modem_pm) {
		pr_debug("%s: request_irq IPC_AP_WAKE_IRQ\n", __func__);
		ipc_ap_wake_state = IPC_AP_WAKE_UNINIT;
		err = request_threaded_irq(
			gpio_to_irq(data->modem.xmm.ipc_ap_wake),
			NULL,
			baseband_xmm_power_ipc_ap_wake_irq,
			IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
			"IPC_AP_WAKE_IRQ",
			NULL);
		if (err < 0) {
			pr_err("%s - request irq IPC_AP_WAKE_IRQ failed\n",
				__func__);
			return err;
		}
		ap_wake_irq = enable_irq_wake(gpio_to_irq(data->modem.xmm.ipc_ap_wake));
                tegra_pm_irq_set_wake_type(ap_wake_irq, IRQF_TRIGGER_FALLING);
                enable_irq_wake(ap_wake_irq);
		if (err < 0)
			 pr_err("%s: enable_irq_wake error\n", __func__);
		ipc_ap_wake_state = IPC_AP_WAKE_IRQ_READY;
		if (modem_ver >= XMM_MODEM_VER_1130) {
			pr_debug("%s: ver > 1130: AP_WAKE_INIT1\n", __func__);
			/* ver 1130 or later starts in INIT1 state */
			ipc_ap_wake_state = IPC_AP_WAKE_INIT1;
		}
	}

	/* init work queue */
	workqueue = create_singlethread_workqueue
		("baseband_xmm_power_workqueue");
	if (!workqueue) {
		pr_err("cannot create workqueue\n");
		return -1;
	}
	baseband_xmm_power_work = (struct baseband_xmm_power_work_t *)
		kmalloc(sizeof(struct baseband_xmm_power_work_t), GFP_KERNEL);
	if (!baseband_xmm_power_work) {
		pr_err("cannot allocate baseband_xmm_power_work\n");
		return -1;
	}
	INIT_WORK((struct work_struct *) baseband_xmm_power_work,
		baseband_xmm_power_work_func);
	baseband_xmm_power_work->state = BBXMM_WORK_INIT;
	queue_work(workqueue,
		(struct work_struct *) baseband_xmm_power_work);

	/* init work objects */
	INIT_WORK(&init1_work, baseband_xmm_power_init1_work);
	INIT_WORK(&init2_work, baseband_xmm_power_init2_work);
	INIT_WORK(&L2_resume_work, baseband_xmm_power_L2_resume_work);
	INIT_WORK(&autopm_resume_work, baseband_xmm_power_autopm_resume);

	/* init state variables */
	register_hsic_device = true;
	CP_initiated_L2toL0 = false;
	spin_lock_irqsave(&xmm_lock, flags);
	baseband_xmm_powerstate = BBXMM_PS_UNINIT;
	wakeup_pending = false;
	spin_unlock_irqrestore(&xmm_lock, flags);

	usb_register_notify(&usb_xmm_nb);

	pr_debug("%s }\n", __func__);
	return 0;

failed_create_file:
	while (i--)
		device_remove_file(dev, &xmm_device_attr[i]);
	return err;
}
开发者ID:AndroidDeveloperAlliance,项目名称:ZenKernel_Grouper,代码行数:101,代码来源:baseband-xmm-power.c

示例4: pn547_probe

static int pn547_probe(struct i2c_client *client,
        const struct i2c_device_id *id)
{
    int ret;
    struct pn547_dev *pn547_dev = NULL;
    pn547_client = client;

    dprintk(PN547_DRV_NAME ": pn547_probe() start\n");

    pn547_dev = kzalloc(sizeof(*pn547_dev), GFP_KERNEL);
    if (pn547_dev == NULL) {
        dev_err(&client->dev,
                "failed to allocate memory for module data\n");
        ret = -ENOMEM;
        goto err_exit;
    }

    pn547_parse_dt(&client->dev, pn547_dev);

    pn547_dev->client   = client;
    dprintk(PN547_DRV_NAME ":IRQ : %d\nVEN : %d\nFIRM : %d\n",
            pn547_dev->irq_gpio, pn547_dev->ven_gpio, pn547_dev->firm_gpio);

    ret = gpio_request(pn547_dev->irq_gpio, "nfc_int");
    if (ret) {
        dprintk(PN547_DRV_NAME ":pn547_probe() : nfc_int request failed!\n");
        goto err_int;
    }
    ret = gpio_request(pn547_dev->ven_gpio, "nfc_ven");
    if (ret) {
        dprintk(PN547_DRV_NAME ":pn547_probe() : nfc_ven request failed!\n");
        goto err_ven;
    }
    ret = gpio_request(pn547_dev->firm_gpio, "nfc_firm");
    if (ret) {
        dprintk(PN547_DRV_NAME ":pn547_probe() : nfc_firm request failed!\n");
        goto err_firm;
    }

    pn547_gpio_enable(pn547_dev);

    ret = gpio_direction_output(pn547_dev->ven_gpio,1);
    ret = gpio_direction_output(pn547_dev->firm_gpio,0);
    ret = gpio_direction_input(pn547_dev->irq_gpio);

    /* init mutex and queues */
    init_waitqueue_head(&pn547_dev->read_wq);
    mutex_init(&pn547_dev->read_mutex);
    spin_lock_init(&pn547_dev->irq_enabled_lock);

    pn547_dev->pn547_device.minor = MISC_DYNAMIC_MINOR;
    pn547_dev->pn547_device.name = PN547_DRV_NAME;
    pn547_dev->pn547_device.fops = &pn547_dev_fops;

    ret = misc_register(&pn547_dev->pn547_device);
    if (ret) {
        pr_err("%s : misc_register failed\n", __FILE__);
        goto err_misc_register;
    }

    wake_lock_init(&nfc_wake_lock, WAKE_LOCK_SUSPEND, "NFCWAKE");

    /* request irq.  the irq is set whenever the chip has data available
     * for reading.  it is cleared when all data has been read.
     */
    pr_info("%s : requesting IRQ %d\n", __func__, client->irq);
    pn547_dev->irq_enabled = true;
    ret = request_irq(pn547_gpio_to_irq(pn547_dev), pn547_dev_irq_handler,
              IRQF_TRIGGER_RISING|IRQF_NO_SUSPEND, client->name, pn547_dev);
    if (ret) {
        dev_err(&client->dev, "request_irq failed\n");
        goto err_request_irq_failed;
    }
    enable_irq_wake(pn547_get_irq_pin(pn547_dev));
    pn547_disable_irq(pn547_dev);
    i2c_set_clientdata(client, pn547_dev);
    dprintk(PN547_DRV_NAME ": pn547_probe() end\n");
    return 0;

err_request_irq_failed:
    misc_deregister(&pn547_dev->pn547_device);

err_misc_register:
    mutex_destroy(&pn547_dev->read_mutex);
    gpio_free(pn547_dev->firm_gpio);

err_firm:
    gpio_free(pn547_dev->ven_gpio);

err_ven:
    gpio_free(pn547_dev->irq_gpio);

err_int:
    kfree(pn547_dev);

err_exit:
    pr_err(PN547_DRV_NAME ": pn547_dev is null\n");
    pr_err(PN547_DRV_NAME ": pn547_probe() end with error!\n");

    return ret;
//.........这里部分代码省略.........
开发者ID:TheNotOnly,项目名称:android_kernel_lge_jagnm_kk,代码行数:101,代码来源:pn547_lge.c

示例5: tps6591x_rtc_probe

static int __devinit tps6591x_rtc_probe(struct platform_device *pdev)
{
	struct tps6591x_rtc_platform_data *pdata = pdev->dev.platform_data;
	struct tps6591x_rtc *rtc;
	struct rtc_time tm;
	int err;
	u8 reg;

	rtc = kzalloc(sizeof(*rtc), GFP_KERNEL);

	if (!rtc)
		return -ENOMEM;

	rtc->irq = -1;

	if (!pdata) {
		dev_err(&pdev->dev, "no platform_data specified\n");
		return -EINVAL;
	}

	if (pdata->irq < 0)
		dev_err(&pdev->dev, "\n no IRQ specified, wakeup is disabled\n");

	dev_set_drvdata(&pdev->dev, rtc);
	device_init_wakeup(&pdev->dev, 1);
	rtc->rtc = rtc_device_register(pdev->name, &pdev->dev,
				       &tps6591x_rtc_ops, THIS_MODULE);

	if (IS_ERR(rtc->rtc)) {
		err = PTR_ERR(rtc->rtc);
		goto fail;
	}

	if ((int)pdev && (int)&pdev->dev)
		err = tps6591x_read_regs(&pdev->dev, RTC_STATUS, 1, &reg);
	else {
		dev_err(&pdev->dev, "\n %s Input params incorrect\n", __func__);
		return -EBUSY;
	}
	if (err) {
		dev_err(&pdev->dev, "\n %s unable to read status\n", __func__);
		return -EBUSY;
	}

	reg = RTC_BBCH_SEL | RTC_BBCH_EN;
	tps6591x_write_regs(&pdev->dev, RTC_BBCH_REG, 1, &reg);
	if (err) {
		dev_err(&pdev->dev, "unable to program Charger reg\n");
		return -EBUSY;
	}

	tps6591x_rtc_read_time(&pdev->dev, &tm);
	if ((tm.tm_year < RTC_YEAR_OFFSET || tm.tm_year > (RTC_YEAR_OFFSET + 99))){
		if (pdata->time.tm_year < 2000 || pdata->time.tm_year > 2100)	{
			memset(&pdata->time, 0, sizeof(pdata->time));
			pdata->time.tm_year = RTC_YEAR_OFFSET;
			pdata->time.tm_mday = 1;
		} else
		pdata->time.tm_year -= OS_REF_YEAR;
		tps6591x_rtc_set_time(&pdev->dev, &pdata->time);
	}

	reg = ALARM_INT_STATUS;
	err = tps6591x_write_regs(&pdev->dev, RTC_STATUS, 1, &reg);
	if (err) {
		dev_err(&pdev->dev, "unable to program RTC_STATUS reg\n");
		return -EBUSY;
	}

	reg = ENABLE_ALARM_INT;
	tps6591x_write_regs(&pdev->dev, RTC_INT, 1, &reg);
	if (err) {
		dev_err(&pdev->dev, "unable to program Interrupt Mask reg\n");
		return -EBUSY;
	}

	if (pdata && (pdata->irq >= 0)) {
		rtc->irq = pdata->irq;
		err = request_threaded_irq(pdata->irq, NULL, tps6591x_rtc_irq,
					IRQF_ONESHOT, "rtc_tps6591x",
					&pdev->dev);
		if (err) {
			dev_err(&pdev->dev, "request IRQ:%d fail\n", rtc->irq);
			rtc->irq = -1;
		} else {
			device_init_wakeup(&pdev->dev, 1);
			enable_irq_wake(rtc->irq);
		}
	}
	return 0;

fail:
	if (!IS_ERR_OR_NULL(rtc->rtc))
		rtc_device_unregister(rtc->rtc);
	kfree(rtc);
	return err;
}
开发者ID:AndroidRoot,项目名称:android_kernel_asus_tf201,代码行数:97,代码来源:rtc-tps6591x.c

示例6: max14526_probe


//.........这里部分代码省略.........
		printk(KERN_INFO "[MUIC] gpio_55 IFX_USB_VBUS_EN_GPIO is already occupied by other driver!\n");
		return -ENOSYS;
	}

	ret = gpio_direction_output(IFX_USB_VBUS_EN_GPIO, 0);
	if (ret < 0) {
		printk(KERN_INFO "[MUIC] gpio_55 IFX_USB_VBUS_EN_GPIO direction initialization failed!\n");
		return -ENOSYS;
	}

	/*
	 * Initializes gpio_wk8 (MUIC_INT_N).
	 * Checks if other driver already occupied it.
	 */
	ret = gpio_request(dev->gpio_int, "MUIC IRQ GPIO");
	if (ret < 0) {
		dev_err(&client->dev, "muic: GPIO %d is already used\n",	dev->gpio_int);
		ret = -ENOSYS;
		goto err_gpio_request;
	}
	/* Initializes GPIO direction before use or IRQ setting */
	gpio_direction_input(dev->gpio_int);

	/* Registers MUIC work queue function */
	INIT_WORK(&dev->muic_wq, max14526_wq_func);

	/*
	 * Set up an IRQ line and enable the involved interrupt handler.
	 * From this point, a MUIC_INT_N can invoke muic_interrupt_handler().
	 * muic_interrupt_handler merely calls schedule_work() with muic_wq_func().
	 * muic_wq_func() actually performs the accessory detection.
	 */
	ret = request_irq(dev->irq, max14526_interrupt_handler,IRQF_TRIGGER_FALLING, "muic_irq", dev);
	if (ret < 0) 
	{
		dev_err(&client->dev, "muic: %s: request_irq failed!\n",__func__);
		goto err_request_irq;
	}

	//disable_irq_wake(gpio_to_irq(MUIC_INT));

	/* Prepares a human accessible method to control MUIC */
	//create_cosmo_muic_proc_file();

	/* Selects one of the possible muic chips */
	//muic_detect_device();

	wake_lock_init(&dev->muic_wake_lock, WAKE_LOCK_SUSPEND,"muic_wake_lock");

	ret = muic_device_register(&muic_dev, NULL);
	if (ret < 0) {
		dev_err(&client->dev, "muic: %s: muic_device_register failed\n",__func__);
		goto err_muic_device_register;
	}

	i2c_set_clientdata(client, dev);

	// hunsoo.lee
	printk("%s, registering ops\n", __func__);
	muic_client_dev_register(dev->client->name, dev, &max14526_ops);

	/* Initializes MUIC - Finally MUIC INT becomes enabled */
	if (BOOT_RECOVERY == muic_retain_mode) 
	{ /* Recovery mode */
		muic_mode = MUIC_CP_UART;
		muic_init_max14526(client, BOOTUP);
		dev_info(&client->dev, "muic: %s: first boot\n", __func__);
	}
	else 
	{
		muic_init_max14526(client, RESET);
		muic_max14526_detect_accessory(client, NOT_UPON_IRQ);
		muic_mode = muic_get_mode();
	}
	muic_set_mode(muic_mode);

	/* Makes the interrupt on MUIC INT wake up OMAP which is in suspend mode */
	ret = enable_irq_wake(dev->irq);
	if (ret < 0) {
		dev_err(&client->dev, "muic: GPIO %d wake up source setting failed!\n", dev->gpio_int);
		disable_irq_wake(dev->irq);
		goto err_irq_wake;
	}

	dev_info(&client->dev, "muic: muic_probe()\n");

	return ret;

err_irq_wake:
	muic_device_unregister(&muic_dev);
err_muic_device_register:
	wake_lock_destroy(&dev->muic_wake_lock);
	free_irq(dev->irq, dev);
err_request_irq:
	gpio_free(dev->gpio_int);
err_gpio_request:
	kfree(dev);

	return ret;
}
开发者ID:suiye223,项目名称:p920-ICS-kernel,代码行数:101,代码来源:muic_max14526.c

示例7: tab3_wm1811_init_paiftx


//.........这里部分代码省略.........
	snd_soc_dapm_ignore_suspend(&codec->dapm, "AIF1DACDAT");
	snd_soc_dapm_ignore_suspend(&codec->dapm, "AIF2DACDAT");
	snd_soc_dapm_ignore_suspend(&codec->dapm, "AIF3DACDAT");
	snd_soc_dapm_ignore_suspend(&codec->dapm, "AIF1ADCDAT");
	snd_soc_dapm_ignore_suspend(&codec->dapm, "AIF2ADCDAT");
	snd_soc_dapm_ignore_suspend(&codec->dapm, "AIF3ADCDAT");
	snd_soc_dapm_ignore_suspend(&codec->dapm, "FM In");
	snd_soc_dapm_ignore_suspend(&codec->dapm, "LINE");
	snd_soc_dapm_ignore_suspend(&codec->dapm, "HDMI");
	snd_soc_dapm_ignore_suspend(&codec->dapm, "Third Mic");

	wm1811->codec = codec;

	tab3_micd_set_rate(codec);

#ifdef CONFIG_SEC_DEV_JACK
	/* By default use idle_bias_off, will override for WM8994 */
	codec->dapm.idle_bias_off = 0;
#if defined (CONFIG_TAB3_00_BD)
	if(system_rev < 2) {
		ret = snd_soc_dapm_force_enable_pin(&codec->dapm, "MICBIAS2");
		if (ret < 0)
			dev_err(codec->dev, "Failed to enable MICBIAS2: %d\n",
					ret);
	}
#endif
#else /* CONFIG_SEC_DEV_JACK */
	wm1811->jack.status = 0;

	ret = snd_soc_jack_new(codec, "Tab3 Jack",
				SND_JACK_HEADSET | SND_JACK_BTN_0 |
				SND_JACK_BTN_1 | SND_JACK_BTN_2,
				&wm1811->jack);

	if (ret < 0)
		dev_err(codec->dev, "Failed to create jack: %d\n", ret);

	ret = snd_jack_set_key(wm1811->jack.jack, SND_JACK_BTN_0, KEY_MEDIA);

	if (ret < 0)
		dev_err(codec->dev, "Failed to set KEY_MEDIA: %d\n", ret);

	ret = snd_jack_set_key(wm1811->jack.jack, SND_JACK_BTN_1,
							KEY_VOLUMEUP);
	if (ret < 0)
		dev_err(codec->dev, "Failed to set KEY_VOLUMEUP: %d\n", ret);

	ret = snd_jack_set_key(wm1811->jack.jack, SND_JACK_BTN_2,
							KEY_VOLUMEDOWN);

	if (ret < 0)
		dev_err(codec->dev, "Failed to set KEY_VOLUMEDOWN: %d\n", ret);

	if (wm8994->revision > 1) {
		dev_info(codec->dev, "wm1811: Rev %c support mic detection\n",
			'A' + wm8994->revision);
		ret = wm8958_mic_detect(codec, &wm1811->jack, NULL,
				NULL, tab3_mic_id, wm1811);

		if (ret < 0)
			dev_err(codec->dev, "Failed start detection: %d\n",
				ret);
	} else {
		dev_info(codec->dev, "wm1811: Rev %c doesn't support mic detection\n",
			'A' + wm8994->revision);
		codec->dapm.idle_bias_off = 0;
	}
	/* To wakeup for earjack event in suspend mode */
	enable_irq_wake(control->irq);

	wake_lock_init(&wm1811->jackdet_wake_lock,
					WAKE_LOCK_SUSPEND, "Tab3_jackdet");

	/* To support PBA function test */
	jack_class = class_create(THIS_MODULE, "audio");

	if (IS_ERR(jack_class))
		pr_err("Failed to create class\n");

	jack_dev = device_create(jack_class, NULL, 0, codec, "earjack");

	if (device_create_file(jack_dev, &dev_attr_select_jack) < 0)
		pr_err("Failed to create device file (%s)!\n",
			dev_attr_select_jack.attr.name);

	if (device_create_file(jack_dev, &dev_attr_key_state) < 0)
		pr_err("Failed to create device file (%s)!\n",
			dev_attr_key_state.attr.name);

	if (device_create_file(jack_dev, &dev_attr_state) < 0)
		pr_err("Failed to create device file (%s)!\n",
			dev_attr_state.attr.name);

	if (device_create_file(jack_dev, &dev_attr_reselect_jack) < 0)
		pr_err("Failed to create device file (%s)!\n",
			dev_attr_reselect_jack.attr.name);

#endif /* CONFIG_SEC_DEV_JACK */
	return snd_soc_dapm_sync(&codec->dapm);
}
开发者ID:LuckJC,项目名称:Adam-Kernel-GS3,代码行数:101,代码来源:tab3_wm1811.c

示例8: anx7816_get_sbl_cable_type


//.........这里部分代码省略.........
	anx7816->workqueue = create_singlethread_workqueue("anx7816_work");
	if (anx7816->workqueue == NULL) {
		pr_err("%s: failed to create work queue\n", __func__);
		ret = -ENOMEM;
		goto err1;
	}

	//anx7816->pdata->avdd_power(1);
	//anx7816->pdata->dvdd_power(1);

	ret = anx7816_system_init();
	if (ret) {
		pr_err("%s: failed to initialize anx7816\n", __func__);
		goto err2;
	}

	client->irq = gpio_to_irq(anx7816->pdata->gpio_cbl_det);
	if (client->irq < 0) {
		pr_err("%s : failed to get gpio irq\n", __func__);
		goto err2;
	}

	wake_lock_init(&anx7816->slimport_lock,
				WAKE_LOCK_SUSPEND,
				"slimport_wake_lock");

	//sbl_cable_type = anx7816_get_sbl_cable_type();

/*                                                
                               */ 
//	{

		ret = request_threaded_irq(client->irq, NULL, anx7816_cbl_det_isr,
						IRQF_TRIGGER_RISING
						| IRQF_TRIGGER_FALLING
						| IRQF_ONESHOT,
						"anx7816", anx7816);
		if (ret  < 0) {
			pr_err("%s : failed to request irq\n", __func__);
			goto err2;
		}

		ret = irq_set_irq_wake(client->irq, 1);
		if (ret  < 0) {
			pr_err("%s : Request irq for cable detect", __func__);
			pr_err("interrupt wake set fail\n");
			goto err3;
		}

		ret = enable_irq_wake(client->irq);
		if (ret  < 0) {
			pr_err("%s : Enable irq for cable detect", __func__);
			pr_err("interrupt wake enable fail\n");
			goto err3;
		}
/*	} else {
		pr_err("%s %s : %s, Disable cbl det irq!!\n", LOG_TAG, __func__,
			sbl_cable_type == CBL_910K ? "910K Cable Connected" : "Laf Mode");
	}
*/
	ret = create_sysfs_interfaces(&client->dev);
	if (ret < 0) {
		pr_err("%s : sysfs register failed", __func__);
		goto err3;
	}
#ifdef CONFIG_SLIMPORT_DYNAMIC_HPD
	hdmi_slimport_ops = devm_kzalloc(&client->dev,
				    sizeof(struct msm_hdmi_slimport_ops),
				    GFP_KERNEL);
	if (!hdmi_slimport_ops) {
		pr_err("%s: alloc hdmi slimport ops failed\n", __func__);
		ret = -ENOMEM;
		goto err3;
	}

	if (anx7816->pdata->hdmi_pdev) {
		ret = msm_hdmi_register_slimport(anx7816->pdata->hdmi_pdev,
					   hdmi_slimport_ops, anx7816);
		if (ret) {
			pr_err("%s: register with hdmi failed\n", __func__);
			ret = -EPROBE_DEFER;
			goto err3;
		}
	}
#endif
	pr_info("%s %s end\n", LOG_TAG, __func__);
	goto exit;

err3:
	free_irq(client->irq, anx7816);
err2:
	destroy_workqueue(anx7816->workqueue);
err1:
	anx7816_free_gpio(anx7816);
err0:
	anx7816_client = NULL;
	kfree(anx7816);
exit:
	return ret;
}
开发者ID:bju2000,项目名称:kernel_lge_msm8994,代码行数:101,代码来源:slimport7816.c

示例9: proximity_enable_store

static ssize_t proximity_enable_store(struct device *dev,
					struct device_attribute *attr,
					const char *buf, size_t size)
{
	struct cm36686_data *cm36686 = dev_get_drvdata(dev);
	bool new_value;

	if (sysfs_streq(buf, "1"))
		new_value = true;
	else if (sysfs_streq(buf, "0"))
		new_value = false;
	else {
		pr_err("[SENSOR] %s: invalid value %d\n", __func__, *buf);
		return -EINVAL;
	}

	mutex_lock(&cm36686->power_lock);
	pr_info("%s, new_value = %d\n", __func__, new_value);
	if (new_value && !(cm36686->power_state & PROXIMITY_ENABLED)) {
		u8 val = 1;
		int i;
#ifdef CM36686_CANCELATION
		int err = 0;
#endif
		cm36686->power_state |= PROXIMITY_ENABLED;
#if defined(CONFIG_SENSORS_CM36686_LEDA_EN_GPIO)
		cm36686_leden_gpio_onoff(cm36686, 1);
#else
	prox_led_onoff(cm36686, 1);
#endif
#ifdef CM36686_CANCELATION
		/* open cancelation data */
		err = proximity_open_cancelation(cm36686);
		if (err < 0 && err != -ENOENT)
			pr_err("[SENSOR] %s: proximity_open_cancelation() failed\n",
				__func__);
#endif
		/* enable settings */
		for (i = 0; i < PS_REG_NUM; i++) {
			cm36686_i2c_write_word(cm36686,
				ps_reg_init_setting[i][REG_ADDR],
				ps_reg_init_setting[i][CMD]);
		}

		val = gpio_get_value(cm36686->pdata->irq);
		/* 0 is close, 1 is far */
		input_report_abs(cm36686->proximity_input_dev,
			ABS_DISTANCE, val);
		input_sync(cm36686->proximity_input_dev);

		enable_irq(cm36686->irq);
		enable_irq_wake(cm36686->irq);
	} else if (!new_value && (cm36686->power_state & PROXIMITY_ENABLED)) {
		cm36686->power_state &= ~PROXIMITY_ENABLED;

		disable_irq_wake(cm36686->irq);
		disable_irq(cm36686->irq);
		/* disable settings */
		cm36686_i2c_write_word(cm36686, REG_PS_CONF1, 0x0001);
#if defined(CONFIG_SENSORS_CM36686_LEDA_EN_GPIO)
		cm36686_leden_gpio_onoff(cm36686, 0);
#else
	prox_led_onoff(cm36686, 0);
#endif
	}
	mutex_unlock(&cm36686->power_lock);
	return size;
}
开发者ID:thanhltd,项目名称:android_kernel_sm_g800h_kk,代码行数:68,代码来源:cm36686.c

示例10: xmm_power_on

static int xmm_power_on(struct platform_device *device)
{
	struct baseband_power_platform_data *pdata =
			device->dev.platform_data;
	struct xmm_power_data *data = &xmm_power_drv_data;
	unsigned long flags;
	int ret;

	pr_debug("%s {\n", __func__);

	/* check for platform data */
	if (!pdata) {
		pr_err("%s: !pdata\n", __func__);
		return -EINVAL;
	}
	if (baseband_xmm_get_power_status() != BBXMM_PS_UNINIT)
		return -EINVAL;

	/* reset the state machine */
	baseband_xmm_set_power_status(BBXMM_PS_INIT);
	modem_sleep_flag = false;
	modem_acked_resume = true;

	pr_debug("%s wake_st(%d) modem version %lu\n", __func__,
				ipc_ap_wake_state, modem_ver);

	/* register usb host controller */
	if (!modem_flash) {
		pr_debug("%s - %d\n", __func__, __LINE__);

		spin_lock_irqsave(&xmm_lock, flags);
		ipc_ap_wake_state = IPC_AP_WAKE_INIT2;
		spin_unlock_irqrestore(&xmm_lock, flags);

		/* register usb host controller only once */
		if (register_hsic_device) {
			pr_debug("%s: register usb host controller\n",
				__func__);
			modem_power_on = true;
			if (pdata->hsic_register)
				data->hsic_device = pdata->hsic_register
					(pdata->ehci_device);
			else
				pr_err("%s: hsic_register is missing\n",
					__func__);
			register_hsic_device = false;
			baseband_modem_power_on(pdata);
		} else {
			/* register usb host controller */
			if (pdata->hsic_register)
				data->hsic_device = pdata->hsic_register
					(pdata->ehci_device);
			/* turn on modem */
			pr_debug("%s call baseband_modem_power_on_async\n",
								__func__);
			baseband_modem_power_on_async(pdata);
		}
	} else {
		/* reset flashed modem then it will respond with
		 * ap-wake rising followed by falling gpio
		 */

		pr_debug("%s: reset flash modem\n", __func__);

		modem_power_on = false;
		spin_lock_irqsave(&xmm_lock, flags);
		ipc_ap_wake_state = IPC_AP_WAKE_IRQ_READY;
		spin_unlock_irqrestore(&xmm_lock, flags);
		gpio_set_value(pdata->modem.xmm.ipc_hsic_active, 0);
		forced_abort_hubevent = 0;

		xmm_power_reset_on(pdata);
	}

	ret = enable_irq_wake(gpio_to_irq(pdata->modem.xmm.ipc_ap_wake));
	if (ret < 0)
		pr_err("%s: enable_irq_wake error\n", __func__);
	pr_debug("%s }\n", __func__);

	return 0;
}
开发者ID:iodak,项目名称:android_kernel_lge_x3,代码行数:81,代码来源:baseband-xmm-power.c

示例11: proximity_enable_store

static ssize_t proximity_enable_store(struct device *dev,
                                      struct device_attribute *attr,
                                      const char *buf, size_t size)
{
    struct gp2a_data *gp2a = dev_get_drvdata(dev);
    bool new_value;
    u8 value;
#ifdef GP2AP002X_PROXIMITY_OFFSET
    int err;
#endif

    if (sysfs_streq(buf, "1")) {
        new_value = true;
    } else if (sysfs_streq(buf, "0")) {
        new_value = false;
    } else {
        pr_err("%s: invalid value %d\n", __func__, *buf);
        return -EINVAL;
    }

    mutex_lock(&gp2a->power_lock);
    gp2a_dbgmsg("new_value = %d, old state = %d\n",
                new_value,
                (gp2a->power_state & PROXIMITY_ENABLED) ? 1 : 0);
    if (new_value && !(gp2a->power_state & PROXIMITY_ENABLED)) {
        pr_info("%s, %d\n", __func__, __LINE__);

#ifdef GP2AP002X_PROXIMITY_OFFSET
        pr_info("%s, %d GP2AP002X_PROXIMITY_OFFSET\n", __func__, __LINE__);
        err = gp2a_cal_mode_read_file(&gp2a->cal_mode);
        if (err < 0 && err != -ENOENT)
            pr_err("%s: cal_mode file read fail\n", __func__);

        pr_info("%s: mode = %02x\n", __func__, gp2a->cal_mode);
        if (gp2a->cal_mode == 2) {
            nondetect = PROX_NONDETECT_MODE2;
            detect = PROX_DETECT_MODE2;
        } else if (gp2a->cal_mode == 1) {
            nondetect = PROX_NONDETECT_MODE1;
            detect = PROX_DETECT_MODE1;
        } else {
            nondetect = PROX_NONDETECT;
            detect = PROX_DETECT;
        }
#endif
        /* We send 1 for far status, 0 for close status */
        gp2a->val_state = 1;
        input_report_abs(gp2a->proximity_input_dev,
                         ABS_DISTANCE,
                         gp2a->val_state);
        input_sync(gp2a->proximity_input_dev);

        gp2a->power_state |= PROXIMITY_ENABLED;
        msleep(20);

        value = 0x18;
        gp2a_i2c_write(gp2a, REGS_CON, &value);

        value = 0x08;
        gp2a_i2c_write(gp2a, REGS_GAIN, &value);
        value = nondetect;
        gp2a_i2c_write(gp2a, REGS_HYS, &value);
        value = 0x04;
        gp2a_i2c_write(gp2a, REGS_CYCLE, &value);

        enable_irq_wake(gp2a->irq);

        value = 0x03;
        gp2a_i2c_write(gp2a, REGS_OPMOD, &value);
        enable_irq(gp2a->irq);
        value = 0x00;
        gp2a_i2c_write(gp2a, REGS_CON, &value);

    } else if (!new_value && (gp2a->power_state & PROXIMITY_ENABLED)) {
        pr_info("%s, %d\n", __func__, __LINE__);

        disable_irq_wake(gp2a->irq);
        disable_irq(gp2a->irq);
        value = 0x02;
        gp2a_i2c_write(gp2a, REGS_OPMOD, &value);
        gp2a->power_state &= ~PROXIMITY_ENABLED;
    }
    mutex_unlock(&gp2a->power_lock);
    return size;
}
开发者ID:TeamBliss-Devices,项目名称:android_kernel_samsung_golden,代码行数:85,代码来源:gp2a.c

示例12: wsa_irq_init

static int wsa_irq_init(struct wsa_resource *wsa_res)
{
	int i, ret;

	if (wsa_res == NULL) {
		pr_err("%s: wsa_res is NULL\n", __func__);
		return -EINVAL;
	}
	mutex_init(&wsa_res->irq_lock);
	mutex_init(&wsa_res->nested_irq_lock);

	wsa_res->irq = wsa_irq_get_upstream_irq(wsa_res);
	if (!wsa_res->irq) {
		pr_warn("%s: irq driver is not yet initialized\n", __func__);
		mutex_destroy(&wsa_res->irq_lock);
		mutex_destroy(&wsa_res->nested_irq_lock);
		return -EPROBE_DEFER;
	}
	pr_debug("%s: probed irq %d\n", __func__, wsa_res->irq);

	/* Setup downstream IRQs */
	ret = wsa_irq_setup_downstream_irq(wsa_res);
	if (ret) {
		pr_err("%s: Failed to setup downstream IRQ\n", __func__);
		goto fail_irq_init;
	}

	/* mask all the interrupts */
	for (i = 0; i < wsa_res->num_irqs; i++) {
		wsa_res->irq_masks_cur |= BYTE_BIT_MASK(i);
		wsa_res->irq_masks_cache |= BYTE_BIT_MASK(i);
	}

	ret = request_threaded_irq(wsa_res->irq, NULL, wsa_irq_thread,
				   IRQF_TRIGGER_HIGH | IRQF_ONESHOT,
				   "wsa", wsa_res);
	if (ret != 0) {
		dev_err(wsa_res->dev, "Failed to request IRQ %d: %d\n",
			wsa_res->irq, ret);
	} else {
		ret = enable_irq_wake(wsa_res->irq);
		if (ret) {
			dev_err(wsa_res->dev,
				"Failed to set wake interrupt on IRQ %d: %d\n",
				wsa_res->irq, ret);
			free_irq(wsa_res->irq, wsa_res);
		}
	}

	if (ret)
		goto fail_irq_init;

	return ret;

fail_irq_init:
	dev_err(wsa_res->dev,
			"%s: Failed to init wsa irq\n", __func__);
	wsa_irq_put_upstream_irq(wsa_res);
	mutex_destroy(&wsa_res->irq_lock);
	mutex_destroy(&wsa_res->nested_irq_lock);
	return ret;
}
开发者ID:moonlightly,项目名称:NX523J_kernel,代码行数:62,代码来源:wsa881x-irq.c

示例13: ge_counter_probe

static int ge_counter_probe(struct platform_device *pdev)
{
	struct device *dev = &pdev->dev;
	struct ge_counter_platform_data *pdata = dev_get_platdata(dev);
	struct driver_data *data;
	struct counter_data *dest;
	unsigned int irq;
	int i, ret;

	if (!pdata) {
		pdata = ge_counter_get_devtree_pdata(dev);
		if (IS_ERR(pdata))
			return PTR_ERR(pdata);
	}

	data = kzalloc(sizeof(struct driver_data) + sizeof(struct counter_data)
			* pdata->num_counter, GFP_KERNEL);
	if (!data)
		return -ENOMEM;

	data->dir = kobject_create_and_add("counter", &pdev->dev.kobj);
	if (!data->dir) {
		dev_err(&pdev->dev, "Cannot create sysfs counter dir 'counter'\n");
		kfree(data);
		return -EIO;
	}

	data->num_counter = pdata->num_counter;
	for (i = 0; i < pdata->num_counter; i++) {
		struct ge_counter *src = &pdata->counter[i];
		dest = &data->vdata[i];

		if (!src->name) {
			dev_err(&pdev->dev, "Counter name must be set\n");
			ret = -EINVAL;
			goto err;
		}

		if (!src->gpio || gpio_request(src->gpio, src->name)) {
			dev_err(&pdev->dev, "Invalid counter GPIO %d\n", src->gpio);
			ret = -EINVAL;
			goto err;
		}

		gpio_direction_input(src->gpio);
		irq = gpio_to_irq(src->gpio);
		enable_irq_wake(irq);
		ret = request_any_context_irq(irq, counter_event, src->irq_type,
				"ge_counter", dest);
		if (ret < 0) {
			dev_err(&pdev->dev, "Cannot request IRQ %u for GPIO %u", irq, src->gpio);
			ret = -EINVAL;
			goto err_gpio;
		}

		dest->subdir = kobject_create_and_add(src->name, data->dir);
		if (!dest->subdir) {
			dev_err(&pdev->dev, "Cannot create sysfs counter dir '%s'\n",
					src->name);
			ret = -EIO;
			goto err_irq;
		}

		spin_lock_init(&dest->lock);

		dest->gpio = src->gpio;
		dest->interval = msecs_to_jiffies(src->interval);
		dest->counter = 0UL;
		dest->start_jiffies = jiffies;
		dest->start_count = 0UL;
		dest->reset_on_read = src->reset_on_read;
		dest->use_timer = false;
		dest->interval_count_valid = false;

		dest->counter_attr.show = counter_show;
		dest->counter_attr.store = counter_store;
		sysfs_attr_init(&dest->counter_attr.attr);
		dest->counter_attr.attr.name = "counter";
		dest->counter_attr.attr.mode = S_IRUGO | S_IWUSR;

		ret = sysfs_create_file(dest->subdir, &dest->counter_attr.attr);
		if (ret)
			goto err_dir;

		dest->elapsed_attr.show = elapsed_show;
		dest->elapsed_attr.store = elapsed_store;
		sysfs_attr_init(&dest->elapsed_attr.attr);
		dest->elapsed_attr.attr.name = "elapsed";
		dest->elapsed_attr.attr.mode = S_IRUGO | S_IWUSR;

		ret = sysfs_create_file(dest->subdir, &dest->elapsed_attr.attr);
		if (ret)
			goto err_file1;

		dest->state_attr.show = state_show;
		sysfs_attr_init(&dest->state_attr.attr);
		dest->state_attr.attr.name = "state";
		dest->state_attr.attr.mode = S_IRUGO;

		ret = sysfs_create_file(dest->subdir, &dest->state_attr.attr);
//.........这里部分代码省略.........
开发者ID:SystemTera,项目名称:SystemTera.Server-V-3.14-Kernel,代码行数:101,代码来源:ge_counter.c

示例14: kp_probe

static int __devinit kp_probe(struct platform_device *pdev)
{
	struct keypad_pmic_mogami_platform_data *pdata = pdev->dev.platform_data;
	struct kp_data *dt;
	struct pm8058_chip *pm_chip = platform_get_drvdata(pdev);
	int rc, i;

	if (pm_chip == NULL) {
		dev_err(&pdev->dev, "no parent pm8058\n");
		return -EINVAL;
	}
	if (pdata == NULL) {
		dev_err(&pdev->dev, "no pdata\n");
		return -EINVAL;
	}

	dt = kzalloc(sizeof(struct kp_data), GFP_KERNEL);
	if (dt == NULL)
		return -ENOMEM;

	dt->pm_chip = pm_chip;
	dt->num_keys = pdata->keymap_size;
	dt->pm_gpio_config = pdata->pm_gpio_config;
	dt->keys = kzalloc(dt->num_keys * sizeof(struct kp_key), GFP_KERNEL);
	if (dt->keys == NULL) {
		rc = -ENOMEM;
		goto err_key_alloc_failed;
	}

	platform_set_drvdata(pdev, dt);
	dt->dev	= &pdev->dev;

	dt->input = input_allocate_device();
	if (dt->input == NULL) {
		dev_err(&pdev->dev, "unable to allocate input device\n");
		rc = -ENOMEM;
		goto err_input_alloc_failed;
	}

	for (i = 0; i < dt->num_keys; ++i) {
		dt->keys[i].irq  = pdata->keymap[i].irq;
		dt->keys[i].gpio = pdata->keymap[i].gpio;
		dt->keys[i].code = pdata->keymap[i].code;
		dt->keys[i].wake = pdata->keymap[i].wake;
		/* our irq status will be a bitmask of the block which
		 * contains a certain gpio. since a block is only eight bits
		 * we need to find the correct bit in the block which
		 * reflects the requested gpio */
		dt->keys[i].id   = (pdata->keymap[i].gpio - 1) % 8;

		set_bit(dt->keys[i].code, dt->input->keybit);
		rc = kp_pm_gpio_config(dt, pm_chip, dt->keys[i].gpio);
		if (rc)
			goto err_bad_gpio_config;
	}

	dt->input->name = pdata->input_name;
	dt->input->phys = KP_DEVICE;
	dt->input->dev.parent	= &pdev->dev;
	dt->input->open		= kp_device_open;
	dt->input->close	= kp_device_close;
	dt->input->id.bustype	= BUS_HOST;
	dt->input->id.version	= 0x0001;
	dt->input->id.product	= 0x0001;
	dt->input->id.vendor	= 0x0001;
	set_bit(EV_KEY, dt->input->evbit);
	input_set_drvdata(dt->input, dt);

	rc = input_register_device(dt->input);
	if (rc < 0) {
		dev_err(&pdev->dev, "unable to register keypad input device\n");
		input_free_device(dt->input);
		goto err_input_register_failed;
	}

	for (i = 0; i < dt->num_keys; ++i) {
		rc = pm8058_irq_get_rt_status(dt->pm_chip, dt->keys[i].irq);
		if (rc < 0) {
			dev_err(&dt->input->dev, "unable to get irq status\n");
			/* non-fatal */
		} else {
			dt->keys[i].state = !rc;
			input_report_key(dt->input, dt->keys[i].code, !rc);
		}
		rc = request_threaded_irq(dt->keys[i].irq, NULL, kp_irq,
				IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |
				IRQF_DISABLED, KP_NAME, &dt->input->dev);
		if (rc < 0) {
			dev_err(&dt->input->dev, "unable to request irq\n");
			goto err_request_irq;
		}
		if (!dt->keys[i].wake)
			disable_irq(dt->keys[i].irq);
		else
			enable_irq_wake(dt->keys[i].irq);
	}

	return 0;

 err_request_irq:
//.........这里部分代码省略.........
开发者ID:325116067,项目名称:semc-qsd8x50,代码行数:101,代码来源:keypad-pmic-mogami.c

示例15: yas_probe

static int yas_probe(struct i2c_client *i2c, const struct i2c_device_id *id)
{
	struct yas_state *st;
	struct iio_dev *indio_dev;
	int ret, i;
	s8 *bias;
	struct yas_acc_platform_data *pdata;

	I("%s\n", __func__);

	this_client = i2c;
	indio_dev = iio_device_alloc(sizeof(*st));
	if (!indio_dev) {
		ret = -ENOMEM;
		goto error_ret;
	}
	i2c_set_clientdata(i2c, indio_dev);

	indio_dev->name = id->name;
	indio_dev->dev.parent = &i2c->dev;
	indio_dev->info = &yas_info;
	indio_dev->channels = yas_channels;
	indio_dev->num_channels = ARRAY_SIZE(yas_channels);
	indio_dev->modes = INDIO_DIRECT_MODE;

	st = iio_priv(indio_dev);
	st->client = i2c;
	st->sampling_frequency = 20;
	st->acc.callback.device_open = yas_device_open;
	st->acc.callback.device_close = yas_device_close;
	st->acc.callback.device_read = yas_device_read;
	st->acc.callback.device_write = yas_device_write;
	st->acc.callback.usleep = yas_usleep;
	st->acc.callback.current_time = yas_current_time;
	st->indio_dev = indio_dev;
	INIT_DELAYED_WORK(&st->work, yas_work_func);
	INIT_WORK(&st->resume_work, yas_resume_work_func);
	mutex_init(&st->lock);
#ifdef CONFIG_HAS_EARLYSUSPEND
	st->sus.level = EARLY_SUSPEND_LEVEL_BLANK_SCREEN + 1;
	st->sus.suspend = yas_early_suspend;
	st->sus.resume = yas_late_resume;
	register_early_suspend(&st->sus);
#endif
	ret = yas_probe_buffer(indio_dev);
	if (ret)
		goto error_free_dev;
	ret = yas_probe_trigger(indio_dev);
	if (ret)
		goto error_remove_buffer;
	ret = iio_device_register(indio_dev);
	if (ret)
		goto error_remove_trigger;
	ret = yas_acc_driver_init(&st->acc);
	if (ret < 0) {
		ret = -EFAULT;
		goto error_unregister_iio;
	}
	ret = st->acc.init();
	if (ret < 0) {
		ret = -EFAULT;
		goto error_unregister_iio;
	}
	ret = st->acc.set_enable(1);
	if (ret < 0) {
		ret = -EFAULT;
		goto error_driver_term;
	}

	pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
	if (pdata == NULL)
		E("%s: memory allocation for pdata failed.", __func__);
	else
		yas_parse_dt(&i2c->dev, pdata);

	for (i = 0; i < 3; i++) {
		st->accel_data[i] = 0;
		bias = (s8 *)&pdata->gs_kvalue;
		st->calib_bias[i] = -(bias[2-i] *
					YAS_GRAVITY_EARTH / 256);
		I("%s: calib_bias[%d] = %d\n", __func__, i, st->calib_bias[i]);
	}

	mutex_lock(&st->lock);
	if ((pdata->placement < 8) && (pdata->placement >= 0)) {
		ret = st->acc.set_position(pdata->placement);
		I("%s: set position = %d\n", __func__, pdata->placement);
	} else {
		ret = st->acc.set_position(5);
		D("%s: set default position = 5\n", __func__);
	}
	mutex_unlock(&st->lock);

#ifdef CONFIG_CIR_ALWAYS_READY
	
	module.IRQ = pdata->intr;
	I("%s: IRQ = %d\n", __func__, module.IRQ);
	ret = request_irq(module.IRQ, kxtj2_irq_handler, IRQF_TRIGGER_RISING,
			"kxtj2", &module);
	enable_irq_wake(module.IRQ);
//.........这里部分代码省略.........
开发者ID:anticline,项目名称:android_kernel_htc_msm8939,代码行数:101,代码来源:kxtj2.c


注:本文中的enable_irq_wake函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。