1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-only */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * Tegra host1x Interrupt Management 4*4882a593Smuzhiyun * 5*4882a593Smuzhiyun * Copyright (c) 2010-2013, NVIDIA Corporation. 6*4882a593Smuzhiyun */ 7*4882a593Smuzhiyun 8*4882a593Smuzhiyun #ifndef __HOST1X_INTR_H 9*4882a593Smuzhiyun #define __HOST1X_INTR_H 10*4882a593Smuzhiyun 11*4882a593Smuzhiyun #include <linux/interrupt.h> 12*4882a593Smuzhiyun #include <linux/workqueue.h> 13*4882a593Smuzhiyun 14*4882a593Smuzhiyun struct host1x_syncpt; 15*4882a593Smuzhiyun struct host1x; 16*4882a593Smuzhiyun 17*4882a593Smuzhiyun enum host1x_intr_action { 18*4882a593Smuzhiyun /* 19*4882a593Smuzhiyun * Perform cleanup after a submit has completed. 20*4882a593Smuzhiyun * 'data' points to a channel 21*4882a593Smuzhiyun */ 22*4882a593Smuzhiyun HOST1X_INTR_ACTION_SUBMIT_COMPLETE = 0, 23*4882a593Smuzhiyun 24*4882a593Smuzhiyun /* 25*4882a593Smuzhiyun * Wake up a task. 26*4882a593Smuzhiyun * 'data' points to a wait_queue_head_t 27*4882a593Smuzhiyun */ 28*4882a593Smuzhiyun HOST1X_INTR_ACTION_WAKEUP, 29*4882a593Smuzhiyun 30*4882a593Smuzhiyun /* 31*4882a593Smuzhiyun * Wake up a interruptible task. 32*4882a593Smuzhiyun * 'data' points to a wait_queue_head_t 33*4882a593Smuzhiyun */ 34*4882a593Smuzhiyun HOST1X_INTR_ACTION_WAKEUP_INTERRUPTIBLE, 35*4882a593Smuzhiyun 36*4882a593Smuzhiyun HOST1X_INTR_ACTION_COUNT 37*4882a593Smuzhiyun }; 38*4882a593Smuzhiyun 39*4882a593Smuzhiyun struct host1x_syncpt_intr { 40*4882a593Smuzhiyun spinlock_t lock; 41*4882a593Smuzhiyun struct list_head wait_head; 42*4882a593Smuzhiyun char thresh_irq_name[12]; 43*4882a593Smuzhiyun struct work_struct work; 44*4882a593Smuzhiyun }; 45*4882a593Smuzhiyun 46*4882a593Smuzhiyun struct host1x_waitlist { 47*4882a593Smuzhiyun struct list_head list; 48*4882a593Smuzhiyun struct kref refcount; 49*4882a593Smuzhiyun u32 thresh; 50*4882a593Smuzhiyun enum host1x_intr_action action; 51*4882a593Smuzhiyun atomic_t state; 52*4882a593Smuzhiyun void *data; 53*4882a593Smuzhiyun int count; 54*4882a593Smuzhiyun }; 55*4882a593Smuzhiyun 56*4882a593Smuzhiyun /* 57*4882a593Smuzhiyun * Schedule an action to be taken when a sync point reaches the given threshold. 58*4882a593Smuzhiyun * 59*4882a593Smuzhiyun * @id the sync point 60*4882a593Smuzhiyun * @thresh the threshold 61*4882a593Smuzhiyun * @action the action to take 62*4882a593Smuzhiyun * @data a pointer to extra data depending on action, see above 63*4882a593Smuzhiyun * @waiter waiter structure - assumes ownership 64*4882a593Smuzhiyun * @ref must be passed if cancellation is possible, else NULL 65*4882a593Smuzhiyun * 66*4882a593Smuzhiyun * This is a non-blocking api. 67*4882a593Smuzhiyun */ 68*4882a593Smuzhiyun int host1x_intr_add_action(struct host1x *host, struct host1x_syncpt *syncpt, 69*4882a593Smuzhiyun u32 thresh, enum host1x_intr_action action, 70*4882a593Smuzhiyun void *data, struct host1x_waitlist *waiter, 71*4882a593Smuzhiyun void **ref); 72*4882a593Smuzhiyun 73*4882a593Smuzhiyun /* 74*4882a593Smuzhiyun * Unreference an action submitted to host1x_intr_add_action(). 75*4882a593Smuzhiyun * You must call this if you passed non-NULL as ref. 76*4882a593Smuzhiyun * @ref the ref returned from host1x_intr_add_action() 77*4882a593Smuzhiyun */ 78*4882a593Smuzhiyun void host1x_intr_put_ref(struct host1x *host, unsigned int id, void *ref); 79*4882a593Smuzhiyun 80*4882a593Smuzhiyun /* Initialize host1x sync point interrupt */ 81*4882a593Smuzhiyun int host1x_intr_init(struct host1x *host, unsigned int irq_sync); 82*4882a593Smuzhiyun 83*4882a593Smuzhiyun /* Deinitialize host1x sync point interrupt */ 84*4882a593Smuzhiyun void host1x_intr_deinit(struct host1x *host); 85*4882a593Smuzhiyun 86*4882a593Smuzhiyun /* Enable host1x sync point interrupt */ 87*4882a593Smuzhiyun void host1x_intr_start(struct host1x *host); 88*4882a593Smuzhiyun 89*4882a593Smuzhiyun /* Disable host1x sync point interrupt */ 90*4882a593Smuzhiyun void host1x_intr_stop(struct host1x *host); 91*4882a593Smuzhiyun 92*4882a593Smuzhiyun irqreturn_t host1x_syncpt_thresh_fn(void *dev_id); 93*4882a593Smuzhiyun #endif 94