]> git.sur5r.net Git - u-boot/commitdiff
Merge git://git.denx.de/u-boot-video
authorTom Rini <trini@konsulko.com>
Tue, 5 Sep 2017 12:54:55 +0000 (08:54 -0400)
committerTom Rini <trini@konsulko.com>
Tue, 5 Sep 2017 12:54:55 +0000 (08:54 -0400)
15 files changed:
.gitignore
arch/arm/include/asm/arch-rockchip/cru_rk3288.h
arch/arm/mach-rmobile/pfc-r8a7795.c
arch/arm/mach-rockchip/rk3288-board.c
board/phytec/phycore_rk3288/phycore-rk3288.c
board/phytec/phycore_rk3288/som.h [new file with mode: 0644]
board/renesas/salvator-x/salvator-x.c
board/renesas/ulcb/ulcb.c
cmd/fdt.c
configs/firefly-rk3399_defconfig
configs/phycore-rk3288_defconfig
doc/driver-model/MIGRATION.txt [new file with mode: 0644]
doc/driver-model/livetree.txt [new file with mode: 0644]
drivers/i2c/rk_i2c.c
drivers/timer/rockchip_timer.c

index 29757aa51e32364015a29ceff1deafab02365df3..f6f5dae3d4460f48c45c5d9b4b0e3f0b36e79060 100644 (file)
@@ -57,6 +57,14 @@ fit-dtb.blob
 /include/config/
 /include/generated/
 
+# Since "ee95d10 fdt: Build the new python libfdt module", a number of
+# build artifacts and intermediated from the python libfdt module are
+# installed into the /tools directory.
+/tools/_libfdt.so
+/tools/libfdt.py
+/tools/libfdt.pyc
+/tools/libfdt_wrap.c
+
 # stgit generated dirs
 patches-*
 .stgit-edit.txt
index c7e21bd605efdde1c395756df188dfc61888260e..79a6d6db80bbc1283346c33240e3c2caefb01cd9 100644 (file)
@@ -220,4 +220,16 @@ enum {
        CLKF_MASK               = 0x1fff << CLKF_SHIFT,
 };
 
+/* CRU_GLB_RST_ST */
+enum {
+       GLB_POR_RST,
+       FST_GLB_RST_ST          = BIT(0),
+       SND_GLB_RST_ST          = BIT(1),
+       FST_GLB_TSADC_RST_ST    = BIT(2),
+       SND_GLB_TSADC_RST_ST    = BIT(3),
+       FST_GLB_WDT_RST_ST      = BIT(4),
+       SND_GLB_WDT_RST_ST      = BIT(5),
+       GLB_RST_ST_MASK         = GENMASK(5, 0),
+};
+
 #endif
index 44460939733dec7cbfc61521948058307778ced8..93aaf31ed960f11f8e779199694a61552307dbce 100644 (file)
@@ -2185,6 +2185,27 @@ enum {
        FSO_TOEx_MARK,
        TPU0TO1_MARK,
 
+       /* IPSR18 */
+       USB3_PWEN_IMARK,
+       AUDIO_CLKOUT2_B_MARK,
+       SSI_SCK9_B_MARK,
+       TS_SDEN0_E_MARK,
+       STP_ISEN_0_E_MARK,
+       RIF2_D0_B_MARK,
+       TPU0TO2_MARK,
+       FMCLK_C_MARK,
+       FMCLK_D_MARK,
+
+       USB3_OVC_IMARK,
+       AUDIO_CLKOUT3_B_MARK,
+       SSI_WS9_B_MARK,
+       TS_SPSYNC0_E_MARK,
+       STP_ISSYNC_0_E_MARK,
+       RIF2_D1_B_MARK,
+       TPU0TO3_MARK,
+       FMIN_C_MARK,
+       FMIN_D_MARK,
+
        PINMUX_MARK_END,
 };
 
@@ -3288,6 +3309,27 @@ static struct pinmux_gpio pinmux_gpios[] = {
        GPIO_FN(RIF3_D1_B),
        GPIO_FN(FSO_TOEx),
        GPIO_FN(TPU0TO1),
+
+       /* IPSR18 */
+       GPIO_IFN(USB3_PWEN),
+       GPIO_FN(AUDIO_CLKOUT2_B),
+       GPIO_FN(SSI_SCK9_B),
+       GPIO_FN(TS_SDEN0_E),
+       GPIO_FN(STP_ISEN_0_E),
+       GPIO_FN(RIF2_D0_B),
+       GPIO_FN(TPU0TO2),
+       GPIO_FN(FMCLK_C),
+       GPIO_FN(FMCLK_D),
+
+       GPIO_IFN(USB3_OVC),
+       GPIO_FN(AUDIO_CLKOUT3_B),
+       GPIO_FN(SSI_WS9_B),
+       GPIO_FN(TS_SPSYNC0_E),
+       GPIO_FN(STP_ISSYNC_0_E),
+       GPIO_FN(RIF2_D1_B),
+       GPIO_FN(TPU0TO3),
+       GPIO_FN(FMIN_C),
+       GPIO_FN(FMIN_D),
 };
 
 static struct pinmux_cfg_reg pinmux_config_regs[] = {
index 74c6cc14a140e51b9cd78fe61c9754485b27b9c3..278bb406f03cf6a6ef7937537d4eb25e125ef6c7 100644 (file)
@@ -11,6 +11,7 @@
 #include <syscon.h>
 #include <asm/io.h>
 #include <asm/arch/clock.h>
+#include <asm/arch/cru_rk3288.h>
 #include <asm/arch/periph.h>
 #include <asm/arch/pmu_rk3288.h>
 #include <asm/arch/qos_rk3288.h>
@@ -70,10 +71,48 @@ int rk3288_qos_init(void)
        return 0;
 }
 
+static void rk3288_detect_reset_reason(void)
+{
+       struct rk3288_cru *cru = rockchip_get_cru();
+       const char *reason;
+
+       if (IS_ERR(cru))
+               return;
+
+       switch (cru->cru_glb_rst_st) {
+       case GLB_POR_RST:
+               reason = "POR";
+               break;
+       case FST_GLB_RST_ST:
+       case SND_GLB_RST_ST:
+               reason = "RST";
+               break;
+       case FST_GLB_TSADC_RST_ST:
+       case SND_GLB_TSADC_RST_ST:
+               reason = "THERMAL";
+               break;
+       case FST_GLB_WDT_RST_ST:
+       case SND_GLB_WDT_RST_ST:
+               reason = "WDOG";
+               break;
+       default:
+               reason = "unknown reset";
+       }
+
+       env_set("reset_reason", reason);
+
+       /*
+        * Clear cru_glb_rst_st, so we can determine the last reset cause
+        * for following resets.
+        */
+       rk_clrreg(&cru->cru_glb_rst_st, GLB_RST_ST_MASK);
+}
+
 int board_late_init(void)
 {
        setup_boot_mode();
        rk3288_qos_init();
+       rk3288_detect_reset_reason();
 
        return rk_board_late_init();
 }
index 20696f6dca1cdbaf797705e8af68e8c781549ad2..47b069e2ad8f8d35161a461e24191a90a21758d3 100644 (file)
@@ -5,4 +5,66 @@
  * SPDX-License-Identifier:     GPL-2.0+
  */
 
+#include <asm/io.h>
 #include <common.h>
+#include <dm.h>
+#include <i2c.h>
+#include <i2c_eeprom.h>
+#include <netdev.h>
+#include "som.h"
+
+static int valid_rk3288_som(struct rk3288_som *som)
+{
+       unsigned char *p = (unsigned char *)som;
+       unsigned char *e = p + sizeof(struct rk3288_som) - 1;
+       int hw = 0;
+
+       while (p < e) {
+               hw += hweight8(*p);
+               p++;
+       }
+
+       return hw == som->bs;
+}
+
+int rk_board_late_init(void)
+{
+       int ret;
+       struct udevice *dev;
+       struct rk3288_som opt;
+       int off;
+
+       /* Get the identificatioin page of M24C32-D EEPROM */
+       off = fdt_path_offset(gd->fdt_blob, "eeprom0");
+       if (off < 0) {
+               printf("%s: No eeprom0 path offset\n", __func__);
+               return off;
+       }
+
+       ret = uclass_get_device_by_of_offset(UCLASS_I2C_EEPROM, off, &dev);
+       if (ret) {
+               printf("%s: Could not find EEPROM\n", __func__);
+               return ret;
+       }
+
+       ret = i2c_set_chip_offset_len(dev, 2);
+       if (ret)
+               return ret;
+
+       ret = i2c_eeprom_read(dev, 0, (uint8_t *)&opt,
+                               sizeof(struct rk3288_som));
+       if (ret) {
+               printf("%s: Could not read EEPROM\n", __func__);
+               return ret;
+       }
+
+       if (opt.api_version != 0 || !valid_rk3288_som(&opt)) {
+               printf("Invalid data or wrong EEPROM layout version.\n");
+               /* Proceed anyway, since there is no fallback option */
+       }
+
+       if (is_valid_ethaddr(opt.mac))
+               eth_env_set_enetaddr("ethaddr", opt.mac);
+
+       return 0;
+}
diff --git a/board/phytec/phycore_rk3288/som.h b/board/phytec/phycore_rk3288/som.h
new file mode 100644 (file)
index 0000000..1b7f9a1
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2017 PHYTEC Messtechnik GmbH
+ * Author: Wadim Egorov <w.egorov@phytec.de>
+ *
+ * SPDX-License-Identifier:     GPL-2.0+
+ */
+
+/*
+ * rk3288_som struct represents the eeprom layout for PHYTEC RK3288 based SoMs
+ */
+struct rk3288_som {
+       unsigned char api_version;      /* EEPROM layout API version */
+       unsigned char mod_version;      /* PCM/PFL/PCA */
+       unsigned char option[12];       /* coding for variants */
+       unsigned char som_rev;          /* SOM revision */
+       unsigned char mac[6];
+       unsigned char ksp;              /* 1: KSP, 2: KSM */
+       unsigned char kspno;            /* Number for KSP/KSM module */
+       unsigned char reserved[8];      /* not used */
+       unsigned char bs;               /* Bits set in previous bytes */
+} __attribute__ ((__packed__));
index a09cd56d66ce082fed7576faba8764bb64290396..2695de5dbf358633c189c2aee38326574665c130 100644 (file)
@@ -116,7 +116,7 @@ int board_init(void)
        /* USB1 pull-up */
        setbits_le32(PFC_PUEN6, PUEN_USB1_OVC | PUEN_USB1_PWEN);
 
-#ifdef CONFIG_RAVB
+#ifdef CONFIG_RENESAS_RAVB
        /* EtherAVB Enable */
        /* GPSR2 */
        gpio_request(GPIO_GFN_AVB_AVTP_CAPTURE_A, NULL);
@@ -158,12 +158,7 @@ int board_init(void)
        udelay(1);
 #endif
 
-       return 0;
-}
-
-#ifdef CONFIG_SH_SDHI
-int board_mmc_init(bd_t *bis)
-{
+#ifdef CONFIG_MMC
        /* SDHI0 */
        gpio_request(GPIO_GFN_SD0_DAT0, NULL);
        gpio_request(GPIO_GFN_SD0_DAT1, NULL);
@@ -227,10 +222,10 @@ int board_mmc_init(bd_t *bis)
        gpio_request(GPIO_GP_3_14, NULL);
        gpio_direction_output(GPIO_GP_3_15, 1); /* power on */
        gpio_direction_output(GPIO_GP_3_14, 1); /* 1: 3.3V, 0: 1.8V */
+#endif
 
        return 0;
 }
-#endif
 
 int dram_init(void)
 {
index 068cbdea037e5c108b2e9cb68b861781c9233f0f..2b6cc612c8c597ff143147425301e952c47768f0 100644 (file)
@@ -105,7 +105,7 @@ int board_init(void)
        /* USB1 pull-up */
        setbits_le32(PFC_PUEN6, PUEN_USB1_OVC | PUEN_USB1_PWEN);
 
-#ifdef CONFIG_RAVB
+#ifdef CONFIG_RENESAS_RAVB
        /* EtherAVB Enable */
        /* GPSR2 */
        gpio_request(GPIO_GFN_AVB_AVTP_CAPTURE_A, NULL);
@@ -137,12 +137,7 @@ int board_init(void)
        udelay(1);
 #endif
 
-       return 0;
-}
-
-#ifdef CONFIG_SH_SDHI
-int board_mmc_init(bd_t *bis)
-{
+#ifdef CONFIG_MMC
        /* SDHI0 */
        gpio_request(GPIO_GFN_SD0_DAT0, NULL);
        gpio_request(GPIO_GFN_SD0_DAT1, NULL);
@@ -179,10 +174,10 @@ int board_mmc_init(bd_t *bis)
        gpio_request(GPIO_GP_5_9, NULL);
        gpio_direction_output(GPIO_GP_5_3, 0);  /* 1: 3.3V, 0: 1.8V */
        gpio_direction_output(GPIO_GP_5_9, 0);  /* 1: 3.3V, 0: 1.8V */
+#endif
 
        return 0;
 }
-#endif
 
 int dram_init(void)
 {
index 118613f405169c82d70f5d50c76dec1341761200..d7654b2c4fd5de88c935a8cbc4e2e52be8450eb4 100644 (file)
--- a/cmd/fdt.c
+++ b/cmd/fdt.c
@@ -284,16 +284,14 @@ static int do_fdt(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
                        len = 0;
                } else {
                        ptmp = fdt_getprop(working_fdt, nodeoffset, prop, &len);
-                       if (!ptmp) {
-                               printf("prop (%s) not found!\n", prop);
-                               return 1;
-                       }
                        if (len > SCRATCHPAD) {
                                printf("prop (%d) doesn't fit in scratchpad!\n",
                                       len);
                                return 1;
                        }
-                       memcpy(data, ptmp, len);
+                       if (ptmp != NULL)
+                               memcpy(data, ptmp, len);
+
                        ret = fdt_parse_prop(&argv[4], argc - 4, data, &len);
                        if (ret != 0)
                                return ret;
index 7e3d1070725ddc0d29f9cfe13a24df661d2cce80..58eaab3783a476b1bb543427ff9d3dda6008696a 100644 (file)
@@ -13,6 +13,8 @@ CONFIG_SPL_LOAD_FIT=y
 CONFIG_SPL_STACK_R=y
 CONFIG_SPL_STACK_R_MALLOC_SIMPLE_LEN=0x4000
 CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR=0x200
+CONFIG_SPL_ATF_SUPPORT=y
+CONFIG_SPL_ATF_TEXT_BASE=0x00010000
 CONFIG_CMD_BOOTZ=y
 # CONFIG_CMD_IMLS is not set
 CONFIG_CMD_GPT=y
index 17855a94b53c9961505f2ba973c5b32b86726a79..338efc484cdff9b37e98c0d9e13909217f2c83b5 100644 (file)
@@ -46,6 +46,8 @@ CONFIG_CLK=y
 CONFIG_SPL_CLK=y
 CONFIG_ROCKCHIP_GPIO=y
 CONFIG_SYS_I2C_ROCKCHIP=y
+CONFIG_MISC=y
+CONFIG_I2C_EEPROM=y
 CONFIG_MMC_DW=y
 CONFIG_MMC_DW_ROCKCHIP=y
 CONFIG_DM_ETH=y
diff --git a/doc/driver-model/MIGRATION.txt b/doc/driver-model/MIGRATION.txt
new file mode 100644 (file)
index 0000000..d2fe027
--- /dev/null
@@ -0,0 +1,20 @@
+Migration Schedule
+====================
+
+U-Boot has been migrating to a new driver model since its introduction in
+2014. This file describes the schedule for deprecation of pre-driver-model
+features.
+
+
+CONFIG_BLK
+----------
+
+Status: In progress
+Deadline: 2018.05
+
+Maintainers should submit patches for enabling CONFIG_BLK on all boards in
+time for inclusion in the 2018.05 release. Boards not converted by this
+time may be removed in a subsequent release.
+
+Note that this implies use of driver model for all block devices (e.g.
+MMC, USB, SCSI, SATA).
diff --git a/doc/driver-model/livetree.txt b/doc/driver-model/livetree.txt
new file mode 100644 (file)
index 0000000..01d4488
--- /dev/null
@@ -0,0 +1,272 @@
+Driver Model with Live Device Tree
+==================================
+
+
+Introduction
+------------
+
+Traditionally U-Boot has used a 'flat' device tree. This means that it
+reads directly from the device tree binary structure. It is called a flat
+device tree because nodes are listed one after the other, with the
+hierarchy detected by tags in the format.
+
+This document describes U-Boot's support for a 'live' device tree, meaning
+that the tree is loaded into a hierarchical data structure within U-Boot.
+
+
+Motivation
+----------
+
+The flat device tree has several advantages:
+
+- it is the format produced by the device tree compiler, so no translation
+is needed
+
+- it is fairly compact (e.g. there is no need for pointers)
+
+- it is accessed by the libfdt library, which is well tested and stable
+
+
+However the flat device tree does have some limitations. Adding new
+properties can involve copying large amounts of data around to make room.
+The overall tree has a fixed maximum size so sometimes the tree must be
+rebuilt in a new location to create more space. Even if not adding new
+properties or nodes, scanning the tree can be slow. For example, finding
+the parent of a node is a slow process. Reading from nodes involves a
+small amount parsing which takes a little time.
+
+Driver model scans the entire device tree sequentially on start-up which
+avoids the worst of the flat tree's limitations. But if the tree is to be
+modified at run-time, a live tree is much faster. Even if no modification
+is necessary, parsing the tree once and using a live tree from then on
+seems to save a little time.
+
+
+Implementation
+--------------
+
+In U-Boot a live device tree ('livetree') is currently supported only
+after relocation. Therefore we need a mechanism to specify a device
+tree node regardless of whether it is in the flat tree or livetree.
+
+The 'ofnode' type provides this. An ofnode can point to either a flat tree
+node (when the live tree node is not yet set up) or a livetree node. The
+caller of an ofnode function does not need to worry about these details.
+
+The main users of the information in a device tree are  drivers. These have
+a 'struct udevice *' which is attached to a device tree node. Therefore it
+makes sense to be able to read device tree  properties using the
+'struct udevice *', rather than having to obtain the ofnode first.
+
+The 'dev_read_...()' interface provides this. It allows properties to be
+easily read from the device tree using only a device pointer. Under the
+hood it uses ofnode so it works with both flat and live device trees.
+
+
+Enabling livetree
+-----------------
+
+CONFIG_OF_LIVE enables livetree. When this option is enabled, the flat
+tree will be used in SPL and before relocation in U-Boot proper. Just
+before relocation a livetree is built, and this is used for U-Boot proper
+after relocation.
+
+Most checks for livetree use CONFIG_IS_ENABLED(OF_LIVE). This means that
+for SPL, the CONFIG_SPL_OF_LIVE option is checked. At present this does
+not exist, since SPL does not support livetree.
+
+
+Porting drivers
+---------------
+
+Many existing drivers use the fdtdec interface to read device tree
+properties. This only works with a flat device tree. The drivers should be
+converted to use the dev_read_() interface.
+
+For example, the old code may be like this:
+
+    struct udevice *bus;
+    const void *blob = gd->fdt_blob;
+    int node = dev_of_offset(bus);
+
+    i2c_bus->regs = (struct i2c_ctlr *)devfdt_get_addr(dev);
+    plat->frequency = fdtdec_get_int(blob, node, "spi-max-frequency", 500000);
+
+The new code is:
+
+    struct udevice *bus;
+
+    i2c_bus->regs = (struct i2c_ctlr *)dev_read_addr(dev);
+    plat->frequency = dev_read_u32_default(bus, "spi-max-frequency", 500000);
+
+The dev_read_...() interface is more convenient and works with both the
+flat and live device trees. See include/dm/read.h for a list of functions.
+
+Where properties must be read from sub-nodes or other nodes, you must fall
+back to using ofnode. For example, for old code like this:
+
+    const void *blob = gd->fdt_blob;
+    int subnode;
+
+    fdt_for_each_subnode(subnode, blob, dev_of_offset(dev)) {
+        freq = fdtdec_get_int(blob, node, "spi-max-frequency", 500000);
+        ...
+    }
+
+you should use:
+
+    ofnode subnode;
+
+    ofnode_for_each_subnode(subnode, dev_ofnode(dev)) {
+        freq = ofnode_read_u32(node, "spi-max-frequency", 500000);
+        ...
+    }
+
+
+Useful ofnode functions
+-----------------------
+
+The internal data structures of the livetree are defined in include/dm/of.h :
+
+   struct device_node - holds information about a device tree node
+   struct property    - holds information about a property within a node
+
+Nodes have pointers to their first property, their parent, their first child
+and their sibling. This allows nodes to be linked together in a hierarchical
+tree.
+
+Properties have pointers to the next property. This allows all properties of
+a node to be linked together in a chain.
+
+It should not be necessary to use these data structures in normal code. In
+particular, you should refrain from using functions which access the livetree
+directly, such as of_read_u32(). Use ofnode functions instead, to allow your
+code to work with a flat tree also.
+
+Some conversion functions are used internally. Generally these are not needed
+for driver code. Note that they will not work if called in the wrong context.
+For example it is invalid to call ofnode_to_no() when a flat tree is being
+used. Similarly it is not possible to call ofnode_to_offset() on a livetree
+node.
+
+   ofnode_to_np() - converts ofnode to struct device_node *
+   ofnode_to_offset() - converts ofnode to offset
+
+   no_to_ofnode() - converts node pointer to ofnode
+   offset_to_ofnode() - converts offset to ofnode
+
+
+Other useful functions:
+
+   of_live_active() returns true if livetree is in use, false if flat tree
+   ofnode_valid() return true if a given node is valid
+   ofnode_is_np() returns true if a given node is a livetree node
+   ofnode_equal() compares two ofnodes
+   ofnode_null() returns a null ofnode (for which ofnode_valid() returns false)
+
+
+Phandles
+--------
+
+There is full phandle support for live tree. All functions make use of
+struct ofnode_phandle_args, which has an ofnode within it. This supports both
+livetree and flat tree transparently. See for example
+ofnode_parse_phandle_with_args().
+
+
+Reading addresses
+-----------------
+
+You should use dev_read_addr() and friends to read addresses from device-tree
+nodes.
+
+
+fdtdec
+------
+
+The existing fdtdec interface will eventually be retired. Please try to avoid
+using it in new code.
+
+
+Modifying the livetree
+----------------------
+
+This is not currently supported. Once implemented it should provide a much
+more efficient implementation for modification of the device tree than using
+the flat tree.
+
+
+Internal implementation
+-----------------------
+
+The dev_read_...() functions have two implementations. When
+CONFIG_DM_DEV_READ_INLINE is enabled, these functions simply call the ofnode
+functions directly. This is useful when livetree is not enabled. The ofnode
+functions call ofnode_is_np(node) which will always return false if livetree
+is disabled, just falling back to flat tree code.
+
+This optimisation means that without livetree enabled, the dev_read_...() and
+ofnode interfaces do not noticeably add to code size.
+
+The CONFIG_DM_DEV_READ_INLINE option defaults to enabled when livetree is
+disabled.
+
+Most livetree code comes directly from Linux and is modified as little as
+possible. This is deliberate since this code is fairly stable and does what
+we want. Some features (such as get/put) are not supported. Internal macros
+take care of removing these features silently.
+
+Within the of_access.c file there are pointers to the alias node, the chosen
+node and the stdout-path alias.
+
+
+Errors
+------
+
+With a flat device tree, libfdt errors are returned (e.g. -FDT_ERR_NOTFOUND).
+For livetree normal 'errno' errors are returned (e.g. -ENOTFOUND). At present
+the ofnode and dev_read_...() functions return either one or other type of
+error. This is clearly not desirable. Once tests are added for all the
+functions this can be tidied up.
+
+
+Adding new access functions
+---------------------------
+
+Adding a new function for device-tree access involves the following steps:
+
+   - Add two dev_read() functions:
+       - inline version in the read.h header file, which calls an ofnode
+               function
+       - standard version in the read.c file (or perhaps another file), which
+               also calls an ofnode function
+
+       The implementations of these functions can be the same. The purpose
+       of the inline version is purely to reduce code size impact.
+
+   - Add an ofnode function. This should call ofnode_is_np() to work out
+       whether a livetree or flat tree is used. For the livetree it should
+       call an of_...() function. For the flat tree it should call an
+       fdt_...() function. The livetree version will be optimised out at
+       compile time if livetree is not enabled.
+
+   - Add an of_...() function for the livetree implementation. If a similar
+       function is available in Linux, the implementation should be taken
+       from there and modified as little as possible (generally not at all).
+
+
+Future work
+-----------
+
+Live tree support was introduced in U-Boot 2017.07. There is still quite a bit
+of work to do to flesh this out:
+
+- tests for all access functions
+- support for livetree modification
+- addition of more access functions as needed
+- support for livetree in SPL and before relocation (if desired)
+
+
+--
+Simon Glass <sjg@chromium.org>
+5-Aug-17
index 8bc045a1a02b22482926b4ced8218c60dbb52761..68e66536e4e3af6ae759b461ee072b73ff9c4191 100644 (file)
@@ -164,6 +164,7 @@ static int rk_i2c_read(struct rk_i2c *i2c, uchar chip, uint reg, uint r_len,
        uint rxdata;
        uint i, j;
        int err;
+       bool snd_chunk = false;
 
        debug("rk_i2c_read: chip = %d, reg = %d, r_len = %d, b_len = %d\n",
              chip, reg, r_len, b_len);
@@ -184,15 +185,26 @@ static int rk_i2c_read(struct rk_i2c *i2c, uchar chip, uint reg, uint r_len,
 
        while (bytes_remain_len) {
                if (bytes_remain_len > RK_I2C_FIFO_SIZE) {
-                       con = I2C_CON_EN | I2C_CON_MOD(I2C_MODE_TRX);
+                       con = I2C_CON_EN;
                        bytes_xferred = 32;
                } else {
-                       con = I2C_CON_EN | I2C_CON_MOD(I2C_MODE_TRX) |
-                               I2C_CON_LASTACK;
+                       /*
+                        * The hw can read up to 32 bytes at a time. If we need
+                        * more than one chunk, send an ACK after the last byte.
+                        */
+                       con = I2C_CON_EN | I2C_CON_LASTACK;
                        bytes_xferred = bytes_remain_len;
                }
                words_xferred = DIV_ROUND_UP(bytes_xferred, 4);
 
+               /*
+                * make sure we are in plain RX mode if we read a second chunk
+                */
+               if (snd_chunk)
+                       con |= I2C_CON_MOD(I2C_MODE_RX);
+               else
+                       con |= I2C_CON_MOD(I2C_MODE_TRX);
+
                writel(con, &regs->con);
                writel(bytes_xferred, &regs->mrxcnt);
                writel(I2C_MBRFIEN | I2C_NAKRCVIEN, &regs->ien);
@@ -227,6 +239,7 @@ static int rk_i2c_read(struct rk_i2c *i2c, uchar chip, uint reg, uint r_len,
                }
 
                bytes_remain_len -= bytes_xferred;
+               snd_chunk = true;
                debug("I2C Read bytes_remain_len %d\n", bytes_remain_len);
        }
 
index 0848033c66257630b987ed14b0411280cb08662b..eb44965a19d488ac3b43564ef8977f8949a00d32 100644 (file)
@@ -92,7 +92,7 @@ static const struct udevice_id rockchip_timer_ids[] = {
        {}
 };
 
-U_BOOT_DRIVER(arc_timer) = {
+U_BOOT_DRIVER(rockchip_rk3368_timer) = {
        .name   = "rockchip_rk3368_timer",
        .id     = UCLASS_TIMER,
        .of_match = rockchip_timer_ids,