- Move P2SB from Apollo Lake to a more generic location
- Add a function to find a device by drvdata in DM core
- Enhancement of DM IRQ uclass driver
- Add a clock driver for Intel devices
- Add support for ACPI general-purpose events
- Add a TPM driver for H1/Cr50
- Enable TPM on Google Chromebook Coral
This commit is contained in:
Tom Rini
2020-02-10 12:27:31 -05:00
38 changed files with 1641 additions and 95 deletions

View File

@@ -56,6 +56,8 @@ enum {
enum {
DM_TEST_TYPE_FIRST = 0,
DM_TEST_TYPE_SECOND,
DM_TEST_TYPE_COUNT,
};
/* The number added to the ping total on each probe */

View File

@@ -350,6 +350,20 @@ int uclass_first_device_check(enum uclass_id id, struct udevice **devp);
*/
int uclass_next_device_check(struct udevice **devp);
/**
* uclass_first_device_drvdata() - Find the first device with given driver data
*
* This searches through the devices for a particular uclass looking for one
* that has the given driver data.
*
* @id: Uclass ID to check
* @driver_data: Driver data to search for
* @devp: Returns pointer to the first matching device in that uclass, if found
* @return 0 if found, -ENODEV if not found, other -ve on error
*/
int uclass_first_device_drvdata(enum uclass_id id, ulong driver_data,
struct udevice **devp);
/**
* uclass_resolve_seq() - Resolve a device's sequence number
*
@@ -365,6 +379,23 @@ int uclass_next_device_check(struct udevice **devp);
*/
int uclass_resolve_seq(struct udevice *dev);
/**
* uclass_id_foreach_dev() - Helper function to iteration through devices
*
* This creates a for() loop which works through the available devices in
* a uclass ID in order from start to end.
*
* If for some reason the uclass cannot be found, this does nothing.
*
* @id: enum uclass_id ID to use
* @pos: struct udevice * to hold the current device. Set to NULL when there
* are no more devices.
* @uc: temporary uclass variable (struct udevice *)
*/
#define uclass_id_foreach_dev(id, pos, uc) \
if (!uclass_get(id, &uc)) \
list_for_each_entry(pos, &uc->dev_head, uclass_node)
/**
* uclass_foreach_dev() - Helper function to iteration through devices
*

View File

@@ -0,0 +1,15 @@
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* This header provides constants for Intel clocks.
*
* The constants defined in this header are used in the device tree
*
* Copyright 2019 Google LLC
*/
#ifndef _DT_BINDINGS_CLK_INTEL_H
#define _DT_BINDINGS_CLK_INTEL_H
#define CLK_I2C 1
#endif

View File

@@ -8,8 +8,32 @@
#ifndef __irq_H
#define __irq_H
/*
* Interrupt controller types available. You can find a particular one with
* irq_first_device_type()
*/
enum irq_dev_t {
X86_IRQT_BASE, /* Base controller */
X86_IRQT_ITSS, /* ITSS controller, e.g. on APL */
X86_IRQT_ACPI_GPE, /* ACPI General-Purpose Events controller */
SANDBOX_IRQT_BASE, /* Sandbox testing */
};
/**
* struct irq - A single irq line handled by an interrupt controller
*
* @dev: IRQ device that handles this irq
* @id: ID to identify this irq with the device
*/
struct irq {
struct udevice *dev;
ulong id;
};
/**
* struct irq_ops - Operations for the IRQ
*
* Each IRQ device can handle mulitple IRQ lines
*/
struct irq_ops {
/**
@@ -46,6 +70,55 @@ struct irq_ops {
* @return 0
*/
int (*restore_polarities)(struct udevice *dev);
/**
* read_and_clear() - get the value of an interrupt and clear it
*
* Clears the interrupt if pending
*
* @irq: IRQ line
* @return 0 if interrupt is not pending, 1 if it was (and so has been
* cleared), -ve on error
*/
int (*read_and_clear)(struct irq *irq);
/**
* of_xlate - Translate a client's device-tree (OF) irq specifier.
*
* The irq core calls this function as the first step in implementing
* a client's irq_get_by_*() call.
*
* If this function pointer is set to NULL, the irq core will use a
* default implementation, which assumes #interrupt-cells = <1>, and
* that the DT cell contains a simple integer irq ID.
*
* @irq: The irq struct to hold the translation result.
* @args: The irq specifier values from device tree.
* @return 0 if OK, or a negative error code.
*/
int (*of_xlate)(struct irq *irq, struct ofnode_phandle_args *args);
/**
* request - Request a translated irq.
*
* The irq core calls this function as the second step in
* implementing a client's irq_get_by_*() call, following a successful
* xxx_xlate() call, or as the only step in implementing a client's
* irq_request() call.
*
* @irq: The irq struct to request; this has been fille in by
* a previoux xxx_xlate() function call, or by the caller
* of irq_request().
* @return 0 if OK, or a negative error code.
*/
int (*request)(struct irq *irq);
/**
* free - Free a previously requested irq.
*
* This is the implementation of the client irq_free() API.
*
* @irq: The irq to free.
* @return 0 if OK, or a negative error code.
*/
int (*free)(struct irq *irq);
};
#define irq_get_ops(dev) ((struct irq_ops *)(dev)->driver->ops)
@@ -85,4 +158,69 @@ int irq_snapshot_polarities(struct udevice *dev);
*/
int irq_restore_polarities(struct udevice *dev);
/**
* read_and_clear() - get the value of an interrupt and clear it
*
* Clears the interrupt if pending
*
* @dev: IRQ device
* @return 0 if interrupt is not pending, 1 if it was (and so has been
* cleared), -ve on error
*/
int irq_read_and_clear(struct irq *irq);
/**
* irq_get_by_index - Get/request an irq by integer index.
*
* This looks up and requests an irq. The index is relative to the client
* device; each device is assumed to have n irqs associated with it somehow,
* and this function finds and requests one of them. The mapping of client
* device irq indices to provider irqs may be via device-tree
* properties, board-provided mapping tables, or some other mechanism.
*
* @dev: The client device.
* @index: The index of the irq to request, within the client's list of
* irqs.
* @irq: A pointer to a irq struct to initialise.
* @return 0 if OK, or a negative error code.
*/
int irq_get_by_index(struct udevice *dev, int index, struct irq *irq);
/**
* irq_request - Request a irq by provider-specific ID.
*
* This requests a irq using a provider-specific ID. Generally, this function
* should not be used, since irq_get_by_index/name() provide an interface that
* better separates clients from intimate knowledge of irq providers.
* However, this function may be useful in core SoC-specific code.
*
* @dev: The irq provider device.
* @irq: A pointer to a irq struct to initialise. The caller must
* have already initialised any field in this struct which the
* irq provider uses to identify the irq.
* @return 0 if OK, or a negative error code.
*/
int irq_request(struct udevice *dev, struct irq *irq);
/**
* irq_free - Free a previously requested irq.
*
* @irq: A irq struct that was previously successfully requested by
* irq_request/get_by_*().
* @return 0 if OK, or a negative error code.
*/
int irq_free(struct irq *irq);
/**
* irq_first_device_type() - Get a particular interrupt controller
*
* On success this returns an activated interrupt device.
*
* @type: Type to find
* @devp: Returns the device, if found
* @return 0 if OK, -ENODEV if not found, other -ve error if uclass failed to
* probe
*/
int irq_first_device_type(enum irq_dev_t type, struct udevice **devp);
#endif

View File

@@ -161,6 +161,37 @@ enum tpm_index_attrs {
TPMA_NV_AUTHWRITE | TPMA_NV_POLICYWRITE,
};
enum {
TPM_ACCESS_VALID = 1 << 7,
TPM_ACCESS_ACTIVE_LOCALITY = 1 << 5,
TPM_ACCESS_REQUEST_PENDING = 1 << 2,
TPM_ACCESS_REQUEST_USE = 1 << 1,
TPM_ACCESS_ESTABLISHMENT = 1 << 0,
};
enum {
TPM_STS_FAMILY_SHIFT = 26,
TPM_STS_FAMILY_MASK = 0x3 << TPM_STS_FAMILY_SHIFT,
TPM_STS_FAMILY_TPM2 = 1 << TPM_STS_FAMILY_SHIFT,
TPM_STS_RESE_TESTABLISMENT_BIT = 1 << 25,
TPM_STS_COMMAND_CANCEL = 1 << 24,
TPM_STS_BURST_COUNT_SHIFT = 8,
TPM_STS_BURST_COUNT_MASK = 0xffff << TPM_STS_BURST_COUNT_SHIFT,
TPM_STS_VALID = 1 << 7,
TPM_STS_COMMAND_READY = 1 << 6,
TPM_STS_GO = 1 << 5,
TPM_STS_DATA_AVAIL = 1 << 4,
TPM_STS_DATA_EXPECT = 1 << 3,
TPM_STS_SELF_TEST_DONE = 1 << 2,
TPM_STS_RESPONSE_RETRY = 1 << 1,
};
enum {
TPM_CMD_COUNT_OFFSET = 2,
TPM_CMD_ORDINAL_OFFSET = 6,
TPM_MAX_BUF_SIZE = 1260,
};
/**
* Issue a TPM2_Startup command.
*