mirror of
https://source.denx.de/u-boot/u-boot.git
synced 2026-06-13 15:03:58 +03:00
Merge branch 'master' of git://git.denx.de/u-boot-dm
This commit is contained in:
@@ -1,32 +1,73 @@
|
||||
/*
|
||||
* You do not need to use #ifdef around functions that may not exist
|
||||
* You need to use #ifdef around functions that may not exist
|
||||
* in the final configuration (such as i2c).
|
||||
* use a dummyfunction as first parameter to EXPORT_FUNC.
|
||||
* As an example see the CONFIG_CMD_I2C section below
|
||||
*/
|
||||
EXPORT_FUNC(get_version)
|
||||
EXPORT_FUNC(getc)
|
||||
EXPORT_FUNC(tstc)
|
||||
EXPORT_FUNC(putc)
|
||||
EXPORT_FUNC(puts)
|
||||
EXPORT_FUNC(printf)
|
||||
EXPORT_FUNC(install_hdlr)
|
||||
EXPORT_FUNC(free_hdlr)
|
||||
EXPORT_FUNC(malloc)
|
||||
EXPORT_FUNC(free)
|
||||
EXPORT_FUNC(udelay)
|
||||
EXPORT_FUNC(get_timer)
|
||||
EXPORT_FUNC(vprintf)
|
||||
EXPORT_FUNC(do_reset)
|
||||
EXPORT_FUNC(getenv)
|
||||
EXPORT_FUNC(setenv)
|
||||
EXPORT_FUNC(simple_strtoul)
|
||||
EXPORT_FUNC(strict_strtoul)
|
||||
EXPORT_FUNC(simple_strtol)
|
||||
EXPORT_FUNC(strcmp)
|
||||
EXPORT_FUNC(i2c_write)
|
||||
EXPORT_FUNC(i2c_read)
|
||||
EXPORT_FUNC(spi_init)
|
||||
EXPORT_FUNC(spi_setup_slave)
|
||||
EXPORT_FUNC(spi_free_slave)
|
||||
EXPORT_FUNC(spi_claim_bus)
|
||||
EXPORT_FUNC(spi_release_bus)
|
||||
EXPORT_FUNC(spi_xfer)
|
||||
#ifndef EXPORT_FUNC
|
||||
#define EXPORT_FUNC(a, b, c, ...)
|
||||
#endif
|
||||
EXPORT_FUNC(get_version, unsigned long, get_version, void)
|
||||
EXPORT_FUNC(getc, int, getc, void)
|
||||
EXPORT_FUNC(tstc, int, tstc, void)
|
||||
EXPORT_FUNC(putc, void, putc, const char)
|
||||
EXPORT_FUNC(puts, void, puts, const char *)
|
||||
EXPORT_FUNC(printf, int, printf, const char*, ...)
|
||||
#if defined(CONFIG_X86) || defined(CONFIG_PPC)
|
||||
EXPORT_FUNC(irq_install_handler, void, install_hdlr,
|
||||
int, interrupt_handler_t, void*)
|
||||
|
||||
EXPORT_FUNC(irq_free_handler, void, free_hdlr, int)
|
||||
#else
|
||||
EXPORT_FUNC(dummy, void, install_hdlr, void)
|
||||
EXPORT_FUNC(dummy, void, free_hdlr, void)
|
||||
#endif
|
||||
EXPORT_FUNC(malloc, void *, malloc, size_t)
|
||||
EXPORT_FUNC(free, void, free, void *)
|
||||
EXPORT_FUNC(udelay, void, udelay, unsigned long)
|
||||
EXPORT_FUNC(get_timer, unsigned long, get_timer, unsigned long)
|
||||
EXPORT_FUNC(vprintf, int, vprintf, const char *, va_list)
|
||||
EXPORT_FUNC(do_reset, int, do_reset, cmd_tbl_t *,
|
||||
int , int , char * const [])
|
||||
EXPORT_FUNC(getenv, char *, getenv, const char*)
|
||||
EXPORT_FUNC(setenv, int, setenv, const char *, const char *)
|
||||
EXPORT_FUNC(simple_strtoul, unsigned long, simple_strtoul,
|
||||
const char *, char **, unsigned int)
|
||||
EXPORT_FUNC(strict_strtoul, int, strict_strtoul,
|
||||
const char *, unsigned int , unsigned long *)
|
||||
EXPORT_FUNC(simple_strtol, long, simple_strtol,
|
||||
const char *, char **, unsigned int)
|
||||
EXPORT_FUNC(strcmp, int, strcmp, const char *cs, const char *ct)
|
||||
#if defined(CONFIG_CMD_I2C) && \
|
||||
(!defined(CONFIG_DM_I2C) || defined(CONFIG_DM_I2C_COMPAT))
|
||||
EXPORT_FUNC(i2c_write, int, i2c_write, uchar, uint, int , uchar * , int)
|
||||
EXPORT_FUNC(i2c_read, int, i2c_read, uchar, uint, int , uchar * , int)
|
||||
#else
|
||||
EXPORT_FUNC(dummy, void, i2c_write, void)
|
||||
EXPORT_FUNC(dummy, void, i2c_read, void)
|
||||
#endif
|
||||
|
||||
#if !defined(CONFIG_CMD_SPI) || defined(CONFIG_DM_SPI)
|
||||
EXPORT_FUNC(dummy, void, spi_init, void)
|
||||
EXPORT_FUNC(dummy, void, spi_setup_slave, void)
|
||||
EXPORT_FUNC(dummy, void, spi_free_slave, void)
|
||||
#else
|
||||
EXPORT_FUNC(spi_init, void, spi_init, void)
|
||||
EXPORT_FUNC(spi_setup_slave, struct spi_slave *, spi_setup_slave,
|
||||
unsigned int, unsigned int, unsigned int, unsigned int)
|
||||
EXPORT_FUNC(spi_free_slave, void, spi_free_slave, struct spi_slave *)
|
||||
#endif
|
||||
#ifndef CONFIG_CMD_SPI
|
||||
EXPORT_FUNC(dummy, void, spi_claim_bus, void)
|
||||
EXPORT_FUNC(dummy, void, spi_release_bus, void)
|
||||
EXPORT_FUNC(dummy, void, spi_xfer, void)
|
||||
#else
|
||||
EXPORT_FUNC(spi_claim_bus, int, spi_claim_bus, struct spi_slave *)
|
||||
EXPORT_FUNC(spi_release_bus, void, spi_release_bus, struct spi_slave *)
|
||||
EXPORT_FUNC(spi_xfer, int, spi_xfer, struct spi_slave *,
|
||||
unsigned int, const void *, void *, unsigned long)
|
||||
#endif
|
||||
EXPORT_FUNC(ustrtoul, unsigned long, ustrtoul,
|
||||
const char *, char **, unsigned int)
|
||||
EXPORT_FUNC(ustrtoull, unsigned long long, ustrtoull,
|
||||
const char *, char **, unsigned int)
|
||||
|
||||
@@ -73,7 +73,7 @@ typedef struct global_data {
|
||||
const void *fdt_blob; /* Our device tree, NULL if none */
|
||||
void *new_fdt; /* Relocated FDT */
|
||||
unsigned long fdt_size; /* Space reserved for relocated FDT */
|
||||
void **jt; /* jump table */
|
||||
struct jt_funcs *jt; /* jump table */
|
||||
char env_buf[32]; /* buffer for getenv() before reloc. */
|
||||
#ifdef CONFIG_TRACE
|
||||
void *trace_buff; /* The trace buffer */
|
||||
|
||||
@@ -10,6 +10,15 @@
|
||||
/*
|
||||
* Generic GPIO API for U-Boot
|
||||
*
|
||||
* --
|
||||
* NB: This is deprecated. Please use the driver model functions instead:
|
||||
*
|
||||
* - gpio_request_by_name()
|
||||
* - dm_gpio_get_value() etc.
|
||||
*
|
||||
* For now we need a dm_ prefix on some functions to avoid name collision.
|
||||
* --
|
||||
*
|
||||
* GPIOs are numbered from 0 to GPIO_COUNT-1 which value is defined
|
||||
* by the SOC/architecture.
|
||||
*
|
||||
@@ -26,6 +35,7 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* @deprecated Please use driver model instead
|
||||
* Request a GPIO. This should be called before any of the other functions
|
||||
* are used on this GPIO.
|
||||
*
|
||||
@@ -39,6 +49,7 @@
|
||||
int gpio_request(unsigned gpio, const char *label);
|
||||
|
||||
/**
|
||||
* @deprecated Please use driver model instead
|
||||
* Stop using the GPIO. This function should not alter pin configuration.
|
||||
*
|
||||
* @param gpio GPIO number
|
||||
@@ -47,6 +58,7 @@ int gpio_request(unsigned gpio, const char *label);
|
||||
int gpio_free(unsigned gpio);
|
||||
|
||||
/**
|
||||
* @deprecated Please use driver model instead
|
||||
* Make a GPIO an input.
|
||||
*
|
||||
* @param gpio GPIO number
|
||||
@@ -55,6 +67,7 @@ int gpio_free(unsigned gpio);
|
||||
int gpio_direction_input(unsigned gpio);
|
||||
|
||||
/**
|
||||
* @deprecated Please use driver model instead
|
||||
* Make a GPIO an output, and set its value.
|
||||
*
|
||||
* @param gpio GPIO number
|
||||
@@ -64,6 +77,7 @@ int gpio_direction_input(unsigned gpio);
|
||||
int gpio_direction_output(unsigned gpio, int value);
|
||||
|
||||
/**
|
||||
* @deprecated Please use driver model instead
|
||||
* Get a GPIO's value. This will work whether the GPIO is an input
|
||||
* or an output.
|
||||
*
|
||||
@@ -73,6 +87,7 @@ int gpio_direction_output(unsigned gpio, int value);
|
||||
int gpio_get_value(unsigned gpio);
|
||||
|
||||
/**
|
||||
* @deprecated Please use driver model instead
|
||||
* Set an output GPIO's value. The GPIO must already be an output or
|
||||
* this function may have no effect.
|
||||
*
|
||||
@@ -95,6 +110,34 @@ enum gpio_func_t {
|
||||
|
||||
struct udevice;
|
||||
|
||||
struct gpio_desc {
|
||||
struct udevice *dev; /* Device, NULL for invalid GPIO */
|
||||
unsigned long flags;
|
||||
#define GPIOD_REQUESTED (1 << 0) /* Requested/claimed */
|
||||
#define GPIOD_IS_OUT (1 << 1) /* GPIO is an output */
|
||||
#define GPIOD_IS_IN (1 << 2) /* GPIO is an output */
|
||||
#define GPIOD_ACTIVE_LOW (1 << 3) /* value has active low */
|
||||
#define GPIOD_IS_OUT_ACTIVE (1 << 4) /* set output active */
|
||||
|
||||
uint offset; /* GPIO offset within the device */
|
||||
/*
|
||||
* We could consider adding the GPIO label in here. Possibly we could
|
||||
* use this structure for internal GPIO information.
|
||||
*/
|
||||
};
|
||||
|
||||
/**
|
||||
* dm_gpio_is_valid() - Check if a GPIO is gpio_is_valie
|
||||
*
|
||||
* @desc: GPIO description containing device, offset and flags,
|
||||
* previously returned by gpio_request_by_name()
|
||||
* @return true if valid, false if not
|
||||
*/
|
||||
static inline bool dm_gpio_is_valid(struct gpio_desc *desc)
|
||||
{
|
||||
return desc->dev != NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* gpio_get_status() - get the current GPIO status as a string
|
||||
*
|
||||
@@ -106,6 +149,8 @@ struct udevice;
|
||||
* which means this is GPIO bank b, offset 4, currently set to input, current
|
||||
* value 1, [x] means that it is requested and the owner is 'sdmmc_cd'
|
||||
*
|
||||
* TODO(sjg@chromium.org): This should use struct gpio_desc
|
||||
*
|
||||
* @dev: Device to check
|
||||
* @offset: Offset of device GPIO to check
|
||||
* @buf: Place to put string
|
||||
@@ -118,6 +163,8 @@ int gpio_get_status(struct udevice *dev, int offset, char *buf, int buffsize);
|
||||
*
|
||||
* Note this returns GPIOF_UNUSED if the GPIO is not requested.
|
||||
*
|
||||
* TODO(sjg@chromium.org): This should use struct gpio_desc
|
||||
*
|
||||
* @dev: Device to check
|
||||
* @offset: Offset of device GPIO to check
|
||||
* @namep: If non-NULL, this is set to the nane given when the GPIO
|
||||
@@ -135,6 +182,8 @@ int gpio_get_function(struct udevice *dev, int offset, const char **namep);
|
||||
* Note this does not return GPIOF_UNUSED - it will always return the GPIO
|
||||
* driver's view of a pin function, even if it is not correctly set up.
|
||||
*
|
||||
* TODO(sjg@chromium.org): This should use struct gpio_desc
|
||||
*
|
||||
* @dev: Device to check
|
||||
* @offset: Offset of device GPIO to check
|
||||
* @namep: If non-NULL, this is set to the nane given when the GPIO
|
||||
@@ -155,6 +204,8 @@ int gpio_get_raw_function(struct udevice *dev, int offset, const char **namep);
|
||||
int gpio_requestf(unsigned gpio, const char *fmt, ...)
|
||||
__attribute__ ((format (__printf__, 2, 3)));
|
||||
|
||||
struct fdtdec_phandle_args;
|
||||
|
||||
/**
|
||||
* struct struct dm_gpio_ops - Driver model GPIO operations
|
||||
*
|
||||
@@ -198,6 +249,33 @@ struct dm_gpio_ops {
|
||||
* @return current function - GPIOF_...
|
||||
*/
|
||||
int (*get_function)(struct udevice *dev, unsigned offset);
|
||||
|
||||
/**
|
||||
* xlate() - Translate phandle arguments into a GPIO description
|
||||
*
|
||||
* This function should set up the fields in desc according to the
|
||||
* information in the arguments. The uclass will have set up:
|
||||
*
|
||||
* @desc->dev to @dev
|
||||
* @desc->flags to 0
|
||||
* @desc->offset to the value of the first argument in args, if any,
|
||||
* otherwise -1 (which is invalid)
|
||||
*
|
||||
* This method is optional so if the above defaults suit it can be
|
||||
* omitted. Typical behaviour is to set up the GPIOD_ACTIVE_LOW flag
|
||||
* in desc->flags.
|
||||
*
|
||||
* Note that @dev is passed in as a parameter to follow driver model
|
||||
* uclass conventions, even though it is already available as
|
||||
* desc->dev.
|
||||
*
|
||||
* @dev: GPIO device
|
||||
* @desc: Place to put GPIO description
|
||||
* @args: Arguments provided in descripion
|
||||
* @return 0 if OK, -ve on error
|
||||
*/
|
||||
int (*xlate)(struct udevice *dev, struct gpio_desc *desc,
|
||||
struct fdtdec_phandle_args *args);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -268,4 +346,191 @@ int gpio_lookup_name(const char *name, struct udevice **devp,
|
||||
*/
|
||||
unsigned gpio_get_values_as_int(const int *gpio_list);
|
||||
|
||||
/**
|
||||
* gpio_request_by_name() - Locate and request a GPIO by name
|
||||
*
|
||||
* This operates by looking up the given list name in the device (device
|
||||
* tree property) and requesting the GPIO for use. The property must exist
|
||||
* in @dev's node.
|
||||
*
|
||||
* Use @flags to specify whether the GPIO should be an input or output. In
|
||||
* principle this can also come from the device tree binding but most
|
||||
* bindings don't provide this information. Specifically, when the GPIO uclass
|
||||
* calls the xlate() method, it can return default flags, which are then
|
||||
* ORed with this @flags.
|
||||
*
|
||||
* If we find that requesting the GPIO is not always needed we could add a
|
||||
* new function or a new GPIOD_NO_REQUEST flag.
|
||||
*
|
||||
* At present driver model has no reference counting so if one device
|
||||
* requests a GPIO which subsequently is unbound, the @desc->dev pointer
|
||||
* will be invalid. However this will only happen if the GPIO device is
|
||||
* unbound, not if it is removed, so this seems like a reasonable limitation
|
||||
* for now. There is no real use case for unbinding drivers in normal
|
||||
* operation.
|
||||
*
|
||||
* The device tree binding is doc/device-tree-bindings/gpio/gpio.txt in
|
||||
* generate terms and each specific device may add additional details in
|
||||
* a binding file in the same directory.
|
||||
*
|
||||
* @dev: Device requesting the GPIO
|
||||
* @list_name: Name of GPIO list (e.g. "board-id-gpios")
|
||||
* @index: Index number of the GPIO in that list use request (0=first)
|
||||
* @desc: Returns GPIO description information. If there is no such
|
||||
* GPIO, dev->dev will be NULL.
|
||||
* @flags: Indicates the GPIO input/output settings (GPIOD_...)
|
||||
* @return 0 if OK, -ENOENT if the GPIO does not exist, -EINVAL if there is
|
||||
* something wrong with the list, or other -ve for another error (e.g.
|
||||
* -EBUSY if a GPIO was already requested)
|
||||
*/
|
||||
int gpio_request_by_name(struct udevice *dev, const char *list_name,
|
||||
int index, struct gpio_desc *desc, int flags);
|
||||
|
||||
/**
|
||||
* gpio_request_list_by_name() - Request a list of GPIOs
|
||||
*
|
||||
* Reads all the GPIOs from a list and requetss them. See
|
||||
* gpio_request_by_name() for additional details. Lists should not be
|
||||
* misused to hold unrelated or optional GPIOs. They should only be used
|
||||
* for things like parallel data lines. A zero phandle terminates the list
|
||||
* the list.
|
||||
*
|
||||
* This function will either succeed, and request all GPIOs in the list, or
|
||||
* fail and request none (it will free already-requested GPIOs in case of
|
||||
* an error part-way through).
|
||||
*
|
||||
* @dev: Device requesting the GPIO
|
||||
* @list_name: Name of GPIO list (e.g. "board-id-gpios")
|
||||
* @desc_list: Returns a list of GPIO description information
|
||||
* @max_count: Maximum number of GPIOs to return (@desc_list must be at least
|
||||
* this big)
|
||||
* @flags: Indicates the GPIO input/output settings (GPIOD_...)
|
||||
* @return number of GPIOs requested, or -ve on error
|
||||
*/
|
||||
int gpio_request_list_by_name(struct udevice *dev, const char *list_name,
|
||||
struct gpio_desc *desc_list, int max_count,
|
||||
int flags);
|
||||
|
||||
/**
|
||||
* gpio_get_list_count() - Returns the number of GPIOs in a list
|
||||
*
|
||||
* Counts the GPIOs in a list. See gpio_request_by_name() for additional
|
||||
* details.
|
||||
*
|
||||
* @dev: Device requesting the GPIO
|
||||
* @list_name: Name of GPIO list (e.g. "board-id-gpios")
|
||||
* @return number of GPIOs (0 for an empty property) or -ENOENT if the list
|
||||
* does not exist
|
||||
*/
|
||||
int gpio_get_list_count(struct udevice *dev, const char *list_name);
|
||||
|
||||
/**
|
||||
* gpio_request_by_name_nodev() - request GPIOs without a device
|
||||
*
|
||||
* This is a version of gpio_request_list_by_name() that does not use a
|
||||
* device. Avoid it unless the caller is not yet using driver model
|
||||
*/
|
||||
int gpio_request_by_name_nodev(const void *blob, int node,
|
||||
const char *list_name,
|
||||
int index, struct gpio_desc *desc, int flags);
|
||||
|
||||
/**
|
||||
* gpio_request_list_by_name_nodev() - request GPIOs without a device
|
||||
*
|
||||
* This is a version of gpio_request_list_by_name() that does not use a
|
||||
* device. Avoid it unless the caller is not yet using driver model
|
||||
*/
|
||||
int gpio_request_list_by_name_nodev(const void *blob, int node,
|
||||
const char *list_name,
|
||||
struct gpio_desc *desc_list, int max_count,
|
||||
int flags);
|
||||
|
||||
/**
|
||||
* dm_gpio_free() - Free a single GPIO
|
||||
*
|
||||
* This frees a single GPIOs previously returned from gpio_request_by_name().
|
||||
*
|
||||
* @dev: Device which requested the GPIO
|
||||
* @desc: GPIO to free
|
||||
* @return 0 if OK, -ve on error
|
||||
*/
|
||||
int dm_gpio_free(struct udevice *dev, struct gpio_desc *desc);
|
||||
|
||||
/**
|
||||
* gpio_free_list() - Free a list of GPIOs
|
||||
*
|
||||
* This frees a list of GPIOs previously returned from
|
||||
* gpio_request_list_by_name().
|
||||
*
|
||||
* @dev: Device which requested the GPIOs
|
||||
* @desc: List of GPIOs to free
|
||||
* @count: Number of GPIOs in the list
|
||||
* @return 0 if OK, -ve on error
|
||||
*/
|
||||
int gpio_free_list(struct udevice *dev, struct gpio_desc *desc, int count);
|
||||
|
||||
/**
|
||||
* gpio_free_list_nodev() - free GPIOs without a device
|
||||
*
|
||||
* This is a version of gpio_free_list() that does not use a
|
||||
* device. Avoid it unless the caller is not yet using driver model
|
||||
*/
|
||||
int gpio_free_list_nodev(struct gpio_desc *desc, int count);
|
||||
|
||||
/**
|
||||
* dm_gpio_get_value() - Get the value of a GPIO
|
||||
*
|
||||
* This is the driver model version of the existing gpio_get_value() function
|
||||
* and should be used instead of that.
|
||||
*
|
||||
* For now, these functions have a dm_ prefix since they conflict with
|
||||
* existing names.
|
||||
*
|
||||
* @desc: GPIO description containing device, offset and flags,
|
||||
* previously returned by gpio_request_by_name()
|
||||
* @return GPIO value (0 for inactive, 1 for active) or -ve on error
|
||||
*/
|
||||
int dm_gpio_get_value(struct gpio_desc *desc);
|
||||
|
||||
int dm_gpio_set_value(struct gpio_desc *desc, int value);
|
||||
|
||||
/**
|
||||
* dm_gpio_set_dir() - Set the direction for a GPIO
|
||||
*
|
||||
* This sets up the direction according tot the provided flags. It will do
|
||||
* nothing unless the direction is actually specified.
|
||||
*
|
||||
* @desc: GPIO description containing device, offset and flags,
|
||||
* previously returned by gpio_request_by_name()
|
||||
* @return 0 if OK, -ve on error
|
||||
*/
|
||||
int dm_gpio_set_dir(struct gpio_desc *desc);
|
||||
|
||||
/**
|
||||
* dm_gpio_set_dir_flags() - Set direction using specific flags
|
||||
*
|
||||
* This is like dm_gpio_set_dir() except that the flags value is provided
|
||||
* instead of being used from desc->flags. This is needed because in many
|
||||
* cases the GPIO description does not include direction information.
|
||||
* Note that desc->flags is updated by this function.
|
||||
*
|
||||
* @desc: GPIO description containing device, offset and flags,
|
||||
* previously returned by gpio_request_by_name()
|
||||
* @flags: New flags to use
|
||||
* @return 0 if OK, -ve on error, in which case desc->flags is not updated
|
||||
*/
|
||||
int dm_gpio_set_dir_flags(struct gpio_desc *desc, ulong flags);
|
||||
|
||||
/**
|
||||
* gpio_get_number() - Get the global GPIO number of a GPIO
|
||||
*
|
||||
* This should only be used for debugging or interest. It returns the nummber
|
||||
* that should be used for gpio_get_value() etc. to access this GPIO.
|
||||
*
|
||||
* @desc: GPIO description containing device, offset and flags,
|
||||
* previously returned by gpio_request_by_name()
|
||||
* @return GPIO number, or -ve if not found
|
||||
*/
|
||||
int gpio_get_number(struct gpio_desc *desc);
|
||||
|
||||
#endif /* _ASM_GENERIC_GPIO_H_ */
|
||||
|
||||
@@ -228,12 +228,13 @@ int run_command_list(const char *cmd, int len, int flag);
|
||||
extern char console_buffer[];
|
||||
|
||||
/* arch/$(ARCH)/lib/board.c */
|
||||
void board_init_f(ulong);
|
||||
void board_init_r (gd_t *, ulong) __attribute__ ((noreturn));
|
||||
int checkboard (void);
|
||||
int checkflash (void);
|
||||
int checkdram (void);
|
||||
int last_stage_init(void);
|
||||
void board_init_f(ulong);
|
||||
void board_init_r(gd_t *, ulong) __attribute__ ((noreturn));
|
||||
int checkboard(void);
|
||||
int show_board_info(void);
|
||||
int checkflash(void);
|
||||
int checkdram(void);
|
||||
int last_stage_init(void);
|
||||
extern ulong monitor_flash_len;
|
||||
int mac_read_from_eeprom(void);
|
||||
extern u8 __dtb_dt_begin[]; /* embedded device tree blob */
|
||||
|
||||
@@ -19,13 +19,11 @@
|
||||
#include <configs/ti_am335x_common.h>
|
||||
|
||||
#ifndef CONFIG_SPL_BUILD
|
||||
#ifndef CONFIG_FIT
|
||||
# define CONFIG_FIT
|
||||
#endif
|
||||
# define CONFIG_TIMESTAMP
|
||||
# define CONFIG_LZO
|
||||
# ifdef CONFIG_ENABLE_VBOOT
|
||||
# define CONFIG_FIT_SIGNATURE
|
||||
# define CONFIG_RSA
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define CONFIG_SYS_BOOTM_LEN (16 << 20)
|
||||
|
||||
@@ -51,8 +51,6 @@
|
||||
/* PMIC */
|
||||
#define CONFIG_PMIC
|
||||
#define CONFIG_POWER_I2C
|
||||
#define CONFIG_POWER_MAX77686
|
||||
|
||||
|
||||
#define CONFIG_PREBOOT
|
||||
|
||||
|
||||
@@ -126,12 +126,11 @@
|
||||
#define SPI_FLASH_UBOOT_POS (CONFIG_SEC_FW_SIZE + CONFIG_BL1_SIZE)
|
||||
|
||||
/* I2C */
|
||||
#define CONFIG_SYS_I2C_INIT_BOARD
|
||||
#define CONFIG_SYS_I2C
|
||||
#define CONFIG_DM_I2C
|
||||
#define CONFIG_DM_I2C_COMPAT
|
||||
#define CONFIG_CMD_I2C
|
||||
#define CONFIG_SYS_I2C_S3C24X0_SPEED 100000 /* 100 Kbps */
|
||||
#define CONFIG_SYS_I2C_S3C24X0
|
||||
#define CONFIG_I2C_MULTI_BUS
|
||||
#define CONFIG_SYS_I2C_S3C24X0_SPEED 100000 /* 100 Kbps */
|
||||
#define CONFIG_SYS_I2C_S3C24X0_SLAVE 0x0
|
||||
#define CONFIG_I2C_EDID
|
||||
|
||||
|
||||
@@ -28,9 +28,6 @@
|
||||
|
||||
#define CONFIG_SYS_INIT_SP_ADDR CONFIG_IRAM_STACK
|
||||
|
||||
/* PMIC */
|
||||
#define CONFIG_POWER_MAX77686
|
||||
|
||||
/* Sound */
|
||||
#define CONFIG_CMD_SOUND
|
||||
#ifdef CONFIG_CMD_SOUND
|
||||
|
||||
@@ -575,12 +575,9 @@
|
||||
|
||||
#define CONFIG_VERSION_VARIABLE
|
||||
|
||||
#define CONFIG_FIT
|
||||
#define CONFIG_FIT_SIGNATURE
|
||||
#define CONFIG_IMAGE_FORMAT_LEGACY
|
||||
#define CONFIG_CMD_FDT
|
||||
#define CONFIG_CMD_HASH
|
||||
#define CONFIG_RSA
|
||||
#define CONFIG_SHA1
|
||||
#define CONFIG_SHA256
|
||||
|
||||
|
||||
@@ -177,12 +177,11 @@
|
||||
|
||||
/* I2C */
|
||||
#define CONFIG_CMD_I2C
|
||||
#define CONFIG_SYS_I2C
|
||||
#define CONFIG_DM_I2C
|
||||
#define CONFIG_DM_I2C_COMPAT
|
||||
#define CONFIG_SYS_I2C_S3C24X0
|
||||
#define CONFIG_SYS_I2C_S3C24X0_SPEED 100000
|
||||
#define CONFIG_SYS_I2C_S3C24X0_SLAVE 0
|
||||
#define CONFIG_MAX_I2C_NUM 8
|
||||
#define CONFIG_SYS_I2C_INIT_BOARD
|
||||
|
||||
/* POWER */
|
||||
#define CONFIG_POWER
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
#define CONFIG_BOOTSTAGE
|
||||
#define CONFIG_BOOTSTAGE_REPORT
|
||||
#define CONFIG_DM
|
||||
#define CONFIG_CMD_DEMO
|
||||
#define CONFIG_CMD_DM
|
||||
#define CONFIG_DM_DEMO
|
||||
@@ -41,9 +40,6 @@
|
||||
|
||||
#define CONFIG_OF_LIBFDT
|
||||
#define CONFIG_LMB
|
||||
#define CONFIG_FIT
|
||||
#define CONFIG_FIT_SIGNATURE
|
||||
#define CONFIG_RSA
|
||||
#define CONFIG_CMD_FDT
|
||||
#define CONFIG_ANDROID_BOOT_IMAGE
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
#include <configs/exynos5250-common.h>
|
||||
|
||||
/* PMIC */
|
||||
#define CONFIG_POWER_MAX77686
|
||||
|
||||
#define CONFIG_BOARD_COMMON
|
||||
#define CONFIG_ARCH_EARLY_INIT_R
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
#define CONFIG_CROS_EC_I2C /* Support CROS_EC over I2C */
|
||||
#define CONFIG_POWER_TPS65090_I2C
|
||||
#define CONFIG_DM_CROS_EC
|
||||
|
||||
#define CONFIG_BOARD_COMMON
|
||||
#define CONFIG_ARCH_EARLY_INIT_R
|
||||
|
||||
@@ -20,7 +20,9 @@
|
||||
#define CONFIG_SPL_AM33XX_ENABLE_RTC32K_OSC
|
||||
|
||||
#ifndef CONFIG_SPL_BUILD
|
||||
#ifndef CONFIG_DM
|
||||
# define CONFIG_DM
|
||||
#endif
|
||||
# define CONFIG_CMD_DM
|
||||
# define CONFIG_DM_GPIO
|
||||
# define CONFIG_DM_SERIAL
|
||||
|
||||
@@ -43,6 +43,9 @@
|
||||
#define CONFIG_SDRAM1_SIZE 0x10000000
|
||||
#endif
|
||||
|
||||
#define CONFIG_I2C_EEPROM
|
||||
#define CONFIG_SYS_EEPROM_PAGE_WRITE_DELAY_MS 10
|
||||
|
||||
/*
|
||||
* Support card address map
|
||||
*/
|
||||
|
||||
@@ -276,17 +276,11 @@
|
||||
#define CONFIG_OF_LIBFDT
|
||||
|
||||
/* FIT support */
|
||||
#define CONFIG_FIT
|
||||
#define CONFIG_FIT_VERBOSE 1 /* enable fit_format_{error,warning}() */
|
||||
#define CONFIG_IMAGE_FORMAT_LEGACY /* enable also legacy image format */
|
||||
|
||||
/* FDT support */
|
||||
#define CONFIG_DISPLAY_BOARDINFO_LATE
|
||||
|
||||
/* RSA support */
|
||||
#define CONFIG_FIT_SIGNATURE
|
||||
#define CONFIG_RSA
|
||||
|
||||
/* Extend size of kernel image for uncompression */
|
||||
#define CONFIG_SYS_BOOTM_LEN (60 * 1024 * 1024)
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <ec_commands.h>
|
||||
#include <fdtdec.h>
|
||||
#include <cros_ec_message.h>
|
||||
#include <asm/gpio.h>
|
||||
|
||||
#ifndef CONFIG_DM_CROS_EC
|
||||
/* Which interface is the device on? */
|
||||
@@ -39,7 +40,7 @@ struct cros_ec_dev {
|
||||
unsigned int bus_num; /* Bus number (for I2C) */
|
||||
unsigned int max_frequency; /* Maximum interface frequency */
|
||||
#endif
|
||||
struct fdt_gpio_state ec_int; /* GPIO used as EC interrupt line */
|
||||
struct gpio_desc ec_int; /* GPIO used as EC interrupt line */
|
||||
int protocol_version; /* Protocol version to use */
|
||||
int optimise_flash_write; /* Don't write erased flash blocks */
|
||||
|
||||
|
||||
@@ -25,10 +25,14 @@ struct dm_demo_pdata {
|
||||
struct demo_ops {
|
||||
int (*hello)(struct udevice *dev, int ch);
|
||||
int (*status)(struct udevice *dev, int *status);
|
||||
int (*set_light)(struct udevice *dev, int light);
|
||||
int (*get_light)(struct udevice *dev);
|
||||
};
|
||||
|
||||
int demo_hello(struct udevice *dev, int ch);
|
||||
int demo_status(struct udevice *dev, int *status);
|
||||
int demo_set_light(struct udevice *dev, int light);
|
||||
int demo_get_light(struct udevice *dev);
|
||||
int demo_list(void);
|
||||
|
||||
int demo_parse_dt(struct udevice *dev);
|
||||
|
||||
@@ -26,6 +26,9 @@ struct driver_info;
|
||||
/* DM should init this device prior to relocation */
|
||||
#define DM_FLAG_PRE_RELOC (1 << 2)
|
||||
|
||||
/* DM is responsible for allocating and freeing parent_platdata */
|
||||
#define DM_FLAG_ALLOC_PARENT_PDATA (1 << 3)
|
||||
|
||||
/**
|
||||
* struct udevice - An instance of a driver
|
||||
*
|
||||
@@ -46,6 +49,7 @@ struct driver_info;
|
||||
* @driver: The driver used by this device
|
||||
* @name: Name of device, typically the FDT node name
|
||||
* @platdata: Configuration data for this device
|
||||
* @parent_platdata: The parent bus's configuration data for this device
|
||||
* @of_offset: Device tree node offset for this device (- for none)
|
||||
* @of_id: Pointer to the udevice_id structure which created the device
|
||||
* @parent: Parent of this device, or NULL for the top level device
|
||||
@@ -65,6 +69,7 @@ struct udevice {
|
||||
struct driver *driver;
|
||||
const char *name;
|
||||
void *platdata;
|
||||
void *parent_platdata;
|
||||
int of_offset;
|
||||
const struct udevice_id *of_id;
|
||||
struct udevice *parent;
|
||||
@@ -127,6 +132,7 @@ struct udevice_id {
|
||||
* @remove: Called to remove a device, i.e. de-activate it
|
||||
* @unbind: Called to unbind a device from its driver
|
||||
* @ofdata_to_platdata: Called before probe to decode device tree data
|
||||
* @child_post_bind: Called after a new child has been bound
|
||||
* @child_pre_probe: Called before a child device is probed. The device has
|
||||
* memory allocated but it has not yet been probed.
|
||||
* @child_post_remove: Called after a child device is removed. The device
|
||||
@@ -146,6 +152,9 @@ struct udevice_id {
|
||||
* 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
|
||||
* its children. If non-zero this is the size of this data, to be allocated
|
||||
* in the child's parent_platdata pointer.
|
||||
* @ops: Driver-specific operations. This is typically a list of function
|
||||
* pointers defined by the driver, to implement driver functions required by
|
||||
* the uclass.
|
||||
@@ -160,11 +169,13 @@ struct driver {
|
||||
int (*remove)(struct udevice *dev);
|
||||
int (*unbind)(struct udevice *dev);
|
||||
int (*ofdata_to_platdata)(struct udevice *dev);
|
||||
int (*child_post_bind)(struct udevice *dev);
|
||||
int (*child_pre_probe)(struct udevice *dev);
|
||||
int (*child_post_remove)(struct udevice *dev);
|
||||
int priv_auto_alloc_size;
|
||||
int platdata_auto_alloc_size;
|
||||
int per_child_auto_alloc_size;
|
||||
int per_child_platdata_auto_alloc_size;
|
||||
const void *ops; /* driver-specific operations */
|
||||
uint32_t flags;
|
||||
};
|
||||
@@ -183,6 +194,16 @@ struct driver {
|
||||
*/
|
||||
void *dev_get_platdata(struct udevice *dev);
|
||||
|
||||
/**
|
||||
* dev_get_parent_platdata() - Get the parent platform data for a device
|
||||
*
|
||||
* This checks that dev is not NULL, but no other checks for now
|
||||
*
|
||||
* @dev Device to check
|
||||
* @return parent's platform data, or NULL if none
|
||||
*/
|
||||
void *dev_get_parent_platdata(struct udevice *dev);
|
||||
|
||||
/**
|
||||
* dev_get_parentdata() - Get the parent data for a device
|
||||
*
|
||||
@@ -224,6 +245,14 @@ struct udevice *dev_get_parent(struct udevice *child);
|
||||
*/
|
||||
ulong dev_get_of_data(struct udevice *dev);
|
||||
|
||||
/*
|
||||
* device_get_uclass_id() - return the uclass ID of a device
|
||||
*
|
||||
* @dev: Device to check
|
||||
* @return uclass ID for the device
|
||||
*/
|
||||
enum uclass_id device_get_uclass_id(struct udevice *dev);
|
||||
|
||||
/**
|
||||
* device_get_child() - Get the child of a device by index
|
||||
*
|
||||
|
||||
@@ -67,6 +67,8 @@ enum {
|
||||
struct dm_test_priv {
|
||||
int ping_total;
|
||||
int op_count[DM_TEST_OP_COUNT];
|
||||
int uclass_flag;
|
||||
int uclass_total;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -88,6 +90,7 @@ struct dm_test_uclass_priv {
|
||||
*
|
||||
* @sum: Test value used to check parent data works correctly
|
||||
* @flag: Used to track calling of parent operations
|
||||
* @uclass_flag: Used to track calling of parent operations by uclass
|
||||
*/
|
||||
struct dm_test_parent_data {
|
||||
int sum;
|
||||
|
||||
@@ -33,6 +33,7 @@ enum uclass_id {
|
||||
UCLASS_I2C, /* I2C bus */
|
||||
UCLASS_I2C_GENERIC, /* Generic I2C device */
|
||||
UCLASS_I2C_EEPROM, /* I2C EEPROM device */
|
||||
UCLASS_MOD_EXP, /* RSA Mod Exp device */
|
||||
|
||||
UCLASS_COUNT,
|
||||
UCLASS_INVALID = -1,
|
||||
|
||||
@@ -43,6 +43,17 @@ int uclass_bind_device(struct udevice *dev);
|
||||
*/
|
||||
int uclass_unbind_device(struct udevice *dev);
|
||||
|
||||
/**
|
||||
* uclass_pre_probe_child() - Deal with a child that is about to be probed
|
||||
*
|
||||
* Perform any pre-processing that is needed by the uclass before it can be
|
||||
* probed.
|
||||
*
|
||||
* @dev: Pointer to the device
|
||||
* #return 0 on success, -ve on error
|
||||
*/
|
||||
int uclass_pre_probe_child(struct udevice *dev);
|
||||
|
||||
/**
|
||||
* uclass_post_probe_device() - Deal with a device that has just been probed
|
||||
*
|
||||
|
||||
@@ -40,6 +40,9 @@ struct uclass {
|
||||
|
||||
struct udevice;
|
||||
|
||||
/* Members of this uclass sequence themselves with aliases */
|
||||
#define DM_UC_FLAG_SEQ_ALIAS (1 << 0)
|
||||
|
||||
/**
|
||||
* struct uclass_driver - Driver for the uclass
|
||||
*
|
||||
@@ -52,6 +55,7 @@ struct udevice;
|
||||
* @pre_unbind: Called before a device is unbound from this uclass
|
||||
* @post_probe: Called after a new device is probed
|
||||
* @pre_remove: Called before a device is removed
|
||||
* @child_post_bind: Called after a child is bound to a device in this uclass
|
||||
* @init: Called to set up the uclass
|
||||
* @destroy: Called to destroy the uclass
|
||||
* @priv_auto_alloc_size: If non-zero this is the size of the private data
|
||||
@@ -60,8 +64,16 @@ struct udevice;
|
||||
* @per_device_auto_alloc_size: Each device can hold private data owned
|
||||
* by the uclass. If required this will be automatically allocated if this
|
||||
* value is non-zero.
|
||||
* @per_child_auto_alloc_size: Each child device (of a parent in this
|
||||
* uclass) can hold parent data for the device/uclass. This value is only
|
||||
* used as a falback if this member is 0 in the driver.
|
||||
* @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
|
||||
* in the child device's parent_platdata pointer. This value is only used as
|
||||
* a falback if this member is 0 in the driver.
|
||||
* @ops: Uclass operations, providing the consistent interface to devices
|
||||
* within the uclass.
|
||||
* @flags: Flags for this uclass (DM_UC_...)
|
||||
*/
|
||||
struct uclass_driver {
|
||||
const char *name;
|
||||
@@ -70,11 +82,16 @@ struct uclass_driver {
|
||||
int (*pre_unbind)(struct udevice *dev);
|
||||
int (*post_probe)(struct udevice *dev);
|
||||
int (*pre_remove)(struct udevice *dev);
|
||||
int (*child_post_bind)(struct udevice *dev);
|
||||
int (*child_pre_probe)(struct udevice *dev);
|
||||
int (*init)(struct uclass *class);
|
||||
int (*destroy)(struct uclass *class);
|
||||
int priv_auto_alloc_size;
|
||||
int per_device_auto_alloc_size;
|
||||
int per_child_auto_alloc_size;
|
||||
int per_child_platdata_auto_alloc_size;
|
||||
const void *ops;
|
||||
uint32_t flags;
|
||||
};
|
||||
|
||||
/* Declare a new uclass_driver */
|
||||
@@ -141,6 +158,8 @@ int uclass_get_device_by_of_offset(enum uclass_id id, int node,
|
||||
/**
|
||||
* uclass_first_device() - Get the first device in a uclass
|
||||
*
|
||||
* The device returned is probed if necessary, and ready for use
|
||||
*
|
||||
* @id: Uclass ID to look up
|
||||
* @devp: Returns pointer to the first device in that uclass, or NULL if none
|
||||
* @return 0 if OK (found or not found), -1 on error
|
||||
@@ -150,6 +169,8 @@ int uclass_first_device(enum uclass_id id, struct udevice **devp);
|
||||
/**
|
||||
* uclass_next_device() - Get the next device in a uclass
|
||||
*
|
||||
* The device returned is probed if necessary, and ready for use
|
||||
*
|
||||
* @devp: On entry, pointer to device to lookup. On exit, returns pointer
|
||||
* to the next device in the same uclass, or NULL if none
|
||||
* @return 0 if OK (found or not found), -1 on error
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
struct spi_slave;
|
||||
|
||||
/* These are declarations of exported functions available in C code */
|
||||
unsigned long get_version(void);
|
||||
int getc(void);
|
||||
@@ -10,22 +12,23 @@ int tstc(void);
|
||||
void putc(const char);
|
||||
void puts(const char*);
|
||||
int printf(const char* fmt, ...);
|
||||
void install_hdlr(int, void (*interrupt_handler_t)(void *), void*);
|
||||
void install_hdlr(int, interrupt_handler_t, void*);
|
||||
void free_hdlr(int);
|
||||
void *malloc(size_t);
|
||||
void free(void*);
|
||||
void __udelay(unsigned long);
|
||||
unsigned long get_timer(unsigned long);
|
||||
int vprintf(const char *, va_list);
|
||||
unsigned long simple_strtoul(const char *cp,char **endp,unsigned int base);
|
||||
unsigned long simple_strtoul(const char *cp, char **endp, unsigned int base);
|
||||
int strict_strtoul(const char *cp, unsigned int base, unsigned long *res);
|
||||
char *getenv (const char *name);
|
||||
int setenv (const char *varname, const char *varvalue);
|
||||
long simple_strtol(const char *cp,char **endp,unsigned int base);
|
||||
int strcmp(const char * cs,const char * ct);
|
||||
long simple_strtol(const char *cp, char **endp, unsigned int base);
|
||||
int strcmp(const char *cs, const char *ct);
|
||||
unsigned long ustrtoul(const char *cp, char **endp, unsigned int base);
|
||||
unsigned long long ustrtoull(const char *cp, char **endp, unsigned int base);
|
||||
#if defined(CONFIG_CMD_I2C)
|
||||
#if defined(CONFIG_CMD_I2C) && \
|
||||
(!defined(CONFIG_DM_I2C) || defined(CONFIG_DM_I2C_COMPAT))
|
||||
int i2c_write (uchar, uint, int , uchar* , int);
|
||||
int i2c_read (uchar, uint, int , uchar* , int);
|
||||
#endif
|
||||
@@ -34,15 +37,14 @@ void app_startup(char * const *);
|
||||
|
||||
#endif /* ifndef __ASSEMBLY__ */
|
||||
|
||||
enum {
|
||||
#define EXPORT_FUNC(x) XF_ ## x ,
|
||||
struct jt_funcs {
|
||||
#define EXPORT_FUNC(impl, res, func, ...) res(*func)(__VA_ARGS__);
|
||||
#include <_exports.h>
|
||||
#undef EXPORT_FUNC
|
||||
|
||||
XF_MAX
|
||||
};
|
||||
|
||||
#define XF_VERSION 6
|
||||
|
||||
#define XF_VERSION 7
|
||||
|
||||
#if defined(CONFIG_X86)
|
||||
extern gd_t *global_data;
|
||||
|
||||
123
include/fdtdec.h
123
include/fdtdec.h
@@ -115,9 +115,6 @@ enum fdt_compat_id {
|
||||
COMPAT_NVIDIA_TEGRA20_USB, /* Tegra20 USB port */
|
||||
COMPAT_NVIDIA_TEGRA30_USB, /* Tegra30 USB port */
|
||||
COMPAT_NVIDIA_TEGRA114_USB, /* Tegra114 USB port */
|
||||
COMPAT_NVIDIA_TEGRA114_I2C, /* Tegra114 I2C w/single clock source */
|
||||
COMPAT_NVIDIA_TEGRA20_I2C, /* Tegra20 i2c */
|
||||
COMPAT_NVIDIA_TEGRA20_DVC, /* Tegra20 dvc (really just i2c) */
|
||||
COMPAT_NVIDIA_TEGRA20_EMC, /* Tegra20 memory controller */
|
||||
COMPAT_NVIDIA_TEGRA20_EMC_TABLE, /* Tegra20 memory timing table */
|
||||
COMPAT_NVIDIA_TEGRA20_KBC, /* Tegra20 Keyboard */
|
||||
@@ -127,9 +124,6 @@ enum fdt_compat_id {
|
||||
COMPAT_NVIDIA_TEGRA124_SDMMC, /* Tegra124 SDMMC controller */
|
||||
COMPAT_NVIDIA_TEGRA30_SDMMC, /* Tegra30 SDMMC controller */
|
||||
COMPAT_NVIDIA_TEGRA20_SDMMC, /* Tegra20 SDMMC controller */
|
||||
COMPAT_NVIDIA_TEGRA20_SFLASH, /* Tegra 2 SPI flash controller */
|
||||
COMPAT_NVIDIA_TEGRA20_SLINK, /* Tegra 2 SPI SLINK controller */
|
||||
COMPAT_NVIDIA_TEGRA114_SPI, /* Tegra 114 SPI controller */
|
||||
COMPAT_NVIDIA_TEGRA124_PCIE, /* Tegra 124 PCIe controller */
|
||||
COMPAT_NVIDIA_TEGRA30_PCIE, /* Tegra 30 PCIe controller */
|
||||
COMPAT_NVIDIA_TEGRA20_PCIE, /* Tegra 20 PCIe controller */
|
||||
@@ -140,7 +134,6 @@ enum fdt_compat_id {
|
||||
COMPAT_SAMSUNG_S3C2440_I2C, /* Exynos I2C Controller */
|
||||
COMPAT_SAMSUNG_EXYNOS5_SOUND, /* Exynos Sound */
|
||||
COMPAT_WOLFSON_WM8994_CODEC, /* Wolfson WM8994 Sound Codec */
|
||||
COMPAT_SAMSUNG_EXYNOS_SPI, /* Exynos SPI */
|
||||
COMPAT_GOOGLE_CROS_EC, /* Google CROS_EC Protocol */
|
||||
COMPAT_GOOGLE_CROS_EC_KEYB, /* Google CROS_EC Keyboard */
|
||||
COMPAT_SAMSUNG_EXYNOS_EHCI, /* Exynos EHCI controller */
|
||||
@@ -178,38 +171,58 @@ enum fdt_compat_id {
|
||||
COMPAT_COUNT,
|
||||
};
|
||||
|
||||
/* GPIOs are numbered from 0 */
|
||||
enum {
|
||||
FDT_GPIO_NONE = -1U, /* an invalid GPIO used to end our list */
|
||||
|
||||
FDT_GPIO_ACTIVE_LOW = 1 << 0, /* input is active low (else high) */
|
||||
#define MAX_PHANDLE_ARGS 16
|
||||
struct fdtdec_phandle_args {
|
||||
int node;
|
||||
int args_count;
|
||||
uint32_t args[MAX_PHANDLE_ARGS];
|
||||
};
|
||||
|
||||
/* This is the state of a GPIO pin as defined by the fdt */
|
||||
struct fdt_gpio_state {
|
||||
const char *name; /* name of the fdt property defining this */
|
||||
uint gpio; /* GPIO number, or FDT_GPIO_NONE if none */
|
||||
u8 flags; /* FDT_GPIO_... flags */
|
||||
};
|
||||
|
||||
/* This tells us whether a fdt_gpio_state record is valid or not */
|
||||
#define fdt_gpio_isvalid(x) ((x)->gpio != FDT_GPIO_NONE)
|
||||
|
||||
/**
|
||||
* Read the GPIO taking into account the polarity of the pin.
|
||||
* fdtdec_parse_phandle_with_args() - Find a node pointed by phandle in a list
|
||||
*
|
||||
* @param gpio pointer to the decoded gpio
|
||||
* @return value of the gpio if successful, < 0 if unsuccessful
|
||||
*/
|
||||
int fdtdec_get_gpio(struct fdt_gpio_state *gpio);
|
||||
|
||||
/**
|
||||
* Write the GPIO taking into account the polarity of the pin.
|
||||
* This function is useful to parse lists of phandles and their arguments.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* phandle1: node1 {
|
||||
* #list-cells = <2>;
|
||||
* }
|
||||
*
|
||||
* phandle2: node2 {
|
||||
* #list-cells = <1>;
|
||||
* }
|
||||
*
|
||||
* node3 {
|
||||
* list = <&phandle1 1 2 &phandle2 3>;
|
||||
* }
|
||||
*
|
||||
* To get a device_node of the `node2' node you may call this:
|
||||
* fdtdec_parse_phandle_with_args(blob, node3, "list", "#list-cells", 0, 1,
|
||||
* &args);
|
||||
*
|
||||
* (This function is a modified version of __of_parse_phandle_with_args() from
|
||||
* Linux 3.18)
|
||||
*
|
||||
* @blob: Pointer to device tree
|
||||
* @src_node: Offset of device tree node containing a list
|
||||
* @list_name: property name that contains a list
|
||||
* @cells_name: property name that specifies the phandles' arguments count,
|
||||
* or NULL to use @cells_count
|
||||
* @cells_count: Cell count to use if @cells_name is NULL
|
||||
* @index: index of a phandle to parse out
|
||||
* @out_args: optional pointer to output arguments structure (will be filled)
|
||||
* @return 0 on success (with @out_args filled out if not NULL), -ENOENT if
|
||||
* @list_name does not exist, a phandle was not found, @cells_name
|
||||
* could not be found, the arguments were truncated or there were too
|
||||
* many arguments.
|
||||
*
|
||||
* @param gpio pointer to the decoded gpio
|
||||
* @return 0 if successful
|
||||
*/
|
||||
int fdtdec_set_gpio(struct fdt_gpio_state *gpio, int val);
|
||||
int fdtdec_parse_phandle_with_args(const void *blob, int src_node,
|
||||
const char *list_name,
|
||||
const char *cells_name,
|
||||
int cell_count, int index,
|
||||
struct fdtdec_phandle_args *out_args);
|
||||
|
||||
/**
|
||||
* Find the next numbered alias for a peripheral. This is used to enumerate
|
||||
@@ -591,50 +604,6 @@ const u32 *fdtdec_locate_array(const void *blob, int node,
|
||||
*/
|
||||
int fdtdec_get_bool(const void *blob, int node, const char *prop_name);
|
||||
|
||||
/**
|
||||
* Decode a single GPIOs from an FDT.
|
||||
*
|
||||
* If the property is not found, then the GPIO structure will still be
|
||||
* initialised, with gpio set to FDT_GPIO_NONE. This makes it easy to
|
||||
* provide optional GPIOs.
|
||||
*
|
||||
* @param blob FDT blob to use
|
||||
* @param node Node to look at
|
||||
* @param prop_name Node property name
|
||||
* @param gpio gpio elements to fill from FDT
|
||||
* @return 0 if ok, -FDT_ERR_NOTFOUND if the property is missing.
|
||||
*/
|
||||
int fdtdec_decode_gpio(const void *blob, int node, const char *prop_name,
|
||||
struct fdt_gpio_state *gpio);
|
||||
|
||||
/**
|
||||
* Decode a list of GPIOs from an FDT. This creates a list of GPIOs with no
|
||||
* terminating item.
|
||||
*
|
||||
* @param blob FDT blob to use
|
||||
* @param node Node to look at
|
||||
* @param prop_name Node property name
|
||||
* @param gpio Array of gpio elements to fill from FDT. This will be
|
||||
* untouched if either 0 or an error is returned
|
||||
* @param max_count Maximum number of elements allowed
|
||||
* @return number of GPIOs read if ok, -FDT_ERR_BADLAYOUT if max_count would
|
||||
* be exceeded, or -FDT_ERR_NOTFOUND if the property is missing.
|
||||
*/
|
||||
int fdtdec_decode_gpios(const void *blob, int node, const char *prop_name,
|
||||
struct fdt_gpio_state *gpio, int max_count);
|
||||
|
||||
/**
|
||||
* Set up a GPIO pin according to the provided gpio information. At present this
|
||||
* just requests the GPIO.
|
||||
*
|
||||
* If the gpio is FDT_GPIO_NONE, no action is taken. This makes it easy to
|
||||
* deal with optional GPIOs.
|
||||
*
|
||||
* @param gpio GPIO info to use for set up
|
||||
* @return 0 if all ok or gpio was FDT_GPIO_NONE; -1 on error
|
||||
*/
|
||||
int fdtdec_setup_gpio(struct fdt_gpio_state *gpio);
|
||||
|
||||
/**
|
||||
* Look in the FDT for a config item with the given name and return its value
|
||||
* as a 32-bit integer. The property must have at least 4 bytes of data. The
|
||||
|
||||
@@ -17,7 +17,6 @@ enum {
|
||||
HASH_FLAG_ENV = 1 << 1, /* Allow env vars */
|
||||
};
|
||||
|
||||
#ifndef USE_HOSTCC
|
||||
#if defined(CONFIG_SHA1SUM_VERIFY) || defined(CONFIG_CRC32_VERIFY)
|
||||
#define CONFIG_HASH_VERIFY
|
||||
#endif
|
||||
@@ -77,6 +76,7 @@ struct hash_algo {
|
||||
int size);
|
||||
};
|
||||
|
||||
#ifndef USE_HOSTCC
|
||||
/**
|
||||
* hash_command: Process a hash command for a particular algorithm
|
||||
*
|
||||
@@ -114,19 +114,6 @@ int hash_command(const char *algo_name, int flags, cmd_tbl_t *cmdtp, int flag,
|
||||
int hash_block(const char *algo_name, const void *data, unsigned int len,
|
||||
uint8_t *output, int *output_size);
|
||||
|
||||
/**
|
||||
* hash_lookup_algo() - Look up the hash_algo struct for an algorithm
|
||||
*
|
||||
* The function returns the pointer to the struct or -EPROTONOSUPPORT if the
|
||||
* algorithm is not available.
|
||||
*
|
||||
* @algo_name: Hash algorithm to look up
|
||||
* @algop: Pointer to the hash_algo struct if found
|
||||
*
|
||||
* @return 0 if ok, -EPROTONOSUPPORT for an unknown algorithm.
|
||||
*/
|
||||
int hash_lookup_algo(const char *algo_name, struct hash_algo **algop);
|
||||
|
||||
/**
|
||||
* hash_show() - Print out a hash algorithm and value
|
||||
*
|
||||
@@ -141,5 +128,34 @@ int hash_lookup_algo(const char *algo_name, struct hash_algo **algop);
|
||||
*/
|
||||
void hash_show(struct hash_algo *algo, ulong addr, ulong len,
|
||||
uint8_t *output);
|
||||
|
||||
#endif /* !USE_HOSTCC */
|
||||
|
||||
/**
|
||||
* hash_lookup_algo() - Look up the hash_algo struct for an algorithm
|
||||
*
|
||||
* The function returns the pointer to the struct or -EPROTONOSUPPORT if the
|
||||
* algorithm is not available.
|
||||
*
|
||||
* @algo_name: Hash algorithm to look up
|
||||
* @algop: Pointer to the hash_algo struct if found
|
||||
*
|
||||
* @return 0 if ok, -EPROTONOSUPPORT for an unknown algorithm.
|
||||
*/
|
||||
int hash_lookup_algo(const char *algo_name, struct hash_algo **algop);
|
||||
|
||||
/**
|
||||
* hash_progressive_lookup_algo() - Look up hash_algo for prog. hash support
|
||||
*
|
||||
* The function returns the pointer to the struct or -EPROTONOSUPPORT if the
|
||||
* algorithm is not available with progressive hash support.
|
||||
*
|
||||
* @algo_name: Hash algorithm to look up
|
||||
* @algop: Pointer to the hash_algo struct if found
|
||||
*
|
||||
* @return 0 if ok, -EPROTONOSUPPORT for an unknown algorithm.
|
||||
*/
|
||||
int hash_progressive_lookup_algo(const char *algo_name,
|
||||
struct hash_algo **algop);
|
||||
|
||||
#endif
|
||||
|
||||
105
include/i2c.h
105
include/i2c.h
@@ -39,8 +39,8 @@ enum dm_i2c_chip_flags {
|
||||
* An I2C chip is a device on the I2C bus. It sits at a particular address
|
||||
* and normally supports 7-bit or 10-bit addressing.
|
||||
*
|
||||
* To obtain this structure, use dev_get_parentdata(dev) where dev is the
|
||||
* chip to examine.
|
||||
* To obtain this structure, use dev_get_parent_platdata(dev) where dev is
|
||||
* the chip to examine.
|
||||
*
|
||||
* @chip_addr: Chip address on bus
|
||||
* @offset_len: Length of offset in bytes. A single byte offset can
|
||||
@@ -75,7 +75,7 @@ struct dm_i2c_bus {
|
||||
};
|
||||
|
||||
/**
|
||||
* i2c_read() - read bytes from an I2C chip
|
||||
* dm_i2c_read() - read bytes from an I2C chip
|
||||
*
|
||||
* To obtain an I2C device (called a 'chip') given the I2C bus address you
|
||||
* can use i2c_get_chip(). To obtain a bus by bus number use
|
||||
@@ -91,13 +91,12 @@ struct dm_i2c_bus {
|
||||
*
|
||||
* @return 0 on success, -ve on failure
|
||||
*/
|
||||
int i2c_read(struct udevice *dev, uint offset, uint8_t *buffer,
|
||||
int len);
|
||||
int dm_i2c_read(struct udevice *dev, uint offset, uint8_t *buffer, int len);
|
||||
|
||||
/**
|
||||
* i2c_write() - write bytes to an I2C chip
|
||||
* dm_i2c_write() - write bytes to an I2C chip
|
||||
*
|
||||
* See notes for i2c_read() above.
|
||||
* See notes for dm_i2c_read() above.
|
||||
*
|
||||
* @dev: Chip to write to
|
||||
* @offset: Offset within chip to start writing
|
||||
@@ -106,11 +105,11 @@ int i2c_read(struct udevice *dev, uint offset, uint8_t *buffer,
|
||||
*
|
||||
* @return 0 on success, -ve on failure
|
||||
*/
|
||||
int i2c_write(struct udevice *dev, uint offset, const uint8_t *buffer,
|
||||
int len);
|
||||
int dm_i2c_write(struct udevice *dev, uint offset, const uint8_t *buffer,
|
||||
int len);
|
||||
|
||||
/**
|
||||
* i2c_probe() - probe a particular chip address
|
||||
* dm_i2c_probe() - probe a particular chip address
|
||||
*
|
||||
* This can be useful to check for the existence of a chip on the bus.
|
||||
* It is typically implemented by writing the chip address to the bus
|
||||
@@ -122,8 +121,8 @@ int i2c_write(struct udevice *dev, uint offset, const uint8_t *buffer,
|
||||
* @devp: Returns the device found, or NULL if none
|
||||
* @return 0 if a chip was found at that address, -ve if not
|
||||
*/
|
||||
int i2c_probe(struct udevice *bus, uint chip_addr, uint chip_flags,
|
||||
struct udevice **devp);
|
||||
int dm_i2c_probe(struct udevice *bus, uint chip_addr, uint chip_flags,
|
||||
struct udevice **devp);
|
||||
|
||||
/**
|
||||
* i2c_set_bus_speed() - set the speed of a bus
|
||||
@@ -185,6 +184,80 @@ int i2c_set_chip_offset_len(struct udevice *dev, uint offset_len);
|
||||
*/
|
||||
int i2c_deblock(struct udevice *bus);
|
||||
|
||||
#ifdef CONFIG_DM_I2C_COMPAT
|
||||
/**
|
||||
* i2c_probe() - Compatibility function for driver model
|
||||
*
|
||||
* Calls dm_i2c_probe() on the current bus
|
||||
*/
|
||||
int i2c_probe(uint8_t chip_addr);
|
||||
|
||||
/**
|
||||
* i2c_read() - Compatibility function for driver model
|
||||
*
|
||||
* Calls dm_i2c_read() with the device corresponding to @chip_addr, and offset
|
||||
* set to @addr. @alen must match the current setting for the device.
|
||||
*/
|
||||
int i2c_read(uint8_t chip_addr, unsigned int addr, int alen, uint8_t *buffer,
|
||||
int len);
|
||||
|
||||
/**
|
||||
* i2c_write() - Compatibility function for driver model
|
||||
*
|
||||
* Calls dm_i2c_write() with the device corresponding to @chip_addr, and offset
|
||||
* set to @addr. @alen must match the current setting for the device.
|
||||
*/
|
||||
int i2c_write(uint8_t chip_addr, unsigned int addr, int alen, uint8_t *buffer,
|
||||
int len);
|
||||
|
||||
/**
|
||||
* i2c_get_bus_num_fdt() - Compatibility function for driver model
|
||||
*
|
||||
* @return the bus number associated with the given device tree node
|
||||
*/
|
||||
int i2c_get_bus_num_fdt(int node);
|
||||
|
||||
/**
|
||||
* i2c_get_bus_num() - Compatibility function for driver model
|
||||
*
|
||||
* @return the 'current' bus number
|
||||
*/
|
||||
unsigned int i2c_get_bus_num(void);
|
||||
|
||||
/**
|
||||
* i2c_set_bus_num() - Compatibility function for driver model
|
||||
*
|
||||
* Sets the 'current' bus
|
||||
*/
|
||||
int i2c_set_bus_num(unsigned int bus);
|
||||
|
||||
static inline void I2C_SET_BUS(unsigned int bus)
|
||||
{
|
||||
i2c_set_bus_num(bus);
|
||||
}
|
||||
|
||||
static inline unsigned int I2C_GET_BUS(void)
|
||||
{
|
||||
return i2c_get_bus_num();
|
||||
}
|
||||
|
||||
/**
|
||||
* i2c_init() - Compatibility function for driver model
|
||||
*
|
||||
* This function does nothing.
|
||||
*/
|
||||
void i2c_init(int speed, int slaveaddr);
|
||||
|
||||
/**
|
||||
* board_i2c_init() - Compatibility function for driver model
|
||||
*
|
||||
* @param blob Device tree blbo
|
||||
* @return the number of I2C bus
|
||||
*/
|
||||
void board_i2c_init(const void *blob);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Not all of these flags are implemented in the U-Boot API
|
||||
*/
|
||||
@@ -330,10 +403,12 @@ struct dm_i2c_ops {
|
||||
*
|
||||
* @bus: Bus to examine
|
||||
* @chip_addr: Chip address for the new device
|
||||
* @offset_len: Length of a register offset in bytes (normally 1)
|
||||
* @devp: Returns pointer to new device if found or -ENODEV if not
|
||||
* found
|
||||
*/
|
||||
int i2c_get_chip(struct udevice *bus, uint chip_addr, struct udevice **devp);
|
||||
int i2c_get_chip(struct udevice *bus, uint chip_addr, uint offset_len,
|
||||
struct udevice **devp);
|
||||
|
||||
/**
|
||||
* i2c_get_chip() - get a device to use to access a chip on a bus number
|
||||
@@ -343,10 +418,12 @@ int i2c_get_chip(struct udevice *bus, uint chip_addr, struct udevice **devp);
|
||||
*
|
||||
* @busnum: Bus number to examine
|
||||
* @chip_addr: Chip address for the new device
|
||||
* @offset_len: Length of a register offset in bytes (normally 1)
|
||||
* @devp: Returns pointer to new device if found or -ENODEV if not
|
||||
* found
|
||||
*/
|
||||
int i2c_get_chip_for_busnum(int busnum, int chip_addr, struct udevice **devp);
|
||||
int i2c_get_chip_for_busnum(int busnum, int chip_addr, uint offset_len,
|
||||
struct udevice **devp);
|
||||
|
||||
/**
|
||||
* i2c_chip_ofdata_to_platdata() - Decode standard I2C platform data
|
||||
|
||||
@@ -928,8 +928,9 @@ struct checksum_algo {
|
||||
#if IMAGE_ENABLE_SIGN
|
||||
const EVP_MD *(*calculate_sign)(void);
|
||||
#endif
|
||||
void (*calculate)(const struct image_region region[],
|
||||
int region_count, uint8_t *checksum);
|
||||
int (*calculate)(const char *name,
|
||||
const struct image_region region[],
|
||||
int region_count, uint8_t *checksum);
|
||||
const uint8_t *rsa_padding;
|
||||
};
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
#include <asm/io.h>
|
||||
#include <mmc.h>
|
||||
#include <fdtdec.h>
|
||||
#include <asm/gpio.h>
|
||||
|
||||
/*
|
||||
* Controller registers
|
||||
@@ -246,8 +246,8 @@ struct sdhci_host {
|
||||
int index;
|
||||
|
||||
int bus_width;
|
||||
struct fdt_gpio_state pwr_gpio; /* Power GPIO */
|
||||
struct fdt_gpio_state cd_gpio; /* Card Detect GPIO */
|
||||
struct gpio_desc pwr_gpio; /* Power GPIO */
|
||||
struct gpio_desc cd_gpio; /* Card Detect GPIO */
|
||||
|
||||
void (*set_control_reg)(struct sdhci_host *host);
|
||||
void (*set_clock)(int dev_index, unsigned int div);
|
||||
|
||||
@@ -56,20 +56,42 @@
|
||||
#define SPI_DEFAULT_WORDLEN 8
|
||||
|
||||
#ifdef CONFIG_DM_SPI
|
||||
/* TODO(sjg@chromium.org): Remove this and use max_hz from struct spi_slave */
|
||||
struct dm_spi_bus {
|
||||
uint max_hz;
|
||||
};
|
||||
|
||||
/**
|
||||
* struct dm_spi_platdata - platform data for all SPI slaves
|
||||
*
|
||||
* This describes a SPI slave, a child device of the SPI bus. To obtain this
|
||||
* struct from a spi_slave, use dev_get_parent_platdata(dev) or
|
||||
* dev_get_parent_platdata(slave->dev).
|
||||
*
|
||||
* This data is immuatable. Each time the device is probed, @max_hz and @mode
|
||||
* will be copied to struct spi_slave.
|
||||
*
|
||||
* @cs: Chip select number (0..n-1)
|
||||
* @max_hz: Maximum bus speed that this slave can tolerate
|
||||
* @mode: SPI mode to use for this device (see SPI mode flags)
|
||||
*/
|
||||
struct dm_spi_slave_platdata {
|
||||
unsigned int cs;
|
||||
uint max_hz;
|
||||
uint mode;
|
||||
};
|
||||
|
||||
#endif /* CONFIG_DM_SPI */
|
||||
|
||||
/**
|
||||
* struct spi_slave - Representation of a SPI slave
|
||||
*
|
||||
* 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. Each SPI
|
||||
* driver should define this child data in its U_BOOT_DRIVER() definition:
|
||||
*
|
||||
* .per_child_auto_alloc_size = sizeof(struct spi_slave),
|
||||
* be accessed using dev_get_parentdata() on the slave device. The SPI uclass
|
||||
* 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)
|
||||
* are copied into this structure to provide an initial value. This allows
|
||||
* them to be changed, since we should never change platform data in drivers.
|
||||
*
|
||||
* If not using driver model, drivers are expected to extend this with
|
||||
* controller-specific data.
|
||||
@@ -97,8 +119,8 @@ struct spi_slave {
|
||||
uint mode;
|
||||
#else
|
||||
unsigned int bus;
|
||||
#endif
|
||||
unsigned int cs;
|
||||
#endif
|
||||
u8 op_mode_rx;
|
||||
u8 op_mode_tx;
|
||||
unsigned int wordlen;
|
||||
@@ -545,16 +567,16 @@ int spi_chip_select(struct udevice *slave);
|
||||
int spi_find_chip_select(struct udevice *bus, int cs, struct udevice **devp);
|
||||
|
||||
/**
|
||||
* spi_ofdata_to_platdata() - decode standard SPI platform data
|
||||
* spi_slave_ofdata_to_platdata() - decode standard SPI platform data
|
||||
*
|
||||
* This decodes the speed and mode from a device tree node and puts it into
|
||||
* the spi_slave structure.
|
||||
* This decodes the speed and mode for a slave from a device tree node
|
||||
*
|
||||
* @blob: Device tree blob
|
||||
* @node: Node offset to read from
|
||||
* @spi: Place to put the decoded information
|
||||
* @plat: Place to put the decoded information
|
||||
*/
|
||||
int spi_ofdata_to_platdata(const void *blob, int node, struct spi_slave *spi);
|
||||
int spi_slave_ofdata_to_platdata(const void *blob, int node,
|
||||
struct dm_spi_slave_platdata *plat);
|
||||
|
||||
/**
|
||||
* spi_cs_info() - Check information on a chip select
|
||||
|
||||
@@ -16,9 +16,18 @@ extern const uint8_t padding_sha256_rsa4096[];
|
||||
extern const uint8_t padding_sha256_rsa2048[];
|
||||
extern const uint8_t padding_sha1_rsa2048[];
|
||||
|
||||
void sha256_calculate(const struct image_region region[], int region_count,
|
||||
uint8_t *checksum);
|
||||
void sha1_calculate(const struct image_region region[], int region_count,
|
||||
uint8_t *checksum);
|
||||
/**
|
||||
* hash_calculate() - Calculate hash over the data
|
||||
*
|
||||
* @name: Name of algorithm to be used for hash calculation
|
||||
* @region: Array having info of regions over which hash needs to be calculated
|
||||
* @region_count: Number of regions in the region array
|
||||
* @checksum: Buffer contanining the output hash
|
||||
*
|
||||
* @return 0 if OK, < 0 if error
|
||||
*/
|
||||
int hash_calculate(const char *name,
|
||||
const struct image_region region[], int region_count,
|
||||
uint8_t *checksum);
|
||||
|
||||
#endif
|
||||
|
||||
75
include/u-boot/rsa-mod-exp.h
Normal file
75
include/u-boot/rsa-mod-exp.h
Normal file
@@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Ruchika Gupta.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
|
||||
#ifndef _RSA_MOD_EXP_H
|
||||
#define _RSA_MOD_EXP_H
|
||||
|
||||
#include <errno.h>
|
||||
#include <image.h>
|
||||
|
||||
/**
|
||||
* struct key_prop - holder for a public key properties
|
||||
*
|
||||
* The struct has pointers to modulus (Typically called N),
|
||||
* The inverse, R^2, exponent. These can be typecasted and
|
||||
* used as byte arrays or converted to the required format
|
||||
* as per requirement of RSA implementation.
|
||||
*/
|
||||
struct key_prop {
|
||||
const void *rr; /* R^2 can be treated as byte array */
|
||||
const void *modulus; /* modulus as byte array */
|
||||
const void *public_exponent; /* public exponent as byte array */
|
||||
uint32_t n0inv; /* -1 / modulus[0] mod 2^32 */
|
||||
int num_bits; /* Key length in bits */
|
||||
uint32_t exp_len; /* Exponent length in number of uint8_t */
|
||||
};
|
||||
|
||||
/**
|
||||
* rsa_mod_exp_sw() - Perform RSA Modular Exponentiation in sw
|
||||
*
|
||||
* Operation: out[] = sig ^ exponent % modulus
|
||||
*
|
||||
* @sig: RSA PKCS1.5 signature
|
||||
* @sig_len: Length of signature in number of bytes
|
||||
* @node: Node with RSA key elements like modulus, exponent, R^2, n0inv
|
||||
* @out: Result in form of byte array of len equal to sig_len
|
||||
*/
|
||||
int rsa_mod_exp_sw(const uint8_t *sig, uint32_t sig_len,
|
||||
struct key_prop *node, uint8_t *out);
|
||||
|
||||
int rsa_mod_exp(struct udevice *dev, const uint8_t *sig, uint32_t sig_len,
|
||||
struct key_prop *node, uint8_t *out);
|
||||
|
||||
/**
|
||||
* struct struct mod_exp_ops - Driver model for RSA Modular Exponentiation
|
||||
* operations
|
||||
*
|
||||
* The uclass interface is implemented by all crypto devices which use
|
||||
* driver model.
|
||||
*/
|
||||
struct mod_exp_ops {
|
||||
/**
|
||||
* Perform Modular Exponentiation
|
||||
*
|
||||
* Operation: out[] = sig ^ exponent % modulus
|
||||
*
|
||||
* @dev: RSA Device
|
||||
* @sig: RSA PKCS1.5 signature
|
||||
* @sig_len: Length of signature in number of bytes
|
||||
* @node: Node with RSA key elements like modulus, exponent,
|
||||
* R^2, n0inv
|
||||
* @out: Result in form of byte array of len equal to sig_len
|
||||
*
|
||||
* This function computes exponentiation over the signature.
|
||||
* Returns: 0 if exponentiation is successful, or a negative value
|
||||
* if it wasn't.
|
||||
*/
|
||||
int (*mod_exp)(struct udevice *dev, const uint8_t *sig,
|
||||
uint32_t sig_len, struct key_prop *node,
|
||||
uint8_t *outp);
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user