Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * STMicroelectronics TPM Linux driver for TPM ST33ZP24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  * Copyright (C) 2009 - 2016 STMicroelectronics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/delay.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/wait.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/freezer.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/gpio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include "../tpm.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include "st33zp24.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #define TPM_ACCESS			0x0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #define TPM_STS				0x18
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) #define TPM_DATA_FIFO			0x24
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #define TPM_INTF_CAPABILITY		0x14
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #define TPM_INT_STATUS			0x10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #define TPM_INT_ENABLE			0x08
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #define LOCALITY0			0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) enum st33zp24_access {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	TPM_ACCESS_VALID = 0x80,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 	TPM_ACCESS_ACTIVE_LOCALITY = 0x20,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	TPM_ACCESS_REQUEST_PENDING = 0x04,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	TPM_ACCESS_REQUEST_USE = 0x02,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) enum st33zp24_status {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 	TPM_STS_VALID = 0x80,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	TPM_STS_COMMAND_READY = 0x40,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	TPM_STS_GO = 0x20,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 	TPM_STS_DATA_AVAIL = 0x10,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	TPM_STS_DATA_EXPECT = 0x08,
^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) enum st33zp24_int_flags {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	TPM_GLOBAL_INT_ENABLE = 0x80,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 	TPM_INTF_CMD_READY_INT = 0x080,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	TPM_INTF_FIFO_AVALAIBLE_INT = 0x040,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	TPM_INTF_WAKE_UP_READY_INT = 0x020,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 	TPM_INTF_LOCALITY_CHANGE_INT = 0x004,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	TPM_INTF_STS_VALID_INT = 0x002,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	TPM_INTF_DATA_AVAIL_INT = 0x001,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) enum tis_defaults {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	TIS_SHORT_TIMEOUT = 750,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	TIS_LONG_TIMEOUT = 2000,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) };
^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)  * clear_interruption clear the pending interrupt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65)  * @param: tpm_dev, the tpm device device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66)  * @return: the interrupt status value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) static u8 clear_interruption(struct st33zp24_dev *tpm_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	u8 interrupt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	tpm_dev->ops->recv(tpm_dev->phy_id, TPM_INT_STATUS, &interrupt, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	tpm_dev->ops->send(tpm_dev->phy_id, TPM_INT_STATUS, &interrupt, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 	return interrupt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) } /* clear_interruption() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78)  * st33zp24_cancel, cancel the current command execution or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79)  * set STS to COMMAND READY.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80)  * @param: chip, the tpm_chip description as specified in driver/char/tpm/tpm.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) static void st33zp24_cancel(struct tpm_chip *chip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 	struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	u8 data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	data = TPM_STS_COMMAND_READY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	tpm_dev->ops->send(tpm_dev->phy_id, TPM_STS, &data, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) } /* st33zp24_cancel() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92)  * st33zp24_status return the TPM_STS register
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93)  * @param: chip, the tpm chip description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94)  * @return: the TPM_STS register value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) static u8 st33zp24_status(struct tpm_chip *chip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	u8 data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	tpm_dev->ops->recv(tpm_dev->phy_id, TPM_STS, &data, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	return data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) } /* st33zp24_status() */
^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)  * check_locality if the locality is active
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)  * @param: chip, the tpm chip description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)  * @return: true if LOCALITY0 is active, otherwise false
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) static bool check_locality(struct tpm_chip *chip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 	u8 data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	u8 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	status = tpm_dev->ops->recv(tpm_dev->phy_id, TPM_ACCESS, &data, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	if (status && (data &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 		(TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) ==
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		(TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) } /* check_locality() */
^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)  * request_locality request the TPM locality
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)  * @param: chip, the chip description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)  * @return: the active locality or negative value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) static int request_locality(struct tpm_chip *chip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	unsigned long stop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	long ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 	u8 data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	if (check_locality(chip))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		return tpm_dev->locality;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	data = TPM_ACCESS_REQUEST_USE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	ret = tpm_dev->ops->send(tpm_dev->phy_id, TPM_ACCESS, &data, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	stop = jiffies + chip->timeout_a;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 	/* Request locality is usually effective after the request */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) 		if (check_locality(chip))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 			return tpm_dev->locality;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 		msleep(TPM_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 	} while (time_before(jiffies, stop));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	/* could not get locality */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 	return -EACCES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) } /* request_locality() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159)  * release_locality release the active locality
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)  * @param: chip, the tpm chip description.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) static void release_locality(struct tpm_chip *chip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	u8 data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	data = TPM_ACCESS_ACTIVE_LOCALITY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	tpm_dev->ops->send(tpm_dev->phy_id, TPM_ACCESS, &data, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)  * get_burstcount return the burstcount value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)  * @param: chip, the chip description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)  * return: the burstcount or negative value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) static int get_burstcount(struct tpm_chip *chip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	unsigned long stop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	int burstcnt, status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	u8 temp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	stop = jiffies + chip->timeout_d;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		status = tpm_dev->ops->recv(tpm_dev->phy_id, TPM_STS + 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 					    &temp, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 		if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 			return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		burstcnt = temp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 		status = tpm_dev->ops->recv(tpm_dev->phy_id, TPM_STS + 2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 					    &temp, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 		if (status < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 			return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 		burstcnt |= temp << 8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		if (burstcnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 			return burstcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 		msleep(TPM_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 	} while (time_before(jiffies, stop));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) } /* get_burstcount() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207)  * wait_for_tpm_stat_cond
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208)  * @param: chip, chip description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)  * @param: mask, expected mask value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210)  * @param: check_cancel, does the command expected to be canceled ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211)  * @param: canceled, did we received a cancel request ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212)  * @return: true if status == mask or if the command is canceled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)  * false in other cases.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) static bool wait_for_tpm_stat_cond(struct tpm_chip *chip, u8 mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 				bool check_cancel, bool *canceled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	u8 status = chip->ops->status(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 	*canceled = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	if ((status & mask) == mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 	if (check_cancel && chip->ops->req_canceled(chip, status)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 		*canceled = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 		return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231)  * wait_for_stat wait for a TPM_STS value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)  * @param: chip, the tpm chip description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)  * @param: mask, the value mask to wait
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)  * @param: timeout, the timeout
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235)  * @param: queue, the wait queue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)  * @param: check_cancel, does the command can be cancelled ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)  * @return: the tpm status, 0 if success, -ETIME if timeout is reached.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) static int wait_for_stat(struct tpm_chip *chip, u8 mask, unsigned long timeout,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 			wait_queue_head_t *queue, bool check_cancel)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 	unsigned long stop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 	bool canceled = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	bool condition;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	u32 cur_intrs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 	u8 status;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	/* check current status */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	status = st33zp24_status(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	if ((status & mask) == mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 	stop = jiffies + timeout;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	if (chip->flags & TPM_CHIP_FLAG_IRQ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 		cur_intrs = tpm_dev->intrs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 		clear_interruption(tpm_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 		enable_irq(tpm_dev->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 		do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 			if (ret == -ERESTARTSYS && freezing(current))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 				clear_thread_flag(TIF_SIGPENDING);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 			timeout = stop - jiffies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 			if ((long) timeout <= 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 				return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 			ret = wait_event_interruptible_timeout(*queue,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 						cur_intrs != tpm_dev->intrs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 						timeout);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 			clear_interruption(tpm_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 			condition = wait_for_tpm_stat_cond(chip, mask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) 						check_cancel, &canceled);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 			if (ret >= 0 && condition) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 				if (canceled)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 					return -ECANCELED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 				return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 		} while (ret == -ERESTARTSYS && freezing(current));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 		disable_irq_nosync(tpm_dev->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 		do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 			msleep(TPM_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 			status = chip->ops->status(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 			if ((status & mask) == mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 				return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 		} while (time_before(jiffies, stop));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	return -ETIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) } /* wait_for_stat() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)  * recv_data receive data
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)  * @param: chip, the tpm chip description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300)  * @param: buf, the buffer where the data are received
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)  * @param: count, the number of data to receive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302)  * @return: the number of bytes read from TPM FIFO.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) static int recv_data(struct tpm_chip *chip, u8 *buf, size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	int size = 0, burstcnt, len, ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	while (size < count &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	       wait_for_stat(chip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 			     TPM_STS_DATA_AVAIL | TPM_STS_VALID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 			     chip->timeout_c,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 			     &tpm_dev->read_queue, true) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 		burstcnt = get_burstcount(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 		if (burstcnt < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 			return burstcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 		len = min_t(int, burstcnt, count - size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 		ret = tpm_dev->ops->recv(tpm_dev->phy_id, TPM_DATA_FIFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 					 buf + size, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 		if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 			return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 		size += len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 	return size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)  * tpm_ioserirq_handler the serirq irq handler
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)  * @param: irq, the tpm chip description
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)  * @param: dev_id, the description of the chip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)  * @return: the status of the handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) static irqreturn_t tpm_ioserirq_handler(int irq, void *dev_id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	struct tpm_chip *chip = dev_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 	struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 	tpm_dev->intrs++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	wake_up_interruptible(&tpm_dev->read_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 	disable_irq_nosync(tpm_dev->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 	return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) } /* tpm_ioserirq_handler() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)  * st33zp24_send send TPM commands through the I2C bus.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)  * @param: chip, the tpm_chip description as specified in driver/char/tpm/tpm.h
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)  * @param: buf,	the buffer to send.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)  * @param: count, the number of bytes to send.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)  * @return: In case of success the number of bytes sent.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)  *			In other case, a < 0 value describing the issue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) static int st33zp24_send(struct tpm_chip *chip, unsigned char *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 			 size_t len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	u32 status, i, size, ordinal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	int burstcnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 	u8 data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	if (len < TPM_HEADER_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 		return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 	ret = request_locality(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	status = st33zp24_status(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	if ((status & TPM_STS_COMMAND_READY) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 		st33zp24_cancel(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 		if (wait_for_stat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 		    (chip, TPM_STS_COMMAND_READY, chip->timeout_b,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 		     &tpm_dev->read_queue, false) < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 			ret = -ETIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 			goto out_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	for (i = 0; i < len - 1;) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 		burstcnt = get_burstcount(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 		if (burstcnt < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 			return burstcnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 		size = min_t(int, len - i - 1, burstcnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 		ret = tpm_dev->ops->send(tpm_dev->phy_id, TPM_DATA_FIFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 					 buf + i, size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 		if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 			goto out_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 		i += size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	status = st33zp24_status(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	if ((status & TPM_STS_DATA_EXPECT) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 		ret = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 		goto out_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	ret = tpm_dev->ops->send(tpm_dev->phy_id, TPM_DATA_FIFO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 				 buf + len - 1, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 		goto out_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	status = st33zp24_status(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 	if ((status & TPM_STS_DATA_EXPECT) != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 		ret = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 		goto out_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	data = TPM_STS_GO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	ret = tpm_dev->ops->send(tpm_dev->phy_id, TPM_STS, &data, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 		goto out_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 	if (chip->flags & TPM_CHIP_FLAG_IRQ) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 		ordinal = be32_to_cpu(*((__be32 *) (buf + 6)));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 		ret = wait_for_stat(chip, TPM_STS_DATA_AVAIL | TPM_STS_VALID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 				tpm_calc_ordinal_duration(chip, ordinal),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 				&tpm_dev->read_queue, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 		if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 			goto out_err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) out_err:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	st33zp24_cancel(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	release_locality(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435)  * st33zp24_recv received TPM response through TPM phy.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)  * @param: chip, the tpm_chip description as specified in driver/char/tpm/tpm.h.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437)  * @param: buf,	the buffer to store datas.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438)  * @param: count, the number of bytes to send.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439)  * @return: In case of success the number of bytes received.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440)  *	    In other case, a < 0 value describing the issue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) static int st33zp24_recv(struct tpm_chip *chip, unsigned char *buf,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 			    size_t count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	int size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	u32 expected;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	if (!chip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 		return -EBUSY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	if (count < TPM_HEADER_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 		size = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 	size = recv_data(chip, buf, TPM_HEADER_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 	if (size < TPM_HEADER_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 		dev_err(&chip->dev, "Unable to read header\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 	expected = be32_to_cpu(*(__be32 *)(buf + 2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 	if (expected > count || expected < TPM_HEADER_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 		size = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 	size += recv_data(chip, &buf[TPM_HEADER_SIZE],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 			expected - TPM_HEADER_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	if (size < expected) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 		dev_err(&chip->dev, "Unable to read remainder of result\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 		size = -ETIME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 	st33zp24_cancel(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) 	release_locality(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 	return size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482)  * st33zp24_req_canceled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483)  * @param: chip, the tpm_chip description as specified in driver/char/tpm/tpm.h.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484)  * @param: status, the TPM status.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485)  * @return: Does TPM ready to compute a new command ? true.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) static bool st33zp24_req_canceled(struct tpm_chip *chip, u8 status)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) 	return (status == TPM_STS_COMMAND_READY);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) static const struct tpm_class_ops st33zp24_tpm = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 	.flags = TPM_OPS_AUTO_STARTUP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 	.send = st33zp24_send,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 	.recv = st33zp24_recv,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 	.cancel = st33zp24_cancel,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 	.status = st33zp24_status,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 	.req_complete_mask = TPM_STS_DATA_AVAIL | TPM_STS_VALID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 	.req_complete_val = TPM_STS_DATA_AVAIL | TPM_STS_VALID,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 	.req_canceled = st33zp24_req_canceled,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504)  * st33zp24_probe initialize the TPM device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505)  * @param: client, the i2c_client description (TPM I2C description).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506)  * @param: id, the i2c_device_id struct.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507)  * @return: 0 in case of success.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508)  *	 -1 in other case.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) int st33zp24_probe(void *phy_id, const struct st33zp24_phy_ops *ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 		   struct device *dev, int irq, int io_lpcpd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 	u8 intmask = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 	struct tpm_chip *chip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 	struct st33zp24_dev *tpm_dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 	chip = tpmm_chip_alloc(dev, &st33zp24_tpm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 	if (IS_ERR(chip))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 		return PTR_ERR(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 	tpm_dev = devm_kzalloc(dev, sizeof(struct st33zp24_dev),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 			       GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 	if (!tpm_dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 	tpm_dev->phy_id = phy_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 	tpm_dev->ops = ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 	dev_set_drvdata(&chip->dev, tpm_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 	chip->timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 	chip->timeout_b = msecs_to_jiffies(TIS_LONG_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 	chip->timeout_c = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 	chip->timeout_d = msecs_to_jiffies(TIS_SHORT_TIMEOUT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 	tpm_dev->locality = LOCALITY0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 	if (irq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 		/* INTERRUPT Setup */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 		init_waitqueue_head(&tpm_dev->read_queue);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 		tpm_dev->intrs = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 		if (request_locality(chip) != LOCALITY0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 			ret = -ENODEV;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 			goto _tpm_clean_answer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 		clear_interruption(tpm_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 		ret = devm_request_irq(dev, irq, tpm_ioserirq_handler,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 				IRQF_TRIGGER_HIGH, "TPM SERIRQ management",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 				chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 		if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 			dev_err(&chip->dev, "TPM SERIRQ signals %d not available\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) 				irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 			goto _tpm_clean_answer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 		intmask |= TPM_INTF_CMD_READY_INT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 			|  TPM_INTF_STS_VALID_INT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 			|  TPM_INTF_DATA_AVAIL_INT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 		ret = tpm_dev->ops->send(tpm_dev->phy_id, TPM_INT_ENABLE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 					 &intmask, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 		if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 			goto _tpm_clean_answer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 		intmask = TPM_GLOBAL_INT_ENABLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 		ret = tpm_dev->ops->send(tpm_dev->phy_id, (TPM_INT_ENABLE + 3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 					 &intmask, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 		if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 			goto _tpm_clean_answer;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 		tpm_dev->irq = irq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 		chip->flags |= TPM_CHIP_FLAG_IRQ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 		disable_irq_nosync(tpm_dev->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 	return tpm_chip_register(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) _tpm_clean_answer:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 	dev_info(&chip->dev, "TPM initialization fail\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) EXPORT_SYMBOL(st33zp24_probe);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587)  * st33zp24_remove remove the TPM device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588)  * @param: tpm_data, the tpm phy.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589)  * @return: 0 in case of success.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) int st33zp24_remove(struct tpm_chip *chip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 	tpm_chip_unregister(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) EXPORT_SYMBOL(st33zp24_remove);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) #ifdef CONFIG_PM_SLEEP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600)  * st33zp24_pm_suspend suspend the TPM device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601)  * @param: tpm_data, the tpm phy.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602)  * @param: mesg, the power management message.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603)  * @return: 0 in case of success.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) int st33zp24_pm_suspend(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 	struct tpm_chip *chip = dev_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 	struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 	if (gpio_is_valid(tpm_dev->io_lpcpd))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 		gpio_set_value(tpm_dev->io_lpcpd, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 		ret = tpm_pm_suspend(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) } /* st33zp24_pm_suspend() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) EXPORT_SYMBOL(st33zp24_pm_suspend);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622)  * st33zp24_pm_resume resume the TPM device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623)  * @param: tpm_data, the tpm phy.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624)  * @return: 0 in case of success.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) int st33zp24_pm_resume(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) 	struct tpm_chip *chip = dev_get_drvdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) 	struct st33zp24_dev *tpm_dev = dev_get_drvdata(&chip->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) 	if (gpio_is_valid(tpm_dev->io_lpcpd)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) 		gpio_set_value(tpm_dev->io_lpcpd, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) 		ret = wait_for_stat(chip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) 				TPM_STS_VALID, chip->timeout_b,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) 				&tpm_dev->read_queue, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) 		ret = tpm_pm_resume(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) 		if (!ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) 			tpm1_do_selftest(chip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) } /* st33zp24_pm_resume() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) EXPORT_SYMBOL(st33zp24_pm_resume);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) MODULE_AUTHOR("TPM support (TPMsupport@list.st.com)");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) MODULE_DESCRIPTION("ST33ZP24 TPM 1.2 driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) MODULE_VERSION("1.3.0");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) MODULE_LICENSE("GPL");