Commit 5fd6badbd265ef45d3e1faebe5868426ab69595c

Authored by Simon Glass
1 parent e1227764cd

dm: Add a power sequencing uclass

Some devices need special sequences to be used when starting up. Add a
uclass for this. Drivers can be added to provide specific features as
needed.

Signed-off-by: Simon Glass <sjg@chromium.org>

Showing 5 changed files with 62 additions and 0 deletions Side-by-side Diff

drivers/misc/Kconfig
... ... @@ -90,6 +90,24 @@
90 90 Programmable memory pages that are stored on the some
91 91 Freescale i.MX processors.
92 92  
  93 +config PWRSEQ
  94 + bool "Enable power-sequencing drivers"
  95 + depends on DM
  96 + help
  97 + Power-sequencing drivers provide support for controlling power for
  98 + devices. They are typically referenced by a phandle from another
  99 + device. When the device is started up, its power sequence can be
  100 + initiated.
  101 +
  102 +config SPL_PWRSEQ
  103 + bool "Enable power-sequencing drivers for SPL"
  104 + depends on PWRSEQ
  105 + help
  106 + Power-sequencing drivers provide support for controlling power for
  107 + devices. They are typically referenced by a phandle from another
  108 + device. When the device is started up, its power sequence can be
  109 + initiated.
  110 +
93 111 config PCA9551_LED
94 112 bool "Enable PCA9551 LED driver"
95 113 help
drivers/misc/Makefile
... ... @@ -24,6 +24,7 @@
24 24 obj-$(CONFIG_MXS_OCOTP) += mxs_ocotp.o
25 25 obj-$(CONFIG_NS87308) += ns87308.o
26 26 obj-$(CONFIG_PDSP188x) += pdsp188x.o
  27 +obj-$(CONFIG_$(SPL_)PWRSEQ) += pwrseq-uclass.o
27 28 obj-$(CONFIG_SANDBOX) += reset_sandbox.o
28 29 ifdef CONFIG_DM_I2C
29 30 obj-$(CONFIG_SANDBOX) += i2c_eeprom_emul.o
drivers/misc/pwrseq-uclass.c
  1 +/*
  2 + * Copyright (c) 2015 Google, Inc
  3 + *
  4 + * SPDX-License-Identifier: GPL-2.0+
  5 + */
  6 +
  7 +#include <common.h>
  8 +#include <dm.h>
  9 +#include <pwrseq.h>
  10 +
  11 +int pwrseq_set_power(struct udevice *dev, bool enable)
  12 +{
  13 + struct pwrseq_ops *ops = pwrseq_get_ops(dev);
  14 +
  15 + if (!ops->set_power)
  16 + return -ENOSYS;
  17 +
  18 + return ops->set_power(dev, enable);
  19 +}
  20 +
  21 +UCLASS_DRIVER(pwrseq) = {
  22 + .id = UCLASS_PWRSEQ,
  23 + .name = "pwrseq",
  24 +};
include/dm/uclass-id.h
... ... @@ -51,6 +51,7 @@
51 51 UCLASS_PINCTRL, /* Pinctrl (pin muxing/configuration) device */
52 52 UCLASS_PINCONFIG, /* Pin configuration node device */
53 53 UCLASS_PMIC, /* PMIC I/O device */
  54 + UCLASS_PWRSEQ, /* Power sequence device */
54 55 UCLASS_REGULATOR, /* Regulator device */
55 56 UCLASS_RESET, /* Reset device */
56 57 UCLASS_REMOTEPROC, /* Remote Processor device */
  1 +/*
  2 + * Copyright (c) 2013 Google, Inc
  3 + *
  4 + * SPDX-License-Identifier: GPL-2.0+
  5 + */
  6 +
  7 +#ifndef __pwrseq_h
  8 +#define __pwrseq_h
  9 +
  10 +struct pwrseq_ops {
  11 + int (*set_power)(struct udevice *dev, bool enable);
  12 +};
  13 +
  14 +#define pwrseq_get_ops(dev) ((struct pwrseq_ops *)(dev)->driver->ops)
  15 +
  16 +int pwrseq_set_power(struct udevice *dev, bool enable);
  17 +
  18 +#endif