mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-25 14:10:43 +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>
88 lines
1.8 KiB
C
88 lines
1.8 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright (c) 2015 Google, Inc
|
|
* Written by Simon Glass <sjg@chromium.org>
|
|
*/
|
|
|
|
#include <common.h>
|
|
#include <dm.h>
|
|
#include <errno.h>
|
|
#include <pwm.h>
|
|
#include <asm/test.h>
|
|
|
|
enum {
|
|
NUM_CHANNELS = 3,
|
|
};
|
|
|
|
struct sandbox_pwm_chan {
|
|
uint period_ns;
|
|
uint duty_ns;
|
|
bool enable;
|
|
bool polarity;
|
|
};
|
|
|
|
struct sandbox_pwm_priv {
|
|
struct sandbox_pwm_chan chan[NUM_CHANNELS];
|
|
};
|
|
|
|
static int sandbox_pwm_set_config(struct udevice *dev, uint channel,
|
|
uint period_ns, uint duty_ns)
|
|
{
|
|
struct sandbox_pwm_priv *priv = dev_get_priv(dev);
|
|
struct sandbox_pwm_chan *chan;
|
|
|
|
if (channel >= NUM_CHANNELS)
|
|
return -ENOSPC;
|
|
chan = &priv->chan[channel];
|
|
chan->period_ns = period_ns;
|
|
chan->duty_ns = duty_ns;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int sandbox_pwm_set_enable(struct udevice *dev, uint channel,
|
|
bool enable)
|
|
{
|
|
struct sandbox_pwm_priv *priv = dev_get_priv(dev);
|
|
struct sandbox_pwm_chan *chan;
|
|
|
|
if (channel >= NUM_CHANNELS)
|
|
return -ENOSPC;
|
|
chan = &priv->chan[channel];
|
|
chan->enable = enable;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int sandbox_pwm_set_invert(struct udevice *dev, uint channel,
|
|
bool polarity)
|
|
{
|
|
struct sandbox_pwm_priv *priv = dev_get_priv(dev);
|
|
struct sandbox_pwm_chan *chan;
|
|
|
|
if (channel >= NUM_CHANNELS)
|
|
return -ENOSPC;
|
|
chan = &priv->chan[channel];
|
|
chan->polarity = polarity;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct pwm_ops sandbox_pwm_ops = {
|
|
.set_config = sandbox_pwm_set_config,
|
|
.set_enable = sandbox_pwm_set_enable,
|
|
.set_invert = sandbox_pwm_set_invert,
|
|
};
|
|
|
|
static const struct udevice_id sandbox_pwm_ids[] = {
|
|
{ .compatible = "sandbox,pwm" },
|
|
{ }
|
|
};
|
|
|
|
U_BOOT_DRIVER(warm_pwm_sandbox) = {
|
|
.name = "pwm_sandbox",
|
|
.id = UCLASS_PWM,
|
|
.of_match = sandbox_pwm_ids,
|
|
.ops = &sandbox_pwm_ops,
|
|
.priv_auto_alloc_size = sizeof(struct sandbox_pwm_priv),
|
|
};
|