summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2018-09-30 18:16:51 -0400
committerTom Rini <trini@konsulko.com>2018-09-30 18:16:51 -0400
commitd24c1d0f4da3b081a4fedf7ae2a08790871f08d0 (patch)
tree30051c24000bbb640b6296c8a71a8e05f0cc06e4 /include
parent2c1e16b9d2e3a6138acf4ffd9866e47ddbe6d453 (diff)
parent31b8217e83a63d1c8c70edcdcdf5aff3b1791640 (diff)
Merge git://git.denx.de/u-boot-dm
Diffstat (limited to 'include')
-rw-r--r--include/board.h139
-rw-r--r--include/clk.h2
-rw-r--r--include/dm.h1
-rw-r--r--include/dm/device.h16
-rw-r--r--include/dm/ofnode.h46
-rw-r--r--include/dm/uclass-id.h1
6 files changed, 203 insertions, 2 deletions
diff --git a/include/board.h b/include/board.h
new file mode 100644
index 0000000000..9dc78684f8
--- /dev/null
+++ b/include/board.h
@@ -0,0 +1,139 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * (C) Copyright 2017
+ * Mario Six, Guntermann & Drunck GmbH, mario.six@gdsys.cc
+ */
+
+/*
+ * This uclass encapsulates hardware methods to gather information about a
+ * board or a specific device such as hard-wired GPIOs on GPIO expanders,
+ * read-only data in flash ICs, or similar.
+ *
+ * The interface offers functions to read the usual standard data types (bool,
+ * int, string) from the device, each of which is identified by a static
+ * numeric ID (which will usually be defined as a enum in a header file).
+ *
+ * If for example the board had a read-only serial number flash IC, we could
+ * call
+ *
+ * ret = board_detect(dev);
+ * if (ret) {
+ * debug("board device not found.");
+ * return ret;
+ * }
+ *
+ * ret = board_get_int(dev, ID_SERIAL_NUMBER, &serial);
+ * if (ret) {
+ * debug("Error when reading serial number from device.");
+ * return ret;
+ * }
+ *
+ * to read the serial number.
+ */
+
+struct board_ops {
+ /**
+ * detect() - Run the hardware info detection procedure for this
+ * device.
+ * @dev: The device containing the information
+ *
+ * This operation might take a long time (e.g. read from EEPROM,
+ * check the presence of a device on a bus etc.), hence this is not
+ * done in the probe() method, but later during operation in this
+ * dedicated method.
+ *
+ * Return: 0 if OK, -ve on error.
+ */
+ int (*detect)(struct udevice *dev);
+
+ /**
+ * get_bool() - Read a specific bool data value that describes the
+ * hardware setup.
+ * @dev: The board instance to gather the data.
+ * @id: A unique identifier for the bool value to be read.
+ * @val: Pointer to a buffer that receives the value read.
+ *
+ * Return: 0 if OK, -ve on error.
+ */
+ int (*get_bool)(struct udevice *dev, int id, bool *val);
+
+ /**
+ * get_int() - Read a specific int data value that describes the
+ * hardware setup.
+ * @dev: The board instance to gather the data.
+ * @id: A unique identifier for the int value to be read.
+ * @val: Pointer to a buffer that receives the value read.
+ *
+ * Return: 0 if OK, -ve on error.
+ */
+ int (*get_int)(struct udevice *dev, int id, int *val);
+
+ /**
+ * get_str() - Read a specific string data value that describes the
+ * hardware setup.
+ * @dev: The board instance to gather the data.
+ * @id: A unique identifier for the string value to be read.
+ * @size: The size of the buffer to receive the string data.
+ * @val: Pointer to a buffer that receives the value read.
+ *
+ * Return: 0 if OK, -ve on error.
+ */
+ int (*get_str)(struct udevice *dev, int id, size_t size, char *val);
+};
+
+#define board_get_ops(dev) ((struct board_ops *)(dev)->driver->ops)
+
+/**
+ * board_detect() - Run the hardware info detection procedure for this device.
+ *
+ * @dev: The device containing the information
+ *
+ * Return: 0 if OK, -ve on error.
+ */
+int board_detect(struct udevice *dev);
+
+/**
+ * board_get_bool() - Read a specific bool data value that describes the
+ * hardware setup.
+ * @dev: The board instance to gather the data.
+ * @id: A unique identifier for the bool value to be read.
+ * @val: Pointer to a buffer that receives the value read.
+ *
+ * Return: 0 if OK, -ve on error.
+ */
+int board_get_bool(struct udevice *dev, int id, bool *val);
+
+/**
+ * board_get_int() - Read a specific int data value that describes the
+ * hardware setup.
+ * @dev: The board instance to gather the data.
+ * @id: A unique identifier for the int value to be read.
+ * @val: Pointer to a buffer that receives the value read.
+ *
+ * Return: 0 if OK, -ve on error.
+ */
+int board_get_int(struct udevice *dev, int id, int *val);
+
+/**
+ * board_get_str() - Read a specific string data value that describes the
+ * hardware setup.
+ * @dev: The board instance to gather the data.
+ * @id: A unique identifier for the string value to be read.
+ * @size: The size of the buffer to receive the string data.
+ * @val: Pointer to a buffer that receives the value read.
+ *
+ * Return: 0 if OK, -ve on error.
+ */
+int board_get_str(struct udevice *dev, int id, size_t size, char *val);
+
+/**
+ * board_get() - Return the board device for the board in question.
+ * @devp: Pointer to structure to receive the board device.
+ *
+ * Since there can only be at most one board instance, the API can supply a
+ * function that returns the unique device. This is especially useful for use
+ * in board files.
+ *
+ * Return: 0 if OK, -ve on error.
+ */
+int board_get(struct udevice **devp);
diff --git a/include/clk.h b/include/clk.h
index c0a20cd47a..8e366163f9 100644
--- a/include/clk.h
+++ b/include/clk.h
@@ -21,7 +21,7 @@
*
* A driver that implements UCLASS_CLOCK is a clock provider. A provider will
* often implement multiple separate clocks, since the hardware it manages
- * often has this capability. clock_uclass.h describes the interface which
+ * often has this capability. clk-uclass.h describes the interface which
* clock providers must implement.
*
* Clock consumers/clients are the HW modules driven by the clock signals. This
diff --git a/include/dm.h b/include/dm.h
index bf4b07d28f..2e1afda440 100644
--- a/include/dm.h
+++ b/include/dm.h
@@ -6,7 +6,6 @@
#ifndef _DM_H_
#define _DM_H_
-#include <dm/ofnode.h>
#include <dm/device.h>
#include <dm/fdtaddr.h>
#include <dm/ofnode.h>
diff --git a/include/dm/device.h b/include/dm/device.h
index 3120b68fcc..9812d86f08 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -601,6 +601,22 @@ bool device_is_compatible(struct udevice *dev, const char *compat);
bool of_machine_is_compatible(const char *compat);
/**
+ * dev_disable_by_path() - Disable a device given its device tree path
+ *
+ * @path: The device tree path identifying the device to be disabled
+ * @return 0 on success, -ve on error
+ */
+int dev_disable_by_path(const char *path);
+
+/**
+ * dev_enable_by_path() - Enable a device given its device tree path
+ *
+ * @path: The device tree path identifying the device to be enabled
+ * @return 0 on success, -ve on error
+ */
+int dev_enable_by_path(const char *path);
+
+/**
* device_is_on_pci_bus - Test if a device is on a PCI bus
*
* @dev: device to test
diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h
index c06d77849c..2fc9fa39a3 100644
--- a/include/dm/ofnode.h
+++ b/include/dm/ofnode.h
@@ -764,4 +764,50 @@ u64 ofnode_translate_address(ofnode node, const fdt32_t *in_addr);
* @return true if OK, false if the compatible is not found
*/
int ofnode_device_is_compatible(ofnode node, const char *compat);
+
+/**
+ * ofnode_write_prop() - Set a property of a ofnode
+ *
+ * Note that the value passed to the function is *not* allocated by the
+ * function itself, but must be allocated by the caller if necessary.
+ *
+ * @node: The node for whose property should be set
+ * @propname: The name of the property to set
+ * @len: The length of the new value of the property
+ * @value: The new value of the property (must be valid prior to calling
+ * the function)
+ * @return 0 if successful, -ve on error
+ */
+int ofnode_write_prop(ofnode node, const char *propname, int len,
+ const void *value);
+
+/**
+ * ofnode_write_string() - Set a string property of a ofnode
+ *
+ * Note that the value passed to the function is *not* allocated by the
+ * function itself, but must be allocated by the caller if necessary.
+ *
+ * @node: The node for whose string property should be set
+ * @propname: The name of the string property to set
+ * @value: The new value of the string property (must be valid prior to
+ * calling the function)
+ * @return 0 if successful, -ve on error
+ */
+int ofnode_write_string(ofnode node, const char *propname, const char *value);
+
+/**
+ * ofnode_set_enabled() - Enable or disable a device tree node given by its
+ * ofnode
+ *
+ * This function effectively sets the node's "status" property to either "okay"
+ * or "disable", hence making it available for driver model initialization or
+ * not.
+ *
+ * @node: The node to enable
+ * @value: Flag that tells the function to either disable or enable the
+ * node
+ * @return 0 if successful, -ve on error
+ */
+int ofnode_set_enabled(ofnode node, bool value);
+
#endif
diff --git a/include/dm/uclass-id.h b/include/dm/uclass-id.h
index cefd9d7983..79fd3008d5 100644
--- a/include/dm/uclass-id.h
+++ b/include/dm/uclass-id.h
@@ -30,6 +30,7 @@ enum uclass_id {
UCLASS_ADC, /* Analog-to-digital converter */
UCLASS_AHCI, /* SATA disk controller */
UCLASS_BLK, /* Block device */
+ UCLASS_BOARD, /* Device information from hardware */
UCLASS_CLK, /* Clock source, e.g. used by peripherals */
UCLASS_CPU, /* CPU, typically part of an SoC */
UCLASS_CROS_EC, /* Chrome OS EC */