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>
TI thermal framework: omap die governor: simplify the cooling device search

Inside each zone entering function, there is a search for cooling devices.
This search is not really needed as the registered devices are already
supposed to be part of that thermal zone. The checks for the missing pointers
are done by the caller macro helper.

Change-Id: I4a227933f3b7c723675007c5b7dc7d3ce1ec1ac6
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
TI thermal framework: omap die governor: introduce enter zone helper function

This code changes the OMAP DIE governor to use a helper function to enter
a thermal zone, instead of using a function for each zone. Idea is to
reduce the amount of duplicated code.

This code also introduces a data structure to represent a thermal zone.
The enter zone helper function is based on this data structure.

The logic alert zone logic computation, which depends on if we
are rising or lowering in temperature, is now moved to the zone
matching function. This place is much more convenient, then inside
the enter zone helper.

Change-Id: Ibcb9228556c793104d2ec6f8df092a1c7ea99966
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
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: register cpufreq cooling device in module init

the CPUfreq cooling device is being registered in the wrong place.
We don't want to register a cooling device every time a CPU is
initialized. This is fundamentally wrong. Thus, this patch moves
the cooling device registration to module init instead.

Change-Id: I7886eb14c68e1bf696ef77e86326a62ea05b8c8b
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
TI thermal framework: fix initialization sequence and introduce "pcb" domain

This patch creates a new thermal domain, named "pcb". Also it teaches
the omap die governor how to be aware of a separated domain.

The pcb sensor will not be part of the "cpu" domain, but instead, it
is now part of the "pcb" domain. This will change the system so that,
instead of wrongly attempt to register two sensors on the same domain,
they will be registered on two different domains, but the governor
is aware of both domains.

By doing so, it is not necessary to keep track of sensors being
registered on the same domain, and deciding by looking up the
sensor names.

Now that governors can fetch the temperature from a different domain,
there is no need to keep feeding the framework with temperature reports
by means of running workqueues. This workaround was necessary
because there was an initialization issue while registering several
sensors in the same domain.

Now, because there are multiple domains, there is no need to keep
track on sensors being registered and their reports. For now,
these workqueues are not needed.

Change-Id: I6e2764fc1d49fbe97953c2a9a5192f8585c91aab
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>
OMAP4: PM: Add errata id for handling Errata i736

The errata handler is present in kernel 3.0. The patch adds the
Errata id for simplification of search in the kernel sources

Change-Id: I346ac0e1262fdb3fcfd1e38879619baa02ebf4cb
Signed-off-by: Eugen Mandrenko <ievgen.mandrenko@ti.com>
ARM: OMAP4: cpuidle: prevent CPU1 from locking CPU0 in idle entry

We can have a lockup scenario when two cpu are spin waiting for each other:

CPU0:
	omap4_enter_idle()
		|---omap4_enter_idle_primary()
			|---------while (omap4_idle_requested_cx[1])
					cpu_relax();

CPU1:
	omap4_enter_idle()
		|----
		while ((omap4_idle_ready_count == 0) && omap4_all_cpus_idle()) {
			spin_unlock(&omap4_idle_lock);
			cpu_relax();
			spin_lock(&omap4_idle_lock);
		}

Depend on idle ready count to let CPU0 to progress forward.

Change-Id: Ida6b60f618e8078701fcad8d976c3f1620cc71e6
Acked-by: Santosh Shilimkar <santosh.shilimkar@ti.com>
Signed-off-by: Yuan Jiangli <jlyuan@motorola.com>
OMAPDSS: Increase PLL1_CLK1 frequency for correct work with large panels

The current design does not work correctly in case when we are using large
panels with 1080p resolution as default. It happens because current fclk rate
is less then required one. This patch corrects that issue by increasing
PLL1_CLK1 frequency. Also it removes excess initialization of the DISPC fclk
src from HDMI driver.

Change-Id: I24cdbfc417034a9275b1f305a8754bbae306da48
Signed-off-by: Victor Kleinik <x0150886@ti.com>
Merge remote-tracking branch 'remotes/omap_zoom/p-android-omap-3.0' into acclaim
Add debug info.