The M2-M5 brane system and a generalized Nahm's equation