Entropy change for a system is defined classically as:
$$dS=\frac{\delta Q_{rev}}{T}$$
where $\delta Q_{rev}$ is infinitesimal reversible heat that flows in a system.
I don't understand whether $T$ refers to the temperature of a system or its surroundings. Many sources said $T$ is the temperature of a system. However since this entropy definition applies to reversible processes and most reversible processes have a system in thermal equilibrium with its surroundings, so $T$ refers to either system and surroundings because temperatures in equilibrium are equal.
To calculate the entropy change when a system changes its temperature from $T_i$ to $T_f$:
$$\Delta S=\int_{T_i}^{T_f} \frac{\delta Q_{rev}}{T}$$
This integral assumes that the path we are integrating is quasistatic and reversible. If $T$ refers to either system and surroundings, then that means in the selected quasistatic and reversible process, the temperature of both system and surroundings change from $T_i$ to $T_f$?
Also, when the definitions of Helmholtz and Gibbs free energy are discussed
$$F=U-TS$$
$$G=H-TS$$
Schroeder wrote that the term $TS$ refers to heat that flows in a system where $S$ is a system's final entropy and $T$ is the temperature of surroundings. Can $T$ refers to the temperature of a system?