Kuiying Wang | a9d39e3 | 2018-08-14 13:47:32 +0800 | [diff] [blame] | 1 | /* |
| 2 | // Copyright (c) 2018 Intel Corporation |
| 3 | // |
| 4 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | // you may not use this file except in compliance with the License. |
| 6 | // You may obtain a copy of the License at |
| 7 | // |
| 8 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | // |
| 10 | // Unless required by applicable law or agreed to in writing, software |
| 11 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | // See the License for the specific language governing permissions and |
| 14 | // limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #pragma once |
Naveen Moses | a1af329 | 2021-12-15 11:47:01 +0530 | [diff] [blame] | 18 | #include "button_factory.hpp" |
| 19 | #include "button_interface.hpp" |
Kuiying Wang | a9d39e3 | 2018-08-14 13:47:32 +0800 | [diff] [blame] | 20 | #include "common.hpp" |
| 21 | #include "gpio.hpp" |
Patrick Venture | 0d9377d | 2018-11-01 19:34:59 -0700 | [diff] [blame] | 22 | #include "xyz/openbmc_project/Chassis/Buttons/ID/server.hpp" |
| 23 | #include "xyz/openbmc_project/Chassis/Common/error.hpp" |
Kuiying Wang | a9d39e3 | 2018-08-14 13:47:32 +0800 | [diff] [blame] | 24 | |
Patrick Venture | 0d9377d | 2018-11-01 19:34:59 -0700 | [diff] [blame] | 25 | #include <unistd.h> |
| 26 | |
| 27 | #include <phosphor-logging/elog-errors.hpp> |
| 28 | |
Naveen Moses | a1af329 | 2021-12-15 11:47:01 +0530 | [diff] [blame] | 29 | static constexpr std::string_view ID_BUTTON = "ID_BTN"; |
Kuiying Wang | a9d39e3 | 2018-08-14 13:47:32 +0800 | [diff] [blame] | 30 | |
Naveen Moses | a1af329 | 2021-12-15 11:47:01 +0530 | [diff] [blame] | 31 | class IDButton |
| 32 | : public sdbusplus::server::object::object< |
| 33 | sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::ID>, |
| 34 | public ButtonIface |
Kuiying Wang | a9d39e3 | 2018-08-14 13:47:32 +0800 | [diff] [blame] | 35 | { |
| 36 | |
Naveen Moses | a1af329 | 2021-12-15 11:47:01 +0530 | [diff] [blame] | 37 | public: |
Patrick Venture | 0d9377d | 2018-11-01 19:34:59 -0700 | [diff] [blame] | 38 | IDButton(sdbusplus::bus::bus& bus, const char* path, EventPtr& event, |
Naveen Moses | a1af329 | 2021-12-15 11:47:01 +0530 | [diff] [blame] | 39 | buttonConfig& buttonCfg) : |
Kuiying Wang | a9d39e3 | 2018-08-14 13:47:32 +0800 | [diff] [blame] | 40 | sdbusplus::server::object::object< |
| 41 | sdbusplus::xyz::openbmc_project::Chassis::Buttons::server::ID>( |
| 42 | bus, path), |
Naveen Moses | a1af329 | 2021-12-15 11:47:01 +0530 | [diff] [blame] | 43 | ButtonIface(bus, event, buttonCfg) |
Kuiying Wang | a9d39e3 | 2018-08-14 13:47:32 +0800 | [diff] [blame] | 44 | { |
Naveen Moses | a1af329 | 2021-12-15 11:47:01 +0530 | [diff] [blame] | 45 | init(); |
Kuiying Wang | a9d39e3 | 2018-08-14 13:47:32 +0800 | [diff] [blame] | 46 | } |
| 47 | |
| 48 | ~IDButton() |
| 49 | { |
Naveen Moses | a1af329 | 2021-12-15 11:47:01 +0530 | [diff] [blame] | 50 | deInit(); |
Kuiying Wang | a9d39e3 | 2018-08-14 13:47:32 +0800 | [diff] [blame] | 51 | } |
| 52 | |
| 53 | void simPress() override; |
| 54 | |
Naveen Moses | a1af329 | 2021-12-15 11:47:01 +0530 | [diff] [blame] | 55 | static constexpr std::string_view getFormFactorName() |
Matt Spinler | 8605bdf | 2018-11-05 14:55:46 -0600 | [diff] [blame] | 56 | { |
| 57 | return ID_BUTTON; |
| 58 | } |
Naveen Moses | a1af329 | 2021-12-15 11:47:01 +0530 | [diff] [blame] | 59 | static constexpr const char* getDbusObjectPath() |
Kuiying Wang | a9d39e3 | 2018-08-14 13:47:32 +0800 | [diff] [blame] | 60 | { |
Naveen Moses | a1af329 | 2021-12-15 11:47:01 +0530 | [diff] [blame] | 61 | return ID_DBUS_OBJECT_NAME; |
Kuiying Wang | a9d39e3 | 2018-08-14 13:47:32 +0800 | [diff] [blame] | 62 | } |
| 63 | |
Naveen Moses | a1af329 | 2021-12-15 11:47:01 +0530 | [diff] [blame] | 64 | void handleEvent(sd_event_source* es, int fd, uint32_t revents) override; |
Kuiying Wang | a9d39e3 | 2018-08-14 13:47:32 +0800 | [diff] [blame] | 65 | }; |