Remove useless inlcude and modify properties.
Submit a small patch to make sure x86-power-control
is added into meta/intel/meta-s2600wf and make sure
obmc-phosphor-image is built successfully.
The more funtions will be submitted one by one in
the comming.
Change-Id: I53101712fd17b949f1fa57acbccb4d95ba193f14
Signed-off-by: Kuiying Wang <kuiying.wang@intel.com>
diff --git a/power-control/CMakeLists.txt b/power-control/CMakeLists.txt
index 5b55db9..e328e3e 100644
--- a/power-control/CMakeLists.txt
+++ b/power-control/CMakeLists.txt
@@ -3,8 +3,6 @@
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
-set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}
- ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
include(GNUInstallDirs)
diff --git a/power-control/inc/power_control.hpp b/power-control/inc/power_control.hpp
index 6918f08..bc87cf6 100644
--- a/power-control/inc/power_control.hpp
+++ b/power-control/inc/power_control.hpp
@@ -18,7 +18,6 @@
#include "gpio.hpp"
#include <fcntl.h>
-#include <linux/aspeed-lpc-sio.h>
#include <unistd.h>
#include <phosphor-logging/elog-errors.hpp>
@@ -26,26 +25,32 @@
#include <xyz/openbmc_project/Chassis/Control/Power/server.hpp>
#include <xyz/openbmc_project/Common/error.hpp>
-static constexpr size_t POLLING_INTERVAL_MS = 500;
+//static constexpr size_t POLLING_INTERVAL_MS = 500;
-const static constexpr char* LPC_SIO_DEVPATH = "/dev/lpc-sio";
const static constexpr char* PGOOD_PIN = "PGOOD";
const static constexpr char* POWER_UP_PIN = "POWER_UP_PIN";
-const static constexpr size_t PCH_DEVICE_BUS_ADDRESS = 3;
-const static constexpr size_t PCH_DEVICE_SLAVE_ADDRESS = 0x44;
-const static constexpr size_t PCH_CMD_REGISTER = 0;
-const static constexpr size_t PCH_POWER_DOWN_CMD = 0x02;
-
const static constexpr size_t POWER_UP_PIN_PULSE_TIME_MS = 200;
+struct EventDeleter
+{
+ void operator()(sd_event *event) const
+ {
+ event = sd_event_unref(event);
+ }
+};
+
+using EventPtr = std::unique_ptr<sd_event, EventDeleter>;
+
+
using pwr_control =
sdbusplus::xyz::openbmc_project::Chassis::Control::server::Power;
struct PowerControl : sdbusplus::server::object_t<pwr_control>
{
PowerControl(sdbusplus::bus::bus& bus, const char* path,
- phosphor::watchdog::EventPtr event,
+ EventPtr &event,
+ //phosphor::watchdog::EventPtr event,
sd_event_io_handler_t handler = PowerControl::EventHandler) :
sdbusplus::server::object_t<pwr_control>(bus, path),
bus(bus), callbackHandler(handler)
@@ -66,7 +71,7 @@
closeGpio(pgood_fd);
throw std::runtime_error("failed to config POWER_UP_PIN");
}
-
+/*
ret = sd_event_add_io(event.get(), nullptr, pgood_fd, EPOLLPRI,
callbackHandler, this);
if (ret < 0)
@@ -80,6 +85,7 @@
std::chrono::milliseconds(POLLING_INTERVAL_MS)));
timer.setEnabled<std::true_type>();
phosphor::logging::log<phosphor::logging::level::DEBUG>("Enable timer");
+*/
}
~PowerControl()
@@ -132,7 +138,7 @@
if (buf == '0')
{
powercontrol->state(0);
- powercontrol->pgood(0);
+ powercontrol->pGood(0);
if (first_event)
{
@@ -140,26 +146,27 @@
}
else
{
- powercontrol->powerLost();
+ //powercontrol->powerLost();
}
}
else
{
powercontrol->state(1);
- powercontrol->pgood(1);
+ powercontrol->pGood(1);
if (first_event)
{
first_event = false;
}
else
{
- powercontrol->powerGood();
+// powercontrol->powerGood();
}
}
return 0;
}
+ int32_t forcePowerOff() override;
int32_t setPowerState(int32_t newState) override;
int32_t getPowerState() override;
diff --git a/power-control/src/main.cpp b/power-control/src/main.cpp
index 695666e..676d65d 100644
--- a/power-control/src/main.cpp
+++ b/power-control/src/main.cpp
@@ -30,8 +30,9 @@
"Error creating a default sd_event handler");
return ret;
}
- phosphor::watchdog::EventPtr eventP{event,
- phosphor::watchdog::EventDeleter()};
+ //phosphor::watchdog::EventPtr eventP{event,
+ // phosphor::watchdog::EventDeleter()};
+ EventPtr eventP{event};
event = nullptr;
sdbusplus::bus::bus bus = sdbusplus::bus::new_default();
diff --git a/power-control/src/power_control.cpp b/power-control/src/power_control.cpp
index df92108..9d15a06 100644
--- a/power-control/src/power_control.cpp
+++ b/power-control/src/power_control.cpp
@@ -15,6 +15,13 @@
*/
#include "power_control.hpp"
+int32_t PowerControl::forcePowerOff()
+{
+ int ret = 0;
+
+ return ret;
+}
+
int32_t PowerControl::setPowerState(int32_t newState)
{
int ret = 0;