From patchwork Mon Oct 15 10:24:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Bj=C3=B8rn_Mork?= X-Patchwork-Id: 984083 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mork.no Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="kAwxRnOy"; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=mork.no header.i=@mork.no header.b="ODXKCeWt"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YZTs6Wj5z9s5c for ; Mon, 15 Oct 2018 21:30:57 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wi4uKLRgqaLQrhZjAGOIuyF/53kBqkhroc5mSmz6xiA=; b=kAwxRnOyRZ6geO 8aHuYb++LsRCZlZSH661CjHbt9iXYjKnOk8LYu0vLWgRmao2KFSEv5uOQ7gnIxIMkKa64SrbYu0TK 2ysrV0cX4QG+Sodrb/mo6m/fugpHhUSaLiX3pP4AQc/2lM/3JjreDgVoaluXQ/pIk5E3+KqMZjJF3 93CQt2gLuYQo2mkeBti5Bxb6xlr+DStvuHmM5B6uS4rCsLJUf6ihBxIMGrR5JnmiRz/WW2z4lMR9h Ym/12orb2tt5zX5A/CJ2SO983tLm58Pl9sZraie1HF4TS+vz22njVP/J25VR8bxeNm8vyRJNGa8QI Gca2CUbjxn/IIGk+BktQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gC09C-00067e-6q; Mon, 15 Oct 2018 10:30:50 +0000 Received: from canardo.mork.no ([2001:4641::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gC04D-0002Wv-1o for openwrt-devel@lists.openwrt.org; Mon, 15 Oct 2018 10:26:25 +0000 Received: from canardo.mork.no (ip6-localhost [IPv6:0:0:0:0:0:0:0:1]) by canardo.mork.no (8.15.2/8.15.2) with ESMTPS id w9FAPMYP030799 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 15 Oct 2018 12:25:23 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mork.no; s=b; t=1539599123; bh=n+bh/l8W1gNCV4AgnV2p7dNQOFbLEqlvTBPRGpqsuac=; h=From:To:Cc:Subject:Date:Message-Id:References:From; b=ODXKCeWtcrlA+THiQ0KoqOVcXzP1oVcMx6iSu+viOIKsHSjQxfDrT9dsrg0IXZHeq JSTnibrlx/teF/wmJmM/UsNv2h9JraI4H2by14bOBupjMJV8ylDHWmFkXcnBoo4G7X x6cz6oiLmFx6A17OwbXD/VDhpzxhsTHi/nP48fps= Received: (from bjorn@localhost) by canardo.mork.no (8.15.2/8.15.2/Submit) id w9FAPMow030793; Mon, 15 Oct 2018 12:25:22 +0200 From: =?utf-8?q?Bj=C3=B8rn_Mork?= To: OpenWrt Development List Date: Mon, 15 Oct 2018 12:24:55 +0200 Message-Id: <20181015102503.30731-2-bjorn@mork.no> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181015102503.30731-1-bjorn@mork.no> References: <20181015102503.30731-1-bjorn@mork.no> MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on canardo.mork.no X-Virus-Scanned: clamav-milter 0.100.1 at canardo X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181015_032542_062966_E8049290 X-CRM114-Status: GOOD ( 26.50 ) X-Spam-Score: -2.4 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [2001:4641:0:0:0:0:0:1 listed in] [list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Subject: [OpenWrt-Devel] [RFC 1/9] wap6805: add Mitrastar uImage tool X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Bj=C3=B8rn_Mork?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Signed-off-by: Bjørn Mork --- include/image-commands.mk | 10 + tools/firmware-utils/Makefile | 1 + tools/firmware-utils/src/mkmitrastar.c | 958 +++++++++++++++++++++++++++++++++ 3 files changed, 969 insertions(+) create mode 100644 tools/firmware-utils/src/mkmitrastar.c diff --git a/include/image-commands.mk b/include/image-commands.mk index 05d36093d3ec..2537895587bc 100644 --- a/include/image-commands.mk +++ b/include/image-commands.mk @@ -316,6 +316,16 @@ define Build/tplink-v2-image rm -rf $@.new endef +define Build/mitrastar + mkmitrastar -A $(LINUX_KARCH) \ + -O linux -T kernel \ + -C $(1) -a $(KERNEL_LOADADDR) -e $(if $(KERNEL_ENTRY),$(KERNEL_ENTRY),$(KERNEL_LOADADDR)) \ + -n '$(if $(UIMAGE_NAME),$(UIMAGE_NAME),$(call toupper,$(LINUX_KARCH)) $(VERSION_DIST) Linux-$(LINUX_VERSION))' \ + -c '$(if $(UIMAGE_NAME),$(UIMAGE_NAME),$(call toupper,$(LINUX_KARCH)) $(VERSION_DIST) Linux-$(LINUX_VERSION))' \ + -i $(MITRASTAR_MODEL_ID) -I $(MITRASTAR_CUST_ID) -d $@ $@.new + mv $@.new $@ +endef + json_quote=$(subst ','\'',$(subst ",\",$(1))) #")') metadata_devices=$(if $(1),$(subst "$(space)","$(comma)",$(strip $(foreach v,$(1),"$(call json_quote,$(v))")))) diff --git a/tools/firmware-utils/Makefile b/tools/firmware-utils/Makefile index 00917c34178c..95bd951a0690 100644 --- a/tools/firmware-utils/Makefile +++ b/tools/firmware-utils/Makefile @@ -86,6 +86,7 @@ define Host/Compile $(call cc,mkdlinkfw mkdlinkfw-lib, -lz -Wall --std=gnu99) $(call cc,dns313-header, -Wall) $(call cc,mksercommfw, -Wall --std=gnu99) + $(call cc,mkmitrastar, -lz) endef define Host/Install diff --git a/tools/firmware-utils/src/mkmitrastar.c b/tools/firmware-utils/src/mkmitrastar.c new file mode 100644 index 000000000000..257334789380 --- /dev/null +++ b/tools/firmware-utils/src/mkmitrastar.c @@ -0,0 +1,958 @@ +/* + * (C) Copyright 2000-2004 + * DENX Software Engineering + * Wolfgang Denk, wd@denx.de + * All rights reserved. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of + * the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, + * MA 02111-1307 USA + */ + +#include +#include +#include +#include +#include +#ifndef __WIN32__ +#include /* for host / network byte order conversions */ +#endif +#include +#include +#include +#include +#include /*for crc32 */ + +#if defined(__BEOS__) || defined(__NetBSD__) || defined(__APPLE__) +#include +#endif + +#ifdef __WIN32__ +typedef unsigned int __u32; + +#define SWAP_LONG(x) \ + ((__u32)( \ + (((__u32)(x) & (__u32)0x000000ffUL) << 24) | \ + (((__u32)(x) & (__u32)0x0000ff00UL) << 8) | \ + (((__u32)(x) & (__u32)0x00ff0000UL) >> 8) | \ + (((__u32)(x) & (__u32)0xff000000UL) >> 24) )) +typedef unsigned char uint8_t; +typedef unsigned short uint16_t; +typedef unsigned int uint32_t; + +#define ntohl(a) SWAP_LONG(a) +#define htonl(a) SWAP_LONG(a) +#endif /* __WIN32__ */ + +#ifndef O_BINARY /* should be define'd on __WIN32__ */ +#define O_BINARY 0 +#endif + +extern int errno; + +#ifndef MAP_FAILED +#define MAP_FAILED (-1) +#endif + +/* + * Operating System Codes + */ +#define IH_OS_INVALID 0 /* Invalid OS */ +#define IH_OS_OPENBSD 1 /* OpenBSD */ +#define IH_OS_NETBSD 2 /* NetBSD */ +#define IH_OS_FREEBSD 3 /* FreeBSD */ +#define IH_OS_4_4BSD 4 /* 4.4BSD */ +#define IH_OS_LINUX 5 /* Linux */ +#define IH_OS_SVR4 6 /* SVR4 */ +#define IH_OS_ESIX 7 /* Esix */ +#define IH_OS_SOLARIS 8 /* Solaris */ +#define IH_OS_IRIX 9 /* Irix */ +#define IH_OS_SCO 10 /* SCO */ +#define IH_OS_DELL 11 /* Dell */ +#define IH_OS_NCR 12 /* NCR */ +#define IH_OS_LYNXOS 13 /* LynxOS */ +#define IH_OS_VXWORKS 14 /* VxWorks */ +#define IH_OS_PSOS 15 /* pSOS */ +#define IH_OS_QNX 16 /* QNX */ +#define IH_OS_U_BOOT 17 /* Firmware */ +#define IH_OS_RTEMS 18 /* RTEMS */ +#define IH_OS_ARTOS 19 /* ARTOS */ +#define IH_OS_UNITY 20 /* Unity OS */ + +/* + * CPU Architecture Codes (supported by Linux) + */ +#define IH_CPU_INVALID 0 /* Invalid CPU */ +#define IH_CPU_ALPHA 1 /* Alpha */ +#define IH_CPU_ARM 2 /* ARM */ +#define IH_CPU_I386 3 /* Intel x86 */ +#define IH_CPU_IA64 4 /* IA64 */ +#define IH_CPU_MIPS 5 /* MIPS */ +#define IH_CPU_MIPS64 6 /* MIPS 64 Bit */ +#define IH_CPU_PPC 7 /* PowerPC */ +#define IH_CPU_S390 8 /* IBM S390 */ +#define IH_CPU_SH 9 /* SuperH */ +#define IH_CPU_SPARC 10 /* Sparc */ +#define IH_CPU_SPARC64 11 /* Sparc 64 Bit */ +#define IH_CPU_M68K 12 /* M68K */ +#define IH_CPU_NIOS 13 /* Nios-32 */ +#define IH_CPU_MICROBLAZE 14 /* MicroBlaze */ +#define IH_CPU_NIOS2 15 /* Nios-II */ + +/* + * Image Types + * + * "Standalone Programs" are directly runnable in the environment + * provided by U-Boot; it is expected that (if they behave + * well) you can continue to work in U-Boot after return from + * the Standalone Program. + * "OS Kernel Images" are usually images of some Embedded OS which + * will take over control completely. Usually these programs + * will install their own set of exception handlers, device + * drivers, set up the MMU, etc. - this means, that you cannot + * expect to re-enter U-Boot except by resetting the CPU. + * "RAMDisk Images" are more or less just data blocks, and their + * parameters (address, size) are passed to an OS kernel that is + * being started. + * "Multi-File Images" contain several images, typically an OS + * (Linux) kernel image and one or more data images like + * RAMDisks. This construct is useful for instance when you want + * to boot over the network using BOOTP etc., where the boot + * server provides just a single image file, but you want to get + * for instance an OS kernel and a RAMDisk image. + * + * "Multi-File Images" start with a list of image sizes, each + * image size (in bytes) specified by an "uint32_t" in network + * byte order. This list is terminated by an "(uint32_t)0". + * Immediately after the terminating 0 follow the images, one by + * one, all aligned on "uint32_t" boundaries (size rounded up to + * a multiple of 4 bytes - except for the last file). + * + * "Firmware Images" are binary images containing firmware (like + * U-Boot or FPGA images) which usually will be programmed to + * flash memory. + * + * "Script files" are command sequences that will be executed by + * U-Boot's command interpreter; this feature is especially + * useful when you configure U-Boot to use a real shell (hush) + * as command interpreter (=> Shell Scripts). + */ + +#define IH_TYPE_INVALID 0 /* Invalid Image */ +#define IH_TYPE_STANDALONE 1 /* Standalone Program */ +#define IH_TYPE_KERNEL 2 /* OS Kernel Image */ +#define IH_TYPE_RAMDISK 3 /* RAMDisk Image */ +#define IH_TYPE_MULTI 4 /* Multi-File Image */ +#define IH_TYPE_FIRMWARE 5 /* Firmware Image */ +#define IH_TYPE_SCRIPT 6 /* Script file */ +#define IH_TYPE_FILESYSTEM 7 /* Filesystem Image (any type) */ + +/* + * Compression Types + */ +#define IH_COMP_NONE 0 /* No Compression Used */ +#define IH_COMP_GZIP 1 /* gzip Compression Used */ +#define IH_COMP_BZIP2 2 /* bzip2 Compression Used */ +#define IH_COMP_LZMA 3 /* lzma Compression Used */ +#define IH_COMP_XZ 5 /* xz Compression Used */ + +#define IH_MAGIC 0x27051956 /* Image Magic Number */ +#define IH_NMLEN (32-4) /* Image Name Length */ +#if 1 // __MSTC__, Richard Huang +#define IH_CNMLEN 32 +#define IH_MODELID 4 +#define IH_HWVER 4 +#define IH_SEQUENCE 4 +#define IH_RESERVE (128 - IH_MODELID - IH_HWVER - IH_SEQUENCE) +#endif + +/* + * all data in network byte order (aka natural aka bigendian) + */ + +typedef struct image_header { + uint32_t ih_magic; /* Image Header Magic Number */ + uint32_t ih_hcrc; /* Image Header CRC Checksum */ + uint32_t ih_time; /* Image Creation Timestamp */ + uint32_t ih_size; /* Image Data Size */ + uint32_t ih_load; /* Data Load Address */ + uint32_t ih_ep; /* Entry Point Address */ + uint32_t ih_dcrc; /* Image Data CRC Checksum */ + uint8_t ih_os; /* Operating System */ + uint8_t ih_arch; /* CPU architecture */ + uint8_t ih_type; /* Image Type */ + uint8_t ih_comp; /* Compression Type */ + uint8_t ih_name[IH_NMLEN]; /* Image Name */ + uint32_t ih_ksz; /* Kernel Part Size */ + uint8_t ih_cname[IH_CNMLEN]; + uint8_t ih_modelid[IH_MODELID]; + uint8_t ih_hwver[IH_HWVER]; + uint32_t ih_sequence; /* Dual image sequence number */ + uint8_t ih_reserve[IH_RESERVE]; +} image_header_t; + +char *cmdname; + +typedef struct table_entry { + int val; /* as defined in image.h */ + char *sname; /* short (input) name */ + char *lname; /* long (output) name */ +} table_entry_t; + +table_entry_t arch_name[] = { + { IH_CPU_INVALID, NULL, "Invalid CPU", }, + { IH_CPU_ALPHA, "alpha", "Alpha", }, + { IH_CPU_ARM, "arm", "ARM", }, + { IH_CPU_I386, "x86", "Intel x86", }, + { IH_CPU_IA64, "ia64", "IA64", }, + { IH_CPU_M68K, "m68k", "MC68000", }, + { IH_CPU_MICROBLAZE, "microblaze", "MicroBlaze", }, + { IH_CPU_MIPS, "mips", "MIPS", }, + { IH_CPU_MIPS64, "mips64", "MIPS 64 Bit", }, + { IH_CPU_PPC, "ppc", "PowerPC", }, + { IH_CPU_S390, "s390", "IBM S390", }, + { IH_CPU_SH, "sh", "SuperH", }, + { IH_CPU_SPARC, "sparc", "SPARC", }, + { IH_CPU_SPARC64, "sparc64", "SPARC 64 Bit", }, + { -1, "", "", }, +}; + +table_entry_t os_name[] = { + { IH_OS_INVALID, NULL, "Invalid OS", }, + { IH_OS_4_4BSD, "4_4bsd", "4_4BSD", }, + { IH_OS_ARTOS, "artos", "ARTOS", }, + { IH_OS_DELL, "dell", "Dell", }, + { IH_OS_ESIX, "esix", "Esix", }, + { IH_OS_FREEBSD, "freebsd", "FreeBSD", }, + { IH_OS_IRIX, "irix", "Irix", }, + { IH_OS_LINUX, "linux", "Linux", }, + { IH_OS_LYNXOS, "lynxos", "LynxOS", }, + { IH_OS_NCR, "ncr", "NCR", }, + { IH_OS_NETBSD, "netbsd", "NetBSD", }, + { IH_OS_OPENBSD, "openbsd", "OpenBSD", }, + { IH_OS_PSOS, "psos", "pSOS", }, + { IH_OS_QNX, "qnx", "QNX", }, + { IH_OS_RTEMS, "rtems", "RTEMS", }, + { IH_OS_SCO, "sco", "SCO", }, + { IH_OS_SOLARIS, "solaris", "Solaris", }, + { IH_OS_SVR4, "svr4", "SVR4", }, + { IH_OS_U_BOOT, "u-boot", "U-Boot", }, + { IH_OS_VXWORKS, "vxworks", "VxWorks", }, + { -1, "", "", }, +}; + +table_entry_t type_name[] = { + { IH_TYPE_INVALID, NULL, "Invalid Image", }, + { IH_TYPE_FILESYSTEM, "filesystem", "Filesystem Image", }, + { IH_TYPE_FIRMWARE, "firmware", "Firmware", }, + { IH_TYPE_KERNEL, "kernel", "Kernel Image", }, + { IH_TYPE_MULTI, "multi", "Multi-File Image", }, + { IH_TYPE_RAMDISK, "ramdisk", "RAMDisk Image", }, + { IH_TYPE_SCRIPT, "script", "Script", }, + { IH_TYPE_STANDALONE, "standalone", "Standalone Program", }, + { -1, "", "", }, +}; + +table_entry_t comp_name[] = { + { IH_COMP_NONE, "none", "uncompressed", }, + { IH_COMP_BZIP2, "bzip2", "bzip2 compressed", }, + { IH_COMP_GZIP, "gzip", "gzip compressed", }, + { IH_COMP_LZMA, "lzma", "lzma compressed", }, + { IH_COMP_XZ, "xz", "xz compressed", }, + { -1, "", "", }, +}; + +static void copy_file (int, const char *, int); +static void usage (void); +static void print_header (image_header_t *); +static void print_type (image_header_t *); +static char *put_table_entry (table_entry_t *, char *, int); +static char *put_arch (int); +static char *put_type (int); +static char *put_os (int); +static char *put_comp (int); +static int get_table_entry (table_entry_t *, char *, char *); +static int get_arch(char *); +static int get_comp(char *); +static int get_os (char *); +static int get_type(char *); +static int xtoi(const char*); + +char *datafile; +char *imagefile; + +int dflag = 0; +int eflag = 0; +int lflag = 0; +int vflag = 0; +int xflag = 0; +int opt_os = IH_OS_LINUX; +int opt_arch = IH_CPU_PPC; +int opt_type = IH_TYPE_KERNEL; +int opt_comp = IH_COMP_GZIP; + +image_header_t header; +image_header_t *hdr = &header; + +int +main (int argc, char **argv) +{ + int ifd; + uint32_t checksum; + uint32_t addr; + uint32_t ep; + uint32_t ksz=0; + struct stat sbuf; + unsigned char *ptr; + char *name = ""; + char *cname = ""; + char *modelid = ""; + char *hwver = ""; + char *customerid = ""; + char tempValue[3]; + + cmdname = *argv; + + addr = ep = 0; + + while (--argc > 0 && **++argv == '-') { + while (*++*argv) { + switch (**argv) { + case 'l': + lflag = 1; + break; + case 'A': + if ((--argc <= 0) || + (opt_arch = get_arch(*++argv)) < 0) + usage (); + goto NXTARG; + case 'C': + if ((--argc <= 0) || + (opt_comp = get_comp(*++argv)) < 0) + usage (); + goto NXTARG; + case 'O': + if ((--argc <= 0) || + (opt_os = get_os(*++argv)) < 0) + usage (); + goto NXTARG; + case 'T': + if ((--argc <= 0) || + (opt_type = get_type(*++argv)) < 0) + usage (); + goto NXTARG; + + case 'a': + if (--argc <= 0) + usage (); + addr = strtoul (*++argv, (char **)&ptr, 16); + if (*ptr) { + fprintf (stderr, + "%s: invalid load address %s\n", + cmdname, *argv); + exit (EXIT_FAILURE); + } + goto NXTARG; + case 'd': + if (--argc <= 0) + usage (); + datafile = *++argv; + dflag = 1; + goto NXTARG; + case 'e': + if (--argc <= 0) + usage (); + ep = strtoul (*++argv, (char **)&ptr, 16); + if (*ptr) { + fprintf (stderr, + "%s: invalid entry point %s\n", + cmdname, *argv); + exit (EXIT_FAILURE); + } + eflag = 1; + goto NXTARG; + case 'k': + if (--argc <= 0) + usage (); + ksz = (uint32_t)atoi(*++argv); + goto NXTARG; + case 'n': + if (--argc <= 0) + usage (); + name = *++argv; + goto NXTARG; + case 'c': + if (--argc <= 0) + usage (); + cname = *++argv; + goto NXTARG; + /*case 'h': + if (--argc <= 0) + usage (); + hwver = *++argv; + goto NXTARG;*/ + case 'i': + if (--argc <= 0) + usage (); + modelid = *++argv; + goto NXTARG; + case 'I': + if (--argc <= 0) + usage (); + customerid = *++argv; + goto NXTARG; + case 'v': + vflag++; + break; + case 'x': + xflag++; + break; + default: + usage (); + } + } +NXTARG: ; + } + + if ((argc != 1) || ((lflag ^ dflag) == 0)) + usage(); + + if (!eflag) { + ep = addr; + /* If XIP, entry point must be after the U-Boot header */ + if (xflag) + ep += sizeof(image_header_t); + } + + /* + * If XIP, ensure the entry point is equal to the load address plus + * the size of the U-Boot header. + */ + if (xflag) { + if (ep != addr + sizeof(image_header_t)) { + fprintf (stderr, "%s: For XIP, the entry point must be the load addr + %lu\n", + cmdname, + (unsigned long)sizeof(image_header_t)); + exit (EXIT_FAILURE); + } + } + + imagefile = *argv; + + if (lflag) { + ifd = open(imagefile, O_RDONLY|O_BINARY); + } else { + ifd = open(imagefile, O_RDWR|O_CREAT|O_TRUNC|O_BINARY, 0666); + } + + if (ifd < 0) { + fprintf (stderr, "%s: Can't open %s: %s\n", + cmdname, imagefile, strerror(errno)); + exit (EXIT_FAILURE); + } + + if (lflag) { + int len; + char *data; + /* + * list header information of existing image + */ + if (fstat(ifd, &sbuf) < 0) { + fprintf (stderr, "%s: Can't stat %s: %s\n", + cmdname, imagefile, strerror(errno)); + exit (EXIT_FAILURE); + } + + if ((unsigned)sbuf.st_size < sizeof(image_header_t)) { + fprintf (stderr, + "%s: Bad size: \"%s\" is no valid image\n", + cmdname, imagefile); + exit (EXIT_FAILURE); + } + + ptr = (unsigned char *)mmap(0, sbuf.st_size, + PROT_READ, MAP_SHARED, ifd, 0); + if ((caddr_t)ptr == (caddr_t)-1) { + fprintf (stderr, "%s: Can't read %s: %s\n", + cmdname, imagefile, strerror(errno)); + exit (EXIT_FAILURE); + } + + /* + * create copy of header so that we can blank out the + * checksum field for checking - this can't be done + * on the PROT_READ mapped data. + */ + memcpy (hdr, ptr, sizeof(image_header_t)); + + if (ntohl(hdr->ih_magic) != IH_MAGIC) { + fprintf (stderr, + "%s: Bad Magic Number: \"%s\" is no valid image\n", + cmdname, imagefile); + exit (EXIT_FAILURE); + } + + data = (char *)hdr; + len = sizeof(image_header_t); + + checksum = ntohl(hdr->ih_hcrc); + hdr->ih_hcrc = htonl(0); /* clear for re-calculation */ + + if (crc32 (0, data, len) != checksum) { + fprintf (stderr, + "*** Warning: \"%s\" has bad header checksum!\n", + imagefile); + } + + data = (char *)(ptr + sizeof(image_header_t)); + len = sbuf.st_size - sizeof(image_header_t) ; + + if (crc32 (0, data, len) != ntohl(hdr->ih_dcrc)) { + fprintf (stderr, + "*** Warning: \"%s\" has corrupted data!\n", + imagefile); + } + + /* for multi-file images we need the data part, too */ + print_header ((image_header_t *)ptr); + + (void) munmap((void *)ptr, sbuf.st_size); + (void) close (ifd); + + exit (EXIT_SUCCESS); + } + + /* + * Must be -w then: + * + * write dummy header, to be fixed later + */ + memset (hdr, 0, sizeof(image_header_t)); + + if (write(ifd, hdr, sizeof(image_header_t)) != sizeof(image_header_t)) { + fprintf (stderr, "%s: Write error on %s: %s\n", + cmdname, imagefile, strerror(errno)); + exit (EXIT_FAILURE); + } + + if (opt_type == IH_TYPE_MULTI || opt_type == IH_TYPE_SCRIPT) { + char *file = datafile; + unsigned long size; + + for (;;) { + char *sep = NULL; + + if (file) { + if ((sep = strchr(file, ':')) != NULL) { + *sep = '\0'; + } + + if (stat (file, &sbuf) < 0) { + fprintf (stderr, "%s: Can't stat %s: %s\n", + cmdname, file, strerror(errno)); + exit (EXIT_FAILURE); + } + size = htonl(sbuf.st_size); + } else { + size = 0; + } + + if (write(ifd, (char *)&size, sizeof(size)) != sizeof(size)) { + fprintf (stderr, "%s: Write error on %s: %s\n", + cmdname, imagefile, strerror(errno)); + exit (EXIT_FAILURE); + } + + if (!file) { + break; + } + + if (sep) { + *sep = ':'; + file = sep + 1; + } else { + file = NULL; + } + } + + file = datafile; + + for (;;) { + char *sep = strchr(file, ':'); + if (sep) { + *sep = '\0'; + copy_file (ifd, file, 1); + *sep++ = ':'; + file = sep; + } else { + copy_file (ifd, file, 0); + break; + } + } + } else { + copy_file (ifd, datafile, 0); + } + + /* We're a bit of paranoid */ +#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__) + (void) fdatasync (ifd); +#else + (void) fsync (ifd); +#endif + + if (fstat(ifd, &sbuf) < 0) { + fprintf (stderr, "%s: Can't stat %s: %s\n", + cmdname, imagefile, strerror(errno)); + exit (EXIT_FAILURE); + } + + ptr = (unsigned char *)mmap(0, sbuf.st_size, + PROT_READ|PROT_WRITE, MAP_SHARED, ifd, 0); + if (ptr == (unsigned char *)MAP_FAILED) { + fprintf (stderr, "%s: Can't map %s: %s\n", + cmdname, imagefile, strerror(errno)); + exit (EXIT_FAILURE); + } + + hdr = (image_header_t *)ptr; + + checksum = crc32 (0, + (const char *)(ptr + sizeof(image_header_t)), + sbuf.st_size - sizeof(image_header_t) + ); + + /* Build new header */ + hdr->ih_magic = htonl(IH_MAGIC); + hdr->ih_time = htonl(sbuf.st_mtime); + hdr->ih_size = htonl(sbuf.st_size - sizeof(image_header_t)); + hdr->ih_load = htonl(addr); + hdr->ih_ep = htonl(ep); + hdr->ih_dcrc = htonl(checksum); + hdr->ih_ksz = htonl(ksz); + hdr->ih_os = opt_os; + hdr->ih_arch = opt_arch; + hdr->ih_type = opt_type; + hdr->ih_comp = opt_comp; + + strncpy((char *)hdr->ih_name, name, IH_NMLEN); + strncpy((char *)hdr->ih_cname, cname, IH_CNMLEN); + //strncpy((char *)hdr->ih_hwver, hwver, IH_HWVER); + memset(tempValue, 0, 3); + memcpy(tempValue, modelid, 2); + hdr->ih_modelid[0] = (char)xtoi(tempValue); + memset(tempValue, 0, 3); + memcpy(tempValue, modelid+2, 2); + hdr->ih_modelid[1] = (char)xtoi(tempValue); + memset(tempValue, 0, 3); + memcpy(tempValue, customerid, 2); + hdr->ih_modelid[2] = (char)xtoi(tempValue); + memset(tempValue, 0, 3); + memcpy(tempValue, customerid+2, 2); + hdr->ih_modelid[3] = (char)xtoi(tempValue); + + checksum = crc32(0,(const char *)hdr,sizeof(image_header_t)); + + hdr->ih_hcrc = htonl(checksum); + + print_header (hdr); + + (void) munmap((void *)ptr, sbuf.st_size); + + /* We're a bit of paranoid */ +#if defined(_POSIX_SYNCHRONIZED_IO) && !defined(__sun__) && !defined(__FreeBSD__) + (void) fdatasync (ifd); +#else + (void) fsync (ifd); +#endif + + if (close(ifd)) { + fprintf (stderr, "%s: Write error on %s: %s\n", + cmdname, imagefile, strerror(errno)); + exit (EXIT_FAILURE); + } + + exit (EXIT_SUCCESS); +} + +static void +copy_file (int ifd, const char *datafile, int pad) +{ + int dfd; + struct stat sbuf; + unsigned char *ptr; + int tail; + int zero = 0; + int offset = 0; + int size; + + if (vflag) { + fprintf (stderr, "Adding Image %s\n", datafile); + } + + if ((dfd = open(datafile, O_RDONLY|O_BINARY)) < 0) { + fprintf (stderr, "%s: Can't open %s: %s\n", + cmdname, datafile, strerror(errno)); + exit (EXIT_FAILURE); + } + + if (fstat(dfd, &sbuf) < 0) { + fprintf (stderr, "%s: Can't stat %s: %s\n", + cmdname, datafile, strerror(errno)); + exit (EXIT_FAILURE); + } + + ptr = (unsigned char *)mmap(0, sbuf.st_size, + PROT_READ, MAP_SHARED, dfd, 0); + if (ptr == (unsigned char *)MAP_FAILED) { + fprintf (stderr, "%s: Can't read %s: %s\n", + cmdname, datafile, strerror(errno)); + exit (EXIT_FAILURE); + } + + if (xflag) { + unsigned char *p = NULL; + /* + * XIP: do not append the image_header_t at the + * beginning of the file, but consume the space + * reserved for it. + */ + + if ((unsigned)sbuf.st_size < sizeof(image_header_t)) { + fprintf (stderr, + "%s: Bad size: \"%s\" is too small for XIP\n", + cmdname, datafile); + exit (EXIT_FAILURE); + } + + for (p=ptr; p < ptr+sizeof(image_header_t); p++) { + if ( *p != 0xff ) { + fprintf (stderr, + "%s: Bad file: \"%s\" has invalid buffer for XIP\n", + cmdname, datafile); + exit (EXIT_FAILURE); + } + } + + offset = sizeof(image_header_t); + } + + size = sbuf.st_size - offset; + if (write(ifd, ptr + offset, size) != size) { + fprintf (stderr, "%s: Write error on %s: %s\n", + cmdname, imagefile, strerror(errno)); + exit (EXIT_FAILURE); + } + + if (pad && ((tail = size % 4) != 0)) { + + if (write(ifd, (char *)&zero, 4-tail) != 4-tail) { + fprintf (stderr, "%s: Write error on %s: %s\n", + cmdname, imagefile, strerror(errno)); + exit (EXIT_FAILURE); + } + } + + (void) munmap((void *)ptr, sbuf.st_size); + (void) close (dfd); +} + +void +usage () +{ + fprintf (stderr, "Usage: %s -l image\n" + " -l ==> list image header information\n" + " %s [-x] -A arch -O os -T type -C comp " + "-a addr -e ep -n name -c cname -h hwver -i modelid -I customerid -d data_file[:data_file...] image\n", + cmdname, cmdname); + fprintf (stderr, " -A ==> set architecture to 'arch'\n" + " -O ==> set operating system to 'os'\n" + " -T ==> set image type to 'type'\n" + " -C ==> set compression type 'comp'\n" + " -a ==> set load address to 'addr' (hex)\n" + " -e ==> set entry point to 'ep' (hex)\n" + " -n ==> set image name to 'name'\n" + " -c ==> set customer name to 'cname'\n" + " -h ==> set hardware version to 'hwver'\n" + " -i ==> set model id to 'modelid'\n" + " -I ==> set customer id to 'modelid'\n" + " -d ==> use image data from 'datafile'\n" + " -x ==> set XIP (execute in place)\n" + ); + exit (EXIT_FAILURE); +} + +static void +print_header (image_header_t *hdr) +{ + time_t timestamp; + uint32_t size; + + timestamp = (time_t)ntohl(hdr->ih_time); + size = ntohl(hdr->ih_size); + + printf ("Image Name: %.*s\n", IH_NMLEN, hdr->ih_name); + printf ("Customer Name:%.*s\n", IH_CNMLEN, hdr->ih_cname); + //printf ("Hardware version:%.*s\n", IH_HWVER, hdr->ih_hwver); + printf ("Created: %s", ctime(×tamp)); + printf ("Image Type: "); print_type(hdr); + printf ("Data Size: %d Bytes = %.2f kB = %.2f MB\n", + size, (double)size / 1.024e3, (double)size / 1.048576e6 ); + printf ("Load Address: 0x%08X\n", ntohl(hdr->ih_load)); + printf ("Entry Point: 0x%08X\n", ntohl(hdr->ih_ep)); + printf ("Kernel Size: 0x%08X\n", ntohl(hdr->ih_ksz)); + printf ("chk: 0x%08X\n", ntohl(hdr->ih_hcrc)); + + if (hdr->ih_type == IH_TYPE_MULTI || hdr->ih_type == IH_TYPE_SCRIPT) { + int i, ptrs; + uint32_t pos; + unsigned long *len_ptr = (unsigned long *) ( + (unsigned long)hdr + sizeof(image_header_t) + ); + + /* determine number of images first (to calculate image offsets) */ + for (i=0; len_ptr[i]; ++i) /* null pointer terminates list */ + ; + ptrs = i; /* null pointer terminates list */ + + pos = sizeof(image_header_t) + ptrs * sizeof(long); + printf ("Contents:\n"); + for (i=0; len_ptr[i]; ++i) { + size = ntohl(len_ptr[i]); + + printf (" Image %d: %8d Bytes = %4d kB = %d MB\n", + i, size, size>>10, size>>20); + if (hdr->ih_type == IH_TYPE_SCRIPT && i > 0) { + /* + * the user may need to know offsets + * if planning to do something with + * multiple files + */ + printf (" Offset = %08X\n", pos); + } + /* copy_file() will pad the first files to even word align */ + size += 3; + size &= ~3; + pos += size; + } + } +} + + +static void +print_type (image_header_t *hdr) +{ + printf ("%s %s %s (%s)\n", + put_arch (hdr->ih_arch), + put_os (hdr->ih_os ), + put_type (hdr->ih_type), + put_comp (hdr->ih_comp) + ); +} + +static char *put_arch (int arch) +{ + return (put_table_entry(arch_name, "Unknown Architecture", arch)); +} + +static char *put_os (int os) +{ + return (put_table_entry(os_name, "Unknown OS", os)); +} + +static char *put_type (int type) +{ + return (put_table_entry(type_name, "Unknown Image", type)); +} + +static char *put_comp (int comp) +{ + return (put_table_entry(comp_name, "Unknown Compression", comp)); +} + +static char *put_table_entry (table_entry_t *table, char *msg, int type) +{ + for (; table->val>=0; ++table) { + if (table->val == type) + return (table->lname); + } + return (msg); +} + +static int get_arch(char *name) +{ + return (get_table_entry(arch_name, "CPU", name)); +} + + +static int get_comp(char *name) +{ + return (get_table_entry(comp_name, "Compression", name)); +} + + +static int get_os (char *name) +{ + return (get_table_entry(os_name, "OS", name)); +} + + +static int get_type(char *name) +{ + return (get_table_entry(type_name, "Image", name)); +} + +static int get_table_entry (table_entry_t *table, char *msg, char *name) +{ + table_entry_t *t; + int first = 1; + + for (t=table; t->val>=0; ++t) { + if (t->sname && strcasecmp(t->sname, name)==0) + return (t->val); + } + fprintf (stderr, "\nInvalid %s Type - valid names are", msg); + for (t=table; t->val>=0; ++t) { + if (t->sname == NULL) + continue; + fprintf (stderr, "%c %s", (first) ? ':' : ',', t->sname); + first = 0; + } + fprintf (stderr, "\n"); + return (-1); +} + +static int xtoi(const char* dest) +{ + int x = 0; + int digit; + + if( (*dest == '0') && (*(dest+1) == 'x') ) + dest += 2; + + while( *dest ) { + if( (*dest >= '0') && (*dest <= '9') ) + digit = *dest - '0'; + else if( (*dest >= 'A') && (*dest <= 'F') ) + digit = 10 + *dest - 'A'; + else if( (*dest >= 'a') && (*dest <= 'f') ) + digit = 10 + *dest - 'a'; + else + break; + x *= 16; + x += digit; + dest++; + } + return x; +} + From patchwork Mon Oct 15 10:24:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Bj=C3=B8rn_Mork?= X-Patchwork-Id: 984080 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mork.no Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="QLjua7YN"; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=mork.no header.i=@mork.no header.b="AlK1vPPb"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YZRM0dlkz9s5c for ; Mon, 15 Oct 2018 21:28:47 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=LFrF8Y/LTIIaXaK/zFrGwRl5HopcnPodqnsfWQ65o6k=; b=QLjua7YNQN+8vN vKs/NPOUoQhzZ/dHUiitZaimkYJJBH87RUetu3F036Z/tTvsG2FWSsi/HyC29JR6HNDiiyEBjEEDD yGcGgzuSo/dbM1ldDm/jskGXbvNgEb5VqXwFvTb3rpEf+bok49qVF7P0G4qkWIfG4FAfBujg05DSn ZNtbmt7g/23kMoSZwVtEk+k70JoGtRDYj9cj3sw7VMoYxeD2YbiK5VCFRuWnswhc6ug2bk6Bdvww9 +WjvVxfdkxTyiw7eGMumyVcLrFODwNM2Xg/yMFDh3alIacX09yGn4WLUuDzd/aM0XFgCTJ4s1vE1B aSlzlEl4DMD3+pD9X9rQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gC074-0003tN-D3; Mon, 15 Oct 2018 10:28:38 +0000 Received: from canardo.mork.no ([2001:4641::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gC04D-0002Wx-1U for openwrt-devel@lists.openwrt.org; Mon, 15 Oct 2018 10:25:47 +0000 Received: from canardo.mork.no (ip6-localhost [IPv6:0:0:0:0:0:0:0:1]) by canardo.mork.no (8.15.2/8.15.2) with ESMTPS id w9FAPNPT030814 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 15 Oct 2018 12:25:23 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mork.no; s=b; t=1539599123; bh=QHoqiR8TXW89UVH1D8IGieml/OqhdxnNVVQtMvIWVqo=; h=From:To:Cc:Subject:Date:Message-Id:References:From; b=AlK1vPPbFAAY76jTBw5l9Qc2W3BnbOdhZ3jerk5eQgtV+hDEHnQi0B3b6g8GDaHLK Nv0lDL7X7HDgUpOhsYuEvrS6JzPQEma434XaCP2s0s+QN3t5u7O+liyP8mZ4l1tkl+ aRryhb4on5e8+DQxgj0hCV/QQUHlBVM7D10EMo2c= Received: (from bjorn@localhost) by canardo.mork.no (8.15.2/8.15.2/Submit) id w9FAPNGI030807; Mon, 15 Oct 2018 12:25:23 +0200 From: =?utf-8?q?Bj=C3=B8rn_Mork?= To: OpenWrt Development List Date: Mon, 15 Oct 2018 12:24:56 +0200 Message-Id: <20181015102503.30731-3-bjorn@mork.no> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181015102503.30731-1-bjorn@mork.no> References: <20181015102503.30731-1-bjorn@mork.no> MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on canardo.mork.no X-Virus-Scanned: clamav-milter 0.100.1 at canardo X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181015_032542_025845_AEDF21E9 X-CRM114-Status: GOOD ( 14.15 ) X-Spam-Score: -2.4 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [2001:4641:0:0:0:0:0:1 listed in] [list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Subject: [OpenWrt-Devel] [RFC 2/9] wap6805: add board definition and DTS X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Bj=C3=B8rn_Mork?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Signed-off-by: Bjørn Mork --- .../linux/ramips/base-files/etc/board.d/02_network | 4 + .../ramips/base-files/etc/board.d/03_gpio_switches | 3 + target/linux/ramips/base-files/lib/ramips.sh | 3 + .../ramips/base-files/lib/upgrade/platform.sh | 6 +- target/linux/ramips/dts/WAP6805.dts | 142 +++++++++++++++++++++ target/linux/ramips/image/mt7621.mk | 24 +++- 6 files changed, 179 insertions(+), 3 deletions(-) create mode 100644 target/linux/ramips/dts/WAP6805.dts diff --git a/target/linux/ramips/base-files/etc/board.d/02_network b/target/linux/ramips/base-files/etc/board.d/02_network index 9e9ecbcb51df..f53bf02d221f 100755 --- a/target/linux/ramips/base-files/etc/board.d/02_network +++ b/target/linux/ramips/base-files/etc/board.d/02_network @@ -404,6 +404,10 @@ ramips_setup_interfaces() ucidef_add_switch "switch0" \ "0:lan:2" "1:lan:1" "4:wan" "6@eth0" ;; + wap6805) + ucidef_add_switch "switch0" \ + "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "6@eth0" + ;; *) RT3X5X=`cat /proc/cpuinfo | egrep "(RT3.5|RT5350)"` if [ -n "${RT3X5X}" ]; then diff --git a/target/linux/ramips/base-files/etc/board.d/03_gpio_switches b/target/linux/ramips/base-files/etc/board.d/03_gpio_switches index a847a64d6bb0..9753d5d69df8 100755 --- a/target/linux/ramips/base-files/etc/board.d/03_gpio_switches +++ b/target/linux/ramips/base-files/etc/board.d/03_gpio_switches @@ -17,6 +17,9 @@ ubnt-erx-sfp) ucidef_add_gpio_switch "poe_power_port3" "PoE Power Port3" "499" ucidef_add_gpio_switch "poe_power_port4" "PoE Power Port4" "500" ;; +wap6805) + ucidef_add_gpio_switch "qtn_power" "Quantenna Module Power" "16" + ;; esac board_config_flush diff --git a/target/linux/ramips/base-files/lib/ramips.sh b/target/linux/ramips/base-files/lib/ramips.sh index 5741cbd2ee13..5afae99cd41e 100755 --- a/target/linux/ramips/base-files/lib/ramips.sh +++ b/target/linux/ramips/base-files/lib/ramips.sh @@ -718,6 +718,9 @@ ramips_board_detect() { *"ZyXEL Keenetic Viva") name="kng_rc" ;; + *"ZyXEL WAP6805") + name="wap6805" + ;; *"YK1") name="youku-yk1" ;; diff --git a/target/linux/ramips/base-files/lib/upgrade/platform.sh b/target/linux/ramips/base-files/lib/upgrade/platform.sh index 7558b4e3168a..238290c7ea37 100755 --- a/target/linux/ramips/base-files/lib/upgrade/platform.sh +++ b/target/linux/ramips/base-files/lib/upgrade/platform.sh @@ -304,7 +304,8 @@ platform_check_image() { mir3g|\ r6220|\ ubnt-erx|\ - ubnt-erx-sfp) + ubnt-erx-sfp|\ + wap6805) nand_do_platform_check "$board" "$1" return $?; ;; @@ -361,7 +362,8 @@ platform_do_upgrade() { mir3g|\ r6220|\ ubnt-erx|\ - ubnt-erx-sfp) + ubnt-erx-sfp|\ + wap6805) nand_do_upgrade "$ARGV" ;; *) diff --git a/target/linux/ramips/dts/WAP6805.dts b/target/linux/ramips/dts/WAP6805.dts new file mode 100644 index 000000000000..53ef7301d13b --- /dev/null +++ b/target/linux/ramips/dts/WAP6805.dts @@ -0,0 +1,142 @@ +/dts-v1/; + +#include "mt7621.dtsi" + +#include +#include + +/ { + compatible = "zyxel,wap6805", "mediatek,mt7621-soc"; + model = "ZyXEL WAP6805"; + + memory@0 { + device_type = "memory"; + reg = <0x0 0x4000000>; + }; + + chosen { + bootargs = "console=ttyS0,57600"; + }; + + gpio-keys-polled { + compatible = "gpio-keys-polled"; + #address-cells = <1>; + #size-cells = <0>; + poll-interval = <20>; + + wps { + label = "wps"; + gpios = <&gpio0 8 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + + reset { + label = "reset"; + gpios = <&gpio0 18 GPIO_ACTIVE_LOW>; + linux,code = ; + }; + }; + + aliases { + led-status = &led_system; + }; + + gpio-leds { + compatible = "gpio-leds"; + + system_red { + label = "wap6805:red:system"; + gpios = <&gpio0 4 GPIO_ACTIVE_HIGH>; + }; + + led_system: system_green { + label = "wap6805:green:system"; + gpios = <&gpio0 13 GPIO_ACTIVE_HIGH>; + }; + }; +}; + +&nand { + status = "okay"; + + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + partition@0 { + label = "Bootloader"; + reg = <0x0 0x100000>; + read-only; + }; + + partition@100000 { + label = "MRD"; + reg = <0x100000 0x100000>; + read-only; + }; + + factory: partition@200000 { + label = "Factory"; + reg = <0x200000 0x100000>; + read-only; + }; + + partition@300000 { + label = "Config"; + reg = <0x300000 0x100000>; + }; + + partition@400000 { + label = "firmware"; + reg = <0x400000 0x2000000 >; + }; + + partition@2400000 { + label = "Kernel2"; + reg = <0x2400000 0x2000000 >; + }; + + partition@4400000 { + label = "Private"; + reg = <0x4400000 0x100000>; + }; + + partition@4500000 { + label = "Log"; + reg = <0x4500000 0x1000000>; + }; + + partition@5500000 { + label = "App"; + reg = <0x5500000 0x2b00000>; + }; + }; +}; + +&pcie { + status = "okay"; + pcie0 { + mt76@0,0 { + mediatek,mtd-eeprom = <&factory 0>; + }; + }; + +}; + +ðernet { + mtd-mac-address = <&factory 0xe000>; +}; + +&xhci { + status = "disabled"; +}; + +&pinctrl { + state_default: pinctrl0 { + gpio { + ralink,group = "i2c", "uart3", "jtag", "wdt", "spi", "sdhci"; + ralink,function = "gpio"; + }; + }; +}; diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index a4a0f3d29382..cc37c53bad28 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -3,7 +3,7 @@ # KERNEL_DTB += -d21 -DEVICE_VARS += TPLINK_BOARD_ID TPLINK_HEADER_VERSION TPLINK_HWID TPLINK_HWREV +DEVICE_VARS += TPLINK_BOARD_ID TPLINK_HEADER_VERSION TPLINK_HWID TPLINK_HWREV MITRASTAR_MODEL_ID MITRASTAR_CUST_ID define Build/elecom-gst-factory $(eval product=$(word 1,$(1))) @@ -531,6 +531,28 @@ define Device/zbt-wg3526-32M endef TARGET_DEVICES += zbt-wg3526-32M +define Device/wap6805 + DTS := WAP6805 + BLOCKSIZE := 128k + PAGESIZE := 2048 + FILESYSTEMS := squashfs + IMAGE_SIZE := $(ralink_default_fw_size_32M) + DEVICE_TITLE := ZyXEL WAP6805 + DEVICE_PACKAGES := \ + kmod-mt7603 kmod-mt76x2 \ + kmod-usb3 kmod-usb-ledtrig-usbport wpad-mini \ + -swconfig + MITRASTAR_MODEL_ID := 8008 + MITRASTAR_CUST_ID := ffff + KERNEL_SIZE := 4096k + KERNEL := $(KERNEL_DTB) | mitrastar lzma + IMAGES += factory.bin + IMAGE/sysupgrade.bin := sysupgrade-tar | append-metadata + UBINIZE_OPTS := -E 5 + IMAGE/factory.bin := append-kernel | pad-to $$(KERNEL_SIZE) | append-ubi | check-size $$$$(IMAGE_SIZE) +endef +TARGET_DEVICES += wap6805 + # FIXME: is this still needed? define Image/Prepare #define Build/Compile From patchwork Mon Oct 15 10:24:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Bj=C3=B8rn_Mork?= X-Patchwork-Id: 984082 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mork.no Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="j82il27/"; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=mork.no header.i=@mork.no header.b="bwfKGOcr"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YZSs1NZsz9s5c for ; Mon, 15 Oct 2018 21:30:05 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Nc8fPJsfLvm8dY5FRfUg2a97PJFRnBrjcrpFlDuSOB4=; b=j82il27/d396N6 8sk4El3ds22RruHCcnGSqlf1ow06tEN72wBEHH3N3SJ+4udNY0/+sp5gj49kJMYHn0aTGM0rSCAcN pfbI22y+ZF2a4y7ZVP3c0JFadkfc3SPMxOl+kvz3Cz8oXElmt3GSIOMMid73N9EiUYSg2ygcVBmqT xUrKm1/8pdQR33Yi2tzyQH/Ul658Zkbi0L4lab1uKaIcZ0Y9bfUoCfIO5IuVMdcGXZa8dYHAJ6FKv QKxX6zeuJSlwYkot/fwkoON1KLudYTS4A+SJQhgsfSqgchB8YYd0r/Nm3YX5zKbcFclky+19xmadp TvINpctnDmhyiP1T2eyw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gC08M-0004Uw-6Y; Mon, 15 Oct 2018 10:29:58 +0000 Received: from canardo.mork.no ([2001:4641::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gC04D-0002Wy-2H for openwrt-devel@lists.openwrt.org; Mon, 15 Oct 2018 10:26:19 +0000 Received: from canardo.mork.no (ip6-localhost [IPv6:0:0:0:0:0:0:0:1]) by canardo.mork.no (8.15.2/8.15.2) with ESMTPS id w9FAPNlb030825 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 15 Oct 2018 12:25:23 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mork.no; s=b; t=1539599123; bh=K96myx1F3awOrqFL6GUUH8yOiYqGxnH5mXmWsyV1gDw=; h=From:To:Cc:Subject:Date:Message-Id:References:From; b=bwfKGOcrtHeYZrJRK4cZyG6nq6+pVOEXVlUjmwc9nSzB0WSXuSAwXjuY94Bf7ILlo XePTuCFFzb0kFdKG5aWUqgehqZEsVnZJwnbj6BYRQtQK7+Lv91zDsrEeYO9FUe4ikr qBuGTB9fMDhUdkeZOD7Gag3lXbl5RhbPGAoDUeT0= Received: (from bjorn@localhost) by canardo.mork.no (8.15.2/8.15.2/Submit) id w9FAPNmX030817; Mon, 15 Oct 2018 12:25:23 +0200 From: =?utf-8?q?Bj=C3=B8rn_Mork?= To: OpenWrt Development List Date: Mon, 15 Oct 2018 12:24:57 +0200 Message-Id: <20181015102503.30731-4-bjorn@mork.no> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181015102503.30731-1-bjorn@mork.no> References: <20181015102503.30731-1-bjorn@mork.no> MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on canardo.mork.no X-Virus-Scanned: clamav-milter 0.100.1 at canardo X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181015_032542_091245_6FE1C1B9 X-CRM114-Status: GOOD ( 13.47 ) X-Spam-Score: -2.4 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [2001:4641:0:0:0:0:0:1 listed in] [list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Subject: [OpenWrt-Devel] [RFC 3/9] ramips: rename out-of-tree net driver to "ralink" X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Bj=C3=B8rn_Mork?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Signed-off-by: Bjørn Mork --- .../drivers/net/ethernet/mediatek/Kconfig | 70 ---------------------- .../drivers/net/ethernet/mediatek/Makefile | 22 ------- .../files-4.14/drivers/net/ethernet/ralink/Kconfig | 70 ++++++++++++++++++++++ .../drivers/net/ethernet/ralink/Makefile | 22 +++++++ .../net/ethernet/{mediatek => ralink}/esw_rt3050.c | 0 .../net/ethernet/{mediatek => ralink}/esw_rt3050.h | 2 +- .../net/ethernet/{mediatek => ralink}/ethtool.c | 0 .../net/ethernet/{mediatek => ralink}/ethtool.h | 0 .../net/ethernet/{mediatek => ralink}/gsw_mt7620.c | 0 .../net/ethernet/{mediatek => ralink}/gsw_mt7620.h | 0 .../net/ethernet/{mediatek => ralink}/gsw_mt7621.c | 0 .../net/ethernet/{mediatek => ralink}/mdio.c | 2 +- .../net/ethernet/{mediatek => ralink}/mdio.h | 2 +- .../ethernet/{mediatek => ralink}/mdio_mt7620.c | 0 .../ethernet/{mediatek => ralink}/mdio_rt2880.c | 0 .../ethernet/{mediatek => ralink}/mdio_rt2880.h | 0 .../net/ethernet/{mediatek => ralink}/mt7530.c | 0 .../net/ethernet/{mediatek => ralink}/mt7530.h | 0 .../ethernet/{mediatek => ralink}/mtk_debugfs.c | 0 .../ethernet/{mediatek => ralink}/mtk_eth_soc.c | 12 ++-- .../ethernet/{mediatek => ralink}/mtk_eth_soc.h | 0 .../ethernet/{mediatek => ralink}/mtk_offload.c | 6 +- .../ethernet/{mediatek => ralink}/mtk_offload.h | 0 .../net/ethernet/{mediatek => ralink}/soc_mt7620.c | 0 .../net/ethernet/{mediatek => ralink}/soc_mt7621.c | 0 .../net/ethernet/{mediatek => ralink}/soc_rt2880.c | 0 .../net/ethernet/{mediatek => ralink}/soc_rt3050.c | 0 .../net/ethernet/{mediatek => ralink}/soc_rt3883.c | 0 target/linux/ramips/mt7620/config-4.14 | 14 ++--- target/linux/ramips/mt7621/config-4.14 | 12 ++-- target/linux/ramips/mt76x8/config-4.14 | 10 ++-- .../patches-4.14/700-add-net-ethernet-ralink.patch | 20 +++++++ target/linux/ramips/rt288x/config-4.14 | 10 ++-- target/linux/ramips/rt305x/config-4.14 | 8 +-- target/linux/ramips/rt3883/config-4.14 | 10 ++-- 35 files changed, 156 insertions(+), 136 deletions(-) delete mode 100644 target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/Kconfig delete mode 100644 target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/Makefile create mode 100644 target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/Kconfig create mode 100644 target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/Makefile rename target/linux/ramips/files-4.14/drivers/net/ethernet/{mediatek => ralink}/esw_rt3050.c (100%) rename target/linux/ramips/files-4.14/drivers/net/ethernet/{mediatek => ralink}/esw_rt3050.h (95%) rename target/linux/ramips/files-4.14/drivers/net/ethernet/{mediatek => ralink}/ethtool.c (100%) rename target/linux/ramips/files-4.14/drivers/net/ethernet/{mediatek => ralink}/ethtool.h (100%) rename target/linux/ramips/files-4.14/drivers/net/ethernet/{mediatek => ralink}/gsw_mt7620.c (100%) rename target/linux/ramips/files-4.14/drivers/net/ethernet/{mediatek => ralink}/gsw_mt7620.h (100%) rename target/linux/ramips/files-4.14/drivers/net/ethernet/{mediatek => ralink}/gsw_mt7621.c (100%) rename target/linux/ramips/files-4.14/drivers/net/ethernet/{mediatek => ralink}/mdio.c (98%) rename target/linux/ramips/files-4.14/drivers/net/ethernet/{mediatek => ralink}/mdio.h (96%) rename target/linux/ramips/files-4.14/drivers/net/ethernet/{mediatek => ralink}/mdio_mt7620.c (100%) rename target/linux/ramips/files-4.14/drivers/net/ethernet/{mediatek => ralink}/mdio_rt2880.c (100%) rename target/linux/ramips/files-4.14/drivers/net/ethernet/{mediatek => ralink}/mdio_rt2880.h (100%) rename target/linux/ramips/files-4.14/drivers/net/ethernet/{mediatek => ralink}/mt7530.c (100%) rename target/linux/ramips/files-4.14/drivers/net/ethernet/{mediatek => ralink}/mt7530.h (100%) rename target/linux/ramips/files-4.14/drivers/net/ethernet/{mediatek => ralink}/mtk_debugfs.c (100%) rename target/linux/ramips/files-4.14/drivers/net/ethernet/{mediatek => ralink}/mtk_eth_soc.c (99%) rename target/linux/ramips/files-4.14/drivers/net/ethernet/{mediatek => ralink}/mtk_eth_soc.h (100%) rename target/linux/ramips/files-4.14/drivers/net/ethernet/{mediatek => ralink}/mtk_offload.c (99%) rename target/linux/ramips/files-4.14/drivers/net/ethernet/{mediatek => ralink}/mtk_offload.h (100%) rename target/linux/ramips/files-4.14/drivers/net/ethernet/{mediatek => ralink}/soc_mt7620.c (100%) rename target/linux/ramips/files-4.14/drivers/net/ethernet/{mediatek => ralink}/soc_mt7621.c (100%) rename target/linux/ramips/files-4.14/drivers/net/ethernet/{mediatek => ralink}/soc_rt2880.c (100%) rename target/linux/ramips/files-4.14/drivers/net/ethernet/{mediatek => ralink}/soc_rt3050.c (100%) rename target/linux/ramips/files-4.14/drivers/net/ethernet/{mediatek => ralink}/soc_rt3883.c (100%) create mode 100644 target/linux/ramips/patches-4.14/700-add-net-ethernet-ralink.patch diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/Kconfig b/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/Kconfig deleted file mode 100644 index 822806fd856f..000000000000 --- a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/Kconfig +++ /dev/null @@ -1,70 +0,0 @@ -config NET_VENDOR_MEDIATEK - tristate "Mediatek/Ralink ethernet driver" - depends on RALINK - help - This driver supports the ethernet mac inside the Mediatek and Ralink WiSoCs - -config NET_MEDIATEK_SOC - def_tristate NET_VENDOR_MEDIATEK - -if NET_MEDIATEK_SOC -choice - prompt "MAC type" - -config NET_MEDIATEK_RT2880 - bool "RT2882" - depends on MIPS && SOC_RT288X - -config NET_MEDIATEK_RT3050 - bool "RT3050/MT7628" - depends on MIPS && (SOC_RT305X || SOC_MT7620) - -config NET_MEDIATEK_RT3883 - bool "RT3883" - depends on MIPS && SOC_RT3883 - -config NET_MEDIATEK_MT7620 - bool "MT7620" - depends on MIPS && SOC_MT7620 - -config NET_MEDIATEK_MT7621 - bool "MT7621" - depends on MIPS && SOC_MT7621 - -endchoice - -config NET_MEDIATEK_OFFLOAD - def_bool NET_MEDIATEK_SOC - depends on NET_MEDIATEK_MT7621 - -config NET_MEDIATEK_HW_QOS - def_bool NET_MEDIATEK_SOC - depends on NET_MEDIATEK_MT7623 - -config NET_MEDIATEK_MDIO - def_bool NET_MEDIATEK_SOC - depends on (NET_MEDIATEK_RT2880 || NET_MEDIATEK_RT3883 || NET_MEDIATEK_MT7620 || NET_MEDIATEK_MT7621) - select PHYLIB - -config NET_MEDIATEK_MDIO_RT2880 - def_bool NET_MEDIATEK_SOC - depends on (NET_MEDIATEK_RT2880 || NET_MEDIATEK_RT3883) - select NET_MEDIATEK_MDIO - -config NET_MEDIATEK_MDIO_MT7620 - def_bool NET_MEDIATEK_SOC - depends on (NET_MEDIATEK_MT7620 || NET_MEDIATEK_MT7621) - select NET_MEDIATEK_MDIO - -config NET_MEDIATEK_ESW_RT3050 - def_tristate NET_MEDIATEK_SOC - depends on NET_MEDIATEK_RT3050 - -config NET_MEDIATEK_GSW_MT7620 - def_tristate NET_MEDIATEK_SOC - depends on NET_MEDIATEK_MT7620 - -config NET_MEDIATEK_GSW_MT7621 - def_tristate NET_MEDIATEK_SOC - depends on NET_MEDIATEK_MT7621 -endif diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/Makefile b/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/Makefile deleted file mode 100644 index b038ae369948..000000000000 --- a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/Makefile +++ /dev/null @@ -1,22 +0,0 @@ -# -# Makefile for the Ralink SoCs built-in ethernet macs -# - -mtk-eth-soc-y += mtk_eth_soc.o ethtool.o - -mtk-eth-soc-$(CONFIG_NET_MEDIATEK_MDIO) += mdio.o -mtk-eth-soc-$(CONFIG_NET_MEDIATEK_MDIO_RT2880) += mdio_rt2880.o -mtk-eth-soc-$(CONFIG_NET_MEDIATEK_MDIO_MT7620) += mdio_mt7620.o - -mtk-eth-soc-$(CONFIG_NET_MEDIATEK_OFFLOAD) += mtk_offload.o mtk_debugfs.o - -mtk-eth-soc-$(CONFIG_NET_MEDIATEK_RT2880) += soc_rt2880.o -mtk-eth-soc-$(CONFIG_NET_MEDIATEK_RT3050) += soc_rt3050.o -mtk-eth-soc-$(CONFIG_NET_MEDIATEK_RT3883) += soc_rt3883.o -mtk-eth-soc-$(CONFIG_NET_MEDIATEK_MT7620) += soc_mt7620.o -mtk-eth-soc-$(CONFIG_NET_MEDIATEK_MT7621) += soc_mt7621.o - -obj-$(CONFIG_NET_MEDIATEK_ESW_RT3050) += esw_rt3050.o -obj-$(CONFIG_NET_MEDIATEK_GSW_MT7620) += gsw_mt7620.o mt7530.o -obj-$(CONFIG_NET_MEDIATEK_GSW_MT7621) += gsw_mt7621.o mt7530.o -obj-$(CONFIG_NET_MEDIATEK_SOC) += mtk-eth-soc.o diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/Kconfig b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/Kconfig new file mode 100644 index 000000000000..9d413d2714bc --- /dev/null +++ b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/Kconfig @@ -0,0 +1,70 @@ +config NET_VENDOR_RALINK + tristate "Mediatek/Ralink ethernet driver" + depends on RALINK + help + This driver supports the ethernet mac inside the Mediatek and Ralink WiSoCs + +config NET_RALINK_SOC + def_tristate NET_VENDOR_RALINK + +if NET_RALINK_SOC +choice + prompt "MAC type" + +config NET_RALINK_RT2880 + bool "RT2882" + depends on MIPS && SOC_RT288X + +config NET_RALINK_RT3050 + bool "RT3050/MT7628" + depends on MIPS && (SOC_RT305X || SOC_MT7620) + +config NET_RALINK_RT3883 + bool "RT3883" + depends on MIPS && SOC_RT3883 + +config NET_RALINK_MT7620 + bool "MT7620" + depends on MIPS && SOC_MT7620 + +config NET_RALINK_MT7621 + bool "MT7621" + depends on MIPS && SOC_MT7621 + +endchoice + +config NET_RALINK_OFFLOAD + def_bool NET_RALINK_SOC + depends on NET_RALINK_MT7621 + +config NET_RALINK_HW_QOS + def_bool NET_RALINK_SOC + depends on NET_RALINK_MT7623 + +config NET_RALINK_MDIO + def_bool NET_RALINK_SOC + depends on (NET_RALINK_RT2880 || NET_RALINK_RT3883 || NET_RALINK_MT7620 || NET_RALINK_MT7621) + select PHYLIB + +config NET_RALINK_MDIO_RT2880 + def_bool NET_RALINK_SOC + depends on (NET_RALINK_RT2880 || NET_RALINK_RT3883) + select NET_RALINK_MDIO + +config NET_RALINK_MDIO_MT7620 + def_bool NET_RALINK_SOC + depends on (NET_RALINK_MT7620 || NET_RALINK_MT7621) + select NET_RALINK_MDIO + +config NET_RALINK_ESW_RT3050 + def_tristate NET_RALINK_SOC + depends on NET_RALINK_RT3050 + +config NET_RALINK_GSW_MT7620 + def_tristate NET_RALINK_SOC + depends on NET_RALINK_MT7620 + +config NET_RALINK_GSW_MT7621 + def_tristate NET_RALINK_SOC + depends on NET_RALINK_MT7621 +endif diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/Makefile b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/Makefile new file mode 100644 index 000000000000..9dccb8fa6e81 --- /dev/null +++ b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/Makefile @@ -0,0 +1,22 @@ +# +# Makefile for the Ralink SoCs built-in ethernet macs +# + +mtk-eth-soc-y += mtk_eth_soc.o ethtool.o + +mtk-eth-soc-$(CONFIG_NET_RALINK_MDIO) += mdio.o +mtk-eth-soc-$(CONFIG_NET_RALINK_MDIO_RT2880) += mdio_rt2880.o +mtk-eth-soc-$(CONFIG_NET_RALINK_MDIO_MT7620) += mdio_mt7620.o + +mtk-eth-soc-$(CONFIG_NET_RALINK_OFFLOAD) += mtk_offload.o mtk_debugfs.o + +mtk-eth-soc-$(CONFIG_NET_RALINK_RT2880) += soc_rt2880.o +mtk-eth-soc-$(CONFIG_NET_RALINK_RT3050) += soc_rt3050.o +mtk-eth-soc-$(CONFIG_NET_RALINK_RT3883) += soc_rt3883.o +mtk-eth-soc-$(CONFIG_NET_RALINK_MT7620) += soc_mt7620.o +mtk-eth-soc-$(CONFIG_NET_RALINK_MT7621) += soc_mt7621.o + +obj-$(CONFIG_NET_RALINK_ESW_RT3050) += esw_rt3050.o +obj-$(CONFIG_NET_RALINK_GSW_MT7620) += gsw_mt7620.o mt7530.o +obj-$(CONFIG_NET_RALINK_GSW_MT7621) += gsw_mt7621.o mt7530.o +obj-$(CONFIG_NET_RALINK_SOC) += mtk-eth-soc.o diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/esw_rt3050.c b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/esw_rt3050.c similarity index 100% rename from target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/esw_rt3050.c rename to target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/esw_rt3050.c diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/esw_rt3050.h b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/esw_rt3050.h similarity index 95% rename from target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/esw_rt3050.h rename to target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/esw_rt3050.h index b757e5d63946..bbc8fbd52a40 100644 --- a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/esw_rt3050.h +++ b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/esw_rt3050.h @@ -15,7 +15,7 @@ #ifndef _RALINK_ESW_RT3052_H__ #define _RALINK_ESW_RT3052_H__ -#ifdef CONFIG_NET_MEDIATEK_ESW_RT3052 +#ifdef CONFIG_NET_RALINK_ESW_RT3052 int __init mtk_switch_init(void); void mtk_switch_exit(void); diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/ethtool.c b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/ethtool.c similarity index 100% rename from target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/ethtool.c rename to target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/ethtool.c diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/ethtool.h b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/ethtool.h similarity index 100% rename from target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/ethtool.h rename to target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/ethtool.h diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/gsw_mt7620.c b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/gsw_mt7620.c similarity index 100% rename from target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/gsw_mt7620.c rename to target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/gsw_mt7620.c diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/gsw_mt7620.h b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/gsw_mt7620.h similarity index 100% rename from target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/gsw_mt7620.h rename to target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/gsw_mt7620.h diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/gsw_mt7621.c b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/gsw_mt7621.c similarity index 100% rename from target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/gsw_mt7621.c rename to target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/gsw_mt7621.c diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mdio.c b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mdio.c similarity index 98% rename from target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mdio.c rename to target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mdio.c index a1c115687ec5..e2c3a30cec1c 100644 --- a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mdio.c +++ b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mdio.c @@ -110,7 +110,7 @@ static void phy_init(struct fe_priv *priv, struct phy_device *phy) phy->autoneg = AUTONEG_ENABLE; phy->speed = 0; phy->duplex = 0; - phy->supported &= IS_ENABLED(CONFIG_NET_MEDIATEK_MDIO_MT7620) ? + phy->supported &= IS_ENABLED(CONFIG_NET_RALINK_MDIO_MT7620) ? PHY_GBIT_FEATURES : PHY_BASIC_FEATURES; phy->advertising = phy->supported | ADVERTISED_Autoneg; diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mdio.h b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mdio.h similarity index 96% rename from target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mdio.h rename to target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mdio.h index 498cf144e631..ca00180af85a 100644 --- a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mdio.h +++ b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mdio.h @@ -15,7 +15,7 @@ #ifndef _RALINK_MDIO_H__ #define _RALINK_MDIO_H__ -#ifdef CONFIG_NET_MEDIATEK_MDIO +#ifdef CONFIG_NET_RALINK_MDIO int fe_mdio_init(struct fe_priv *priv); void fe_mdio_cleanup(struct fe_priv *priv); int fe_connect_phy_node(struct fe_priv *priv, diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mdio_mt7620.c b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mdio_mt7620.c similarity index 100% rename from target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mdio_mt7620.c rename to target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mdio_mt7620.c diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mdio_rt2880.c b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mdio_rt2880.c similarity index 100% rename from target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mdio_rt2880.c rename to target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mdio_rt2880.c diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mdio_rt2880.h b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mdio_rt2880.h similarity index 100% rename from target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mdio_rt2880.h rename to target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mdio_rt2880.h diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mt7530.c b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mt7530.c similarity index 100% rename from target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mt7530.c rename to target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mt7530.c diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mt7530.h b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mt7530.h similarity index 100% rename from target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mt7530.h rename to target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mt7530.h diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mtk_debugfs.c b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mtk_debugfs.c similarity index 100% rename from target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mtk_debugfs.c rename to target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mtk_debugfs.c diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mtk_eth_soc.c similarity index 99% rename from target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mtk_eth_soc.c rename to target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mtk_eth_soc.c index e0bc0ab818c4..5455e2fa062f 100644 --- a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mtk_eth_soc.c @@ -933,14 +933,14 @@ static int fe_poll_rx(struct napi_struct *napi, int budget, skb_checksum_none_assert(skb); skb->protocol = eth_type_trans(skb, netdev); -#ifdef CONFIG_NET_MEDIATEK_OFFLOAD +#ifdef CONFIG_NET_RALINK_OFFLOAD if (mtk_offload_check_rx(priv, skb, trxd.rxd4) == 0) { #endif stats->rx_packets++; stats->rx_bytes += pktlen; napi_gro_receive(napi, skb); -#ifdef CONFIG_NET_MEDIATEK_OFFLOAD +#ifdef CONFIG_NET_RALINK_OFFLOAD } else { dev_kfree_skb(skb); } @@ -1282,7 +1282,7 @@ static int fe_open(struct net_device *dev) napi_enable(&priv->rx_napi); fe_int_enable(priv->soc->tx_int | priv->soc->rx_int); netif_start_queue(dev); -#ifdef CONFIG_NET_MEDIATEK_OFFLOAD +#ifdef CONFIG_NET_RALINK_OFFLOAD mtk_ppe_probe(priv); #endif @@ -1321,7 +1321,7 @@ static int fe_stop(struct net_device *dev) fe_free_dma(priv); -#ifdef CONFIG_NET_MEDIATEK_OFFLOAD +#ifdef CONFIG_NET_RALINK_OFFLOAD mtk_ppe_remove(priv); #endif @@ -1465,7 +1465,7 @@ static int fe_change_mtu(struct net_device *dev, int new_mtu) return fe_open(dev); } -#ifdef CONFIG_NET_MEDIATEK_OFFLOAD +#ifdef CONFIG_NET_RALINK_OFFLOAD static int fe_flow_offload(enum flow_offload_type type, struct flow_offload *flow, struct flow_offload_hw_path *src, @@ -1499,7 +1499,7 @@ static const struct net_device_ops fe_netdev_ops = { #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = fe_poll_controller, #endif -#ifdef CONFIG_NET_MEDIATEK_OFFLOAD +#ifdef CONFIG_NET_RALINK_OFFLOAD .ndo_flow_offload = fe_flow_offload, #endif }; diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mtk_eth_soc.h b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mtk_eth_soc.h similarity index 100% rename from target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mtk_eth_soc.h rename to target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mtk_eth_soc.h diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mtk_offload.c b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mtk_offload.c similarity index 99% rename from target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mtk_offload.c rename to target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mtk_offload.c index 3001c081f7c4..9dab5e03be77 100644 --- a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mtk_offload.c +++ b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mtk_offload.c @@ -60,7 +60,7 @@ mtk_foe_prepare_v4(struct mtk_foe_entry *entry, entry->ipv4_hnapt.iblk2.dscp = 0; entry->ipv4_hnapt.iblk2.port_mg = 0x3f; entry->ipv4_hnapt.iblk2.port_ag = 0x1f; -#ifdef CONFIG_NET_MEDIATEK_HW_QOS +#ifdef CONFIG_NET_RALINK_HW_QOS entry->ipv4_hnapt.iblk2.qid = 1; entry->ipv4_hnapt.iblk2.fqos = 1; #endif @@ -188,7 +188,7 @@ write: return 0; } -#ifdef CONFIG_NET_MEDIATEK_HW_QOS +#ifdef CONFIG_NET_RALINK_HW_QOS #define QDMA_TX_SCH_TX 0x1a14 @@ -379,7 +379,7 @@ static int mtk_ppe_start(struct mtk_eth *eth) dev_info(eth->dev, "PPE started\n"); -#ifdef CONFIG_NET_MEDIATEK_HW_QOS +#ifdef CONFIG_NET_RALINK_HW_QOS mtk_ppe_scheduler(eth, 0, 500000); mtk_ppe_scheduler(eth, 1, 500000); mtk_ppe_queue(eth, 0, 0, 7, 32, 250000, 0); diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mtk_offload.h b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mtk_offload.h similarity index 100% rename from target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/mtk_offload.h rename to target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/mtk_offload.h diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/soc_mt7620.c b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/soc_mt7620.c similarity index 100% rename from target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/soc_mt7620.c rename to target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/soc_mt7620.c diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/soc_mt7621.c b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/soc_mt7621.c similarity index 100% rename from target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/soc_mt7621.c rename to target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/soc_mt7621.c diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/soc_rt2880.c b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/soc_rt2880.c similarity index 100% rename from target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/soc_rt2880.c rename to target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/soc_rt2880.c diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/soc_rt3050.c b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/soc_rt3050.c similarity index 100% rename from target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/soc_rt3050.c rename to target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/soc_rt3050.c diff --git a/target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/soc_rt3883.c b/target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/soc_rt3883.c similarity index 100% rename from target/linux/ramips/files-4.14/drivers/net/ethernet/mediatek/soc_rt3883.c rename to target/linux/ramips/files-4.14/drivers/net/ethernet/ralink/soc_rt3883.c diff --git a/target/linux/ramips/mt7620/config-4.14 b/target/linux/ramips/mt7620/config-4.14 index 1162ed47b282..639766ecc4a6 100644 --- a/target/linux/ramips/mt7620/config-4.14 +++ b/target/linux/ramips/mt7620/config-4.14 @@ -163,13 +163,13 @@ CONFIG_MTD_SPLIT_TPLINK_FW=y CONFIG_MTD_SPLIT_UIMAGE_FW=y CONFIG_NEED_DMA_MAP_STATE=y CONFIG_NEED_PER_CPU_KM=y -CONFIG_NET_MEDIATEK_GSW_MT7620=y -CONFIG_NET_MEDIATEK_MDIO=y -CONFIG_NET_MEDIATEK_MDIO_MT7620=y -CONFIG_NET_MEDIATEK_MT7620=y -# CONFIG_NET_MEDIATEK_RT3050 is not set -CONFIG_NET_MEDIATEK_SOC=y -CONFIG_NET_VENDOR_MEDIATEK=y +CONFIG_NET_RALINK_GSW_MT7620=y +CONFIG_NET_RALINK_MDIO=y +CONFIG_NET_RALINK_MDIO_MT7620=y +CONFIG_NET_RALINK_MT7620=y +# CONFIG_NET_RALINK_RT3050 is not set +CONFIG_NET_RALINK_SOC=y +CONFIG_NET_VENDOR_RALINK=y CONFIG_NO_GENERIC_PCI_IOPORT_MAP=y # CONFIG_NO_IOPORT_MAP is not set CONFIG_OF=y diff --git a/target/linux/ramips/mt7621/config-4.14 b/target/linux/ramips/mt7621/config-4.14 index 0e060237802f..07e0ec5038c5 100644 --- a/target/linux/ramips/mt7621/config-4.14 +++ b/target/linux/ramips/mt7621/config-4.14 @@ -186,12 +186,12 @@ CONFIG_MTD_UBI_WL_THRESHOLD=4096 CONFIG_MTK_MTD_NAND=y CONFIG_NEED_DMA_MAP_STATE=y CONFIG_NET_FLOW_LIMIT=y -CONFIG_NET_MEDIATEK_GSW_MT7621=y -CONFIG_NET_MEDIATEK_MDIO=y -CONFIG_NET_MEDIATEK_MDIO_MT7620=y -CONFIG_NET_MEDIATEK_MT7621=y -CONFIG_NET_MEDIATEK_SOC=y -CONFIG_NET_VENDOR_MEDIATEK=y +CONFIG_NET_RALINK_GSW_MT7621=y +CONFIG_NET_RALINK_MDIO=y +CONFIG_NET_RALINK_MDIO_MT7620=y +CONFIG_NET_RALINK_MT7621=y +CONFIG_NET_RALINK_SOC=y +CONFIG_NET_VENDOR_RALINK=y CONFIG_NO_GENERIC_PCI_IOPORT_MAP=y # CONFIG_NO_IOPORT_MAP is not set CONFIG_NR_CPUS=4 diff --git a/target/linux/ramips/mt76x8/config-4.14 b/target/linux/ramips/mt76x8/config-4.14 index 81e08489315d..3f2e91ede666 100644 --- a/target/linux/ramips/mt76x8/config-4.14 +++ b/target/linux/ramips/mt76x8/config-4.14 @@ -159,11 +159,11 @@ CONFIG_MTD_SPLIT_TRX_FW=y CONFIG_MTD_SPLIT_UIMAGE_FW=y CONFIG_NEED_DMA_MAP_STATE=y CONFIG_NEED_PER_CPU_KM=y -CONFIG_NET_MEDIATEK_ESW_RT3050=y -# CONFIG_NET_MEDIATEK_MT7620 is not set -CONFIG_NET_MEDIATEK_RT3050=y -CONFIG_NET_MEDIATEK_SOC=y -CONFIG_NET_VENDOR_MEDIATEK=y +CONFIG_NET_RALINK_ESW_RT3050=y +# CONFIG_NET_RALINK_MT7620 is not set +CONFIG_NET_RALINK_RT3050=y +CONFIG_NET_RALINK_SOC=y +CONFIG_NET_VENDOR_RALINK=y CONFIG_NO_GENERIC_PCI_IOPORT_MAP=y # CONFIG_NO_IOPORT_MAP is not set CONFIG_OF=y diff --git a/target/linux/ramips/patches-4.14/700-add-net-ethernet-ralink.patch b/target/linux/ramips/patches-4.14/700-add-net-ethernet-ralink.patch new file mode 100644 index 000000000000..b662fe5e6f23 --- /dev/null +++ b/target/linux/ramips/patches-4.14/700-add-net-ethernet-ralink.patch @@ -0,0 +1,20 @@ +--- a/drivers/net/ethernet/Kconfig ++++ b/drivers/net/ethernet/Kconfig +@@ -159,6 +159,7 @@ source "drivers/net/ethernet/packetengin + source "drivers/net/ethernet/pasemi/Kconfig" + source "drivers/net/ethernet/qlogic/Kconfig" + source "drivers/net/ethernet/qualcomm/Kconfig" ++source "drivers/net/ethernet/ralink/Kconfig" + source "drivers/net/ethernet/realtek/Kconfig" + source "drivers/net/ethernet/renesas/Kconfig" + source "drivers/net/ethernet/rdc/Kconfig" +--- a/drivers/net/ethernet/Makefile ++++ b/drivers/net/ethernet/Makefile +@@ -70,6 +70,7 @@ obj-$(CONFIG_NET_PACKET_ENGINE) += packe + obj-$(CONFIG_NET_VENDOR_PASEMI) += pasemi/ + obj-$(CONFIG_NET_VENDOR_QLOGIC) += qlogic/ + obj-$(CONFIG_NET_VENDOR_QUALCOMM) += qualcomm/ ++obj-$(CONFIG_NET_VENDOR_RALINK) += ralink/ + obj-$(CONFIG_NET_VENDOR_REALTEK) += realtek/ + obj-$(CONFIG_NET_VENDOR_RENESAS) += renesas/ + obj-$(CONFIG_NET_VENDOR_RDC) += rdc/ diff --git a/target/linux/ramips/rt288x/config-4.14 b/target/linux/ramips/rt288x/config-4.14 index de4dffe885cf..2676a819463c 100644 --- a/target/linux/ramips/rt288x/config-4.14 +++ b/target/linux/ramips/rt288x/config-4.14 @@ -150,11 +150,11 @@ CONFIG_MTD_SPLIT_UIMAGE_FW=y CONFIG_MTD_SPLIT_WRGG_FW=y CONFIG_NEED_DMA_MAP_STATE=y CONFIG_NEED_PER_CPU_KM=y -CONFIG_NET_MEDIATEK_MDIO=y -CONFIG_NET_MEDIATEK_MDIO_RT2880=y -CONFIG_NET_MEDIATEK_RT2880=y -CONFIG_NET_MEDIATEK_SOC=y -CONFIG_NET_VENDOR_MEDIATEK=y +CONFIG_NET_RALINK_MDIO=y +CONFIG_NET_RALINK_MDIO_RT2880=y +CONFIG_NET_RALINK_RT2880=y +CONFIG_NET_RALINK_SOC=y +CONFIG_NET_VENDOR_RALINK=y CONFIG_NLS=m CONFIG_NO_GENERIC_PCI_IOPORT_MAP=y # CONFIG_NO_IOPORT_MAP is not set diff --git a/target/linux/ramips/rt305x/config-4.14 b/target/linux/ramips/rt305x/config-4.14 index 346a8a8814f7..27969e8819a0 100644 --- a/target/linux/ramips/rt305x/config-4.14 +++ b/target/linux/ramips/rt305x/config-4.14 @@ -141,10 +141,10 @@ CONFIG_MTD_SPLIT_SEAMA_FW=y CONFIG_MTD_SPLIT_UIMAGE_FW=y CONFIG_NEED_DMA_MAP_STATE=y CONFIG_NEED_PER_CPU_KM=y -CONFIG_NET_MEDIATEK_ESW_RT3050=y -CONFIG_NET_MEDIATEK_RT3050=y -CONFIG_NET_MEDIATEK_SOC=y -CONFIG_NET_VENDOR_MEDIATEK=y +CONFIG_NET_RALINK_ESW_RT3050=y +CONFIG_NET_RALINK_RT3050=y +CONFIG_NET_RALINK_SOC=y +CONFIG_NET_VENDOR_RALINK=y CONFIG_NO_GENERIC_PCI_IOPORT_MAP=y # CONFIG_NO_IOPORT_MAP is not set CONFIG_OF=y diff --git a/target/linux/ramips/rt3883/config-4.14 b/target/linux/ramips/rt3883/config-4.14 index 93d803e2edef..94163d52afa6 100644 --- a/target/linux/ramips/rt3883/config-4.14 +++ b/target/linux/ramips/rt3883/config-4.14 @@ -155,11 +155,11 @@ CONFIG_MTD_SPLIT_SEAMA_FW=y CONFIG_MTD_SPLIT_UIMAGE_FW=y CONFIG_NEED_DMA_MAP_STATE=y CONFIG_NEED_PER_CPU_KM=y -CONFIG_NET_MEDIATEK_MDIO=y -CONFIG_NET_MEDIATEK_MDIO_RT2880=y -CONFIG_NET_MEDIATEK_RT3883=y -CONFIG_NET_MEDIATEK_SOC=y -CONFIG_NET_VENDOR_MEDIATEK=y +CONFIG_NET_RALINK_MDIO=y +CONFIG_NET_RALINK_MDIO_RT2880=y +CONFIG_NET_RALINK_RT3883=y +CONFIG_NET_RALINK_SOC=y +CONFIG_NET_VENDOR_RALINK=y CONFIG_NO_GENERIC_PCI_IOPORT_MAP=y # CONFIG_NO_IOPORT_MAP is not set CONFIG_OF=y From patchwork Mon Oct 15 10:24:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Bj=C3=B8rn_Mork?= X-Patchwork-Id: 984085 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mork.no Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="pb4GU2wN"; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=mork.no header.i=@mork.no header.b="g80AGR8S"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YZVh3y29z9s5c for ; Mon, 15 Oct 2018 21:31:40 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=htZQW+/47cir70MlnJLs/Q+yDDfdFGpIr6MT1KN51tk=; b=pb4GU2wNpUf9Oz W0ubiL/FHg3wmQ6gzAPWS0OZJUN8/lnRdLFFFpjcUGX7OK/WWzA7TNj5ygjCXbjgIWE1ahTTqFdah KNxk4PFoSfzkCnwGmSlcMwEra954+39+88p2ARoYrgLaiPx4ScO/FBVwhsYnajFKYXQdhO2putJMN SorglsadBgNpv4wF8BJkNlB7UVfQO2qN2RwN1GimDfcyRJsTv/7t3w4/yerpCsoH5Y/R6bi3zLflD XOkRwlHckjOGqP5uEn/wvYgJZRW2kPg9sOpC8err3rEGa5EkqqzYe6HUdZQUp279LVd7sEoR8gk2p 8WS4h9dRNEXziqeqCFpA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gC09r-0006QI-LF; Mon, 15 Oct 2018 10:31:31 +0000 Received: from canardo.mork.no ([2001:4641::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gC04D-0002Ww-0B for openwrt-devel@lists.openwrt.org; Mon, 15 Oct 2018 10:26:40 +0000 Received: from canardo.mork.no (ip6-localhost [IPv6:0:0:0:0:0:0:0:1]) by canardo.mork.no (8.15.2/8.15.2) with ESMTPS id w9FAPNRk030837 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 15 Oct 2018 12:25:23 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mork.no; s=b; t=1539599123; bh=Lb/LS7SXBBDrcqRXfd+Isdf4Ag4CnEPHuRV6EjaUOFI=; h=From:To:Cc:Subject:Date:Message-Id:References:From; b=g80AGR8SZ6DLmMgKu9YMn8osyZBcKM0hheXewE44GWXzIhlFI6sWX74prbX7MaqJI 11wvHijWX7KIXjs4M/bfC1d0sGkcBCYgVEa/ccKCBvhZEk/bD2lztxwCWKnsvJw3Yf /pSvJwkX7daJV9t3W5i9MbUOdKOs6AUM+Tq40dHg= Received: (from bjorn@localhost) by canardo.mork.no (8.15.2/8.15.2/Submit) id w9FAPNl1030828; Mon, 15 Oct 2018 12:25:23 +0200 From: =?utf-8?q?Bj=C3=B8rn_Mork?= To: OpenWrt Development List Date: Mon, 15 Oct 2018 12:24:58 +0200 Message-Id: <20181015102503.30731-5-bjorn@mork.no> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181015102503.30731-1-bjorn@mork.no> References: <20181015102503.30731-1-bjorn@mork.no> MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on canardo.mork.no X-Virus-Scanned: clamav-milter 0.100.1 at canardo X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181015_032542_091980_AD4DBB2C X-CRM114-Status: GOOD ( 27.16 ) X-Spam-Score: -2.4 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [2001:4641:0:0:0:0:0:1 listed in] [list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Subject: [OpenWrt-Devel] [RFC 4/9] mt7621: import mtk_eth_soc and mt7530 patches from the mediatek target X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Bj=C3=B8rn_Mork?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org This syncronizes most of the mtk_eth_soc and mt7530 patches between the two targets, with the following exception: 0045-net-dsa-mediatek-turn-into-platform-driver.patch which will require more changes to the mt7621 device-trees than the absolute minimum. Signed-off-by: Bjørn Mork --- .../0027-net-next-mediatek-fix-DQL-support.patch | 92 +++++++ ...iatek-add-support-for-GMAC2-wired-to-ext-.patch | 26 ++ .../ramips/patches-4.14/0033-dsa-multi-cpu.patch | 268 +++++++++++++++++++++ ...5-net-mediatek-disable-RX-VLan-offloading.patch | 47 ++++ ...diatek-honour-special-tag-bit-inside-RX-D.patch | 50 ++++ ...diatek-enable-special-tag-indication-for-.patch | 41 ++++ ...a-mediatek-tell-GDMA-when-we-are-turning-.patch | 43 ++++ .../0046-net-mediatek-add-irq-delay.patch | 21 ++ .../0051-net-mediatek-increase-tx_timeout.patch | 21 ++ .../ramips/patches-4.14/0062-mdio-atomic.patch | 14 ++ .../ramips/patches-4.14/0063-atomic-sleep.patch | 46 ++++ ...k-remove-superfluous-pin-setup-for-MT7622.patch | 102 ++++++++ 12 files changed, 771 insertions(+) create mode 100644 target/linux/ramips/patches-4.14/0027-net-next-mediatek-fix-DQL-support.patch create mode 100644 target/linux/ramips/patches-4.14/0032-net-dsa-mediatek-add-support-for-GMAC2-wired-to-ext-.patch create mode 100644 target/linux/ramips/patches-4.14/0033-dsa-multi-cpu.patch create mode 100644 target/linux/ramips/patches-4.14/0035-net-mediatek-disable-RX-VLan-offloading.patch create mode 100644 target/linux/ramips/patches-4.14/0042-net-next-mediatek-honour-special-tag-bit-inside-RX-D.patch create mode 100644 target/linux/ramips/patches-4.14/0043-net-next-mediatek-enable-special-tag-indication-for-.patch create mode 100644 target/linux/ramips/patches-4.14/0044-net-next-dsa-mediatek-tell-GDMA-when-we-are-turning-.patch create mode 100644 target/linux/ramips/patches-4.14/0046-net-mediatek-add-irq-delay.patch create mode 100644 target/linux/ramips/patches-4.14/0051-net-mediatek-increase-tx_timeout.patch create mode 100644 target/linux/ramips/patches-4.14/0062-mdio-atomic.patch create mode 100644 target/linux/ramips/patches-4.14/0063-atomic-sleep.patch create mode 100644 target/linux/ramips/patches-4.14/0175-net-mediatek-remove-superfluous-pin-setup-for-MT7622.patch diff --git a/target/linux/ramips/patches-4.14/0027-net-next-mediatek-fix-DQL-support.patch b/target/linux/ramips/patches-4.14/0027-net-next-mediatek-fix-DQL-support.patch new file mode 100644 index 000000000000..3ea2f456a8ce --- /dev/null +++ b/target/linux/ramips/patches-4.14/0027-net-next-mediatek-fix-DQL-support.patch @@ -0,0 +1,92 @@ +From f974e397b806f7b16d11cc1542538616291924f1 Mon Sep 17 00:00:00 2001 +From: John Crispin +Date: Sat, 23 Apr 2016 11:57:21 +0200 +Subject: [PATCH 27/57] net-next: mediatek: fix DQL support + +The MTK ethernet core has 2 MACs both sitting on the same DMA ring. The +current code will assign the TX traffic of each MAC to its own DQL. This +results in the amount of data, that DQL says is in the queue incorrect. As +the data from multiple devices is infact enqueued. This makes any decision +based on these value non deterministic. Fix this by tracking all TX +traffic, regardless of the MAC it belongs to in the DQL of all devices +using the DMA. + +Signed-off-by: John Crispin +--- + drivers/net/ethernet/mediatek/mtk_eth_soc.c | 35 +++++++++++++++++------------ + 1 file changed, 21 insertions(+), 14 deletions(-) + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -779,7 +779,16 @@ static int mtk_tx_map(struct sk_buff *sk + WRITE_ONCE(itxd->txd3, (TX_DMA_SWC | TX_DMA_PLEN0(skb_headlen(skb)) | + (!nr_frags * TX_DMA_LS0))); + +- netdev_sent_queue(dev, skb->len); ++ /* we have a single DMA ring so BQL needs to be updated for all devices ++ * sitting on this ring ++ */ ++ for (i = 0; i < MTK_MAC_COUNT; i++) { ++ if (!eth->netdev[i]) ++ continue; ++ ++ netdev_sent_queue(eth->netdev[i], skb->len); ++ } ++ + skb_tx_timestamp(skb); + + ring->next_free = mtk_qdma_phys_to_virt(ring, txd->txd2); +@@ -1076,20 +1085,17 @@ static int mtk_poll_tx(struct mtk_eth *e + struct mtk_tx_dma *desc; + struct sk_buff *skb; + struct mtk_tx_buf *tx_buf; +- unsigned int done[MTK_MAX_DEVS]; +- unsigned int bytes[MTK_MAX_DEVS]; ++ int total = 0, done = 0; ++ unsigned int bytes = 0; + u32 cpu, dma; +- int total = 0, i; +- +- memset(done, 0, sizeof(done)); +- memset(bytes, 0, sizeof(bytes)); ++ int i; + + cpu = mtk_r32(eth, MTK_QTX_CRX_PTR); + dma = mtk_r32(eth, MTK_QTX_DRX_PTR); + + desc = mtk_qdma_phys_to_virt(ring, cpu); + +- while ((cpu != dma) && budget) { ++ while ((cpu != dma) && (done < budget)) { + u32 next_cpu = desc->txd2; + int mac = 0; + +@@ -1106,9 +1112,8 @@ static int mtk_poll_tx(struct mtk_eth *e + break; + + if (skb != (struct sk_buff *)MTK_DMA_DUMMY_DESC) { +- bytes[mac] += skb->len; +- done[mac]++; +- budget--; ++ bytes += skb->len; ++ done++; + } + mtk_tx_unmap(eth, tx_buf); + +@@ -1120,11 +1125,13 @@ static int mtk_poll_tx(struct mtk_eth *e + + mtk_w32(eth, cpu, MTK_QTX_CRX_PTR); + ++ /* we have a single DMA ring so BQL needs to be updated for all devices ++ * sitting on this ring ++ */ + for (i = 0; i < MTK_MAC_COUNT; i++) { +- if (!eth->netdev[i] || !done[i]) ++ if (!eth->netdev[i]) + continue; +- netdev_completed_queue(eth->netdev[i], done[i], bytes[i]); +- total += done[i]; ++ netdev_completed_queue(eth->netdev[i], done, bytes); + } + + if (mtk_queue_stopped(eth) && diff --git a/target/linux/ramips/patches-4.14/0032-net-dsa-mediatek-add-support-for-GMAC2-wired-to-ext-.patch b/target/linux/ramips/patches-4.14/0032-net-dsa-mediatek-add-support-for-GMAC2-wired-to-ext-.patch new file mode 100644 index 000000000000..c01703d07b8b --- /dev/null +++ b/target/linux/ramips/patches-4.14/0032-net-dsa-mediatek-add-support-for-GMAC2-wired-to-ext-.patch @@ -0,0 +1,26 @@ +From 52e9ce30a2b3c414e0efb20632fefa7cfc5096e6 Mon Sep 17 00:00:00 2001 +From: John Crispin +Date: Thu, 10 Aug 2017 14:44:18 +0200 +Subject: [PATCH 32/57] net: dsa: mediatek: add support for GMAC2 wired to ext + phy + +Signed-off-by: John Crispin +--- + drivers/net/dsa/mt7530.c | 5 +++++ + drivers/net/ethernet/mediatek/mtk_eth_soc.c | 3 +++ + 2 files changed, 8 insertions(+) + +--- a/drivers/net/dsa/mt7530.c ++++ b/drivers/net/dsa/mt7530.c +@@ -991,6 +991,11 @@ mt7530_setup(struct dsa_switch *ds) + val = mt7530_read(priv, MT7530_MHWTRAP); + val &= ~MHWTRAP_P6_DIS & ~MHWTRAP_PHY_ACCESS; + val |= MHWTRAP_MANUAL; ++ if (!dsa_is_cpu_port(ds, 5)) { ++ val |= MHWTRAP_P5_DIS; ++ val |= MHWTRAP_P5_MAC_SEL; ++ val |= MHWTRAP_P5_RGMII_MODE; ++ } + mt7530_write(priv, MT7530_MHWTRAP, val); + + /* Enable and reset MIB counters */ diff --git a/target/linux/ramips/patches-4.14/0033-dsa-multi-cpu.patch b/target/linux/ramips/patches-4.14/0033-dsa-multi-cpu.patch new file mode 100644 index 000000000000..926e0d842169 --- /dev/null +++ b/target/linux/ramips/patches-4.14/0033-dsa-multi-cpu.patch @@ -0,0 +1,268 @@ +--- a/drivers/net/dsa/mt7530.c ++++ b/drivers/net/dsa/mt7530.c +@@ -670,6 +670,9 @@ static int + mt7530_cpu_port_enable(struct mt7530_priv *priv, + int port) + { ++ u8 port_mask = 0; ++ int i; ++ + /* Enable Mediatek header mode on the cpu port */ + mt7530_write(priv, MT7530_PVC_P(port), + PORT_SPEC_TAG); +@@ -686,8 +689,12 @@ mt7530_cpu_port_enable(struct mt7530_pri + /* CPU port gets connected to all user ports of + * the switch + */ ++ for (i = 0; i < MT7530_NUM_PORTS; i++) ++ if ((priv->ds->enabled_port_mask & BIT(i)) && ++ (dsa_port_upstream_port(priv->ds, i) == port)) ++ port_mask |= BIT(i); + mt7530_write(priv, MT7530_PCR_P(port), +- PCR_MATRIX(priv->ds->enabled_port_mask)); ++ PCR_MATRIX(port_mask)); + + return 0; + } +@@ -697,6 +704,7 @@ mt7530_port_enable(struct dsa_switch *ds + struct phy_device *phy) + { + struct mt7530_priv *priv = ds->priv; ++ u8 upstream = dsa_port_upstream_port(ds, port); + + mutex_lock(&priv->reg_mutex); + +@@ -707,7 +715,7 @@ mt7530_port_enable(struct dsa_switch *ds + * restore the port matrix if the port is the member of a certain + * bridge. + */ +- priv->ports[port].pm |= PCR_MATRIX(BIT(MT7530_CPU_PORT)); ++ priv->ports[port].pm |= PCR_MATRIX(BIT(upstream)); + priv->ports[port].enable = true; + mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK, + priv->ports[port].pm); +@@ -770,7 +778,8 @@ mt7530_port_bridge_join(struct dsa_switc + struct net_device *bridge) + { + struct mt7530_priv *priv = ds->priv; +- u32 port_bitmap = BIT(MT7530_CPU_PORT); ++ u8 upstream = dsa_port_upstream_port(ds, port); ++ u32 port_bitmap = BIT(upstream); + int i; + + mutex_lock(&priv->reg_mutex); +@@ -808,6 +817,7 @@ mt7530_port_bridge_leave(struct dsa_swit + struct net_device *bridge) + { + struct mt7530_priv *priv = ds->priv; ++ u8 upstream = dsa_port_upstream_port(ds, port); + int i; + + mutex_lock(&priv->reg_mutex); +@@ -832,8 +842,8 @@ mt7530_port_bridge_leave(struct dsa_swit + */ + if (priv->ports[port].enable) + mt7530_rmw(priv, MT7530_PCR_P(port), PCR_MATRIX_MASK, +- PCR_MATRIX(BIT(MT7530_CPU_PORT))); +- priv->ports[port].pm = PCR_MATRIX(BIT(MT7530_CPU_PORT)); ++ PCR_MATRIX(BIT(upstream))); ++ priv->ports[port].pm = PCR_MATRIX(BIT(upstream)); + + mutex_unlock(&priv->reg_mutex); + } +@@ -908,15 +918,7 @@ err: + static enum dsa_tag_protocol + mtk_get_tag_protocol(struct dsa_switch *ds) + { +- struct mt7530_priv *priv = ds->priv; +- +- if (!dsa_is_cpu_port(ds, MT7530_CPU_PORT)) { +- dev_warn(priv->dev, +- "port not matched with tagging CPU port\n"); +- return DSA_TAG_PROTO_NONE; +- } else { +- return DSA_TAG_PROTO_MTK; +- } ++ return DSA_TAG_PROTO_MTK; + } + + static int +@@ -989,7 +991,7 @@ mt7530_setup(struct dsa_switch *ds) + + /* Enable Port 6 only; P5 as GMAC5 which currently is not supported */ + val = mt7530_read(priv, MT7530_MHWTRAP); +- val &= ~MHWTRAP_P6_DIS & ~MHWTRAP_PHY_ACCESS; ++ val &= ~MHWTRAP_P5_DIS & ~MHWTRAP_P6_DIS & ~MHWTRAP_PHY_ACCESS; + val |= MHWTRAP_MANUAL; + if (!dsa_is_cpu_port(ds, 5)) { + val |= MHWTRAP_P5_DIS; +--- a/include/net/dsa.h ++++ b/include/net/dsa.h +@@ -185,6 +185,10 @@ struct dsa_port { + u8 stp_state; + struct net_device *bridge_dev; + struct devlink_port devlink_port; ++ ++ struct net_device *ethernet; ++ int upstream; ++ + /* + * Original copy of the master netdev ethtool_ops + */ +@@ -266,6 +270,11 @@ static inline bool dsa_is_normal_port(st + return !dsa_is_cpu_port(ds, p) && !dsa_is_dsa_port(ds, p); + } + ++static inline bool dsa_is_upstream_port(struct dsa_switch *ds, int p) ++{ ++ return dsa_is_cpu_port(ds, p) || dsa_is_dsa_port(ds, p); ++} ++ + static inline u8 dsa_upstream_port(struct dsa_switch *ds) + { + struct dsa_switch_tree *dst = ds->dst; +@@ -282,6 +291,18 @@ static inline u8 dsa_upstream_port(struc + return ds->rtable[dst->cpu_dp->ds->index]; + } + ++static inline u8 dsa_port_upstream_port(struct dsa_switch *ds, int port) ++{ ++ /* ++ * If this port has a specific upstream cpu port, use it, ++ * otherwise use the switch default. ++ */ ++ if (ds->ports[port].upstream) ++ return ds->ports[port].upstream; ++ else ++ return dsa_upstream_port(ds); ++} ++ + typedef int dsa_fdb_dump_cb_t(const unsigned char *addr, u16 vid, + bool is_static, void *data); + struct dsa_switch_ops { +--- a/net/dsa/dsa2.c ++++ b/net/dsa/dsa2.c +@@ -253,6 +253,8 @@ static int dsa_cpu_port_apply(struct dsa + memset(&port->devlink_port, 0, sizeof(port->devlink_port)); + err = devlink_port_register(ds->devlink, &port->devlink_port, + port->index); ++ if (port->netdev) ++ port->netdev->dsa_ptr = ds->dst; + return err; + } + +@@ -262,6 +264,12 @@ static void dsa_cpu_port_unapply(struct + dsa_cpu_dsa_destroy(port); + port->ds->cpu_port_mask &= ~BIT(port->index); + ++ if (port->netdev) ++ port->netdev->dsa_ptr = NULL; ++ if (port->ethernet) { ++ dev_put(port->ethernet); ++ port->ethernet = NULL; ++ } + } + + static int dsa_user_port_apply(struct dsa_port *port) +@@ -505,10 +513,9 @@ static int dsa_cpu_parse(struct dsa_port + dev_put(ethernet_dev); + } + +- if (!dst->cpu_dp) { ++ if (!dst->cpu_dp) + dst->cpu_dp = port; +- dst->cpu_dp->netdev = ethernet_dev; +- } ++ port->netdev = ethernet_dev; + + /* Initialize cpu_port_mask now for drv->setup() + * to have access to a correct value, just like what +@@ -526,6 +533,29 @@ static int dsa_cpu_parse(struct dsa_port + + dst->rcv = dst->tag_ops->rcv; + ++ dev_hold(ethernet_dev); ++ ds->ports[index].ethernet = ethernet_dev; ++ ds->cpu_port_mask |= BIT(index); ++ ++ return 0; ++} ++ ++static int dsa_user_parse(struct dsa_port *port, u32 index, ++ struct dsa_switch *ds) ++{ ++ struct device_node *cpu_port; ++ const unsigned int *cpu_port_reg; ++ int cpu_port_index; ++ ++ cpu_port = of_parse_phandle(port->dn, "cpu", 0); ++ if (cpu_port) { ++ cpu_port_reg = of_get_property(cpu_port, "reg", NULL); ++ if (!cpu_port_reg) ++ return -EINVAL; ++ cpu_port_index = be32_to_cpup(cpu_port_reg); ++ ds->ports[index].upstream = cpu_port_index; ++ } ++ + return 0; + } + +@@ -533,7 +563,7 @@ static int dsa_ds_parse(struct dsa_switc + { + struct dsa_port *port; + u32 index; +- int err; ++ int err = 0; + + for (index = 0; index < ds->num_ports; index++) { + port = &ds->ports[index]; +@@ -546,6 +576,9 @@ static int dsa_ds_parse(struct dsa_switc + if (err) + return err; + } else { ++ err = dsa_user_parse(port, index, ds); ++ if (err) ++ return err; + /* Initialize enabled_port_mask now for drv->setup() + * to have access to a correct value, just like what + * net/dsa/dsa.c::dsa_switch_setup_one does. +--- a/net/dsa/dsa_priv.h ++++ b/net/dsa/dsa_priv.h +@@ -91,6 +91,8 @@ struct dsa_slave_priv { + + /* TC context */ + struct list_head mall_tc_list; ++ ++ struct net_device *master; + }; + + /* dsa.c */ +@@ -177,6 +179,9 @@ extern const struct dsa_device_ops trail + + static inline struct net_device *dsa_master_netdev(struct dsa_slave_priv *p) + { ++ if (p->master) ++ return p->master; ++ + return p->dp->cpu_dp->netdev; + } + +--- a/net/dsa/slave.c ++++ b/net/dsa/slave.c +@@ -1263,7 +1263,7 @@ int dsa_slave_create(struct dsa_port *po + int ret; + + cpu_dp = ds->dst->cpu_dp; +- master = cpu_dp->netdev; ++ master = ds->ports[port->upstream].ethernet; + + if (!ds->num_tx_queues) + ds->num_tx_queues = 1; +@@ -1301,6 +1301,7 @@ int dsa_slave_create(struct dsa_port *po + p->dp = port; + INIT_LIST_HEAD(&p->mall_tc_list); + p->xmit = dst->tag_ops->xmit; ++ p->master = master; + + p->old_pause = -1; + p->old_link = -1; diff --git a/target/linux/ramips/patches-4.14/0035-net-mediatek-disable-RX-VLan-offloading.patch b/target/linux/ramips/patches-4.14/0035-net-mediatek-disable-RX-VLan-offloading.patch new file mode 100644 index 000000000000..72a2ece464bc --- /dev/null +++ b/target/linux/ramips/patches-4.14/0035-net-mediatek-disable-RX-VLan-offloading.patch @@ -0,0 +1,47 @@ +From 35b83b85e752a6660b92f08c0fb912308f25cf6d Mon Sep 17 00:00:00 2001 +From: John Crispin +Date: Thu, 10 Aug 2017 15:56:40 +0200 +Subject: [PATCH 35/57] net: mediatek: disable RX VLan offloading + +Signed-off-by: John Crispin +--- + drivers/net/ethernet/mediatek/mtk_eth_soc.c | 9 ++++++--- + drivers/net/ethernet/mediatek/mtk_eth_soc.h | 2 -- + 2 files changed, 6 insertions(+), 5 deletions(-) + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -709,8 +709,8 @@ static int mtk_tx_map(struct sk_buff *sk + txd4 |= TX_DMA_CHKSUM; + + /* VLAN header offload */ +- if (skb_vlan_tag_present(skb)) +- txd4 |= TX_DMA_INS_VLAN | skb_vlan_tag_get(skb); ++// if (skb_vlan_tag_present(skb)) ++// txd4 |= TX_DMA_INS_VLAN | skb_vlan_tag_get(skb); + + mapped_addr = dma_map_single(eth->dev, skb->data, + skb_headlen(skb), DMA_TO_DEVICE); +@@ -1980,7 +1980,10 @@ static int mtk_hw_init(struct mtk_eth *e + mtk_w32(eth, val | MTK_CDMQ_STAG_EN, MTK_CDMQ_IG_CTRL); + + /* Enable RX VLan Offloading */ +- mtk_w32(eth, 1, MTK_CDMP_EG_CTRL); ++ if (MTK_HW_FEATURES & NETIF_F_HW_VLAN_CTAG_RX) ++ mtk_w32(eth, 1, MTK_CDMP_EG_CTRL); ++ else ++ mtk_w32(eth, 0, MTK_CDMP_EG_CTRL); + + /* enable interrupt delay for RX */ + mtk_w32(eth, MTK_PDMA_DELAY_RX_DELAY, MTK_PDMA_DELAY_INT); +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h +@@ -34,8 +34,6 @@ + NETIF_MSG_TX_ERR) + #define MTK_HW_FEATURES (NETIF_F_IP_CSUM | \ + NETIF_F_RXCSUM | \ +- NETIF_F_HW_VLAN_CTAG_TX | \ +- NETIF_F_HW_VLAN_CTAG_RX | \ + NETIF_F_SG | NETIF_F_TSO | \ + NETIF_F_TSO6 | \ + NETIF_F_IPV6_CSUM) diff --git a/target/linux/ramips/patches-4.14/0042-net-next-mediatek-honour-special-tag-bit-inside-RX-D.patch b/target/linux/ramips/patches-4.14/0042-net-next-mediatek-honour-special-tag-bit-inside-RX-D.patch new file mode 100644 index 000000000000..8163e4475d57 --- /dev/null +++ b/target/linux/ramips/patches-4.14/0042-net-next-mediatek-honour-special-tag-bit-inside-RX-D.patch @@ -0,0 +1,50 @@ +From a306af3b97c56b9e224a2f9ee04838a2d32ff60b Mon Sep 17 00:00:00 2001 +From: John Crispin +Date: Wed, 9 Aug 2017 14:44:07 +0200 +Subject: [PATCH 42/57] net-next: mediatek: honour special tag bit inside RX + DMA descriptor + +For HW NAT/QoS to work the DSA driver needs to turn the special tag bit +inside the ingress control register on. This has the side effect that +the code working out which ingress gmac we have breaks. Fix this by +honouring the special tag bit inside the RX free descriptor. + +Signed-off-by: John Crispin +--- + drivers/net/ethernet/mediatek/mtk_eth_soc.c | 14 ++++++++++---- + drivers/net/ethernet/mediatek/mtk_eth_soc.h | 1 + + 2 files changed, 11 insertions(+), 4 deletions(-) + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -999,10 +999,16 @@ static int mtk_poll_rx(struct napi_struc + if (!(trxd.rxd2 & RX_DMA_DONE)) + break; + +- /* find out which mac the packet come from. values start at 1 */ +- mac = (trxd.rxd4 >> RX_DMA_FPORT_SHIFT) & +- RX_DMA_FPORT_MASK; +- mac--; ++ /* find out which mac the packet comes from. If the special tag is ++ * we can assume that the traffic is coming from the builtin mt7530 ++ * and the DSA driver has loaded. FPORT will be the physical switch ++ * port in this case rather than the FE forward port id. */ ++ if (!(trxd.rxd4 & RX_DMA_SP_TAG)) { ++ /* values start at 1 */ ++ mac = (trxd.rxd4 >> RX_DMA_FPORT_SHIFT) & ++ RX_DMA_FPORT_MASK; ++ mac--; ++ } + + if (unlikely(mac < 0 || mac >= MTK_MAC_COUNT || + !eth->netdev[mac])) +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h +@@ -287,6 +287,7 @@ + + /* QDMA descriptor rxd4 */ + #define RX_DMA_L4_VALID BIT(24) ++#define RX_DMA_SP_TAG BIT(22) + #define RX_DMA_FPORT_SHIFT 19 + #define RX_DMA_FPORT_MASK 0x7 + diff --git a/target/linux/ramips/patches-4.14/0043-net-next-mediatek-enable-special-tag-indication-for-.patch b/target/linux/ramips/patches-4.14/0043-net-next-mediatek-enable-special-tag-indication-for-.patch new file mode 100644 index 000000000000..a658a572fc22 --- /dev/null +++ b/target/linux/ramips/patches-4.14/0043-net-next-mediatek-enable-special-tag-indication-for-.patch @@ -0,0 +1,41 @@ +From 53e3d9af39805a7e1ba81a047a9ab433be0e82f5 Mon Sep 17 00:00:00 2001 +From: John Crispin +Date: Wed, 9 Aug 2017 14:56:53 +0200 +Subject: [PATCH 43/57] net-next: mediatek: enable special tag indication for + PDMA + +The Ingress special tag indication was only enabled for QDMA and not PDMA. +Properly initialize the STAG bit. This broke HW NAT and Qos from working +for traffic coming in via a DSA device. The PPE failed to properly parse +the traffic as it was not expecting the special tag. + +Signed-off-by: John Crispin +--- + drivers/net/ethernet/mediatek/mtk_eth_soc.c | 2 ++ + drivers/net/ethernet/mediatek/mtk_eth_soc.h | 4 ++++ + 2 files changed, 6 insertions(+) + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -1984,6 +1984,8 @@ static int mtk_hw_init(struct mtk_eth *e + */ + val = mtk_r32(eth, MTK_CDMQ_IG_CTRL); + mtk_w32(eth, val | MTK_CDMQ_STAG_EN, MTK_CDMQ_IG_CTRL); ++ val = mtk_r32(eth, MTK_CDMP_IG_CTRL); ++ mtk_w32(eth, val | MTK_CDMP_STAG_EN, MTK_CDMP_IG_CTRL); + + /* Enable RX VLan Offloading */ + if (MTK_HW_FEATURES & NETIF_F_HW_VLAN_CTAG_RX) +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h +@@ -72,6 +72,10 @@ + #define MTK_CDMQ_IG_CTRL 0x1400 + #define MTK_CDMQ_STAG_EN BIT(0) + ++/* CDMP Ingress Control Register */ ++#define MTK_CDMP_IG_CTRL 0x400 ++#define MTK_CDMP_STAG_EN BIT(0) ++ + /* CDMP Exgress Control Register */ + #define MTK_CDMP_EG_CTRL 0x404 + diff --git a/target/linux/ramips/patches-4.14/0044-net-next-dsa-mediatek-tell-GDMA-when-we-are-turning-.patch b/target/linux/ramips/patches-4.14/0044-net-next-dsa-mediatek-tell-GDMA-when-we-are-turning-.patch new file mode 100644 index 000000000000..4a69e7aadf48 --- /dev/null +++ b/target/linux/ramips/patches-4.14/0044-net-next-dsa-mediatek-tell-GDMA-when-we-are-turning-.patch @@ -0,0 +1,43 @@ +From 6a5932028a4f3217ed7c9d602f269611d95dd8ca Mon Sep 17 00:00:00 2001 +From: John Crispin +Date: Wed, 9 Aug 2017 15:13:19 +0200 +Subject: [PATCH 44/57] net-next: dsa: mediatek: tell GDMA when we are turning + on the special tag + +Enabling this bit will make the RX DMA descriptor enable the SP bit for all +ingress traffic inside the return descriptor. The PPE needs this to know +that a SP is present. + +Signed-off-by: John Crispin +--- + drivers/net/dsa/mt7530.c | 5 +++++ + drivers/net/dsa/mt7530.h | 4 ++++ + 2 files changed, 9 insertions(+) + +--- a/drivers/net/dsa/mt7530.c ++++ b/drivers/net/dsa/mt7530.c +@@ -677,6 +677,11 @@ mt7530_cpu_port_enable(struct mt7530_pri + mt7530_write(priv, MT7530_PVC_P(port), + PORT_SPEC_TAG); + ++ /* Enable Mediatek header mode on the GMAC that the cpu port ++ * connects to */ ++ regmap_write_bits(priv->ethernet, MTK_GDMA_FWD_CFG(port), ++ GDMA_SPEC_TAG, GDMA_SPEC_TAG); ++ + /* Setup the MAC by default for the cpu port */ + mt7530_write(priv, MT7530_PMCR_P(port), PMCR_CPUP_LINK); + +--- a/drivers/net/dsa/mt7530.h ++++ b/drivers/net/dsa/mt7530.h +@@ -22,6 +22,10 @@ + + #define TRGMII_BASE(x) (0x10000 + (x)) + ++/* Registers for GDMA configuration access */ ++#define MTK_GDMA_FWD_CFG(x) (0x500 + (x * 0x1000)) ++#define GDMA_SPEC_TAG BIT(24) ++ + /* Registers to ethsys access */ + #define ETHSYS_CLKCFG0 0x2c + #define ETHSYS_TRGMII_CLK_SEL362_5 BIT(11) diff --git a/target/linux/ramips/patches-4.14/0046-net-mediatek-add-irq-delay.patch b/target/linux/ramips/patches-4.14/0046-net-mediatek-add-irq-delay.patch new file mode 100644 index 000000000000..3ace7265c6ca --- /dev/null +++ b/target/linux/ramips/patches-4.14/0046-net-mediatek-add-irq-delay.patch @@ -0,0 +1,21 @@ +From 6e081074df96bf3762c2e6438c383f11a56b0a7e Mon Sep 17 00:00:00 2001 +From: John Crispin +Date: Thu, 10 Aug 2017 15:58:04 +0200 +Subject: [PATCH 46/57] net: mediatek: add irq delay + +Signed-off-by: John Crispin +--- + drivers/net/ethernet/mediatek/mtk_eth_soc.c | 7 ++++++- + drivers/net/ethernet/mediatek/mtk_eth_soc.h | 8 +++++++- + 2 files changed, 13 insertions(+), 2 deletions(-) + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -1995,6 +1995,7 @@ static int mtk_hw_init(struct mtk_eth *e + + /* enable interrupt delay for RX */ + mtk_w32(eth, MTK_PDMA_DELAY_RX_DELAY, MTK_PDMA_DELAY_INT); ++ //mtk_w32(eth, MTK_PDMA_DELAY_RX_DELAY, MTK_QDMA_DELAY_INT); + + /* disable delay and normal interrupt */ + mtk_w32(eth, 0, MTK_QDMA_DELAY_INT); diff --git a/target/linux/ramips/patches-4.14/0051-net-mediatek-increase-tx_timeout.patch b/target/linux/ramips/patches-4.14/0051-net-mediatek-increase-tx_timeout.patch new file mode 100644 index 000000000000..f4c0fce56686 --- /dev/null +++ b/target/linux/ramips/patches-4.14/0051-net-mediatek-increase-tx_timeout.patch @@ -0,0 +1,21 @@ +From 5cbf53c7e5eac5bacc409461888789accdaf8eec Mon Sep 17 00:00:00 2001 +From: John Crispin +Date: Thu, 10 Aug 2017 16:00:06 +0200 +Subject: [PATCH 51/57] net: mediatek: increase tx_timeout + +Signed-off-by: John Crispin +--- + drivers/net/ethernet/mediatek/mtk_eth_soc.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -2454,7 +2454,7 @@ static int mtk_add_mac(struct mtk_eth *e + mac->hw_stats->reg_offset = id * MTK_STAT_OFFSET; + + SET_NETDEV_DEV(eth->netdev[id], eth->dev); +- eth->netdev[id]->watchdog_timeo = 5 * HZ; ++ eth->netdev[id]->watchdog_timeo = 30 * HZ; + eth->netdev[id]->netdev_ops = &mtk_netdev_ops; + eth->netdev[id]->base_addr = (unsigned long)eth->base; + diff --git a/target/linux/ramips/patches-4.14/0062-mdio-atomic.patch b/target/linux/ramips/patches-4.14/0062-mdio-atomic.patch new file mode 100644 index 000000000000..9ce66ef48736 --- /dev/null +++ b/target/linux/ramips/patches-4.14/0062-mdio-atomic.patch @@ -0,0 +1,14 @@ +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -76,7 +76,10 @@ static int mtk_mdio_busy_wait(struct mtk + return 0; + if (time_after(jiffies, t_start + PHY_IAC_TIMEOUT)) + break; +- usleep_range(10, 20); ++ if (in_atomic()) ++ udelay(10); ++ else ++ usleep_range(10, 20); + } + + dev_err(eth->dev, "mdio: MDIO timeout\n"); diff --git a/target/linux/ramips/patches-4.14/0063-atomic-sleep.patch b/target/linux/ramips/patches-4.14/0063-atomic-sleep.patch new file mode 100644 index 000000000000..0dde3fdb6440 --- /dev/null +++ b/target/linux/ramips/patches-4.14/0063-atomic-sleep.patch @@ -0,0 +1,46 @@ +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -409,6 +409,7 @@ static int mtk_mdio_init(struct mtk_eth + + snprintf(eth->mii_bus->id, MII_BUS_ID_SIZE, "%s", mii_np->name); + ret = of_mdiobus_register(eth->mii_bus, mii_np); ++printk("%s:%s[%d]%d %p\n", __FILE__, __func__, __LINE__, ret, eth->mii_bus); + + err_put_node: + of_node_put(mii_np); +@@ -1472,7 +1473,10 @@ static void mtk_hwlro_rx_uninit(struct m + for (i = 0; i < 10; i++) { + val = mtk_r32(eth, MTK_PDMA_LRO_CTRL_DW0); + if (val & MTK_LRO_RING_RELINQUISH_DONE) { +- msleep(20); ++ if (in_atomic()) ++ mdelay(20); ++ else ++ msleep(20); + continue; + } + break; +@@ -1868,7 +1872,10 @@ static void mtk_stop_dma(struct mtk_eth + for (i = 0; i < 10; i++) { + val = mtk_r32(eth, glo_cfg); + if (val & (MTK_TX_DMA_BUSY | MTK_RX_DMA_BUSY)) { +- msleep(20); ++ if (in_atomic()) ++ mdelay(20); ++ else ++ msleep(20); + continue; + } + break; +@@ -1906,7 +1913,10 @@ static void ethsys_reset(struct mtk_eth + reset_bits, + reset_bits); + +- usleep_range(1000, 1100); ++ if (in_atomic()) ++ udelay(1000); ++ else ++ usleep_range(1000, 1100); + regmap_update_bits(eth->ethsys, ETHSYS_RSTCTRL, + reset_bits, + ~reset_bits); diff --git a/target/linux/ramips/patches-4.14/0175-net-mediatek-remove-superfluous-pin-setup-for-MT7622.patch b/target/linux/ramips/patches-4.14/0175-net-mediatek-remove-superfluous-pin-setup-for-MT7622.patch new file mode 100644 index 000000000000..86354973b146 --- /dev/null +++ b/target/linux/ramips/patches-4.14/0175-net-mediatek-remove-superfluous-pin-setup-for-MT7622.patch @@ -0,0 +1,102 @@ +From d96cf7e724105dc73f623c2019ab5bc78cef036e Mon Sep 17 00:00:00 2001 +From: Sean Wang +Date: Wed, 20 Dec 2017 17:47:06 +0800 +Subject: [PATCH 175/224] net: mediatek: remove superfluous pin setup for + MT7622 SoC + +Remove superfluous pin setup to get out of accessing invalid I/O pin +registers because the way for pin configuring tends to be different from +various SoCs and thus it should be better being managed and controlled by +the pinctrl driver which MT7622 already can support. + +Signed-off-by: Sean Wang +Signed-off-by: David S. Miller +--- + drivers/net/ethernet/mediatek/mtk_eth_soc.c | 35 +++++++++++++++++------------ + drivers/net/ethernet/mediatek/mtk_eth_soc.h | 3 +++ + 2 files changed, 24 insertions(+), 14 deletions(-) + +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -1976,14 +1976,16 @@ static int mtk_hw_init(struct mtk_eth *e + } + regmap_write(eth->ethsys, ETHSYS_SYSCFG0, val); + +- /* Set GE2 driving and slew rate */ +- regmap_write(eth->pctl, GPIO_DRV_SEL10, 0xa00); ++ if (eth->pctl) { ++ /* Set GE2 driving and slew rate */ ++ regmap_write(eth->pctl, GPIO_DRV_SEL10, 0xa00); + +- /* set GE2 TDSEL */ +- regmap_write(eth->pctl, GPIO_OD33_CTRL8, 0x5); ++ /* set GE2 TDSEL */ ++ regmap_write(eth->pctl, GPIO_OD33_CTRL8, 0x5); + +- /* set GE2 TUNE */ +- regmap_write(eth->pctl, GPIO_BIAS_CTRL, 0x0); ++ /* set GE2 TUNE */ ++ regmap_write(eth->pctl, GPIO_BIAS_CTRL, 0x0); ++ } + + /* Set linkdown as the default for each GMAC. Its own MCR would be set + * up with the more appropriate value when mtk_phy_link_adjust call is +@@ -2568,11 +2570,13 @@ static int mtk_probe(struct platform_dev + } + } + +- eth->pctl = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, +- "mediatek,pctl"); +- if (IS_ERR(eth->pctl)) { +- dev_err(&pdev->dev, "no pctl regmap found\n"); +- return PTR_ERR(eth->pctl); ++ if (eth->soc->required_pctl) { ++ eth->pctl = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, ++ "mediatek,pctl"); ++ if (IS_ERR(eth->pctl)) { ++ dev_err(&pdev->dev, "no pctl regmap found\n"); ++ return PTR_ERR(eth->pctl); ++ } + } + + for (i = 0; i < 3; i++) { +@@ -2698,17 +2702,20 @@ static int mtk_remove(struct platform_de + + static const struct mtk_soc_data mt2701_data = { + .caps = MTK_GMAC1_TRGMII, +- .required_clks = MT7623_CLKS_BITMAP ++ .required_clks = MT7623_CLKS_BITMAP, ++ .required_pctl = true, + }; + + static const struct mtk_soc_data mt7622_data = { + .caps = MTK_DUAL_GMAC_SHARED_SGMII | MTK_GMAC1_ESW, +- .required_clks = MT7622_CLKS_BITMAP ++ .required_clks = MT7622_CLKS_BITMAP, ++ .required_pctl = false, + }; + + static const struct mtk_soc_data mt7623_data = { + .caps = MTK_GMAC1_TRGMII, +- .required_clks = MT7623_CLKS_BITMAP ++ .required_clks = MT7623_CLKS_BITMAP, ++ .required_pctl = true, + }; + + const struct of_device_id of_mtk_match[] = { +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h +@@ -574,10 +574,13 @@ struct mtk_rx_ring { + * @caps Flags shown the extra capability for the SoC + * @required_clks Flags shown the bitmap for required clocks on + * the target SoC ++ * @required_pctl A bool value to show whether the SoC requires ++ * the extra setup for those pins used by GMAC. + */ + struct mtk_soc_data { + u32 caps; + u32 required_clks; ++ bool required_pctl; + }; + + /* currently no SoC has more than 2 macs */ From patchwork Mon Oct 15 10:24:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Bj=C3=B8rn_Mork?= X-Patchwork-Id: 984079 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mork.no Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="KNOcrT95"; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=mork.no header.i=@mork.no header.b="Sty9LhVo"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YZQj1ZBcz9s3q for ; Mon, 15 Oct 2018 21:28:13 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ugWgdutiNandN9Oh86CcG68sQR4mG0G9odE1E+W+bgc=; b=KNOcrT95RCjyhn M8QnLKx3KSgrKVWnQrUaovsS5WdoVnz+Eok+oLclCVxU8ptbTh5eVtJJ+eE3trqhK3bz5L0OdnqiC V7g7AUQh/mOGVuDwqHWinwZKR70mE9an6+v2nVGjXyq3vOVNPG/RC2Co6r9S3egKh17P1TESNpw3B Tgpr2Z5IQd91Kxn+h/GrlmcuUHl2NRXBXrDgH0+CnvvwBSTW9FWN3821Nys7BwIUl5KuDS3rEkgg0 0qmnnnKDRM3YIdeg9yBHgc1ATBaGcOTOjMcq27qM2ZbXUPkU5HVqK+y3uA7drA8lcucxzrCEYdhl7 wVegeKGcaeAbEdfJN/RQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gC06X-0003cr-0x; Mon, 15 Oct 2018 10:28:05 +0000 Received: from canardo.mork.no ([2001:4641::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gC04D-0002X0-0S for openwrt-devel@lists.openwrt.org; Mon, 15 Oct 2018 10:25:47 +0000 Received: from canardo.mork.no (ip6-localhost [IPv6:0:0:0:0:0:0:0:1]) by canardo.mork.no (8.15.2/8.15.2) with ESMTPS id w9FAPNMr030847 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 15 Oct 2018 12:25:23 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mork.no; s=b; t=1539599123; bh=85LWt/WS+UAy6uCVphYOKJHRmjixrPtEudb4FSSN1ms=; h=From:To:Cc:Subject:Date:Message-Id:References:From; b=Sty9LhVofof2IEYWdOSDv+9Dbh9vdguDsM6UPVnYl6sBCKOJS1KqU+pCooYg8EPOX L4ZYmkBddgCXMZt9AbwSOdcS0IXFa78m1zd5rXElHumJzh1fLEHLTOESXGeHEhcq0u U4A85m5fJt6FzzuHPz+zGwrjIFrHxUwgP/DRfzaw= Received: (from bjorn@localhost) by canardo.mork.no (8.15.2/8.15.2/Submit) id w9FAPNAV030840; Mon, 15 Oct 2018 12:25:23 +0200 From: =?utf-8?q?Bj=C3=B8rn_Mork?= To: OpenWrt Development List Date: Mon, 15 Oct 2018 12:24:59 +0200 Message-Id: <20181015102503.30731-6-bjorn@mork.no> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181015102503.30731-1-bjorn@mork.no> References: <20181015102503.30731-1-bjorn@mork.no> MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on canardo.mork.no X-Virus-Scanned: clamav-milter 0.100.1 at canardo X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181015_032542_009353_0BE4AE41 X-CRM114-Status: GOOD ( 17.51 ) X-Spam-Score: -2.4 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [2001:4641:0:0:0:0:0:1 listed in] [list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Subject: [OpenWrt-Devel] [RFC 5/9] mt7621: enable mainline driver X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Bj=C3=B8rn_Mork?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Signed-off-by: Bjørn Mork --- target/linux/ramips/mt7621/config-4.14 | 1 + .../ramips/patches-4.14/2200-mt7621-eth-dsa.patch | 121 +++++++++++++++++++++ 2 files changed, 122 insertions(+) create mode 100644 target/linux/ramips/patches-4.14/2200-mt7621-eth-dsa.patch diff --git a/target/linux/ramips/mt7621/config-4.14 b/target/linux/ramips/mt7621/config-4.14 index 07e0ec5038c5..cf05b22bf930 100644 --- a/target/linux/ramips/mt7621/config-4.14 +++ b/target/linux/ramips/mt7621/config-4.14 @@ -191,6 +191,7 @@ CONFIG_NET_RALINK_MDIO=y CONFIG_NET_RALINK_MDIO_MT7620=y CONFIG_NET_RALINK_MT7621=y CONFIG_NET_RALINK_SOC=y +# CONFIG_NET_VENDOR_MEDIATEK is not set CONFIG_NET_VENDOR_RALINK=y CONFIG_NO_GENERIC_PCI_IOPORT_MAP=y # CONFIG_NO_IOPORT_MAP is not set diff --git a/target/linux/ramips/patches-4.14/2200-mt7621-eth-dsa.patch b/target/linux/ramips/patches-4.14/2200-mt7621-eth-dsa.patch new file mode 100644 index 000000000000..51a610264e82 --- /dev/null +++ b/target/linux/ramips/patches-4.14/2200-mt7621-eth-dsa.patch @@ -0,0 +1,121 @@ +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -1792,6 +1792,19 @@ static irqreturn_t mtk_handle_irq_tx(int + return IRQ_HANDLED; + } + ++static irqreturn_t mtk_handle_irq(int irq, void *_eth) ++{ ++ struct mtk_eth *eth = _eth; ++ ++ if (mtk_r32(eth, MTK_PDMA_INT_STATUS) & MTK_RX_DONE_INT) ++ mtk_handle_irq_rx(irq, _eth); ++ ++ if (mtk_r32(eth, MTK_QMTK_INT_STATUS) & MTK_TX_DONE_INT) ++ mtk_handle_irq_tx(irq, _eth); ++ ++ return IRQ_HANDLED; ++} ++ + #ifdef CONFIG_NET_POLL_CONTROLLER + static void mtk_poll_controller(struct net_device *dev) + { +@@ -2579,8 +2592,12 @@ static int mtk_probe(struct platform_dev + } + } + +- for (i = 0; i < 3; i++) { +- eth->irq[i] = platform_get_irq(pdev, i); ++ for (i = 0; i < 3; i++) ++ { ++ if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT) && i > 0) ++ eth->irq[i] = eth->irq[0]; ++ else ++ eth->irq[i] = platform_get_irq(pdev, i); + if (eth->irq[i] < 0) { + dev_err(&pdev->dev, "no IRQ%d resource found\n", i); + return -ENXIO; +@@ -2627,13 +2644,18 @@ static int mtk_probe(struct platform_dev + goto err_deinit_hw; + } + +- err = devm_request_irq(eth->dev, eth->irq[1], mtk_handle_irq_tx, 0, +- dev_name(eth->dev), eth); +- if (err) +- goto err_free_dev; ++ if (MTK_HAS_CAPS(eth->soc->caps, MTK_SHARED_INT)) { ++ err = devm_request_irq(eth->dev, eth->irq[0], mtk_handle_irq, 0, ++ dev_name(eth->dev), eth); ++ } else { ++ err = devm_request_irq(eth->dev, eth->irq[1], mtk_handle_irq_tx, 0, ++ dev_name(eth->dev), eth); ++ if (err) ++ goto err_free_dev; + +- err = devm_request_irq(eth->dev, eth->irq[2], mtk_handle_irq_rx, 0, +- dev_name(eth->dev), eth); ++ err = devm_request_irq(eth->dev, eth->irq[2], mtk_handle_irq_rx, 0, ++ dev_name(eth->dev), eth); ++ } + if (err) + goto err_free_dev; + +@@ -2706,6 +2728,12 @@ static const struct mtk_soc_data mt2701_ + .required_pctl = true, + }; + ++static const struct mtk_soc_data mt7621_data = { ++ .caps = MTK_SHARED_INT, ++ .required_clks = MT7621_CLKS_BITMAP, ++ .required_pctl = false, ++}; ++ + static const struct mtk_soc_data mt7622_data = { + .caps = MTK_DUAL_GMAC_SHARED_SGMII | MTK_GMAC1_ESW, + .required_clks = MT7622_CLKS_BITMAP, +@@ -2720,6 +2748,7 @@ static const struct mtk_soc_data mt7623_ + + const struct of_device_id of_mtk_match[] = { + { .compatible = "mediatek,mt2701-eth", .data = &mt2701_data}, ++ { .compatible = "mediatek,mt7621-eth", .data = &mt7621_data}, + { .compatible = "mediatek,mt7622-eth", .data = &mt7622_data}, + { .compatible = "mediatek,mt7623-eth", .data = &mt7623_data}, + {}, +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h +@@ -364,6 +364,7 @@ + #define ETHSYS_CHIPID4_7 0x4 + #define MT7623_ETH 7623 + #define MT7622_ETH 7622 ++#define MT7621_ETH 7621 + + /* ethernet subsystem config register */ + #define ETHSYS_SYSCFG0 0x14 +@@ -489,6 +490,8 @@ enum mtk_clks_map { + BIT(MTK_CLK_SGMII_CDR_FB) | \ + BIT(MTK_CLK_SGMII_CK) | \ + BIT(MTK_CLK_ETH2PLL)) ++#define MT7621_CLKS_BITMAP (0) ++ + enum mtk_dev_state { + MTK_HW_INIT, + MTK_RESETTING +@@ -567,6 +570,8 @@ struct mtk_rx_ring { + #define MTK_GMAC2_SGMII (BIT(10) | MTK_SGMII) + #define MTK_DUAL_GMAC_SHARED_SGMII (BIT(11) | MTK_GMAC1_SGMII | \ + MTK_GMAC2_SGMII) ++#define MTK_SHARED_INT BIT(12) ++ + #define MTK_HAS_CAPS(caps, _x) (((caps) & (_x)) == (_x)) + + /* struct mtk_eth_data - This is the structure holding all differences +--- a/drivers/net/ethernet/mediatek/Kconfig ++++ b/drivers/net/ethernet/mediatek/Kconfig +@@ -1,6 +1,6 @@ + config NET_VENDOR_MEDIATEK + bool "MediaTek ethernet driver" +- depends on ARCH_MEDIATEK ++ depends on ARCH_MEDIATEK || SOC_MT7621 + ---help--- + If you have a Mediatek SoC with ethernet, say Y. + From patchwork Mon Oct 15 10:25:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Bj=C3=B8rn_Mork?= X-Patchwork-Id: 984077 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mork.no Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ZCsEnTTk"; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=mork.no header.i=@mork.no header.b="nguiqgc0"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YZPP029yz9s3q for ; Mon, 15 Oct 2018 21:27:04 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=cpPOzrzWyw0YcHbGyjNRY7v/P5RIM8e58OBV3pn01uw=; b=ZCsEnTTkzi7XkN E5Xau9mmmESLBIzgxHUEyiXXUPw8kCa528x7AI3hZB7PtBbhHnlbH/tU6qsLwBYIcTHgN3WWYcq/E kZ9augqNS3qpX4YYL3hv1PPqfnHb3h7aYEOpk+6NG6Iwfdpe/zTx+feqaoklE6Uw9/GKksz3DeChi DwaMKWpXQcYTonnZRaKgSdDGi7AYxajDGOBdqlTCxhUz8r0NY44GpMNPnOrXO5Vudi+24fFYosrUC vfvsjvSKiicyQMj7GdP5ENs9CHwXzbA+Ep+HHUtzDx3PsuFI6SMiPH8aZyJYpBm7TtQnMtL8ylOgd 2evntK+RWDrr8JUHoXvQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gC05Q-00035Q-S3; Mon, 15 Oct 2018 10:26:56 +0000 Received: from canardo.mork.no ([2001:4641::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gC04C-0002X1-VS for openwrt-devel@lists.openwrt.org; Mon, 15 Oct 2018 10:25:46 +0000 Received: from canardo.mork.no (ip6-localhost [IPv6:0:0:0:0:0:0:0:1]) by canardo.mork.no (8.15.2/8.15.2) with ESMTPS id w9FAPNdH030853 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 15 Oct 2018 12:25:23 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mork.no; s=b; t=1539599123; bh=nIzGyo7wT4vtSWTq3snjcZTX1JbaaXHAn8dznRXigww=; h=From:To:Cc:Subject:Date:Message-Id:References:From; b=nguiqgc0gYFnjhc4HcHvGzcyuDlOv/kyF61eBXupALSLAskSmaa5aaORb9KSq7mUA dJuOs1APEaoApdU48QzlHxNvfepNwopTwZRokGCvE7faAovcghPVC2dDdWtd0oHWtM 4j9M7041ugKTo3n5BZgI0FcP2HL7QPQjqVQi6SMs= Received: (from bjorn@localhost) by canardo.mork.no (8.15.2/8.15.2/Submit) id w9FAPNo9030850; Mon, 15 Oct 2018 12:25:23 +0200 From: =?utf-8?q?Bj=C3=B8rn_Mork?= To: OpenWrt Development List Date: Mon, 15 Oct 2018 12:25:00 +0200 Message-Id: <20181015102503.30731-7-bjorn@mork.no> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181015102503.30731-1-bjorn@mork.no> References: <20181015102503.30731-1-bjorn@mork.no> MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on canardo.mork.no X-Virus-Scanned: clamav-milter 0.100.1 at canardo X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181015_032541_996655_880130BC X-CRM114-Status: GOOD ( 10.85 ) X-Spam-Score: -2.4 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [2001:4641:0:0:0:0:0:1 listed in] [list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Subject: [OpenWrt-Devel] [RFC 6/9] mt7621: fix softirq loop X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Bj=C3=B8rn_Mork?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Signed-off-by: Bjørn Mork --- .../2201-mt7621-eth-fix-napi-int.patch | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 target/linux/ramips/patches-4.14/2201-mt7621-eth-fix-napi-int.patch diff --git a/target/linux/ramips/patches-4.14/2201-mt7621-eth-fix-napi-int.patch b/target/linux/ramips/patches-4.14/2201-mt7621-eth-fix-napi-int.patch new file mode 100644 index 000000000000..d52ff56643cb --- /dev/null +++ b/target/linux/ramips/patches-4.14/2201-mt7621-eth-fix-napi-int.patch @@ -0,0 +1,22 @@ +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -1775,8 +1775,8 @@ static irqreturn_t mtk_handle_irq_rx(int + + if (likely(napi_schedule_prep(ð->rx_napi))) { + __napi_schedule(ð->rx_napi); +- mtk_rx_irq_disable(eth, MTK_RX_DONE_INT); + } ++ mtk_rx_irq_disable(eth, MTK_RX_DONE_INT); + + return IRQ_HANDLED; + } +@@ -1787,8 +1787,8 @@ static irqreturn_t mtk_handle_irq_tx(int + + if (likely(napi_schedule_prep(ð->tx_napi))) { + __napi_schedule(ð->tx_napi); +- mtk_tx_irq_disable(eth, MTK_TX_DONE_INT); + } ++ mtk_tx_irq_disable(eth, MTK_TX_DONE_INT); + + return IRQ_HANDLED; + } From patchwork Mon Oct 15 10:25:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Bj=C3=B8rn_Mork?= X-Patchwork-Id: 984076 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mork.no Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="q0pyxXcO"; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=mork.no header.i=@mork.no header.b="mEEbO77C"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YZNg0YJ6z9s3q for ; Mon, 15 Oct 2018 21:26:27 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tJGVzyIfzlXODWh/Gplys0FHWD9rhmMjEYE9C0YbCY0=; b=q0pyxXcOTe+grc wYp3O/VyDto5yLP4ne+2SnF0SomGlcOpP59FDzEii9HqT3ELv7/nfMGhAat0TTxWycsnm9sAjG4wa 2PjrFD0MWn5pdgfdMEpW3xmj74LQjKrZv6SuCkqQor42L/Lhcxf8VQFKX34CG1EIzjP+ZcMZMAm3E BVJBTSa0TbidKUxx5cZ/Xdkms4ijyhqVjvw8C0/Y5FNLBoZHL6PCx1ieeGpcthlHyHeMRae173NaM MQG/jfXCmlg4x+PG/i79jVuWVkm1Z9T2i3rkGZgKdYBCe4qL3JRXMgXkMmSmTp/SUeHtyHy/jAhr1 mJpKDQq8DRV4UrafIvuQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gC04p-0002nN-40; Mon, 15 Oct 2018 10:26:19 +0000 Received: from canardo.mork.no ([2001:4641::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gC04C-0002X2-Vv for openwrt-devel@lists.openwrt.org; Mon, 15 Oct 2018 10:25:43 +0000 Received: from canardo.mork.no (ip6-localhost [IPv6:0:0:0:0:0:0:0:1]) by canardo.mork.no (8.15.2/8.15.2) with ESMTPS id w9FAPNW0030870 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 15 Oct 2018 12:25:23 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mork.no; s=b; t=1539599123; bh=V5bavDAcBdSGswbBeJDCgTLYGrLgKKQidGZ795PbFUU=; h=From:To:Cc:Subject:Date:Message-Id:References:From; b=mEEbO77CF9gOtisH1s6Y1nHVTNX0uVKxK8qImudCG3C9J4cAqKUS5koSY5ybUW2p8 sTdXxh7CnPgqOcxwMWE7BJ7jq7/8nUuUaUXv4PaQoYHntSAsHsCDbPf33NWidQZ9aq Qu37yPR8TLHJOMW4ym6itbuUKSWTKHTDY8vGPLrQ= Received: (from bjorn@localhost) by canardo.mork.no (8.15.2/8.15.2/Submit) id w9FAPNYY030863; Mon, 15 Oct 2018 12:25:23 +0200 From: =?utf-8?q?Bj=C3=B8rn_Mork?= To: OpenWrt Development List Date: Mon, 15 Oct 2018 12:25:01 +0200 Message-Id: <20181015102503.30731-8-bjorn@mork.no> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181015102503.30731-1-bjorn@mork.no> References: <20181015102503.30731-1-bjorn@mork.no> MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on canardo.mork.no X-Virus-Scanned: clamav-milter 0.100.1 at canardo X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181015_032541_980080_3B18257A X-CRM114-Status: GOOD ( 10.86 ) X-Spam-Score: -2.4 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [2001:4641:0:0:0:0:0:1 listed in] [list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Subject: [OpenWrt-Devel] [RFC 7/9] mt7621: update dtsi X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Bj=C3=B8rn_Mork?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Signed-off-by: Bjørn Mork --- target/linux/ramips/dts/mt7621.dtsi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/target/linux/ramips/dts/mt7621.dtsi b/target/linux/ramips/dts/mt7621.dtsi index aa85aee6cb38..8b65f6149826 100644 --- a/target/linux/ramips/dts/mt7621.dtsi +++ b/target/linux/ramips/dts/mt7621.dtsi @@ -60,7 +60,7 @@ #size-cells = <1>; sysc: sysc@0 { - compatible = "mtk,mt7621-sysc"; + compatible = "mtk,mt7621-sysc", "syscon"; reg = <0x0 0x100>; }; @@ -408,7 +408,7 @@ }; ethernet: ethernet@1e100000 { - compatible = "mediatek,mt7621-eth"; + compatible = "mediatek,mt7621-eth", "syscon"; reg = <0x1e100000 0x10000>; #address-cells = <1>; @@ -421,6 +421,7 @@ interrupts = ; mediatek,switch = <&gsw>; + mediatek,ethsys = <&sysc>; mdio-bus { #address-cells = <1>; From patchwork Mon Oct 15 10:25:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Bj=C3=B8rn_Mork?= X-Patchwork-Id: 984075 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mork.no Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="sXZBUP5v"; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=mork.no header.i=@mork.no header.b="J8+3N4X0"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YZN562qDz9s3q for ; Mon, 15 Oct 2018 21:25:57 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=qukAuANiJldD9O63jn5Otmi3NLtoM1f12ypwoG07LtA=; b=sXZBUP5v9q76OQ om9cQN6JVeZFZGw9rX2yS1pfiyM5F7t/Z3d3tNTU1ay2SUJTR8MWYBkFbnMgiVFel8SYEtz7cKWk2 qWmYOF5O1DLLc8s9SppipABBtCTX8GVuKg/8xn98WZsD5nqYxn/8bAUhT6ltPCw86+iydm2qy3N/6 4r/uEiD2ZYvFE6F9Uow34hHUYzGTXTgNhsgxfwk/GMJrBT/52xmLw9fsjZbxgyAilcqSvH/iHmv5b fiKnTu7PSKrdIgJokxt9Q5RLKNGGOgDx8xn5WQ/RT3O2sqhv89AThf9GEXnxnnJ5uZ7Hr3UJpDT4E OpUsTtOV31yHE+3e+i0A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gC04J-0002b1-S7; Mon, 15 Oct 2018 10:25:47 +0000 Received: from canardo.mork.no ([2001:4641::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gC04D-0002X3-10 for openwrt-devel@lists.openwrt.org; Mon, 15 Oct 2018 10:25:43 +0000 Received: from canardo.mork.no (ip6-localhost [IPv6:0:0:0:0:0:0:0:1]) by canardo.mork.no (8.15.2/8.15.2) with ESMTPS id w9FAPN6N030880 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 15 Oct 2018 12:25:23 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mork.no; s=b; t=1539599123; bh=SnwMtqnBl+6x2vNT2iqvWxPSzUsLB6Ue9Wzz+HyJC0o=; h=From:To:Cc:Subject:Date:Message-Id:References:From; b=J8+3N4X0IY1ssY2k3JAkSclpNIuVGsiMvEEJ/MEpOVhHFj/3hkYSg6mG01Ue1bH/+ 2U04DKCmVtOHPDE11AcHEYwtQgdriQ63yIAJaXKHZoY3Hn1VI/nPrjWl62NtBAw9fz 9v0nwFgOptqjMs208wMSG47Rmz53VgixC88GtUjw= Received: (from bjorn@localhost) by canardo.mork.no (8.15.2/8.15.2/Submit) id w9FAPNt7030873; Mon, 15 Oct 2018 12:25:23 +0200 From: =?utf-8?q?Bj=C3=B8rn_Mork?= To: OpenWrt Development List Date: Mon, 15 Oct 2018 12:25:02 +0200 Message-Id: <20181015102503.30731-9-bjorn@mork.no> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181015102503.30731-1-bjorn@mork.no> References: <20181015102503.30731-1-bjorn@mork.no> MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on canardo.mork.no X-Virus-Scanned: clamav-milter 0.100.1 at canardo X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181015_032541_960537_ADA390F8 X-CRM114-Status: UNSURE ( 8.69 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.4 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [2001:4641:0:0:0:0:0:1 listed in] [list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Subject: [OpenWrt-Devel] [RFC 8/9] mt7621 dsa: add virtual DSA kernel package X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Bj=C3=B8rn_Mork?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Signed-off-by: Bjørn Mork --- target/linux/ramips/modules.mk | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/target/linux/ramips/modules.mk b/target/linux/ramips/modules.mk index 88e83a487f6f..5c3b09721934 100644 --- a/target/linux/ramips/modules.mk +++ b/target/linux/ramips/modules.mk @@ -136,3 +136,29 @@ define KernelPackage/sound-mt7620/description endef $(eval $(call KernelPackage,sound-mt7620)) + +define KernelPackage/mtk-eth-soc + TITLE:=Use mainline MediaTek ethernet driver with DSA + DEPENDS:=@TARGET_ramips @TARGET_ramips_mt7621 + HIDDEN:=1 + KCONFIG:= \ + NET_VENDOR_RALINK=n \ + CONFIG_NET_RALINK_SOC=n \ + CONFIG_NET_RALINK_GSW_MT7621=n \ + CONFIG_NET_RALINK_MDIO=n \ + CONFIG_NET_RALINK_MDIO_MT7620=n \ + CONFIG_NET_RALINK_MT7621=n \ + CONFIG_NET_VENDOR_MEDIATEK=y \ + CONFIG_NET_MEDIATEK_SOC=y \ + CONFIG_NET_DSA=y \ + CONFIG_NET_DSA_MT7530=y \ + CONFIG_NET_DSA_TAG_MTK=y \ + CONFIG_BRIDGE_VLAN_FILTERING=y \ + CONFIG_MDIO_BUS=y \ + CONFIG_MDIO_DEVICE=y \ + CONFIG_MDIO_I2C=y \ + CONFIG_MFD_SYSCON=y \ + CONFIG_REGMAP_MMIO=y +endef + +$(eval $(call KernelPackage,mtk-eth-soc)) From patchwork Mon Oct 15 10:25:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Bj=C3=B8rn_Mork?= X-Patchwork-Id: 984078 X-Patchwork-Delegate: blogic@openwrt.org Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=mork.no Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="HCk52oSe"; dkim=fail reason="signature verification failed" (1024-bit key; secure) header.d=mork.no header.i=@mork.no header.b="FrZGeAwl"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42YZQ35frMz9s3q for ; Mon, 15 Oct 2018 21:27:39 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Subject:MIME-Version:References: In-Reply-To:Message-Id:Date:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=9R25+I/NSOgxEhKxn/44xIPQozACEcdrO4KyVRZnTjY=; b=HCk52oSetQNGym AuBgsemAwgWRBbPzPRjteQ+FT+4VLW3l8DaVVHAjVBPJnJZLCBvhO9iQiVklM/6KIMD0JIAKxN5HB 9JkK15VvTryvJNuUuEaBPm1tyLGlLkwClhrt0qr+rKqBueQ6YVdARXI+feJQSF5QA6i4kGe4TyDiy 8892Lr3QLhlkPlwMnDU3T9dKk05JMJWsw8FslhmyJp/LvMns87mbmtoKw/mZNELN61xf6hzgqJlR3 xejcumdLRpdrEZ7Atj5+FjB1fIWbJ+CoaCNM+LIEFvLfY++vUFpqNR+twVCOYCj4kzjrbDMaN2puQ JXnb5qCwkQngxLR9RbDQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gC05x-0003Ls-Ss; Mon, 15 Oct 2018 10:27:29 +0000 Received: from canardo.mork.no ([2001:4641::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gC04C-0002X4-Vr for openwrt-devel@lists.openwrt.org; Mon, 15 Oct 2018 10:25:47 +0000 Received: from canardo.mork.no (ip6-localhost [IPv6:0:0:0:0:0:0:0:1]) by canardo.mork.no (8.15.2/8.15.2) with ESMTPS id w9FAPNZY030890 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 15 Oct 2018 12:25:23 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mork.no; s=b; t=1539599124; bh=mGDP7P2fT4N7JtQblOeiiwRWCKOQL9kYvhcGh/nimaU=; h=From:To:Cc:Subject:Date:Message-Id:References:From; b=FrZGeAwlqDacf1lcjTfmBk0u05JYRJXKPkf746QuKn36b3rbSvwc/zF7uE5RJSwiC WJiweFBeBoV0Y/uASF4Bro5ydeBVko4TZpW6c0T4aIcB7Egc3GV7KOnPkFuhOGLOHo LnzIinA8z9N4Hkq5HOVV2gZfvgii4VfCmE5FCrwY= Received: (from bjorn@localhost) by canardo.mork.no (8.15.2/8.15.2/Submit) id w9FAPNoQ030883; Mon, 15 Oct 2018 12:25:23 +0200 From: =?utf-8?q?Bj=C3=B8rn_Mork?= To: OpenWrt Development List Date: Mon, 15 Oct 2018 12:25:03 +0200 Message-Id: <20181015102503.30731-10-bjorn@mork.no> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181015102503.30731-1-bjorn@mork.no> References: <20181015102503.30731-1-bjorn@mork.no> MIME-Version: 1.0 X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT shortcircuit=ham autolearn=disabled version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on canardo.mork.no X-Virus-Scanned: clamav-milter 0.100.1 at canardo X-Virus-Status: Clean X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181015_032541_992721_7CF4BDF0 X-CRM114-Status: GOOD ( 12.06 ) X-Spam-Score: -2.4 (--) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-2.4 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [2001:4641:0:0:0:0:0:1 listed in] [list.dnswl.org] -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid Subject: [OpenWrt-Devel] [RFC 9/9] wap6805: use mtk-eth-soc driver with DSA X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: =?utf-8?q?Bj=C3=B8rn_Mork?= Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org Signed-off-by: Bjørn Mork --- .../linux/ramips/base-files/etc/board.d/02_network | 3 +- target/linux/ramips/dts/WAP6805.dts | 61 +++++++++++++++++++++- target/linux/ramips/image/mt7621.mk | 1 + 3 files changed, 62 insertions(+), 3 deletions(-) diff --git a/target/linux/ramips/base-files/etc/board.d/02_network b/target/linux/ramips/base-files/etc/board.d/02_network index f53bf02d221f..5b0dffbc0be2 100755 --- a/target/linux/ramips/base-files/etc/board.d/02_network +++ b/target/linux/ramips/base-files/etc/board.d/02_network @@ -405,8 +405,7 @@ ramips_setup_interfaces() "0:lan:2" "1:lan:1" "4:wan" "6@eth0" ;; wap6805) - ucidef_add_switch "switch0" \ - "0:lan:4" "1:lan:3" "2:lan:2" "3:lan:1" "6@eth0" + ucidef_set_interface_lan "lan0 lan1 lan2 lan3" ;; *) RT3X5X=`cat /proc/cpuinfo | egrep "(RT3.5|RT5350)"` diff --git a/target/linux/ramips/dts/WAP6805.dts b/target/linux/ramips/dts/WAP6805.dts index 53ef7301d13b..95fd3ecbebda 100644 --- a/target/linux/ramips/dts/WAP6805.dts +++ b/target/linux/ramips/dts/WAP6805.dts @@ -125,7 +125,66 @@ }; ðernet { - mtd-mac-address = <&factory 0xe000>; + gmac0: mac@0 { + compatible = "mediatek,eth-mac"; + reg = <0>; + phy-mode = "rgmii"; + mtd-mac-address = <&factory 0xe000>; + fixed-link { + speed = <1000>; + full-duplex; + pause; + }; + }; + gmac1: mac@1 { + compatible = "mediatek,eth-mac"; + reg = <1>; + mtd-mac-address = <&factory 0xe000>; + mtd-mac-address-increment = <1>; + phy-mode = "rgmii"; + fixed-link { + speed = <1000>; + full-duplex; + pause; + }; + }; +}; + +&phy1f { + compatible = "mediatek,mt7530"; + #address-cells = <1>; + #size-cells = <0>; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + label = "lan0"; + cpu = <&cpu_port0>; + }; + port@1 { + reg = <1>; + label = "lan1"; + cpu = <&cpu_port0>; + }; + port@2 { + reg = <2>; + label = "lan2"; + cpu = <&cpu_port0>; + }; + port@3 { + reg = <3>; + label = "lan3"; + cpu = <&cpu_port0>; + }; + cpu_port0: port@6 { + reg = <6>; + label = "cpu"; + ethernet = <&gmac0>; + }; + }; }; &xhci { diff --git a/target/linux/ramips/image/mt7621.mk b/target/linux/ramips/image/mt7621.mk index cc37c53bad28..b2f07b5e2e68 100644 --- a/target/linux/ramips/image/mt7621.mk +++ b/target/linux/ramips/image/mt7621.mk @@ -539,6 +539,7 @@ define Device/wap6805 IMAGE_SIZE := $(ralink_default_fw_size_32M) DEVICE_TITLE := ZyXEL WAP6805 DEVICE_PACKAGES := \ + kmod-mtk-eth-soc \ kmod-mt7603 kmod-mt76x2 \ kmod-usb3 kmod-usb-ledtrig-usbport wpad-mini \ -swconfig