static int __devexit modemctl_remove(struct platform_device *pdev)
{
	struct modemctl *mc = platform_get_drvdata(pdev);

	flush_work(&mc->work.work);
	flush_work(&mc->resume_work);
	platform_set_drvdata(pdev, NULL);
	_free_all(mc);
	return 0;
}
Example #2
0
static int __devexit modemctl_remove(struct platform_device *pdev)
{
	struct modemctl *mc = platform_get_drvdata(pdev);

	flush_work(&mc->work.work);
//	flush_work(&mc->cpdump_work);
	platform_set_drvdata(pdev, NULL);
	wake_lock_destroy(&mc->reset_lock);
	_free_all(mc);
	return 0;
}
static int __devexit modem_remove(struct platform_device *pdev)
{
	struct modemctl *mc = platform_get_drvdata(pdev);

	flush_work(&mc->work.work);
	flush_work(&mc->cpreset_work);
	platform_set_drvdata(pdev, NULL);
#if CONFIG_HAS_WAKELOCK
	wake_lock_destroy(&mc->reset_lock);
#endif

	misc_deregister(&modem_miscdev);
	_free_all(mc);
	return 0;
}
Example #4
0
static int __devinit modemctl_probe(struct platform_device *pdev)
{
	struct modemctl_platform_data *pdata = pdev->dev.platform_data;
	struct device *dev = &pdev->dev;
	struct modemctl *mc;
	int irq;
	int error;

	if (!pdata) {
		dev_err(dev, "No platform data\n");
		return -EINVAL;
	}

	mc = kzalloc(sizeof(struct modemctl), GFP_KERNEL);
	if (!mc) {
		dev_err(dev, "Failed to allocate device\n");
		return -ENOMEM;
	}

	mc->gpio_phone_on = pdata->gpio_phone_on;
	mc->gpio_phone_active = pdata->gpio_phone_active;
	mc->gpio_pda_active = pdata->gpio_pda_active;
	mc->gpio_cp_reset = pdata->gpio_cp_reset;
	mc->gpio_cp_req_reset = pdata->gpio_cp_req_reset;
	mc->gpio_ipc_slave_wakeup = pdata->gpio_ipc_slave_wakeup;
	mc->gpio_ipc_host_wakeup = pdata->gpio_ipc_host_wakeup;
	mc->gpio_suspend_request = pdata->gpio_suspend_request;
	mc->gpio_active_state = pdata->gpio_active_state;
	mc->gpio_usim_boot = pdata->gpio_usim_boot;
	mc->gpio_flm_sel = pdata->gpio_flm_sel;
	mc->gpio_cp_dump_int = pdata->gpio_cp_dump_int;
	mc->gpio_sim_detect = pdata->gpio_sim_detect;
	mc->ops = &pdata->ops;
	mc->dev = dev;
	dev_set_drvdata(mc->dev, mc);

	error = sysfs_create_group(&mc->dev->kobj, &modemctl_group);
	if (error) {
		dev_err(dev, "Failed to create sysfs files\n");
		goto fail;
	}
	mc->group = &modemctl_group;

	INIT_DELAYED_WORK(&mc->work, mc_work);
	INIT_WORK(&mc->cpdump_work, mc_cpdump_worker);
	wake_lock_init(&mc->reset_lock, WAKE_LOCK_SUSPEND, "modemctl");

	mc->ops->modem_cfg_gpio();

	irq = gpio_to_irq(pdata->gpio_phone_active);
	error = request_irq(irq, modemctl_irq_handler,
			IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
			"phone_active", mc);
	if (error) {
		dev_err(dev, "Failed to allocate an interrupt(%d)\n", irq);
		goto fail;
	}
	mc->irq[0] = irq;
	enable_irq_wake(irq);

	irq = gpio_to_irq(pdata->gpio_ipc_host_wakeup);

	error = request_threaded_irq(irq, NULL, modemctl_resume_thread,
			IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
			"IPC_HOST_WAKEUP", mc);

	if (error) {
		dev_err(dev, "Failed to allocate an interrupt(%d)\n", irq);
		goto fail;
	}
	mc->irq[1] = irq;
	enable_irq_wake(irq);

	irq = gpio_to_irq(pdata->gpio_cp_dump_int);
	error = request_irq(irq, modemctl_cpdump_irq,
			IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
			"CP_DUMP_INT", mc);
	if (error) {
		dev_err(dev, "Failed to allocate an interrupt(%d)\n", irq);
		goto fail;
	}
	mc->irq[2] = irq;
	enable_irq_wake(irq);

#ifdef CONFIG_SUPPORT_SIMDETECT
	if (pdata->gpio_sim_detect) {
		INIT_DELAYED_WORK(&mc->sim_work, mc_simdetect_worker);

		irq = gpio_to_irq(pdata->gpio_sim_detect);
		error = request_irq(irq, modemctl_simdetect_irq,
			IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
			"SIM_DETECT", mc);
		if (error) {
			dev_err(dev, "Failed to allocate an irq(%d)\n", irq);
			goto fail;
		}
		mc->irq[3] = irq;
		enable_irq_wake(irq);

		mc->sim_prev_states = SIM_IGNORE;
	}
#endif

	mc->debug_cnt = 0;

	device_init_wakeup(&pdev->dev, pdata->wakeup);
	platform_set_drvdata(pdev, mc);
	global_mc = mc;
	return 0;

fail:
	_free_all(mc);
	return error;
}
static int __devinit modem_probe(struct platform_device *pdev)
{
	struct modem_platform_data *pdata = pdev->dev.platform_data;
	struct device *dev = &pdev->dev;
	struct modemctl *mc;
	int irq;
	int error;
	if (!pdata) {
		dev_err(dev, "No platform data\n");
		return -EINVAL;
	}

	mc = kzalloc(sizeof(struct modemctl), GFP_KERNEL);
	if (!mc) {
		dev_err(dev, "Failed to allocate device\n");
		return -ENOMEM;
	}

	mc->gpio_phone_on = pdata->gpio_phone_on;
	mc->gpio_phone_active = pdata->gpio_phone_active;
	mc->gpio_pda_active = pdata->gpio_pda_active;
	mc->gpio_cp_reset = pdata->gpio_cp_reset;
	mc->gpio_cp_req_reset = pdata->gpio_cp_req_reset;
	mc->gpio_ipc_slave_wakeup = pdata->gpio_ipc_slave_wakeup;
	mc->gpio_ipc_host_wakeup = pdata->gpio_ipc_host_wakeup;
	mc->gpio_suspend_request = pdata->gpio_suspend_request;
	mc->gpio_active_state = pdata->gpio_active_state;
	mc->gpio_usim_boot = pdata->gpio_usim_boot;
	mc->gpio_flm_sel = pdata->gpio_flm_sel;
	//mc->gpio_cp_dump_int = pdata->gpio_cp_dump_int;
	mc->gpio_cp_reset_int = pdata->gpio_cp_reset_int;
	mc->ops = &pdata->ops;
	mc->dev = dev;
	dev_set_drvdata(mc->dev, mc);

	error = sysfs_create_group(&mc->dev->kobj, &modem_group);
	if (error) {
		dev_err(dev, "Failed to create sysfs files\n");
		goto fail;
	}
	mc->group = &modem_group;

//	INIT_DELAYED_WORK(&mc->work, mc_work);
	INIT_WORK(&mc->cpreset_work, mc_cpreset_worker);
#if CONFIG_HAS_WAKELOCK
	wake_lock_init(&mc->reset_lock, WAKE_LOCK_SUSPEND, "modemctl");
	//wake_lock(&mc->reset_lock);
//This should be disable at first for some kernel page access error
#endif
	init_waitqueue_head(&mc->wq);
	mc->ops->modem_cfg();
#if 0
	irq = gpio_to_irq(pdata->gpio_suspend_request);

	error = request_irq(irq, modem_irq_handler,
			IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
			"phone_request_suspend", mc);
	if (error) {
		dev_err(dev, "Active Failed to allocate an interrupt(%d)\n", irq);
		goto fail;
	}
	mc->irq[0] = irq;
	enable_irq_wake(irq);
#endif
        /*add CP_RESET_OUT int detect function*/
		 irq=s5p_register_gpio_interrupt(GPIO_CP_ABNORMAL_RESET_INT);
		 printk("irq num =%d\n",irq);
		 //irq = gpio_to_irq(GPIO_CP_ABNORMAL_RESET_INT);
		 error = request_irq(irq, modem_cpreset_out_irq,
						IRQF_TRIGGER_FALLING,
		 		 		 "CP_RESET_OUT_INT", mc);
		 if (error) {
		 		 dev_err(dev, "Failed to allocate an interrupt(%d)\n", irq);
		 		 goto fail;
		 	}
	irq = gpio_to_irq(pdata->gpio_ipc_host_wakeup);

	error = request_threaded_irq(irq, NULL, modem_resume_thread,
			IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
			"IPC_HOST_WAKEUP", mc);

	if (error) {
		dev_err(dev, "Resume thread Failed to allocate an interrupt(%d)\n", irq);
		goto fail;
	}
	mc->irq[1] = irq;
	//enable_irq_wake(irq);
#if 1
	irq = gpio_to_irq(pdata->gpio_cp_reset_int);
	error = request_threaded_irq(irq, NULL, modem_cpreset_irq,
			IRQF_TRIGGER_RISING ,               //    IRQF_TRIGGER_FALLING,
			"CP_RESET_INT", mc);
	if (error) {
		dev_err(dev, "Failed to allocate an interrupt(%d)\n", irq);
		goto fail;
	}
	
	mc->irq[2] = irq;
	enable_irq_wake(irq);
#endif
	mc->debug_cnt = 0;

	device_init_wakeup(&pdev->dev, pdata->wakeup);
	platform_set_drvdata(pdev, mc);
	global_mc = mc;

	error = misc_register(&modem_miscdev);
	if(error)
	{
		dev_err(dev, "Failed to register modem control device\n");
		goto fail;
	}

	return 0;

fail:
	_free_all(mc);
	return error;
}
static int __devinit modemctl_probe(struct platform_device *pdev)
{
	struct modemctl_platform_data *pdata = pdev->dev.platform_data;
	struct device *dev = &pdev->dev;
	struct modemctl *mc;
	int irq;
	int error;

	if (!pdata) {
		dev_err(dev, "No platform data\n");
		return -EINVAL;
	}

	mc = kzalloc(sizeof(struct modemctl), GFP_KERNEL);
	if (!mc) {
		dev_err(dev, "Failed to allocate device\n");
		return -ENOMEM;
	}

	mc->gpio_phone_on = pdata->gpio_phone_on;
	mc->gpio_phone_off = pdata->gpio_phone_off;
	mc->gpio_cp_reset = pdata->gpio_cp_reset;
	mc->gpio_slave_wakeup = pdata->gpio_slave_wakeup;
	mc->gpio_host_wakeup = pdata->gpio_host_wakeup;
	mc->gpio_host_active = pdata->gpio_host_active;
//	mc->gpio_pda_active = pdata->gpio_pda_active;

	if( !pdata->gpio_phone_active ){
                if( system_rev > 0xA ){
		     mc->gpio_phone_active = GPIO_LTE_ACTIVE;        
		}
                  else{
                        printk("[%s], %d LTE_ACTIVE gpio is replaced as  LTE2AP_STATUS in this HW rev(system_rev = %x)\n",__func__, __LINE__, system_rev);
		     mc->gpio_phone_active = GPIO_LTE2AP_STATUS;
                  }

                  pdata->gpio_phone_active = mc->gpio_phone_active;
	}

	mc->ops = &pdata->ops;
	mc->dev = dev;
	dev_set_drvdata(mc->dev, mc);

	error = sysfs_create_group(&mc->dev->kobj, &modemctl_group);
	if (error) {
		dev_err(dev, "Failed to create sysfs files\n");
		goto fail;
	}
	mc->group = &modemctl_group;

	INIT_DELAYED_WORK(&mc->work, mc_work); 
	INIT_WORK(&mc->resume_work, mc_resume_worker);

	mc->ops->modem_cfg_gpio();

	irq = gpio_to_irq(pdata->gpio_phone_active);
	error = request_irq(irq, modemctl_irq_handler,
			IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
			"phone_active", mc);
	if (error) {
		dev_err(dev, "Failed to allocate an interrupt(%d)\n", irq);
		goto fail;
	}
	mc->irq[0] = irq; 
	//enable_irq_wake(irq);
	disable_irq(irq);

	irq = gpio_to_irq(pdata->gpio_host_wakeup);
	error = request_irq(irq, modemctl_resume_irq,
			IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
			"IPC_HOST_WAKEUP", mc);

	if (error) {
		dev_err(dev, "Failed to allocate an interrupt(%d)\n", irq);
		goto fail;
	}
	mc->irq[1] = irq;
	enable_irq_wake(irq);

	device_init_wakeup(&pdev->dev, pdata->wakeup);
	platform_set_drvdata(pdev, mc);
	global_mc = mc;
	return 0;

fail:
	_free_all(mc);
	return error;
}
Example #7
0
static int __devinit modemctl_probe(struct platform_device *pdev)
{
	struct modemctl_platform_data *pdata = pdev->dev.platform_data;
	struct device *dev = &pdev->dev;
	struct modemctl *mc;
	int irq;
	int error;

	if (!pdata) {
		dev_err(dev, "No platform data\n");
		return -EINVAL;
	}

	mc = kzalloc(sizeof(struct modemctl), GFP_KERNEL);
	if (!mc) {
		dev_err(dev, "Failed to allocate device\n");
		return -ENOMEM;
	}

	mc->gpio_phone_on = pdata->gpio_phone_on;
	mc->gpio_phone_active = pdata->gpio_phone_active;
	mc->gpio_pda_active = pdata->gpio_pda_active;
	mc->gpio_cp_dump_int = pdata->gpio_cp_dump_int;
	mc->gpio_ap_cp_int1 = pdata->gpio_ap_cp_int1;
	mc->gpio_ap_cp_int2 = pdata->gpio_ap_cp_int2;

	mc->ops = &pdata->ops;
	mc->dev = dev;
	dev_set_drvdata(mc->dev, mc);

	error = sysfs_create_group(&mc->dev->kobj, &modemctl_group);
	if (error) {
		dev_err(dev, "Failed to create sysfs files\n");
		goto fail;
	}
	mc->group = &modemctl_group;

	INIT_DELAYED_WORK(&mc->work, mc_work);
	INIT_WORK(&mc->cpdump_work, mc_cpdump_worker);
	wake_lock_init(&mc->reset_lock, WAKE_LOCK_SUSPEND, "modemctl");

	irq = gpio_to_irq(pdata->gpio_phone_active);
	error = request_irq(irq, modemctl_irq_handler,
			IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
			"phone_active", mc);
	if (error) {
		dev_err(dev, "(%d) Failed to allocate an interrupt(%d)\n",
			__LINE__, irq);
		goto fail;
	}
	mc->irq[0] = irq;
	enable_irq_wake(irq);

	irq = gpio_to_irq(pdata->gpio_cp_dump_int);
#if defined(CONFIG_CHN_CMCC_SPI_SPRD)
	error = request_irq(irq, modemctl_irq_handler,
			IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
			"CP_DUMP_INT", mc);
#else
	error = request_irq(irq, modemctl_cpdump_irq,
			IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING,
			"CP_DUMP_INT", mc);
#endif
	if (error) {
		dev_err(dev, "(%d) Failed to allocate an interrupt(%d)\n",
			__LINE__, irq);
		goto fail;
	}
	mc->irq[1] = irq;
	enable_irq_wake(irq);
	mc->debug_cnt = 0;

	device_init_wakeup(&pdev->dev, pdata->wakeup);
	platform_set_drvdata(pdev, mc);
	global_mc = mc;

	pr_info("[%s] Done\n ", __func__);
	return 0;

fail:
	_free_all(mc);
	return error;
}