Added intellidemand governor by faux123.

Squashed commit of the following:

commit f2a0e90818c30288a501cd33496d9c3c03006c22
Author: Andreas Pohl <apohl79@gmail.com>
Date:   Thu Feb 14 23:00:39 2013 +0100

    Added intellidemand

commit 822ebbf3b9f617c4f3e7284c210fa7377277e0ea
Author: Anji Jonnala <anjir@codeaurora.org>
Date:   Sun Dec 30 11:54:45 2012 -0800

    msm: cpufreq: Implement suspend/resume for cpufreq driver

    Cpufreq suspend variable get's updated in kernel pm notifier
    callback which gets called in process context. This will create
    window where cpufreq governor may try to change the frequency
    before suspend variable is updated while resume.

    Define suspend/resume for cpufreq driver to update suspend variable
    in atomic context.

    Don't update the policy->cur upon cpufreq driver failure.

    CRs-fixed: 423791
    Change-Id: Id78705f5c3b8bf801c6253e9362299280903769f
    Signed-off-by: Anji Jonnala <anjir@codeaurora.org>
    Signed-off-by: Andreas Pohl <apohl79@gmail.com>

commit b8bde7548c635179eb429bdf6309dcaf5667c8ff
Author: faux123 <reioux@gmail.com>
Date:   Sun Dec 30 11:52:52 2012 -0800

    intellidemand: Don't update the policy->cur upon cpufreq driver failure

    Signed-off-by: faux123 <reioux@gmail.com>
    Signed-off-by: Andreas Pohl <apohl79@gmail.com>

commit 2cc64739cb075a2e0355611950818c2c6b7608b8
Author: faux123 <reioux@gmail.com>
Date:   Fri Dec 28 20:35:46 2012 -0800

    intellidemand: remove unused min performance lock defines

    Signed-off-by: faux123 <reioux@gmail.com>
    Signed-off-by: Andreas Pohl <apohl79@gmail.com>

commit e6af17ca4df42a8a673217db61068d15aa5130fb
Author: faux123 <reioux@gmail.com>
Date:   Fri Dec 28 20:26:35 2012 -0800

    intellidemand: remove eco mode option (replaced by intelli_plug)

    Signed-off-by: faux123 <reioux@gmail.com>
    Signed-off-by: Andreas Pohl <apohl79@gmail.com>

commit 676bd843b9fc480f59e960402747186948c1f0a8
Author: faux123 <reioux@gmail.com>
Date:   Fri Dec 28 20:16:30 2012 -0800

    intellidemand: remove cpu cores autoplug capability (replaced by intelli_plug)

    Signed-off-by: faux123 <reioux@gmail.com>
    Signed-off-by: Andreas Pohl <apohl79@gmail.com>

commit 9f31a9ac92d69f4ef4236624de70db27e224b43e
Author: faux123 <reioux@gmail.com>
Date:   Wed Dec 19 22:56:46 2012 -0800

    intellidemand: add default values for dbs sync and optimal tuneables

    Signed-off-by: faux123 <reioux@gmail.com>
    Signed-off-by: Andreas Pohl <apohl79@gmail.com>

commit f5482d15afd68921cb4bed74c5738887b8fe75f2
Author: Paul Reioux <reioux@gmail.com>
Date:   Wed Dec 19 20:43:57 2012 -0500

    intellidemand: give intellidemand's cpu_dbs_info its own name

    Signed-off-by: Paul Reioux <reioux@gmail.com>
    Signed-off-by: Andreas Pohl <apohl79@gmail.com>

commit d97724b503b3bde4d3cd5ffb7f1a58ad3f86898b
Author: faux123 <reioux@gmail.com>
Date:   Tue Dec 18 23:07:55 2012 -0800

    intellidemand: Add support to consider other cpu load when scaling frequencies

    Currently only current cpu load is considered when frequency scaling.
    As a side effect of this when scheduler migrates a thread to a slower
    core, the execution time increases unexpectedly.

    The new algorithm not only considers current cpu load for frequency
    scaling, but also takes into account load of other online cpus. The
    treshold for this can be controlled using up_threshold_any_cpu_load.
    When the up_threshold_any_cpu_load is crossed in any cpu then the
    current cpu is set to sync_freq.

    Also, when more than one cpu is online a two step ramp-up mechanism
    is used. When the up_threshold_multi_core is crossed the cpu is ramped
    up to optimal_freq which is less than policy->max and set to a power
    friendly value.

    Change-Id: I64bed1b142cde1f239e73aa1f78981c78aaf59ce
    Signed-off-by: Narayanan Gopalakrishnan <nargop@codeaurora.org>

    intellidemand: Fix kernel warning in cpufreq_governor_dbs

    GOV_STOP event destroys the timer_mutex and is not initialized back
    upon GOV_START event.
    The Kernel complains at mutex_lock(during GOV_LIMITS event) after
    mutex_destroy.

    [<c0014918>] (unwind_backtrace+0x0/0x11c)
    [<c007c004>] (warn_slowpath_common+0x4c/0x64)
    [<c007c034>] (warn_slowpath_null+0x18/0x1c)
    [<c079eef8>] (__mutex_lock_slowpath+0x130/0x3c4)
    [<c079f1ac>] (mutex_lock+0x20/0x3c) from [<c0540900>]
    [<c0540900>] (cpufreq_governor_dbs+0x3c8/0x468)
    [<c053d500>] (__cpufreq_governor+0x90/0xe0)
    [<c053d774>] (__cpufreq_set_policy+0x224/0x258)
    [<c053da58>] (cpufreq_add_dev_interface+0x2b0/0x308)
    [<c053e784>] (cpufreq_add_dev+0x500/0x56c)
    [<c079247c>] (cpufreq_cpu_callback+0x88/0x9c)
    [<c07a2ca8>] (notifier_call_chain+0x38/0x68)
    [<c007ded0>] (__cpu_notify+0x28/0x40)
    [<c0790024>] (_cpu_up+0xe4/0x118)
    [<c0790024>] (cpu_up+0x64/0x80)
    [<c0765840>] (store_online+0x48/0x78)
    [<c038d0c8>] (dev_attr_store+0x18/0x24)
    [<c017be40>] (sysfs_write_file+0x108/0x13c)
    [<c012cdfc>] (vfs_write+0xb0/0x128)
    [<c012d034>](sys_write+0x38/0x64)

    Change-Id: Ie2a796b17209243de731ccf2ab04b7f9e7048df8
    Signed-off-by: Anji Jonnala <anjir@codeaurora.org>

    Adapted for Intellidemand from CAF reference

    Signed-off-by: faux123 <reioux@gmail.com>
    Signed-off-by: Andreas Pohl <apohl79@gmail.com>

commit be74e21bd8e9046b6d76f46915b533b11db5cfbf
Author: faux123 <reioux@gmail.com>
Date:   Tue Dec 18 22:43:52 2012 -0800

    cpufreq: Avoid using smp_processor_id() in preemptible context

    Even though this work item runs on only one cpu at a time (due to
    queue_work_on()) it is possible for the work item to be preempted
    and so use of smp_processor_id() is illegal.

    BUG: using smp_processor_id() in preemptible [00000000]
    code: kworker/3:1/4162 caller is dbs_refresh_callback+0xc/0x188
    [<c00151b0>] (unwind_backtrace+0x0/0x120) from [<c0279058>]
    (debug_smp_processor_id+0xbc/0xf0)
    [<c0279058>] (debug_smp_processor_id+0xbc/0xf0) from [<c0454b54>]
    (dbs_refresh_callback+0xc/0x188)
    [<c0454b54>] (dbs_refresh_callback+0xc/0x188) from [<c0087290>]
    (process_one_work+0x354/0x648)
    [<c0087290>] (process_one_work+0x354/0x648) from [<c0089754>]
    (worker_thread+0x1a8/0x2a8)
    [<c0089754>] (worker_thread+0x1a8/0x2a8) from [<c008e480>]
    (kthread+0x90/0xa0)
    [<c008e480>] (kthread+0x90/0xa0) from [<c000f438>]
    (kernel_thread_exit+0x0/0x8)

    The intent of the code is to determine which CPU this work item
    is running on, which we can easily do by passing that information
    in a wrapper struct around the work struct. Do this so we avoid
    this problem.

    Change-Id: I05ca0ff2b3cbaa239930463ea0760e3e9d75145f
    Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
    adapted for Intellidemand from CAF reference

    Signed-off-by: faux123 <reioux@gmail.com>
    Signed-off-by: Andreas Pohl <apohl79@gmail.com>

commit 3c2b69b674efea84b57e4ebcc5f6b04c35ecf38f
Author: Stephen Boyd <sboyd@codeaurora.org>
Date:   Mon Oct 29 12:45:01 2012 -0700

    cpufreq: interactive: Fix blocked task warnings

    Running a kernel that never enables the interactive cpufreq
    will eventually hit the following warning:

    INFO: task kinteractiveup:112 blocked for more than 120 seconds.
    kinteractiveup  D c07ae3a4  7072   112      2 0x00000000
    [<c07ae3a4>] (__schedule+0x4e4/0x5c4) from [<c00a1b8c>] (kthread+0x70/0x94)
    [<c00a1b8c>] (kthread+0x70/0x94) from [<c000f368>]
    (kernel_thread_exit+0x0/0x8)

    due to the fact that the kthread is never woken up after being
    forked. Kick the thread to its idle loop so that it can
    schedule() and move out of the D state.

    Change-Id: Idc490e707d9a14dd143306a8ee1c2241320d29d5
    Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
    Signed-off-by: Andreas Pohl <apohl79@gmail.com>

commit 3cd956f6e6a60d7af909c78a5c472a92d62729dc
Author: Narayanan Gopalakrishnan <nargop@codeaurora.org>
Date:   Mon Aug 20 10:52:13 2012 -0700

    cpufreq: fix interactive bug during hotplug

    When a new cpu is added and if does not enter idle
    for long, the interactive timer is not started and hence
    the cpu remains at lowest frequecny, despite the system
    load. This impacts mainly benchmarks. Starting a timer
    at governor start to handle low frequency.

    Change-Id: I8ac9705b9f166a95715c985efacd2ae8ef387cb7
    Signed-off-by: Narayanan Gopalakrishnan <nargop@codeaurora.org>
    Signed-off-by: Andreas Pohl <apohl79@gmail.com>

commit f1e0ae73d0d89de8cb8efa4c2138eca7211890b6
Author: Anji Jonnala <anjir@codeaurora.org>
Date:   Wed Nov 14 13:34:54 2012 +0530

    cpufreq: ondemand: Fix kernel warning in cpufreq_governor_dbs

    GOV_STOP event destroys the timer_mutex and is not initialized back
    upon GOV_START event.
    The Kernel complains at mutex_lock(during GOV_LIMITS event) after
    mutex_destroy.

    [<c0014918>] (unwind_backtrace+0x0/0x11c)
    [<c007c004>] (warn_slowpath_common+0x4c/0x64)
    [<c007c034>] (warn_slowpath_null+0x18/0x1c)
    [<c079eef8>] (__mutex_lock_slowpath+0x130/0x3c4)
    [<c079f1ac>] (mutex_lock+0x20/0x3c) from [<c0540900>]
    [<c0540900>] (cpufreq_governor_dbs+0x3c8/0x468)
    [<c053d500>] (__cpufreq_governor+0x90/0xe0)
    [<c053d774>] (__cpufreq_set_policy+0x224/0x258)
    [<c053da58>] (cpufreq_add_dev_interface+0x2b0/0x308)
    [<c053e784>] (cpufreq_add_dev+0x500/0x56c)
    [<c079247c>] (cpufreq_cpu_callback+0x88/0x9c)
    [<c07a2ca8>] (notifier_call_chain+0x38/0x68)
    [<c007ded0>] (__cpu_notify+0x28/0x40)
    [<c0790024>] (_cpu_up+0xe4/0x118)
    [<c0790024>] (cpu_up+0x64/0x80)
    [<c0765840>] (store_online+0x48/0x78)
    [<c038d0c8>] (dev_attr_store+0x18/0x24)
    [<c017be40>] (sysfs_write_file+0x108/0x13c)
    [<c012cdfc>] (vfs_write+0xb0/0x128)
    [<c012d034>](sys_write+0x38/0x64)

    Change-Id: Ie2a796b17209243de731ccf2ab04b7f9e7048df8
    Signed-off-by: Anji Jonnala <anjir@codeaurora.org>
    Signed-off-by: Andreas Pohl <apohl79@gmail.com>

commit 2ca22d01e43b2ba17aabc51047a664ee0c9e0577
Author: Stephen Boyd <sboyd@codeaurora.org>
Date:   Wed Oct 31 17:43:08 2012 -0700

    cpufreq: Avoid using smp_processor_id() in preemptible context

    Even though this work item runs on only one cpu at a time (due to
    queue_work_on()) it is possible for the work item to be preempted
    and so use of smp_processor_id() is illegal.

    BUG: using smp_processor_id() in preemptible [00000000]
    code: kworker/3:1/4162 caller is dbs_refresh_callback+0xc/0x188
    [<c00151b0>] (unwind_backtrace+0x0/0x120) from [<c0279058>]
    (debug_smp_processor_id+0xbc/0xf0)
    [<c0279058>] (debug_smp_processor_id+0xbc/0xf0) from [<c0454b54>]
    (dbs_refresh_callback+0xc/0x188)
    [<c0454b54>] (dbs_refresh_callback+0xc/0x188) from [<c0087290>]
    (process_one_work+0x354/0x648)
    [<c0087290>] (process_one_work+0x354/0x648) from [<c0089754>]
    (worker_thread+0x1a8/0x2a8)
    [<c0089754>] (worker_thread+0x1a8/0x2a8) from [<c008e480>]
    (kthread+0x90/0xa0)
    [<c008e480>] (kthread+0x90/0xa0) from [<c000f438>]
    (kernel_thread_exit+0x0/0x8)

    The intent of the code is to determine which CPU this work item
    is running on, which we can easily do by passing that information
    in a wrapper struct around the work struct. Do this so we avoid
    this problem.

    Change-Id: I05ca0ff2b3cbaa239930463ea0760e3e9d75145f
    Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
    Signed-off-by: Andreas Pohl <apohl79@gmail.com>

commit e8aadfcd44d9d745722a71f4f2b9d753c0375798
Author: faux123 <reioux@gmail.com>
Date:   Sun Dec 16 13:11:51 2012 -0800

    Intellidemand: adjust the nr_run hysteresis for better UI response

    Signed-off-by: faux123 <reioux@gmail.com>
    Signed-off-by: Andreas Pohl <apohl79@gmail.com>

commit cd29fd5c0bbe3d2087feb45690e35fc0870f7e1d
Author: faux123 <reioux@gmail.com>
Date:   Sat Dec 8 00:03:05 2012 -0800

    intellidemand: tweak for not using min performance lock

    Signed-off-by: faux123 <reioux@gmail.com>
    Signed-off-by: Andreas Pohl <apohl79@gmail.com>

commit db5034475e3a5c1a0e70f61427c79d013085369a
Author: faux123 <reioux@gmail.com>
Date:   Wed Dec 5 19:59:42 2012 -0600

    intellidemand: add eco mode (dual core operations) bump version to 4.1

    Signed-off-by: faux123 <reioux@gmail.com>
    Signed-off-by: Andreas Pohl <apohl79@gmail.com>

commit b933e9d110d6303bbbbfada2ede4ac8dbdacaefa
Author: faux123 <reioux@gmail.com>
Date:   Wed Dec 5 06:19:54 2012 -0800

    intellidemand: increase boost duration to 2.5 seconds from 1.5

    Signed-off-by: faux123 <reioux@gmail.com>
    Signed-off-by: Andreas Pohl <apohl79@gmail.com>

commit e7bc455c99a179699a966fab2aa8898d48c22ecc
Author: faux123 <reioux@gmail.com>
Date:   Sun Dec 2 10:47:31 2012 -0800

    Intellidemand: put cores 1~3 to sleep while screen is off

    Signed-off-by: faux123 <reioux@gmail.com>
    Signed-off-by: Andreas Pohl <apohl79@gmail.com>

commit f81c72c6c3ab2bdf0dbf2aa31210d2e3cc442e1c
Author: faux123 <reioux@gmail.com>
Date:   Sun Nov 25 08:12:27 2012 -0800

    intellidemand: code derps clean up!

    Signed-off-by: faux123 <reioux@gmail.com>
    Signed-off-by: Andreas Pohl <apohl79@gmail.com>

commit 882240a57deab9550758bc8b2c08cf3a27302bee
Author: faux123 <reioux@gmail.com>
Date:   Sat Nov 24 14:56:18 2012 -0800

    Intellidemand: update for quadcore operations. bump version to 4.0

    Signed-off-by: faux123 <reioux@gmail.com>
    Signed-off-by: Andreas Pohl <apohl79@gmail.com>

commit f6a0954481c96f0d281b6633c50f4c3b34d0c51f
Author: faux123 <reioux@gmail.com>
Date:   Sat Nov 24 14:22:32 2012 -0800

    intellidemand: add minimum cpu performance lock

    a minimum cpu frequency performance lock is add to ensure smooth
    operations when only 1 core is active

    Signed-off-by: faux123 <reioux@gmail.com>
    Signed-off-by: Andreas Pohl <apohl79@gmail.com>

commit 8022068c2a9c60c70f93f0009e30077aaec0cf57
Author: faux123 <reioux@gmail.com>
Date:   Sat Nov 24 14:20:10 2012 -0800

    intellidemand: add a run queue persistence to determine browsing state

    persistence will allow for better browsing state detection rather than just
    purely based on run queue depth alone

    Signed-off-by: faux123 <reioux@gmail.com>
    Signed-off-by: Andreas Pohl <apohl79@gmail.com>

commit 392479210b36a388ab5b78724f618f680c1c7787
Author: faux123 <reioux@gmail.com>
Date:   Sat Nov 24 14:17:12 2012 -0800

    intellidemand: add bug fixes

     - Fix crash input event handler on governor switch
     - Fix panic when setting sampling rate

    Signed-off-by: faux123 <reioux@gmail.com>
    Signed-off-by: Andreas Pohl <apohl79@gmail.com>

commit 96fd79bd9510dcbb7c7e5e86e9d0aa16f9dcb72f
Author: faux123 <reioux@gmail.com>
Date:   Sat Nov 24 14:15:27 2012 -0800

    intellidemand: Add boost pulse capability

    Boost pulse increases UI performance by increasing CPU freq and
    reduce sampling time.

    forward ported for Linux 3.4 for use on Mako
    Signed-off-by: faux123 <reioux@gmail.com>

    Signed-off-by: Andreas Pohl <apohl79@gmail.com>

commit 4d78f680b6d7cdc48b203bea63925d28828ad978
Author: faux123 <reioux@gmail.com>
Date:   Sat Nov 24 14:04:27 2012 -0800

    cpufreq/cpufreq_intellidemand: intellidemand cpufreq governor (version 4.0)

    Intellidemand is inspired by ondemand governor. Its main features are:

     - auto cpu hotplugging based on runnable thread average calculations
     - detection of browsing mode (long screen on activities with moderate run
       queue depth =< 45 )
     - limit max frequencies when in browsing mode to conserve battery for long
       duration tasks

    Browsing State Determination:
     1- Browsing state is enabled as power-on default. Browsing state is disabled
        when run queue depth is > 45 (very high instantaneous spikes)

    Browsing State Limit Max Freq Logic (sliding window algorithm):
     1- While Screen is ON > 3 min, and average load of the CPU is < 35%, then
        CPU Max frequencies will remain power-on default
     2- While Screen is On, if average CPU load > 35%, both CPUs max frequencies
        will be limited to a lower user configurable max value
     3- While Screen is On, After both CPUs' Max is limited to lowered max, when
        the average CPU load has dropped down to less than < 25%, then both CPUs
        Max freq will be restored to back to power-on default

    Runnable Thread Auto-hotplug (fast hotplug / slow unplug algorithm):
     1- When average number of running thread is < threshold, 2nd cpu will be
        unplugged.
     2- When > threshold, 2nd cpu will be hotplugged.
     3- The logic applies a fast hotplug and slow unplug algorithm so 2nd core
        will stay enabled longer to help deal with performance spikes

    changes from Ver 2.0 -> Ver 3.0:
      - remove GPU Busy dependency for browsing state detection (this will make
        the governor more portable to other platforms without specific GPU
        architecture knowledge)

    dependencies:
      -- Qualcomm's run queue average logic (SOC independent logic)
      -- TI's runnable thread average logic (SOC independent logic)

    forward ported to Linux 3.4 for use on Mako

    Signed-off-by: faux123 <reioux@gmail.com>
    Signed-off-by: Andreas Pohl <apohl79@gmail.com>