Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

char: tpm: handle HAS_IOPORT dependencies

In a future patch HAS_IOPORT=n will disable inb()/outb() and friends at
compile time. We thus need to add this dependency and ifdef sections of
code using inb()/outb() as alternative access methods.

Reviewed-by: Jarkko Sakkinen <jarkko@kernel.org>
Co-developed-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Arnd Bergmann <arnd@kernel.org>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Acked-by: Jarkko Sakkinen <jarkko@kernel.org>
Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>

authored by

Niklas Schnelle and committed by
Jarkko Sakkinen
61551536 45db3ab7

+21 -15
+1
drivers/char/tpm/Kconfig
··· 149 149 config TCG_ATMEL 150 150 tristate "Atmel TPM Interface" 151 151 depends on PPC64 || HAS_IOPORT_MAP 152 + depends on HAS_IOPORT 152 153 help 153 154 If you have a TPM security chip from Atmel say Yes and it 154 155 will be accessible from within Linux. To compile this driver
+12 -4
drivers/char/tpm/tpm_infineon.c
··· 26 26 #define TPM_MAX_TRIES 5000 27 27 #define TPM_INFINEON_DEV_VEN_VALUE 0x15D1 28 28 29 + #ifdef CONFIG_HAS_IOPORT 29 30 #define TPM_INF_IO_PORT 0x0 31 + #endif 30 32 #define TPM_INF_IO_MEM 0x1 31 33 32 34 #define TPM_INF_ADDR 0x0 ··· 53 51 54 52 static inline void tpm_data_out(unsigned char data, unsigned char offset) 55 53 { 54 + #ifdef CONFIG_HAS_IOPORT 56 55 if (tpm_dev.iotype == TPM_INF_IO_PORT) 57 56 outb(data, tpm_dev.data_regs + offset); 58 57 else 58 + #endif 59 59 writeb(data, tpm_dev.mem_base + tpm_dev.data_regs + offset); 60 60 } 61 61 62 62 static inline unsigned char tpm_data_in(unsigned char offset) 63 63 { 64 + #ifdef CONFIG_HAS_IOPORT 64 65 if (tpm_dev.iotype == TPM_INF_IO_PORT) 65 66 return inb(tpm_dev.data_regs + offset); 66 - else 67 - return readb(tpm_dev.mem_base + tpm_dev.data_regs + offset); 67 + #endif 68 + return readb(tpm_dev.mem_base + tpm_dev.data_regs + offset); 68 69 } 69 70 70 71 static inline void tpm_config_out(unsigned char data, unsigned char offset) 71 72 { 73 + #ifdef CONFIG_HAS_IOPORT 72 74 if (tpm_dev.iotype == TPM_INF_IO_PORT) 73 75 outb(data, tpm_dev.config_port + offset); 74 76 else 77 + #endif 75 78 writeb(data, tpm_dev.mem_base + tpm_dev.index_off + offset); 76 79 } 77 80 78 81 static inline unsigned char tpm_config_in(unsigned char offset) 79 82 { 83 + #ifdef CONFIG_HAS_IOPORT 80 84 if (tpm_dev.iotype == TPM_INF_IO_PORT) 81 85 return inb(tpm_dev.config_port + offset); 82 - else 83 - return readb(tpm_dev.mem_base + tpm_dev.index_off + offset); 86 + #endif 87 + return readb(tpm_dev.mem_base + tpm_dev.index_off + offset); 84 88 } 85 89 86 90 /* TPM header definitions */
+8 -11
drivers/char/tpm/tpm_tis_core.c
··· 1057 1057 clkrun_val &= ~LPC_CLKRUN_EN; 1058 1058 iowrite32(clkrun_val, data->ilb_base_addr + LPC_CNTRL_OFFSET); 1059 1059 1060 - /* 1061 - * Write any random value on port 0x80 which is on LPC, to make 1062 - * sure LPC clock is running before sending any TPM command. 1063 - */ 1064 - outb(0xCC, 0x80); 1065 1060 } else { 1066 1061 data->clkrun_enabled--; 1067 1062 if (data->clkrun_enabled) ··· 1067 1072 /* Enable LPC CLKRUN# */ 1068 1073 clkrun_val |= LPC_CLKRUN_EN; 1069 1074 iowrite32(clkrun_val, data->ilb_base_addr + LPC_CNTRL_OFFSET); 1070 - 1071 - /* 1072 - * Write any random value on port 0x80 which is on LPC, to make 1073 - * sure LPC clock is running before sending any TPM command. 1074 - */ 1075 - outb(0xCC, 0x80); 1076 1075 } 1076 + 1077 + #ifdef CONFIG_HAS_IOPORT 1078 + /* 1079 + * Write any random value on port 0x80 which is on LPC, to make 1080 + * sure LPC clock is running before sending any TPM command. 1081 + */ 1082 + outb(0xCC, 0x80); 1083 + #endif 1077 1084 } 1078 1085 1079 1086 static const struct tpm_class_ops tpm_tis = {