Self-Organized Criticality and Thermodynamic Formalism