static int db8500_thermal_remove(struct platform_device *pdev) { struct db8500_thermal_zone *pzone = platform_get_drvdata(pdev); thermal_zone_device_unregister(pzone->therm_dev); cancel_work_sync(&pzone->therm_work); mutex_destroy(&pzone->th_lock); return 0; }
static int omap3_thermal_exit(struct platform_device *pdev) { struct thermal_zone_device *omap3_thermal = platform_get_drvdata(pdev); thermal_zone_device_unregister(omap3_thermal); platform_set_drvdata(pdev, NULL); pm_runtime_disable(&pdev->dev); return 0; }
static int __devexit gadc_thermal_remove(struct platform_device *pdev) { struct gadc_thermal_driver_data *drvdata = platform_get_drvdata(pdev); if (drvdata->dentry) debugfs_remove_recursive(drvdata->dentry); thermal_zone_device_unregister(drvdata->tz); iio_st_channel_release(drvdata->channel); return 0; }
static int __exit kona_thermal_remove(struct platform_device *pdev) { struct kona_tmon_thermal *thermal = platform_get_drvdata(pdev); cpufreq_cooling_unregister(thermal->freq_cdev); thermal_zone_device_unregister(thermal->tz); kona_tmon_exit(thermal, false); clk_disable(thermal->tmon_1m_clk); clk_disable(thermal->tmon_apb_clk); return 0; }
static int therm_fan_est_remove(struct platform_device *pdev) { struct therm_fan_estimator *est = platform_get_drvdata(pdev); if (!est) return -EINVAL; cancel_delayed_work(&est->therm_fan_est_work); thermal_zone_device_unregister(est->thz); return 0; }
void exynos4_unregister_thermal(void) { if (th_zone && th_zone->cool_dev) cpufreq_cooling_unregister(); if (th_zone && th_zone->therm_dev) thermal_zone_device_unregister(th_zone->therm_dev); kfree(th_zone); pr_info("Exynos: Kernel Thermal management unregistered\n"); }
/** * mid_thermal_probe - mfld thermal initialize * @pdev: platform device structure * * mid thermal probe initializes the hardware and registers * all the sensors with the generic thermal framework. Can sleep. */ static int mid_thermal_probe(struct platform_device *pdev) { static char *name[MSIC_THERMAL_SENSORS] = { "skin0", "skin1", "sys", "msicdie" }; int ret; int i; struct platform_info *pinfo; pinfo = kzalloc(sizeof(struct platform_info), GFP_KERNEL); if (!pinfo) return -ENOMEM; /* Initializing the hardware */ ret = mid_initialize_adc(&pdev->dev); if (ret) { dev_err(&pdev->dev, "ADC init failed"); kfree(pinfo); return ret; } /* Register each sensor with the generic thermal framework*/ for (i = 0; i < MSIC_THERMAL_SENSORS; i++) { struct thermal_device_info *td_info = initialize_sensor(i); if (!td_info) { ret = -ENOMEM; goto err; } pinfo->tzd[i] = thermal_zone_device_register(name[i], 0, 0, td_info, &tzd_ops, NULL, 0, 0); if (IS_ERR(pinfo->tzd[i])) { kfree(td_info); ret = PTR_ERR(pinfo->tzd[i]); goto err; } } pinfo->pdev = pdev; platform_set_drvdata(pdev, pinfo); return 0; err: while (--i >= 0) { kfree(pinfo->tzd[i]->devdata); thermal_zone_device_unregister(pinfo->tzd[i]); } configure_adc(0); kfree(pinfo); return ret; }
/** * mid_thermal_probe - mfld thermal initialize * @ipcdev: ipc device structure * * mid thermal probe initializes the hardware and registers * all the sensors with the generic thermal framework. Can sleep. */ static int mid_thermal_probe(struct ipc_device *ipcdev) { int ret; int i; ipcinfo = kzalloc(sizeof(struct ipc_info), GFP_KERNEL); if (!ipcinfo) return -ENOMEM; /* initialize mutex locks */ mutex_init(&ipcinfo->cacheinfo.lock); #ifdef CONFIG_BOARD_CTP /* Allocate ADC channels for all sensors */ ipcinfo->therm_adc_handle = intel_mid_gpadc_alloc(MSIC_THERMAL_SENSORS, 0x04 | CH_NEED_VREF | CH_NEED_VCALIB, 0x04 | CH_NEED_VREF | CH_NEED_VCALIB, 0x03 | CH_NEED_VCALIB, 0x09 | CH_NEED_VREF | CH_NEED_VCALIB); #else /* Allocate ADC channels for all sensors */ ipcinfo->therm_adc_handle = intel_mid_gpadc_alloc(MSIC_THERMAL_SENSORS, 0x08 | CH_NEED_VREF | CH_NEED_VCALIB, 0x08 | CH_NEED_VREF | CH_NEED_VCALIB, 0x0A | CH_NEED_VREF | CH_NEED_VCALIB, 0x03 | CH_NEED_VCALIB); #endif if (!ipcinfo->therm_adc_handle) { ret = -ENOMEM; goto alloc_fail; } /* Register each sensor with the generic thermal framework*/ for (i = 0; i < MSIC_THERMAL_SENSORS; i++) { ipcinfo->tzd[i] = thermal_zone_device_register(name[i], 0, 0, initialize_sensor(i), &tzd_ops, 0, 0, 0, 0); if (IS_ERR(ipcinfo->tzd[i])) goto reg_fail; } ipcinfo->ipcdev = ipcdev; ipc_set_drvdata(ipcdev, ipcinfo); return 0; reg_fail: ret = PTR_ERR(ipcinfo->tzd[i]); while (--i >= 0) thermal_zone_device_unregister(ipcinfo->tzd[i]); alloc_fail: kfree(ipcinfo); return ret; }
/** * mid_thermal_remove - mfld thermal finalize * @dev: platform device structure * * MLFD thermal remove unregisters all the sensors from the generic * thermal framework. Can sleep. */ static int mid_thermal_remove(struct platform_device *pdev) { int i; struct platform_info *pinfo = platform_get_drvdata(pdev); for (i = 0; i < MSIC_THERMAL_SENSORS; i++) { kfree(pinfo->tzd[i]->devdata); thermal_zone_device_unregister(pinfo->tzd[i]); } /* Stop the ADC */ return configure_adc(0); }
static int __devexit pmic8901_tm_remove(struct platform_device *pdev) { struct pm8901_tm_device *tmdev = platform_get_drvdata(pdev); free_irq(tmdev->hi_irq, tmdev); free_irq(tmdev->irq, tmdev); thermal_zone_device_unregister(tmdev->tz_dev); platform_set_drvdata(pdev, tmdev->pm_chip); pm8901_tm_shutdown_override(tmdev->pm_chip, SOFTWARE_OVERRIDE_DISABLED); kfree(tmdev); return 0; }
static int __devexit pmic8058_tm_remove(struct platform_device *pdev) { struct pm8058_tm_device *tmdev = platform_get_drvdata(pdev); thermal_zone_device_unregister(tmdev->tz_dev); platform_set_drvdata(pdev, tmdev->pm_chip); pm8058_tm_shutdown_override(tmdev->pm_chip, THERMAL_DEVICE_DISABLED); adc_channel_close(tmdev->adc_handle); free_irq(tmdev->irq, tmdev); kfree(tmdev); return 0; }
static int imx_thermal_remove(struct platform_device *pdev) { struct imx_thermal_data *data = platform_get_drvdata(pdev); struct regmap *map = data->tempmon; /* Disable measurements */ regmap_write(map, TEMPSENSE0 + REG_SET, TEMPSENSE0_POWER_DOWN); thermal_zone_device_unregister(data->tz); cpufreq_cooling_unregister(data->cdev); return 0; }
static int int3400_thermal_remove(struct platform_device *pdev) { struct int3400_thermal_priv *priv = platform_get_drvdata(pdev); if (!priv->rel_misc_dev_res) acpi_thermal_rel_misc_device_remove(priv->adev->handle); sysfs_remove_group(&pdev->dev.kobj, &uuid_attribute_group); thermal_zone_device_unregister(priv->thermal); kfree(priv->trts); kfree(priv->arts); kfree(priv); return 0; }
static int __devexit qpnp_tm_remove(struct spmi_device *spmi) { struct qpnp_tm_chip *chip = dev_get_drvdata(&spmi->dev); dev_set_drvdata(&spmi->dev, NULL); thermal_zone_device_unregister(chip->tz_dev); kfree(chip->tm_name); qpnp_tm_shutdown_override(chip, SOFTWARE_OVERRIDE_DISABLED); free_irq(chip->irq, chip); cancel_delayed_work_sync(&chip->irq_work); kfree(chip); return 0; }
static int hisi_peripheral_tm_remove(struct platform_device *pdev) { struct hisi_peripheral_tm_chip *chip = platform_get_drvdata(pdev); int i; if (chip) { platform_set_drvdata(pdev, NULL); for (i = DETECT_SYSTEM_H_CHANEL; i < (gtm_dev->tsens_num_sensor + DETECT_SYSTEM_H_CHANEL); i++) { kfree(gtm_dev->sensor[i].ntc_name); thermal_zone_device_unregister(gtm_dev->sensor[i].tz_dev); } kfree(chip); } return 0; }
static int __devexit pm8xxx_tm_remove(struct platform_device *pdev) { struct pm8xxx_tm_chip *chip = platform_get_drvdata(pdev); if (chip) { platform_set_drvdata(pdev, NULL); cancel_work_sync(&chip->irq_work); free_irq(chip->overtemp_irq, chip); free_irq(chip->tempstat_irq, chip); pm8xxx_tm_shutdown_override(chip, SOFTWARE_OVERRIDE_DISABLED); thermal_zone_device_unregister(chip->tz_dev); kfree(chip); } return 0; }
/** * mid_thermal_remove - mfld thermal finalize * @dev: ipc device structure * * MLFD thermal remove unregisters all the sensors from the generic * thermal framework. Can sleep. */ static int mid_thermal_remove(struct ipc_device *ipcdev) { int i; for (i = 0; i < MSIC_THERMAL_SENSORS; i++) thermal_zone_device_unregister(ipcinfo->tzd[i]); /* Free the allocated ADC channels */ if (ipcinfo->therm_adc_handle) intel_mid_gpadc_free(ipcinfo->therm_adc_handle); kfree(ipcinfo); ipc_set_drvdata(ipcdev, NULL); return 0; }
/* Un-Register with the in-kernel thermal management */ static void exynos_unregister_thermal(void) { int i; for (i = 0; i < th_zone->cool_dev_size; i++) { if (th_zone && th_zone->cool_dev[i]) cpufreq_cooling_unregister(th_zone->cool_dev[i]); } if (th_zone && th_zone->therm_dev) thermal_zone_device_unregister(th_zone->therm_dev); kfree(th_zone); pr_info("Exynos: Kernel Thermal management unregistered\n"); }
static int spear_thermal_exit(struct platform_device *pdev) { unsigned int actual_mask = 0; struct thermal_zone_device *spear_thermal = platform_get_drvdata(pdev); struct spear_thermal_dev *stdev = spear_thermal->devdata; thermal_zone_device_unregister(spear_thermal); /* Disable SPEAr Thermal Sensor */ actual_mask = readl_relaxed(stdev->thermal_base); writel_relaxed(actual_mask & ~stdev->flags, stdev->thermal_base); clk_disable(stdev->clk); return 0; }
static int modem_thermal_remove(struct platform_device *pdev) { struct modem_thermal_data *mtd = platform_get_drvdata(pdev); int i; device_remove_file(&pdev->dev, &dev_attr_temp); device_remove_file(&pdev->dev, &dev_attr_sensors_active); for (i = 0; i < mtd->num_zones; i++) if (!IS_ERR(mtd->zi[i].tzd)) thermal_zone_device_unregister(mtd->zi[i].tzd); kfree(mtd->zi); kfree(mtd); return 0; }
static int __devexit therm_est_remove(struct platform_device *pdev) { struct therm_estimator *est = platform_get_drvdata(pdev); int i; cancel_delayed_work_sync(&est->therm_est_work); cancel_delayed_work_sync(&est->timer_trip_work); #ifdef CONFIG_PM unregister_pm_notifier(&est->pm_nb); #endif for (i = 0; i < ARRAY_SIZE(therm_est_nodes); i++) device_remove_file(&pdev->dev, &therm_est_nodes[i].dev_attr); thermal_zone_device_unregister(est->thz); destroy_workqueue(est->workqueue); kfree(est); return 0; }
/* Un-Register with the in-kernel thermal management */ void exynos_unregister_thermal(struct thermal_sensor_conf *sensor_conf) { int i; struct exynos_thermal_zone *th_zone; if (!sensor_conf || !sensor_conf->pzone_data) { pr_err("Invalid temperature sensor configuration data\n"); return; } th_zone = sensor_conf->pzone_data; thermal_zone_device_unregister(th_zone->therm_dev); for (i = 0; i < th_zone->cool_dev_size; ++i) cpufreq_cooling_unregister(th_zone->cool_dev[i]); dev_info(sensor_conf->dev, "Exynos: Kernel Thermal management unregistered\n"); }
static int __devinit qpnp_tm_probe(struct spmi_device *spmi) { struct device_node *node; struct resource *res; struct qpnp_tm_chip *chip; struct thermal_zone_device_ops *tz_ops; char *tm_name; u32 default_temperature; int rc = 0; u8 raw_type[2], type, subtype; if (!spmi || !(&spmi->dev) || !spmi->dev.of_node) { dev_err(&spmi->dev, "%s: device tree node not found\n", __func__); return -EINVAL; } node = spmi->dev.of_node; chip = kzalloc(sizeof(struct qpnp_tm_chip), GFP_KERNEL); if (!chip) { dev_err(&spmi->dev, "%s: Can't allocate qpnp_tm_chip\n", __func__); return -ENOMEM; } dev_set_drvdata(&spmi->dev, chip); res = spmi_get_resource(spmi, NULL, IORESOURCE_MEM, 0); if (!res) { dev_err(&spmi->dev, "%s: node is missing base address\n", __func__); rc = -EINVAL; goto free_chip; } chip->base_addr = res->start; chip->spmi_dev = spmi; chip->irq = spmi_get_irq(spmi, NULL, 0); if (chip->irq < 0) { rc = chip->irq; dev_err(&spmi->dev, "%s: node is missing irq, rc=%d\n", __func__, rc); goto free_chip; } chip->tm_name = of_get_property(node, "label", NULL); if (chip->tm_name == NULL) { dev_err(&spmi->dev, "%s: node is missing label\n", __func__); rc = -EINVAL; goto free_chip; } tm_name = kstrdup(chip->tm_name, GFP_KERNEL); if (tm_name == NULL) { dev_err(&spmi->dev, "%s: could not allocate memory for label\n", __func__); rc = -ENOMEM; goto free_chip; } chip->tm_name = tm_name; INIT_DELAYED_WORK(&chip->irq_work, qpnp_tm_work); /* These bindings are optional, so it is okay if they are not found. */ chip->thresh = THRESH_MAX + 1; rc = of_property_read_u32(node, "qcom,threshold-set", &chip->thresh); if (!rc && (chip->thresh < THRESH_MIN || chip->thresh > THRESH_MAX)) dev_err(&spmi->dev, "%s: invalid qcom,threshold-set=%u specified\n", __func__, chip->thresh); chip->adc_type = QPNP_TM_ADC_NONE; rc = of_property_read_u32(node, "qcom,channel-num", &chip->adc_channel); if (!rc) { if (chip->adc_channel < 0 || chip->adc_channel >= ADC_MAX_NUM) { dev_err(&spmi->dev, "%s: invalid qcom,channel-num=%d specified\n", __func__, chip->adc_channel); } else { chip->adc_type = QPNP_TM_ADC_QPNP_ADC; rc = qpnp_vadc_is_ready(); if (rc) { /* Probe retry, do not print an error message */ goto err_cancel_work; } } } if (chip->adc_type == QPNP_TM_ADC_QPNP_ADC) tz_ops = &qpnp_thermal_zone_ops_qpnp_adc; else tz_ops = &qpnp_thermal_zone_ops_no_adc; chip->allow_software_override = of_property_read_bool(node, "qcom,allow-override"); default_temperature = DEFAULT_NO_ADC_TEMP; rc = of_property_read_u32(node, "qcom,default-temp", &default_temperature); chip->temperature = default_temperature; rc = qpnp_tm_read(chip, QPNP_TM_REG_TYPE, raw_type, 2); if (rc) { dev_err(&spmi->dev, "%s: could not read type register, rc=%d\n", __func__, rc); goto err_cancel_work; } type = raw_type[0]; subtype = raw_type[1]; if (type != QPNP_TM_TYPE || subtype != QPNP_TM_SUBTYPE) { dev_err(&spmi->dev, "%s: invalid type=%02X or subtype=%02X register value\n", __func__, type, subtype); rc = -ENODEV; goto err_cancel_work; } rc = qpnp_tm_init_reg(chip); if (rc) { dev_err(&spmi->dev, "%s: qpnp_tm_init_reg() failed, rc=%d\n", __func__, rc); goto err_cancel_work; } if (chip->adc_type == QPNP_TM_ADC_NONE) { rc = qpnp_tm_init_temp_no_adc(chip); if (rc) { dev_err(&spmi->dev, "%s: qpnp_tm_init_temp_no_adc() failed, rc=%d\n", __func__, rc); goto err_cancel_work; } } /* Start in HW control; switch to SW control when user changes mode. */ chip->mode = THERMAL_DEVICE_DISABLED; rc = qpnp_tm_shutdown_override(chip, SOFTWARE_OVERRIDE_DISABLED); if (rc) { dev_err(&spmi->dev, "%s: qpnp_tm_shutdown_override() failed, rc=%d\n", __func__, rc); goto err_cancel_work; } chip->tz_dev = thermal_zone_device_register(tm_name, TRIP_NUM, chip, tz_ops, 0, 0, 0, 0); if (chip->tz_dev == NULL) { dev_err(&spmi->dev, "%s: thermal_zone_device_register() failed.\n", __func__); rc = -ENODEV; goto err_cancel_work; } rc = request_irq(chip->irq, qpnp_tm_isr, IRQF_TRIGGER_RISING, tm_name, chip); if (rc < 0) { dev_err(&spmi->dev, "%s: request_irq(%d) failed: %d\n", __func__, chip->irq, rc); goto err_free_tz; } return 0; err_free_tz: thermal_zone_device_unregister(chip->tz_dev); err_cancel_work: cancel_delayed_work_sync(&chip->irq_work); kfree(chip->tm_name); free_chip: dev_set_drvdata(&spmi->dev, NULL); kfree(chip); return rc; }
static int __devinit qpnp_tm_probe(struct spmi_device *spmi) { struct device_node *node; struct resource *res; struct qpnp_tm_chip *chip; struct thermal_zone_device_ops *tz_ops; char *tm_name; u32 default_temperature; int rc = 0; u8 raw_type[2], type, subtype; #ifdef CONFIG_LGE_PM struct spmi_resource *spmi_resource; u8 batt_pres_rt_sts; #endif if (!spmi || !(&spmi->dev) || !spmi->dev.of_node) { dev_err(&spmi->dev, "%s: device tree node not found\n", __func__); return -EINVAL; } node = spmi->dev.of_node; chip = kzalloc(sizeof(struct qpnp_tm_chip), GFP_KERNEL); if (!chip) { dev_err(&spmi->dev, "%s: Can't allocate qpnp_tm_chip\n", __func__); return -ENOMEM; } dev_set_drvdata(&spmi->dev, chip); res = spmi_get_resource(spmi, NULL, IORESOURCE_MEM, 0); if (!res) { dev_err(&spmi->dev, "%s: node is missing base address\n", __func__); rc = -EINVAL; goto free_chip; } chip->base_addr = res->start; chip->spmi_dev = spmi; chip->irq = spmi_get_irq(spmi, NULL, 0); if (chip->irq < 0) { rc = chip->irq; dev_err(&spmi->dev, "%s: node is missing irq, rc=%d\n", __func__, rc); goto free_chip; } chip->tm_name = of_get_property(node, "label", NULL); if (chip->tm_name == NULL) { dev_err(&spmi->dev, "%s: node is missing label\n", __func__); rc = -EINVAL; goto free_chip; } tm_name = kstrdup(chip->tm_name, GFP_KERNEL); if (tm_name == NULL) { dev_err(&spmi->dev, "%s: could not allocate memory for label\n", __func__); rc = -ENOMEM; goto free_chip; } chip->tm_name = tm_name; INIT_DELAYED_WORK(&chip->irq_work, qpnp_tm_work); /* These bindings are optional, so it is okay if they are not found. */ chip->thresh = THRESH_MAX + 1; rc = of_property_read_u32(node, "qcom,threshold-set", &chip->thresh); if (!rc && (chip->thresh < THRESH_MIN || chip->thresh > THRESH_MAX)) dev_err(&spmi->dev, "%s: invalid qcom,threshold-set=%u specified\n", __func__, chip->thresh); chip->adc_type = QPNP_TM_ADC_NONE; rc = of_property_read_u32(node, "qcom,channel-num", &chip->adc_channel); if (!rc) { if (chip->adc_channel < 0 || chip->adc_channel >= ADC_MAX_NUM) { dev_err(&spmi->dev, "%s: invalid qcom,channel-num=%d specified\n", __func__, chip->adc_channel); } else { chip->adc_type = QPNP_TM_ADC_QPNP_ADC; chip->vadc_dev = qpnp_get_vadc(&spmi->dev, "temp_alarm"); if (IS_ERR(chip->vadc_dev)) { rc = PTR_ERR(chip->vadc_dev); if (rc != -EPROBE_DEFER) pr_err("vadc property missing\n"); goto err_cancel_work; } } } if (chip->adc_type == QPNP_TM_ADC_QPNP_ADC) tz_ops = &qpnp_thermal_zone_ops_qpnp_adc; else tz_ops = &qpnp_thermal_zone_ops_no_adc; chip->allow_software_override = of_property_read_bool(node, "qcom,allow-override"); default_temperature = DEFAULT_NO_ADC_TEMP; rc = of_property_read_u32(node, "qcom,default-temp", &default_temperature); chip->temperature = default_temperature; rc = qpnp_tm_read(chip, QPNP_TM_REG_TYPE, raw_type, 2); if (rc) { dev_err(&spmi->dev, "%s: could not read type register, rc=%d\n", __func__, rc); goto err_cancel_work; } type = raw_type[0]; subtype = raw_type[1]; if (type != QPNP_TM_TYPE || subtype != QPNP_TM_SUBTYPE) { dev_err(&spmi->dev, "%s: invalid type=%02X or subtype=%02X register value\n", __func__, type, subtype); rc = -ENODEV; goto err_cancel_work; } rc = qpnp_tm_init_reg(chip); if (rc) { dev_err(&spmi->dev, "%s: qpnp_tm_init_reg() failed, rc=%d\n", __func__, rc); goto err_cancel_work; } if (chip->adc_type == QPNP_TM_ADC_NONE) { rc = qpnp_tm_init_temp_no_adc(chip); if (rc) { dev_err(&spmi->dev, "%s: qpnp_tm_init_temp_no_adc() failed, rc=%d\n", __func__, rc); goto err_cancel_work; } } /* Start in HW control; switch to SW control when user changes mode. */ chip->mode = THERMAL_DEVICE_DISABLED; rc = qpnp_tm_shutdown_override(chip, SOFTWARE_OVERRIDE_DISABLED); if (rc) { dev_err(&spmi->dev, "%s: qpnp_tm_shutdown_override() failed, rc=%d\n", __func__, rc); goto err_cancel_work; } chip->tz_dev = thermal_zone_device_register(tm_name, TRIP_NUM, chip, tz_ops, 0, 0, 0, 0); if (chip->tz_dev == NULL) { dev_err(&spmi->dev, "%s: thermal_zone_device_register() failed.\n", __func__); rc = -ENODEV; goto err_cancel_work; } rc = request_irq(chip->irq, qpnp_tm_isr, IRQF_TRIGGER_RISING, tm_name, chip); if (rc < 0) { dev_err(&spmi->dev, "%s: request_irq(%d) failed: %d\n", __func__, chip->irq, rc); goto err_free_tz; } #ifdef CONFIG_LGE_PM spmi_for_each_container_dev(spmi_resource, spmi) { if (!spmi_resource) { pr_err("qpnp temp alarm : spmi resource absent\n"); goto fail_bat_if; } res = spmi_get_resource(spmi, spmi_resource, IORESOURCE_MEM, 0); if (!(res && res->start)) { pr_err("node %s IO resource absent!\n", spmi->dev.of_node->full_name); goto fail_bat_if; } rc = qpnp_register_read(chip, &subtype, res->start + REG_OFFSET_PERP_SUBTYPE, 1); if (rc) { pr_err("Peripheral subtype read failed rc=%d\n", rc); goto fail_bat_if; } switch (subtype) { case SMBB_BAT_IF_SUBTYPE: pr_err("qpnp bat_if block enable for batt insert remove irq.\n"); chip->bat_if_base = res->start; chip->batt_present_irq = spmi_get_irq_byname(chip->spmi_dev, spmi_resource, "batt-pres"); if (chip->batt_present_irq < 0) { pr_err("Unable to get batt_present_irq\n"); goto fail_bat_if; } rc = devm_request_irq(&(chip->spmi_dev->dev), chip->batt_present_irq, qpnp_batif_batt_inserted_removed_irq_handler, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, "batt_remove_insert", chip); if (rc < 0) { pr_err("Can't request %d batt irq for insert, remove : %d\n", chip->batt_present_irq, rc); goto fail_bat_if; } rc = qpnp_register_masked_write(chip, INT_EN_SET(chip->bat_if_base), BATT_PRES_EN_BIT, BATT_PRES_EN_BIT, 1); if (rc) { pr_err("failed to enable BAT_IF_INT_EN_SET rc=%d\n", rc); goto fail_bat_if; } /* smb349 charger battery present W/A */ rc = qpnp_register_read(chip, &batt_pres_rt_sts, INT_RT_STS(chip->bat_if_base), 1); if (rc) { pr_err("spmi read failed: addr=%03X, rc=%d\n", INT_RT_STS(chip->bat_if_base), rc); pr_err("assume that battery is present\n"); /* battery present */ pm_batt_rt_sts = 1; } else { pm_batt_rt_sts = (int)(batt_pres_rt_sts & BATT_IF_PRES_RT_STATUS); pr_err("%s : init PMIC battery RTS = %d\n", __func__, pm_batt_rt_sts); } enable_irq_wake(chip->batt_present_irq); break; default: break; } } INIT_WORK(&chip->batt_insert_remove_worker, batt_insert_remove_work); INIT_DELAYED_WORK(&chip->batt_insert_remove_worker_second, batt_insert_remove_work_second); wake_lock_init(&chip->battgone_wake_lock, WAKE_LOCK_SUSPEND, "batt removed"); #endif return 0; err_free_tz: thermal_zone_device_unregister(chip->tz_dev); err_cancel_work: cancel_delayed_work_sync(&chip->irq_work); kfree(chip->tm_name); free_chip: dev_set_drvdata(&spmi->dev, NULL); kfree(chip); return rc; #ifdef CONFIG_LGE_PM fail_bat_if: pr_err("Cannot enable qpnp bat_if block.\n"); return 0; #endif }
static int modem_thermal_probe(struct platform_device *pdev) { struct modem_thermal_platform_data *pdata = pdev->dev.platform_data; struct modem_thermal_data *mtd; char tz_name[THERMAL_NAME_LENGTH]; int i; int ret; mtd = kzalloc(sizeof(struct modem_thermal_data), GFP_KERNEL); if (!mtd) { dev_err(&pdev->dev, "failed to allocated memory\n"); ret = -ENOMEM; return ret; } mtd->num_zones = pdata->num_zones; mtd->zi = kzalloc(mtd->num_zones * sizeof(struct modem_zone_info), GFP_KERNEL); if (!mtd->zi) { dev_err(&pdev->dev, "failed to allocate zones\n"); ret = -ENOMEM; goto err_mtd_free; } for (i = 0; i < mtd->num_zones; i++) { snprintf(&tz_name, THERMAL_NAME_LENGTH, "modem%d", i); mtd->zi[i].tzd = thermal_zone_device_register(&tz_name, 0, 0, mtd, &modem_thermal_ops, NULL, 0, 0); if (IS_ERR(mtd->zi[i].tzd)) { dev_err(&pdev->dev, "error in therm reg\n"); ret = -EINVAL; goto err_tzd_unregister; } } if (device_create_file(&pdev->dev, &dev_attr_temp)) { dev_err(&pdev->dev, "can't create temp sysfs file\n"); ret = -EINVAL; goto err_remove_temp_file; } if (device_create_file(&pdev->dev, &dev_attr_sensors_active)) { dev_err(&pdev->dev, "can't create sensors sysfs file\n"); ret = -EINVAL; goto err_remove_sensor_file; } mtd->dev = &pdev->dev; dev_set_drvdata(&pdev->dev, mtd); return 0; err_remove_sensor_file: device_remove_file(&pdev->dev, &dev_attr_sensors_active); err_remove_temp_file: device_remove_file(&pdev->dev, &dev_attr_temp); err_tzd_unregister: for (i = 0; i < mtd->num_zones; i++) if (!IS_ERR(mtd->zi[i].tzd)) thermal_zone_device_unregister(mtd->zi[i].tzd); kfree(mtd->zi); err_mtd_free: kfree(mtd); return ret; }
static int bcm2835_thermal_remove(struct platform_device *pdev) { thermal_zone_device_unregister(platform_get_drvdata(pdev)); return 0; }
static int __devinit pmic8901_tm_probe(struct platform_device *pdev) { struct pm8901_tm_device *tmdev; struct pm8901_chip *pm_chip; unsigned int irq, hi_irq; int rc; pm_chip = platform_get_drvdata(pdev); if (pm_chip == NULL) { pr_err("%s: no driver data passed in.\n", __func__); return -EFAULT; } irq = platform_get_irq(pdev, 0); if (!irq) { pr_err("%s: no IRQ passed in.\n", __func__); return -EFAULT; } hi_irq = platform_get_irq(pdev, 1); if (!hi_irq) { pr_err("%s: no HI IRQ passed in.\n", __func__); return -EFAULT; } tmdev = kzalloc(sizeof *tmdev, GFP_KERNEL); if (tmdev == NULL) { pr_err("%s: kzalloc() failed.\n", __func__); return -ENOMEM; } tmdev->tz_dev = thermal_zone_device_register("pm8901_tz", PM8901_TRIP_NUM, tmdev, &pm8901_thermal_zone_ops, 0, 0, 0, 0); if (tmdev->tz_dev == NULL) { pr_err("%s: thermal_zone_device_register() failed.\n", __func__); kfree(tmdev); return -ENODEV; } tmdev->pm_chip = pm_chip; rc = pm8901_tm_init_reg(tmdev); pm8901_tm_shutdown_override(tmdev->pm_chip, SOFTWARE_OVERRIDE_DISABLED); if (rc < 0) { thermal_zone_device_unregister(tmdev->tz_dev); kfree(tmdev); return rc; } /* start in HW control, switch to SW control when user changes mode */ tmdev->mode = THERMAL_DEVICE_DISABLED; thermal_zone_device_update(tmdev->tz_dev); platform_set_drvdata(pdev, tmdev); rc = request_threaded_irq(irq, pm8901_tm_isr1, NULL, IRQF_TRIGGER_RISING | IRQF_DISABLED, "pm8901-tm-irq", tmdev); if (rc < 0) { pr_err("%s: request_threaded_irq(%d) FAIL: %d\n", __func__, irq, rc); thermal_zone_device_unregister(tmdev->tz_dev); platform_set_drvdata(pdev, tmdev->pm_chip); kfree(tmdev); return -ENODEV; } tmdev->irq = irq; rc = request_threaded_irq(hi_irq, pm8901_tm_isr2, NULL, IRQF_TRIGGER_RISING | IRQF_DISABLED, "pm8901-tm-irq2", tmdev); if (rc < 0) { pr_err("%s: request_threaded_irq(%d) FAIL: %d\n", __func__, hi_irq, rc); free_irq(irq, tmdev); thermal_zone_device_unregister(tmdev->tz_dev); platform_set_drvdata(pdev, tmdev->pm_chip); kfree(tmdev); return -ENODEV; } tmdev->hi_irq = hi_irq; pr_notice("%s: OK\n", __func__); return 0; }
static int __devinit pmic8058_tm_probe(struct platform_device *pdev) { DECLARE_COMPLETION_ONSTACK(wait); struct pm8058_tm_device *tmdev; struct pm8058_chip *pm_chip; unsigned int irq; int rc; pm_chip = platform_get_drvdata(pdev); if (pm_chip == NULL) { pr_err("%s: no driver data passed in.\n", __func__); return -EFAULT; } irq = platform_get_irq(pdev, 0); if (!irq) { pr_err("%s: no IRQ passed in.\n", __func__); return -EFAULT; } tmdev = kzalloc(sizeof *tmdev, GFP_KERNEL); if (tmdev == NULL) { pr_err("%s: kzalloc() failed.\n", __func__); return -ENOMEM; } rc = adc_channel_open(PM8058_TEMP_ADC_CH, &(tmdev->adc_handle)); if (rc < 0) { pr_err("%s: adc_channel_open() failed.\n", __func__); kfree(tmdev); return rc; } /* calibrate the die temperature sensor */ if (adc_calib_request(tmdev->adc_handle, &wait) == CALIB_STARTED) wait_for_completion(&wait); tmdev->pm_chip = pm_chip; tmdev->tz_dev = thermal_zone_device_register("pm8058_tz", PM8058_TRIP_NUM, tmdev, &pm8058_thermal_zone_ops, 0, 0, 0, 0); if (tmdev->tz_dev == NULL) { pr_err("%s: thermal_zone_device_register() failed.\n", __func__); adc_channel_close(tmdev->adc_handle); kfree(tmdev); return -ENODEV; } rc = pm8058_tm_init_reg(tmdev); pm8058_tm_shutdown_override(tmdev->pm_chip, SOFTWARE_OVERRIDE_DISABLED); if (rc < 0) { thermal_zone_device_unregister(tmdev->tz_dev); adc_channel_close(tmdev->adc_handle); kfree(tmdev); return rc; } /* start in HW control, switch to SW control when user changes mode */ tmdev->mode = THERMAL_DEVICE_DISABLED; thermal_zone_device_update(tmdev->tz_dev); platform_set_drvdata(pdev, tmdev); rc = request_threaded_irq(irq, NULL, pm8058_tm_isr, IRQF_TRIGGER_RISING | IRQF_DISABLED, "pm8058-tm-irq", tmdev); if (rc < 0) { pr_err("%s: request_irq(%d) FAIL: %d\n", __func__, irq, rc); thermal_zone_device_unregister(tmdev->tz_dev); platform_set_drvdata(pdev, tmdev->pm_chip); adc_channel_close(tmdev->adc_handle); kfree(tmdev); return rc; } tmdev->irq = irq; pr_notice("%s: OK\n", __func__); return 0; }
static int __devinit pm8xxx_tm_probe(struct platform_device *pdev) { const struct pm8xxx_tm_core_data *cdata = pdev->dev.platform_data; struct thermal_zone_device_ops *tz_ops; struct pm8xxx_tm_chip *chip; struct resource *res; int rc = 0; if (!cdata) { pr_err("missing core data\n"); return -EINVAL; } chip = kzalloc(sizeof(struct pm8xxx_tm_chip), GFP_KERNEL); if (chip == NULL) { pr_err("kzalloc() failed.\n"); return -ENOMEM; } chip->dev = &pdev->dev; memcpy(&(chip->cdata), cdata, sizeof(struct pm8xxx_tm_core_data)); res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, chip->cdata.irq_name_temp_stat); if (res) { chip->tempstat_irq = res->start; } else { pr_err("temp stat IRQ not specified\n"); goto err_free_chip; } res = platform_get_resource_byname(pdev, IORESOURCE_IRQ, chip->cdata.irq_name_over_temp); if (res) { chip->overtemp_irq = res->start; } else { pr_err("over temp IRQ not specified\n"); goto err_free_chip; } rc = pm8xxx_init_adc(chip, true); if (rc < 0) { pr_err("Unable to initialize adc\n"); goto err_free_chip; } /* Select proper thermal zone ops functions based on ADC type. */ if (chip->cdata.adc_type == PM8XXX_TM_ADC_PM8XXX_ADC) tz_ops = &pm8xxx_thermal_zone_ops_pm8xxx_adc; else if (chip->cdata.adc_type == PM8XXX_TM_ADC_PM8058_ADC) tz_ops = &pm8xxx_thermal_zone_ops_pm8058_adc; else tz_ops = &pm8xxx_thermal_zone_ops_no_adc; chip->tz_dev = thermal_zone_device_register(chip->cdata.tm_name, TRIP_NUM, chip, tz_ops, 0, 0, 0, 0); if (chip->tz_dev == NULL) { pr_err("thermal_zone_device_register() failed.\n"); rc = -ENODEV; goto err_fail_adc; } rc = pm8xxx_tm_init_reg(chip); if (rc < 0) goto err_free_tz; rc = pm8xxx_tm_shutdown_override(chip, SOFTWARE_OVERRIDE_DISABLED); if (rc < 0) goto err_free_tz; if (chip->cdata.adc_type == PM8XXX_TM_ADC_NONE) { rc = pm8xxx_tm_init_temp_no_adc(chip); if (rc < 0) goto err_free_tz; } /* Start in HW control; switch to SW control when user changes mode. */ chip->mode = THERMAL_DEVICE_DISABLED; thermal_zone_device_update(chip->tz_dev); INIT_DELAYED_WORK(&chip->irq_work, pm8xxx_tm_work); rc = request_irq(chip->tempstat_irq, pm8xxx_tm_isr, IRQF_TRIGGER_RISING, chip->cdata.irq_name_temp_stat, chip); if (rc < 0) { pr_err("request_irq(%d) failed: %d\n", chip->tempstat_irq, rc); goto err_cancel_work; } rc = request_irq(chip->overtemp_irq, pm8xxx_tm_isr, IRQF_TRIGGER_RISING, chip->cdata.irq_name_over_temp, chip); if (rc < 0) { pr_err("request_irq(%d) failed: %d\n", chip->overtemp_irq, rc); goto err_free_irq_tempstat; } platform_set_drvdata(pdev, chip); pr_info("OK\n"); return 0; err_free_irq_tempstat: free_irq(chip->tempstat_irq, chip); err_cancel_work: cancel_delayed_work_sync(&chip->irq_work); err_free_tz: thermal_zone_device_unregister(chip->tz_dev); err_fail_adc: pm8xxx_init_adc(chip, false); err_free_chip: kfree(chip); return rc; }
static int int3400_thermal_probe(struct platform_device *pdev) { struct acpi_device *adev = ACPI_COMPANION(&pdev->dev); struct int3400_thermal_priv *priv; int result; if (!adev) return -ENODEV; priv = kzalloc(sizeof(struct int3400_thermal_priv), GFP_KERNEL); if (!priv) return -ENOMEM; priv->adev = adev; result = int3400_thermal_get_uuids(priv); if (result) goto free_priv; result = acpi_parse_art(priv->adev->handle, &priv->art_count, &priv->arts, true); if (result) dev_dbg(&pdev->dev, "_ART table parsing error\n"); result = acpi_parse_trt(priv->adev->handle, &priv->trt_count, &priv->trts, true); if (result) dev_dbg(&pdev->dev, "_TRT table parsing error\n"); platform_set_drvdata(pdev, priv); if (priv->uuid_bitmap & 1 << INT3400_THERMAL_PASSIVE_1) { int3400_thermal_ops.get_mode = int3400_thermal_get_mode; int3400_thermal_ops.set_mode = int3400_thermal_set_mode; } priv->thermal = thermal_zone_device_register("INT3400 Thermal", 0, 0, priv, &int3400_thermal_ops, &int3400_thermal_params, 0, 0); if (IS_ERR(priv->thermal)) { result = PTR_ERR(priv->thermal); goto free_art_trt; } priv->rel_misc_dev_res = acpi_thermal_rel_misc_device_add( priv->adev->handle); result = sysfs_create_group(&pdev->dev.kobj, &uuid_attribute_group); if (result) goto free_zone; return 0; free_zone: thermal_zone_device_unregister(priv->thermal); free_art_trt: kfree(priv->trts); kfree(priv->arts); free_priv: kfree(priv); return result; }