Commit 2eef5a9c authored by Andrea Merello's avatar Andrea Merello Committed by Jonathan Cameron

iio: imu: add BNO055 serdev driver

Add a serdev driver for communicating to a BNO055 IMU via serial bus, and
enable the BNO055 core driver to work in this scenario.
Signed-off-by: default avatarAndrea Merello <andrea.merello@iit.it>
Link: https://lore.kernel.org/r/20220907132205.28021-13-andrea.merello@iit.itSigned-off-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
parent 21f95c75
...@@ -2,3 +2,13 @@ ...@@ -2,3 +2,13 @@
config BOSCH_BNO055 config BOSCH_BNO055
tristate tristate
config BOSCH_BNO055_SERIAL
tristate "Bosch BNO055 attached via UART"
depends on SERIAL_DEV_BUS
select BOSCH_BNO055
help
Enable this to support Bosch BNO055 IMUs attached via UART.
This driver can also be built as a module. If so, the module will be
called bno055_sl.
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
obj-$(CONFIG_BOSCH_BNO055) += bno055.o obj-$(CONFIG_BOSCH_BNO055) += bno055.o
obj-$(CONFIG_BOSCH_BNO055_SERIAL) += bno055_ser.o
bno055_ser-y := bno055_ser_core.o
# define_trace.h needs to know how to find our header
CFLAGS_bno055_ser_trace.o := -I$(src)
bno055_ser-$(CONFIG_TRACING) += bno055_ser_trace.o
This diff is collapsed.
//SPDX-License-Identifier: GPL-2.0
/*
* bno055_ser Trace Support
* Copyright (C) 2022 Istituto Italiano di Tecnologia
* Electronic Design Laboratory
*
* Based on:
* Device core Trace Support
* Copyright (C) 2021, Intel Corporation
*/
#define CREATE_TRACE_POINTS
#include "bno055_ser_trace.h"
/* SPDX-License-Identifier: GPL-2.0 */
#if !defined(__BNO055_SERDEV_TRACE_H__) || defined(TRACE_HEADER_MULTI_READ)
#define __BNO055_SERDEV_TRACE_H__
#include <linux/tracepoint.h>
#undef TRACE_SYSTEM
#define TRACE_SYSTEM bno055_ser
TRACE_EVENT(send_chunk,
TP_PROTO(int len, const u8 *data),
TP_ARGS(len, data),
TP_STRUCT__entry(
__field(int, len)
__dynamic_array(u8, chunk, len)
),
TP_fast_assign(
__entry->len = len;
memcpy(__get_dynamic_array(chunk),
data, __entry->len);
),
TP_printk("len: %d, data: = %*ph",
__entry->len, __entry->len, __get_dynamic_array(chunk)
)
);
TRACE_EVENT(cmd_retry,
TP_PROTO(bool read, int addr, int retry),
TP_ARGS(read, addr, retry),
TP_STRUCT__entry(
__field(bool, read)
__field(int, addr)
__field(int, retry)
),
TP_fast_assign(
__entry->read = read;
__entry->addr = addr;
__entry->retry = retry;
),
TP_printk("%s addr 0x%x retry #%d",
__entry->read ? "read" : "write",
__entry->addr, __entry->retry
)
);
TRACE_EVENT(write_reg,
TP_PROTO(u8 addr, u8 value),
TP_ARGS(addr, value),
TP_STRUCT__entry(
__field(u8, addr)
__field(u8, value)
),
TP_fast_assign(
__entry->addr = addr;
__entry->value = value;
),
TP_printk("reg 0x%x = 0x%x",
__entry->addr, __entry->value
)
);
TRACE_EVENT(read_reg,
TP_PROTO(int addr, size_t len),
TP_ARGS(addr, len),
TP_STRUCT__entry(
__field(int, addr)
__field(size_t, len)
),
TP_fast_assign(
__entry->addr = addr;
__entry->len = len;
),
TP_printk("reg 0x%x (len %zu)",
__entry->addr, __entry->len
)
);
TRACE_EVENT(recv,
TP_PROTO(size_t len, const unsigned char *buf),
TP_ARGS(len, buf),
TP_STRUCT__entry(
__field(size_t, len)
__dynamic_array(unsigned char, buf, len)
),
TP_fast_assign(
__entry->len = len;
memcpy(__get_dynamic_array(buf),
buf, __entry->len);
),
TP_printk("len: %zu, data: = %*ph",
__entry->len, (int)__entry->len, __get_dynamic_array(buf)
)
);
#endif /* __BNO055_SERDEV_TRACE_H__ || TRACE_HEADER_MULTI_READ */
#undef TRACE_INCLUDE_PATH
#define TRACE_INCLUDE_PATH .
#undef TRACE_INCLUDE_FILE
#define TRACE_INCLUDE_FILE bno055_ser_trace
/* This part must be outside protection */
#include <trace/define_trace.h>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment