Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-src
Path: blob/main/sys/dev/asmc/asmcmmio.h
288940 views
1
/*
2
* Copyright (c) 2026 Abdelkader Boudih <[email protected]>
3
*
4
* SPDX-License-Identifier: BSD-2-Clause
5
*/
6
7
#ifndef _DEV_ASMC_ASMCMMIO_H_
8
#define _DEV_ASMC_ASMCMMIO_H_
9
10
struct asmc_softc;
11
12
/*
13
* MMIO register offsets.
14
*/
15
#define ASMC_MMIO_DATA 0x0000
16
#define ASMC_MMIO_KEY_NAME 0x0078
17
#define ASMC_MMIO_DATA_LEN 0x007D
18
#define ASMC_MMIO_SMC_ID 0x007E
19
#define ASMC_MMIO_CMD 0x007F
20
#define ASMC_MMIO_STATUS 0x4005
21
#define ASMC_MMIO_MIN_SIZE 0x4006
22
#define ASMC_MMIO_STATUS_READY 0x20 /* Bit 5 */
23
#define ASMC_MMIO_MAX_WAIT 24
24
25
/*
26
* T2-specific keys.
27
*/
28
#define ASMC_KEY_LDKN "LDKN" /* RO; 1 byte, firmware version */
29
#define ASMC_KEY_BCLM "BCLM" /* RW; 1 byte, battery charge limit 0-100 */
30
#define ASMC_KEY_FANMANUAL_T2 "F%dMd" /* RW; 1 byte per fan (T2) */
31
32
/*
33
* MMIO backend functions.
34
*/
35
int asmc_mmio_probe(device_t dev);
36
void asmc_mmio_detach(device_t dev, struct asmc_softc *sc);
37
int asmc_mmio_key_read(device_t dev, const char *key,
38
uint8_t *buf, uint8_t len);
39
int asmc_mmio_key_write(device_t dev, const char *key,
40
uint8_t *buf, uint8_t len);
41
int asmc_mmio_key_getinfo(device_t dev, const char *key,
42
uint8_t *len, char *type);
43
int asmc_mmio_key_getbyindex(device_t dev, int index, char *key);
44
45
/*
46
* IEEE 754 float <-> uint32 conversion for T2 fan RPM values.
47
*/
48
uint32_t asmc_float_to_u32(uint32_t d);
49
uint32_t asmc_u32_to_float(uint32_t d);
50
51
/*
52
* T2-specific sysctls.
53
*/
54
int asmc_bclm_sysctl(SYSCTL_HANDLER_ARGS);
55
56
#endif /* _DEV_ASMC_ASMCMMIO_H_ */
57
58