Uptake of magnesium and calcium by mitochondria in exchange for hydrogen ions