static int hisi_sim_hotplug_probe(struct platform_device *pdev) { struct hisi_sim_hotplug_info *info; struct device_node *np = NULL; struct device *dev = NULL; int ret = 0; #ifdef CONFIG_HISI_RDR static int g_rdr_flag = 0; u32 rdr_int = 0; #endif int shared_irq = 0; if (pdev == NULL) { pr_err("[%s]sim_hotplug get platform device para is err!\n", __func__); return -EINVAL; } dev = &pdev->dev; np = dev->of_node; info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); if (!info) { dev_err(&pdev->dev, "failed to allocate memory\n"); return -ENOMEM; } ret = get_iomux_base_addr(info); if (ret < 0) { dev_err(&pdev->dev, "failed to get iomux base addr\n"); return ret; } #ifdef CONFIG_HISI_RDR if (g_rdr_flag == 0) { RDR_ASSERT(rdr_afreg(rdr_int, RDR_LOG_SIMHOTPLUG_BUF, RDR_U32, LOG_SIMHOTPLUG_BUF_LEN)); g_log_org = (sim_log *)field_addr(u32, rdr_int); memset(g_log_org, 0xFF, MAX_SIM_HOTPLUG_LOG * sizeof(sim_log)); g_rdr_flag = 1; pr_info("%s, g_log_org=%p, rdr_int=0x%x\n", __func__, g_log_org, rdr_int); } #endif ret = sim_pmu_hpd_init(); if (ret < 0) { dev_err(&pdev->dev, "failed to sim_pmu_hpd_init\n"); return ret; } sim_read_pmu_settings(info, np); sim_pmu_hpd_write(info); sim_pmu_hpd_read(); ret = sim_hotplug_dt_init(info, np, dev); if (ret < 0) { dev_err(&pdev->dev, "failed to set sim hotplug gpio hw init\n"); return ret; } ret = sim_state_init(info, dev); if (ret < 0) { dev_err(&pdev->dev, "failed to set sim state hw init\n"); goto free_sim_det_wq; } if (of_property_read_u32(np, "shared-irq", &shared_irq)) { dev_info(dev, "shared-irq property not found, using " "value of 0 as default\n"); shared_irq = 0; } if (shared_irq) { ret = request_threaded_irq(info->det_irq, sim_det_irq_handler, NULL, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_NO_SUSPEND | IRQF_SHARED, "sim_det", info); } else { ret = request_threaded_irq(info->det_irq, sim_det_irq_handler, NULL, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_NO_SUSPEND, "sim_det", info); } if (ret < 0) { dev_err(&pdev->dev, "failed to requset sim_det irq!\n"); goto free_sim_lock; } if (0 == info->sim_id) { sys_add_sim_node(); } platform_set_drvdata(pdev, info); return ret; free_sim_lock: wake_lock_destroy(&info->sim_hotplug_wklock); mutex_destroy(&info->sim_hotplug_lock); free_sim_det_wq: if (info->sim_hotplug_det_wq) destroy_workqueue(info->sim_hotplug_det_wq); return ret; }
static int hisi_sim_hotplug_probe(struct platform_device *pdev) { struct hisi_sim_hotplug_info *info; struct device_node *np = NULL; struct device *dev = NULL; int ret = 0; #ifdef CONFIG_HISI_RDR static int g_rdr_flag = 0; u32 rdr_int = 0; #endif if (pdev == NULL) { pr_err("[%s]sim_hotplug get platform device para is err!\n", __func__); return -EINVAL; } dev = &pdev->dev; np = dev->of_node; info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); if (!info) { dev_err(&pdev->dev, "failed to allocate memory\n"); return -ENOMEM; } ret = get_iomux_base_addr(info); if (ret < 0) { dev_err(&pdev->dev, "failed to get iomux base addr\n"); return ret; } #ifdef CONFIG_HISI_RDR if (g_rdr_flag == 0) { RDR_ASSERT(rdr_afreg(rdr_int, RDR_LOG_SIMHOTPLUG_BUF, RDR_U32, LOG_SIMHOTPLUG_BUF_LEN)); g_log_org = (sim_log *)field_addr(u32, rdr_int); memset(g_log_org, 0xFF, MAX_SIM_HOTPLUG_LOG * sizeof(sim_log)); g_rdr_flag = 1; } #endif ret = sim_hotplug_dt_init(info, np, dev); if (ret < 0) { dev_err(&pdev->dev, "failed to set sim hotplug gpio hw init\n"); return ret; } ret = sim_state_init(info, dev); if (ret < 0) { dev_err(&pdev->dev, "failed to set sim state hw init\n"); goto free_sim_det_wq; } ret = request_threaded_irq(info->det_irq, sim_det_irq_handler, NULL, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_NO_SUSPEND, "sim_det", info); if (ret < 0) { dev_err(&pdev->dev, "failed to requset sim_det irq!\n"); goto free_sim_lock; } platform_set_drvdata(pdev, info); return ret; free_sim_lock: wake_lock_destroy(&info->sim_hotplug_wklock); mutex_destroy(&info->sim_hotplug_lock); free_sim_det_wq: if (info->sim_hotplug_det_wq) destroy_workqueue(info->sim_hotplug_det_wq); return ret; }