blob: 4658f33fe23509cfb24a702feee95c40cbd99e75 [file] [log] [blame]
Marc Olberding1e17db52025-08-27 12:25:28 -07001// SPDX-License-Identifier: Apache-2.0
Patrick Williams4a943522025-10-09 20:34:38 -04002// SPDX-FileCopyrightText: Copyright OpenBMC Authors
Marc Olberding1e17db52025-08-27 12:25:28 -07003
4#pragma once
5
Marc Olberding5d50e522025-09-03 18:23:32 -07006#include <cstdint>
Marc Olberding1e17db52025-08-27 12:25:28 -07007#include <string>
8
9namespace i2c
10{
11
12void rebind_controller(const std::string_view number);
13void new_device(unsigned int bus, unsigned int address,
14 std::string_view device_type);
Marc Olberding5d50e522025-09-03 18:23:32 -070015
16// a simple RAII wrapper for raw i2c comms
17struct RawDevice
18{
19 RawDevice(size_t bus, uint8_t address);
20 ~RawDevice();
21 RawDevice(const RawDevice&) = delete;
22 RawDevice& operator=(const RawDevice&) = delete;
23 RawDevice& operator=(RawDevice&&) = default;
24 RawDevice(RawDevice&&) = default;
25
26 int read_byte(uint8_t reg, uint8_t& val);
27
28 int fd;
29};
Marc Olberding1e17db52025-08-27 12:25:28 -070030} // namespace i2c