Cleanup code for power management and remove some duplication and isolate power management code from the kernel code. Signed-off-by: Anas Nashif <anas.nashif@intel.com>