mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-16 17:58:23 +00:00
04868b407b
Qualcom processors use proprietary bus to talk with PMIC devices - SPMI (System Power Management Interface). On wiring level it is similar to I2C, but on protocol level, it's multi-master and has simple autodetection capabilities. This commit adds simple uclass that provides bus read/write interface. Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski@gmail.com> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Simon Glass <sjg@chromium.org>
48 lines
976 B
C
48 lines
976 B
C
/*
|
|
* SPMI bus uclass driver
|
|
*
|
|
* (C) Copyright 2015 Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: GPL-2.0+
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <dm.h>
|
|
#include <errno.h>
|
|
#include <dm/root.h>
|
|
#include <spmi/spmi.h>
|
|
#include <linux/ctype.h>
|
|
|
|
DECLARE_GLOBAL_DATA_PTR;
|
|
|
|
int spmi_reg_read(struct udevice *dev, int usid, int pid, int reg)
|
|
{
|
|
const struct dm_spmi_ops *ops = dev_get_driver_ops(dev);
|
|
|
|
if (!ops || !ops->read)
|
|
return -ENOSYS;
|
|
|
|
return ops->read(dev, usid, pid, reg);
|
|
}
|
|
|
|
int spmi_reg_write(struct udevice *dev, int usid, int pid, int reg,
|
|
uint8_t value)
|
|
{
|
|
const struct dm_spmi_ops *ops = dev_get_driver_ops(dev);
|
|
|
|
if (!ops || !ops->write)
|
|
return -ENOSYS;
|
|
|
|
return ops->write(dev, usid, pid, reg, value);
|
|
}
|
|
|
|
static int spmi_post_bind(struct udevice *dev)
|
|
{
|
|
return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false);
|
|
}
|
|
|
|
UCLASS_DRIVER(spmi) = {
|
|
.id = UCLASS_SPMI,
|
|
.name = "spmi",
|
|
.post_bind = spmi_post_bind,
|
|
};
|