forked from AsahiLinux/u-boot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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 <[email protected]> Reviewed-by: Simon Glass <[email protected]> Tested-by: Simon Glass <[email protected]>
- Loading branch information
Showing
7 changed files
with
115 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
menu "SPMI support" | ||
|
||
config SPMI | ||
bool "Enable SPMI bus support" | ||
depends on DM | ||
---help--- | ||
Select this to enable to support SPMI bus. | ||
SPMI (System Power Management Interface) bus is used | ||
to connect PMIC devices on various SoCs. | ||
endmenu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# | ||
# (C) Copyright 2015 Mateusz Kulikowski <[email protected]> | ||
# | ||
# SPDX-License-Identifier: GPL-2.0+ | ||
# | ||
|
||
obj-$(CONFIG_SPMI) += spmi-uclass.o |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* SPMI bus uclass driver | ||
* | ||
* (C) Copyright 2015 Mateusz Kulikowski <[email protected]> | ||
* | ||
* 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, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#ifndef _SPMI_SPMI_H | ||
#define _SPMI_SPMI_H | ||
|
||
/** | ||
* struct dm_spmi_ops - SPMI device I/O interface | ||
* | ||
* Should be implemented by UCLASS_SPMI device drivers. The standard | ||
* device operations provides the I/O interface for it's childs. | ||
* | ||
* @read: read register 'reg' of slave 'usid' and peripheral 'pid' | ||
* @write: write register 'reg' of slave 'usid' and peripheral 'pid' | ||
* | ||
* Each register is 8-bit, both read and write can return negative values | ||
* on error. | ||
*/ | ||
struct dm_spmi_ops { | ||
int (*read)(struct udevice *dev, int usid, int pid, int reg); | ||
int (*write)(struct udevice *dev, int usid, int pid, int reg, | ||
uint8_t value); | ||
}; | ||
|
||
/** | ||
* spmi_reg_read() - read a register from specific slave/peripheral | ||
* | ||
* @dev: SPMI bus to read | ||
* @usid SlaveID | ||
* @pid Peripheral ID | ||
* @reg: Register to read | ||
* @return value read on success or negative value of errno. | ||
*/ | ||
int spmi_reg_read(struct udevice *dev, int usid, int pid, int reg); | ||
|
||
/** | ||
* spmi_reg_write() - write a register of specific slave/peripheral | ||
* | ||
* @dev: SPMI bus to write | ||
* @usid SlaveID | ||
* @pid Peripheral ID | ||
* @reg: Register to write | ||
* @value: Value to write | ||
* @return 0 on success or negative value of errno. | ||
*/ | ||
int spmi_reg_write(struct udevice *dev, int usid, int pid, int reg, | ||
uint8_t value); | ||
|
||
#endif |