diff options
-rw-r--r-- | arch/arm/mach-socfpga/spl_a10.c | 3 | ||||
-rw-r--r-- | cmd/ubi.c | 6 | ||||
-rw-r--r-- | drivers/i2c/imx_lpi2c.c | 82 | ||||
-rw-r--r-- | fs/ubifs/super.c | 8 | ||||
-rw-r--r-- | fs/ubifs/ubifs.h | 2 | ||||
-rw-r--r-- | include/imx_lpi2c.h (renamed from arch/arm/include/asm/arch-mx7ulp/imx_lpi2c.h) | 0 |
6 files changed, 59 insertions, 42 deletions
diff --git a/arch/arm/mach-socfpga/spl_a10.c b/arch/arm/mach-socfpga/spl_a10.c index e6fc766fca..fe4782c9cb 100644 --- a/arch/arm/mach-socfpga/spl_a10.c +++ b/arch/arm/mach-socfpga/spl_a10.c @@ -1,7 +1,6 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Copyright (C) 2012 Altera Corporation <www.altera.com> - * - * SPDX-License-Identifier: GPL-2.0+ */ #include <common.h> @@ -356,6 +356,8 @@ int ubi_volume_read(char *volume, char *buf, size_t size) size = vol->used_bytes; } + printf("Read %u bytes from volume %s to %p\n", size, volume, buf); + if (vol->corrupted) printf("read from corrupted volume %d", vol->vol_id); if (offp + size > vol->used_bytes) @@ -510,6 +512,7 @@ int ubi_part(char *part_name, const char *vid_header_offset) vid_header_offset); if (err) { printf("UBI init error %d\n", err); + printf("Please check, if the correct MTD partition is used (size big enough?)\n"); ubi_dev.selected = 0; return err; } @@ -674,9 +677,6 @@ static int do_ubi(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) } if (argc == 3) { - printf("Read %lld bytes from volume %s to %lx\n", size, - argv[3], addr); - return ubi_volume_read(argv[3], (char *)addr, size); } } diff --git a/drivers/i2c/imx_lpi2c.c b/drivers/i2c/imx_lpi2c.c index 8d3e0555a1..ff07ca34aa 100644 --- a/drivers/i2c/imx_lpi2c.c +++ b/drivers/i2c/imx_lpi2c.c @@ -8,15 +8,18 @@ #include <asm/io.h> #include <asm/arch/clock.h> #include <asm/arch/imx-regs.h> -#include <asm/arch/imx_lpi2c.h> +#include <imx_lpi2c.h> #include <asm/arch/sys_proto.h> #include <dm.h> #include <fdtdec.h> #include <i2c.h> #define LPI2C_FIFO_SIZE 4 +#define LPI2C_NACK_TOUT_MS 1 #define LPI2C_TIMEOUT_MS 100 +static int bus_i2c_init(struct udevice *bus, int speed); + /* Weak linked function for overridden by some SoC power function */ int __weak init_i2c_power(unsigned i2c_num) { @@ -90,8 +93,9 @@ static int bus_i2c_wait_for_tx_ready(struct imx_lpi2c_reg *regs) return result; } -static int bus_i2c_send(struct imx_lpi2c_reg *regs, u8 *txbuf, int len) +static int bus_i2c_send(struct udevice *bus, u8 *txbuf, int len) { + struct imx_lpi2c_reg *regs = (struct imx_lpi2c_reg *)devfdt_get_addr(bus); lpi2c_status_t result = LPI2C_SUCESS; /* empty tx */ @@ -110,8 +114,9 @@ static int bus_i2c_send(struct imx_lpi2c_reg *regs, u8 *txbuf, int len) return result; } -static int bus_i2c_receive(struct imx_lpi2c_reg *regs, u8 *rxbuf, int len) +static int bus_i2c_receive(struct udevice *bus, u8 *rxbuf, int len) { + struct imx_lpi2c_reg *regs = (struct imx_lpi2c_reg *)devfdt_get_addr(bus); lpi2c_status_t result = LPI2C_SUCESS; u32 val; ulong start_time = get_timer(0); @@ -152,15 +157,24 @@ static int bus_i2c_receive(struct imx_lpi2c_reg *regs, u8 *rxbuf, int len) return result; } -static int bus_i2c_start(struct imx_lpi2c_reg *regs, u8 addr, u8 dir) +static int bus_i2c_start(struct udevice *bus, u8 addr, u8 dir) { lpi2c_status_t result; + struct imx_lpi2c_reg *regs = + (struct imx_lpi2c_reg *)devfdt_get_addr(bus); u32 val; result = imx_lpci2c_check_busy_bus(regs); if (result) { debug("i2c: start check busy bus: 0x%x\n", result); - return result; + + /* Try to init the lpi2c then check the bus busy again */ + bus_i2c_init(bus, 100000); + result = imx_lpci2c_check_busy_bus(regs); + if (result) { + printf("i2c: Error check busy bus: 0x%x\n", result); + return result; + } } /* clear all status flags */ writel(0x7f00, ®s->msr); @@ -180,10 +194,13 @@ static int bus_i2c_start(struct imx_lpi2c_reg *regs, u8 addr, u8 dir) return result; } -static int bus_i2c_stop(struct imx_lpi2c_reg *regs) +static int bus_i2c_stop(struct udevice *bus) { lpi2c_status_t result; + struct imx_lpi2c_reg *regs = + (struct imx_lpi2c_reg *)devfdt_get_addr(bus); u32 status; + ulong start_time; result = bus_i2c_wait_for_tx_ready(regs); if (result) { @@ -194,7 +211,8 @@ static int bus_i2c_stop(struct imx_lpi2c_reg *regs) /* send stop command */ writel(LPI2C_MTDR_CMD(0x2), ®s->mtdr); - while (result == LPI2C_SUCESS) { + start_time = get_timer(0); + while (1) { status = readl(®s->msr); result = imx_lpci2c_check_clear_error(regs); /* stop detect flag */ @@ -204,39 +222,38 @@ static int bus_i2c_stop(struct imx_lpi2c_reg *regs) writel(status, ®s->msr); break; } + + if (get_timer(start_time) > LPI2C_NACK_TOUT_MS) { + debug("stop timeout\n"); + return -ETIMEDOUT; + } } return result; } -static int bus_i2c_read(struct imx_lpi2c_reg *regs, u32 chip, u8 *buf, int len) +static int bus_i2c_read(struct udevice *bus, u32 chip, u8 *buf, int len) { lpi2c_status_t result; - result = bus_i2c_start(regs, chip, 1); - if (result) - return result; - result = bus_i2c_receive(regs, buf, len); + result = bus_i2c_start(bus, chip, 1); if (result) return result; - result = bus_i2c_stop(regs); + result = bus_i2c_receive(bus, buf, len); if (result) return result; return result; } -static int bus_i2c_write(struct imx_lpi2c_reg *regs, u32 chip, u8 *buf, int len) +static int bus_i2c_write(struct udevice *bus, u32 chip, u8 *buf, int len) { lpi2c_status_t result; - result = bus_i2c_start(regs, chip, 0); + result = bus_i2c_start(bus, chip, 0); if (result) return result; - result = bus_i2c_send(regs, buf, len); - if (result) - return result; - result = bus_i2c_stop(regs); + result = bus_i2c_send(bus, buf, len); if (result) return result; @@ -351,38 +368,32 @@ static int bus_i2c_init(struct udevice *bus, int speed) static int imx_lpi2c_probe_chip(struct udevice *bus, u32 chip, u32 chip_flags) { - struct imx_lpi2c_reg *regs; lpi2c_status_t result; - regs = (struct imx_lpi2c_reg *)devfdt_get_addr(bus); - result = bus_i2c_start(regs, chip, 0); + result = bus_i2c_start(bus, chip, 0); if (result) { - bus_i2c_stop(regs); + bus_i2c_stop(bus); bus_i2c_init(bus, 100000); return result; } - result = bus_i2c_stop(regs); - if (result) { + result = bus_i2c_stop(bus); + if (result) bus_i2c_init(bus, 100000); - return -result; - } return result; } static int imx_lpi2c_xfer(struct udevice *bus, struct i2c_msg *msg, int nmsgs) { - struct imx_lpi2c_reg *regs; - int ret = 0; + int ret = 0, ret_stop; - regs = (struct imx_lpi2c_reg *)devfdt_get_addr(bus); for (; nmsgs > 0; nmsgs--, msg++) { debug("i2c_xfer: chip=0x%x, len=0x%x\n", msg->addr, msg->len); if (msg->flags & I2C_M_RD) - ret = bus_i2c_read(regs, msg->addr, msg->buf, msg->len); + ret = bus_i2c_read(bus, msg->addr, msg->buf, msg->len); else { - ret = bus_i2c_write(regs, msg->addr, msg->buf, + ret = bus_i2c_write(bus, msg->addr, msg->buf, msg->len); if (ret) break; @@ -392,6 +403,12 @@ static int imx_lpi2c_xfer(struct udevice *bus, struct i2c_msg *msg, int nmsgs) if (ret) debug("i2c_write: error sending\n"); + ret_stop = bus_i2c_stop(bus); + if (ret_stop) + debug("i2c_xfer: stop bus error\n"); + + ret |= ret_stop; + return ret; } @@ -447,6 +464,7 @@ static const struct dm_i2c_ops imx_lpi2c_ops = { static const struct udevice_id imx_lpi2c_ids[] = { { .compatible = "fsl,imx7ulp-lpi2c", }, + { .compatible = "fsl,imx8qm-lpi2c", }, {} }; diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index abdef1e6ab..9603163d8a 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c @@ -2360,7 +2360,9 @@ static struct super_block *alloc_super(struct file_system_type *type, int flags) return ERR_PTR(err); } +#ifndef __UBOOT__ INIT_HLIST_NODE(&s->s_instances); +#endif INIT_LIST_HEAD(&s->s_inodes); s->s_time_gran = 1000000000; s->s_flags = flags; @@ -2429,14 +2431,12 @@ retry: #ifndef __UBOOT__ strlcpy(s->s_id, type->name, sizeof(s->s_id)); list_add_tail(&s->s_list, &super_blocks); -#else - strncpy(s->s_id, type->name, sizeof(s->s_id)); -#endif hlist_add_head(&s->s_instances, &type->fs_supers); -#ifndef __UBOOT__ spin_unlock(&sb_lock); get_filesystem(type); register_shrinker(&s->s_shrink); +#else + strncpy(s->s_id, type->name, sizeof(s->s_id)); #endif return s; } diff --git a/fs/ubifs/ubifs.h b/fs/ubifs/ubifs.h index 78c3a68216..512fdaa144 100644 --- a/fs/ubifs/ubifs.h +++ b/fs/ubifs/ubifs.h @@ -316,8 +316,8 @@ struct super_block { struct backing_dev_info *s_bdi; #endif struct mtd_info *s_mtd; - struct hlist_node s_instances; #ifndef __UBOOT__ + struct hlist_node s_instances; struct quota_info s_dquot; /* Diskquota specific options */ #endif diff --git a/arch/arm/include/asm/arch-mx7ulp/imx_lpi2c.h b/include/imx_lpi2c.h index 3fbb40bdd1..3fbb40bdd1 100644 --- a/arch/arm/include/asm/arch-mx7ulp/imx_lpi2c.h +++ b/include/imx_lpi2c.h |