mirror of
https://github.com/linux-sunxi/u-boot-sunxi.git
synced 2024-02-12 11:16:03 +08:00
Merge git://git.denx.de/u-boot-dm
This commit is contained in:
4
README
4
README
@ -1472,8 +1472,8 @@ The following options need to be configured:
|
|||||||
CONFIG_TPM
|
CONFIG_TPM
|
||||||
Support TPM devices.
|
Support TPM devices.
|
||||||
|
|
||||||
CONFIG_TPM_TIS_I2C
|
CONFIG_TPM_TIS_INFINEON
|
||||||
Support for i2c bus TPM devices. Only one device
|
Support for Infineon i2c bus TPM devices. Only one device
|
||||||
per system is supported at this time.
|
per system is supported at this time.
|
||||||
|
|
||||||
CONFIG_TPM_TIS_I2C_BURST_LIMITATION
|
CONFIG_TPM_TIS_I2C_BURST_LIMITATION
|
||||||
|
@ -449,6 +449,9 @@ static int initr_env(void)
|
|||||||
env_relocate();
|
env_relocate();
|
||||||
else
|
else
|
||||||
set_default_env(NULL);
|
set_default_env(NULL);
|
||||||
|
#ifdef CONFIG_OF_CONTROL
|
||||||
|
setenv_addr("fdtcontroladdr", gd->fdt_blob);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Initialize from environment */
|
/* Initialize from environment */
|
||||||
load_addr = getenv_ulong("loadaddr", 16, load_addr);
|
load_addr = getenv_ulong("loadaddr", 16, load_addr);
|
||||||
|
@ -443,7 +443,6 @@ TPM_COMMAND_NO_ARG(tpm_force_clear)
|
|||||||
TPM_COMMAND_NO_ARG(tpm_physical_enable)
|
TPM_COMMAND_NO_ARG(tpm_physical_enable)
|
||||||
TPM_COMMAND_NO_ARG(tpm_physical_disable)
|
TPM_COMMAND_NO_ARG(tpm_physical_disable)
|
||||||
|
|
||||||
#ifdef CONFIG_DM_TPM
|
|
||||||
static int get_tpm(struct udevice **devp)
|
static int get_tpm(struct udevice **devp)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
@ -476,11 +475,11 @@ static int do_tpm_info(cmd_tbl_t *cmdtp, int flag, int argc,
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
static int do_tpm_raw_transfer(cmd_tbl_t *cmdtp, int flag,
|
static int do_tpm_raw_transfer(cmd_tbl_t *cmdtp, int flag,
|
||||||
int argc, char * const argv[])
|
int argc, char * const argv[])
|
||||||
{
|
{
|
||||||
|
struct udevice *dev;
|
||||||
void *command;
|
void *command;
|
||||||
uint8_t response[1024];
|
uint8_t response[1024];
|
||||||
size_t count, response_length = sizeof(response);
|
size_t count, response_length = sizeof(response);
|
||||||
@ -492,17 +491,11 @@ static int do_tpm_raw_transfer(cmd_tbl_t *cmdtp, int flag,
|
|||||||
return CMD_RET_FAILURE;
|
return CMD_RET_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_DM_TPM
|
|
||||||
struct udevice *dev;
|
|
||||||
|
|
||||||
rc = get_tpm(&dev);
|
rc = get_tpm(&dev);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
rc = tpm_xfer(dev, command, count, response, &response_length);
|
rc = tpm_xfer(dev, command, count, response, &response_length);
|
||||||
#else
|
|
||||||
rc = tis_sendrecv(command, count, response, &response_length);
|
|
||||||
#endif
|
|
||||||
free(command);
|
free(command);
|
||||||
if (!rc) {
|
if (!rc) {
|
||||||
puts("tpm response:\n");
|
puts("tpm response:\n");
|
||||||
@ -657,9 +650,7 @@ TPM_COMMAND_NO_ARG(tpm_end_oiap)
|
|||||||
U_BOOT_CMD_MKENT(cmd, 0, 1, do_tpm_ ## cmd, "", "")
|
U_BOOT_CMD_MKENT(cmd, 0, 1, do_tpm_ ## cmd, "", "")
|
||||||
|
|
||||||
static cmd_tbl_t tpm_commands[] = {
|
static cmd_tbl_t tpm_commands[] = {
|
||||||
#ifdef CONFIG_DM_TPM
|
|
||||||
U_BOOT_CMD_MKENT(info, 0, 1, do_tpm_info, "", ""),
|
U_BOOT_CMD_MKENT(info, 0, 1, do_tpm_info, "", ""),
|
||||||
#endif
|
|
||||||
U_BOOT_CMD_MKENT(init, 0, 1,
|
U_BOOT_CMD_MKENT(init, 0, 1,
|
||||||
do_tpm_init, "", ""),
|
do_tpm_init, "", ""),
|
||||||
U_BOOT_CMD_MKENT(startup, 0, 1,
|
U_BOOT_CMD_MKENT(startup, 0, 1,
|
||||||
@ -730,9 +721,7 @@ U_BOOT_CMD(tpm, CONFIG_SYS_MAXARGS, 1, do_tpm,
|
|||||||
"cmd args...\n"
|
"cmd args...\n"
|
||||||
" - Issue TPM command <cmd> with arguments <args...>.\n"
|
" - Issue TPM command <cmd> with arguments <args...>.\n"
|
||||||
"Admin Startup and State Commands:\n"
|
"Admin Startup and State Commands:\n"
|
||||||
#ifdef CONFIG_DM_TPM
|
|
||||||
" info - Show information about the TPM\n"
|
" info - Show information about the TPM\n"
|
||||||
#endif
|
|
||||||
" init\n"
|
" init\n"
|
||||||
" - Put TPM into a state where it waits for 'startup' command.\n"
|
" - Put TPM into a state where it waits for 'startup' command.\n"
|
||||||
" startup mode\n"
|
" startup mode\n"
|
||||||
|
@ -281,7 +281,7 @@ static struct usb_device *usb_find_device(int devnum)
|
|||||||
|
|
||||||
if (!device_active(hub))
|
if (!device_active(hub))
|
||||||
continue;
|
continue;
|
||||||
udev = dev_get_parentdata(hub);
|
udev = dev_get_parent_priv(hub);
|
||||||
if (udev->devnum == devnum)
|
if (udev->devnum == devnum)
|
||||||
return udev;
|
return udev;
|
||||||
|
|
||||||
@ -291,7 +291,7 @@ static struct usb_device *usb_find_device(int devnum)
|
|||||||
if (!device_active(hub))
|
if (!device_active(hub))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
udev = dev_get_parentdata(dev);
|
udev = dev_get_parent_priv(dev);
|
||||||
if (udev->devnum == devnum)
|
if (udev->devnum == devnum)
|
||||||
return udev;
|
return udev;
|
||||||
}
|
}
|
||||||
@ -407,7 +407,7 @@ static void usb_show_tree_graph(struct usb_device *dev, char *pre)
|
|||||||
if (!device_active(child))
|
if (!device_active(child))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
udev = dev_get_parentdata(child);
|
udev = dev_get_parent_priv(child);
|
||||||
|
|
||||||
/* Ignore emulators, we only want real devices */
|
/* Ignore emulators, we only want real devices */
|
||||||
if (device_get_uclass_id(child) != UCLASS_USB_EMUL) {
|
if (device_get_uclass_id(child) != UCLASS_USB_EMUL) {
|
||||||
@ -553,7 +553,7 @@ static void show_info(struct udevice *dev)
|
|||||||
struct udevice *child;
|
struct udevice *child;
|
||||||
struct usb_device *udev;
|
struct usb_device *udev;
|
||||||
|
|
||||||
udev = dev_get_parentdata(dev);
|
udev = dev_get_parent_priv(dev);
|
||||||
usb_display_desc(udev);
|
usb_display_desc(udev);
|
||||||
usb_display_config(udev);
|
usb_display_config(udev);
|
||||||
for (device_find_first_child(dev, &child);
|
for (device_find_first_child(dev, &child);
|
||||||
@ -641,7 +641,7 @@ static int do_usb(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
|
|||||||
|
|
||||||
device_find_first_child(bus, &dev);
|
device_find_first_child(bus, &dev);
|
||||||
if (dev && device_active(dev)) {
|
if (dev && device_active(dev)) {
|
||||||
udev = dev_get_parentdata(dev);
|
udev = dev_get_parent_priv(dev);
|
||||||
usb_show_tree(udev);
|
usb_show_tree(udev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ int legacy_hub_port_reset(struct usb_device *dev, int port,
|
|||||||
#ifdef CONFIG_DM_USB
|
#ifdef CONFIG_DM_USB
|
||||||
int hub_port_reset(struct udevice *dev, int port, unsigned short *portstat)
|
int hub_port_reset(struct udevice *dev, int port, unsigned short *portstat)
|
||||||
{
|
{
|
||||||
struct usb_device *udev = dev_get_parentdata(dev);
|
struct usb_device *udev = dev_get_parent_priv(dev);
|
||||||
|
|
||||||
return legacy_hub_port_reset(udev, port, portstat);
|
return legacy_hub_port_reset(udev, port, portstat);
|
||||||
}
|
}
|
||||||
@ -610,7 +610,7 @@ int usb_hub_probe(struct usb_device *dev, int ifnum)
|
|||||||
#ifdef CONFIG_DM_USB
|
#ifdef CONFIG_DM_USB
|
||||||
int usb_hub_scan(struct udevice *hub)
|
int usb_hub_scan(struct udevice *hub)
|
||||||
{
|
{
|
||||||
struct usb_device *udev = dev_get_parentdata(hub);
|
struct usb_device *udev = dev_get_parent_priv(hub);
|
||||||
|
|
||||||
return usb_hub_configure(udev);
|
return usb_hub_configure(udev);
|
||||||
}
|
}
|
||||||
|
@ -1408,7 +1408,7 @@ int usb_stor_get_info(struct usb_device *dev, struct us_data *ss,
|
|||||||
|
|
||||||
static int usb_mass_storage_probe(struct udevice *dev)
|
static int usb_mass_storage_probe(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct usb_device *udev = dev_get_parentdata(dev);
|
struct usb_device *udev = dev_get_parent_priv(dev);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
usb_disable_asynch(1); /* asynch transfer not allowed */
|
usb_disable_asynch(1); /* asynch transfer not allowed */
|
||||||
|
@ -6,6 +6,8 @@ CONFIG_SYS_EXTRA_OPTIONS="36BIT,SDCARD,DEVELOP"
|
|||||||
# CONFIG_CMD_FLASH is not set
|
# CONFIG_CMD_FLASH is not set
|
||||||
CONFIG_CMD_TPM=y
|
CONFIG_CMD_TPM=y
|
||||||
CONFIG_SPI_FLASH=y
|
CONFIG_SPI_FLASH=y
|
||||||
|
CONFIG_DM=y
|
||||||
|
CONFIG_DM_TPM=y
|
||||||
CONFIG_TPM_ATMEL_TWI=y
|
CONFIG_TPM_ATMEL_TWI=y
|
||||||
CONFIG_TPM_AUTH_SESSIONS=y
|
CONFIG_TPM_AUTH_SESSIONS=y
|
||||||
CONFIG_TPM=y
|
CONFIG_TPM=y
|
||||||
|
@ -6,6 +6,8 @@ CONFIG_SYS_EXTRA_OPTIONS="36BIT,SDCARD"
|
|||||||
# CONFIG_CMD_FLASH is not set
|
# CONFIG_CMD_FLASH is not set
|
||||||
CONFIG_CMD_TPM=y
|
CONFIG_CMD_TPM=y
|
||||||
CONFIG_SPI_FLASH=y
|
CONFIG_SPI_FLASH=y
|
||||||
|
CONFIG_DM=y
|
||||||
|
CONFIG_DM_TPM=y
|
||||||
CONFIG_TPM_ATMEL_TWI=y
|
CONFIG_TPM_ATMEL_TWI=y
|
||||||
CONFIG_TPM_AUTH_SESSIONS=y
|
CONFIG_TPM_AUTH_SESSIONS=y
|
||||||
CONFIG_TPM=y
|
CONFIG_TPM=y
|
||||||
|
@ -7,6 +7,8 @@ CONFIG_SYS_EXTRA_OPTIONS="TRAILBLAZER,SPIFLASH,DEVELOP"
|
|||||||
# CONFIG_CMD_FLASH is not set
|
# CONFIG_CMD_FLASH is not set
|
||||||
# CONFIG_CMD_SETEXPR is not set
|
# CONFIG_CMD_SETEXPR is not set
|
||||||
CONFIG_CMD_TPM=y
|
CONFIG_CMD_TPM=y
|
||||||
|
CONFIG_DM=y
|
||||||
|
CONFIG_DM_TPM=y
|
||||||
CONFIG_TPM_ATMEL_TWI=y
|
CONFIG_TPM_ATMEL_TWI=y
|
||||||
CONFIG_TPM_AUTH_SESSIONS=y
|
CONFIG_TPM_AUTH_SESSIONS=y
|
||||||
CONFIG_TPM=y
|
CONFIG_TPM=y
|
||||||
|
@ -7,6 +7,8 @@ CONFIG_SYS_EXTRA_OPTIONS="TRAILBLAZER,SPIFLASH"
|
|||||||
# CONFIG_CMD_FLASH is not set
|
# CONFIG_CMD_FLASH is not set
|
||||||
# CONFIG_CMD_SETEXPR is not set
|
# CONFIG_CMD_SETEXPR is not set
|
||||||
CONFIG_CMD_TPM=y
|
CONFIG_CMD_TPM=y
|
||||||
|
CONFIG_DM=y
|
||||||
|
CONFIG_DM_TPM=y
|
||||||
CONFIG_TPM_ATMEL_TWI=y
|
CONFIG_TPM_ATMEL_TWI=y
|
||||||
CONFIG_TPM_AUTH_SESSIONS=y
|
CONFIG_TPM_AUTH_SESSIONS=y
|
||||||
CONFIG_TPM=y
|
CONFIG_TPM=y
|
||||||
|
@ -20,7 +20,7 @@ CONFIG_CROS_EC_SPI=y
|
|||||||
CONFIG_SPI_FLASH=y
|
CONFIG_SPI_FLASH=y
|
||||||
CONFIG_TEGRA114_SPI=y
|
CONFIG_TEGRA114_SPI=y
|
||||||
CONFIG_DM_TPM=y
|
CONFIG_DM_TPM=y
|
||||||
CONFIG_TPM_TIS_I2C=y
|
CONFIG_TPM_TIS_INFINEON=y
|
||||||
CONFIG_USB=y
|
CONFIG_USB=y
|
||||||
CONFIG_DM_USB=y
|
CONFIG_DM_USB=y
|
||||||
CONFIG_DISPLAY_PORT=y
|
CONFIG_DISPLAY_PORT=y
|
||||||
|
@ -30,7 +30,7 @@ CONFIG_I2S_SAMSUNG=y
|
|||||||
CONFIG_SOUND_MAX98095=y
|
CONFIG_SOUND_MAX98095=y
|
||||||
CONFIG_SOUND_WM8994=y
|
CONFIG_SOUND_WM8994=y
|
||||||
CONFIG_DM_TPM=y
|
CONFIG_DM_TPM=y
|
||||||
CONFIG_TPM_TIS_I2C=y
|
CONFIG_TPM_TIS_INFINEON=y
|
||||||
CONFIG_USB=y
|
CONFIG_USB=y
|
||||||
CONFIG_DM_USB=y
|
CONFIG_DM_USB=y
|
||||||
CONFIG_VIDEO_BRIDGE=y
|
CONFIG_VIDEO_BRIDGE=y
|
||||||
|
@ -30,7 +30,7 @@ CONFIG_I2S_SAMSUNG=y
|
|||||||
CONFIG_SOUND_MAX98095=y
|
CONFIG_SOUND_MAX98095=y
|
||||||
CONFIG_SOUND_WM8994=y
|
CONFIG_SOUND_WM8994=y
|
||||||
CONFIG_DM_TPM=y
|
CONFIG_DM_TPM=y
|
||||||
CONFIG_TPM_TIS_I2C=y
|
CONFIG_TPM_TIS_INFINEON=y
|
||||||
CONFIG_USB=y
|
CONFIG_USB=y
|
||||||
CONFIG_DM_USB=y
|
CONFIG_DM_USB=y
|
||||||
CONFIG_VIDEO_BRIDGE=y
|
CONFIG_VIDEO_BRIDGE=y
|
||||||
|
@ -39,7 +39,7 @@ CONFIG_I2S_SAMSUNG=y
|
|||||||
CONFIG_SOUND_MAX98095=y
|
CONFIG_SOUND_MAX98095=y
|
||||||
CONFIG_SOUND_WM8994=y
|
CONFIG_SOUND_WM8994=y
|
||||||
CONFIG_DM_TPM=y
|
CONFIG_DM_TPM=y
|
||||||
CONFIG_TPM_TIS_I2C=y
|
CONFIG_TPM_TIS_INFINEON=y
|
||||||
CONFIG_USB=y
|
CONFIG_USB=y
|
||||||
CONFIG_DM_USB=y
|
CONFIG_DM_USB=y
|
||||||
CONFIG_VIDEO_BRIDGE=y
|
CONFIG_VIDEO_BRIDGE=y
|
||||||
|
@ -39,7 +39,7 @@ CONFIG_I2S_SAMSUNG=y
|
|||||||
CONFIG_SOUND_MAX98095=y
|
CONFIG_SOUND_MAX98095=y
|
||||||
CONFIG_SOUND_WM8994=y
|
CONFIG_SOUND_WM8994=y
|
||||||
CONFIG_DM_TPM=y
|
CONFIG_DM_TPM=y
|
||||||
CONFIG_TPM_TIS_I2C=y
|
CONFIG_TPM_TIS_INFINEON=y
|
||||||
CONFIG_USB=y
|
CONFIG_USB=y
|
||||||
CONFIG_DM_USB=y
|
CONFIG_DM_USB=y
|
||||||
CONFIG_VIDEO_BRIDGE=y
|
CONFIG_VIDEO_BRIDGE=y
|
||||||
|
@ -156,7 +156,10 @@ address of the fdt binary blob, and will override either of the options.
|
|||||||
Be aware that this environment variable is checked prior to relocation,
|
Be aware that this environment variable is checked prior to relocation,
|
||||||
when only the compiled-in environment is available. Therefore it is not
|
when only the compiled-in environment is available. Therefore it is not
|
||||||
possible to define this variable in the saved SPI/NAND flash
|
possible to define this variable in the saved SPI/NAND flash
|
||||||
environment, for example (it will be ignored).
|
environment, for example (it will be ignored). After relocation, this
|
||||||
|
variable will be set to the address of the newly relocated fdt blob.
|
||||||
|
It is read-only and cannot be changed. It can optionally be used to
|
||||||
|
control the boot process of Linux with bootm/bootz commands.
|
||||||
|
|
||||||
To use this, put something like this in your board header file:
|
To use this, put something like this in your board header file:
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ The following primary data structures are in use:
|
|||||||
This holds information about a device on the bus. All devices have
|
This holds information about a device on the bus. All devices have
|
||||||
this structure, even the root hub. The controller itself does not
|
this structure, even the root hub. The controller itself does not
|
||||||
have this structure. You can access it for a device 'dev' with
|
have this structure. You can access it for a device 'dev' with
|
||||||
dev_get_parentdata(dev). It matches the old structure except that the
|
dev_get_parent_priv(dev). It matches the old structure except that the
|
||||||
parent and child information is not present (since driver model
|
parent and child information is not present (since driver model
|
||||||
handles that). Once the device is set up, you can find the device
|
handles that). Once the device is set up, you can find the device
|
||||||
descriptor and current configuration descriptor in this structure.
|
descriptor and current configuration descriptor in this structure.
|
||||||
@ -279,7 +279,7 @@ USB hubs are scanned as in the section above. While hubs have their own
|
|||||||
uclass, they share some common elements with controllers:
|
uclass, they share some common elements with controllers:
|
||||||
|
|
||||||
- they both attach private data to their children (struct usb_device,
|
- they both attach private data to their children (struct usb_device,
|
||||||
accessible for a child with dev_get_parentdata(child))
|
accessible for a child with dev_get_parent_priv(child))
|
||||||
- they both use usb_child_pre_probe() to set up their children as proper USB
|
- they both use usb_child_pre_probe() to set up their children as proper USB
|
||||||
devices
|
devices
|
||||||
|
|
||||||
|
@ -395,7 +395,7 @@ void *dev_get_uclass_priv(struct udevice *dev)
|
|||||||
return dev->uclass_priv;
|
return dev->uclass_priv;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *dev_get_parentdata(struct udevice *dev)
|
void *dev_get_parent_priv(struct udevice *dev)
|
||||||
{
|
{
|
||||||
if (!dev) {
|
if (!dev) {
|
||||||
dm_warn("%s: null device\n", __func__);
|
dm_warn("%s: null device\n", __func__);
|
||||||
|
@ -24,7 +24,7 @@ DECLARE_GLOBAL_DATA_PTR;
|
|||||||
int cros_ec_spi_packet(struct udevice *udev, int out_bytes, int in_bytes)
|
int cros_ec_spi_packet(struct udevice *udev, int out_bytes, int in_bytes)
|
||||||
{
|
{
|
||||||
struct cros_ec_dev *dev = dev_get_uclass_priv(udev);
|
struct cros_ec_dev *dev = dev_get_uclass_priv(udev);
|
||||||
struct spi_slave *slave = dev_get_parentdata(dev->dev);
|
struct spi_slave *slave = dev_get_parent_priv(dev->dev);
|
||||||
ulong start;
|
ulong start;
|
||||||
uint8_t byte;
|
uint8_t byte;
|
||||||
int rv;
|
int rv;
|
||||||
@ -84,7 +84,7 @@ int cros_ec_spi_command(struct udevice *udev, uint8_t cmd, int cmd_version,
|
|||||||
uint8_t **dinp, int din_len)
|
uint8_t **dinp, int din_len)
|
||||||
{
|
{
|
||||||
struct cros_ec_dev *dev = dev_get_uclass_priv(udev);
|
struct cros_ec_dev *dev = dev_get_uclass_priv(udev);
|
||||||
struct spi_slave *slave = dev_get_parentdata(dev->dev);
|
struct spi_slave *slave = dev_get_parent_priv(dev->dev);
|
||||||
int in_bytes = din_len + 4; /* status, length, checksum, trailer */
|
int in_bytes = din_len + 4; /* status, length, checksum, trailer */
|
||||||
uint8_t *out;
|
uint8_t *out;
|
||||||
uint8_t *p;
|
uint8_t *p;
|
||||||
|
@ -577,7 +577,7 @@ static struct flash_info *jedec_probe(struct spi_slave *spi, u8 *id)
|
|||||||
*/
|
*/
|
||||||
static int spi_dataflash_probe(struct udevice *dev)
|
static int spi_dataflash_probe(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct spi_slave *spi = dev_get_parentdata(dev);
|
struct spi_slave *spi = dev_get_parent_priv(dev);
|
||||||
struct spi_flash *spi_flash;
|
struct spi_flash *spi_flash;
|
||||||
struct flash_info *info;
|
struct flash_info *info;
|
||||||
u8 idcode[5];
|
u8 idcode[5];
|
||||||
|
@ -471,7 +471,7 @@ int spi_flash_std_erase(struct udevice *dev, u32 offset, size_t len)
|
|||||||
|
|
||||||
int spi_flash_std_probe(struct udevice *dev)
|
int spi_flash_std_probe(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct spi_slave *slave = dev_get_parentdata(dev);
|
struct spi_slave *slave = dev_get_parent_priv(dev);
|
||||||
struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev);
|
struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev);
|
||||||
struct spi_flash *flash;
|
struct spi_flash *flash;
|
||||||
|
|
||||||
|
@ -913,7 +913,7 @@ void spi_init(void)
|
|||||||
#else
|
#else
|
||||||
static int fsl_qspi_child_pre_probe(struct udevice *dev)
|
static int fsl_qspi_child_pre_probe(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct spi_slave *slave = dev_get_parentdata(dev);
|
struct spi_slave *slave = dev_get_parent_priv(dev);
|
||||||
|
|
||||||
slave->max_write_size = TX_BUFFER_SIZE;
|
slave->max_write_size = TX_BUFFER_SIZE;
|
||||||
|
|
||||||
|
@ -740,7 +740,7 @@ static int ich_spi_child_pre_probe(struct udevice *dev)
|
|||||||
struct udevice *bus = dev_get_parent(dev);
|
struct udevice *bus = dev_get_parent(dev);
|
||||||
struct ich_spi_platdata *plat = dev_get_platdata(bus);
|
struct ich_spi_platdata *plat = dev_get_platdata(bus);
|
||||||
struct ich_spi_priv *priv = dev_get_priv(bus);
|
struct ich_spi_priv *priv = dev_get_priv(bus);
|
||||||
struct spi_slave *slave = dev_get_parentdata(dev);
|
struct spi_slave *slave = dev_get_parent_priv(dev);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Yes this controller can only write a small number of bytes at
|
* Yes this controller can only write a small number of bytes at
|
||||||
|
@ -200,7 +200,7 @@ static int soft_spi_ofdata_to_platdata(struct udevice *dev)
|
|||||||
|
|
||||||
static int soft_spi_probe(struct udevice *dev)
|
static int soft_spi_probe(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct spi_slave *slave = dev_get_parentdata(dev);
|
struct spi_slave *slave = dev_get_parent_priv(dev);
|
||||||
struct soft_spi_platdata *plat = dev->platdata;
|
struct soft_spi_platdata *plat = dev->platdata;
|
||||||
int cs_flags, clk_flags;
|
int cs_flags, clk_flags;
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ static int spi_post_probe(struct udevice *bus)
|
|||||||
static int spi_child_pre_probe(struct udevice *dev)
|
static int spi_child_pre_probe(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev);
|
struct dm_spi_slave_platdata *plat = dev_get_parent_platdata(dev);
|
||||||
struct spi_slave *slave = dev_get_parentdata(dev);
|
struct spi_slave *slave = dev_get_parent_priv(dev);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is needed because we pass struct spi_slave around the place
|
* This is needed because we pass struct spi_slave around the place
|
||||||
@ -282,7 +282,7 @@ int spi_get_bus_and_cs(int busnum, int cs, int speed, int mode,
|
|||||||
ret = device_probe(dev);
|
ret = device_probe(dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
goto err;
|
goto err;
|
||||||
slave = dev_get_parentdata(dev);
|
slave = dev_get_parent_priv(dev);
|
||||||
slave->dev = dev;
|
slave->dev = dev;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,7 +291,7 @@ int spi_get_bus_and_cs(int busnum, int cs, int speed, int mode,
|
|||||||
goto err;
|
goto err;
|
||||||
|
|
||||||
*busp = bus;
|
*busp = bus;
|
||||||
*devp = dev_get_parentdata(dev);
|
*devp = dev_get_parent_priv(dev);
|
||||||
debug("%s: bus=%p, slave=%p\n", __func__, bus, *devp);
|
debug("%s: bus=%p, slave=%p\n", __func__, bus, *devp);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -320,7 +320,7 @@ struct spi_slave *spi_setup_slave_fdt(const void *blob, int node,
|
|||||||
ret = device_get_child_by_of_offset(bus, node, &dev);
|
ret = device_get_child_by_of_offset(bus, node, &dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
return NULL;
|
return NULL;
|
||||||
return dev_get_parentdata(dev);
|
return dev_get_parent_priv(dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Compatibility function - to be removed */
|
/* Compatibility function - to be removed */
|
||||||
|
@ -4,15 +4,6 @@
|
|||||||
|
|
||||||
menu "TPM support"
|
menu "TPM support"
|
||||||
|
|
||||||
config DM_TPM
|
|
||||||
bool "Enable driver model for Trusted Platform Module drivers"
|
|
||||||
depends on DM && TPM
|
|
||||||
help
|
|
||||||
Enable driver model for TPMs. The TIS interface (tis_open(),
|
|
||||||
tis_sendrecv(), etc.) is then implemented by the TPM uclass. Note
|
|
||||||
that even with driver model only a single TPM is currently
|
|
||||||
supported, since the tpm library assumes this.
|
|
||||||
|
|
||||||
config TPM_TIS_SANDBOX
|
config TPM_TIS_SANDBOX
|
||||||
bool "Enable sandbox TPM driver"
|
bool "Enable sandbox TPM driver"
|
||||||
depends on SANDBOX
|
depends on SANDBOX
|
||||||
@ -24,14 +15,14 @@ config TPM_TIS_SANDBOX
|
|||||||
|
|
||||||
config TPM_ATMEL_TWI
|
config TPM_ATMEL_TWI
|
||||||
bool "Enable Atmel TWI TPM device driver"
|
bool "Enable Atmel TWI TPM device driver"
|
||||||
depends on TPM
|
depends on TPM && DM_I2C
|
||||||
help
|
help
|
||||||
This driver supports an Atmel TPM device connected on the I2C bus.
|
This driver supports an Atmel TPM device connected on the I2C bus.
|
||||||
The usual tpm operations and the 'tpm' command can be used to talk
|
The usual tpm operations and the 'tpm' command can be used to talk
|
||||||
to the device using the standard TPM Interface Specification (TIS)
|
to the device using the standard TPM Interface Specification (TIS)
|
||||||
protocol
|
protocol
|
||||||
|
|
||||||
config TPM_TIS_I2C
|
config TPM_TIS_INFINEON
|
||||||
bool "Enable support for Infineon SLB9635/45 TPMs on I2C"
|
bool "Enable support for Infineon SLB9635/45 TPMs on I2C"
|
||||||
depends on TPM && DM_I2C
|
depends on TPM && DM_I2C
|
||||||
help
|
help
|
||||||
@ -42,7 +33,7 @@ config TPM_TIS_I2C
|
|||||||
|
|
||||||
config TPM_TIS_I2C_BURST_LIMITATION
|
config TPM_TIS_I2C_BURST_LIMITATION
|
||||||
bool "Enable I2C burst length limitation"
|
bool "Enable I2C burst length limitation"
|
||||||
depends on TPM_TIS_I2C
|
depends on TPM_TIS_INFINEON
|
||||||
help
|
help
|
||||||
Some broken TPMs have a limitation on the number of bytes they can
|
Some broken TPMs have a limitation on the number of bytes they can
|
||||||
receive in one message. Enable this option to allow you to set this
|
receive in one message. Enable this option to allow you to set this
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
# SPDX-License-Identifier: GPL-2.0+
|
# SPDX-License-Identifier: GPL-2.0+
|
||||||
#
|
#
|
||||||
|
|
||||||
obj-$(CONFIG_DM_TPM) += tpm-uclass.o
|
obj-$(CONFIG_TPM) += tpm-uclass.o
|
||||||
|
|
||||||
obj-$(CONFIG_TPM_ATMEL_TWI) += tpm_atmel_twi.o
|
obj-$(CONFIG_TPM_ATMEL_TWI) += tpm_atmel_twi.o
|
||||||
obj-$(CONFIG_TPM_TIS_I2C) += tpm_tis_i2c.o
|
obj-$(CONFIG_TPM_TIS_INFINEON) += tpm_tis_infineon.o
|
||||||
obj-$(CONFIG_TPM_TIS_LPC) += tpm_tis_lpc.o
|
obj-$(CONFIG_TPM_TIS_LPC) += tpm_tis_lpc.o
|
||||||
obj-$(CONFIG_TPM_TIS_SANDBOX) += tpm_tis_sandbox.o
|
obj-$(CONFIG_TPM_TIS_SANDBOX) += tpm_tis_sandbox.o
|
||||||
|
@ -7,51 +7,56 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
|
#include <dm.h>
|
||||||
#include <tpm.h>
|
#include <tpm.h>
|
||||||
#include <i2c.h>
|
#include <i2c.h>
|
||||||
#include <asm/unaligned.h>
|
#include <asm/unaligned.h>
|
||||||
|
|
||||||
|
#include "tpm_internal.h"
|
||||||
|
|
||||||
#define ATMEL_TPM_TIMEOUT_MS 5000 /* sufficient for anything but
|
#define ATMEL_TPM_TIMEOUT_MS 5000 /* sufficient for anything but
|
||||||
generating/exporting keys */
|
generating/exporting keys */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* tis_init()
|
* tpm_atmel_twi_open()
|
||||||
*
|
|
||||||
* Initialize the TPM device. Returns 0 on success or -1 on
|
|
||||||
* failure (in case device probing did not succeed).
|
|
||||||
*/
|
|
||||||
int tis_init(void)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* tis_open()
|
|
||||||
*
|
*
|
||||||
* Requests access to locality 0 for the caller. After all commands have been
|
* Requests access to locality 0 for the caller. After all commands have been
|
||||||
* completed the caller is supposed to call tis_close().
|
* completed the caller is supposed to call tis_close().
|
||||||
*
|
*
|
||||||
* Returns 0 on success, -1 on failure.
|
* Returns 0 on success, -1 on failure.
|
||||||
*/
|
*/
|
||||||
int tis_open(void)
|
static int tpm_atmel_twi_open(struct udevice *dev)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* tis_close()
|
* tpm_atmel_twi_close()
|
||||||
*
|
*
|
||||||
* terminate the currect session with the TPM by releasing the locked
|
* terminate the currect session with the TPM by releasing the locked
|
||||||
* locality. Returns 0 on success of -1 on failure (in case lock
|
* locality. Returns 0 on success of -1 on failure (in case lock
|
||||||
* removal did not succeed).
|
* removal did not succeed).
|
||||||
*/
|
*/
|
||||||
int tis_close(void)
|
static int tpm_atmel_twi_close(struct udevice *dev)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* tis_sendrecv()
|
* tpm_atmel_twi_get_desc()
|
||||||
|
*
|
||||||
|
* @dev: Device to check
|
||||||
|
* @buf: Buffer to put the string
|
||||||
|
* @size: Maximum size of buffer
|
||||||
|
* @return length of string, or -ENOSPC it no space
|
||||||
|
*/
|
||||||
|
static int tpm_atmel_twi_get_desc(struct udevice *dev, char *buf, int size)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* tpm_atmel_twi_xfer()
|
||||||
*
|
*
|
||||||
* Send the requested data to the TPM and then try to get its response
|
* Send the requested data to the TPM and then try to get its response
|
||||||
*
|
*
|
||||||
@ -63,8 +68,9 @@ int tis_close(void)
|
|||||||
* Returns 0 on success (and places the number of response bytes at recv_len)
|
* Returns 0 on success (and places the number of response bytes at recv_len)
|
||||||
* or -1 on failure.
|
* or -1 on failure.
|
||||||
*/
|
*/
|
||||||
int tis_sendrecv(const uint8_t *sendbuf, size_t send_size, uint8_t *recvbuf,
|
static int tpm_atmel_twi_xfer(struct udevice *dev,
|
||||||
size_t *recv_len)
|
const uint8_t *sendbuf, size_t send_size,
|
||||||
|
uint8_t *recvbuf, size_t *recv_len)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
unsigned long start;
|
unsigned long start;
|
||||||
@ -83,6 +89,7 @@ int tis_sendrecv(const uint8_t *sendbuf, size_t send_size, uint8_t *recvbuf,
|
|||||||
|
|
||||||
start = get_timer(0);
|
start = get_timer(0);
|
||||||
while ((res = i2c_read(0x29, 0, 0, recvbuf, 10))) {
|
while ((res = i2c_read(0x29, 0, 0, recvbuf, 10))) {
|
||||||
|
/* TODO Use TIS_TIMEOUT from tpm_tis_infineon.h */
|
||||||
if (get_timer(start) > ATMEL_TPM_TIMEOUT_MS) {
|
if (get_timer(start) > ATMEL_TPM_TIMEOUT_MS) {
|
||||||
puts("tpm timed out\n");
|
puts("tpm timed out\n");
|
||||||
return -1;
|
return -1;
|
||||||
@ -110,3 +117,28 @@ int tis_sendrecv(const uint8_t *sendbuf, size_t send_size, uint8_t *recvbuf,
|
|||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int tpm_atmel_twi_probe(struct udevice *dev)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct udevice_id tpm_atmel_twi_ids[] = {
|
||||||
|
{ .compatible = "atmel,at97sc3204t"},
|
||||||
|
{ }
|
||||||
|
};
|
||||||
|
|
||||||
|
static const struct tpm_ops tpm_atmel_twi_ops = {
|
||||||
|
.open = tpm_atmel_twi_open,
|
||||||
|
.close = tpm_atmel_twi_close,
|
||||||
|
.xfer = tpm_atmel_twi_xfer,
|
||||||
|
.get_desc = tpm_atmel_twi_get_desc,
|
||||||
|
};
|
||||||
|
|
||||||
|
U_BOOT_DRIVER(tpm_atmel_twi) = {
|
||||||
|
.name = "tpm_atmel_twi",
|
||||||
|
.id = UCLASS_TPM,
|
||||||
|
.of_match = tpm_atmel_twi_ids,
|
||||||
|
.ops = &tpm_atmel_twi_ops,
|
||||||
|
.probe = tpm_atmel_twi_probe,
|
||||||
|
};
|
||||||
|
@ -24,14 +24,13 @@
|
|||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
#include <fdtdec.h>
|
#include <fdtdec.h>
|
||||||
#include <i2c.h>
|
#include <i2c.h>
|
||||||
#include <tis.h>
|
|
||||||
#include <tpm.h>
|
#include <tpm.h>
|
||||||
#include <asm-generic/errno.h>
|
#include <asm-generic/errno.h>
|
||||||
#include <linux/compiler.h>
|
#include <linux/compiler.h>
|
||||||
#include <linux/types.h>
|
#include <linux/types.h>
|
||||||
#include <linux/unaligned/be_byteshift.h>
|
#include <linux/unaligned/be_byteshift.h>
|
||||||
|
|
||||||
#include "tpm_tis_i2c.h"
|
#include "tpm_tis_infineon.h"
|
||||||
#include "tpm_internal.h"
|
#include "tpm_internal.h"
|
||||||
|
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
@ -614,7 +613,7 @@ static const struct udevice_id tpm_tis_i2c_ids[] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
U_BOOT_DRIVER(tpm_tis_i2c) = {
|
U_BOOT_DRIVER(tpm_tis_i2c) = {
|
||||||
.name = "tpm_tis_i2c",
|
.name = "tpm_tis_infineon",
|
||||||
.id = UCLASS_TPM,
|
.id = UCLASS_TPM,
|
||||||
.of_match = tpm_tis_i2c_ids,
|
.of_match = tpm_tis_i2c_ids,
|
||||||
.ops = &tpm_tis_i2c_ops,
|
.ops = &tpm_tis_i2c_ops,
|
@ -16,7 +16,6 @@
|
|||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
#include <mapmem.h>
|
#include <mapmem.h>
|
||||||
#include <tis.h>
|
|
||||||
#include <tpm.h>
|
#include <tpm.h>
|
||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
|
|
||||||
|
@ -945,7 +945,7 @@ int smsc95xx_eth_get_info(struct usb_device *dev, struct ueth_data *ss,
|
|||||||
#ifdef CONFIG_DM_ETH
|
#ifdef CONFIG_DM_ETH
|
||||||
static int smsc95xx_eth_start(struct udevice *dev)
|
static int smsc95xx_eth_start(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct usb_device *udev = dev_get_parentdata(dev);
|
struct usb_device *udev = dev_get_parent_priv(dev);
|
||||||
struct smsc95xx_private *priv = dev_get_priv(dev);
|
struct smsc95xx_private *priv = dev_get_priv(dev);
|
||||||
struct eth_pdata *pdata = dev_get_platdata(dev);
|
struct eth_pdata *pdata = dev_get_platdata(dev);
|
||||||
|
|
||||||
@ -1029,7 +1029,7 @@ static int smsc95xx_free_pkt(struct udevice *dev, uchar *packet, int packet_len)
|
|||||||
|
|
||||||
int smsc95xx_write_hwaddr(struct udevice *dev)
|
int smsc95xx_write_hwaddr(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct usb_device *udev = dev_get_parentdata(dev);
|
struct usb_device *udev = dev_get_parent_priv(dev);
|
||||||
struct eth_pdata *pdata = dev_get_platdata(dev);
|
struct eth_pdata *pdata = dev_get_platdata(dev);
|
||||||
struct smsc95xx_private *priv = dev_get_priv(dev);
|
struct smsc95xx_private *priv = dev_get_priv(dev);
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
int usb_ether_register(struct udevice *dev, struct ueth_data *ueth, int rxsize)
|
int usb_ether_register(struct udevice *dev, struct ueth_data *ueth, int rxsize)
|
||||||
{
|
{
|
||||||
struct usb_device *udev = dev_get_parentdata(dev);
|
struct usb_device *udev = dev_get_parent_priv(dev);
|
||||||
struct usb_interface_descriptor *iface_desc;
|
struct usb_interface_descriptor *iface_desc;
|
||||||
bool ep_in_found = false, ep_out_found = false;
|
bool ep_in_found = false, ep_out_found = false;
|
||||||
struct usb_interface *iface;
|
struct usb_interface *iface;
|
||||||
|
@ -303,7 +303,7 @@ static void ehci_update_endpt2_dev_n_port(struct usb_device *udev,
|
|||||||
|
|
||||||
ttdev = udev;
|
ttdev = udev;
|
||||||
parent = udev->dev;
|
parent = udev->dev;
|
||||||
uparent = dev_get_parentdata(parent);
|
uparent = dev_get_parent_priv(parent);
|
||||||
|
|
||||||
while (uparent->speed != USB_SPEED_HIGH) {
|
while (uparent->speed != USB_SPEED_HIGH) {
|
||||||
struct udevice *dev = parent;
|
struct udevice *dev = parent;
|
||||||
@ -313,9 +313,9 @@ static void ehci_update_endpt2_dev_n_port(struct usb_device *udev,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ttdev = dev_get_parentdata(dev);
|
ttdev = dev_get_parent_priv(dev);
|
||||||
parent = dev->parent;
|
parent = dev->parent;
|
||||||
uparent = dev_get_parentdata(parent);
|
uparent = dev_get_parent_priv(parent);
|
||||||
}
|
}
|
||||||
parent_devnum = uparent->devnum;
|
parent_devnum = uparent->devnum;
|
||||||
#else
|
#else
|
||||||
|
@ -289,7 +289,7 @@ static struct usb_device *find_child_devnum(struct udevice *parent, int devnum)
|
|||||||
|
|
||||||
if (!device_active(parent))
|
if (!device_active(parent))
|
||||||
return NULL;
|
return NULL;
|
||||||
udev = dev_get_parentdata(parent);
|
udev = dev_get_parent_priv(parent);
|
||||||
if (udev->devnum == devnum)
|
if (udev->devnum == devnum)
|
||||||
return udev;
|
return udev;
|
||||||
|
|
||||||
@ -575,7 +575,7 @@ int usb_scan_device(struct udevice *parent, int port,
|
|||||||
udev->portnr = port;
|
udev->portnr = port;
|
||||||
debug("Calling usb_setup_device(), portnr=%d\n", udev->portnr);
|
debug("Calling usb_setup_device(), portnr=%d\n", udev->portnr);
|
||||||
parent_udev = device_get_uclass_id(parent) == UCLASS_USB_HUB ?
|
parent_udev = device_get_uclass_id(parent) == UCLASS_USB_HUB ?
|
||||||
dev_get_parentdata(parent) : NULL;
|
dev_get_parent_priv(parent) : NULL;
|
||||||
ret = usb_setup_device(udev, priv->desc_before_addr, parent_udev);
|
ret = usb_setup_device(udev, priv->desc_before_addr, parent_udev);
|
||||||
debug("read_descriptor for '%s': ret=%d\n", parent->name, ret);
|
debug("read_descriptor for '%s': ret=%d\n", parent->name, ret);
|
||||||
if (ret)
|
if (ret)
|
||||||
@ -638,7 +638,7 @@ int usb_detect_change(void)
|
|||||||
if (!device_active(dev))
|
if (!device_active(dev))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
udev = dev_get_parentdata(dev);
|
udev = dev_get_parent_priv(dev);
|
||||||
if (usb_get_port_status(udev, udev->portnr, &status)
|
if (usb_get_port_status(udev, udev->portnr, &status)
|
||||||
< 0)
|
< 0)
|
||||||
/* USB request failed */
|
/* USB request failed */
|
||||||
@ -694,7 +694,7 @@ struct udevice *usb_get_bus(struct udevice *dev)
|
|||||||
|
|
||||||
int usb_child_pre_probe(struct udevice *dev)
|
int usb_child_pre_probe(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct usb_device *udev = dev_get_parentdata(dev);
|
struct usb_device *udev = dev_get_parent_priv(dev);
|
||||||
struct usb_dev_platdata *plat = dev_get_parent_platdata(dev);
|
struct usb_dev_platdata *plat = dev_get_parent_platdata(dev);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -1119,7 +1119,7 @@ static struct usb_device *get_usb_device(struct udevice *dev)
|
|||||||
if (device_get_uclass_id(dev) == UCLASS_USB)
|
if (device_get_uclass_id(dev) == UCLASS_USB)
|
||||||
udev = dev_get_uclass_priv(dev);
|
udev = dev_get_uclass_priv(dev);
|
||||||
else
|
else
|
||||||
udev = dev_get_parentdata(dev);
|
udev = dev_get_parent_priv(dev);
|
||||||
|
|
||||||
return udev;
|
return udev;
|
||||||
}
|
}
|
||||||
@ -1150,7 +1150,7 @@ static int xhci_submit_control_msg(struct udevice *dev, struct usb_device *udev,
|
|||||||
} else {
|
} else {
|
||||||
while (!is_root_hub(hub->parent))
|
while (!is_root_hub(hub->parent))
|
||||||
hub = hub->parent;
|
hub = hub->parent;
|
||||||
uhop = dev_get_parentdata(hub);
|
uhop = dev_get_parent_priv(hub);
|
||||||
root_portnr = uhop->portnr;
|
root_portnr = uhop->portnr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ static inline u16 find_tt(struct usb_device *udev)
|
|||||||
*/
|
*/
|
||||||
ttdev = udev;
|
ttdev = udev;
|
||||||
parent = udev->dev;
|
parent = udev->dev;
|
||||||
uparent = dev_get_parentdata(parent);
|
uparent = dev_get_parent_priv(parent);
|
||||||
|
|
||||||
while (uparent->speed != USB_SPEED_HIGH) {
|
while (uparent->speed != USB_SPEED_HIGH) {
|
||||||
struct udevice *dev = parent;
|
struct udevice *dev = parent;
|
||||||
@ -92,9 +92,9 @@ static inline u16 find_tt(struct usb_device *udev)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ttdev = dev_get_parentdata(dev);
|
ttdev = dev_get_parent_priv(dev);
|
||||||
parent = dev->parent;
|
parent = dev->parent;
|
||||||
uparent = dev_get_parentdata(parent);
|
uparent = dev_get_parent_priv(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (uparent->devnum << 8) | (ttdev->portnr - 1);
|
return (uparent->devnum << 8) | (ttdev->portnr - 1);
|
||||||
@ -119,12 +119,12 @@ static inline struct usb_device *usb_dev_get_parent(struct usb_device *udev)
|
|||||||
* If these 2 are not the same we are being called from
|
* If these 2 are not the same we are being called from
|
||||||
* usb_scan_device() and udev itself is the parent.
|
* usb_scan_device() and udev itself is the parent.
|
||||||
*/
|
*/
|
||||||
if (dev_get_parentdata(udev->dev) != udev)
|
if (dev_get_parent_priv(udev->dev) != udev)
|
||||||
return udev;
|
return udev;
|
||||||
|
|
||||||
/* We are being called normally, use the parent pointer */
|
/* We are being called normally, use the parent pointer */
|
||||||
if (device_get_uclass_id(parent) == UCLASS_USB_HUB)
|
if (device_get_uclass_id(parent) == UCLASS_USB_HUB)
|
||||||
return dev_get_parentdata(parent);
|
return dev_get_parent_priv(parent);
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -21,13 +21,13 @@
|
|||||||
struct driver_info;
|
struct driver_info;
|
||||||
|
|
||||||
/* Driver is active (probed). Cleared when it is removed */
|
/* Driver is active (probed). Cleared when it is removed */
|
||||||
#define DM_FLAG_ACTIVATED (1 << 0)
|
#define DM_FLAG_ACTIVATED (1 << 0)
|
||||||
|
|
||||||
/* DM is responsible for allocating and freeing platdata */
|
/* DM is responsible for allocating and freeing platdata */
|
||||||
#define DM_FLAG_ALLOC_PDATA (1 << 1)
|
#define DM_FLAG_ALLOC_PDATA (1 << 1)
|
||||||
|
|
||||||
/* DM should init this device prior to relocation */
|
/* DM should init this device prior to relocation */
|
||||||
#define DM_FLAG_PRE_RELOC (1 << 2)
|
#define DM_FLAG_PRE_RELOC (1 << 2)
|
||||||
|
|
||||||
/* DM is responsible for allocating and freeing parent_platdata */
|
/* DM is responsible for allocating and freeing parent_platdata */
|
||||||
#define DM_FLAG_ALLOC_PARENT_PDATA (1 << 3)
|
#define DM_FLAG_ALLOC_PARENT_PDATA (1 << 3)
|
||||||
@ -36,10 +36,10 @@ struct driver_info;
|
|||||||
#define DM_FLAG_ALLOC_UCLASS_PDATA (1 << 4)
|
#define DM_FLAG_ALLOC_UCLASS_PDATA (1 << 4)
|
||||||
|
|
||||||
/* Allocate driver private data on a DMA boundary */
|
/* Allocate driver private data on a DMA boundary */
|
||||||
#define DM_FLAG_ALLOC_PRIV_DMA (1 << 5)
|
#define DM_FLAG_ALLOC_PRIV_DMA (1 << 5)
|
||||||
|
|
||||||
/* Device is bound */
|
/* Device is bound */
|
||||||
#define DM_FLAG_BOUND (1 << 6)
|
#define DM_FLAG_BOUND (1 << 6)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct udevice - An instance of a driver
|
* struct udevice - An instance of a driver
|
||||||
@ -78,6 +78,10 @@ struct driver_info;
|
|||||||
* @req_seq: Requested sequence number for this device (-1 = any)
|
* @req_seq: Requested sequence number for this device (-1 = any)
|
||||||
* @seq: Allocated sequence number for this device (-1 = none). This is set up
|
* @seq: Allocated sequence number for this device (-1 = none). This is set up
|
||||||
* when the device is probed and will be unique within the device's uclass.
|
* when the device is probed and will be unique within the device's uclass.
|
||||||
|
* @devres_head: List of memory allocations associated with this device.
|
||||||
|
* When CONFIG_DEVRES is enabled, devm_kmalloc() and friends will
|
||||||
|
* add to this list. Memory so-allocated will be freed
|
||||||
|
* automatically when the device is removed / unbound
|
||||||
*/
|
*/
|
||||||
struct udevice {
|
struct udevice {
|
||||||
const struct driver *driver;
|
const struct driver *driver;
|
||||||
@ -166,10 +170,6 @@ struct udevice_id {
|
|||||||
* @per_child_auto_alloc_size: Each device can hold private data owned by
|
* @per_child_auto_alloc_size: Each device can hold private data owned by
|
||||||
* its parent. If required this will be automatically allocated if this
|
* its parent. If required this will be automatically allocated if this
|
||||||
* value is non-zero.
|
* value is non-zero.
|
||||||
* TODO(sjg@chromium.org): I'm considering dropping this, and just having
|
|
||||||
* device_probe_child() pass it in. So far the use case for allocating it
|
|
||||||
* is SPI, but I found that unsatisfactory. Since it is here I will leave it
|
|
||||||
* until things are clearer.
|
|
||||||
* @per_child_platdata_auto_alloc_size: A bus likes to store information about
|
* @per_child_platdata_auto_alloc_size: A bus likes to store information about
|
||||||
* its children. If non-zero this is the size of this data, to be allocated
|
* its children. If non-zero this is the size of this data, to be allocated
|
||||||
* in the child's parent_platdata pointer.
|
* in the child's parent_platdata pointer.
|
||||||
@ -232,20 +232,6 @@ void *dev_get_parent_platdata(struct udevice *dev);
|
|||||||
*/
|
*/
|
||||||
void *dev_get_uclass_platdata(struct udevice *dev);
|
void *dev_get_uclass_platdata(struct udevice *dev);
|
||||||
|
|
||||||
/**
|
|
||||||
* dev_get_parentdata() - Get the parent data for a device
|
|
||||||
*
|
|
||||||
* The parent data is data stored in the device but owned by the parent.
|
|
||||||
* For example, a USB device may have parent data which contains information
|
|
||||||
* about how to talk to the device over USB.
|
|
||||||
*
|
|
||||||
* This checks that dev is not NULL, but no other checks for now
|
|
||||||
*
|
|
||||||
* @dev Device to check
|
|
||||||
* @return parent data, or NULL if none
|
|
||||||
*/
|
|
||||||
void *dev_get_parentdata(struct udevice *dev);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dev_get_priv() - Get the private data for a device
|
* dev_get_priv() - Get the private data for a device
|
||||||
*
|
*
|
||||||
@ -257,12 +243,18 @@ void *dev_get_parentdata(struct udevice *dev);
|
|||||||
void *dev_get_priv(struct udevice *dev);
|
void *dev_get_priv(struct udevice *dev);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* struct dev_get_parent() - Get the parent of a device
|
* dev_get_parent_priv() - Get the parent private data for a device
|
||||||
*
|
*
|
||||||
* @child: Child to check
|
* The parent private data is data stored in the device but owned by the
|
||||||
* @return parent of child, or NULL if this is the root device
|
* parent. For example, a USB device may have parent data which contains
|
||||||
|
* information about how to talk to the device over USB.
|
||||||
|
*
|
||||||
|
* This checks that dev is not NULL, but no other checks for now
|
||||||
|
*
|
||||||
|
* @dev Device to check
|
||||||
|
* @return parent data, or NULL if none
|
||||||
*/
|
*/
|
||||||
struct udevice *dev_get_parent(struct udevice *child);
|
void *dev_get_parent_priv(struct udevice *dev);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dev_get_uclass_priv() - Get the private uclass data for a device
|
* dev_get_uclass_priv() - Get the private uclass data for a device
|
||||||
@ -274,17 +266,38 @@ struct udevice *dev_get_parent(struct udevice *child);
|
|||||||
*/
|
*/
|
||||||
void *dev_get_uclass_priv(struct udevice *dev);
|
void *dev_get_uclass_priv(struct udevice *dev);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* struct dev_get_parent() - Get the parent of a device
|
||||||
|
*
|
||||||
|
* @child: Child to check
|
||||||
|
* @return parent of child, or NULL if this is the root device
|
||||||
|
*/
|
||||||
|
struct udevice *dev_get_parent(struct udevice *child);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* dev_get_driver_data() - get the driver data used to bind a device
|
* dev_get_driver_data() - get the driver data used to bind a device
|
||||||
*
|
*
|
||||||
* When a device is bound using a device tree node, it matches a
|
* When a device is bound using a device tree node, it matches a
|
||||||
* particular compatible string as in struct udevice_id. This function
|
* particular compatible string in struct udevice_id. This function
|
||||||
* returns the associated data value for that compatible string. This is
|
* returns the associated data value for that compatible string. This is
|
||||||
* the 'data' field in struct udevice_id.
|
* the 'data' field in struct udevice_id.
|
||||||
*
|
*
|
||||||
|
* As an example, consider this structure:
|
||||||
|
* static const struct udevice_id tegra_i2c_ids[] = {
|
||||||
|
* { .compatible = "nvidia,tegra114-i2c", .data = TYPE_114 },
|
||||||
|
* { .compatible = "nvidia,tegra20-i2c", .data = TYPE_STD },
|
||||||
|
* { .compatible = "nvidia,tegra20-i2c-dvc", .data = TYPE_DVC },
|
||||||
|
* { }
|
||||||
|
* };
|
||||||
|
*
|
||||||
|
* When driver model finds a driver for this it will store the 'data' value
|
||||||
|
* corresponding to the compatible string it matches. This function returns
|
||||||
|
* that value. This allows the driver to handle several variants of a device.
|
||||||
|
*
|
||||||
* For USB devices, this is the driver_info field in struct usb_device_id.
|
* For USB devices, this is the driver_info field in struct usb_device_id.
|
||||||
*
|
*
|
||||||
* @dev: Device to check
|
* @dev: Device to check
|
||||||
|
* @return driver data (0 if none is provided)
|
||||||
*/
|
*/
|
||||||
ulong dev_get_driver_data(struct udevice *dev);
|
ulong dev_get_driver_data(struct udevice *dev);
|
||||||
|
|
||||||
@ -299,7 +312,7 @@ ulong dev_get_driver_data(struct udevice *dev);
|
|||||||
*/
|
*/
|
||||||
const void *dev_get_driver_ops(struct udevice *dev);
|
const void *dev_get_driver_ops(struct udevice *dev);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* device_get_uclass_id() - return the uclass ID of a device
|
* device_get_uclass_id() - return the uclass ID of a device
|
||||||
*
|
*
|
||||||
* @dev: Device to check
|
* @dev: Device to check
|
||||||
@ -307,7 +320,7 @@ const void *dev_get_driver_ops(struct udevice *dev);
|
|||||||
*/
|
*/
|
||||||
enum uclass_id device_get_uclass_id(struct udevice *dev);
|
enum uclass_id device_get_uclass_id(struct udevice *dev);
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* dev_get_uclass_name() - return the uclass name of a device
|
* dev_get_uclass_name() - return the uclass name of a device
|
||||||
*
|
*
|
||||||
* This checks that dev is not NULL.
|
* This checks that dev is not NULL.
|
||||||
@ -512,7 +525,7 @@ void *_devres_alloc(dr_release_t release, size_t size, gfp_t gfp);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* devres_alloc - Allocate device resource data
|
* devres_alloc() - Allocate device resource data
|
||||||
* @release: Release function devres will be associated with
|
* @release: Release function devres will be associated with
|
||||||
* @size: Allocation size
|
* @size: Allocation size
|
||||||
* @gfp: Allocation flags
|
* @gfp: Allocation flags
|
||||||
@ -528,7 +541,7 @@ void *_devres_alloc(dr_release_t release, size_t size, gfp_t gfp);
|
|||||||
_devres_alloc(release, size, gfp | __GFP_ZERO)
|
_devres_alloc(release, size, gfp | __GFP_ZERO)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* devres_free - Free device resource data
|
* devres_free() - Free device resource data
|
||||||
* @res: Pointer to devres data to free
|
* @res: Pointer to devres data to free
|
||||||
*
|
*
|
||||||
* Free devres created with devres_alloc().
|
* Free devres created with devres_alloc().
|
||||||
@ -536,7 +549,7 @@ void *_devres_alloc(dr_release_t release, size_t size, gfp_t gfp);
|
|||||||
void devres_free(void *res);
|
void devres_free(void *res);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* devres_add - Register device resource
|
* devres_add() - Register device resource
|
||||||
* @dev: Device to add resource to
|
* @dev: Device to add resource to
|
||||||
* @res: Resource to register
|
* @res: Resource to register
|
||||||
*
|
*
|
||||||
@ -547,7 +560,7 @@ void devres_free(void *res);
|
|||||||
void devres_add(struct udevice *dev, void *res);
|
void devres_add(struct udevice *dev, void *res);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* devres_find - Find device resource
|
* devres_find() - Find device resource
|
||||||
* @dev: Device to lookup resource from
|
* @dev: Device to lookup resource from
|
||||||
* @release: Look for resources associated with this release function
|
* @release: Look for resources associated with this release function
|
||||||
* @match: Match function (optional)
|
* @match: Match function (optional)
|
||||||
@ -557,14 +570,13 @@ void devres_add(struct udevice *dev, void *res);
|
|||||||
* and for which @match returns 1. If @match is NULL, it's considered
|
* and for which @match returns 1. If @match is NULL, it's considered
|
||||||
* to match all.
|
* to match all.
|
||||||
*
|
*
|
||||||
* RETURNS:
|
* @return pointer to found devres, NULL if not found.
|
||||||
* Pointer to found devres, NULL if not found.
|
|
||||||
*/
|
*/
|
||||||
void *devres_find(struct udevice *dev, dr_release_t release,
|
void *devres_find(struct udevice *dev, dr_release_t release,
|
||||||
dr_match_t match, void *match_data);
|
dr_match_t match, void *match_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* devres_get - Find devres, if non-existent, add one atomically
|
* devres_get() - Find devres, if non-existent, add one atomically
|
||||||
* @dev: Device to lookup or add devres for
|
* @dev: Device to lookup or add devres for
|
||||||
* @new_res: Pointer to new initialized devres to add if not found
|
* @new_res: Pointer to new initialized devres to add if not found
|
||||||
* @match: Match function (optional)
|
* @match: Match function (optional)
|
||||||
@ -574,14 +586,13 @@ void *devres_find(struct udevice *dev, dr_release_t release,
|
|||||||
* as @new_res and for which @match return 1. If found, @new_res is
|
* as @new_res and for which @match return 1. If found, @new_res is
|
||||||
* freed; otherwise, @new_res is added atomically.
|
* freed; otherwise, @new_res is added atomically.
|
||||||
*
|
*
|
||||||
* RETURNS:
|
* @return ointer to found or added devres.
|
||||||
* Pointer to found or added devres.
|
|
||||||
*/
|
*/
|
||||||
void *devres_get(struct udevice *dev, void *new_res,
|
void *devres_get(struct udevice *dev, void *new_res,
|
||||||
dr_match_t match, void *match_data);
|
dr_match_t match, void *match_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* devres_remove - Find a device resource and remove it
|
* devres_remove() - Find a device resource and remove it
|
||||||
* @dev: Device to find resource from
|
* @dev: Device to find resource from
|
||||||
* @release: Look for resources associated with this release function
|
* @release: Look for resources associated with this release function
|
||||||
* @match: Match function (optional)
|
* @match: Match function (optional)
|
||||||
@ -592,14 +603,13 @@ void *devres_get(struct udevice *dev, void *new_res,
|
|||||||
* match all. If found, the resource is removed atomically and
|
* match all. If found, the resource is removed atomically and
|
||||||
* returned.
|
* returned.
|
||||||
*
|
*
|
||||||
* RETURNS:
|
* @return ointer to removed devres on success, NULL if not found.
|
||||||
* Pointer to removed devres on success, NULL if not found.
|
|
||||||
*/
|
*/
|
||||||
void *devres_remove(struct udevice *dev, dr_release_t release,
|
void *devres_remove(struct udevice *dev, dr_release_t release,
|
||||||
dr_match_t match, void *match_data);
|
dr_match_t match, void *match_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* devres_destroy - Find a device resource and destroy it
|
* devres_destroy() - Find a device resource and destroy it
|
||||||
* @dev: Device to find resource from
|
* @dev: Device to find resource from
|
||||||
* @release: Look for resources associated with this release function
|
* @release: Look for resources associated with this release function
|
||||||
* @match: Match function (optional)
|
* @match: Match function (optional)
|
||||||
@ -613,14 +623,13 @@ void *devres_remove(struct udevice *dev, dr_release_t release,
|
|||||||
* only the devres-allocated data will be freed. The caller becomes
|
* only the devres-allocated data will be freed. The caller becomes
|
||||||
* responsible for freeing any other data.
|
* responsible for freeing any other data.
|
||||||
*
|
*
|
||||||
* RETURNS:
|
* @return 0 if devres is found and freed, -ENOENT if not found.
|
||||||
* 0 if devres is found and freed, -ENOENT if not found.
|
|
||||||
*/
|
*/
|
||||||
int devres_destroy(struct udevice *dev, dr_release_t release,
|
int devres_destroy(struct udevice *dev, dr_release_t release,
|
||||||
dr_match_t match, void *match_data);
|
dr_match_t match, void *match_data);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* devres_release - Find a device resource and destroy it, calling release
|
* devres_release() - Find a device resource and destroy it, calling release
|
||||||
* @dev: Device to find resource from
|
* @dev: Device to find resource from
|
||||||
* @release: Look for resources associated with this release function
|
* @release: Look for resources associated with this release function
|
||||||
* @match: Match function (optional)
|
* @match: Match function (optional)
|
||||||
@ -631,15 +640,14 @@ int devres_destroy(struct udevice *dev, dr_release_t release,
|
|||||||
* match all. If found, the resource is removed atomically, the
|
* match all. If found, the resource is removed atomically, the
|
||||||
* release function called and the resource freed.
|
* release function called and the resource freed.
|
||||||
*
|
*
|
||||||
* RETURNS:
|
* @return 0 if devres is found and freed, -ENOENT if not found.
|
||||||
* 0 if devres is found and freed, -ENOENT if not found.
|
|
||||||
*/
|
*/
|
||||||
int devres_release(struct udevice *dev, dr_release_t release,
|
int devres_release(struct udevice *dev, dr_release_t release,
|
||||||
dr_match_t match, void *match_data);
|
dr_match_t match, void *match_data);
|
||||||
|
|
||||||
/* managed devm_k.alloc/kfree for device drivers */
|
/* managed devm_k.alloc/kfree for device drivers */
|
||||||
/**
|
/**
|
||||||
* devm_kmalloc - Resource-managed kmalloc
|
* devm_kmalloc() - Resource-managed kmalloc
|
||||||
* @dev: Device to allocate memory for
|
* @dev: Device to allocate memory for
|
||||||
* @size: Allocation size
|
* @size: Allocation size
|
||||||
* @gfp: Allocation gfp flags
|
* @gfp: Allocation gfp flags
|
||||||
@ -648,8 +656,7 @@ int devres_release(struct udevice *dev, dr_release_t release,
|
|||||||
* automatically freed on driver detach. Like all other devres
|
* automatically freed on driver detach. Like all other devres
|
||||||
* resources, guaranteed alignment is unsigned long long.
|
* resources, guaranteed alignment is unsigned long long.
|
||||||
*
|
*
|
||||||
* RETURNS:
|
* @return pointer to allocated memory on success, NULL on failure.
|
||||||
* Pointer to allocated memory on success, NULL on failure.
|
|
||||||
*/
|
*/
|
||||||
void *devm_kmalloc(struct udevice *dev, size_t size, gfp_t gfp);
|
void *devm_kmalloc(struct udevice *dev, size_t size, gfp_t gfp);
|
||||||
static inline void *devm_kzalloc(struct udevice *dev, size_t size, gfp_t gfp)
|
static inline void *devm_kzalloc(struct udevice *dev, size_t size, gfp_t gfp)
|
||||||
@ -670,13 +677,13 @@ static inline void *devm_kcalloc(struct udevice *dev,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* devm_kfree - Resource-managed kfree
|
* devm_kfree() - Resource-managed kfree
|
||||||
* @dev: Device this memory belongs to
|
* @dev: Device this memory belongs to
|
||||||
* @p: Memory to free
|
* @ptr: Memory to free
|
||||||
*
|
*
|
||||||
* Free memory allocated with devm_kmalloc().
|
* Free memory allocated with devm_kmalloc().
|
||||||
*/
|
*/
|
||||||
void devm_kfree(struct udevice *dev, void *p);
|
void devm_kfree(struct udevice *dev, void *ptr);
|
||||||
|
|
||||||
#else /* ! CONFIG_DEVRES */
|
#else /* ! CONFIG_DEVRES */
|
||||||
|
|
||||||
@ -750,9 +757,9 @@ static inline void *devm_kcalloc(struct udevice *dev,
|
|||||||
return kmalloc(n * size, flags | __GFP_ZERO);
|
return kmalloc(n * size, flags | __GFP_ZERO);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void devm_kfree(struct udevice *dev, void *p)
|
static inline void devm_kfree(struct udevice *dev, void *ptr)
|
||||||
{
|
{
|
||||||
kfree(p);
|
kfree(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* ! CONFIG_DEVRES */
|
#endif /* ! CONFIG_DEVRES */
|
||||||
|
@ -797,7 +797,7 @@ struct udevice;
|
|||||||
*
|
*
|
||||||
* Every device on a PCI bus has this per-child data.
|
* Every device on a PCI bus has this per-child data.
|
||||||
*
|
*
|
||||||
* It can be accessed using dev_get_parentdata(dev) if dev->parent is a
|
* It can be accessed using dev_get_parent_priv(dev) if dev->parent is a
|
||||||
* PCI bus (i.e. UCLASS_PCI)
|
* PCI bus (i.e. UCLASS_PCI)
|
||||||
*
|
*
|
||||||
* @devfn: Encoded device and function index - see PCI_DEVFN()
|
* @devfn: Encoded device and function index - see PCI_DEVFN()
|
||||||
|
@ -88,7 +88,7 @@ struct dm_spi_slave_platdata {
|
|||||||
* struct spi_slave - Representation of a SPI slave
|
* struct spi_slave - Representation of a SPI slave
|
||||||
*
|
*
|
||||||
* For driver model this is the per-child data used by the SPI bus. It can
|
* For driver model this is the per-child data used by the SPI bus. It can
|
||||||
* be accessed using dev_get_parentdata() on the slave device. The SPI uclass
|
* be accessed using dev_get_parent_priv() on the slave device. The SPI uclass
|
||||||
* sets uip per_child_auto_alloc_size to sizeof(struct spi_slave), and the
|
* sets uip per_child_auto_alloc_size to sizeof(struct spi_slave), and the
|
||||||
* driver should not override it. Two platform data fields (max_hz and mode)
|
* driver should not override it. Two platform data fields (max_hz and mode)
|
||||||
* are copied into this structure to provide an initial value. This allows
|
* are copied into this structure to provide an initial value. This allows
|
||||||
|
@ -1,60 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2011 The Chromium OS Authors.
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: GPL-2.0+
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __TIS_H
|
|
||||||
#define __TIS_H
|
|
||||||
|
|
||||||
#ifndef CONFIG_DM_TPM
|
|
||||||
|
|
||||||
#include <common.h>
|
|
||||||
|
|
||||||
/* Low-level interface to access TPM */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* tis_init()
|
|
||||||
*
|
|
||||||
* Initialize the TPM device. Returns 0 on success or -1 on
|
|
||||||
* failure (in case device probing did not succeed).
|
|
||||||
*/
|
|
||||||
int tis_init(void);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* tis_open()
|
|
||||||
*
|
|
||||||
* Requests access to locality 0 for the caller. After all commands have been
|
|
||||||
* completed the caller is supposed to call tis_close().
|
|
||||||
*
|
|
||||||
* Returns 0 on success, -1 on failure.
|
|
||||||
*/
|
|
||||||
int tis_open(void);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* tis_close()
|
|
||||||
*
|
|
||||||
* terminate the currect session with the TPM by releasing the locked
|
|
||||||
* locality. Returns 0 on success of -1 on failure (in case lock
|
|
||||||
* removal did not succeed).
|
|
||||||
*/
|
|
||||||
int tis_close(void);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* tis_sendrecv()
|
|
||||||
*
|
|
||||||
* Send the requested data to the TPM and then try to get its response
|
|
||||||
*
|
|
||||||
* @sendbuf - buffer of the data to send
|
|
||||||
* @send_size size of the data to send
|
|
||||||
* @recvbuf - memory to save the response to
|
|
||||||
* @recv_len - pointer to the size of the response buffer
|
|
||||||
*
|
|
||||||
* Returns 0 on success (and places the number of response bytes at recv_len)
|
|
||||||
* or -1 on failure.
|
|
||||||
*/
|
|
||||||
int tis_sendrecv(const uint8_t *sendbuf, size_t send_size, uint8_t *recvbuf,
|
|
||||||
size_t *recv_len);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* __TIS_H */
|
|
@ -8,8 +8,6 @@
|
|||||||
#ifndef __TPM_H
|
#ifndef __TPM_H
|
||||||
#define __TPM_H
|
#define __TPM_H
|
||||||
|
|
||||||
#include <tis.h>
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Here is a partial implementation of TPM commands. Please consult TCG Main
|
* Here is a partial implementation of TPM commands. Please consult TCG Main
|
||||||
* Specification for definitions of TPM commands.
|
* Specification for definitions of TPM commands.
|
||||||
@ -196,8 +194,6 @@ struct tpm_permanent_flags {
|
|||||||
u8 disable_full_da_logic_info;
|
u8 disable_full_da_logic_info;
|
||||||
} __packed;
|
} __packed;
|
||||||
|
|
||||||
#ifdef CONFIG_DM_TPM
|
|
||||||
|
|
||||||
/* Max buffer size supported by our tpm */
|
/* Max buffer size supported by our tpm */
|
||||||
#define TPM_DEV_BUFSIZE 1260
|
#define TPM_DEV_BUFSIZE 1260
|
||||||
|
|
||||||
@ -375,8 +371,6 @@ int tpm_get_desc(struct udevice *dev, char *buf, int size);
|
|||||||
int tpm_xfer(struct udevice *dev, const uint8_t *sendbuf, size_t send_size,
|
int tpm_xfer(struct udevice *dev, const uint8_t *sendbuf, size_t send_size,
|
||||||
uint8_t *recvbuf, size_t *recv_size);
|
uint8_t *recvbuf, size_t *recv_size);
|
||||||
|
|
||||||
#endif /* CONFIG_DM_TPM */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize TPM device. It must be called before any TPM commands.
|
* Initialize TPM device. It must be called before any TPM commands.
|
||||||
*
|
*
|
||||||
|
@ -96,7 +96,7 @@ enum {
|
|||||||
* (the hubs) have this as parent data. Hubs are children of controllers or
|
* (the hubs) have this as parent data. Hubs are children of controllers or
|
||||||
* other hubs and there is always a single root hub for each controller.
|
* other hubs and there is always a single root hub for each controller.
|
||||||
* Therefore struct usb_device can always be accessed with
|
* Therefore struct usb_device can always be accessed with
|
||||||
* dev_get_parentdata(dev), where dev is a USB device.
|
* dev_get_parent_priv(dev), where dev is a USB device.
|
||||||
*
|
*
|
||||||
* Pointers exist for obtaining both the device (could be any uclass) and
|
* Pointers exist for obtaining both the device (could be any uclass) and
|
||||||
* controller (UCLASS_USB) from this structure. The controller does not have
|
* controller (UCLASS_USB) from this structure. The controller does not have
|
||||||
|
@ -56,6 +56,7 @@ source lib/rsa/Kconfig
|
|||||||
|
|
||||||
config TPM
|
config TPM
|
||||||
bool "Trusted Platform Module (TPM) Support"
|
bool "Trusted Platform Module (TPM) Support"
|
||||||
|
depends on DM
|
||||||
help
|
help
|
||||||
This enables support for TPMs which can be used to provide security
|
This enables support for TPMs which can be used to provide security
|
||||||
features for your board. The TPM can be connected via LPC or I2C
|
features for your board. The TPM can be connected via LPC or I2C
|
||||||
|
14
lib/fdtdec.c
14
lib/fdtdec.c
@ -219,13 +219,13 @@ int fdtdec_get_pci_addr(const void *blob, int node, enum fdt_pci_space type,
|
|||||||
|
|
||||||
for (i = 0; i < num; i++) {
|
for (i = 0; i < num; i++) {
|
||||||
debug("pci address #%d: %08lx %08lx %08lx\n", i,
|
debug("pci address #%d: %08lx %08lx %08lx\n", i,
|
||||||
(ulong)fdt_addr_to_cpu(cell[0]),
|
(ulong)fdt32_to_cpu(cell[0]),
|
||||||
(ulong)fdt_addr_to_cpu(cell[1]),
|
(ulong)fdt32_to_cpu(cell[1]),
|
||||||
(ulong)fdt_addr_to_cpu(cell[2]));
|
(ulong)fdt32_to_cpu(cell[2]));
|
||||||
if ((fdt_addr_to_cpu(*cell) & type) == type) {
|
if ((fdt32_to_cpu(*cell) & type) == type) {
|
||||||
addr->phys_hi = fdt_addr_to_cpu(cell[0]);
|
addr->phys_hi = fdt32_to_cpu(cell[0]);
|
||||||
addr->phys_mid = fdt_addr_to_cpu(cell[1]);
|
addr->phys_mid = fdt32_to_cpu(cell[1]);
|
||||||
addr->phys_lo = fdt_addr_to_cpu(cell[2]);
|
addr->phys_lo = fdt32_to_cpu(cell[1]);
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
cell += (FDT_PCI_ADDR_CELLS +
|
cell += (FDT_PCI_ADDR_CELLS +
|
||||||
|
20
lib/tpm.c
20
lib/tpm.c
@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <dm.h>
|
#include <dm.h>
|
||||||
#include <tis.h>
|
|
||||||
#include <tpm.h>
|
#include <tpm.h>
|
||||||
#include <asm/unaligned.h>
|
#include <asm/unaligned.h>
|
||||||
#include <u-boot/sha1.h>
|
#include <u-boot/sha1.h>
|
||||||
@ -230,6 +229,8 @@ static uint32_t tpm_return_code(const void *response)
|
|||||||
static uint32_t tpm_sendrecv_command(const void *command,
|
static uint32_t tpm_sendrecv_command(const void *command,
|
||||||
void *response, size_t *size_ptr)
|
void *response, size_t *size_ptr)
|
||||||
{
|
{
|
||||||
|
struct udevice *dev;
|
||||||
|
int ret;
|
||||||
uint8_t response_buffer[COMMAND_BUFFER_SIZE];
|
uint8_t response_buffer[COMMAND_BUFFER_SIZE];
|
||||||
size_t response_length;
|
size_t response_length;
|
||||||
uint32_t err;
|
uint32_t err;
|
||||||
@ -240,19 +241,13 @@ static uint32_t tpm_sendrecv_command(const void *command,
|
|||||||
response = response_buffer;
|
response = response_buffer;
|
||||||
response_length = sizeof(response_buffer);
|
response_length = sizeof(response_buffer);
|
||||||
}
|
}
|
||||||
#ifdef CONFIG_DM_TPM
|
|
||||||
struct udevice *dev;
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
ret = uclass_first_device(UCLASS_TPM, &dev);
|
ret = uclass_first_device(UCLASS_TPM, &dev);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
err = tpm_xfer(dev, command, tpm_command_size(command),
|
err = tpm_xfer(dev, command, tpm_command_size(command),
|
||||||
response, &response_length);
|
response, &response_length);
|
||||||
#else
|
|
||||||
err = tis_sendrecv(command, tpm_command_size(command),
|
|
||||||
response, &response_length);
|
|
||||||
#endif
|
|
||||||
if (err < 0)
|
if (err < 0)
|
||||||
return TPM_LIB_ERROR;
|
return TPM_LIB_ERROR;
|
||||||
if (size_ptr)
|
if (size_ptr)
|
||||||
@ -264,21 +259,12 @@ static uint32_t tpm_sendrecv_command(const void *command,
|
|||||||
int tpm_init(void)
|
int tpm_init(void)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
#ifdef CONFIG_DM_TPM
|
|
||||||
struct udevice *dev;
|
struct udevice *dev;
|
||||||
|
|
||||||
err = uclass_first_device(UCLASS_TPM, &dev);
|
err = uclass_first_device(UCLASS_TPM, &dev);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
return tpm_open(dev);
|
return tpm_open(dev);
|
||||||
#else
|
|
||||||
err = tis_init();
|
|
||||||
if (err)
|
|
||||||
return err;
|
|
||||||
|
|
||||||
return tis_open();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t tpm_startup(enum tpm_startup_type mode)
|
uint32_t tpm_startup(enum tpm_startup_type mode)
|
||||||
|
@ -46,7 +46,7 @@ static int testbus_child_post_bind(struct udevice *dev)
|
|||||||
|
|
||||||
static int testbus_child_pre_probe(struct udevice *dev)
|
static int testbus_child_pre_probe(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct dm_test_parent_data *parent_data = dev_get_parentdata(dev);
|
struct dm_test_parent_data *parent_data = dev_get_parent_priv(dev);
|
||||||
|
|
||||||
parent_data->flag += FLAG_CHILD_PROBED;
|
parent_data->flag += FLAG_CHILD_PROBED;
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ static int testbus_child_pre_probe_uclass(struct udevice *dev)
|
|||||||
|
|
||||||
static int testbus_child_post_remove(struct udevice *dev)
|
static int testbus_child_post_remove(struct udevice *dev)
|
||||||
{
|
{
|
||||||
struct dm_test_parent_data *parent_data = dev_get_parentdata(dev);
|
struct dm_test_parent_data *parent_data = dev_get_parent_priv(dev);
|
||||||
struct dm_test_state *dms = test_state;
|
struct dm_test_state *dms = test_state;
|
||||||
|
|
||||||
parent_data->flag += FLAG_CHILD_REMOVED;
|
parent_data->flag += FLAG_CHILD_REMOVED;
|
||||||
@ -215,20 +215,20 @@ static int test_bus_parent_data(struct unit_test_state *uts)
|
|||||||
|
|
||||||
/* Check that parent data is allocated */
|
/* Check that parent data is allocated */
|
||||||
ut_assertok(device_find_child_by_seq(bus, 0, true, &dev));
|
ut_assertok(device_find_child_by_seq(bus, 0, true, &dev));
|
||||||
ut_asserteq_ptr(NULL, dev_get_parentdata(dev));
|
ut_asserteq_ptr(NULL, dev_get_parent_priv(dev));
|
||||||
ut_assertok(device_get_child_by_seq(bus, 0, &dev));
|
ut_assertok(device_get_child_by_seq(bus, 0, &dev));
|
||||||
parent_data = dev_get_parentdata(dev);
|
parent_data = dev_get_parent_priv(dev);
|
||||||
ut_assert(NULL != parent_data);
|
ut_assert(NULL != parent_data);
|
||||||
|
|
||||||
/* Check that it starts at 0 and goes away when device is removed */
|
/* Check that it starts at 0 and goes away when device is removed */
|
||||||
parent_data->sum += 5;
|
parent_data->sum += 5;
|
||||||
ut_asserteq(5, parent_data->sum);
|
ut_asserteq(5, parent_data->sum);
|
||||||
device_remove(dev);
|
device_remove(dev);
|
||||||
ut_asserteq_ptr(NULL, dev_get_parentdata(dev));
|
ut_asserteq_ptr(NULL, dev_get_parent_priv(dev));
|
||||||
|
|
||||||
/* Check that we can do this twice */
|
/* Check that we can do this twice */
|
||||||
ut_assertok(device_get_child_by_seq(bus, 0, &dev));
|
ut_assertok(device_get_child_by_seq(bus, 0, &dev));
|
||||||
parent_data = dev_get_parentdata(dev);
|
parent_data = dev_get_parent_priv(dev);
|
||||||
ut_assert(NULL != parent_data);
|
ut_assert(NULL != parent_data);
|
||||||
parent_data->sum += 5;
|
parent_data->sum += 5;
|
||||||
ut_asserteq(5, parent_data->sum);
|
ut_asserteq(5, parent_data->sum);
|
||||||
@ -239,11 +239,11 @@ static int test_bus_parent_data(struct unit_test_state *uts)
|
|||||||
uclass_foreach_dev(dev, uc) {
|
uclass_foreach_dev(dev, uc) {
|
||||||
/* Ignore these if they are not on this bus */
|
/* Ignore these if they are not on this bus */
|
||||||
if (dev->parent != bus) {
|
if (dev->parent != bus) {
|
||||||
ut_asserteq_ptr(NULL, dev_get_parentdata(dev));
|
ut_asserteq_ptr(NULL, dev_get_parent_priv(dev));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
ut_assertok(device_probe(dev));
|
ut_assertok(device_probe(dev));
|
||||||
parent_data = dev_get_parentdata(dev);
|
parent_data = dev_get_parent_priv(dev);
|
||||||
|
|
||||||
parent_data->sum = value;
|
parent_data->sum = value;
|
||||||
value += 5;
|
value += 5;
|
||||||
@ -255,7 +255,7 @@ static int test_bus_parent_data(struct unit_test_state *uts)
|
|||||||
/* Ignore these if they are not on this bus */
|
/* Ignore these if they are not on this bus */
|
||||||
if (dev->parent != bus)
|
if (dev->parent != bus)
|
||||||
continue;
|
continue;
|
||||||
parent_data = dev_get_parentdata(dev);
|
parent_data = dev_get_parent_priv(dev);
|
||||||
|
|
||||||
ut_asserteq(value, parent_data->sum);
|
ut_asserteq(value, parent_data->sum);
|
||||||
value += 5;
|
value += 5;
|
||||||
@ -311,10 +311,10 @@ static int dm_test_bus_parent_ops(struct unit_test_state *uts)
|
|||||||
/* Ignore these if they are not on this bus */
|
/* Ignore these if they are not on this bus */
|
||||||
if (dev->parent != bus)
|
if (dev->parent != bus)
|
||||||
continue;
|
continue;
|
||||||
ut_asserteq_ptr(NULL, dev_get_parentdata(dev));
|
ut_asserteq_ptr(NULL, dev_get_parent_priv(dev));
|
||||||
|
|
||||||
ut_assertok(device_probe(dev));
|
ut_assertok(device_probe(dev));
|
||||||
parent_data = dev_get_parentdata(dev);
|
parent_data = dev_get_parent_priv(dev);
|
||||||
ut_asserteq(FLAG_CHILD_PROBED, parent_data->flag);
|
ut_asserteq(FLAG_CHILD_PROBED, parent_data->flag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -322,10 +322,10 @@ static int dm_test_bus_parent_ops(struct unit_test_state *uts)
|
|||||||
/* Ignore these if they are not on this bus */
|
/* Ignore these if they are not on this bus */
|
||||||
if (dev->parent != bus)
|
if (dev->parent != bus)
|
||||||
continue;
|
continue;
|
||||||
parent_data = dev_get_parentdata(dev);
|
parent_data = dev_get_parent_priv(dev);
|
||||||
ut_asserteq(FLAG_CHILD_PROBED, parent_data->flag);
|
ut_asserteq(FLAG_CHILD_PROBED, parent_data->flag);
|
||||||
ut_assertok(device_remove(dev));
|
ut_assertok(device_remove(dev));
|
||||||
ut_asserteq_ptr(NULL, dev_get_parentdata(dev));
|
ut_asserteq_ptr(NULL, dev_get_parent_priv(dev));
|
||||||
ut_asserteq_ptr(dms->removed, dev);
|
ut_asserteq_ptr(dms->removed, dev);
|
||||||
}
|
}
|
||||||
test_state = NULL;
|
test_state = NULL;
|
||||||
|
Reference in New Issue
Block a user