Revert "hoc-clk: add live vdd2, live boost clock and basic pwm dimming"
This reverts commit 15b7df8ef1.
This commit is contained in:
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/i2c/i2c_types.hpp>
|
||||
|
||||
namespace ams::i2c::driver::board::nintendo::nx {
|
||||
|
||||
void Initialize();
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/i2c/i2c_types.hpp>
|
||||
|
||||
namespace ams::i2c::driver {
|
||||
|
||||
namespace impl {
|
||||
|
||||
constexpr inline size_t I2cSessionSize = 0x60;
|
||||
constexpr inline size_t I2cSessionAlign = 8;
|
||||
struct alignas(I2cSessionAlign) I2cSessionImplPadded;
|
||||
|
||||
}
|
||||
|
||||
struct I2cSession {
|
||||
util::TypedStorage<impl::I2cSessionImplPadded, impl::I2cSessionSize, impl::I2cSessionAlign> _impl;
|
||||
};
|
||||
|
||||
Result OpenSession(I2cSession *out, DeviceCode device_code);
|
||||
void CloseSession(I2cSession &session);
|
||||
|
||||
Result Send(I2cSession &session, const void *src, size_t src_size, TransactionOption option);
|
||||
Result Receive(void *dst, size_t dst_size, I2cSession &session, TransactionOption option);
|
||||
|
||||
Result ExecuteCommandList(void *dst, size_t dst_size, I2cSession &session, const void *src, size_t src_size);
|
||||
|
||||
Result SetRetryPolicy(I2cSession &session, int max_retry_count, int retry_interval_us);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/i2c/i2c_types.hpp>
|
||||
|
||||
namespace ams::i2c::driver {
|
||||
|
||||
void Initialize();
|
||||
void Finalize();
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/i2c/i2c_types.hpp>
|
||||
#include <stratosphere/i2c/driver/i2c_i2c_device_property.hpp>
|
||||
#include <stratosphere/i2c/driver/i2c_i_i2c_driver.hpp>
|
||||
|
||||
namespace ams::i2c::driver {
|
||||
|
||||
void RegisterDriver(II2cDriver *driver);
|
||||
void UnregisterDriver(II2cDriver *driver);
|
||||
|
||||
Result RegisterDeviceCode(DeviceCode device_code, I2cDeviceProperty *device);
|
||||
bool UnregisterDeviceCode(DeviceCode device_code);
|
||||
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/i2c/i2c_types.hpp>
|
||||
#include <stratosphere/ddsf.hpp>
|
||||
|
||||
namespace ams::i2c::driver {
|
||||
|
||||
class I2cDeviceProperty : public ::ams::ddsf::IDevice {
|
||||
NON_COPYABLE(I2cDeviceProperty);
|
||||
NON_MOVEABLE(I2cDeviceProperty);
|
||||
AMS_DDSF_CASTABLE_TRAITS(ams::i2c::driver::I2cDeviceProperty, ::ams::ddsf::IDevice);
|
||||
private:
|
||||
u16 m_address;
|
||||
AddressingMode m_addressing_mode;
|
||||
util::IntrusiveListNode m_device_property_list_node;
|
||||
public:
|
||||
using DevicePropertyListTraits = util::IntrusiveListMemberTraits<&I2cDeviceProperty::m_device_property_list_node>;
|
||||
using DevicePropertyList = typename DevicePropertyListTraits::ListType;
|
||||
friend class util::IntrusiveList<I2cDeviceProperty, util::IntrusiveListMemberTraits<&I2cDeviceProperty::m_device_property_list_node>>;
|
||||
public:
|
||||
I2cDeviceProperty() : IDevice(false), m_address(0), m_addressing_mode(AddressingMode_SevenBit), m_device_property_list_node() { /* ... */ }
|
||||
I2cDeviceProperty(u16 addr, AddressingMode m) : IDevice(false), m_address(addr), m_addressing_mode(m), m_device_property_list_node() { /* ... */ }
|
||||
|
||||
virtual ~I2cDeviceProperty() { /* ... */ }
|
||||
|
||||
u16 GetAddress() const {
|
||||
return m_address;
|
||||
}
|
||||
|
||||
AddressingMode GetAddressingMode() const {
|
||||
return m_addressing_mode;
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/i2c/i2c_types.hpp>
|
||||
#include <stratosphere/ddsf.hpp>
|
||||
|
||||
namespace ams::i2c::driver {
|
||||
|
||||
class I2cDeviceProperty;
|
||||
|
||||
class II2cDriver : public ::ams::ddsf::IDriver {
|
||||
NON_COPYABLE(II2cDriver);
|
||||
NON_MOVEABLE(II2cDriver);
|
||||
AMS_DDSF_CASTABLE_TRAITS(ams::i2c::driver::II2cDriver, ::ams::ddsf::IDriver);
|
||||
public:
|
||||
II2cDriver() : IDriver() { /* ... */ }
|
||||
virtual ~II2cDriver() { /* ... */ }
|
||||
|
||||
virtual void InitializeDriver() = 0;
|
||||
virtual void FinalizeDriver() = 0;
|
||||
|
||||
virtual Result InitializeDevice(I2cDeviceProperty *device) = 0;
|
||||
virtual void FinalizeDevice(I2cDeviceProperty *device) = 0;
|
||||
|
||||
virtual Result Send(I2cDeviceProperty *device, const void *src, size_t src_size, TransactionOption option) = 0;
|
||||
virtual Result Receive(void *dst, size_t dst_size, I2cDeviceProperty *device, TransactionOption option) = 0;
|
||||
|
||||
virtual os::SdkMutex &GetTransactionOrderMutex() = 0;
|
||||
|
||||
virtual void SuspendBus() = 0;
|
||||
virtual void SuspendPowerBus() = 0;
|
||||
|
||||
virtual void ResumeBus() = 0;
|
||||
virtual void ResumePowerBus() = 0;
|
||||
|
||||
virtual const DeviceCode &GetDeviceCode() const = 0;
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/i2c/i2c_types.hpp>
|
||||
#include <stratosphere/i2c/driver/i2c_i_i2c_driver.hpp>
|
||||
#include <stratosphere/i2c/driver/i2c_i2c_device_property.hpp>
|
||||
|
||||
#if defined(ATMOSPHERE_BOARD_NINTENDO_NX)
|
||||
|
||||
#include <stratosphere/i2c/driver/board/nintendo/nx/i2c_driver_api.hpp>
|
||||
|
||||
namespace ams::i2c::driver::board {
|
||||
|
||||
using namespace ams::i2c::driver::board::nintendo::nx;
|
||||
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
// TODO: #error "Unknown board for ams::i2c::driver::"
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/i2c/driver/i2c_bus_api.hpp>
|
||||
#include <stratosphere/ddsf.hpp>
|
||||
|
||||
namespace ams::i2c::driver {
|
||||
|
||||
class I2cDeviceProperty;
|
||||
|
||||
}
|
||||
|
||||
namespace ams::i2c::driver::impl {
|
||||
|
||||
class I2cSessionImpl : public ::ams::ddsf::ISession {
|
||||
NON_COPYABLE(I2cSessionImpl);
|
||||
NON_MOVEABLE(I2cSessionImpl);
|
||||
AMS_DDSF_CASTABLE_TRAITS(ams::i2c::driver::impl::I2cSessionImpl, ::ams::ddsf::ISession);
|
||||
private:
|
||||
enum class Command {
|
||||
Send = 0,
|
||||
Receive = 1,
|
||||
};
|
||||
private:
|
||||
TimeSpan m_retry_interval;
|
||||
int m_max_retry_count;
|
||||
private:
|
||||
Result SendHandler(const u8 **cur_cmd, u8 **cur_dst);
|
||||
Result ReceiveHandler(const u8 **cur_cmd, u8 **cur_dst);
|
||||
Result ExtensionHandler(const u8 **cur_cmd, u8 **cur_dst);
|
||||
|
||||
Result ExecuteTransactionWithRetry(void *dst, Command command, const void *src, size_t size, TransactionOption option);
|
||||
public:
|
||||
I2cSessionImpl(int mr, TimeSpan rt) : m_retry_interval(rt), m_max_retry_count(mr) { /* ... */ }
|
||||
|
||||
~I2cSessionImpl() {
|
||||
this->Close();
|
||||
}
|
||||
|
||||
Result Open(I2cDeviceProperty *device, ddsf::AccessMode access_mode);
|
||||
void Close();
|
||||
|
||||
Result Send(const void *src, size_t src_size, TransactionOption option);
|
||||
Result Receive(void *dst, size_t dst_size, TransactionOption option);
|
||||
Result ExecuteCommandList(void *dst, size_t dst_size, const void *src, size_t src_size);
|
||||
Result SetRetryPolicy(int mr, int interval_us);
|
||||
};
|
||||
static_assert( sizeof(I2cSessionImpl) <= I2cSessionSize);
|
||||
static_assert(alignof(I2cSessionImpl) <= I2cSessionAlign);
|
||||
|
||||
struct alignas(I2cSessionAlign) I2cSessionImplPadded {
|
||||
I2cSessionImpl _impl;
|
||||
u8 _padding[I2cSessionSize - sizeof(I2cSessionImpl)];
|
||||
};
|
||||
static_assert( sizeof(I2cSessionImplPadded) == I2cSessionSize);
|
||||
static_assert(alignof(I2cSessionImplPadded) == I2cSessionAlign);
|
||||
|
||||
ALWAYS_INLINE I2cSessionImpl &GetI2cSessionImpl(I2cSession &session) {
|
||||
return GetReference(session._impl)._impl;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE const I2cSessionImpl &GetI2cSessionImpl(const I2cSession &session) {
|
||||
return GetReference(session._impl)._impl;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE I2cSessionImpl &GetOpenI2cSessionImpl(I2cSession &session) {
|
||||
auto &ref = GetReference(session._impl)._impl;
|
||||
AMS_ASSERT(ref.IsOpen());
|
||||
return ref;
|
||||
}
|
||||
|
||||
ALWAYS_INLINE const I2cSessionImpl &GetOpenI2cSessionImpl(const I2cSession &session) {
|
||||
const auto &ref = GetReference(session._impl)._impl;
|
||||
AMS_ASSERT(ref.IsOpen());
|
||||
return ref;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/i2c/i2c_types.hpp>
|
||||
#include <stratosphere/i2c/sf/i2c_sf_i_manager.hpp>
|
||||
|
||||
namespace ams::i2c {
|
||||
|
||||
void InitializeWith(ams::sf::SharedPointer<i2c::sf::IManager> sp, ams::sf::SharedPointer<i2c::sf::IManager> sp_pcv);
|
||||
void InitializeEmpty();
|
||||
|
||||
void Finalize();
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/i2c/i2c_types.hpp>
|
||||
|
||||
namespace ams::i2c {
|
||||
|
||||
struct I2cSession {
|
||||
void *_session;
|
||||
};
|
||||
|
||||
Result OpenSession(I2cSession *out, DeviceCode device_code);
|
||||
void CloseSession(I2cSession &session);
|
||||
|
||||
Result Send(const I2cSession &session, const void *src, size_t src_size, TransactionOption option);
|
||||
Result Receive(void *dst, size_t dst_size, const I2cSession &session, TransactionOption option);
|
||||
|
||||
Result ExecuteCommandList(void *dst, size_t dst_size, const I2cSession &session, const void *src, size_t src_size);
|
||||
|
||||
void SetRetryPolicy(const I2cSession &session, int max_retry_count, int retry_interval_us);
|
||||
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/i2c/i2c_types.hpp>
|
||||
|
||||
namespace ams::i2c {
|
||||
|
||||
constexpr inline size_t CommandListLengthMax = 0x100;
|
||||
constexpr inline size_t CommandListReceiveCommandSize = 2;
|
||||
constexpr inline size_t CommandListSendCommandSize = 2;
|
||||
constexpr inline size_t CommandListSleepCommandSize = 2;
|
||||
|
||||
class CommandListFormatter {
|
||||
NON_COPYABLE(CommandListFormatter);
|
||||
NON_MOVEABLE(CommandListFormatter);
|
||||
private:
|
||||
size_t m_current_index;
|
||||
size_t m_command_list_length;
|
||||
void *m_command_list;
|
||||
private:
|
||||
Result IsEnqueueAble(size_t sz) const;
|
||||
public:
|
||||
CommandListFormatter(void *p, size_t sz) : m_current_index(0), m_command_list_length(sz), m_command_list(p) {
|
||||
AMS_ABORT_UNLESS(m_command_list_length <= CommandListLengthMax);
|
||||
}
|
||||
|
||||
~CommandListFormatter() { m_command_list = nullptr; }
|
||||
|
||||
size_t GetCurrentLength() const { return m_current_index; }
|
||||
const void *GetListHead() const { return m_command_list; }
|
||||
|
||||
Result EnqueueReceiveCommand(i2c::TransactionOption option, size_t size);
|
||||
Result EnqueueSendCommand(i2c::TransactionOption option, const void *src, size_t size);
|
||||
Result EnqueueSleepCommand(int us);
|
||||
};
|
||||
|
||||
}
|
||||
@@ -1,254 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/i2c/i2c_types.hpp>
|
||||
|
||||
namespace ams::i2c {
|
||||
|
||||
enum I2cBus {
|
||||
I2cBus_I2c1 = 0,
|
||||
I2cBus_I2c2 = 1,
|
||||
I2cBus_I2c3 = 2,
|
||||
I2cBus_I2c4 = 3,
|
||||
I2cBus_I2c5 = 4,
|
||||
I2cBus_I2c6 = 5,
|
||||
};
|
||||
|
||||
constexpr inline const DeviceCode DeviceCode_I2c1 = 0x02000001;
|
||||
constexpr inline const DeviceCode DeviceCode_I2c2 = 0x02000002;
|
||||
constexpr inline const DeviceCode DeviceCode_I2c3 = 0x02000003;
|
||||
constexpr inline const DeviceCode DeviceCode_I2c4 = 0x02000004;
|
||||
constexpr inline const DeviceCode DeviceCode_I2c5 = 0x02000005;
|
||||
constexpr inline const DeviceCode DeviceCode_I2c6 = 0x02000006;
|
||||
|
||||
constexpr inline DeviceCode ConvertToDeviceCode(I2cBus bus) {
|
||||
switch (bus) {
|
||||
case I2cBus_I2c1: return DeviceCode_I2c1;
|
||||
case I2cBus_I2c2: return DeviceCode_I2c2;
|
||||
case I2cBus_I2c3: return DeviceCode_I2c3;
|
||||
case I2cBus_I2c4: return DeviceCode_I2c4;
|
||||
case I2cBus_I2c5: return DeviceCode_I2c5;
|
||||
case I2cBus_I2c6: return DeviceCode_I2c6;
|
||||
AMS_UNREACHABLE_DEFAULT_CASE();
|
||||
}
|
||||
}
|
||||
|
||||
constexpr inline DeviceCode ConvertToI2cBus(DeviceCode dc) {
|
||||
switch (dc.GetInternalValue()) {
|
||||
case DeviceCode_I2c1.GetInternalValue(): return I2cBus_I2c1;
|
||||
case DeviceCode_I2c2.GetInternalValue(): return I2cBus_I2c2;
|
||||
case DeviceCode_I2c3.GetInternalValue(): return I2cBus_I2c3;
|
||||
case DeviceCode_I2c4.GetInternalValue(): return I2cBus_I2c4;
|
||||
case DeviceCode_I2c5.GetInternalValue(): return I2cBus_I2c5;
|
||||
case DeviceCode_I2c6.GetInternalValue(): return I2cBus_I2c6;
|
||||
AMS_UNREACHABLE_DEFAULT_CASE();
|
||||
}
|
||||
}
|
||||
|
||||
enum I2cDevice : u32 {
|
||||
I2cDevice_ClassicController = 0,
|
||||
I2cDevice_Ftm3bd56 = 1,
|
||||
I2cDevice_Tmp451 = 2,
|
||||
I2cDevice_Nct72 = 3,
|
||||
I2cDevice_Alc5639 = 4,
|
||||
I2cDevice_Max77620Rtc = 5,
|
||||
I2cDevice_Max77620Pmic = 6,
|
||||
I2cDevice_Max77621Cpu = 7,
|
||||
I2cDevice_Max77621Gpu = 8,
|
||||
I2cDevice_Bq24193 = 9,
|
||||
I2cDevice_Max17050 = 10,
|
||||
I2cDevice_Bm92t30mwv = 11,
|
||||
I2cDevice_Ina226Vdd15v0Hb = 12,
|
||||
|
||||
I2cDevice_Ina226VsysCpuDs = 13,
|
||||
I2cDevice_Ina226VddCpuAp = 13,
|
||||
|
||||
I2cDevice_Ina226VsysGpuDs = 14,
|
||||
I2cDevice_Ina226VddGpuAp = 14,
|
||||
|
||||
I2cDevice_Ina226VsysDdrDs = 15,
|
||||
I2cDevice_Ina226VddDdr1V1Pmic = 15,
|
||||
|
||||
I2cDevice_Ina226VsysAp = 16,
|
||||
I2cDevice_Ina226VsysBlDs = 17,
|
||||
I2cDevice_Bh1730 = 18,
|
||||
|
||||
I2cDevice_Ina226VsysCore = 19,
|
||||
I2cDevice_Ina226VddCoreAp = 19,
|
||||
|
||||
I2cDevice_Ina226Soc1V8 = 20,
|
||||
I2cDevice_Ina226VddSoc1V8 = 20,
|
||||
|
||||
I2cDevice_Ina226Lpddr1V8 = 21,
|
||||
I2cDevice_Ina226Vdd1V8 = 21,
|
||||
|
||||
I2cDevice_Ina226Reg1V32 = 22,
|
||||
I2cDevice_Ina226Vdd3V3Sys = 23,
|
||||
I2cDevice_HdmiDdc = 24,
|
||||
I2cDevice_HdmiScdc = 25,
|
||||
I2cDevice_HdmiHdcp = 26,
|
||||
I2cDevice_Fan53528 = 27,
|
||||
I2cDevice_Max77812_3 = 28,
|
||||
I2cDevice_Max77812_2 = 29,
|
||||
I2cDevice_Ina226VddDdr0V6 = 30,
|
||||
I2cDevice_HoagNfcIc = 31, /* TODO */
|
||||
I2cDevice_PmicUnknownAula_4_18 = 32, /* TODO */
|
||||
};
|
||||
|
||||
/* TODO: Better place for this? */
|
||||
constexpr inline const DeviceCode DeviceCode_ClassicController = 0x350000C9;
|
||||
constexpr inline const DeviceCode DeviceCode_Ftm3bd56 = 0x35000033;
|
||||
constexpr inline const DeviceCode DeviceCode_Tmp451 = 0x3E000001;
|
||||
constexpr inline const DeviceCode DeviceCode_Nct72 = 0x3E000001;
|
||||
constexpr inline const DeviceCode DeviceCode_Alc5639 = 0x33000001;
|
||||
constexpr inline const DeviceCode DeviceCode_Max77620Rtc = 0x3B000001;
|
||||
constexpr inline const DeviceCode DeviceCode_Max77620Pmic = 0x3A000001;
|
||||
constexpr inline const DeviceCode DeviceCode_Max77621Cpu = 0x3A000003;
|
||||
constexpr inline const DeviceCode DeviceCode_Max77621Gpu = 0x3A000004;
|
||||
constexpr inline const DeviceCode DeviceCode_Bq24193 = 0x39000001;
|
||||
constexpr inline const DeviceCode DeviceCode_Max17050 = 0x39000033;
|
||||
constexpr inline const DeviceCode DeviceCode_Bm92t30mwv = 0x040000C9;
|
||||
constexpr inline const DeviceCode DeviceCode_Ina226Vdd15v0Hb = 0x3F000401;
|
||||
|
||||
constexpr inline const DeviceCode DeviceCode_Ina226VsysCpuDs = 0x3F000001;
|
||||
constexpr inline const DeviceCode DeviceCode_Ina226VddCpuAp = 0x3F000001;
|
||||
|
||||
constexpr inline const DeviceCode DeviceCode_Ina226VsysGpuDs = 0x3F000002;
|
||||
constexpr inline const DeviceCode DeviceCode_Ina226VddGpuAp = 0x3F000002;
|
||||
|
||||
constexpr inline const DeviceCode DeviceCode_Ina226VsysDdrDs = 0x3F000003;
|
||||
constexpr inline const DeviceCode DeviceCode_Ina226VddDdr1V1Pmi = 0x3F000003;
|
||||
|
||||
constexpr inline const DeviceCode DeviceCode_Ina226VsysAp = 0x3F000402;
|
||||
constexpr inline const DeviceCode DeviceCode_Ina226VsysBlDs = 0x3F000403;
|
||||
constexpr inline const DeviceCode DeviceCode_Bh1730 = 0x35000047;
|
||||
|
||||
constexpr inline const DeviceCode DeviceCode_Ina226VsysCore = 0x3F000404;
|
||||
constexpr inline const DeviceCode DeviceCode_Ina226VddCoreAp = 0x3F000404;
|
||||
|
||||
constexpr inline const DeviceCode DeviceCode_Ina226Soc1V8 = 0x3F000405;
|
||||
constexpr inline const DeviceCode DeviceCode_Ina226VddSoc1V8 = 0x3F000405;
|
||||
|
||||
constexpr inline const DeviceCode DeviceCode_Ina226Lpddr1V8 = 0x3F000406;
|
||||
constexpr inline const DeviceCode DeviceCode_Ina226Vdd1V8 = 0x3F000406;
|
||||
|
||||
constexpr inline const DeviceCode DeviceCode_Ina226Reg1V32 = 0x3F000407;
|
||||
constexpr inline const DeviceCode DeviceCode_Ina226Vdd3V3Sys = 0x3F000408;
|
||||
constexpr inline const DeviceCode DeviceCode_HdmiDdc = 0x34000001;
|
||||
constexpr inline const DeviceCode DeviceCode_HdmiScdc = 0x34000002;
|
||||
constexpr inline const DeviceCode DeviceCode_HdmiHdcp = 0x34000003;
|
||||
constexpr inline const DeviceCode DeviceCode_Fan53528 = 0x3A000005;
|
||||
constexpr inline const DeviceCode DeviceCode_Max77812_3 = 0x3A000002;
|
||||
constexpr inline const DeviceCode DeviceCode_Max77812_2 = 0x3A000006;
|
||||
constexpr inline const DeviceCode DeviceCode_Ina226VddDdr0V6 = 0x3F000409;
|
||||
constexpr inline const DeviceCode DeviceCode_HoagNfcIc = 0x36000001;
|
||||
constexpr inline const DeviceCode DeviceCode_PmicUnknownAula_4_18 = 0x3A000007;
|
||||
|
||||
constexpr inline DeviceCode ConvertToDeviceCode(I2cDevice dv) {
|
||||
switch (dv) {
|
||||
case I2cDevice_ClassicController: return DeviceCode_ClassicController;
|
||||
case I2cDevice_Ftm3bd56: return DeviceCode_Ftm3bd56;
|
||||
case I2cDevice_Tmp451: return DeviceCode_Tmp451;
|
||||
case I2cDevice_Nct72: return DeviceCode_Nct72;
|
||||
case I2cDevice_Alc5639: return DeviceCode_Alc5639;
|
||||
case I2cDevice_Max77620Rtc: return DeviceCode_Max77620Rtc;
|
||||
case I2cDevice_Max77620Pmic: return DeviceCode_Max77620Pmic;
|
||||
case I2cDevice_Max77621Cpu: return DeviceCode_Max77621Cpu;
|
||||
case I2cDevice_Max77621Gpu: return DeviceCode_Max77621Gpu;
|
||||
case I2cDevice_Bq24193: return DeviceCode_Bq24193;
|
||||
case I2cDevice_Max17050: return DeviceCode_Max17050;
|
||||
case I2cDevice_Bm92t30mwv: return DeviceCode_Bm92t30mwv;
|
||||
case I2cDevice_Ina226Vdd15v0Hb: return DeviceCode_Ina226Vdd15v0Hb;
|
||||
case I2cDevice_Ina226VsysCpuDs: return DeviceCode_Ina226VsysCpuDs;
|
||||
case I2cDevice_Ina226VsysGpuDs: return DeviceCode_Ina226VsysGpuDs;
|
||||
case I2cDevice_Ina226VsysDdrDs: return DeviceCode_Ina226VsysDdrDs;
|
||||
case I2cDevice_Ina226VsysAp: return DeviceCode_Ina226VsysAp;
|
||||
case I2cDevice_Ina226VsysBlDs: return DeviceCode_Ina226VsysBlDs;
|
||||
case I2cDevice_Bh1730: return DeviceCode_Bh1730;
|
||||
case I2cDevice_Ina226VsysCore: return DeviceCode_Ina226VsysCore;
|
||||
case I2cDevice_Ina226Soc1V8: return DeviceCode_Ina226Soc1V8;
|
||||
case I2cDevice_Ina226Lpddr1V8: return DeviceCode_Ina226Lpddr1V8;
|
||||
case I2cDevice_Ina226Reg1V32: return DeviceCode_Ina226Reg1V32;
|
||||
case I2cDevice_Ina226Vdd3V3Sys: return DeviceCode_Ina226Vdd3V3Sys;
|
||||
case I2cDevice_HdmiDdc: return DeviceCode_HdmiDdc;
|
||||
case I2cDevice_HdmiScdc: return DeviceCode_HdmiScdc;
|
||||
case I2cDevice_HdmiHdcp: return DeviceCode_HdmiHdcp;
|
||||
case I2cDevice_Fan53528: return DeviceCode_Fan53528;
|
||||
case I2cDevice_Max77812_3: return DeviceCode_Max77812_3;
|
||||
case I2cDevice_Max77812_2: return DeviceCode_Max77812_2;
|
||||
case I2cDevice_Ina226VddDdr0V6: return DeviceCode_Ina226VddDdr0V6;
|
||||
case I2cDevice_HoagNfcIc: return DeviceCode_HoagNfcIc;
|
||||
case I2cDevice_PmicUnknownAula_4_18: return DeviceCode_PmicUnknownAula_4_18;
|
||||
AMS_UNREACHABLE_DEFAULT_CASE();
|
||||
}
|
||||
}
|
||||
|
||||
constexpr inline I2cDevice ConvertToI2cDevice(DeviceCode dc) {
|
||||
switch (dc.GetInternalValue()) {
|
||||
case DeviceCode_ClassicController .GetInternalValue(): return I2cDevice_ClassicController;
|
||||
case DeviceCode_Ftm3bd56 .GetInternalValue(): return I2cDevice_Ftm3bd56;
|
||||
case DeviceCode_Tmp451 .GetInternalValue(): return I2cDevice_Tmp451;
|
||||
/* case DeviceCode_Nct72 .GetInternalValue(): return I2cDevice_Nct72; */
|
||||
case DeviceCode_Alc5639 .GetInternalValue(): return I2cDevice_Alc5639;
|
||||
case DeviceCode_Max77620Rtc .GetInternalValue(): return I2cDevice_Max77620Rtc;
|
||||
case DeviceCode_Max77620Pmic .GetInternalValue(): return I2cDevice_Max77620Pmic;
|
||||
case DeviceCode_Max77621Cpu .GetInternalValue(): return I2cDevice_Max77621Cpu;
|
||||
case DeviceCode_Max77621Gpu .GetInternalValue(): return I2cDevice_Max77621Gpu;
|
||||
case DeviceCode_Bq24193 .GetInternalValue(): return I2cDevice_Bq24193;
|
||||
case DeviceCode_Max17050 .GetInternalValue(): return I2cDevice_Max17050;
|
||||
case DeviceCode_Bm92t30mwv .GetInternalValue(): return I2cDevice_Bm92t30mwv;
|
||||
case DeviceCode_Ina226Vdd15v0Hb .GetInternalValue(): return I2cDevice_Ina226Vdd15v0Hb;
|
||||
case DeviceCode_Ina226VsysCpuDs .GetInternalValue(): return I2cDevice_Ina226VsysCpuDs;
|
||||
case DeviceCode_Ina226VsysGpuDs .GetInternalValue(): return I2cDevice_Ina226VsysGpuDs;
|
||||
case DeviceCode_Ina226VsysDdrDs .GetInternalValue(): return I2cDevice_Ina226VsysDdrDs;
|
||||
case DeviceCode_Ina226VsysAp .GetInternalValue(): return I2cDevice_Ina226VsysAp;
|
||||
case DeviceCode_Ina226VsysBlDs .GetInternalValue(): return I2cDevice_Ina226VsysBlDs;
|
||||
case DeviceCode_Bh1730 .GetInternalValue(): return I2cDevice_Bh1730;
|
||||
case DeviceCode_Ina226VsysCore .GetInternalValue(): return I2cDevice_Ina226VsysCore;
|
||||
case DeviceCode_Ina226Soc1V8 .GetInternalValue(): return I2cDevice_Ina226Soc1V8;
|
||||
case DeviceCode_Ina226Lpddr1V8 .GetInternalValue(): return I2cDevice_Ina226Lpddr1V8;
|
||||
case DeviceCode_Ina226Reg1V32 .GetInternalValue(): return I2cDevice_Ina226Reg1V32;
|
||||
case DeviceCode_Ina226Vdd3V3Sys .GetInternalValue(): return I2cDevice_Ina226Vdd3V3Sys;
|
||||
case DeviceCode_HdmiDdc .GetInternalValue(): return I2cDevice_HdmiDdc;
|
||||
case DeviceCode_HdmiScdc .GetInternalValue(): return I2cDevice_HdmiScdc;
|
||||
case DeviceCode_HdmiHdcp .GetInternalValue(): return I2cDevice_HdmiHdcp;
|
||||
case DeviceCode_Fan53528 .GetInternalValue(): return I2cDevice_Fan53528;
|
||||
case DeviceCode_Max77812_3 .GetInternalValue(): return I2cDevice_Max77812_3;
|
||||
case DeviceCode_Max77812_2 .GetInternalValue(): return I2cDevice_Max77812_2;
|
||||
case DeviceCode_Ina226VddDdr0V6 .GetInternalValue(): return I2cDevice_Ina226VddDdr0V6;
|
||||
case DeviceCode_HoagNfcIc .GetInternalValue(): return I2cDevice_HoagNfcIc;
|
||||
case DeviceCode_PmicUnknownAula_4_18.GetInternalValue(): return I2cDevice_PmicUnknownAula_4_18;
|
||||
AMS_UNREACHABLE_DEFAULT_CASE();
|
||||
}
|
||||
}
|
||||
|
||||
constexpr bool IsPowerBusDeviceCode(DeviceCode device_code) {
|
||||
switch (device_code.GetInternalValue()) {
|
||||
case DeviceCode_Max77620Pmic.GetInternalValue():
|
||||
case DeviceCode_Max77812_3 .GetInternalValue():
|
||||
case DeviceCode_Max77621Cpu .GetInternalValue():
|
||||
case DeviceCode_Max77621Gpu .GetInternalValue():
|
||||
case DeviceCode_Fan53528 .GetInternalValue():
|
||||
case DeviceCode_Max77812_2 .GetInternalValue():
|
||||
case DeviceCode_Max77620Rtc .GetInternalValue():
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/i2c/i2c_types.hpp>
|
||||
|
||||
namespace ams::i2c {
|
||||
|
||||
enum I2cBus {
|
||||
I2cBus_I2c1 = 0,
|
||||
};
|
||||
|
||||
constexpr inline const DeviceCode DeviceCode_I2c1 = 0x02000001;
|
||||
|
||||
constexpr inline DeviceCode ConvertToDeviceCode(I2cBus bus) {
|
||||
switch (bus) {
|
||||
case I2cBus_I2c1: return DeviceCode_I2c1;
|
||||
AMS_UNREACHABLE_DEFAULT_CASE();
|
||||
}
|
||||
}
|
||||
|
||||
constexpr inline DeviceCode ConvertToI2cBus(DeviceCode dc) {
|
||||
switch (dc.GetInternalValue()) {
|
||||
case DeviceCode_I2c1.GetInternalValue(): return I2cBus_I2c1;
|
||||
AMS_UNREACHABLE_DEFAULT_CASE();
|
||||
}
|
||||
}
|
||||
|
||||
enum I2cDevice : u32 {
|
||||
I2cDevice_ClassicController = 0,
|
||||
};
|
||||
|
||||
/* TODO: Better place for this? */
|
||||
constexpr inline const DeviceCode DeviceCode_ClassicController = 0x350000C9;
|
||||
|
||||
constexpr inline DeviceCode ConvertToDeviceCode(I2cDevice dv) {
|
||||
switch (dv) {
|
||||
case I2cDevice_ClassicController: return DeviceCode_ClassicController;
|
||||
AMS_UNREACHABLE_DEFAULT_CASE();
|
||||
}
|
||||
}
|
||||
|
||||
constexpr inline I2cDevice ConvertToI2cDevice(DeviceCode dc) {
|
||||
switch (dc.GetInternalValue()) {
|
||||
case DeviceCode_ClassicController.GetInternalValue(): return I2cDevice_ClassicController;
|
||||
AMS_UNREACHABLE_DEFAULT_CASE();
|
||||
}
|
||||
}
|
||||
|
||||
constexpr bool IsPowerBusDeviceCode(DeviceCode device_code) {
|
||||
switch (device_code.GetInternalValue()) {
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/i2c/i2c_types.hpp>
|
||||
#include <stratosphere/i2c/i2c_command_list_formatter.hpp>
|
||||
#include <stratosphere/i2c/i2c_bus_api.hpp>
|
||||
|
||||
namespace ams::i2c {
|
||||
|
||||
template<typename RegType> requires std::unsigned_integral<RegType>
|
||||
Result ReadSingleRegister(const I2cSession &session, u8 address, RegType *out) {
|
||||
/* Check pre-conditions. */
|
||||
AMS_ABORT_UNLESS(out != nullptr);
|
||||
|
||||
constexpr i2c::TransactionOption StartOption = i2c::TransactionOption_StartCondition;
|
||||
constexpr i2c::TransactionOption StopOption = static_cast<i2c::TransactionOption>(i2c::TransactionOption_StartCondition | i2c::TransactionOption_StopCondition);
|
||||
|
||||
u8 cmd_list[CommandListLengthMax];
|
||||
i2c::CommandListFormatter formatter(cmd_list, sizeof(cmd_list));
|
||||
|
||||
R_TRY(formatter.EnqueueSendCommand(StartOption, std::addressof(address), sizeof(address)));
|
||||
R_TRY(formatter.EnqueueReceiveCommand(StopOption, sizeof(*out)));
|
||||
|
||||
R_TRY(i2c::ExecuteCommandList(out, sizeof(*out), session, cmd_list, formatter.GetCurrentLength()));
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
template<typename RegType> requires std::unsigned_integral<RegType>
|
||||
Result WriteSingleRegister(const I2cSession &session, u8 address, RegType value) {
|
||||
/* Prepare buffer. */
|
||||
u8 buf[sizeof(address) + sizeof(value)];
|
||||
std::memcpy(buf + 0, std::addressof(address), sizeof(address));
|
||||
std::memcpy(buf + sizeof(address), std::addressof(value), sizeof(value));
|
||||
|
||||
constexpr i2c::TransactionOption StopOption = static_cast<i2c::TransactionOption>(i2c::TransactionOption_StartCondition | i2c::TransactionOption_StopCondition);
|
||||
R_TRY(i2c::Send(session, buf, sizeof(buf), StopOption));
|
||||
|
||||
R_SUCCEED();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/i2c/i2c_types.hpp>
|
||||
|
||||
#if defined(ATMOSPHERE_BOARD_NINTENDO_NX)
|
||||
#include <stratosphere/i2c/i2c_device_name.board.nintendo_nx.hpp>
|
||||
#else
|
||||
#include <stratosphere/i2c/i2c_device_name.generic.hpp>
|
||||
#endif
|
||||
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
|
||||
namespace ams::i2c {
|
||||
|
||||
enum TransactionOption : u32 {
|
||||
TransactionOption_StartCondition = (1u << 0),
|
||||
TransactionOption_StopCondition = (1u << 1),
|
||||
TransactionOption_MaxBits = (1u << 30),
|
||||
};
|
||||
|
||||
enum AddressingMode : u32 {
|
||||
AddressingMode_SevenBit = 0,
|
||||
};
|
||||
|
||||
enum SpeedMode : u32 {
|
||||
SpeedMode_Standard = 100000,
|
||||
SpeedMode_Fast = 400000,
|
||||
SpeedMode_FastPlus = 1000000,
|
||||
SpeedMode_HighSpeed = 3400000,
|
||||
};
|
||||
|
||||
using I2cCommand = u8;
|
||||
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/i2c/i2c_types.hpp>
|
||||
#include <stratosphere/i2c/sf/i2c_sf_i_manager.hpp>
|
||||
|
||||
namespace ams::i2c::server {
|
||||
|
||||
ams::sf::SharedPointer<i2c::sf::IManager> GetServiceObject();
|
||||
ams::sf::SharedPointer<i2c::sf::IManager> GetServiceObjectPowerBus();
|
||||
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/ddsf/ddsf_types.hpp>
|
||||
#include <stratosphere/i2c/i2c_select_device_name.hpp>
|
||||
#include <stratosphere/i2c/sf/i2c_sf_i_session.hpp>
|
||||
|
||||
#define AMS_I2C_I_MANAGER_INTERFACE_INFO(C, H) \
|
||||
AMS_SF_METHOD_INFO(C, H, 0, Result, OpenSessionForDev, (ams::sf::Out<ams::sf::SharedPointer<i2c::sf::ISession>> out, s32 bus_idx, u16 slave_address, i2c::AddressingMode addressing_mode, i2c::SpeedMode speed_mode), (out, bus_idx, slave_address, addressing_mode, speed_mode) ) \
|
||||
AMS_SF_METHOD_INFO(C, H, 1, Result, OpenSession, (ams::sf::Out<ams::sf::SharedPointer<i2c::sf::ISession>> out, i2c::I2cDevice device), (out, device) ) \
|
||||
AMS_SF_METHOD_INFO(C, H, 2, Result, HasDevice, (ams::sf::Out<bool> out, i2c::I2cDevice device), (out, device), hos::Version_Min, hos::Version_5_1_0) \
|
||||
AMS_SF_METHOD_INFO(C, H, 3, Result, HasDeviceForDev, (ams::sf::Out<bool> out, i2c::I2cDevice device), (out, device), hos::Version_Min, hos::Version_5_1_0) \
|
||||
AMS_SF_METHOD_INFO(C, H, 4, Result, OpenSession2, (ams::sf::Out<ams::sf::SharedPointer<i2c::sf::ISession>> out, DeviceCode device_code), (out, device_code), hos::Version_6_0_0 )
|
||||
|
||||
AMS_SF_DEFINE_INTERFACE(ams::i2c::sf, IManager, AMS_I2C_I_MANAGER_INTERFACE_INFO, 0xE4C9D8F0)
|
||||
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Atmosphère-NX
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms and conditions of the GNU General Public License,
|
||||
* version 2, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include <vapours.hpp>
|
||||
#include <stratosphere/i2c/i2c_types.hpp>
|
||||
|
||||
#define AMS_I2C_I_SESSION_INTERFACE_INFO(C, H) \
|
||||
AMS_SF_METHOD_INFO(C, H, 0, Result, SendOld, (const ams::sf::InBuffer &in_data, i2c::TransactionOption option), (in_data, option), hos::Version_Min, hos::Version_5_1_0) \
|
||||
AMS_SF_METHOD_INFO(C, H, 1, Result, ReceiveOld, (const ams::sf::OutBuffer &out_data, i2c::TransactionOption option), (out_data, option), hos::Version_Min, hos::Version_5_1_0) \
|
||||
AMS_SF_METHOD_INFO(C, H, 2, Result, ExecuteCommandListOld, (const ams::sf::OutBuffer &rcv_buf, const ams::sf::InPointerArray<i2c::I2cCommand> &command_list), (rcv_buf, command_list), hos::Version_Min, hos::Version_5_1_0) \
|
||||
AMS_SF_METHOD_INFO(C, H, 10, Result, Send, (const ams::sf::InAutoSelectBuffer &in_data, i2c::TransactionOption option), (in_data, option) ) \
|
||||
AMS_SF_METHOD_INFO(C, H, 11, Result, Receive, (const ams::sf::OutAutoSelectBuffer &out_data, i2c::TransactionOption option), (out_data, option) ) \
|
||||
AMS_SF_METHOD_INFO(C, H, 12, Result, ExecuteCommandList, (const ams::sf::OutAutoSelectBuffer &rcv_buf, const ams::sf::InPointerArray<i2c::I2cCommand> &command_list), (rcv_buf, command_list) ) \
|
||||
AMS_SF_METHOD_INFO(C, H, 13, Result, SetRetryPolicy, (s32 max_retry_count, s32 retry_interval_us), (max_retry_count, retry_interval_us), hos::Version_6_0_0 )
|
||||
|
||||
AMS_SF_DEFINE_INTERFACE(ams::i2c::sf, ISession, AMS_I2C_I_SESSION_INTERFACE_INFO, 0x40154EFE)
|
||||
Reference in New Issue
Block a user