+#ifdef CONFIG_ARCH_ROCKCHIP
+static void cpufreq_interactive_input_event(struct input_handle *handle,
+ unsigned int type,
+ unsigned int code,
+ int value)
+{
+ u64 now, endtime;
+ int i;
+ int anyboost = 0;
+ unsigned long flags[2];
+ struct cpufreq_interactive_cpuinfo *pcpu;
+ struct cpufreq_interactive_tunables *tunables;
+
+ if ((type != EV_ABS) && (type != EV_KEY))
+ return;
+
+ trace_cpufreq_interactive_boost("touch");
+ spin_lock_irqsave(&speedchange_cpumask_lock, flags[0]);
+
+ now = ktime_to_us(ktime_get());
+ for_each_online_cpu(i) {
+ pcpu = &per_cpu(cpuinfo, i);
+ if (have_governor_per_policy())
+ tunables = pcpu->policy->governor_data;
+ else
+ tunables = common_tunables;
+ if (!tunables)
+ continue;
+
+ endtime = now + tunables->touchboostpulse_duration_val;
+ if (endtime < (tunables->touchboostpulse_endtime +
+ 10 * USEC_PER_MSEC))
+ continue;
+ tunables->touchboostpulse_endtime = endtime;
+
+ spin_lock_irqsave(&pcpu->target_freq_lock, flags[1]);
+ if (pcpu->target_freq < tunables->touchboost_freq) {
+ pcpu->target_freq = tunables->touchboost_freq;
+ cpumask_set_cpu(i, &speedchange_cpumask);
+ pcpu->loc_hispeed_val_time =
+ ktime_to_us(ktime_get());
+ anyboost = 1;
+ }
+
+ pcpu->floor_freq = tunables->touchboost_freq;
+ pcpu->loc_floor_val_time = ktime_to_us(ktime_get());
+
+ spin_unlock_irqrestore(&pcpu->target_freq_lock, flags[1]);
+ }
+
+ spin_unlock_irqrestore(&speedchange_cpumask_lock, flags[0]);
+
+ if (anyboost)
+ wake_up_process(speedchange_task);
+}
+
+static int cpufreq_interactive_input_connect(struct input_handler *handler,
+ struct input_dev *dev,
+ const struct input_device_id *id)
+{
+ struct input_handle *handle;
+ int error;
+
+ handle = kzalloc(sizeof(*handle), GFP_KERNEL);
+ if (!handle)
+ return -ENOMEM;
+
+ handle->dev = dev;
+ handle->handler = handler;
+ handle->name = "cpufreq";
+
+ error = input_register_handle(handle);
+ if (error)
+ goto err2;
+
+ error = input_open_device(handle);
+ if (error)
+ goto err1;
+
+ return 0;
+err1:
+ input_unregister_handle(handle);
+err2:
+ kfree(handle);
+ return error;
+}
+
+static void cpufreq_interactive_input_disconnect(struct input_handle *handle)
+{
+ input_close_device(handle);
+ input_unregister_handle(handle);
+ kfree(handle);
+}
+
+static const struct input_device_id cpufreq_interactive_ids[] = {
+ {
+ .flags = INPUT_DEVICE_ID_MATCH_EVBIT |
+ INPUT_DEVICE_ID_MATCH_ABSBIT,
+ .evbit = { BIT_MASK(EV_ABS) },
+ .absbit = { [BIT_WORD(ABS_MT_POSITION_X)] =
+ BIT_MASK(ABS_MT_POSITION_X) |
+ BIT_MASK(ABS_MT_POSITION_Y) },
+ },
+ {
+ .flags = INPUT_DEVICE_ID_MATCH_KEYBIT |
+ INPUT_DEVICE_ID_MATCH_ABSBIT,
+ .keybit = { [BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH) },
+ .absbit = { [BIT_WORD(ABS_X)] =
+ BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) },
+ },
+ {
+ .flags = INPUT_DEVICE_ID_MATCH_EVBIT,
+ .evbit = { BIT_MASK(EV_KEY) },
+ },
+ { },
+};
+
+static struct input_handler cpufreq_interactive_input_handler = {
+ .event = cpufreq_interactive_input_event,
+ .connect = cpufreq_interactive_input_connect,
+ .disconnect = cpufreq_interactive_input_disconnect,
+ .name = "cpufreq_interactive",
+ .id_table = cpufreq_interactive_ids,
+};
+
+static void rockchip_cpufreq_policy_init(struct cpufreq_policy *policy)
+{
+ struct cpufreq_interactive_tunables *tunables = policy->governor_data;
+
+ tunables->min_sample_time = 40 * USEC_PER_MSEC;
+ tunables->boostpulse_duration_val = 40 * USEC_PER_MSEC;
+ if (policy->cpu == 0) {
+ tunables->hispeed_freq = 1008000;
+ tunables->touchboostpulse_duration_val = 500 * USEC_PER_MSEC;
+ tunables->touchboost_freq = 1200000;
+ } else {
+ tunables->hispeed_freq = 816000;
+ }
+}
+#endif
+