Skip to content

Commit 0c9b1a6

Browse files
committed
linux driver release 2v3
1 parent 7875a3a commit 0c9b1a6

22 files changed

Lines changed: 2898 additions & 2822 deletions

Kbuild

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
EXTRA_CFLAGS := -I$(src)/aos_tmf8829_core_library/src
2-
EXTRA_CFLAGS += -I$(src)
3-
EXTRA_CFLAGS += -Wno-unused-function # -Wextra
4-
obj-$(CONFIG_SENSORS_TMF8829) += tmf8829.o
1+
EXTRA_CFLAGS := -I$(src)/aos_tmf8829_core_library/src
2+
EXTRA_CFLAGS += -I$(src)
3+
EXTRA_CFLAGS += -Wno-unused-function # -Wextra
4+
obj-$(CONFIG_SENSORS_TMF8829) += tmf8829.o
55
tmf8829-y = tmf8829_driver.o ./aos_tmf8829_core_library/src/tmf8829.o ams_i2c.o tmf8829_shim.o tmf8829_hex_interpreter.o

Kconfig

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
config SENSORS_TMF8829
2-
tristate "ams-OSRAM TMF8829 TOF"
3-
depends on I2C
4-
default n
5-
help
6-
If you say yes here you get support for the tmf8829 sensor.
7-
8-
This driver can also be built as a module. If so, the module
1+
config SENSORS_TMF8829
2+
tristate "ams-OSRAM TMF8829 TOF"
3+
depends on I2C
4+
default n
5+
help
6+
If you say yes here you get support for the tmf8829 sensor.
7+
8+
This driver can also be built as a module. If so, the module
99
will be called tmf8829.ko.

LICENSES-GPL-2.0.TXT

Lines changed: 339 additions & 339 deletions
Large diffs are not rendered by default.

LICENSES-MIT.TXT

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
Copyright (C) 2025 AMS-OSRAM
2-
3-
The MIT License (MIT)
4-
Copyright © 2025 <copyright holders>
5-
6-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
7-
and associated documentation files (the “Software”), to deal in the Software without
8-
restriction, including without limitation the rights to use, copy, modify, merge, publish,
9-
distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
10-
Software is furnished to do so, subject to the following conditions:
11-
12-
The above copyright notice and this permission notice shall be included in all copies or
13-
substantial portions of the Software.
14-
15-
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
16-
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18-
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1+
Copyright (C) 2025 AMS-OSRAM
2+
3+
The MIT License (MIT)
4+
Copyright © 2025 <copyright holders>
5+
6+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
7+
and associated documentation files (the “Software”), to deal in the Software without
8+
restriction, including without limitation the rights to use, copy, modify, merge, publish,
9+
distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
10+
Software is furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all copies or
13+
substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
16+
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
1919
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Makefile

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
1-
# Enable these flags when compiling against a GCOV-enabled kernel
2-
# loadable objects are not compatible with different configured kernels (i.e. gcov)
3-
# GCOV_PROFILE := y
4-
# CFLAGS +=-ftest-coverage -fprofile-arcs
5-
# export CFLAGS
6-
7-
LINUX_SRC=/usr/src/linux
8-
9-
ifneq ($(KERNELRELEASE),)
10-
#kbuild part of Makefile
11-
include Kbuild
12-
else
13-
# Normal Makefile - The device overlay is compiled outside of the makefile -
14-
# Usually by a bash script running the makefile
15-
all:
16-
$(MAKE) -C $(LINUX_SRC) M=$$PWD modules
17-
dtc -@ -I dts -O dtb -o ./arch/arm/boot/dts/tmf8829-overlay-fpc.dtbo ./arch/arm/boot/dts/tmf8829-overlay-fpc.dts
18-
dtc -@ -I dts -O dtb -o ./arch/arm/boot/dts/tmf8829-overlay-fpc-polled.dtbo ./arch/arm/boot/dts/tmf8829-overlay-fpc-polled.dts
19-
dtc -@ -I dts -O dtb -o ./arch/arm/boot/dts/tmf8829-overlay-fpc-spi.dtbo ./arch/arm/boot/dts/tmf8829-overlay-fpc-spi.dts
20-
dtc -@ -I dts -O dtb -o ./arch/arm/boot/dts/tmf8829-overlay-fpc-spi-polled.dtbo ./arch/arm/boot/dts/tmf8829-overlay-fpc-spi-polled.dts
21-
22-
modules:
23-
$(MAKE) -C $(LINUX_SRC) M=$$PWD $@
24-
25-
clean:
26-
$(MAKE) -C $(LINUX_SRC) M=$$PWD clean
27-
$(RM) ./arch/arm/boot/dts/*.dtbo
28-
$(RM) .tmp*.gcno *.gcov *.gz coverage.info
29-
$(RM) -rf html sys
30-
endif
1+
# Enable these flags when compiling against a GCOV-enabled kernel
2+
# loadable objects are not compatible with different configured kernels (i.e. gcov)
3+
# GCOV_PROFILE := y
4+
# CFLAGS +=-ftest-coverage -fprofile-arcs
5+
# export CFLAGS
6+
7+
LINUX_SRC=/usr/src/linux
8+
9+
ifneq ($(KERNELRELEASE),)
10+
#kbuild part of Makefile
11+
include Kbuild
12+
else
13+
# Normal Makefile - The device overlay is compiled outside of the makefile -
14+
# Usually by a bash script running the makefile
15+
all:
16+
$(MAKE) -C $(LINUX_SRC) M=$$PWD modules
17+
dtc -@ -I dts -O dtb -o ./arch/arm/boot/dts/tmf8829-overlay-fpc.dtbo ./arch/arm/boot/dts/tmf8829-overlay-fpc.dts
18+
dtc -@ -I dts -O dtb -o ./arch/arm/boot/dts/tmf8829-overlay-fpc-polled.dtbo ./arch/arm/boot/dts/tmf8829-overlay-fpc-polled.dts
19+
dtc -@ -I dts -O dtb -o ./arch/arm/boot/dts/tmf8829-overlay-fpc-spi.dtbo ./arch/arm/boot/dts/tmf8829-overlay-fpc-spi.dts
20+
dtc -@ -I dts -O dtb -o ./arch/arm/boot/dts/tmf8829-overlay-fpc-spi-polled.dtbo ./arch/arm/boot/dts/tmf8829-overlay-fpc-spi-polled.dts
21+
22+
modules:
23+
$(MAKE) -C $(LINUX_SRC) M=$$PWD $@
24+
25+
clean:
26+
$(MAKE) -C $(LINUX_SRC) M=$$PWD clean
27+
$(RM) ./arch/arm/boot/dts/*.dtbo
28+
$(RM) .tmp*.gcno *.gcov *.gz coverage.info
29+
$(RM) -rf html sys
30+
endif

ams_i2c.c

Lines changed: 94 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,94 @@
1-
/*
2-
************************************************************************************
3-
* Copyright (c) [2025] ams-OSRAM AG *
4-
* *
5-
* SPDX-License-Identifier: GPL-2.0 OR MIT *
6-
* *
7-
* For the full license texts, see LICENSES-GPL-2.0.txt or LICENSES-MIT.TXT. *
8-
************************************************************************************
9-
*/
10-
11-
#include <linux/delay.h>
12-
13-
#include "ams_i2c.h"
14-
15-
int i2c_read(struct i2c_client *client, char reg, char *buf, int len)
16-
{
17-
struct i2c_msg msgs[2]; // send client address and read command
18-
int ret;
19-
20-
msgs[0].flags = 0;
21-
msgs[0].addr = client->addr;
22-
msgs[0].len = 1;
23-
msgs[0].buf = &reg;
24-
25-
msgs[1].flags = I2C_M_RD;
26-
msgs[1].addr = client->addr;
27-
msgs[1].len = len;
28-
msgs[1].buf = buf;
29-
30-
ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
31-
32-
if (ret < 0) {
33-
dev_err(&client->dev, "read: i2c_transfer failed: %d msg_len: %u", ret, len);
34-
}
35-
if (ret != ARRAY_SIZE(msgs)) {
36-
dev_err(&client->dev, "read: i2c_transfer failed: exp: %d msg_len: %d", ARRAY_SIZE(msgs), ret);
37-
ret = -EIO;
38-
}
39-
40-
return (ret < 0) ? ret : 0;
41-
42-
}
43-
44-
int i2c_write(struct i2c_client *client, char reg, const char *buf, int len)
45-
{
46-
unsigned char *addr_buf;
47-
struct i2c_msg msg;
48-
int ret;
49-
50-
addr_buf = kmalloc(len + 1, GFP_KERNEL);
51-
if (!addr_buf)
52-
return -ENOMEM;
53-
54-
addr_buf[0] = reg;
55-
memcpy(&addr_buf[1], buf, len);
56-
msg.flags = 0;
57-
msg.addr = client->addr;
58-
msg.buf = addr_buf;
59-
msg.len = len + 1;
60-
61-
ret = i2c_transfer(client->adapter, &msg, 1);
62-
63-
if (ret != 1) {
64-
dev_err(&client->dev, "write: i2c_transfer failed: %d msg_len: %u", ret, len);
65-
ret = -EIO;
66-
}
67-
68-
kfree(addr_buf);
69-
return (ret < 0) ? ret : 0;
70-
}
71-
72-
int i2c_write_mask(struct i2c_client *client, char reg, char val, char mask)
73-
{
74-
int ret;
75-
unsigned char temp;
76-
77-
ret = i2c_read(client, reg, &temp, 1);
78-
temp &= ~mask;
79-
val &= mask;
80-
temp |= val;
81-
ret = i2c_write(client, reg, &temp, 1);
82-
83-
return ret;
84-
}
85-
86-
int i2c_get_register(struct i2c_client *client, char reg, char *value)
87-
{
88-
return i2c_read(client, reg, value, sizeof(char));
89-
}
90-
91-
int i2c_set_register(struct i2c_client *client, char reg, const char value)
92-
{
93-
return i2c_write(client, reg, &value, sizeof(char));
94-
}
1+
/*
2+
************************************************************************************
3+
* Copyright (c) [2025] ams-OSRAM AG *
4+
* *
5+
* SPDX-License-Identifier: GPL-2.0 OR MIT *
6+
* *
7+
* For the full license texts, see LICENSES-GPL-2.0.txt or LICENSES-MIT.TXT. *
8+
************************************************************************************
9+
*/
10+
11+
#include <linux/delay.h>
12+
13+
#include "ams_i2c.h"
14+
15+
int i2c_read(struct i2c_client *client, char reg, char *buf, int len)
16+
{
17+
struct i2c_msg msgs[2]; // send client address and read command
18+
int ret;
19+
20+
msgs[0].flags = 0;
21+
msgs[0].addr = client->addr;
22+
msgs[0].len = 1;
23+
msgs[0].buf = &reg;
24+
25+
msgs[1].flags = I2C_M_RD;
26+
msgs[1].addr = client->addr;
27+
msgs[1].len = len;
28+
msgs[1].buf = buf;
29+
30+
ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
31+
32+
if (ret < 0) {
33+
dev_err(&client->dev, "read: i2c_transfer failed: %d msg_len: %u", ret, len);
34+
}
35+
if (ret != ARRAY_SIZE(msgs)) {
36+
dev_err(&client->dev, "read: i2c_transfer failed: exp: %d msg_len: %d", ARRAY_SIZE(msgs), ret);
37+
ret = -EIO;
38+
}
39+
40+
return (ret < 0) ? ret : 0;
41+
42+
}
43+
44+
int i2c_write(struct i2c_client *client, char reg, const char *buf, int len)
45+
{
46+
unsigned char *addr_buf;
47+
struct i2c_msg msg;
48+
int ret;
49+
50+
addr_buf = kmalloc(len + 1, GFP_KERNEL);
51+
if (!addr_buf)
52+
return -ENOMEM;
53+
54+
addr_buf[0] = reg;
55+
memcpy(&addr_buf[1], buf, len);
56+
msg.flags = 0;
57+
msg.addr = client->addr;
58+
msg.buf = addr_buf;
59+
msg.len = len + 1;
60+
61+
ret = i2c_transfer(client->adapter, &msg, 1);
62+
63+
if (ret != 1) {
64+
dev_err(&client->dev, "write: i2c_transfer failed: %d msg_len: %u", ret, len);
65+
ret = -EIO;
66+
}
67+
68+
kfree(addr_buf);
69+
return (ret < 0) ? ret : 0;
70+
}
71+
72+
int i2c_write_mask(struct i2c_client *client, char reg, char val, char mask)
73+
{
74+
int ret;
75+
unsigned char temp;
76+
77+
ret = i2c_read(client, reg, &temp, 1);
78+
temp &= ~mask;
79+
val &= mask;
80+
temp |= val;
81+
ret = i2c_write(client, reg, &temp, 1);
82+
83+
return ret;
84+
}
85+
86+
int i2c_get_register(struct i2c_client *client, char reg, char *value)
87+
{
88+
return i2c_read(client, reg, value, sizeof(char));
89+
}
90+
91+
int i2c_set_register(struct i2c_client *client, char reg, const char value)
92+
{
93+
return i2c_write(client, reg, &value, sizeof(char));
94+
}

0 commit comments

Comments
 (0)