gpio: rcar: Fix runtime PM imbalance on error
[linux/fpc-iii.git] / drivers / misc / ibmasm / lowlevel.h
blob25f1ed07c3c53a71dfaa119b02fdfd6542f5611e
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3 * IBM ASM Service Processor Device Driver
5 * Copyright (C) IBM Corporation, 2004
7 * Author: Max Asböck <amax@us.ibm.com>
8 */
10 /* Condor service processor specific hardware definitions */
12 #ifndef __IBMASM_CONDOR_H__
13 #define __IBMASM_CONDOR_H__
15 #include <asm/io.h>
17 #define VENDORID_IBM 0x1014
18 #define DEVICEID_RSA 0x010F
20 #define GET_MFA_ADDR(x) (x & 0xFFFFFF00)
22 #define MAILBOX_FULL(x) (x & 0x00000001)
24 #define NO_MFAS_AVAILABLE 0xFFFFFFFF
27 #define INBOUND_QUEUE_PORT 0x40 /* contains address of next free MFA */
28 #define OUTBOUND_QUEUE_PORT 0x44 /* contains address of posted MFA */
30 #define SP_INTR_MASK 0x00000008
31 #define UART_INTR_MASK 0x00000010
33 #define INTR_STATUS_REGISTER 0x13A0
34 #define INTR_CONTROL_REGISTER 0x13A4
36 #define SCOUT_COM_A_BASE 0x0000
37 #define SCOUT_COM_B_BASE 0x0100
38 #define SCOUT_COM_C_BASE 0x0200
39 #define SCOUT_COM_D_BASE 0x0300
41 static inline int sp_interrupt_pending(void __iomem *base_address)
43 return SP_INTR_MASK & readl(base_address + INTR_STATUS_REGISTER);
46 static inline int uart_interrupt_pending(void __iomem *base_address)
48 return UART_INTR_MASK & readl(base_address + INTR_STATUS_REGISTER);
51 static inline void ibmasm_enable_interrupts(void __iomem *base_address, int mask)
53 void __iomem *ctrl_reg = base_address + INTR_CONTROL_REGISTER;
54 writel( readl(ctrl_reg) & ~mask, ctrl_reg);
57 static inline void ibmasm_disable_interrupts(void __iomem *base_address, int mask)
59 void __iomem *ctrl_reg = base_address + INTR_CONTROL_REGISTER;
60 writel( readl(ctrl_reg) | mask, ctrl_reg);
63 static inline void enable_sp_interrupts(void __iomem *base_address)
65 ibmasm_enable_interrupts(base_address, SP_INTR_MASK);
68 static inline void disable_sp_interrupts(void __iomem *base_address)
70 ibmasm_disable_interrupts(base_address, SP_INTR_MASK);
73 static inline void enable_uart_interrupts(void __iomem *base_address)
75 ibmasm_enable_interrupts(base_address, UART_INTR_MASK);
78 static inline void disable_uart_interrupts(void __iomem *base_address)
80 ibmasm_disable_interrupts(base_address, UART_INTR_MASK);
83 #define valid_mfa(mfa) ( (mfa) != NO_MFAS_AVAILABLE )
85 static inline u32 get_mfa_outbound(void __iomem *base_address)
87 int retry;
88 u32 mfa;
90 for (retry=0; retry<=10; retry++) {
91 mfa = readl(base_address + OUTBOUND_QUEUE_PORT);
92 if (valid_mfa(mfa))
93 break;
95 return mfa;
98 static inline void set_mfa_outbound(void __iomem *base_address, u32 mfa)
100 writel(mfa, base_address + OUTBOUND_QUEUE_PORT);
103 static inline u32 get_mfa_inbound(void __iomem *base_address)
105 u32 mfa = readl(base_address + INBOUND_QUEUE_PORT);
107 if (MAILBOX_FULL(mfa))
108 return 0;
110 return mfa;
113 static inline void set_mfa_inbound(void __iomem *base_address, u32 mfa)
115 writel(mfa, base_address + INBOUND_QUEUE_PORT);
118 static inline struct i2o_message *get_i2o_message(void __iomem *base_address, u32 mfa)
120 return (struct i2o_message *)(GET_MFA_ADDR(mfa) + base_address);
123 #endif /* __IBMASM_CONDOR_H__ */