Merge git://git.denx.de/u-boot-rockchip
authorTom Rini <trini@konsulko.com>
Mon, 1 Aug 2016 00:31:13 +0000 (20:31 -0400)
committerTom Rini <trini@konsulko.com>
Mon, 1 Aug 2016 00:31:13 +0000 (20:31 -0400)
arch/arm/dts/sun8i-h3-orangepi-one.dts
board/sunxi/board.c
configs/Hummingbird_A31_defconfig
configs/orangepi_one_defconfig
configs/orangepi_pc_defconfig
configs/orangepi_pc_plus_defconfig
configs/pine64_plus_defconfig
drivers/gpio/sunxi_gpio.c
drivers/net/sun8i_emac.c

index 0adf932..8df5c74 100644 (file)
        status = "okay";
 };
 
+&emac {
+       phy = <&phy1>;
+       phy-mode = "mii";
+       allwinner,use-internal-phy;
+       allwinner,leds-active-low;
+       status = "okay";
+       phy1: ethernet-phy@1 {
+               reg = <1>;
+       };
+};
+
 &mmc0 {
        pinctrl-names = "default";
        pinctrl-0 = <&mmc0_pins_a>, <&mmc0_cd_pin>;
index 36cf963..209fb1c 100644 (file)
@@ -27,6 +27,7 @@
 #endif
 #include <asm/gpio.h>
 #include <asm/io.h>
+#include <crc.h>
 #include <environment.h>
 #include <libfdt.h>
 #include <nand.h>
@@ -622,7 +623,28 @@ static void setup_environment(const void *fdt)
        int i, ret;
 
        ret = sunxi_get_sid(sid);
-       if (ret == 0 && sid[0] != 0 && sid[3] != 0) {
+       if (ret == 0 && sid[0] != 0) {
+               /*
+                * The single words 1 - 3 of the SID have quite a few bits
+                * which are the same on many models, so we take a crc32
+                * of all 3 words, to get a more unique value.
+                *
+                * Note we only do this on newer SoCs as we cannot change
+                * the algorithm on older SoCs since those have been using
+                * fixed mac-addresses based on only using word 3 for a
+                * long time and changing a fixed mac-address with an
+                * u-boot update is not good.
+                */
+#if !defined(CONFIG_MACH_SUN4I) && !defined(CONFIG_MACH_SUN5I) && \
+    !defined(CONFIG_MACH_SUN6I) && !defined(CONFIG_MACH_SUN7I) && \
+    !defined(CONFIG_MACH_SUN8I_A23) && !defined(CONFIG_MACH_SUN8I_A33)
+               sid[3] = crc32(0, (unsigned char *)&sid[1], 12);
+#endif
+
+               /* Ensure the NIC specific bytes of the mac are not all 0 */
+               if ((sid[3] & 0xffffff) == 0)
+                       sid[3] |= 0x800000;
+
                for (i = 0; i < 4; i++) {
                        sprintf(ethaddr, "ethernet%d", i);
                        if (!fdt_get_alias(fdt, ethaddr))
index 02bcdbf..3b0c439 100644 (file)
@@ -9,7 +9,7 @@ CONFIG_VIDEO_VGA_EXTERNAL_DAC_EN="PH25"
 CONFIG_DEFAULT_DEVICE_TREE="sun6i-a31-hummingbird"
 # CONFIG_SYS_MALLOC_CLEAR_ON_INIT is not set
 CONFIG_SPL=y
-CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,RGMII,MACPWR=SUNXI_GPA(21)"
+CONFIG_SYS_EXTRA_OPTIONS="SUNXI_GMAC,RGMII"
 # CONFIG_CMD_IMLS is not set
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
index be8afca..81299e6 100644 (file)
@@ -13,3 +13,4 @@ CONFIG_SPL=y
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SUN8I_EMAC=y
index 366fa08..2281aed 100644 (file)
@@ -14,3 +14,4 @@ CONFIG_SPL=y
 # CONFIG_CMD_FPGA is not set
 CONFIG_SY8106A_POWER=y
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SUN8I_EMAC=y
index c78aec3..3ec6dac 100644 (file)
@@ -15,3 +15,4 @@ CONFIG_SPL=y
 # CONFIG_CMD_FPGA is not set
 CONFIG_SY8106A_POWER=y
 CONFIG_USB_EHCI_HCD=y
+CONFIG_SUN8I_EMAC=y
index 0bf79bf..5c97de1 100644 (file)
@@ -10,3 +10,4 @@ CONFIG_DEFAULT_DEVICE_TREE="sun50i-a64-pine64-plus"
 # CONFIG_CMD_FLASH is not set
 # CONFIG_CMD_FPGA is not set
 CONFIG_ENABLE_ARM_SOC_BOOT0_HOOK=y
+CONFIG_SUN8I_EMAC=y
index 94abbeb..e8accaa 100644 (file)
@@ -19,6 +19,7 @@
 #include <asm/io.h>
 #include <asm/gpio.h>
 #include <dm/device-internal.h>
+#include <dt-bindings/gpio/gpio.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -215,12 +216,27 @@ static int sunxi_gpio_get_function(struct udevice *dev, unsigned offset)
                return GPIOF_FUNC;
 }
 
+static int sunxi_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
+                           struct fdtdec_phandle_args *args)
+{
+       int ret;
+
+       ret = device_get_child(dev, args->args[0], &desc->dev);
+       if (ret)
+               return ret;
+       desc->offset = args->args[1];
+       desc->flags = args->args[2] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;
+
+       return 0;
+}
+
 static const struct dm_gpio_ops gpio_sunxi_ops = {
        .direction_input        = sunxi_gpio_direction_input,
        .direction_output       = sunxi_gpio_direction_output,
        .get_value              = sunxi_gpio_get_value,
        .set_value              = sunxi_gpio_set_value,
        .get_function           = sunxi_gpio_get_function,
+       .xlate                  = sunxi_gpio_xlate,
 };
 
 /**
index 7c088c3..4c149e1 100644 (file)
 
 #define CONFIG_TX_DESCR_NUM    32
 #define CONFIG_RX_DESCR_NUM    32
-#define CONFIG_ETH_BUFSIZE     2024
+#define CONFIG_ETH_BUFSIZE     2048 /* Note must be dma aligned */
+
+/*
+ * The datasheet says that each descriptor can transfers up to 4096 bytes
+ * But later, the register documentation reduces that value to 2048,
+ * using 2048 cause strange behaviours and even BSP driver use 2047
+ */
+#define CONFIG_ETH_RXSIZE      2044 /* Note must fit in ETH_BUFSIZE */
 
 #define TX_TOTAL_BUFSIZE       (CONFIG_ETH_BUFSIZE * CONFIG_TX_DESCR_NUM)
 #define RX_TOTAL_BUFSIZE       (CONFIG_ETH_BUFSIZE * CONFIG_RX_DESCR_NUM)
@@ -324,7 +331,7 @@ static void rx_descs_init(struct emac_eth_dev *priv)
                desc_p->buf_addr = (uintptr_t)&rxbuffs[idx * CONFIG_ETH_BUFSIZE]
                        ;
                desc_p->next = (uintptr_t)&desc_table_p[idx + 1];
-               desc_p->st |= CONFIG_ETH_BUFSIZE;
+               desc_p->st |= CONFIG_ETH_RXSIZE;
                desc_p->status = BIT(31);
        }
 
@@ -506,7 +513,7 @@ static int _sun8i_eth_recv(struct emac_eth_dev *priv, uchar **packetp)
                                        roundup(data_end,
                                                ARCH_DMA_MINALIGN));
                if (good_packet) {
-                       if (length > CONFIG_ETH_BUFSIZE) {
+                       if (length > CONFIG_ETH_RXSIZE) {
                                printf("Received packet is too big (len=%d)\n",
                                       length);
                                return -EMSGSIZE;