![]() |
|
|||
0001 /* SPDX-License-Identifier: GPL-2.0 */ 0002 /* 0003 * Intel OnChip System Fabric MailBox access support 0004 */ 0005 0006 #ifndef IOSF_MBI_SYMS_H 0007 #define IOSF_MBI_SYMS_H 0008 0009 #include <linux/notifier.h> 0010 0011 #define MBI_MCR_OFFSET 0xD0 0012 #define MBI_MDR_OFFSET 0xD4 0013 #define MBI_MCRX_OFFSET 0xD8 0014 0015 #define MBI_RD_MASK 0xFEFFFFFF 0016 #define MBI_WR_MASK 0X01000000 0017 0018 #define MBI_MASK_HI 0xFFFFFF00 0019 #define MBI_MASK_LO 0x000000FF 0020 #define MBI_ENABLE 0xF0 0021 0022 /* IOSF SB read/write opcodes */ 0023 #define MBI_MMIO_READ 0x00 0024 #define MBI_MMIO_WRITE 0x01 0025 #define MBI_CFG_READ 0x04 0026 #define MBI_CFG_WRITE 0x05 0027 #define MBI_CR_READ 0x06 0028 #define MBI_CR_WRITE 0x07 0029 #define MBI_REG_READ 0x10 0030 #define MBI_REG_WRITE 0x11 0031 #define MBI_ESRAM_READ 0x12 0032 #define MBI_ESRAM_WRITE 0x13 0033 0034 /* Baytrail available units */ 0035 #define BT_MBI_UNIT_AUNIT 0x00 0036 #define BT_MBI_UNIT_SMC 0x01 0037 #define BT_MBI_UNIT_CPU 0x02 0038 #define BT_MBI_UNIT_BUNIT 0x03 0039 #define BT_MBI_UNIT_PMC 0x04 0040 #define BT_MBI_UNIT_GFX 0x06 0041 #define BT_MBI_UNIT_SMI 0x0C 0042 #define BT_MBI_UNIT_CCK 0x14 0043 #define BT_MBI_UNIT_USB 0x43 0044 #define BT_MBI_UNIT_SATA 0xA3 0045 #define BT_MBI_UNIT_PCIE 0xA6 0046 0047 /* Quark available units */ 0048 #define QRK_MBI_UNIT_HBA 0x00 0049 #define QRK_MBI_UNIT_HB 0x03 0050 #define QRK_MBI_UNIT_RMU 0x04 0051 #define QRK_MBI_UNIT_MM 0x05 0052 #define QRK_MBI_UNIT_SOC 0x31 0053 0054 /* Action values for the pmic_bus_access_notifier functions */ 0055 #define MBI_PMIC_BUS_ACCESS_BEGIN 1 0056 #define MBI_PMIC_BUS_ACCESS_END 2 0057 0058 #if IS_ENABLED(CONFIG_IOSF_MBI) 0059 0060 bool iosf_mbi_available(void); 0061 0062 /** 0063 * iosf_mbi_read() - MailBox Interface read command 0064 * @port: port indicating subunit being accessed 0065 * @opcode: port specific read or write opcode 0066 * @offset: register address offset 0067 * @mdr: register data to be read 0068 * 0069 * Locking is handled by spinlock - cannot sleep. 0070 * Return: Nonzero on error 0071 */ 0072 int iosf_mbi_read(u8 port, u8 opcode, u32 offset, u32 *mdr); 0073 0074 /** 0075 * iosf_mbi_write() - MailBox unmasked write command 0076 * @port: port indicating subunit being accessed 0077 * @opcode: port specific read or write opcode 0078 * @offset: register address offset 0079 * @mdr: register data to be written 0080 * 0081 * Locking is handled by spinlock - cannot sleep. 0082 * Return: Nonzero on error 0083 */ 0084 int iosf_mbi_write(u8 port, u8 opcode, u32 offset, u32 mdr); 0085 0086 /** 0087 * iosf_mbi_modify() - MailBox masked write command 0088 * @port: port indicating subunit being accessed 0089 * @opcode: port specific read or write opcode 0090 * @offset: register address offset 0091 * @mdr: register data being modified 0092 * @mask: mask indicating bits in mdr to be modified 0093 * 0094 * Locking is handled by spinlock - cannot sleep. 0095 * Return: Nonzero on error 0096 */ 0097 int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask); 0098 0099 /** 0100 * iosf_mbi_punit_acquire() - Acquire access to the P-Unit 0101 * 0102 * One some systems the P-Unit accesses the PMIC to change various voltages 0103 * through the same bus as other kernel drivers use for e.g. battery monitoring. 0104 * 0105 * If a driver sends requests to the P-Unit which require the P-Unit to access 0106 * the PMIC bus while another driver is also accessing the PMIC bus various bad 0107 * things happen. 0108 * 0109 * Call this function before sending requests to the P-Unit which may make it 0110 * access the PMIC, be it through iosf_mbi* functions or through other means. 0111 * This function will block all kernel access to the PMIC I2C bus, so that the 0112 * P-Unit can safely access the PMIC over the shared I2C bus. 0113 * 0114 * Note on these systems the i2c-bus driver will request a sempahore from the 0115 * P-Unit for exclusive access to the PMIC bus when i2c drivers are accessing 0116 * it, but this does not appear to be sufficient, we still need to avoid making 0117 * certain P-Unit requests during the access window to avoid problems. 0118 * 0119 * This function locks a mutex, as such it may sleep. 0120 */ 0121 void iosf_mbi_punit_acquire(void); 0122 0123 /** 0124 * iosf_mbi_punit_release() - Release access to the P-Unit 0125 */ 0126 void iosf_mbi_punit_release(void); 0127 0128 /** 0129 * iosf_mbi_block_punit_i2c_access() - Block P-Unit accesses to the PMIC bus 0130 * 0131 * Call this function to block P-Unit access to the PMIC I2C bus, so that the 0132 * kernel can safely access the PMIC over the shared I2C bus. 0133 * 0134 * This function acquires the P-Unit bus semaphore and notifies 0135 * pmic_bus_access_notifier listeners that they may no longer access the 0136 * P-Unit in a way which may cause it to access the shared I2C bus. 0137 * 0138 * Note this function may be called multiple times and the bus will not 0139 * be released until iosf_mbi_unblock_punit_i2c_access() has been called the 0140 * same amount of times. 0141 * 0142 * Return: Nonzero on error 0143 */ 0144 int iosf_mbi_block_punit_i2c_access(void); 0145 0146 /* 0147 * iosf_mbi_unblock_punit_i2c_access() - Release PMIC I2C bus block 0148 * 0149 * Release i2c access block gotten through iosf_mbi_block_punit_i2c_access(). 0150 */ 0151 void iosf_mbi_unblock_punit_i2c_access(void); 0152 0153 /** 0154 * iosf_mbi_register_pmic_bus_access_notifier - Register PMIC bus notifier 0155 * 0156 * This function can be used by drivers which may need to acquire P-Unit 0157 * managed resources from interrupt context, where iosf_mbi_punit_acquire() 0158 * can not be used. 0159 * 0160 * This function allows a driver to register a notifier to get notified (in a 0161 * process context) before other drivers start accessing the PMIC bus. 0162 * 0163 * This allows the driver to acquire any resources, which it may need during 0164 * the window the other driver is accessing the PMIC, before hand. 0165 * 0166 * @nb: notifier_block to register 0167 */ 0168 int iosf_mbi_register_pmic_bus_access_notifier(struct notifier_block *nb); 0169 0170 /** 0171 * iosf_mbi_register_pmic_bus_access_notifier - Unregister PMIC bus notifier 0172 * 0173 * @nb: notifier_block to unregister 0174 */ 0175 int iosf_mbi_unregister_pmic_bus_access_notifier(struct notifier_block *nb); 0176 0177 /** 0178 * iosf_mbi_unregister_pmic_bus_access_notifier_unlocked - Unregister PMIC bus 0179 * notifier, unlocked 0180 * 0181 * Like iosf_mbi_unregister_pmic_bus_access_notifier(), but for use when the 0182 * caller has already called iosf_mbi_punit_acquire() itself. 0183 * 0184 * @nb: notifier_block to unregister 0185 */ 0186 int iosf_mbi_unregister_pmic_bus_access_notifier_unlocked( 0187 struct notifier_block *nb); 0188 0189 /** 0190 * iosf_mbi_assert_punit_acquired - Assert that the P-Unit has been acquired. 0191 */ 0192 void iosf_mbi_assert_punit_acquired(void); 0193 0194 #else /* CONFIG_IOSF_MBI is not enabled */ 0195 static inline 0196 bool iosf_mbi_available(void) 0197 { 0198 return false; 0199 } 0200 0201 static inline 0202 int iosf_mbi_read(u8 port, u8 opcode, u32 offset, u32 *mdr) 0203 { 0204 WARN(1, "IOSF_MBI driver not available"); 0205 return -EPERM; 0206 } 0207 0208 static inline 0209 int iosf_mbi_write(u8 port, u8 opcode, u32 offset, u32 mdr) 0210 { 0211 WARN(1, "IOSF_MBI driver not available"); 0212 return -EPERM; 0213 } 0214 0215 static inline 0216 int iosf_mbi_modify(u8 port, u8 opcode, u32 offset, u32 mdr, u32 mask) 0217 { 0218 WARN(1, "IOSF_MBI driver not available"); 0219 return -EPERM; 0220 } 0221 0222 static inline void iosf_mbi_punit_acquire(void) {} 0223 static inline void iosf_mbi_punit_release(void) {} 0224 0225 static inline 0226 int iosf_mbi_register_pmic_bus_access_notifier(struct notifier_block *nb) 0227 { 0228 return 0; 0229 } 0230 0231 static inline 0232 int iosf_mbi_unregister_pmic_bus_access_notifier(struct notifier_block *nb) 0233 { 0234 return 0; 0235 } 0236 0237 static inline int 0238 iosf_mbi_unregister_pmic_bus_access_notifier_unlocked(struct notifier_block *nb) 0239 { 0240 return 0; 0241 } 0242 0243 static inline 0244 int iosf_mbi_call_pmic_bus_access_notifier_chain(unsigned long val, void *v) 0245 { 0246 return 0; 0247 } 0248 0249 static inline void iosf_mbi_assert_punit_acquired(void) {} 0250 0251 #endif /* CONFIG_IOSF_MBI */ 0252 0253 #endif /* IOSF_MBI_SYMS_H */
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.1.0 LXR engine. The LXR team |
![]() ![]() |