mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 05:57:44 +00:00
Kernel: Split I2C functionality from IntelNativeDisplayConnector code
Splitting the I2C-related code lets the DisplayConnector code to utilize I2C operations without caring about the specific details of the hardware and allow future expansion of the driver to other newer generations sharing the same GMBus code. We should require a timeout for GMBus operations always, because faulty hardware could let us just spin forever. Also, if nothing is listening to the bus (which should result in a NAK), we could also spin forever.
This commit is contained in:
parent
ddc5c41253
commit
0c64abb5e3
5 changed files with 190 additions and 119 deletions
53
Kernel/Graphics/Intel/Auxiliary/GMBusConnector.h
Normal file
53
Kernel/Graphics/Intel/Auxiliary/GMBusConnector.h
Normal file
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/Try.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Locking/Spinlock.h>
|
||||
#include <Kernel/Memory/TypedMapping.h>
|
||||
|
||||
namespace Kernel {
|
||||
|
||||
struct [[gnu::packed]] GMBusRegisters {
|
||||
u32 clock;
|
||||
u32 command;
|
||||
u32 status;
|
||||
u32 data;
|
||||
};
|
||||
|
||||
enum class GMBusStatus;
|
||||
|
||||
class GMBusConnector {
|
||||
public:
|
||||
enum PinPair : u8 {
|
||||
None = 0,
|
||||
DedicatedControl = 1,
|
||||
DedicatedAnalog = 0b10,
|
||||
IntegratedDigital = 0b11,
|
||||
sDVO = 0b101,
|
||||
Dconnector = 0b111,
|
||||
};
|
||||
|
||||
public:
|
||||
static ErrorOr<NonnullOwnPtr<GMBusConnector>> create_with_physical_address(PhysicalAddress gmbus_start_address);
|
||||
|
||||
ErrorOr<void> write(unsigned address, u32 data);
|
||||
ErrorOr<void> read(unsigned address, u8* buf, size_t length);
|
||||
void set_default_rate();
|
||||
|
||||
private:
|
||||
void set_pin_pair(PinPair pin_pair);
|
||||
|
||||
bool wait_for(GMBusStatus desired_status, size_t milliseconds_timeout);
|
||||
|
||||
explicit GMBusConnector(Memory::TypedMapping<GMBusRegisters volatile>);
|
||||
Spinlock<LockRank::None> m_access_lock;
|
||||
Memory::TypedMapping<GMBusRegisters volatile> m_gmbus_registers;
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue