What is the cause of melanosis of the glans?

Melanosis of the glans is partly due to multiple freckle-like nevi, and also due to hyperpigmentation after foreskin glansitis.