Dynamics of Poisson--Nernst--Planck systems and applications to ion channel problems