diff --git a/drivers/input/touchscreen/seco_restouch_filter.c b/drivers/input/touchscreen/seco_restouch_filter.c
index 979f187f93e65175b36b11239428f34810f7a7b3..bef0b21fdb35c9fa8a0dab04ca1b45d58435fe15 100644
--- a/drivers/input/touchscreen/seco_restouch_filter.c
+++ b/drivers/input/touchscreen/seco_restouch_filter.c
@@ -222,6 +222,22 @@ int seco_low_pass_filter(struct device *dev, struct seco_filter_data *fd, struct
 	return 0;
 }
 
+int seco_pen_up_debounce(struct device *dev, unsigned long start_ts, unsigned debounce_time)
+{
+	unsigned long now, delay;
+
+	now = jiffies_to_msecs(jiffies);
+	delay = ((start_ts + debounce_time) - now);
+
+	dev_dbg(dev, "start: %lu now: %lu debounce: %u delay: %lu",
+		start_ts, now, debounce_time, delay);
+
+	if (delay <= debounce_time)
+		return 1;
+
+	return 0;
+}
+
 MODULE_AUTHOR("SECO Northern Europe GmbH");
 MODULE_DESCRIPTION("Filter for noisy resistive touchscreens");
 MODULE_LICENSE("GPLv2");
diff --git a/include/linux/seco_restouch_filter.h b/include/linux/seco_restouch_filter.h
index a61046c56ba70cb607d3942573e35c56a8bd2974..db01696fc8791b5805bf3a229c82d4c8aa16a88e 100644
--- a/include/linux/seco_restouch_filter.h
+++ b/include/linux/seco_restouch_filter.h
@@ -58,11 +58,13 @@ struct seco_filter_data {
 	int median_sort_buffer[SECO_FILTER_MEDIAN_SAMPLES];
 	u8 low_pass_sample_count;
 	struct touch_data low_pass[3];
+	unsigned long pen_up_start;
 };
 
 void seco_init_filter(struct device *dev, struct seco_filter_data *fd);
 int seco_distance_filter(struct device *dev, int *samples, int sample_count, int *filtered_sample, u16 adc_channel);
 int seco_median_filter(struct device *dev, struct seco_filter_data *fd, struct touch_data *data);
 int seco_low_pass_filter(struct device *dev, struct seco_filter_data *fd, struct touch_data *data);
+int seco_pen_up_debounce(struct device *dev, unsigned long pen_up_delay, unsigned pen_up_debounce);
 
 #endif