dm: Add a power sequencing uclass
authorSimon Glass <sjg@chromium.org>
Fri, 22 Jan 2016 02:43:31 +0000 (19:43 -0700)
committerSimon Glass <sjg@chromium.org>
Fri, 22 Jan 2016 03:42:34 +0000 (20:42 -0700)
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>
drivers/misc/Kconfig
drivers/misc/Makefile
drivers/misc/pwrseq-uclass.c [new file with mode: 0644]
include/dm/uclass-id.h
include/pwrseq.h [new file with mode: 0644]

index b92da4e202f824c2c35b4eb9aa00bfd876e67523..cba236334c0e400101ff53c31ea1e8c57568b655 100644 (file)
@@ -90,6 +90,24 @@ config MXC_OCOTP
          Programmable memory pages that are stored on the some
          Freescale i.MX processors.
 
+config PWRSEQ
+       bool "Enable power-sequencing drivers"
+       depends on DM
+       help
+         Power-sequencing drivers provide support for controlling power for
+         devices. They are typically referenced by a phandle from another
+         device. When the device is started up, its power sequence can be
+         initiated.
+
+config SPL_PWRSEQ
+       bool "Enable power-sequencing drivers for SPL"
+       depends on PWRSEQ
+       help
+         Power-sequencing drivers provide support for controlling power for
+         devices. They are typically referenced by a phandle from another
+         device. When the device is started up, its power sequence can be
+         initiated.
+
 config PCA9551_LED
        bool "Enable PCA9551 LED driver"
        help
index aa137f50ea3bb6db2c2840325802318016fd859e..fc8eb6f78526030b3f7e732a5f233bd5546b6bbc 100644 (file)
@@ -24,6 +24,7 @@ obj-$(CONFIG_MXC_OCOTP) += mxc_ocotp.o
 obj-$(CONFIG_MXS_OCOTP) += mxs_ocotp.o
 obj-$(CONFIG_NS87308) += ns87308.o
 obj-$(CONFIG_PDSP188x) += pdsp188x.o
+obj-$(CONFIG_$(SPL_)PWRSEQ) += pwrseq-uclass.o
 obj-$(CONFIG_SANDBOX) += reset_sandbox.o
 ifdef CONFIG_DM_I2C
 obj-$(CONFIG_SANDBOX) += i2c_eeprom_emul.o
diff --git a/drivers/misc/pwrseq-uclass.c b/drivers/misc/pwrseq-uclass.c
new file mode 100644 (file)
index 0000000..8ed2ad4
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2015 Google, Inc
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <dm.h>
+#include <pwrseq.h>
+
+int pwrseq_set_power(struct udevice *dev, bool enable)
+{
+       struct pwrseq_ops *ops = pwrseq_get_ops(dev);
+
+       if (!ops->set_power)
+               return -ENOSYS;
+
+       return ops->set_power(dev, enable);
+}
+
+UCLASS_DRIVER(pwrseq) = {
+       .id             = UCLASS_PWRSEQ,
+       .name           = "pwrseq",
+};
index a0a3a79aac975c234a0b05e1b647d38cad3009de..b5f43ae95e616912371a7751b0716f2207750384 100644 (file)
@@ -51,6 +51,7 @@ enum uclass_id {
        UCLASS_PINCTRL,         /* Pinctrl (pin muxing/configuration) device */
        UCLASS_PINCONFIG,       /* Pin configuration node device */
        UCLASS_PMIC,            /* PMIC I/O device */
+       UCLASS_PWRSEQ,          /* Power sequence device */
        UCLASS_REGULATOR,       /* Regulator device */
        UCLASS_RESET,           /* Reset device */
        UCLASS_REMOTEPROC,      /* Remote Processor device */
diff --git a/include/pwrseq.h b/include/pwrseq.h
new file mode 100644 (file)
index 0000000..b934f29
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2013 Google, Inc
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#ifndef __pwrseq_h
+#define __pwrseq_h
+
+struct pwrseq_ops {
+       int (*set_power)(struct udevice *dev, bool enable);
+};
+
+#define pwrseq_get_ops(dev)    ((struct pwrseq_ops *)(dev)->driver->ops)
+
+int pwrseq_set_power(struct udevice *dev, bool enable);
+
+#endif