Devices with PN homojunction gate