The suppression of charmonium states in heavy-ion collisions is a phenomenon understood as a consequence of quark gluon plasma formation in the hot, dense system formed in heavy ion collisions at the LHC. In addition to hot matter effects in heavy-ion collisions, so-called cold nuclear effects that modify charmonium production are also present. Therefore, a full assessment requires detailed studies in both A+A and p+A collisions. Based on p+Pb data collected in 2013 and pp and Pb+Pb data collected in 2015 at the LHC, the ATLAS experiment has studied prompt and non-prompt J/ψ and ψ(2S) production via the dimuon decay final states. The production yields and excited-to-ground state yield ratios, measured in p+Pb and Pb+Pb with respect to that measured in pp collision data, are presented in intervals of transverse momentum, rapidity and centrality.