Schr\"odinger equations with singular potentials: linear and nonlinear boundary value problems