Пример #1
0
#define GPIO_MAC_RST_N		37

#define FPGA_SDCC_STATUS       0x8E0001A8

#ifdef NOTNOW
int pm8058_gpios_init(struct pm8058_chip *pm_chip)
{
	return 0;
}


/* Put sub devices with fixed location first in sub_devices array */

static struct pm8058_gpio_platform_data pm8058_mpp_data = {
	.irq_base	= PM8058_MPP_IRQ(PMIC8058_IRQ_BASE, 0),
};

static struct mfd_cell pm8058_subdevs[] = {
	{	.name = "pm8058-mpp",
		.platform_data	= &pm8058_mpp_data,
		.data_size	= sizeof(pm8058_mpp_data),
	},
	{	.name = "pm8058-pwm",
	},
};

static struct pm8058_platform_data pm8058_fsm9xxx_data = {
	.irq_base = PMIC8058_IRQ_BASE,
	.init = pm8058_gpios_init,
Пример #2
0
static int __devinit hs_probe(struct platform_device *pdev)
{
    int rc = 0,err;
    struct input_dev *ipdev;
	struct pm8xxx_mpp_config_data sky_handset_digital_adc = {
		.type	= PM8XXX_MPP_TYPE_D_INPUT,
		.level	= PM8058_MPP_DIG_LEVEL_S3,
		.control = PM8XXX_MPP_DIN_TO_INT,
	};

    hs_dbg("hs_probe start!!!\n");
	headset_init=0;
    //sky_hs_3p5pi_jack_ctrl.state=SKY_HS_JACK_STATE_INIT;
    hs = kzalloc(sizeof(struct msm_headset), GFP_KERNEL);
    if (!hs)
        return -ENOMEM;

    hspd = kzalloc(sizeof(struct msm_headset_platform_data), GFP_KERNEL);
    if (!hspd)
        return -ENOMEM;

#if 0	
    hs->sdev.name   = "h2w";
#else
    hs->sdev.name   = "hw2";
#endif
    hs->sdev.print_name = msm_headset_print_name;

    rc = switch_dev_register(&hs->sdev);
    if (rc)
        goto err_switch_dev_register;

    ipdev = input_allocate_device();
    if (!ipdev) {
        rc = -ENOMEM;
        goto err_switch_dev;
    }
    input_set_drvdata(ipdev, hs);

    hs->ipdev = ipdev;

    if (pdev->dev.platform_data) {
        hs->hs_pdata = pdev->dev.platform_data;
	  hspd = pdev->dev.platform_data;
    }

    if (hs->hs_pdata->hs_name)
        ipdev->name = hs->hs_pdata->hs_name;
    else
        ipdev->name = DRIVER_NAME;

	mutex_init(&headset_adc_lock);

    INIT_DELAYED_WORK(&earjack_work,earjack_det_func);
    INIT_DELAYED_WORK(&remotekey_work,remotekey_det_func);

    wake_lock_init(&headset_wakelock, WAKE_LOCK_SUSPEND, "Headset_wakelock");
    
    ipdev->id.vendor    = 0x0001;
    ipdev->id.product   = 1;
    ipdev->id.version   = 1;

    input_set_capability(ipdev, EV_KEY, KEY_MEDIA);
    input_set_capability(ipdev, EV_KEY, KEY_VOLUMEUP);
    input_set_capability(ipdev, EV_KEY, KEY_VOLUMEDOWN);
    //input_set_capability(ipdev, EV_KEY, KEY_END);
    input_set_capability(ipdev, EV_SW, SW_HEADPHONE_INSERT);
    //input_set_capability(ipdev, EV_KEY, KEY_POWER);    
    //input_set_capability(ipdev, EV_KEY, KEY_SEND);
 
    rc = input_register_device(ipdev);
    if (rc) {
        dev_err(&ipdev->dev,
                "hs_probe: input_register_device rc=%d\n", rc);
        goto err_reg_wakelock;
    }

	/* Enable runtime PM ops, start in ACTIVE mode */
	//rc = pm_runtime_set_active(&pdev->dev);
	//if (rc < 0)
	//	dev_dbg(&pdev->dev, "unable to set runtime pm state\n");
	//pm_runtime_enable(&pdev->dev);


    platform_set_drvdata(pdev, hs);

    device_init_wakeup(&pdev->dev,1);

    hs_jack_l8 = regulator_get(NULL, "8058_l8");
    if(IS_ERR(hs_jack_l8)) {
      printk("regulator l8 get error\n");
      goto err_reg_input_dev;
    }

	// Added sysfs. (/sys/devices/platform/msm-handset/headset)
    rc = sysfs_create_group(&pdev->dev.kobj, &dev_attr_grp);
    if (rc) {
        dev_err(&ipdev->dev,
                "hs_probe: sysfs_create_group rc=%d\n", rc);
        goto err_reg_input_dev;
    }


    err = gpio_request(hspd->ear_det, "headset_det");
    if(err) {
		printk("unable to request gpio headset_det err=%d\n",err); 
		goto err_reg_input_dev;
    }

    err=gpio_direction_input(hspd->ear_det);
    if(err) {
		printk("Unable to set direction headset_det err=%d\n",err); 
		goto err_reg_input_dev;
    }
#if AT1_BDVER_GE(AT1_WS22) 
    gpio_tlmm_config(GPIO_CFG(hspd->ear_det, 0, GPIO_CFG_INPUT,GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
#else
	gpio_tlmm_config(GPIO_CFG(hspd->ear_det, 0, GPIO_CFG_INPUT,GPIO_CFG_PULL_DOWN, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
#endif
    //gpio_set_debounce(hspd->ear_det,5);

    //set_irq_wake(gpio_to_irq(hspd->ear_det),1);

    err=request_irq(gpio_to_irq(hspd->ear_det), Earjack_Det_handler, 
		IRQF_DISABLED|IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "earjack_det-irq", hs);
	if (err  < 0) {
		printk("Couldn't acquire ear_det as request_irq()");
		goto err_reg_input_dev;
	}

	irq_set_irq_wake(gpio_to_irq(hspd->ear_det),1);

    err = gpio_request(hspd->remote_det, "remote_det");
    if(err) {
		printk("unable to request gpio remote_det err=%d\n",err); 
		goto err_reg_input_dev;
    }

#if AT1_BDVER_GE(AT1_WS22) 

	err = pm8xxx_mpp_config(PM8058_MPP_PM_TO_SYS(XOADC_MPP_3), &sky_handset_digital_adc);
	if (err < 0)
		printk("%s: pm8058_mpp_config_DIG ret=%d\n",__func__, err);

/*
	err = pm8058_mpp_config_digital_in(PM8058_MPP_SYS_TO_PM(hspd->remote_det),
					PM8058_MPP_DIG_LEVEL_S3,
					PM_MPP_DIN_TO_INT);
	err |=  pm8058_mpp_config_bi_dir(PM8058_MPP_SYS_TO_PM(hspd->remote_det),
					PM8058_MPP_DIG_LEVEL_S3,
					PM_MPP_BI_PULLUP_OPEN);	
*/
	printk("mpp config %d mpp %d err=%d\n",hspd->remote_det,
		PM8058_MPP_SYS_TO_PM(hspd->remote_det),err);
	printk(" remote %d %d\n",gpio_to_irq(hspd->remote_det),PM8058_MPP_IRQ(PM8058_IRQ_BASE,PM8058_MPP_SYS_TO_PM(hspd->remote_det)));

    err=request_threaded_irq(gpio_to_irq(hspd->remote_det),NULL,
		Remotekey_Det_handler,IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "remote_det-irq", hs);
#else
    err=gpio_direction_input(hspd->remote_det);
    if(err) {
		printk("Unable to set direction remote_det err=%d\n",err); 
		goto err_reg_input_dev;
    }

    //gpio_tlmm_config(GPIO_CFG(hspd->remote_det, 0, GPIO_CFG_INPUT,GPIO_CFG_NO_PULL, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
	gpio_tlmm_config(GPIO_CFG(hspd->remote_det, 0, GPIO_CFG_INPUT,GPIO_CFG_PULL_UP, GPIO_CFG_2MA), GPIO_CFG_ENABLE);
    //gpio_set_debounce(hspd->remote_det,5);


    err=request_irq(gpio_to_irq(hspd->remote_det), Remotekey_Det_handler, 
              IRQF_DISABLED|IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "remote_det-irq", hs);
#endif
	if (err  < 0) {
		printk("Couldn't acquire remote_det as request_irq()");
		goto err_reg_input_dev;
	}

	disable_irq(gpio_to_irq(hspd->remote_det));

	headset_init=1; // headset init

	
    rc=gpio_get_value_cansleep(hspd->ear_det);
    if(rc==hspd->ear_det_active) {
	  schedule_delayed_work(&earjack_work,msecs_to_jiffies(200));
	  //schedule_delayed_work(&earjack_work,200);
    }

        printk("hs_probe success!!!\n");

    return 0;

err_reg_input_dev:
    input_unregister_device(ipdev);
err_reg_wakelock:
    wake_lock_destroy(&headset_wakelock);
    input_free_device(ipdev);
err_switch_dev:
    switch_dev_unregister(&hs->sdev);
err_switch_dev_register:
    kfree(hspd);
    kfree(hs);
    return rc;
}