OMAP4460PLUS Thermal: Thermal framework support

The patch adds kernel thermal framework and on die
CPU governer support.

Change-Id: I9490a545e3c3b3c395bfa044001a0b6741170893
Signed-off-by: Dan Murphy <dmurphy@ti.com>
Signed-off-by: Moiz Sonasath <m-sonasath@ti.com>
Signed-off-by: J Keerthy <j-keerthy@ti.com>
Signed-off-by: Margarita Olaya <magi.olaya@ti.com>

Conflicts:
	drivers/staging/Makefile
TI thermal framework: Remove unused index

This patch removes index information as it is never used.

Change-Id: I621036f68ecef9ea4ec2a8dbd1edc1d53df2f817
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
Signed-off-by: Radhesh Fadnis <radhesh.fadnis@ti.com>
 TI thermal framework: standardize thermal device ops

This patch changes the .process_temp callback of governor
type of thermal devices. The aim is to make all callbacks
standard. Now, all callbacks receive as first parameter
the affected thermal device.

Change-Id: If1765c36e401a9327103be0a5fb36c3dabf7c665
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
Signed-off-by: Radhesh Fadnis <radhesh.fadnis@ti.com>
Revert " TI thermal framework: standardize thermal device ops"

This reverts commit 6d7cbe21b307842beb535a9703904f149cd038d4.
Revert "TI thermal framework: Remove unused index"

This reverts commit f1a722c598f12c2f9f299ee0e48a859f97941600.
OMAP4 Thermal Framework: support multiple sensors per domain

Current thermal framework implementation supports 1 temperature
sensor per thermal domain.
The OMAP CPU thermal governor needs to support OMAP and PCB temperature
sensors.
This patch updates the thermal framework to support multiple temperature
sensors per domain.
 - Added temperature report from sensors until at least 1 governor, 1 sensor and
1 cooling device are registered to the thermal framework to have pointers to
temperature sensor initialized at governor level.
 - Updated the thermal framework to allow getting temperature from multiple
temperature sensor and not only the last registered one.

Change-Id: I201ffdeaf3ef18ab17ec84ad8c833b9fc074f4f1
Signed-off-by: Sebastien Sabatier <s-sabatier1@ti.com>

Conflicts:
	drivers/staging/thermal_framework/sensor/omap_temp_sensor.c
	drivers/staging/thermal_framework/sensor/pcb_temp_sensor.c
	drivers/staging/thermal_framework/thermal_framework.c
TI thermal framework: Remove unused index

This patch removes index information as it is never used.

Change-Id: Ic2bfb1677d8fec2cafa7b47626deb432232a0ef6
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>

Conflicts:
	include/linux/thermal_framework.h
TI thermal framework: improve thermal domain manipulations

This patch changes the thermal device data structures
to have a pointer to thermal domain. This way, once
an operation is required on a thermal device, there is
no need to iterate on thermal domains lists.

This patch also centralizes the operations to search and create
thermal domain data structures. Idea is to improve code readability,
having these operations done in one place only.

The patch does not change the code functionality so far.

Change-Id: I482d82feac854270c300273efbef0ef07cdec0b2
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>

Conflicts:
	drivers/staging/thermal_framework/thermal_framework.c
TI thermal framework: release allocated memory for thermal domains

Upon module exit, release all memory allocated on thermal domains.

Change-Id: I74640cc9a9b74dd9cd0a62253ca2444bd00ac31b
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
TI thermal framework: No need to return on end of void functions

Remove unnecessary return at the end of void functions

Change-Id: I6e53e8c1d7b7d33e867b836013a0fecb3f38a3c1
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
TI thermal framework: standardize thermal device ops

This patch changes the .process_temp callback of governor
type of thermal devices. The aim is to make all callbacks
standard. Now, all callbacks receive as first parameter
the affected thermal device.

Change-Id: I9857146e852a7f7d6ac502d044b7f104aa7eb466
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
TI thermal framework: introduce thermal_device_call helper macro

This patch adds a helper macro to call thermal device callback
functions. It will include some pointer checks before calling
the callback. In case the pointer checks fails, it will return
-EOPNOTSUPP, otherwise the callback return value.

The patch also improves the thermal framework core code by
using this helper macro.

Change-Id: I7db80271ec2509eb14670ae04532cff06cdf002c
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
TI thermal framework: remove unnecessary checks on thermal domain list

The domain can be fetch from each thermal device. Because of that,
there is no need to check for the emptiness of thermal domain list.

Change-Id: I786b82f6353711c376bcfcb24d0cca5eeb96a8d3
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
TI thermal framework: avoid free memory not allocated by the fw

Because the objects passed to the thermal framework are already
allocated, it does not make sense to free them inside the thermal
framework. This patch removes all memory release calls to memory
areas not owned by the thermal framework.

Change-Id: Ie49e99b7f6285cf435f5eab7ad26a61257ed86df
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
TI thermal framework: add helper macro to call ops on several thermal devices

This patch introduces a helper macro to execute same callback of several
thermal devices, linked by a list. It will attempt to reach all devices,
even if some of them are missing the callback or if the callback is
returning error values.

Because of the introduction of this helper, there is no need to have
a specific function to set the cooling level on a list of cooling devices.

Change-Id: I430a885400c17b81e98736c9a0ca1b675493b610
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
TI thermal framework: translate sensor helper functions into macro helpers

This patch removes helper functions operations that can be resolved by
the existing helper macros.

Change-Id: I11c8d2efc45c14bacffcddac944afddbc456e3e0
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>

Conflicts:
	drivers/staging/thermal_framework/governor/omap_die_governor.c
TI thermal framework: set temperature when domain is ready

Instead of reading domain temperature when a domain is ready,
this patch changes the flow to set the temperature. Now,
the temperature will be report to the governor when its domain
is ready with all needed pieces: sensor, governor, cooling agents.

Change-Id: I680bd6ff535dbe452d7b6cb9562594fa37826148
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
TI thermal framework: introduce thermal_lookup_temp function

This patch adds a helper function to get temperature of
a thermal domain, based on the domain name.

It will perform a domain name lookup and use its thermal
sensor device to fetch the temperature. If the domain
is not ready to report temperature, it will return an
error code.

Change-Id: I55d173c686e61650cb3a18ff4ae434711f2ebf37
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
TI thermal framework: introduce the thermal framework debug capability

This is a initial implementation of the TI thermal framework debug entries.

As of now, the structure is like this:
<debugfs_dir>
  |- thermal_debug
      |- domains
          |- <domain_name file 0>
          .
          .
          .
          |- <domain_name file n>
      |- devices
          |- device_name 0
          |    |- <device_name 0 own entries>
          .
          .
          .
          |- device_name n
          |    |- <device_name 0 own entries>

Each domain_name file contains a report of the its corresponding domain, e.g.:

 # cat /sys/kernel/debug/thermal_debug/cpu
Domain name: cpu
Temperature sensor:
     Name: omap_ondie_sensor
     Current temperature: 62400
Governor:
     Name: omap_ondie_governor
Cooling agents:
     Name: cpufreq_cooling

Each thermal device participating in a specific thermal domain
will have the opportunity to report their own specific debug
entries on this debug file for that domain. This is achieved
by means of the new thermal device ops callback .debug_report
which receives the target seq file.

Besides, each device registered in this framework will also
have the opportunity to create its own debug entries (directories
or files) under a directory with its name under the "devices"
directory. This is achieved by means of the .register_debug_entries
callback function.

Because we have now a debugfs dependency, this framework is
now initialized by means of the fs_initcall. This way
it will be ready before any registration of thermal devices.

Change-Id: I8b2d861a9263baa2d8af9c6a5edf07a8cfb88388
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
ARM:OMAP4:Thermal Framework:added TMP102 temperature sensor

This patch adds kernel driver for TMP102 temperature sensor
TMP102 is controled through I2C bus.

Change-Id: I4012a0ab53945ad8a240f395bb321cf09ebeb3ea
Signed-off-by: Eugen Mandrenko <ievgen.mandrenko@ti.com>

Conflicts:
	drivers/staging/thermal_framework/sensor/Kconfig
	drivers/staging/thermal_framework/sensor/Makefile