Exchange coupling and Mn valency in GaN doped with Mn and co-doped with Mg