lowlevel.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*
  2. * IBM ASM Service Processor Device Driver
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  17. *
  18. * Copyright (C) IBM Corporation, 2004
  19. *
  20. * Author: Max Asböck <amax@us.ibm.com>
  21. *
  22. */
  23. /* Condor service processor specific hardware definitions */
  24. #ifndef __IBMASM_CONDOR_H__
  25. #define __IBMASM_CONDOR_H__
  26. #include <asm/io.h>
  27. #define VENDORID_IBM 0x1014
  28. #define DEVICEID_RSA 0x010F
  29. #define GET_MFA_ADDR(x) (x & 0xFFFFFF00)
  30. #define MAILBOX_FULL(x) (x & 0x00000001)
  31. #define NO_MFAS_AVAILABLE 0xFFFFFFFF
  32. #define INBOUND_QUEUE_PORT 0x40 /* contains address of next free MFA */
  33. #define OUTBOUND_QUEUE_PORT 0x44 /* contains address of posted MFA */
  34. #define SP_INTR_MASK 0x00000008
  35. #define UART_INTR_MASK 0x00000010
  36. #define INTR_STATUS_REGISTER 0x13A0
  37. #define INTR_CONTROL_REGISTER 0x13A4
  38. #define SCOUT_COM_A_BASE 0x0000
  39. #define SCOUT_COM_B_BASE 0x0100
  40. #define SCOUT_COM_C_BASE 0x0200
  41. #define SCOUT_COM_D_BASE 0x0300
  42. static inline int sp_interrupt_pending(void __iomem *base_address)
  43. {
  44. return SP_INTR_MASK & readl(base_address + INTR_STATUS_REGISTER);
  45. }
  46. static inline int uart_interrupt_pending(void __iomem *base_address)
  47. {
  48. return UART_INTR_MASK & readl(base_address + INTR_STATUS_REGISTER);
  49. }
  50. static inline void ibmasm_enable_interrupts(void __iomem *base_address, int mask)
  51. {
  52. void __iomem *ctrl_reg = base_address + INTR_CONTROL_REGISTER;
  53. writel( readl(ctrl_reg) & ~mask, ctrl_reg);
  54. }
  55. static inline void ibmasm_disable_interrupts(void __iomem *base_address, int mask)
  56. {
  57. void __iomem *ctrl_reg = base_address + INTR_CONTROL_REGISTER;
  58. writel( readl(ctrl_reg) | mask, ctrl_reg);
  59. }
  60. static inline void enable_sp_interrupts(void __iomem *base_address)
  61. {
  62. ibmasm_enable_interrupts(base_address, SP_INTR_MASK);
  63. }
  64. static inline void disable_sp_interrupts(void __iomem *base_address)
  65. {
  66. ibmasm_disable_interrupts(base_address, SP_INTR_MASK);
  67. }
  68. static inline void enable_uart_interrupts(void __iomem *base_address)
  69. {
  70. ibmasm_enable_interrupts(base_address, UART_INTR_MASK);
  71. }
  72. static inline void disable_uart_interrupts(void __iomem *base_address)
  73. {
  74. ibmasm_disable_interrupts(base_address, UART_INTR_MASK);
  75. }
  76. #define valid_mfa(mfa) ( (mfa) != NO_MFAS_AVAILABLE )
  77. static inline u32 get_mfa_outbound(void __iomem *base_address)
  78. {
  79. int retry;
  80. u32 mfa;
  81. for (retry=0; retry<=10; retry++) {
  82. mfa = readl(base_address + OUTBOUND_QUEUE_PORT);
  83. if (valid_mfa(mfa))
  84. break;
  85. }
  86. return mfa;
  87. }
  88. static inline void set_mfa_outbound(void __iomem *base_address, u32 mfa)
  89. {
  90. writel(mfa, base_address + OUTBOUND_QUEUE_PORT);
  91. }
  92. static inline u32 get_mfa_inbound(void __iomem *base_address)
  93. {
  94. u32 mfa = readl(base_address + INBOUND_QUEUE_PORT);
  95. if (MAILBOX_FULL(mfa))
  96. return 0;
  97. return mfa;
  98. }
  99. static inline void set_mfa_inbound(void __iomem *base_address, u32 mfa)
  100. {
  101. writel(mfa, base_address + INBOUND_QUEUE_PORT);
  102. }
  103. static inline struct i2o_message *get_i2o_message(void __iomem *base_address, u32 mfa)
  104. {
  105. return (struct i2o_message *)(GET_MFA_ADDR(mfa) + base_address);
  106. }
  107. #endif /* __IBMASM_CONDOR_H__ */