Merge branch 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 12 Dec 2012 15:57:13 +0000 (07:57 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 12 Dec 2012 15:57:13 +0000 (07:57 -0800)
Pull thermal management update from Zhang Rui:
 "Highlights:

   - Introduction of thermal policy support, together with three new
     thermal governors, including step_wise, user_space, fire_share.

   - Introduction of ST-Ericsson db8500_thermal driver and ST-Ericsson
     db8500_cpufreq_cooling driver.

   - Thermal Kconfig file and Makefile refactor.

   - Fixes for generic thermal layer, generic cpucooling, rcar thermal
     driver and Exynos thermal driver."

* 'release' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux: (36 commits)
  Thermal: Fix DEFAULT_THERMAL_GOVERNOR
  Thermal: fix a NULL pointer dereference when generic thermal layer is built as a module
  thermal: rcar: add rcar_zone_to_priv() macro
  thermal: rcar: fixup the unit of temperature
  thermal: cpu cooling: allow module builds
  thermal: cpu cooling: use const parameter while registering
  Thermal: Add ST-Ericsson DB8500 thermal properties and platform data.
  Thermal: Add ST-Ericsson DB8500 thermal driver.
  drivers/thermal/Makefile refactor
  Exynos: Add missing dependency
  Refactor drivers/thermal/Kconfig
  thermal: cpu_cooling: Make 'notify_device' static
  Thermal: Remove the cooling_cpufreq_list.
  Thermal: fix bug of counting cpu frequencies.
  Thermal: add indent for code alignment.
  thermal: rcar_thermal: remove explicitly used devm_kfree/iounap()
  thermal: user_space: Add missing static storage class specifiers
  thermal: fair_share: Add missing static storage class specifiers
  thermal: step_wise: Add missing static storage class specifiers
  Thermal: Fix oops and unlocking in thermal_sys.c
  ...

1  2 
arch/arm/mach-ux500/board-mop500.c
drivers/acpi/thermal.c
drivers/staging/omap-thermal/omap-thermal-common.c

@@@ -16,6 -16,7 +16,7 @@@
  #include <linux/io.h>
  #include <linux/i2c.h>
  #include <linux/platform_data/i2c-nomadik.h>
+ #include <linux/platform_data/db8500_thermal.h>
  #include <linux/gpio.h>
  #include <linux/amba/bus.h>
  #include <linux/amba/pl022.h>
  #include <linux/of_platform.h>
  #include <linux/leds.h>
  #include <linux/pinctrl/consumer.h>
 +#include <linux/platform_data/pinctrl-nomadik.h>
  
  #include <asm/mach-types.h>
  #include <asm/mach/arch.h>
  #include <asm/hardware/gic.h>
  
  #include <plat/ste_dma40.h>
 -#include <plat/gpio-nomadik.h>
  
  #include <mach/hardware.h>
  #include <mach/setup.h>
@@@ -228,6 -229,67 +229,67 @@@ static struct ab8500_platform_data ab85
        .codec          = &ab8500_codec_pdata,
  };
  
+ /*
+  * Thermal Sensor
+  */
+ static struct resource db8500_thsens_resources[] = {
+       {
+               .name = "IRQ_HOTMON_LOW",
+               .start  = IRQ_PRCMU_HOTMON_LOW,
+               .end    = IRQ_PRCMU_HOTMON_LOW,
+               .flags  = IORESOURCE_IRQ,
+       },
+       {
+               .name = "IRQ_HOTMON_HIGH",
+               .start  = IRQ_PRCMU_HOTMON_HIGH,
+               .end    = IRQ_PRCMU_HOTMON_HIGH,
+               .flags  = IORESOURCE_IRQ,
+       },
+ };
+ static struct db8500_thsens_platform_data db8500_thsens_data = {
+       .trip_points[0] = {
+               .temp = 70000,
+               .type = THERMAL_TRIP_ACTIVE,
+               .cdev_name = {
+                       [0] = "thermal-cpufreq-0",
+               },
+       },
+       .trip_points[1] = {
+               .temp = 75000,
+               .type = THERMAL_TRIP_ACTIVE,
+               .cdev_name = {
+                       [0] = "thermal-cpufreq-0",
+               },
+       },
+       .trip_points[2] = {
+               .temp = 80000,
+               .type = THERMAL_TRIP_ACTIVE,
+               .cdev_name = {
+                       [0] = "thermal-cpufreq-0",
+               },
+       },
+       .trip_points[3] = {
+               .temp = 85000,
+               .type = THERMAL_TRIP_CRITICAL,
+       },
+       .num_trips = 4,
+ };
+ static struct platform_device u8500_thsens_device = {
+       .name           = "db8500-thermal",
+       .resource       = db8500_thsens_resources,
+       .num_resources  = ARRAY_SIZE(db8500_thsens_resources),
+       .dev    = {
+               .platform_data  = &db8500_thsens_data,
+       },
+ };
+ static struct platform_device u8500_cpufreq_cooling_device = {
+       .name           = "db8500-cpufreq-cooling",
+ };
  /*
   * TPS61052
   */
@@@ -583,6 -645,8 +645,8 @@@ static struct platform_device *snowball
        &snowball_key_dev,
        &snowball_sbnet_dev,
        &snowball_gpio_en_3v3_regulator_dev,
+       &u8500_thsens_device,
+       &u8500_cpufreq_cooling_device,
  };
  
  static void __init mop500_init_machine(void)
diff --combined drivers/acpi/thermal.c
@@@ -900,14 -900,14 +900,14 @@@ static int acpi_thermal_register_therma
        if (tz->trips.passive.flags.valid)
                tz->thermal_zone =
                        thermal_zone_device_register("acpitz", trips, 0, tz,
-                                                    &acpi_thermal_zone_ops,
+                                               &acpi_thermal_zone_ops, NULL,
                                                     tz->trips.passive.tsp*100,
                                                     tz->polling_frequency*100);
        else
                tz->thermal_zone =
                        thermal_zone_device_register("acpitz", trips, 0, tz,
-                                                    &acpi_thermal_zone_ops, 0,
-                                                    tz->polling_frequency*100);
+                                               &acpi_thermal_zone_ops, NULL,
+                                               0, tz->polling_frequency*100);
        if (IS_ERR(tz->thermal_zone))
                return -ENODEV;
  
@@@ -984,38 -984,6 +984,38 @@@ static void acpi_thermal_notify(struct 
        }
  }
  
 +/*
 + * On some platforms, the AML code has dependency about
 + * the evaluating order of _TMP and _CRT/_HOT/_PSV/_ACx.
 + * 1. On HP Pavilion G4-1016tx, _TMP must be invoked after
 + *    /_CRT/_HOT/_PSV/_ACx, or else system will be power off.
 + * 2. On HP Compaq 6715b/6715s, the return value of _PSV is 0
 + *    if _TMP has never been evaluated.
 + *
 + * As this dependency is totally transparent to OS, evaluate
 + * all of them once, in the order of _CRT/_HOT/_PSV/_ACx,
 + * _TMP, before they are actually used.
 + */
 +static void acpi_thermal_aml_dependency_fix(struct acpi_thermal *tz)
 +{
 +      acpi_handle handle = tz->device->handle;
 +      unsigned long long value;
 +      int i;
 +
 +      acpi_evaluate_integer(handle, "_CRT", NULL, &value);
 +      acpi_evaluate_integer(handle, "_HOT", NULL, &value);
 +      acpi_evaluate_integer(handle, "_PSV", NULL, &value);
 +      for (i = 0; i < ACPI_THERMAL_MAX_ACTIVE; i++) {
 +              char name[5] = { '_', 'A', 'C', ('0' + i), '\0' };
 +              acpi_status status;
 +
 +              status = acpi_evaluate_integer(handle, name, NULL, &value);
 +              if (status == AE_NOT_FOUND)
 +                      break;
 +      }
 +      acpi_evaluate_integer(handle, "_TMP", NULL, &value);
 +}
 +
  static int acpi_thermal_get_info(struct acpi_thermal *tz)
  {
        int result = 0;
        if (!tz)
                return -EINVAL;
  
 +      acpi_thermal_aml_dependency_fix(tz);
 +
        /* Get trip points [_CRT, _PSV, etc.] (required) */
        result = acpi_thermal_get_trip_points(tz);
        if (result)
@@@ -29,7 -29,6 +29,7 @@@
  #include <linux/workqueue.h>
  #include <linux/thermal.h>
  #include <linux/cpufreq.h>
 +#include <linux/cpumask.h>
  #include <linux/cpu_cooling.h>
  
  #include "omap-thermal.h"
@@@ -113,7 -112,7 +113,7 @@@ static int omap_thermal_bind(struct the
                              struct thermal_cooling_device *cdev)
  {
        struct omap_thermal_data *data = thermal->devdata;
 -      int max, id;
 +      int id;
  
        if (IS_ERR_OR_NULL(data))
                return -ENODEV;
                return 0;
  
        id = data->sensor_id;
 -      max = data->bg_ptr->conf->sensors[id].cooling_data.freq_clip_count;
  
        /* TODO: bind with min and max states */
        /* Simple thing, two trips, one passive another critical */
@@@ -256,12 -256,12 +256,12 @@@ static struct omap_thermal_dat
  int omap_thermal_expose_sensor(struct omap_bandgap *bg_ptr, int id,
                               char *domain)
  {
 -      struct omap_thermal_pdata pdata;
 +      struct omap_thermal_data *data;
  
        data = omap_bandgap_get_sensor_data(bg_ptr, id);
  
        if (!data)
 -              data = omap_thermal_build_pdata(bg_ptr, id);
 +              data = omap_thermal_build_data(bg_ptr, id);
  
        if (!data)
                return -EINVAL;
        /* Create thermal zone */
        data->omap_thermal = thermal_zone_device_register(domain,
                                OMAP_TRIP_NUMBER, 0, data, &omap_thermal_ops,
-                               FAST_TEMP_MONITORING_RATE,
+                               NULL, FAST_TEMP_MONITORING_RATE,
                                FAST_TEMP_MONITORING_RATE);
        if (IS_ERR_OR_NULL(data->omap_thermal)) {
                dev_err(bg_ptr->dev, "thermal zone device is NULL\n");
@@@ -304,24 -304,81 +304,24 @@@ int omap_thermal_report_sensor_temperat
        return 0;
  }
  
 -static int omap_thermal_build_cpufreq_clip(struct omap_bandgap *bg_ptr,
 -                                         struct freq_clip_table **tab_ptr,
 -                                         int *tab_size)
 -{
 -      struct cpufreq_frequency_table *freq_table;
 -      struct freq_clip_table *tab;
 -      int i, count = 0;
 -
 -      freq_table = cpufreq_frequency_get_table(0);
 -      if (IS_ERR_OR_NULL(freq_table)) {
 -              dev_err(bg_ptr->dev,
 -                      "%s: failed to get cpufreq table (%p)\n",
 -                      __func__, freq_table);
 -              return -EINVAL;
 -      }
 -
 -      for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) {
 -              unsigned int freq = freq_table[i].frequency;
 -              if (freq == CPUFREQ_ENTRY_INVALID)
 -                      continue;
 -              count++;
 -      }
 -
 -      tab = devm_kzalloc(bg_ptr->dev, sizeof(*tab) * count, GFP_KERNEL);
 -      if (!tab) {
 -              dev_err(bg_ptr->dev,
 -                      "%s: no memory available\n", __func__);
 -              return -ENOMEM;
 -      }
 -
 -      for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) {
 -              unsigned int freq = freq_table[i].frequency;
 -
 -              if (freq == CPUFREQ_ENTRY_INVALID)
 -                      continue;
 -
 -              tab[count - i - 1].freq_clip_max = freq;
 -              tab[count - i - 1].temp_level = OMAP_TRIP_HOT;
 -              tab[count - i - 1].mask_val = cpumask_of(0);
 -      }
 -
 -      *tab_ptr = tab;
 -      *tab_size = count;
 -
 -      return 0;
 -}
 -
  int omap_thermal_register_cpu_cooling(struct omap_bandgap *bg_ptr, int id)
  {
        struct omap_thermal_data *data;
 -      struct freq_clip_table *tab_ptr;
 -      int tab_size, ret;
  
        data = omap_bandgap_get_sensor_data(bg_ptr, id);
        if (!data)
 -              data = omap_thermal_build_pdata(bg_ptr, id);
 +              data = omap_thermal_build_data(bg_ptr, id);
  
        if (!data)
                return -EINVAL;
  
 -      ret = omap_thermal_build_cpufreq_clip(bg_ptr, &tab_ptr, &tab_size);
 -      if (ret < 0) {
 -              dev_err(bg_ptr->dev,
 -                      "%s: failed to build cpufreq clip table\n", __func__);
 -              return ret;
 -      }
 -
        /* Register cooling device */
 -      data->cool_dev = cpufreq_cooling_register(tab_ptr, tab_size);
 +      data->cool_dev = cpufreq_cooling_register(cpu_present_mask);
        if (IS_ERR_OR_NULL(data->cool_dev)) {
                dev_err(bg_ptr->dev,
                        "Failed to register cpufreq cooling device\n");
                return PTR_ERR(data->cool_dev);
        }
 -      bg_ptr->conf->sensors[id].cooling_data.freq_clip_count = tab_size;
        omap_bandgap_set_sensor_data(bg_ptr, id, data);
  
        return 0;