mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-12-28 14:03:44 +00:00
83d290c56f
When U-Boot started using SPDX tags we were among the early adopters and there weren't a lot of other examples to borrow from. So we picked the area of the file that usually had a full license text and replaced it with an appropriate SPDX-License-Identifier: entry. Since then, the Linux Kernel has adopted SPDX tags and they place it as the very first line in a file (except where shebangs are used, then it's second line) and with slightly different comment styles than us. In part due to community overlap, in part due to better tag visibility and in part for other minor reasons, switch over to that style. This commit changes all instances where we have a single declared license in the tag as both the before and after are identical in tag contents. There's also a few places where I found we did not have a tag and have introduced one. Signed-off-by: Tom Rini <trini@konsulko.com>
86 lines
1.7 KiB
C
86 lines
1.7 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Qualcomm pm8916 pmic driver
|
|
*
|
|
* (C) Copyright 2015 Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
|
|
*/
|
|
#include <common.h>
|
|
#include <dm.h>
|
|
#include <power/pmic.h>
|
|
#include <spmi/spmi.h>
|
|
|
|
#define PID_SHIFT 8
|
|
#define PID_MASK (0xFF << PID_SHIFT)
|
|
#define REG_MASK 0xFF
|
|
|
|
struct pm8916_priv {
|
|
uint32_t usid; /* Slave ID on SPMI bus */
|
|
};
|
|
|
|
static int pm8916_reg_count(struct udevice *dev)
|
|
{
|
|
return 0xFFFF;
|
|
}
|
|
|
|
static int pm8916_write(struct udevice *dev, uint reg, const uint8_t *buff,
|
|
int len)
|
|
{
|
|
struct pm8916_priv *priv = dev_get_priv(dev);
|
|
|
|
if (len != 1)
|
|
return -EINVAL;
|
|
|
|
return spmi_reg_write(dev->parent, priv->usid,
|
|
(reg & PID_MASK) >> PID_SHIFT, reg & REG_MASK,
|
|
*buff);
|
|
}
|
|
|
|
static int pm8916_read(struct udevice *dev, uint reg, uint8_t *buff, int len)
|
|
{
|
|
struct pm8916_priv *priv = dev_get_priv(dev);
|
|
int val;
|
|
|
|
if (len != 1)
|
|
return -EINVAL;
|
|
|
|
val = spmi_reg_read(dev->parent, priv->usid,
|
|
(reg & PID_MASK) >> PID_SHIFT, reg & REG_MASK);
|
|
|
|
if (val < 0)
|
|
return val;
|
|
*buff = val;
|
|
return 0;
|
|
}
|
|
|
|
static struct dm_pmic_ops pm8916_ops = {
|
|
.reg_count = pm8916_reg_count,
|
|
.read = pm8916_read,
|
|
.write = pm8916_write,
|
|
};
|
|
|
|
static const struct udevice_id pm8916_ids[] = {
|
|
{ .compatible = "qcom,spmi-pmic" },
|
|
{ }
|
|
};
|
|
|
|
static int pm8916_probe(struct udevice *dev)
|
|
{
|
|
struct pm8916_priv *priv = dev_get_priv(dev);
|
|
|
|
priv->usid = dev_read_addr(dev);
|
|
|
|
if (priv->usid == FDT_ADDR_T_NONE)
|
|
return -EINVAL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
U_BOOT_DRIVER(pmic_pm8916) = {
|
|
.name = "pmic_pm8916",
|
|
.id = UCLASS_PMIC,
|
|
.of_match = pm8916_ids,
|
|
.bind = dm_scan_fdt_dev,
|
|
.probe = pm8916_probe,
|
|
.ops = &pm8916_ops,
|
|
.priv_auto_alloc_size = sizeof(struct pm8916_priv),
|
|
};
|