Merge git://git.denx.de/u-boot-dm
This commit is contained in:
@@ -10,14 +10,12 @@
|
||||
#ifndef _BCD_H
|
||||
#define _BCD_H
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
static inline unsigned int bcd2bin(u8 val)
|
||||
static inline unsigned int bcd2bin(unsigned int val)
|
||||
{
|
||||
return ((val) & 0x0f) + ((val) >> 4) * 10;
|
||||
return ((val) & 0x0f) + ((val & 0xff) >> 4) * 10;
|
||||
}
|
||||
|
||||
static inline u8 bin2bcd (unsigned int val)
|
||||
static inline unsigned int bin2bcd(unsigned int val)
|
||||
{
|
||||
return (((val / 10) << 4) | (val % 10));
|
||||
}
|
||||
|
||||
@@ -125,6 +125,8 @@
|
||||
func(HOST, host, 1) \
|
||||
func(HOST, host, 0)
|
||||
|
||||
#define CONFIG_BOOTCOMMAND ""
|
||||
|
||||
#include <config_distro_bootcmd.h>
|
||||
|
||||
#define CONFIG_KEEP_SERVERADDR
|
||||
@@ -207,5 +209,6 @@
|
||||
|
||||
#define CONFIG_CMD_LZMADEC
|
||||
#define CONFIG_CMD_USB
|
||||
#define CONFIG_CMD_DATE
|
||||
|
||||
#endif
|
||||
|
||||
@@ -46,6 +46,7 @@ enum uclass_id {
|
||||
UCLASS_USB_DEV_GENERIC, /* USB generic device */
|
||||
UCLASS_MASS_STORAGE, /* Mass storage device */
|
||||
UCLASS_CPU, /* CPU, typically part of an SoC */
|
||||
UCLASS_RTC, /* Real time clock device */
|
||||
|
||||
UCLASS_COUNT,
|
||||
UCLASS_INVALID = -1,
|
||||
|
||||
@@ -145,8 +145,6 @@ enum fdt_compat_id {
|
||||
COMPAT_SAMSUNG_EXYNOS5_SOUND, /* Exynos Sound */
|
||||
COMPAT_WOLFSON_WM8994_CODEC, /* Wolfson WM8994 Sound Codec */
|
||||
COMPAT_GOOGLE_CROS_EC_KEYB, /* Google CROS_EC Keyboard */
|
||||
COMPAT_SAMSUNG_EXYNOS_EHCI, /* Exynos EHCI controller */
|
||||
COMPAT_SAMSUNG_EXYNOS5_XHCI, /* Exynos5 XHCI controller */
|
||||
COMPAT_SAMSUNG_EXYNOS_USB_PHY, /* Exynos phy controller for usb2.0 */
|
||||
COMPAT_SAMSUNG_EXYNOS5_USB3_PHY,/* Exynos phy controller for usb3.0 */
|
||||
COMPAT_SAMSUNG_EXYNOS_TMU, /* Exynos TMU */
|
||||
|
||||
@@ -54,6 +54,7 @@ struct dm_i2c_chip {
|
||||
uint flags;
|
||||
#ifdef CONFIG_SANDBOX
|
||||
struct udevice *emul;
|
||||
bool test_mode;
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -123,6 +124,27 @@ int dm_i2c_write(struct udevice *dev, uint offset, const uint8_t *buffer,
|
||||
int dm_i2c_probe(struct udevice *bus, uint chip_addr, uint chip_flags,
|
||||
struct udevice **devp);
|
||||
|
||||
/**
|
||||
* dm_i2c_reg_read() - Read a value from an I2C register
|
||||
*
|
||||
* This reads a single value from the given address in an I2C chip
|
||||
*
|
||||
* @addr: Address to read from
|
||||
* @return value read, or -ve on error
|
||||
*/
|
||||
int dm_i2c_reg_read(struct udevice *dev, uint offset);
|
||||
|
||||
/**
|
||||
* dm_i2c_reg_write() - Write a value to an I2C register
|
||||
*
|
||||
* This writes a single value to the given address in an I2C chip
|
||||
*
|
||||
* @addr: Address to write to
|
||||
* @val: Value to write (normally a byte)
|
||||
* @return 0 on success, -ve on error
|
||||
*/
|
||||
int dm_i2c_reg_write(struct udevice *dev, uint offset, unsigned int val);
|
||||
|
||||
/**
|
||||
* dm_i2c_set_bus_speed() - set the speed of a bus
|
||||
*
|
||||
|
||||
11
include/os.h
11
include/os.h
@@ -13,6 +13,7 @@
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
struct rtc_time;
|
||||
struct sandbox_state;
|
||||
|
||||
/**
|
||||
@@ -277,4 +278,14 @@ int os_read_ram_buf(const char *fname);
|
||||
*/
|
||||
int os_jump_to_image(const void *dest, int size);
|
||||
|
||||
/**
|
||||
* Read the current system time
|
||||
*
|
||||
* This reads the current Local Time and places it into the provided
|
||||
* structure.
|
||||
*
|
||||
* @param rt Place to put system time
|
||||
*/
|
||||
void os_localtime(struct rtc_time *rt);
|
||||
|
||||
#endif
|
||||
|
||||
195
include/rtc.h
195
include/rtc.h
@@ -15,41 +15,143 @@
|
||||
* it there instead of in evey single driver */
|
||||
|
||||
#include <bcd.h>
|
||||
#include <rtc_def.h>
|
||||
|
||||
/*
|
||||
* The struct used to pass data from the generic interface code to
|
||||
* the hardware dependend low-level code ande vice versa. Identical
|
||||
* to struct rtc_time used by the Linux kernel.
|
||||
*
|
||||
* Note that there are small but significant differences to the
|
||||
* common "struct time":
|
||||
*
|
||||
* struct time: struct rtc_time:
|
||||
* tm_mon 0 ... 11 1 ... 12
|
||||
* tm_year years since 1900 years since 0
|
||||
*/
|
||||
#ifdef CONFIG_DM_RTC
|
||||
|
||||
struct rtc_time {
|
||||
int tm_sec;
|
||||
int tm_min;
|
||||
int tm_hour;
|
||||
int tm_mday;
|
||||
int tm_mon;
|
||||
int tm_year;
|
||||
int tm_wday;
|
||||
int tm_yday;
|
||||
int tm_isdst;
|
||||
struct rtc_ops {
|
||||
/**
|
||||
* get() - get the current time
|
||||
*
|
||||
* Returns the current time read from the RTC device. The driver
|
||||
* is responsible for setting up every field in the structure.
|
||||
*
|
||||
* @dev: Device to read from
|
||||
* @time: Place to put the time that is read
|
||||
*/
|
||||
int (*get)(struct udevice *dev, struct rtc_time *time);
|
||||
|
||||
/**
|
||||
* set() - set the current time
|
||||
*
|
||||
* Sets the time in the RTC device. The driver can expect every
|
||||
* field to be set correctly.
|
||||
*
|
||||
* @dev: Device to read from
|
||||
* @time: Time to write
|
||||
*/
|
||||
int (*set)(struct udevice *dev, const struct rtc_time *time);
|
||||
|
||||
/**
|
||||
* reset() - reset the RTC to a known-good state
|
||||
*
|
||||
* This function resets the RTC to a known-good state. The time may
|
||||
* be unset by this method, so should be set after this method is
|
||||
* called.
|
||||
*
|
||||
* @dev: Device to read from
|
||||
* @return 0 if OK, -ve on error
|
||||
*/
|
||||
int (*reset)(struct udevice *dev);
|
||||
|
||||
/**
|
||||
* read8() - Read an 8-bit register
|
||||
*
|
||||
* @dev: Device to read from
|
||||
* @reg: Register to read
|
||||
* @return value read, or -ve on error
|
||||
*/
|
||||
int (*read8)(struct udevice *dev, unsigned int reg);
|
||||
|
||||
/**
|
||||
* write8() - Write an 8-bit register
|
||||
*
|
||||
* @dev: Device to write to
|
||||
* @reg: Register to write
|
||||
* @value: Value to write
|
||||
* @return 0 if OK, -ve on error
|
||||
*/
|
||||
int (*write8)(struct udevice *dev, unsigned int reg, int val);
|
||||
};
|
||||
|
||||
/* Access the operations for an RTC device */
|
||||
#define rtc_get_ops(dev) ((struct rtc_ops *)(dev)->driver->ops)
|
||||
|
||||
/**
|
||||
* dm_rtc_get() - Read the time from an RTC
|
||||
*
|
||||
* @dev: Device to read from
|
||||
* @time: Place to put the current time
|
||||
* @return 0 if OK, -ve on error
|
||||
*/
|
||||
int dm_rtc_get(struct udevice *dev, struct rtc_time *time);
|
||||
|
||||
/**
|
||||
* dm_rtc_put() - Write a time to an RTC
|
||||
*
|
||||
* @dev: Device to read from
|
||||
* @time: Time to write into the RTC
|
||||
* @return 0 if OK, -ve on error
|
||||
*/
|
||||
int dm_rtc_set(struct udevice *dev, struct rtc_time *time);
|
||||
|
||||
/**
|
||||
* dm_rtc_reset() - reset the RTC to a known-good state
|
||||
*
|
||||
* If the RTC appears to be broken (e.g. it is not counting up in seconds)
|
||||
* it may need to be reset to a known good state. This function achieves this.
|
||||
* After resetting the RTC the time should then be set to a known value by
|
||||
* the caller.
|
||||
*
|
||||
* @dev: Device to read from
|
||||
* @return 0 if OK, -ve on error
|
||||
*/
|
||||
int dm_rtc_reset(struct udevice *dev);
|
||||
|
||||
/**
|
||||
* rtc_read8() - Read an 8-bit register
|
||||
*
|
||||
* @dev: Device to read from
|
||||
* @reg: Register to read
|
||||
* @return value read, or -ve on error
|
||||
*/
|
||||
int rtc_read8(struct udevice *dev, unsigned int reg);
|
||||
|
||||
/**
|
||||
* rtc_write8() - Write an 8-bit register
|
||||
*
|
||||
* @dev: Device to write to
|
||||
* @reg: Register to write
|
||||
* @value: Value to write
|
||||
* @return 0 if OK, -ve on error
|
||||
*/
|
||||
int rtc_write8(struct udevice *dev, unsigned int reg, int val);
|
||||
|
||||
/**
|
||||
* rtc_read32() - Read a 32-bit value from the RTC
|
||||
*
|
||||
* @dev: Device to read from
|
||||
* @reg: Offset to start reading from
|
||||
* @valuep: Place to put the value that is read
|
||||
* @return 0 if OK, -ve on error
|
||||
*/
|
||||
int rtc_read32(struct udevice *dev, unsigned int reg, u32 *valuep);
|
||||
|
||||
/**
|
||||
* rtc_write32() - Write a 32-bit value to the RTC
|
||||
*
|
||||
* @dev: Device to write to
|
||||
* @reg: Register to start writing to
|
||||
* @value: Value to write
|
||||
* @return 0 if OK, -ve on error
|
||||
*/
|
||||
int rtc_write32(struct udevice *dev, unsigned int reg, u32 value);
|
||||
|
||||
#else
|
||||
int rtc_get (struct rtc_time *);
|
||||
int rtc_set (struct rtc_time *);
|
||||
void rtc_reset (void);
|
||||
|
||||
void GregorianDay (struct rtc_time *);
|
||||
void to_tm (int, struct rtc_time *);
|
||||
unsigned long mktime (unsigned int, unsigned int, unsigned int,
|
||||
unsigned int, unsigned int, unsigned int);
|
||||
|
||||
/**
|
||||
* rtc_read8() - Read an 8-bit register
|
||||
*
|
||||
@@ -86,5 +188,44 @@ void rtc_write32(int reg, u32 value);
|
||||
* rtc_init() - Set up the real time clock ready for use
|
||||
*/
|
||||
void rtc_init(void);
|
||||
#endif
|
||||
|
||||
/**
|
||||
* rtc_calc_weekday() - Work out the weekday from a time
|
||||
*
|
||||
* This only works for the Gregorian calendar - i.e. after 1752 (in the UK).
|
||||
* It sets time->tm_wdaay to the correct day of the week.
|
||||
*
|
||||
* @time: Time to inspect. tm_wday is updated
|
||||
* @return 0 if OK, -EINVAL if the weekday could not be determined
|
||||
*/
|
||||
int rtc_calc_weekday(struct rtc_time *time);
|
||||
|
||||
/**
|
||||
* rtc_to_tm() - Convert a time_t value into a broken-out time
|
||||
*
|
||||
* The following fields are set up by this function:
|
||||
* tm_sec, tm_min, tm_hour, tm_mday, tm_mon, tm_year, tm_wday
|
||||
*
|
||||
* Note that tm_yday and tm_isdst are set to 0.
|
||||
*
|
||||
* @time_t: Number of seconds since 1970-01-01 00:00:00
|
||||
* @time: Place to put the broken-out time
|
||||
* @return 0 if OK, -EINVAL if the weekday could not be determined
|
||||
*/
|
||||
int rtc_to_tm(int time_t, struct rtc_time *time);
|
||||
|
||||
/**
|
||||
* rtc_mktime() - Convert a broken-out time into a time_t value
|
||||
*
|
||||
* The following fields need to be valid for this function to work:
|
||||
* tm_sec, tm_min, tm_hour, tm_mday, tm_mon, tm_year
|
||||
*
|
||||
* Note that tm_wday and tm_yday are ignored.
|
||||
*
|
||||
* @time: Broken-out time to convert
|
||||
* @return corresponding time_t value, seconds since 1970-01-01 00:00:00
|
||||
*/
|
||||
unsigned long rtc_mktime(const struct rtc_time *time);
|
||||
|
||||
#endif /* _RTC_H_ */
|
||||
|
||||
36
include/rtc_def.h
Normal file
36
include/rtc_def.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* (C) Copyright 2001
|
||||
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
|
||||
*
|
||||
* SPDX-License-Identifier: GPL-2.0+
|
||||
*/
|
||||
|
||||
#ifndef __rtc_def_h
|
||||
#define __rtc_def_h
|
||||
|
||||
/*
|
||||
* The struct used to pass data from the generic interface code to
|
||||
* the hardware dependend low-level code ande vice versa. Identical
|
||||
* to struct rtc_time used by the Linux kernel.
|
||||
*
|
||||
* Note that there are small but significant differences to the
|
||||
* common "struct time":
|
||||
*
|
||||
* struct time: struct rtc_time:
|
||||
* tm_mon 0 ... 11 1 ... 12
|
||||
* tm_year years since 1900 years since 0
|
||||
*/
|
||||
|
||||
struct rtc_time {
|
||||
int tm_sec;
|
||||
int tm_min;
|
||||
int tm_hour;
|
||||
int tm_mday;
|
||||
int tm_mon;
|
||||
int tm_year;
|
||||
int tm_wday;
|
||||
int tm_yday;
|
||||
int tm_isdst;
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -100,6 +100,8 @@ struct dm_spi_slave_platdata {
|
||||
* @dev: SPI slave device
|
||||
* @max_hz: Maximum speed for this slave
|
||||
* @mode: SPI mode to use for this slave (see SPI mode flags)
|
||||
* @speed: Current bus speed. This is 0 until the bus is first
|
||||
* claimed.
|
||||
* @bus: ID of the bus that the slave is attached to. For
|
||||
* driver model this is the sequence number of the SPI
|
||||
* bus (bus->seq) so does not need to be stored
|
||||
@@ -117,6 +119,7 @@ struct spi_slave {
|
||||
#ifdef CONFIG_DM_SPI
|
||||
struct udevice *dev; /* struct spi_slave is dev->parentdata */
|
||||
uint max_hz;
|
||||
uint speed;
|
||||
uint mode;
|
||||
#else
|
||||
unsigned int bus;
|
||||
@@ -613,7 +616,7 @@ int sandbox_spi_get_emul(struct sandbox_state *state,
|
||||
struct udevice *bus, struct udevice *slave,
|
||||
struct udevice **emulp);
|
||||
|
||||
/* Access the serial operations for a device */
|
||||
/* Access the operations for a SPI device */
|
||||
#define spi_get_ops(dev) ((struct dm_spi_ops *)(dev)->driver->ops)
|
||||
#define spi_emul_get_ops(dev) ((struct dm_spi_emul_ops *)(dev)->driver->ops)
|
||||
#endif /* CONFIG_DM_SPI */
|
||||
|
||||
@@ -571,20 +571,23 @@ struct usb_platdata {
|
||||
* This is used by sandbox to provide emulation data also.
|
||||
*
|
||||
* @id: ID used to match this device
|
||||
* @speed: Stores the speed associated with a USB device
|
||||
* @devnum: Device address on the USB bus
|
||||
* @slot_id: USB3 slot ID, which is separate from the device address
|
||||
* @portnr: Port number of this device on its parent hub, numbered from 1
|
||||
* (0 mean this device is the root hub)
|
||||
* @udev: usb-uclass internal use only do NOT use
|
||||
* @strings: List of descriptor strings (for sandbox emulation purposes)
|
||||
* @desc_list: List of descriptors (for sandbox emulation purposes)
|
||||
*/
|
||||
struct usb_dev_platdata {
|
||||
struct usb_device_id id;
|
||||
enum usb_device_speed speed;
|
||||
int devnum;
|
||||
int slot_id;
|
||||
int portnr; /* Hub port number, 1..n */
|
||||
/*
|
||||
* This pointer is used to pass the usb_device used in usb_scan_device,
|
||||
* to get the usb descriptors before the driver is known, to the
|
||||
* actual udevice once the driver is known and the udevice is created.
|
||||
* This will be NULL except during probe, do NOT use.
|
||||
*
|
||||
* This should eventually go away.
|
||||
*/
|
||||
struct usb_device *udev;
|
||||
#ifdef CONFIG_SANDBOX
|
||||
struct usb_string *strings;
|
||||
/* NULL-terminated list of descriptor pointers */
|
||||
@@ -742,11 +745,10 @@ int usb_scan_device(struct udevice *parent, int port,
|
||||
* will be a device with uclass UCLASS_USB.
|
||||
*
|
||||
* @dev: Device to check
|
||||
* @busp: Returns bus, or NULL if not found
|
||||
* @return 0 if OK, -EXDEV is somehow this bus does not have a controller (this
|
||||
* indicates a critical error in the USB stack
|
||||
* @return The bus, or NULL if not found (this indicates a critical error in
|
||||
* the USB stack
|
||||
*/
|
||||
int usb_get_bus(struct udevice *dev, struct udevice **busp);
|
||||
struct udevice *usb_get_bus(struct udevice *dev);
|
||||
|
||||
/**
|
||||
* usb_select_config() - Set up a device ready for use
|
||||
|
||||
Reference in New Issue
Block a user