This paper proposes a unified system model and uses a general wireless energy harvesting (EH) protocol in massive multiple-input multiple-output (MIMO) systems, in which the terminals have no fixed power supply and thus need to replenish energy via the received signals from the base station (BS). On the downlink, the BS delivers radio frequency (RF) signals to all terminals and each terminal coordinates the processes of EH and information decoding (ID) with wireless EH protocol. On the uplink, a fraction of the harvested energy is used for uplink pilot transmission and the remaining fraction is used for uplink data transmission. Closed-form lower bound expressions for each terminal are first obtained on the uplink and downlink, respectively. Based on these expressions, we then formulate the joint spectral efficiency (SE) of uplink and downlink maximization problem with some practical constraints. As the formulated optimization problem is non-linear and non-convex, it is hard to solve directly. To provide a solution, an iteration algorithm is proposed by utilizing one-dimensional search technique and successive approximation method based on geometric program (GP). Additionally, the convergence and complexity of the proposed algorithm are discussed as well. Finally, the feasibility of the proposed algorithm and analytical results are demonstrated by extensive computer simulations.