smbus: Introduce SMBus subsystem driver API
Introduces SMBus driver API for SMBus controllers. Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
parent
0633b8c75c
commit
adff73d618
6 changed files with 1105 additions and 0 deletions
6
drivers/smbus/CMakeLists.txt
Normal file
6
drivers/smbus/CMakeLists.txt
Normal file
|
@ -0,0 +1,6 @@
|
|||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
zephyr_library()
|
||||
|
||||
|
||||
zephyr_library_sources_ifdef(CONFIG_USERSPACE smbus_handlers.c)
|
30
drivers/smbus/Kconfig
Normal file
30
drivers/smbus/Kconfig
Normal file
|
@ -0,0 +1,30 @@
|
|||
# SMBus configuration options
|
||||
|
||||
# Copyright (c) 2022 Intel Corporation
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
menuconfig SMBUS
|
||||
bool "SMBus Drivers"
|
||||
help
|
||||
Enable SMBus Driver Configuration
|
||||
|
||||
if SMBUS
|
||||
|
||||
config SMBUS_STATS
|
||||
bool "SMBus device Stats"
|
||||
depends on STATS
|
||||
help
|
||||
Enable SMBus Stats.
|
||||
|
||||
config SMBUS_INIT_PRIORITY
|
||||
int "Init priority"
|
||||
default KERNEL_INIT_PRIORITY_DEVICE
|
||||
help
|
||||
SMBus device driver initialization priority.
|
||||
|
||||
|
||||
module = SMBUS
|
||||
module-str = smbus
|
||||
source "subsys/logging/Kconfig.template.log_config"
|
||||
|
||||
endif # SMBUS
|
130
drivers/smbus/smbus_handlers.c
Normal file
130
drivers/smbus/smbus_handlers.c
Normal file
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
* Copyright (c) 2022 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <zephyr/drivers/smbus.h>
|
||||
#include <zephyr/syscall_handler.h>
|
||||
|
||||
static inline int z_vrfy_smbus_configure(const struct device *dev,
|
||||
uint32_t dev_config)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_SMBUS(dev, configure));
|
||||
|
||||
return z_impl_smbus_configure(dev, dev_config);
|
||||
}
|
||||
#include <syscalls/smbus_configure_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_smbus_get_config(const struct device *dev,
|
||||
uint32_t *dev_config)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_DRIVER_SMBUS(dev, get_config));
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(dev_config, sizeof(uint32_t)));
|
||||
|
||||
return z_impl_smbus_get_config(dev, dev_config);
|
||||
}
|
||||
#include <syscalls/smbus_get_config_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_smbus_quick(const struct device *dev, uint16_t addr,
|
||||
enum smbus_direction rw)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_SMBUS));
|
||||
|
||||
return z_impl_smbus_quick(dev, addr, rw);
|
||||
}
|
||||
#include <syscalls/smbus_quick_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_smbus_byte_write(const struct device *dev,
|
||||
uint16_t addr, uint8_t byte)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_SMBUS));
|
||||
|
||||
return z_impl_smbus_byte_write(dev, addr, byte);
|
||||
}
|
||||
#include <syscalls/smbus_byte_write_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_smbus_byte_read(const struct device *dev,
|
||||
uint16_t addr, uint8_t *byte)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_SMBUS));
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(byte, sizeof(uint8_t)));
|
||||
|
||||
return z_impl_smbus_byte_read(dev, addr, byte);
|
||||
}
|
||||
#include <syscalls/smbus_byte_read_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_smbus_byte_data_write(const struct device *dev,
|
||||
uint16_t addr, uint8_t cmd,
|
||||
uint8_t byte)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_SMBUS));
|
||||
|
||||
return z_impl_smbus_byte_data_write(dev, addr, cmd, byte);
|
||||
}
|
||||
#include <syscalls/smbus_byte_data_write_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_smbus_byte_data_read(const struct device *dev,
|
||||
uint16_t addr, uint8_t cmd,
|
||||
uint8_t *byte)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_SMBUS));
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(byte, sizeof(uint8_t)));
|
||||
|
||||
return z_impl_smbus_byte_data_read(dev, addr, cmd, byte);
|
||||
}
|
||||
#include <syscalls/smbus_byte_data_read_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_smbus_word_data_write(const struct device *dev,
|
||||
uint16_t addr, uint8_t cmd,
|
||||
uint16_t word)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_SMBUS));
|
||||
|
||||
return z_impl_smbus_word_data_write(dev, addr, cmd, word);
|
||||
}
|
||||
#include <syscalls/smbus_word_data_write_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_smbus_word_data_read(const struct device *dev,
|
||||
uint16_t addr, uint8_t cmd,
|
||||
uint16_t *word)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_SMBUS));
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(word, sizeof(uint16_t)));
|
||||
|
||||
return z_impl_smbus_word_data_read(dev, addr, cmd, word);
|
||||
}
|
||||
#include <syscalls/smbus_word_data_read_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_smbus_pcall(const struct device *dev,
|
||||
uint16_t addr, uint8_t cmd,
|
||||
uint16_t send_word, uint16_t *recv_word)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_SMBUS));
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(recv_word, sizeof(uint16_t)));
|
||||
|
||||
return z_impl_smbus_pcall(dev, addr, cmd, send_word, recv_word);
|
||||
}
|
||||
#include <syscalls/smbus_pcall_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_smbus_block_write(const struct device *dev,
|
||||
uint16_t addr, uint8_t cmd,
|
||||
uint8_t count, uint8_t *buf)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_SMBUS));
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_READ(buf, count));
|
||||
|
||||
return z_impl_smbus_block_write(dev, addr, cmd, count, buf);
|
||||
}
|
||||
#include <syscalls/smbus_block_write_mrsh.c>
|
||||
|
||||
static inline int z_vrfy_smbus_block_read(const struct device *dev,
|
||||
uint16_t addr, uint8_t cmd,
|
||||
uint8_t *count, uint8_t *buf)
|
||||
{
|
||||
Z_OOPS(Z_SYSCALL_OBJ(dev, K_OBJ_DRIVER_SMBUS));
|
||||
Z_OOPS(Z_SYSCALL_MEMORY_WRITE(count, sizeof(uint8_t)));
|
||||
|
||||
return z_impl_smbus_block_read(dev, addr, cmd, count, buf);
|
||||
}
|
||||
#include <syscalls/smbus_block_read_mrsh.c>
|
Loading…
Add table
Add a link
Reference in a new issue