コード例 #1
0
ファイル: pil-modem.c プロジェクト: miing/lmkp_msm
static int __devinit pil_modem_driver_probe(struct platform_device *pdev)
{
	struct modem_data *drv;
	struct resource *res;
	struct pil_desc *desc;
	int ret;

	drv = devm_kzalloc(&pdev->dev, sizeof(*drv), GFP_KERNEL);
	if (!drv)
		return -ENOMEM;
	platform_set_drvdata(pdev, drv);

	drv->irq = platform_get_irq(pdev, 0);
	if (drv->irq < 0)
		return drv->irq;

	drv->xo = devm_clk_get(&pdev->dev, "xo");
	if (IS_ERR(drv->xo))
		return PTR_ERR(drv->xo);

	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
	drv->base = devm_request_and_ioremap(&pdev->dev, res);
	if (!drv->base)
		return -ENOMEM;

	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
	drv->wdog = devm_request_and_ioremap(&pdev->dev, res);
	if (!drv->wdog)
		return -ENOMEM;

	res = platform_get_resource(pdev, IORESOURCE_MEM, 2);
	if (!res)
		return -EINVAL;

	drv->cbase = devm_ioremap(&pdev->dev, res->start, resource_size(res));
	if (!drv->cbase)
		return -ENOMEM;

	desc = &drv->pil_desc;
	desc->name = "modem";
	desc->dev = &pdev->dev;
	desc->owner = THIS_MODULE;
	desc->proxy_timeout = 10000;

	if (pas_supported(PAS_MODEM) > 0) {
		desc->ops = &pil_modem_ops_trusted;
		dev_info(&pdev->dev, "using secure boot\n");
	} else {
		desc->ops = &pil_modem_ops;
		dev_info(&pdev->dev, "using non-secure boot\n");
	}
	ret = pil_desc_init(desc);
	if (ret)
		return ret;

	drv->notifier.notifier_call = modem_notif_handler,
	ret = modem_register_notifier(&drv->notifier);
	if (ret)
		goto err_notify;

	drv->subsys_desc.name = "modem";
	drv->subsys_desc.depends_on = "adsp";
	drv->subsys_desc.dev = &pdev->dev;
	drv->subsys_desc.owner = THIS_MODULE;
	drv->subsys_desc.start = modem_start;
	drv->subsys_desc.stop = modem_stop;
	drv->subsys_desc.shutdown = modem_shutdown;
	drv->subsys_desc.powerup = modem_powerup;
	drv->subsys_desc.ramdump = modem_ramdump;
	drv->subsys_desc.crash_shutdown = modem_crash_shutdown;

	INIT_WORK(&drv->fatal_work, modem_fatal_fn);
	INIT_DELAYED_WORK(&drv->unlock_work, modem_unlock_timeout);

	drv->subsys = subsys_register(&drv->subsys_desc);
	if (IS_ERR(drv->subsys)) {
		ret = PTR_ERR(drv->subsys);
		goto err_subsys;
	}

	drv->ramdump_dev = create_ramdump_device("modem", &pdev->dev);
	if (!drv->ramdump_dev) {
		ret = -ENOMEM;
		goto err_ramdump;
	}

	ret = devm_request_irq(&pdev->dev, drv->irq, modem_wdog_bite_irq,
			IRQF_TRIGGER_RISING, "modem_watchdog", drv);
	if (ret)
		goto err_irq;
	return 0;

err_irq:
	destroy_ramdump_device(drv->ramdump_dev);
err_ramdump:
	subsys_unregister(drv->subsys);
err_subsys:
	modem_unregister_notifier(&drv->notifier);
err_notify:
	pil_desc_release(desc);
	return ret;
}
コード例 #2
0
ファイル: power.c プロジェクト: printusrzero/hwp6s-kernel
static int modem_boot_probe(struct platform_device *dev)
{
    int ret = 0;

    vmdata = kzalloc(sizeof(struct viatel_modem_data), GFP_KERNEL);
    if(!vmdata)
    {
        ret = -ENOMEM;
        printk("No memory to alloc vmdata");
        goto err_create_vmdata;
    }

    vmdata->via_pdev = dev;
    vmdata->tail = 0;
    vmdata->head = 0;

    ret = modem_data_init(vmdata);
    if(ret < 0)
    {
        printk("Fail to init modem data\n");
        goto err_init_modem_data;
    }

    ret = device_create_file(&(dev->dev), &dev_attr_state);
    if(ret < 0)
    {
        dev_err(&dev->dev, "Failed to create sysfs entry state\n");
        goto err_create_sysfs_state;
    }

    ret = device_create_file(&(dev->dev), &dev_attr_modem_state);
    if(ret < 0)
    {
        dev_err(&dev->dev, "Failed to create sysfs entry modem_state\n");
        goto err_create_sysfs_modem_state;
    }

    ret = device_create_file(&(dev->dev), &dev_attr_sim_switch);
    if(ret < 0)
    {
        dev_err(&dev->dev, "Failed to create sysfs entry sim_switch\n");
        goto err_create_sysfs_sim_switch;
    }

    ret = oem_get_gpio_number(CBP_VIATEL_RST_IND_STR,&cbp_rst_ind_gpio);
    if (ret)
        goto err_get_gpio;
    pr_info("%s get CBP_VIATEL_RST_IND_STR gpio %d\n", __func__, cbp_rst_ind_gpio);

    if(GPIO_OEM_VALID(cbp_rst_ind_gpio)){
        ret = oem_gpio_request(cbp_rst_ind_gpio, "GPIO_VIATEL_MDM_RST_IND");
        oem_gpio_irq_mask(cbp_rst_ind_gpio);
        oem_gpio_direction_input_for_irq(cbp_rst_ind_gpio);
        oem_gpio_set_irq_type(cbp_rst_ind_gpio, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING);
        ret = oem_gpio_request_irq(cbp_rst_ind_gpio, modem_reset_indication_irq, \
                     IRQF_SHARED | IRQF_NO_SUSPEND | IRQF_TRIGGER_FALLING, \
                     "mdm_reset_ind", vmdata);
        oem_gpio_irq_unmask(cbp_rst_ind_gpio);

        if (ret < 0) {
            printk("fail to request mdm_rst_ind irq\n");
        }
        modem_register_notifier(&vmdata->rst_ntf);
    }

    ret = oem_get_gpio_number(CBP_VIATEL_PWR_EN_STR, &cbp_pwr_en_gpio);
    if (ret)
            goto err_get_gpio;
    pr_info(">>>> %s get gpio %d\n", __func__, cbp_pwr_en_gpio);
    if(GPIO_OEM_VALID(cbp_pwr_en_gpio)){
		ret = oem_gpio_request(cbp_pwr_en_gpio, "GPIO_VIATEL_MDM_PWR_EN");

	    if (0 > ret) {
	        printk("%s: gpio request GPIO_VIATEL_MDM_PWR_EN failed", __FUNCTION__);
	    }
		oem_gpio_direction_output(cbp_pwr_en_gpio, 0);
    }

    ret = oem_get_gpio_number(CBP_VIATEL_RST_STR, &cbp_rst_gpio);
    if (ret)
            goto err_get_gpio;
    pr_info(">>>> %s get gpio %d\n", __func__,cbp_rst_gpio);

    if(GPIO_OEM_VALID(cbp_rst_gpio)){
		ret = oem_gpio_request(cbp_rst_gpio, "GPIO_VIATEL_MDM_RST");
	    if (0 > ret) {
	        printk("%s: gpio request GPIO_VIATEL_MDM_RST failed", __FUNCTION__);
	    }
		oem_gpio_direction_output(cbp_rst_gpio, 0);
    }

    ret = oem_get_gpio_number(CBP_VIATEL_SIM_SWITCH_STR, &cbp_sim_switch_gpio);
    if(ret){
        printk("%s: Sim connection switch isn't supported on this board", __FUNCTION__);
    }else{
        printk("%s: Sim connection switch is supported on this board", __FUNCTION__);
    }
    pr_info(">>>> %s get gpio %d\n", __func__,cbp_sim_switch_gpio);
    if(GPIO_OEM_VALID(cbp_sim_switch_gpio)){
        ret = oem_gpio_request(cbp_sim_switch_gpio, "GPIO_VIATEL_MDM_SIM_SWITCH");
        if(0 > ret){
            printk("%s: gpio request GPIO_VIATEL_MDM_PWR_EN failed", __FUNCTION__);
        }
        oem_gpio_direction_output(cbp_sim_switch_gpio, 0);
    }

    /*add gpio function to make cp ramdump*/
    ret = oem_get_gpio_number(CBP_VIATEL_GPIO_BACKUP_STR, &cbp_backup_gpio);
    if (ret)
            goto err_get_gpio;

    ret = oem_gpio_request(cbp_backup_gpio, "gpio_cbp_crash");
    if(0 > ret){
        printk("%s: gpio request GPIO_6_0 failed", __FUNCTION__);
    }

    oem_gpio_direction_output(cbp_backup_gpio, 0);

    return 0;

err_get_gpio:
    device_remove_file(&(dev->dev), &dev_attr_sim_switch);
err_create_sysfs_sim_switch:
    device_remove_file(&(dev->dev), &dev_attr_modem_state);
err_create_sysfs_modem_state:
    device_remove_file(&(dev->dev), &dev_attr_state);
err_create_sysfs_state:
err_init_modem_data:
    kfree(vmdata);
    vmdata = NULL;
err_create_vmdata:

    return ret;

}
コード例 #3
0
ファイル: power.c プロジェクト: AwaisKing/mt6577_aosp_source
static int __init modem_init(void)
{
    int ret = 0;

    vmdata = kzalloc(sizeof(struct viatel_modem_data), GFP_KERNEL);
    if(!vmdata){
        ret = -ENOMEM;
        printk("No memory to alloc vmdata");
        goto err_create_vmdata;
    }

    ret = modem_data_init(vmdata);
    if(ret < 0){
        printk("Fail to init modem data\n");
        goto err_init_modem_data;
    }

    ret = platform_device_register(&platform_modem_device);
    if (ret) {
        printk("platform_device_register failed\n");
        goto err_platform_device_register;
    }
    ret = platform_driver_register(&platform_modem_driver);
    if (ret) {
        printk("platform_driver_register failed\n");
        goto err_platform_driver_register;
    }

    ret = misc_register(&misc_modem_device);
    if(ret < 0){
        printk("misc regiser via modem failed\n");
        goto err_misc_device_register;
    }

    //make the default ETS output through USB
    if(GPIO_OEM_VALID(GPIO_VIATEL_MDM_ETS_SEL)){
        oem_gpio_direction_output(GPIO_VIATEL_MDM_ETS_SEL, 0);
    }

    if(GPIO_OEM_VALID(GPIO_VIATEL_MDM_PWR_IND)){
        oem_gpio_irq_mask(GPIO_VIATEL_MDM_PWR_IND);
        oem_gpio_direction_input_for_irq(GPIO_VIATEL_MDM_PWR_IND);
        oem_gpio_set_irq_type(GPIO_VIATEL_MDM_PWR_IND, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING);
        ret = oem_gpio_request_irq(GPIO_VIATEL_MDM_PWR_IND, modem_power_indication_irq, \
                     IRQF_SHARED | IRQF_NO_SUSPEND | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, \
                     "mdm_power_ind", vmdata);
        oem_gpio_irq_unmask(GPIO_VIATEL_MDM_PWR_IND);
        if (ret < 0) {
            printk("fail to request mdm_power_ind irq\n");
        }
        modem_register_notifier(&vmdata->pwr_ntf);
    }

    if(GPIO_OEM_VALID(GPIO_VIATEL_MDM_RST_IND)){
        oem_gpio_irq_mask(GPIO_VIATEL_MDM_RST_IND);
        oem_gpio_direction_input_for_irq(GPIO_VIATEL_MDM_RST_IND);
        oem_gpio_set_irq_type(GPIO_VIATEL_MDM_RST_IND, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING);
        ret = oem_gpio_request_irq(GPIO_VIATEL_MDM_RST_IND, modem_reset_indication_irq, \
                     IRQF_SHARED | IRQF_NO_SUSPEND | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, \
                     "mdm_reset_ind", vmdata);
        oem_gpio_irq_unmask(GPIO_VIATEL_MDM_RST_IND);
        if (ret < 0) {
            printk("fail to request mdm_rst_ind irq\n");
        }
        modem_register_notifier(&vmdata->rst_ntf);
    }

    //oem_gpio_direction_output(GPIO_VIATEL_MDM_RST, 0);
    //oem_gpio_direction_output(GPIO_VIATEL_MDM_PWR_EN, 1);
    ret = sysfs_create_group(vmdata->modem_kobj, &g_attr_group);

    if(ret){
        printk("sysfs_create_group failed\n");
        goto err_sysfs_create_group; 
    }

    return 0;
err_sysfs_create_group:
    misc_deregister(&misc_modem_device);
err_misc_device_register:
    platform_driver_unregister(&platform_modem_driver);
err_platform_driver_register:
	platform_device_unregister(&platform_modem_device);
err_platform_device_register:
err_init_modem_data:
    kfree(vmdata);
    vmdata = NULL;
err_create_vmdata:
    return ret;
}
コード例 #4
0
static int modem_boot_probe(struct platform_device *pdev)
{
    int ret = 0;
    struct device *dev = &pdev->dev;
    struct device_node *np = dev->of_node;

    vmdata = kzalloc(sizeof(struct viatel_modem_data), GFP_KERNEL);
    if(!vmdata)
    {
        ret = -ENOMEM;
        hwlog_err("No memory to alloc vmdata");
        goto err_create_vmdata;
    }

    vmdata->via_pdev = pdev;
    vmdata->tail = 0;
    vmdata->head = 0;

    ret = modem_data_init(vmdata);
    if(ret < 0)
    {
        hwlog_err("Fail to init modem data\n");
        goto err_init_modem_data;
    }

    ret = platform_device_register(&viacbp82d_3rd_modem_info);
    if (ret) {
        hwlog_err( "%s: platform_device_register failed, ret:%d.\n",
                __func__, ret);
        goto err_register_platform_device;
    }

    ret = sysfs_create_group(&viacbp82d_3rd_modem_info.dev.kobj, &viacbp82d_3rd_modem_node);
    if (ret) {
        hwlog_err( "sensor_input_info_init sysfs_create_group error ret =%d", ret);
        platform_device_unregister(&viacbp82d_3rd_modem_info);
        goto err_create_sysfs_group;
    }

    ret = of_property_read_u32(np, "via_reset_ind_connect_to_codec", &cbp_reset_ind_connect_to_codec);
    if(ret) {
        hwlog_err("can't get cbp_reset_ind_connect_to_codec property in viacbp82d_power device node\n");
        goto err_get_gpio;
    }

    hwlog_info("get cbp_reset_ind_connect_to_codec:%u\n", cbp_reset_ind_connect_to_codec);

    /* rst_ind is connect to hi6402 codec in fifa */
    cbp_rst_ind_gpio = of_get_named_gpio(np, "via_reset_ind", 0);//gpio is 254
    hwlog_info("%s get CBP_VIATEL_RST_IND_STR gpio %d\n", __func__, cbp_rst_ind_gpio);
    if(GPIO_OEM_VALID(cbp_rst_ind_gpio)){
        int irq = 0;
        ret = oem_gpio_request(cbp_rst_ind_gpio, "GPIO_VIATEL_MDM_RST_IND");
        if(ret < 0 )
        {
            hwlog_err("%s:%d gpio_request %d fail, return:%d\n", __func__, __LINE__, cbp_rst_ind_gpio, ret);
        }
        oem_gpio_irq_mask(cbp_rst_ind_gpio);
        ret = oem_gpio_direction_input_for_irq(cbp_rst_ind_gpio);
        if(ret < 0 )
        {
            hwlog_err("%s:%d gpio_direction_inout_for_irq %d fail, return:%d\n", __func__, __LINE__, cbp_rst_ind_gpio, ret);
        }

        irq = oem_gpio_to_irq(cbp_rst_ind_gpio);
        hwlog_info("%s:%d cbp_rst_ind_gpio:%d irq is:%d\n", __func__, __LINE__,  cbp_rst_ind_gpio, irq);

        oem_gpio_set_irq_type(cbp_rst_ind_gpio, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING);

        if( cbp_reset_ind_connect_to_codec ) {
            //connected to hi6402, then use task context api to register irq handler.
            ret = oem_gpio_request_threaded_irq(cbp_rst_ind_gpio, modem_reset_indication_irq, \
                            IRQF_SHARED | IRQF_NO_SUSPEND | IRQF_TRIGGER_FALLING, \
                            "mdm_reset_ind", vmdata);
        } else {
            ret = oem_gpio_request_irq(cbp_rst_ind_gpio, modem_reset_indication_irq, \
                            IRQF_SHARED | IRQF_NO_SUSPEND | IRQF_TRIGGER_FALLING, \
                            "mdm_reset_ind", vmdata);
        }

        oem_gpio_irq_unmask(cbp_rst_ind_gpio);

        if (ret < 0) {
            hwlog_err("%s:%d fail to request mdm_rst_ind %d irq, return:%d\n", __func__, __LINE__, cbp_rst_ind_gpio, ret);
        }
        hwlog_info("%s:%d gpio via_reset_ind %d init successfully\n", __func__, __LINE__, cbp_rst_ind_gpio);

        modem_register_notifier(&vmdata->rst_ntf);
    } else {
        hwlog_err("%s:%d via_reset_ind is invalid gpio\n", __func__, __LINE__);
        goto err_get_gpio;
    }

    cbp_pwr_en_gpio = of_get_named_gpio(np, "via_pwr_en", 0);
    hwlog_info("%s get CBP_VIATEL_PWR_EN_STR gpio %d\n", __func__, cbp_pwr_en_gpio);
    if(GPIO_OEM_VALID(cbp_pwr_en_gpio)){
        ret = oem_gpio_request(cbp_pwr_en_gpio, "GPIO_VIATEL_MDM_PWR_EN");
        if (0 > ret) {
            hwlog_err("%s: gpio request GPIO_VIATEL_MDM_PWR_EN failed", __FUNCTION__);
        }
        oem_gpio_direction_output(cbp_pwr_en_gpio, 0);
    } else {
        goto err_get_gpio;
    }

    cbp_rst_gpio = of_get_named_gpio(np, "via_rst_mdm", 0);
    hwlog_info("%s get CBP_VIATEL_CBP_RST_STR gpio %d\n", __func__, cbp_rst_gpio);
    if(GPIO_OEM_VALID(cbp_rst_gpio)){
        ret = oem_gpio_request(cbp_rst_gpio, "GPIO_VIATEL_MDM_RST");
        if (0 > ret) {
            hwlog_err("%s: gpio request GPIO_VIATEL_MDM_RST failed", __FUNCTION__);
        }
        oem_gpio_direction_output(cbp_rst_gpio, 0);
    } else {
        goto err_get_gpio;
    }

#if 0 //don't delete. there is no gpio for sim switch
    cbp_sim_switch_gpio = of_get_named_gpio(np, "via_sim_switch", 0);
    hwlog_info("%s get CBP_VIATEL_CBP_SIM_SWITCH gpio %d\n", __func__, cbp_sim_switch_gpio);
    if(GPIO_OEM_VALID(cbp_sim_switch_gpio)){
        ret = oem_gpio_request(cbp_sim_switch_gpio, "GPIO_VIATEL_MDM_SIM_SWITCH");
        if(0 > ret){
            hwlog_err("%s: gpio request GPIO_VIATEL_MDM_SIM_SWITCH failed", __FUNCTION__);
        }
        oem_gpio_direction_output(cbp_sim_switch_gpio, 0);
    } else {
        goto err_get_gpio;
    }
#endif

    /*add gpio function to make cp ramdump*/
    cbp_backup_gpio = of_get_named_gpio(np, "via_backup", 0);
    hwlog_info("%s get CBP_VIATEL_CBP_BACKUP gpio %d\n", __func__, cbp_backup_gpio);
    if(GPIO_OEM_VALID(cbp_backup_gpio)){
        ret = oem_gpio_request(cbp_backup_gpio, "gpio_cbp_crash");
        if(0 > ret){
            hwlog_err("%s: gpio request gpio_cbp_crash failed", __FUNCTION__);
        }
        oem_gpio_direction_output(cbp_backup_gpio, 0);
        setup_timer(&cbp_backup_timer, cbp_backup_check_ramdump_timer, (unsigned long)NULL);
    } else {
        goto err_get_gpio;
    }

    return 0;

err_get_gpio:
    sysfs_remove_group(&viacbp82d_3rd_modem_info.dev.kobj, &viacbp82d_3rd_modem_node);
err_create_sysfs_group:
    platform_device_unregister(&viacbp82d_3rd_modem_info);
err_register_platform_device:
err_init_modem_data:
    kfree(vmdata);
    vmdata = NULL;
err_create_vmdata:

    return ret;
}