1*71d7fe43SShawn McCarney /** 2*71d7fe43SShawn McCarney * Copyright © 2024 IBM Corporation 3*71d7fe43SShawn McCarney * 4*71d7fe43SShawn McCarney * Licensed under the Apache License, Version 2.0 (the "License"); 5*71d7fe43SShawn McCarney * you may not use this file except in compliance with the License. 6*71d7fe43SShawn McCarney * You may obtain a copy of the License at 7*71d7fe43SShawn McCarney * 8*71d7fe43SShawn McCarney * http://www.apache.org/licenses/LICENSE-2.0 9*71d7fe43SShawn McCarney * 10*71d7fe43SShawn McCarney * Unless required by applicable law or agreed to in writing, software 11*71d7fe43SShawn McCarney * distributed under the License is distributed on an "AS IS" BASIS, 12*71d7fe43SShawn McCarney * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13*71d7fe43SShawn McCarney * See the License for the specific language governing permissions and 14*71d7fe43SShawn McCarney * limitations under the License. 15*71d7fe43SShawn McCarney */ 16*71d7fe43SShawn McCarney #pragma once 17*71d7fe43SShawn McCarney 18*71d7fe43SShawn McCarney #include "pmbus_driver_device.hpp" 19*71d7fe43SShawn McCarney #include "rail.hpp" 20*71d7fe43SShawn McCarney #include "services.hpp" 21*71d7fe43SShawn McCarney 22*71d7fe43SShawn McCarney #include <cstdint> 23*71d7fe43SShawn McCarney #include <map> 24*71d7fe43SShawn McCarney #include <memory> 25*71d7fe43SShawn McCarney #include <string> 26*71d7fe43SShawn McCarney #include <utility> 27*71d7fe43SShawn McCarney #include <vector> 28*71d7fe43SShawn McCarney 29*71d7fe43SShawn McCarney namespace phosphor::power::sequencer 30*71d7fe43SShawn McCarney { 31*71d7fe43SShawn McCarney 32*71d7fe43SShawn McCarney /** 33*71d7fe43SShawn McCarney * @class UCD90xDevice 34*71d7fe43SShawn McCarney * 35*71d7fe43SShawn McCarney * PMBusDriverDevice sub-class for the UCD90X family of power sequencer devices. 36*71d7fe43SShawn McCarney * 37*71d7fe43SShawn McCarney * These devices share a common device driver. 38*71d7fe43SShawn McCarney */ 39*71d7fe43SShawn McCarney class UCD90xDevice : public PMBusDriverDevice 40*71d7fe43SShawn McCarney { 41*71d7fe43SShawn McCarney public: 42*71d7fe43SShawn McCarney // Specify which compiler-generated methods we want 43*71d7fe43SShawn McCarney UCD90xDevice() = delete; 44*71d7fe43SShawn McCarney UCD90xDevice(const UCD90xDevice&) = delete; 45*71d7fe43SShawn McCarney UCD90xDevice(UCD90xDevice&&) = delete; 46*71d7fe43SShawn McCarney UCD90xDevice& operator=(const UCD90xDevice&) = delete; 47*71d7fe43SShawn McCarney UCD90xDevice& operator=(UCD90xDevice&&) = delete; 48*71d7fe43SShawn McCarney virtual ~UCD90xDevice() = default; 49*71d7fe43SShawn McCarney 50*71d7fe43SShawn McCarney /** 51*71d7fe43SShawn McCarney * Constructor. 52*71d7fe43SShawn McCarney * 53*71d7fe43SShawn McCarney * @param name Device name 54*71d7fe43SShawn McCarney * @param rails Voltage rails that are enabled and monitored by this device 55*71d7fe43SShawn McCarney * @param services System services like hardware presence and the journal 56*71d7fe43SShawn McCarney * @param bus I2C bus for the device 57*71d7fe43SShawn McCarney * @param address I2C address for the device 58*71d7fe43SShawn McCarney */ UCD90xDevice(const std::string & name,std::vector<std::unique_ptr<Rail>> rails,Services & services,uint8_t bus,uint16_t address)59*71d7fe43SShawn McCarney explicit UCD90xDevice(const std::string& name, 60*71d7fe43SShawn McCarney std::vector<std::unique_ptr<Rail>> rails, 61*71d7fe43SShawn McCarney Services& services, uint8_t bus, uint16_t address) : 62*71d7fe43SShawn McCarney PMBusDriverDevice(name, std::move(rails), services, bus, address, 63*71d7fe43SShawn McCarney driverName) 64*71d7fe43SShawn McCarney {} 65*71d7fe43SShawn McCarney 66*71d7fe43SShawn McCarney /** 67*71d7fe43SShawn McCarney * Returns the value of the PMBus MFR_STATUS command. 68*71d7fe43SShawn McCarney * 69*71d7fe43SShawn McCarney * This is a manufacturer-specific command that replaces the standard 70*71d7fe43SShawn McCarney * STATUS_MFR_SPECIFIC command on UCD90x devices. 71*71d7fe43SShawn McCarney * 72*71d7fe43SShawn McCarney * The returned value is in host-endian order. 73*71d7fe43SShawn McCarney * 74*71d7fe43SShawn McCarney * Note that the UCD90x documentation states that this is a paged command. 75*71d7fe43SShawn McCarney * This means that the PMBus PAGE should be set, and some of the bits in the 76*71d7fe43SShawn McCarney * command value are page-specific. However, the current device driver only 77*71d7fe43SShawn McCarney * provides a single file in sysfs, and the driver always sets the PAGE to 78*71d7fe43SShawn McCarney * 0. Thus, the bits that are page-specific in the returned value are 79*71d7fe43SShawn McCarney * always for PAGE 0. 80*71d7fe43SShawn McCarney * 81*71d7fe43SShawn McCarney * Throws an exception if the value could not be obtained. 82*71d7fe43SShawn McCarney * 83*71d7fe43SShawn McCarney * @return MFR_STATUS value 84*71d7fe43SShawn McCarney */ 85*71d7fe43SShawn McCarney virtual uint64_t getMfrStatus(); 86*71d7fe43SShawn McCarney 87*71d7fe43SShawn McCarney constexpr static std::string driverName{"ucd9000"}; 88*71d7fe43SShawn McCarney 89*71d7fe43SShawn McCarney protected: 90*71d7fe43SShawn McCarney /** @copydoc PMBusDriverDevice::storePgoodFaultDebugData() */ 91*71d7fe43SShawn McCarney virtual void storePgoodFaultDebugData( 92*71d7fe43SShawn McCarney Services& services, const std::vector<int>& gpioValues, 93*71d7fe43SShawn McCarney std::map<std::string, std::string>& additionalData) override; 94*71d7fe43SShawn McCarney }; 95*71d7fe43SShawn McCarney 96*71d7fe43SShawn McCarney } // namespace phosphor::power::sequencer 97