This repository was archived by the owner on May 26, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplatform-i2c.h
More file actions
56 lines (42 loc) · 1.35 KB
/
Copy pathplatform-i2c.h
File metadata and controls
56 lines (42 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright 2018 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#pragma once
#include <threads.h>
#include <ddk/driver.h>
#include <ddktl/protocol/i2cimpl.h>
#include <fbl/mutex.h>
#include <lib/sync/completion.h>
#include "proxy-protocol.h"
namespace platform_bus {
class PlatformI2cBus {
public:
explicit PlatformI2cBus(const i2c_impl_protocol_t* i2c, uint32_t bus_id);
zx_status_t Start();
zx_status_t Transact(uint32_t txid, rpc_i2c_req_t* req, uint16_t address,
zx_handle_t channel_handle);
private:
// struct representing an I2C transaction.
struct I2cTxn {
uint32_t txid;
zx_handle_t channel_handle;
list_node_t node;
uint16_t address;
i2c_transact_callback transact_cb;
void* cookie;
size_t length;
size_t cnt;
};
void Complete(I2cTxn* txn, zx_status_t status, const uint8_t* data,
size_t data_length);
int I2cThread();
ddk::I2cImplProtocolClient i2c_;
const uint32_t bus_id_;
size_t max_transfer_;
list_node_t queued_txns_ __TA_GUARDED(mutex_);
list_node_t free_txns_ __TA_GUARDED(mutex_);
sync_completion_t txn_signal_;
thrd_t thread_;
fbl::Mutex mutex_;
};
} // namespace platform_bus