diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2017-09-08 08:41:18 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2017-09-08 08:41:18 +0200 |
commit | 36db84bb10758e2f160c197d267aad3f03e57045 (patch) | |
tree | 38214383d36659181ea397e6eec232b012d8ca12 | |
parent | 43c5a7cb5278a1cba7960bda8876c7182cdca9b5 (diff) | |
parent | 8d430633b26678da9f0ba85ef1b530a72d68ae96 (diff) | |
download | barebox-36db84bb10758e2f160c197d267aad3f03e57045.tar.gz barebox-36db84bb10758e2f160c197d267aad3f03e57045.tar.xz |
Merge branch 'for-next/misc'
-rw-r--r-- | Documentation/devicetree/bindings/rtc/dallas,ds1307.rst | 7 | ||||
-rw-r--r-- | arch/arm/include/asm/io.h | 4 | ||||
-rw-r--r-- | arch/ppc/include/asm/io.h | 2 | ||||
-rw-r--r-- | arch/sandbox/include/asm/io.h | 3 | ||||
-rw-r--r-- | arch/x86/include/asm/io.h | 15 | ||||
-rw-r--r-- | commands/loadxy.c | 4 | ||||
-rw-r--r-- | drivers/gpio/gpio-generic.c | 13 | ||||
-rw-r--r-- | drivers/of/base.c | 23 | ||||
-rw-r--r-- | drivers/serial/serial_ns16550.c | 19 | ||||
-rw-r--r-- | drivers/usb/gadget/autostart.c | 17 | ||||
-rw-r--r-- | include/asm-generic/io.h | 245 | ||||
-rw-r--r-- | include/of.h | 6 | ||||
-rw-r--r-- | lib/readline_simple.c | 5 | ||||
-rwxr-xr-x | scripts/regsubst.pl | 2 |
14 files changed, 319 insertions, 46 deletions
diff --git a/Documentation/devicetree/bindings/rtc/dallas,ds1307.rst b/Documentation/devicetree/bindings/rtc/dallas,ds1307.rst index 602f74b4dc..5a75be40eb 100644 --- a/Documentation/devicetree/bindings/rtc/dallas,ds1307.rst +++ b/Documentation/devicetree/bindings/rtc/dallas,ds1307.rst @@ -2,12 +2,14 @@ Dallas DS1307 I2C Serial Real-Time Clock ======================================== Required properties: + * ``compatible``: ``dallas,ds1307``, ``dallas,ds1308``, ``dallas,ds1338`` "maxim" can be used in place of "dallas" * ``reg``: I2C address for chip Optional properties: + * ``ext-clock-input``: Enable external clock input pin * ``ext-clock-output``: Enable square wave output. The above two properties are mutually exclusive @@ -19,7 +21,10 @@ Optional properties: The default is ext-clock-input, ext-clock-output, and ext-clock-bb disabled and ext-clock-rate of 1 Hz. -Example:: +Example + +.. code-block:: text + ds1307: rtc@68 { compatible = "dallas,ds1307"; reg = <0x68>; diff --git a/arch/arm/include/asm/io.h b/arch/arm/include/asm/io.h index eebf0938b0..d06ff8323f 100644 --- a/arch/arm/include/asm/io.h +++ b/arch/arm/include/asm/io.h @@ -1,10 +1,10 @@ #ifndef __ASM_ARM_IO_H #define __ASM_ARM_IO_H -#include <asm-generic/io.h> - #define IO_SPACE_LIMIT 0 +#include <asm-generic/io.h> + /* * String version of IO memory access ops: */ diff --git a/arch/ppc/include/asm/io.h b/arch/ppc/include/asm/io.h index f83ab6ee0b..025c06f3b7 100644 --- a/arch/ppc/include/asm/io.h +++ b/arch/ppc/include/asm/io.h @@ -244,4 +244,6 @@ void ppcDcbi(unsigned long value); void ppcSync(void); void ppcDcbz(unsigned long value); +#include <asm-generic/io.h> + #endif diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h index 35b578454e..cb891df5c8 100644 --- a/arch/sandbox/include/asm/io.h +++ b/arch/sandbox/include/asm/io.h @@ -1,7 +1,8 @@ #ifndef __ASM_SANDBOX_IO_H #define __ASM_SANDBOX_IO_H -#include <asm-generic/io.h> #define IO_SPACE_LIMIT 0 +#include <asm-generic/io.h> + #endif /* __ASM_SANDBOX_IO_H */ diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h index df4bc99ec8..5d19679b50 100644 --- a/arch/x86/include/asm/io.h +++ b/arch/x86/include/asm/io.h @@ -61,6 +61,19 @@ BUILDIO(b, b, char) BUILDIO(w, w, short) BUILDIO(l, , int) +#define outb outb +#define outw outw +#define outl outb +#define inb inb +#define inw inw +#define inl inl +#define outsb outsb +#define outsw outsw +#define outsl outsb +#define insb insb +#define insw insw +#define insl insl + #define IO_SPACE_LIMIT 0xffff /* do a tiny io delay */ @@ -69,4 +82,6 @@ static inline void io_delay(void) inb(0x80); } +#include <asm-generic/io.h> + #endif /* __ASM_X86_IO_H */ diff --git a/commands/loadxy.c b/commands/loadxy.c index a2aab0fc85..2bfe482fc5 100644 --- a/commands/loadxy.c +++ b/commands/loadxy.c @@ -113,7 +113,7 @@ static int do_loady(int argc, char *argv[]) BAREBOX_CMD_HELP_START(loady) BAREBOX_CMD_HELP_TEXT("Options:") BAREBOX_CMD_HELP_OPT("-g", "use Y-Modem/G (use on lossless tty such as USB)") -BAREBOX_CMD_HELP_OPT("-b BAUD", "baudrate for download (default: console baudrate") +BAREBOX_CMD_HELP_OPT("-b BAUD", "baudrate for download (default: console baudrate)") BAREBOX_CMD_HELP_OPT("-t NAME", "console name to use (default: current)") BAREBOX_CMD_HELP_END @@ -221,7 +221,7 @@ BAREBOX_CMD_HELP_START(loadx) BAREBOX_CMD_HELP_TEXT("Options:") BAREBOX_CMD_HELP_OPT("-f FILE", "download to FILE (default image.bin") BAREBOX_CMD_HELP_OPT("-o OFFS", "destination file OFFSet (default 0)") -BAREBOX_CMD_HELP_OPT("-b BAUD", "baudrate for download (default: console baudrate") +BAREBOX_CMD_HELP_OPT("-b BAUD", "baudrate for download (default: console baudrate)") BAREBOX_CMD_HELP_OPT("-t NAME", "console name to use (default: current)") BAREBOX_CMD_HELP_END diff --git a/drivers/gpio/gpio-generic.c b/drivers/gpio/gpio-generic.c index c6202fc651..14b451bfff 100644 --- a/drivers/gpio/gpio-generic.c +++ b/drivers/gpio/gpio-generic.c @@ -308,7 +308,7 @@ static void __iomem *bgpio_map(struct device_d *dev, const char *name, resource_size_t sane_sz, int *err) { struct resource *r; - void __iomem *ret; + struct resource *ret; *err = 0; @@ -327,7 +327,7 @@ static void __iomem *bgpio_map(struct device_d *dev, const char *name, return NULL; } - return ret; + return IOMEM(ret->start); } static int bgpio_dev_probe(struct device_d *dev) @@ -410,9 +410,18 @@ static struct platform_device_id bgpio_id_table[] = { { } }; +static struct of_device_id __maybe_unused bgpio_of_match[] = { + { + .compatible = "wd,mbl-gpio", + }, { + /* sentinel */ + } +}; + static struct driver_d bgpio_driver = { .name = "basic-mmio-gpio", .id_table = bgpio_id_table, + .of_compatible = DRV_OF_COMPAT(bgpio_of_match), .probe = bgpio_dev_probe, .remove = bgpio_dev_remove, }; diff --git a/drivers/of/base.c b/drivers/of/base.c index ea330d1310..95bea4ee83 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -1622,6 +1622,29 @@ int of_device_is_available(const struct device_node *device) EXPORT_SYMBOL(of_device_is_available); /** + * of_device_is_big_endian - check if a device has BE registers + * + * @device: Node to check for endianness + * + * Returns true if the device has a "big-endian" property, or if the kernel + * was compiled for BE *and* the device has a "native-endian" property. + * Returns false otherwise. + * + * Callers would nominally use ioread32be/iowrite32be if + * of_device_is_big_endian() == true, or readl/writel otherwise. + */ +bool of_device_is_big_endian(const struct device_node *device) +{ + if (of_property_read_bool(device, "big-endian")) + return true; + if (IS_ENABLED(CONFIG_CPU_BIG_ENDIAN) && + of_property_read_bool(device, "native-endian")) + return true; + return false; +} +EXPORT_SYMBOL(of_device_is_big_endian); + +/** * of_get_parent - Get a node's parent if any * @node: Node to get parent * diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c index a8953cd99d..4d73ea8b87 100644 --- a/drivers/serial/serial_ns16550.c +++ b/drivers/serial/serial_ns16550.c @@ -94,6 +94,16 @@ static void ns16550_write_reg_mmio_32(struct ns16550_priv *priv, uint8_t val, un writel(val, priv->mmiobase + offset); } +static uint8_t ns16550_read_reg_mmio_32be(struct ns16550_priv *priv, unsigned offset) +{ + return ioread32be(priv->mmiobase + offset); +} + +static void ns16550_write_reg_mmio_32be(struct ns16550_priv *priv, uint8_t val, unsigned offset) +{ + iowrite32be(val, priv->mmiobase + offset); +} + static uint8_t ns16550_read_reg_ioport_8(struct ns16550_priv *priv, unsigned offset) { return inb(priv->iobase + offset); @@ -305,8 +315,13 @@ static void ns16550_probe_dt(struct device_d *dev, struct ns16550_priv *priv) priv->write_reg = ns16550_write_reg_mmio_16; break; case 4: - priv->read_reg = ns16550_read_reg_mmio_32; - priv->write_reg = ns16550_write_reg_mmio_32; + if (of_device_is_big_endian(np)) { + priv->read_reg = ns16550_read_reg_mmio_32be; + priv->write_reg = ns16550_write_reg_mmio_32be; + } else { + priv->read_reg = ns16550_read_reg_mmio_32; + priv->write_reg = ns16550_write_reg_mmio_32; + } break; default: dev_err(dev, "unsupported reg-io-width (%d)\n", diff --git a/drivers/usb/gadget/autostart.c b/drivers/usb/gadget/autostart.c index 4ad1dd6be1..465d8fd380 100644 --- a/drivers/usb/gadget/autostart.c +++ b/drivers/usb/gadget/autostart.c @@ -31,19 +31,28 @@ static char *fastboot_function; static int usbgadget_autostart(void) { - struct f_multi_opts opts = {}; + struct f_multi_opts *opts; + int ret; if (!autostart) return 0; setenv("otg.mode", "peripheral"); + opts = xzalloc(sizeof(*opts)); + opts->release = usb_multi_opts_release; + if (fastboot_function) - opts.fastboot_opts.files = file_list_parse(fastboot_function); + opts->fastboot_opts.files = file_list_parse(fastboot_function); + + opts->create_acm = acm; + - opts.create_acm = acm; + ret = usb_multi_register(opts); + if (ret) + usb_multi_opts_release(opts); - return usb_multi_register(&opts); + return ret; } postenvironment_initcall(usbgadget_autostart); diff --git a/include/asm-generic/io.h b/include/asm-generic/io.h index 8d83d68069..973b8b954c 100644 --- a/include/asm-generic/io.h +++ b/include/asm-generic/io.h @@ -34,9 +34,17 @@ #define __raw_readl(a) (__chk_io_ptr(a), *(volatile unsigned int __force *)(a)) #endif +#ifndef readb #define readb __raw_readb +#endif + +#ifndef readw #define readw(addr) __le16_to_cpu(__raw_readw(addr)) +#endif + +#ifndef readl #define readl(addr) __le32_to_cpu(__raw_readl(addr)) +#endif #ifndef __raw_writeb #define __raw_writeb(v,a) (__chk_io_ptr(a), *(volatile unsigned char __force *)(a) = (v)) @@ -50,9 +58,17 @@ #define __raw_writel(v,a) (__chk_io_ptr(a), *(volatile unsigned int __force *)(a) = (v)) #endif +#ifndef writeb #define writeb __raw_writeb +#endif + +#ifndef writew #define writew(b,addr) __raw_writew(__cpu_to_le16(b),addr) +#endif + +#ifndef writel #define writel(b,addr) __raw_writel(__cpu_to_le32(b),addr) +#endif #ifdef CONFIG_64BIT static inline u64 __raw_readq(const volatile void __iomem *addr) @@ -69,50 +85,114 @@ static inline void __raw_writeq(u64 b, volatile void __iomem *addr) #endif #ifndef PCI_IOBASE -#define PCI_IOBASE ((void __iomem *) 0) +#define PCI_IOBASE ((void __iomem *)0) +#endif + +#ifndef IO_SPACE_LIMIT +#define IO_SPACE_LIMIT 0xffff #endif -/*****************************************************************************/ /* - * traditional input/output functions + * {in,out}{b,w,l}() access little endian I/O. {in,out}{b,w,l}_p() can be + * implemented on hardware that needs an additional delay for I/O accesses to + * take effect. */ +#ifndef inb +#define inb inb static inline u8 inb(unsigned long addr) { - return readb(addr + PCI_IOBASE); + return readb(PCI_IOBASE + addr); } +#endif +#ifndef inw +#define inw inw static inline u16 inw(unsigned long addr) { - return readw(addr + PCI_IOBASE); + return readw(PCI_IOBASE + addr); } +#endif +#ifndef inl +#define inl inl static inline u32 inl(unsigned long addr) { - return readl(addr + PCI_IOBASE); + return readl(PCI_IOBASE + addr); } +#endif -static inline void outb(u8 b, unsigned long addr) +#ifndef outb +#define outb outb +static inline void outb(u8 value, unsigned long addr) { - writeb(b, addr + PCI_IOBASE); + writeb(value, PCI_IOBASE + addr); } +#endif -static inline void outw(u16 b, unsigned long addr) +#ifndef outw +#define outw outw +static inline void outw(u16 value, unsigned long addr) { - writew(b, addr + PCI_IOBASE); + writew(value, PCI_IOBASE + addr); } +#endif -static inline void outl(u32 b, unsigned long addr) +#ifndef outl +#define outl outl +static inline void outl(u32 value, unsigned long addr) { - writel(b, addr + PCI_IOBASE); + writel(value, PCI_IOBASE + addr); } +#endif -#define inb_p(addr) inb(addr) -#define inw_p(addr) inw(addr) -#define inl_p(addr) inl(addr) -#define outb_p(x, addr) outb((x), (addr)) -#define outw_p(x, addr) outw((x), (addr)) -#define outl_p(x, addr) outl((x), (addr)) +#ifndef inb_p +#define inb_p inb_p +static inline u8 inb_p(unsigned long addr) +{ + return inb(addr); +} +#endif + +#ifndef inw_p +#define inw_p inw_p +static inline u16 inw_p(unsigned long addr) +{ + return inw(addr); +} +#endif + +#ifndef inl_p +#define inl_p inl_p +static inline u32 inl_p(unsigned long addr) +{ + return inl(addr); +} +#endif + +#ifndef outb_p +#define outb_p outb_p +static inline void outb_p(u8 value, unsigned long addr) +{ + outb(value, addr); +} +#endif + +#ifndef outw_p +#define outw_p outw_p +static inline void outw_p(u16 value, unsigned long addr) +{ + outw(value, addr); +} +#endif + +#ifndef outl_p +#define outl_p outl_p +static inline void outl_p(u32 value, unsigned long addr) +{ + outl(value, addr); +} +#endif #ifndef insb static inline void insb(unsigned long addr, void *buffer, int count) @@ -219,16 +299,125 @@ static inline void writesb(const void __iomem *addr, const void *buf, int len) outsb(addr - PCI_IOBASE, buf, len); } -#define ioread8(addr) readb(addr) -#define ioread16(addr) readw(addr) -#define ioread16be(addr) __be16_to_cpu(__raw_readw(addr)) -#define ioread32(addr) readl(addr) -#define ioread32be(addr) __be32_to_cpu(__raw_readl(addr)) -#define iowrite8(v, addr) writeb((v), (addr)) -#define iowrite16(v, addr) writew((v), (addr)) -#define iowrite16be(v, addr) __raw_writew(__cpu_to_be16(v), addr) -#define iowrite32(v, addr) writel((v), (addr)) -#define iowrite32be(v, addr) __raw_writel(__cpu_to_be32(v), addr) +#ifndef ioread8 +#define ioread8 ioread8 +static inline u8 ioread8(const volatile void __iomem *addr) +{ + return readb(addr); +} +#endif + +#ifndef ioread16 +#define ioread16 ioread16 +static inline u16 ioread16(const volatile void __iomem *addr) +{ + return readw(addr); +} +#endif + +#ifndef ioread32 +#define ioread32 ioread32 +static inline u32 ioread32(const volatile void __iomem *addr) +{ + return readl(addr); +} +#endif + +#ifdef CONFIG_64BIT +#ifndef ioread64 +#define ioread64 ioread64 +static inline u64 ioread64(const volatile void __iomem *addr) +{ + return readq(addr); +} +#endif +#endif /* CONFIG_64BIT */ + +#ifndef iowrite8 +#define iowrite8 iowrite8 +static inline void iowrite8(u8 value, volatile void __iomem *addr) +{ + writeb(value, addr); +} +#endif + +#ifndef iowrite16 +#define iowrite16 iowrite16 +static inline void iowrite16(u16 value, volatile void __iomem *addr) +{ + writew(value, addr); +} +#endif + +#ifndef iowrite32 +#define iowrite32 iowrite32 +static inline void iowrite32(u32 value, volatile void __iomem *addr) +{ + writel(value, addr); +} +#endif + +#ifdef CONFIG_64BIT +#ifndef iowrite64 +#define iowrite64 iowrite64 +static inline void iowrite64(u64 value, volatile void __iomem *addr) +{ + writeq(value, addr); +} +#endif +#endif /* CONFIG_64BIT */ + +#ifndef ioread16be +#define ioread16be ioread16be +static inline u16 ioread16be(const volatile void __iomem *addr) +{ + return swab16(readw(addr)); +} +#endif + +#ifndef ioread32be +#define ioread32be ioread32be +static inline u32 ioread32be(const volatile void __iomem *addr) +{ + return swab32(readl(addr)); +} +#endif + +#ifdef CONFIG_64BIT +#ifndef ioread64be +#define ioread64be ioread64be +static inline u64 ioread64be(const volatile void __iomem *addr) +{ + return swab64(readq(addr)); +} +#endif +#endif /* CONFIG_64BIT */ + +#ifndef iowrite16be +#define iowrite16be iowrite16be +static inline void iowrite16be(u16 value, void volatile __iomem *addr) +{ + writew(swab16(value), addr); +} +#endif + +#ifndef iowrite32be +#define iowrite32be iowrite32be +static inline void iowrite32be(u32 value, volatile void __iomem *addr) +{ + writel(swab32(value), addr); +} +#endif + +#ifdef CONFIG_64BIT +#ifndef iowrite64be +#define iowrite64be iowrite64be +static inline void iowrite64be(u64 value, volatile void __iomem *addr) +{ + writeq(swab64(value), addr); +} +#endif +#endif /* CONFIG_64BIT */ #endif /* __ASM_GENERIC_IO_H */ diff --git a/include/of.h b/include/of.h index 0ba73f197f..9ba771a395 100644 --- a/include/of.h +++ b/include/of.h @@ -150,6 +150,7 @@ extern int of_machine_is_compatible(const char *compat); extern int of_device_is_compatible(const struct device_node *device, const char *compat); extern int of_device_is_available(const struct device_node *device); +extern bool of_device_is_big_endian(const struct device_node *device); extern struct device_node *of_get_parent(const struct device_node *node); extern struct device_node *of_get_next_available_child( @@ -595,6 +596,11 @@ static inline int of_device_is_available(const struct device_node *device) return 0; } +static inline bool of_device_is_big_endian(const struct device_node *device) +{ + return false; +} + static inline void of_alias_scan(void) { } diff --git a/lib/readline_simple.c b/lib/readline_simple.c index c4d3d240e5..80e075bc5c 100644 --- a/lib/readline_simple.c +++ b/lib/readline_simple.c @@ -35,11 +35,8 @@ static char * delete_char (char *buffer, char *p, int *colp, int *np, int plen) /* * Prompt for input and read a line. - * If CONFIG_BOOT_RETRY_TIME is defined and retry_time >= 0, - * time out when time goes past endtime (timebase time in ticks). * Return: number of read characters * -1 if break - * -2 if timed out */ int readline (const char *prompt, char *line, int len) { @@ -58,6 +55,8 @@ int readline (const char *prompt, char *line, int len) for (;;) { c = getchar(); + if (c < 0) + return (-1); /* * Special character handling diff --git a/scripts/regsubst.pl b/scripts/regsubst.pl index 9621a58c47..3b6b8aa2e9 100755 --- a/scripts/regsubst.pl +++ b/scripts/regsubst.pl @@ -71,7 +71,7 @@ Then you can process the file with B<regsubst.pl>: If the result looks ok, you can replace the file: $ scripts/regsubst.pl -I arch/arm/mach-imx/include flash-header-myboard.imxcfg > u - $ mov u flash-header-myboard.imxcfg + $ mv u flash-header-myboard.imxcfg =cut |