First-principles calculations of semiconducting TiMgN2