^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Internal header to deal with irq_desc->status which will be renamed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * to irq_desc->settings.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) _IRQ_DEFAULT_INIT_FLAGS = IRQ_DEFAULT_INIT_FLAGS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) _IRQ_PER_CPU = IRQ_PER_CPU,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) _IRQ_LEVEL = IRQ_LEVEL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) _IRQ_NOPROBE = IRQ_NOPROBE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) _IRQ_NOREQUEST = IRQ_NOREQUEST,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) _IRQ_NOTHREAD = IRQ_NOTHREAD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) _IRQ_NOAUTOEN = IRQ_NOAUTOEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) _IRQ_MOVE_PCNTXT = IRQ_MOVE_PCNTXT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) _IRQ_NO_BALANCING = IRQ_NO_BALANCING,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) _IRQ_NESTED_THREAD = IRQ_NESTED_THREAD,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) _IRQ_PER_CPU_DEVID = IRQ_PER_CPU_DEVID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) _IRQ_IS_POLLED = IRQ_IS_POLLED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) _IRQ_DISABLE_UNLAZY = IRQ_DISABLE_UNLAZY,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) _IRQ_HIDDEN = IRQ_HIDDEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) _IRQ_RAW = IRQ_RAW,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) _IRQF_MODIFY_MASK = IRQF_MODIFY_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #define IRQ_PER_CPU GOT_YOU_MORON
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #define IRQ_NO_BALANCING GOT_YOU_MORON
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) #define IRQ_LEVEL GOT_YOU_MORON
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define IRQ_NOPROBE GOT_YOU_MORON
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define IRQ_NOREQUEST GOT_YOU_MORON
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) #define IRQ_NOTHREAD GOT_YOU_MORON
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #define IRQ_NOAUTOEN GOT_YOU_MORON
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) #define IRQ_NESTED_THREAD GOT_YOU_MORON
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #define IRQ_PER_CPU_DEVID GOT_YOU_MORON
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) #define IRQ_IS_POLLED GOT_YOU_MORON
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define IRQ_DISABLE_UNLAZY GOT_YOU_MORON
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #define IRQ_HIDDEN GOT_YOU_MORON
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #define IRQ_RAW GOT_YOU_MORON
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #undef IRQF_MODIFY_MASK
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define IRQF_MODIFY_MASK GOT_YOU_MORON
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) __irq_settings_clr_and_set(struct irq_desc *desc, u32 clr, u32 set, u32 mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) desc->status_use_accessors &= ~(clr & mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) desc->status_use_accessors |= (set & mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) irq_settings_clr_and_set(struct irq_desc *desc, u32 clr, u32 set)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) __irq_settings_clr_and_set(desc, clr, set, _IRQF_MODIFY_MASK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) static inline bool irq_settings_is_per_cpu(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) return desc->status_use_accessors & _IRQ_PER_CPU;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) static inline bool irq_settings_is_per_cpu_devid(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) return desc->status_use_accessors & _IRQ_PER_CPU_DEVID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) static inline void irq_settings_set_per_cpu(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) desc->status_use_accessors |= _IRQ_PER_CPU;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) static inline void irq_settings_set_no_balancing(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) desc->status_use_accessors |= _IRQ_NO_BALANCING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) static inline bool irq_settings_has_no_balance_set(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) return desc->status_use_accessors & _IRQ_NO_BALANCING;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) static inline u32 irq_settings_get_trigger_mask(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) return desc->status_use_accessors & IRQ_TYPE_SENSE_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) irq_settings_set_trigger_mask(struct irq_desc *desc, u32 mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) desc->status_use_accessors &= ~IRQ_TYPE_SENSE_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) desc->status_use_accessors |= mask & IRQ_TYPE_SENSE_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) static inline bool irq_settings_is_level(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) return desc->status_use_accessors & _IRQ_LEVEL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) static inline void irq_settings_clr_level(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) desc->status_use_accessors &= ~_IRQ_LEVEL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) static inline void irq_settings_set_level(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) desc->status_use_accessors |= _IRQ_LEVEL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) static inline bool irq_settings_can_request(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) return !(desc->status_use_accessors & _IRQ_NOREQUEST);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) static inline void irq_settings_clr_norequest(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) desc->status_use_accessors &= ~_IRQ_NOREQUEST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) static inline void irq_settings_set_norequest(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) desc->status_use_accessors |= _IRQ_NOREQUEST;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) static inline bool irq_settings_can_thread(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) return !(desc->status_use_accessors & _IRQ_NOTHREAD);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) static inline void irq_settings_clr_nothread(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) desc->status_use_accessors &= ~_IRQ_NOTHREAD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) static inline void irq_settings_set_nothread(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) desc->status_use_accessors |= _IRQ_NOTHREAD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) static inline bool irq_settings_can_probe(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) return !(desc->status_use_accessors & _IRQ_NOPROBE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) static inline void irq_settings_clr_noprobe(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) desc->status_use_accessors &= ~_IRQ_NOPROBE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) static inline void irq_settings_set_noprobe(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) desc->status_use_accessors |= _IRQ_NOPROBE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) static inline bool irq_settings_can_move_pcntxt(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) return desc->status_use_accessors & _IRQ_MOVE_PCNTXT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) static inline bool irq_settings_can_autoenable(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) return !(desc->status_use_accessors & _IRQ_NOAUTOEN);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) static inline bool irq_settings_is_nested_thread(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) return desc->status_use_accessors & _IRQ_NESTED_THREAD;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) static inline bool irq_settings_is_polled(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) return desc->status_use_accessors & _IRQ_IS_POLLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) static inline bool irq_settings_disable_unlazy(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) return desc->status_use_accessors & _IRQ_DISABLE_UNLAZY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) static inline void irq_settings_clr_disable_unlazy(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) desc->status_use_accessors &= ~_IRQ_DISABLE_UNLAZY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) static inline bool irq_settings_is_hidden(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) return desc->status_use_accessors & _IRQ_HIDDEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) static inline bool irq_settings_is_raw(struct irq_desc *desc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) if (IS_ENABLED(CONFIG_ARCH_WANTS_IRQ_RAW))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) return desc->status_use_accessors & _IRQ_RAW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) * Using IRQ_RAW on architectures that don't expect it is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) * likely to be wrong.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) WARN_ON_ONCE(1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) }