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 Inline Diff

drivers/misc/Kconfig
1 # 1 #
2 # Multifunction miscellaneous devices 2 # Multifunction miscellaneous devices
3 # 3 #
4 4
5 menu "Multifunction device drivers" 5 menu "Multifunction device drivers"
6 6
7 config MISC 7 config MISC
8 bool "Enable Driver Model for Misc drivers" 8 bool "Enable Driver Model for Misc drivers"
9 depends on DM 9 depends on DM
10 help 10 help
11 Enable driver model for miscellaneous devices. This class is 11 Enable driver model for miscellaneous devices. This class is
12 used only for those do not fit other more general classes. A 12 used only for those do not fit other more general classes. A
13 set of generic read, write and ioctl methods may be used to 13 set of generic read, write and ioctl methods may be used to
14 access the device. 14 access the device.
15 15
16 config ALTERA_SYSID 16 config ALTERA_SYSID
17 bool "Altera Sysid support" 17 bool "Altera Sysid support"
18 depends on MISC 18 depends on MISC
19 help 19 help
20 Select this to enable a sysid for Altera devices. Please find 20 Select this to enable a sysid for Altera devices. Please find
21 details on the "Embedded Peripherals IP User Guide" of Altera. 21 details on the "Embedded Peripherals IP User Guide" of Altera.
22 22
23 config CMD_CROS_EC 23 config CMD_CROS_EC
24 bool "Enable crosec command" 24 bool "Enable crosec command"
25 depends on CROS_EC 25 depends on CROS_EC
26 help 26 help
27 Enable command-line access to the Chrome OS EC (Embedded 27 Enable command-line access to the Chrome OS EC (Embedded
28 Controller). This provides the 'crosec' command which has 28 Controller). This provides the 'crosec' command which has
29 a number of sub-commands for performing EC tasks such as 29 a number of sub-commands for performing EC tasks such as
30 updating its flash, accessing a small saved context area 30 updating its flash, accessing a small saved context area
31 and talking to the I2C bus behind the EC (if there is one). 31 and talking to the I2C bus behind the EC (if there is one).
32 32
33 config CROS_EC 33 config CROS_EC
34 bool "Enable Chrome OS EC" 34 bool "Enable Chrome OS EC"
35 help 35 help
36 Enable access to the Chrome OS EC. This is a separate 36 Enable access to the Chrome OS EC. This is a separate
37 microcontroller typically available on a SPI bus on Chromebooks. It 37 microcontroller typically available on a SPI bus on Chromebooks. It
38 provides access to the keyboard, some internal storage and may 38 provides access to the keyboard, some internal storage and may
39 control access to the battery and main PMIC depending on the 39 control access to the battery and main PMIC depending on the
40 device. You can use the 'crosec' command to access it. 40 device. You can use the 'crosec' command to access it.
41 41
42 config CROS_EC_I2C 42 config CROS_EC_I2C
43 bool "Enable Chrome OS EC I2C driver" 43 bool "Enable Chrome OS EC I2C driver"
44 depends on CROS_EC 44 depends on CROS_EC
45 help 45 help
46 Enable I2C access to the Chrome OS EC. This is used on older 46 Enable I2C access to the Chrome OS EC. This is used on older
47 ARM Chromebooks such as snow and spring before the standard bus 47 ARM Chromebooks such as snow and spring before the standard bus
48 changed to SPI. The EC will accept commands across the I2C using 48 changed to SPI. The EC will accept commands across the I2C using
49 a special message protocol, and provide responses. 49 a special message protocol, and provide responses.
50 50
51 config CROS_EC_LPC 51 config CROS_EC_LPC
52 bool "Enable Chrome OS EC LPC driver" 52 bool "Enable Chrome OS EC LPC driver"
53 depends on CROS_EC 53 depends on CROS_EC
54 help 54 help
55 Enable I2C access to the Chrome OS EC. This is used on x86 55 Enable I2C access to the Chrome OS EC. This is used on x86
56 Chromebooks such as link and falco. The keyboard is provided 56 Chromebooks such as link and falco. The keyboard is provided
57 through a legacy port interface, so on x86 machines the main 57 through a legacy port interface, so on x86 machines the main
58 function of the EC is power and thermal management. 58 function of the EC is power and thermal management.
59 59
60 config CROS_EC_SANDBOX 60 config CROS_EC_SANDBOX
61 bool "Enable Chrome OS EC sandbox driver" 61 bool "Enable Chrome OS EC sandbox driver"
62 depends on CROS_EC && SANDBOX 62 depends on CROS_EC && SANDBOX
63 help 63 help
64 Enable a sandbox emulation of the Chrome OS EC. This supports 64 Enable a sandbox emulation of the Chrome OS EC. This supports
65 keyboard (use the -l flag to enable the LCD), verified boot context, 65 keyboard (use the -l flag to enable the LCD), verified boot context,
66 EC flash read/write/erase support and a few other things. It is 66 EC flash read/write/erase support and a few other things. It is
67 enough to perform a Chrome OS verified boot on sandbox. 67 enough to perform a Chrome OS verified boot on sandbox.
68 68
69 config CROS_EC_SPI 69 config CROS_EC_SPI
70 bool "Enable Chrome OS EC SPI driver" 70 bool "Enable Chrome OS EC SPI driver"
71 depends on CROS_EC 71 depends on CROS_EC
72 help 72 help
73 Enable SPI access to the Chrome OS EC. This is used on newer 73 Enable SPI access to the Chrome OS EC. This is used on newer
74 ARM Chromebooks such as pit, pi and nyan-big. The SPI interface 74 ARM Chromebooks such as pit, pi and nyan-big. The SPI interface
75 provides a faster and more robust interface than I2C but the bugs 75 provides a faster and more robust interface than I2C but the bugs
76 are less interesting. 76 are less interesting.
77 77
78 config FSL_SEC_MON 78 config FSL_SEC_MON
79 bool "Enable FSL SEC_MON Driver" 79 bool "Enable FSL SEC_MON Driver"
80 help 80 help
81 Freescale Security Monitor block is responsible for monitoring 81 Freescale Security Monitor block is responsible for monitoring
82 system states. 82 system states.
83 Security Monitor can be transitioned on any security failures, 83 Security Monitor can be transitioned on any security failures,
84 like software violations or hardware security violations. 84 like software violations or hardware security violations.
85 85
86 config MXC_OCOTP 86 config MXC_OCOTP
87 bool "Enable MXC OCOTP Driver" 87 bool "Enable MXC OCOTP Driver"
88 help 88 help
89 If you say Y here, you will get support for the One Time 89 If you say Y here, you will get support for the One Time
90 Programmable memory pages that are stored on the some 90 Programmable memory pages that are stored on the some
91 Freescale i.MX processors. 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 config PCA9551_LED 111 config PCA9551_LED
94 bool "Enable PCA9551 LED driver" 112 bool "Enable PCA9551 LED driver"
95 help 113 help
96 Enable driver for PCA9551 LED controller. This controller 114 Enable driver for PCA9551 LED controller. This controller
97 is connected via I2C. So I2C needs to be enabled. 115 is connected via I2C. So I2C needs to be enabled.
98 116
99 config PCA9551_I2C_ADDR 117 config PCA9551_I2C_ADDR
100 hex "I2C address of PCA9551 LED controller" 118 hex "I2C address of PCA9551 LED controller"
101 depends on PCA9551_LED 119 depends on PCA9551_LED
102 default 0x60 120 default 0x60
103 help 121 help
104 The I2C address of the PCA9551 LED controller. 122 The I2C address of the PCA9551 LED controller.
105 123
106 config RESET 124 config RESET
107 bool "Enable support for reset drivers" 125 bool "Enable support for reset drivers"
108 depends on DM 126 depends on DM
109 help 127 help
110 Enable reset drivers which can be used to reset the CPU or board. 128 Enable reset drivers which can be used to reset the CPU or board.
111 Each driver can provide a reset method which will be called to 129 Each driver can provide a reset method which will be called to
112 effect a reset. The uclass will try all available drivers when 130 effect a reset. The uclass will try all available drivers when
113 reset_walk() is called. 131 reset_walk() is called.
114 132
115 endmenu 133 endmenu
116 134
drivers/misc/Makefile
1 # 1 #
2 # (C) Copyright 2000-2007 2 # (C) Copyright 2000-2007
3 # Wolfgang Denk, DENX Software Engineering, wd@denx.de. 3 # Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 # 4 #
5 # SPDX-License-Identifier: GPL-2.0+ 5 # SPDX-License-Identifier: GPL-2.0+
6 # 6 #
7 7
8 obj-$(CONFIG_MISC) += misc-uclass.o 8 obj-$(CONFIG_MISC) += misc-uclass.o
9 obj-$(CONFIG_ALI152X) += ali512x.o 9 obj-$(CONFIG_ALI152X) += ali512x.o
10 obj-$(CONFIG_ALTERA_SYSID) += altera_sysid.o 10 obj-$(CONFIG_ALTERA_SYSID) += altera_sysid.o
11 obj-$(CONFIG_DS4510) += ds4510.o 11 obj-$(CONFIG_DS4510) += ds4510.o
12 obj-$(CONFIG_CBMEM_CONSOLE) += cbmem_console.o 12 obj-$(CONFIG_CBMEM_CONSOLE) += cbmem_console.o
13 obj-$(CONFIG_CROS_EC) += cros_ec.o 13 obj-$(CONFIG_CROS_EC) += cros_ec.o
14 obj-$(CONFIG_CROS_EC_LPC) += cros_ec_lpc.o 14 obj-$(CONFIG_CROS_EC_LPC) += cros_ec_lpc.o
15 obj-$(CONFIG_CROS_EC_I2C) += cros_ec_i2c.o 15 obj-$(CONFIG_CROS_EC_I2C) += cros_ec_i2c.o
16 obj-$(CONFIG_CROS_EC_SANDBOX) += cros_ec_sandbox.o 16 obj-$(CONFIG_CROS_EC_SANDBOX) += cros_ec_sandbox.o
17 obj-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o 17 obj-$(CONFIG_CROS_EC_SPI) += cros_ec_spi.o
18 obj-$(CONFIG_FSL_DEBUG_SERVER) += fsl_debug_server.o 18 obj-$(CONFIG_FSL_DEBUG_SERVER) += fsl_debug_server.o
19 obj-$(CONFIG_FSL_IIM) += fsl_iim.o 19 obj-$(CONFIG_FSL_IIM) += fsl_iim.o
20 obj-$(CONFIG_GPIO_LED) += gpio_led.o 20 obj-$(CONFIG_GPIO_LED) += gpio_led.o
21 obj-$(CONFIG_I2C_EEPROM) += i2c_eeprom.o 21 obj-$(CONFIG_I2C_EEPROM) += i2c_eeprom.o
22 obj-$(CONFIG_FSL_MC9SDZ60) += mc9sdz60.o 22 obj-$(CONFIG_FSL_MC9SDZ60) += mc9sdz60.o
23 obj-$(CONFIG_MXC_OCOTP) += mxc_ocotp.o 23 obj-$(CONFIG_MXC_OCOTP) += mxc_ocotp.o
24 obj-$(CONFIG_MXS_OCOTP) += mxs_ocotp.o 24 obj-$(CONFIG_MXS_OCOTP) += mxs_ocotp.o
25 obj-$(CONFIG_NS87308) += ns87308.o 25 obj-$(CONFIG_NS87308) += ns87308.o
26 obj-$(CONFIG_PDSP188x) += pdsp188x.o 26 obj-$(CONFIG_PDSP188x) += pdsp188x.o
27 obj-$(CONFIG_$(SPL_)PWRSEQ) += pwrseq-uclass.o
27 obj-$(CONFIG_SANDBOX) += reset_sandbox.o 28 obj-$(CONFIG_SANDBOX) += reset_sandbox.o
28 ifdef CONFIG_DM_I2C 29 ifdef CONFIG_DM_I2C
29 obj-$(CONFIG_SANDBOX) += i2c_eeprom_emul.o 30 obj-$(CONFIG_SANDBOX) += i2c_eeprom_emul.o
30 endif 31 endif
31 obj-$(CONFIG_SMSC_LPC47M) += smsc_lpc47m.o 32 obj-$(CONFIG_SMSC_LPC47M) += smsc_lpc47m.o
32 obj-$(CONFIG_STATUS_LED) += status_led.o 33 obj-$(CONFIG_STATUS_LED) += status_led.o
33 obj-$(CONFIG_SANDBOX) += swap_case.o 34 obj-$(CONFIG_SANDBOX) += swap_case.o
34 obj-$(CONFIG_SANDBOX) += syscon_sandbox.o 35 obj-$(CONFIG_SANDBOX) += syscon_sandbox.o
35 obj-$(CONFIG_TWL4030_LED) += twl4030_led.o 36 obj-$(CONFIG_TWL4030_LED) += twl4030_led.o
36 obj-$(CONFIG_FSL_IFC) += fsl_ifc.o 37 obj-$(CONFIG_FSL_IFC) += fsl_ifc.o
37 obj-$(CONFIG_FSL_SEC_MON) += fsl_sec_mon.o 38 obj-$(CONFIG_FSL_SEC_MON) += fsl_sec_mon.o
38 obj-$(CONFIG_PCA9551_LED) += pca9551_led.o 39 obj-$(CONFIG_PCA9551_LED) += pca9551_led.o
39 obj-$(CONFIG_RESET) += reset-uclass.o 40 obj-$(CONFIG_RESET) += reset-uclass.o
40 obj-$(CONFIG_FSL_DEVICE_DISABLE) += fsl_devdis.o 41 obj-$(CONFIG_FSL_DEVICE_DISABLE) += fsl_devdis.o
41 42
drivers/misc/pwrseq-uclass.c
File was created 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 };
25
include/dm/uclass-id.h
1 /* 1 /*
2 * Copyright (c) 2013 Google, Inc 2 * Copyright (c) 2013 Google, Inc
3 * 3 *
4 * (C) Copyright 2012 4 * (C) Copyright 2012
5 * Pavel Herrmann <morpheus.ibis@gmail.com> 5 * Pavel Herrmann <morpheus.ibis@gmail.com>
6 * 6 *
7 * SPDX-License-Identifier: GPL-2.0+ 7 * SPDX-License-Identifier: GPL-2.0+
8 */ 8 */
9 9
10 #ifndef _DM_UCLASS_ID_H 10 #ifndef _DM_UCLASS_ID_H
11 #define _DM_UCLASS_ID_H 11 #define _DM_UCLASS_ID_H
12 12
13 /* TODO(sjg@chromium.org): this could be compile-time generated */ 13 /* TODO(sjg@chromium.org): this could be compile-time generated */
14 enum uclass_id { 14 enum uclass_id {
15 /* These are used internally by driver model */ 15 /* These are used internally by driver model */
16 UCLASS_ROOT = 0, 16 UCLASS_ROOT = 0,
17 UCLASS_DEMO, 17 UCLASS_DEMO,
18 UCLASS_TEST, 18 UCLASS_TEST,
19 UCLASS_TEST_FDT, 19 UCLASS_TEST_FDT,
20 UCLASS_TEST_BUS, 20 UCLASS_TEST_BUS,
21 UCLASS_SPI_EMUL, /* sandbox SPI device emulator */ 21 UCLASS_SPI_EMUL, /* sandbox SPI device emulator */
22 UCLASS_I2C_EMUL, /* sandbox I2C device emulator */ 22 UCLASS_I2C_EMUL, /* sandbox I2C device emulator */
23 UCLASS_PCI_EMUL, /* sandbox PCI device emulator */ 23 UCLASS_PCI_EMUL, /* sandbox PCI device emulator */
24 UCLASS_USB_EMUL, /* sandbox USB bus device emulator */ 24 UCLASS_USB_EMUL, /* sandbox USB bus device emulator */
25 UCLASS_SIMPLE_BUS, /* bus with child devices */ 25 UCLASS_SIMPLE_BUS, /* bus with child devices */
26 26
27 /* U-Boot uclasses start here - in alphabetical order */ 27 /* U-Boot uclasses start here - in alphabetical order */
28 UCLASS_ADC, /* Analog-to-digital converter */ 28 UCLASS_ADC, /* Analog-to-digital converter */
29 UCLASS_CLK, /* Clock source, e.g. used by peripherals */ 29 UCLASS_CLK, /* Clock source, e.g. used by peripherals */
30 UCLASS_CPU, /* CPU, typically part of an SoC */ 30 UCLASS_CPU, /* CPU, typically part of an SoC */
31 UCLASS_CROS_EC, /* Chrome OS EC */ 31 UCLASS_CROS_EC, /* Chrome OS EC */
32 UCLASS_DISPLAY_PORT, /* Display port video */ 32 UCLASS_DISPLAY_PORT, /* Display port video */
33 UCLASS_RAM, /* RAM controller */ 33 UCLASS_RAM, /* RAM controller */
34 UCLASS_ETH, /* Ethernet device */ 34 UCLASS_ETH, /* Ethernet device */
35 UCLASS_GPIO, /* Bank of general-purpose I/O pins */ 35 UCLASS_GPIO, /* Bank of general-purpose I/O pins */
36 UCLASS_I2C, /* I2C bus */ 36 UCLASS_I2C, /* I2C bus */
37 UCLASS_I2C_EEPROM, /* I2C EEPROM device */ 37 UCLASS_I2C_EEPROM, /* I2C EEPROM device */
38 UCLASS_I2C_GENERIC, /* Generic I2C device */ 38 UCLASS_I2C_GENERIC, /* Generic I2C device */
39 UCLASS_I2C_MUX, /* I2C multiplexer */ 39 UCLASS_I2C_MUX, /* I2C multiplexer */
40 UCLASS_KEYBOARD, /* Keyboard input device */ 40 UCLASS_KEYBOARD, /* Keyboard input device */
41 UCLASS_LED, /* Light-emitting diode (LED) */ 41 UCLASS_LED, /* Light-emitting diode (LED) */
42 UCLASS_LPC, /* x86 'low pin count' interface */ 42 UCLASS_LPC, /* x86 'low pin count' interface */
43 UCLASS_MASS_STORAGE, /* Mass storage device */ 43 UCLASS_MASS_STORAGE, /* Mass storage device */
44 UCLASS_MISC, /* Miscellaneous device */ 44 UCLASS_MISC, /* Miscellaneous device */
45 UCLASS_MMC, /* SD / MMC card or chip */ 45 UCLASS_MMC, /* SD / MMC card or chip */
46 UCLASS_MOD_EXP, /* RSA Mod Exp device */ 46 UCLASS_MOD_EXP, /* RSA Mod Exp device */
47 UCLASS_MTD, /* Memory Technology Device (MTD) device */ 47 UCLASS_MTD, /* Memory Technology Device (MTD) device */
48 UCLASS_PCH, /* x86 platform controller hub */ 48 UCLASS_PCH, /* x86 platform controller hub */
49 UCLASS_PCI, /* PCI bus */ 49 UCLASS_PCI, /* PCI bus */
50 UCLASS_PCI_GENERIC, /* Generic PCI bus device */ 50 UCLASS_PCI_GENERIC, /* Generic PCI bus device */
51 UCLASS_PINCTRL, /* Pinctrl (pin muxing/configuration) device */ 51 UCLASS_PINCTRL, /* Pinctrl (pin muxing/configuration) device */
52 UCLASS_PINCONFIG, /* Pin configuration node device */ 52 UCLASS_PINCONFIG, /* Pin configuration node device */
53 UCLASS_PMIC, /* PMIC I/O device */ 53 UCLASS_PMIC, /* PMIC I/O device */
54 UCLASS_PWRSEQ, /* Power sequence device */
54 UCLASS_REGULATOR, /* Regulator device */ 55 UCLASS_REGULATOR, /* Regulator device */
55 UCLASS_RESET, /* Reset device */ 56 UCLASS_RESET, /* Reset device */
56 UCLASS_REMOTEPROC, /* Remote Processor device */ 57 UCLASS_REMOTEPROC, /* Remote Processor device */
57 UCLASS_RTC, /* Real time clock device */ 58 UCLASS_RTC, /* Real time clock device */
58 UCLASS_SERIAL, /* Serial UART */ 59 UCLASS_SERIAL, /* Serial UART */
59 UCLASS_SPI, /* SPI bus */ 60 UCLASS_SPI, /* SPI bus */
60 UCLASS_SPI_FLASH, /* SPI flash */ 61 UCLASS_SPI_FLASH, /* SPI flash */
61 UCLASS_SPI_GENERIC, /* Generic SPI flash target */ 62 UCLASS_SPI_GENERIC, /* Generic SPI flash target */
62 UCLASS_SYSCON, /* System configuration device */ 63 UCLASS_SYSCON, /* System configuration device */
63 UCLASS_THERMAL, /* Thermal sensor */ 64 UCLASS_THERMAL, /* Thermal sensor */
64 UCLASS_TIMER, /* Timer device */ 65 UCLASS_TIMER, /* Timer device */
65 UCLASS_TPM, /* Trusted Platform Module TIS interface */ 66 UCLASS_TPM, /* Trusted Platform Module TIS interface */
66 UCLASS_USB, /* USB bus */ 67 UCLASS_USB, /* USB bus */
67 UCLASS_USB_DEV_GENERIC, /* USB generic device */ 68 UCLASS_USB_DEV_GENERIC, /* USB generic device */
68 UCLASS_USB_HUB, /* USB hub */ 69 UCLASS_USB_HUB, /* USB hub */
69 UCLASS_VIDEO, /* Video or LCD device */ 70 UCLASS_VIDEO, /* Video or LCD device */
70 UCLASS_VIDEO_BRIDGE, /* Video bridge, e.g. DisplayPort to LVDS */ 71 UCLASS_VIDEO_BRIDGE, /* Video bridge, e.g. DisplayPort to LVDS */
71 UCLASS_VIDEO_CONSOLE, /* Text console driver for video device */ 72 UCLASS_VIDEO_CONSOLE, /* Text console driver for video device */
72 73
73 UCLASS_COUNT, 74 UCLASS_COUNT,
74 UCLASS_INVALID = -1, 75 UCLASS_INVALID = -1,
75 }; 76 };
76 77
77 #endif 78 #endif
78 79
File was created 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
19