[linux-sunxi] Re: [PATCH v2 3/7] spl: nand: support redundant u-boot image
On Wed, 2016-06-01 at 13:23 +0200, Boris Brezillon wrote: > On modern NAND it's more than recommended to have a backup copy of the > u-boot binary to recover from corruption: bitflips are quite common on > MLC NANDs, and the read-disturbance will corrupt your u-boot partitition > more quickly than what you would see on an SLC NAND. Wouldn't the same happen to the SPL itself? Or is the boot block implemented in a different, more robust manner? > Add an extra Kconfig option to specify the offset of the redundant u-boot > image. > > Signed-off-by: Boris Brezillon> Acked-by: Hans de Goede > --- > common/spl/spl_nand.c| 8 > drivers/mtd/nand/Kconfig | 6 ++ > 2 files changed, 14 insertions(+) > > diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c > index 612bd4a..0bf0848 100644 > --- a/common/spl/spl_nand.c > +++ b/common/spl/spl_nand.c > @@ -12,6 +12,9 @@ > > #ifndef CONFIG_SYS_NAND_U_BOOT_OFFS > #define CONFIG_SYS_NAND_U_BOOT_OFFS CONFIG_SPL_NAND_U_BOOT_OFFS > +#define CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND > CONFIG_SPL_NAND_U_BOOT_OFFS_REDUND > +#else > +#define CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND CONFIG_SYS_NAND_U_BOOT_OFFS > #endif > > #if defined(CONFIG_SPL_NAND_RAW_ONLY) > @@ -111,6 +114,11 @@ int spl_nand_load_image(void) > #endif > /* Load u-boot */ > err = spl_nand_load_element(CONFIG_SYS_NAND_U_BOOT_OFFS, header); > +#if CONFIG_SYS_NAND_U_BOOT_OFFS != CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND > + if (err) > + err = > spl_nand_load_element(CONFIG_SYS_NAND_U_BOOT_OFFS_REDUND, > + header); > +#endif If one of the images has failed, doesn't it need to be reflashed before the other one goes bad as well? How does the failure get communicated to later parts of the system that would be responsible for such reflashing? -Scott -- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[linux-sunxi] Re: [PATCH v2 2/7] spl: nand: rename the SYS_NAND_U_BOOT_OFFS Kconfig option
On Wed, 2016-06-01 at 13:23 +0200, Boris Brezillon wrote: > The SYS_NAND_U_BOOT_OFFS is quite generic, but the Kconfig entry is forced > to explicitly depend on platforms that are not already defining it in their > include/configs/.h header. > > Rename this Kconfig option into SPL_NAND_U_BOOT_OFFS, remove the dependency > on NAND_SUNXI and make it dependent on SPL selection. > > common/spl/spl_nand.c now sets CONFIG_SYS_NAND_U_BOOT_OFFS to > CONFIG_SPL_NAND_U_BOOT_OFFS only when it's undefined. This way we stay > compatible with the existing behavior. > > Signed-off-by: Boris Brezillon> Acked-by: Hans de Goede > --- > common/spl/spl_nand.c | 4 > drivers/mtd/nand/Kconfig | 9 + > drivers/mtd/nand/sunxi_nand_spl.c | 8 > 3 files changed, 13 insertions(+), 8 deletions(-) > > diff --git a/common/spl/spl_nand.c b/common/spl/spl_nand.c > index bbd9546..612bd4a 100644 > --- a/common/spl/spl_nand.c > +++ b/common/spl/spl_nand.c > @@ -10,6 +10,10 @@ > #include > #include > > +#ifndef CONFIG_SYS_NAND_U_BOOT_OFFS > +#define CONFIG_SYS_NAND_U_BOOT_OFFS CONFIG_SPL_NAND_U_BOOT_OFFS > +#endif [snip] > -# Enhance depends when converting drivers to Kconfig which use this config > -config SYS_NAND_U_BOOT_OFFS > +if SPL > + > +# This option should be used in replacement of CONFIG_SYS_NAND_U_BOOT_OFFS. > +# CONFIG_SYS_NAND_U_BOOT_OFFS is still preferred if defined. > +config SPL_NAND_U_BOOT_OFFS > hex "Location in NAND to read U-Boot from" > default 0x8000 if NAND_SUNXI > - depends on NAND_SUNXI > help > Set the offset from the start of the nand where u-boot should be > loaded from. This doesn't work. CONFIG_SPL_NAND_U_BOOT_OFFS will always be defined when SPL is defined, and the user will be forced to enter a value before kconfig will continue (or kconfig will error out in an automated build). If you want to do this there needs to be a separate bool config that controls whether the hex config exists. And there'd be no need to rename hex symbol. -Scott -- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[linux-sunxi] Re: [PATCH 1/5] ethernet: add sun8i-emac driver
From: LABBE CorentinDate: Fri, 3 Jun 2016 11:56:26 +0200 > +static int nbdesc_tx = 256; > +module_param(nbdesc_tx, int, S_IRUGO | S_IWUSR); > +MODULE_PARM_DESC(nbdesc_tx, "Number of descriptors in the TX list"); > +static int nbdesc_rx = 128; > +module_param(nbdesc_rx, int, S_IRUGO | S_IWUSR); > +MODULE_PARM_DESC(nbdesc_rx, "Number of descriptors in the RX list"); Module parameters are not appropriate. Please use the proper ethtool configuration facilities to control the size of the RX and TX queues. Thanks.
Re: [linux-sunxi] Re: [PATCH 1/1] devicetree: sunxi: Add OLinuXino Lime2 eMMC to the Makefile
On Mon, May 16, 2016 at 04:45:52PM +0200, Maxime Ripard wrote: > On Fri, May 13, 2016 at 09:57:16PM +0200, Olliver Schinagl wrote: > > commit 27dd9af6bc000ab21fd ("ARM: dts: sunxi: Add a olinuxino-lime2-emmc") > > added the new emmc equipped lime2 but forgot its Makefile. > > > > This patch adds an entry to the Makefile. > > > > Signed-off-by: Olliver Schinagl> > Having the version of the patch would be nice too. > > Acked-by: Maxime Ripard > > Arnd, Kevin, Olof, could you apply that patch directly for 4.7? Applied as fix now, but with the patch subject fixed up (ARM: dts: sunxi: ...). -Olof > > Thanks, > Maxime > > -- > Maxime Ripard, Free Electrons > Embedded Linux, Kernel and Android engineering > http://free-electrons.com > > -- > You received this message because you are subscribed to the Google Groups > "linux-sunxi" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to linux-sunxi+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[linux-sunxi] [PATCH sunxi-tools v3 1/4] nand-image-builder: Fix the copyright header
Add NextThing Co. and Free Electrons copyrights and add myself as the author of the randomizer and image builder implementation. Remove the lengthy description explaining how the BCH implementation works, since this is the purpose of this tool is not to expose a BCH library (which was the case of the original source code I copied from the kernel). Signed-off-by: Boris Brezillon--- Changes since v1: - Add a link to the original bch.c source file --- nand-image-builder.c | 49 - 1 file changed, 8 insertions(+), 41 deletions(-) diff --git a/nand-image-builder.c b/nand-image-builder.c index 645d1cc..a5fb3d8 100644 --- a/nand-image-builder.c +++ b/nand-image-builder.c @@ -14,55 +14,22 @@ * this program; if not, write to the Free Software Foundation, Inc., 51 * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * + * For the BCH implementation: + * * Copyright © 2011 Parrot S.A. * * Author: Ivan Djelic * - * Description: - * - * This library provides runtime configurable encoding/decoding of binary - * Bose-Chaudhuri-Hocquenghem (BCH) codes. - * - * Call init_bch to get a pointer to a newly allocated bch_control structure for - * the given m (Galois field order), t (error correction capability) and - * (optional) primitive polynomial parameters. - * - * Call encode_bch to compute and store ecc parity bytes to a given buffer. - * Call decode_bch to detect and locate errors in received data. - * - * On systems supporting hw BCH features, intermediate results may be provided - * to decode_bch in order to skip certain steps. See decode_bch() documentation - * for details. - * - * Option CONFIG_BCH_CONST_PARAMS can be used to force fixed values of - * parameters m and t; thus allowing extra compiler optimizations and providing - * better (up to 2x) encoding performance. Using this option makes sense when - * (m,t) are fixed and known in advance, e.g. when using BCH error correction - * on a particular NAND flash device. - * - * Algorithmic details: + * See also: + * http://lxr.free-electrons.com/source/lib/bch.c * - * Encoding is performed by processing 32 input bits in parallel, using 4 - * remainder lookup tables. + * For the randomizer and image builder implementation: * - * The final stage of decoding involves the following internal steps: - * a. Syndrome computation - * b. Error locator polynomial computation using Berlekamp-Massey algorithm - * c. Error locator root finding (by far the most expensive step) + * Copyright © 2016 NextThing Co. + * Copyright © 2016 Free Electrons * - * In this implementation, step c is not performed using the usual Chien search. - * Instead, an alternative approach described in [1] is used. It consists in - * factoring the error locator polynomial using the Berlekamp Trace algorithm - * (BTA) down to a certain degree (4), after which ad hoc low-degree polynomial - * solving techniques [2] are used. The resulting algorithm, called BTZ, yields - * much better performance than Chien search for usual (m,t) values (typically - * m >= 13, t < 32, see [1]). + * Author: Boris Brezillon * - * [1] B. Biswas, V. Herbert. Efficient root finding of polynomials over fields - * of characteristic 2, in: Western European Workshop on Research in Cryptology - * - WEWoRC 2009, Graz, Austria, LNCS, Springer, July 2009, to appear. - * [2] [Zin96] V.A. Zinoviev. On the solution of equations of degree 10 over - * finite fields GF(2^q). In Rapport de recherche INRIA no 2829, 1996. */ #include -- 2.7.4 -- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[linux-sunxi] [PATCH sunxi-tools v3 2/4] nand-image-builder: Add error messages to check_image_info()
Add error messages explaining what is wrong or missing in the arguments passed by to the sunxi-nand-image-builder tool. Signed-off-by: Boris BrezillonAcked-by: Bernhard Nortmann --- Changes since v1: - Drop uneeded braces --- nand-image-builder.c | 30 +- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/nand-image-builder.c b/nand-image-builder.c index a5fb3d8..465ab36 100644 --- a/nand-image-builder.c +++ b/nand-image-builder.c @@ -941,20 +941,37 @@ static int check_image_info(struct image_info *info) int eccbytes, eccsteps; unsigned i; - if (!info->page_size || !info->oob_size || !info->eraseblock_size || - !info->usable_page_size) + if (!info->page_size) { + fprintf(stderr, "--page-size is missing\n"); return -EINVAL; + } + + if (!info->page_size) { + fprintf(stderr, "--oob-size is missing\n"); + return -EINVAL; + } + + if (!info->eraseblock_size) { + fprintf(stderr, "--eraseblock-size is missing\n"); + return -EINVAL; + } - if (info->ecc_step_size != 512 && info->ecc_step_size != 1024) + if (info->ecc_step_size != 512 && info->ecc_step_size != 1024) { + fprintf(stderr, "Invalid ECC step argument: %d\n", + info->ecc_step_size); return -EINVAL; + } for (i = 0; i < ARRAY_SIZE(valid_ecc_strengths); i++) { if (valid_ecc_strengths[i] == info->ecc_strength) break; } - if (i == ARRAY_SIZE(valid_ecc_strengths)) + if (i == ARRAY_SIZE(valid_ecc_strengths)) { + fprintf(stderr, "Invalid ECC strength argument: %d\n", + info->ecc_strength); return -EINVAL; + } eccbytes = DIV_ROUND_UP(info->ecc_strength * 14, 8); if (eccbytes % 2) @@ -964,8 +981,11 @@ static int check_image_info(struct image_info *info) eccsteps = info->usable_page_size / info->ecc_step_size; if (info->page_size + info->oob_size < - info->usable_page_size + (eccsteps * (eccbytes))) + info->usable_page_size + (eccsteps * eccbytes)) { + fprintf(stderr, + "ECC bytes do not fit in the NAND page, choose a weaker ECC\n"); return -EINVAL; + } return 0; } -- 2.7.4 -- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[linux-sunxi] [PATCH sunxi-tools v3 3/4] nand-image-builder: Rework the help context
Add explanations on where the options to pass to the tool should be extracted from, and add two examples to illustrate this explanation. Signed-off-by: Boris Brezillon--- Changes since v2: - limit line width in the help context Changes since v1: - use shorter option names - rework the help context --- nand-image-builder.c | 70 +--- 1 file changed, 50 insertions(+), 20 deletions(-) diff --git a/nand-image-builder.c b/nand-image-builder.c index 465ab36..230ed0c 100644 --- a/nand-image-builder.c +++ b/nand-image-builder.c @@ -917,21 +917,51 @@ static void display_help(int status) { fprintf(status == EXIT_SUCCESS ? stdout : stderr, "Usage: sunxi-nand-image-builder [OPTIONS] source-image output-image\n" + "\n" "Creates a raw NAND image that can be read by the sunxi NAND controller.\n" "\n" - "-h --help Display this help and exit\n" - "-c / --ecc=/ ECC config\n" - " Valid strengths: 16, 24, 28, 32, 40, 48, 56, 60 and 64\n" - " Valid steps: 512 and 1024\n" - "-p --page-size= Page size\n" - "-o --oob-size= OOB size\n" - "-u --usable-page-size= Usable page size. Only needed for boot0 mode\n" - "-e --eraseblock-size=Erase block size\n" - "-b --boot0 Build a boot0 image.\n" - "-s --scramble Scramble data\n" - "-a --address Where the image will be programmed.\n" - " This option is only required for non boot0 images that are meant to be programmed at a non eraseblock aligned offset.\n" - "\n"); + "-h --help Display this help and exit\n" + "-c / --ecc=/ ECC config (strength/step-size)\n" + "-p --page=Page size\n" + "-o --oob= OOB size\n" + "-u --usable= Usable page size\n" + "-e --eraseblock= Erase block size\n" + "-b --boot0 Build a boot0 image.\n" + "-s --scramble Scramble data\n" + "-a --addressWhere the image will be programmed.\n" + "\n" + "Notes:\n" + "All the information you need to pass to this tool should be part of\n" + "the NAND datasheet.\n" + "\n" + "The NAND controller only supports the following ECC configs\n" + " Valid ECC strengths: 16, 24, 28, 32, 40, 48, 56, 60 and 64\n" + " Valid ECC step size: 512 and 1024\n" + "\n" + "If you are building a boot0 image, you'll have specify extra options.\n" + "These options should be chosen based on the layouts described here:\n" + " http://linux-sunxi.org/NAND#More_information_on_BROM_NAND\n; + "\n" + " --usable should be assigned the 'Hardware page' value\n" + " --ecc should be assigned the 'ECC capacity'/'ECC page' values\n" + " --usable should be smaller than --page\n" + "\n" + "The --address option is only required for non-boot0 images that are \n" + "meant to be programmed at a non eraseblock aligned offset.\n" + "\n" + "Examples:\n" + " The H27UCG8T2BTR-BC NAND exposes\n" + " * 16k pages\n" + " * 1280 OOB bytes per page\n" + " * 4M eraseblocks\n" + " * requires data scrambling\n" + " * expects a minimum ECC of 40bits/1024bytes\n" + "\n" + " A normal image can be generated with\n" + "sunxi-nand-image-builder -p 16384 -o 1280 -e 0x40 -s -c 40/1024\n" + " A boot0 image can be generated with\n" + "sunxi-nand-image-builder -p 16384 -o 1280 -e 0x40 -s -b -u 4096 -c 64/1024\n" + ); exit(status); } @@ -942,17 +972,17 @@ static int check_image_info(struct image_info *info) unsigned i; if (!info->page_size) { - fprintf(stderr, "--page-size is missing\n"); + fprintf(stderr, "--page is missing\n"); return -EINVAL; } if (!info->page_size)
[linux-sunxi] [PATCH sunxi-tools v3 4/4] nand-image-builder: Fix --help/-h option
--help/-h is not working correctly (it's printing the help context on stderr instead of stdout). Adding a valid shortcut for --help solves the problem. Signed-off-by: Boris Brezillon--- nand-image-builder.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nand-image-builder.c b/nand-image-builder.c index 230ed0c..cb39d5d 100644 --- a/nand-image-builder.c +++ b/nand-image-builder.c @@ -1032,7 +1032,7 @@ int main(int argc, char **argv) int option_index = 0; char *endptr = NULL; static const struct option long_options[] = { - {"help", no_argument, 0, 0}, + {"help", no_argument, 0, 'h'}, {"ecc", required_argument, 0, 'c'}, {"page", required_argument, 0, 'p'}, {"oob", required_argument, 0, 'o'}, @@ -1044,7 +1044,7 @@ int main(int argc, char **argv) {0, 0, 0, 0}, }; - int c = getopt_long(argc, argv, "c:p:o:u:e:ba:s", + int c = getopt_long(argc, argv, "c:p:o:u:e:ba:sh", long_options, _index); if (c == EOF) break; -- 2.7.4 -- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[linux-sunxi] Re: [PATCH RFC 1/2] clk: sunxi-ng: Add the A83T and A80 PLL clocks
Hi Wens, Thanks for the review. On Fri, 3 Jun 2016 14:53:24 +0800 Chen-Yu Tsaiwrote: > On Tue, May 31, 2016 at 3:26 PM, Jean-Francois Moine wrote: > > The A83T and A80 SoCs have unique settings of their PLL clocks. > > > > Signed-off-by: Jean-Francois Moine > > --- > > drivers/clk/sunxi-ng/ccu_ndmp.c | 247 > > > > drivers/clk/sunxi-ng/ccu_ndmp.h | 45 > > 2 files changed, 292 insertions(+) > > create mode 100644 drivers/clk/sunxi-ng/ccu_ndmp.c > > create mode 100644 drivers/clk/sunxi-ng/ccu_ndmp.h > > > > diff --git a/drivers/clk/sunxi-ng/ccu_ndmp.c > > b/drivers/clk/sunxi-ng/ccu_ndmp.c > > new file mode 100644 > > index 000..079b155 > > --- /dev/null > > +++ b/drivers/clk/sunxi-ng/ccu_ndmp.c > > @@ -0,0 +1,247 @@ > > +/* > > + * PLL clocks of sun8iw6 (A83T) and sun9iw1 (A80) > > + * > > + * Copyright (c) 2016 Jean-Francois Moine > > + * > > + * 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. > > + * > > + * The clock rates are computed as: > > + * rate = parent_rate / d1 * n / d2 / m >> p > > + */ > > + > > +#include > > +#include > > +#include > > + > > +#include "ccu_gate.h" > > +#include "ccu_ndmp.h" [snip] > > +/* d1 and d2 may be only 1 or 2 */ > > +static int ccu_ndmp_get_fact(struct ccu_ndmp *ndmp, > > + unsigned long rate, unsigned long prate, > > + int *p_n, int *p_d1, int *p_d2, int *p_m, int *p_p) > > +{ > > + int n, d1, d2, m, p, d; > > + unsigned long t; > > + > > + /* m implies only n, d1, d2 and m (pll-audio) */ > > + /* Setting d1=1 and d2=2 keeps n and m small enough > > +* with error < 5/1 */ > > + /* As only 2 rates are used, this could be simplified: > > Best not simplify generic code to specific use cases. Well, the Allwinner's audio PLL clocks always ask for these 2 rates only. Anyway, this is just a comment. > > +* 22579200Hz => n = 32, m = 17 > > +* 24576000Hz => n = 43, m = 21 > > +*/ > > + if (ndmp->m.shift) { > > shift could be 0. Testing against width is better. > Same for the other functions. Yes. I fixed this already, with some other bugs. > > + long unsigned int lun, lum; > > unsigned long, to match other places. > > > + > > + d1 = 0 + 1; > > + d2 = 1 + 1; > > + t = prate / 2; > > + rational_best_approximation(rate, t, > > + 1 << ndmp->n.width, > > + 1 << ndmp->m.width, > > + , ); > > + if (lum == 0) > > + return -EINVAL; > > + n = lun; > > + m = lum; > > + p = 0; > > + > > + /* no d1 implies n alone (pll-cxcpux) */ > > Pretending these don't have a p factor does not make it disappear. > > > + } else if (!ndmp->d1.shift) { > > + d1 = d2 = 0 + 1; > > If you say they aren't there, why do you still need to set them. > > > + n = rate / prate; > > + m = 1; > > + p = 0; > > A note about why p isn't used would be nice. Like: > > P should only be used for rates under 288 MHz. > > from the manual. Yes. > > + > > + /* p implies only n, d1 and p (pll-videox) */ > > + } else if (ndmp->m.shift) { > >^ p? Yes. Already fixed. > > + d2 = 0 + 1; > > + d = 2 + ndmp->p.width; > > + n = rate / (prate / (1 << d)); > > + if (n < 12) { > > + n *= 2; > > + d++; > > + } > > + while (n >= 12 * 2 && !(n & 1)) { > > + n /= 2; > > + if (--d == 0) > > + break; > > + } > > + if (d <= 1) { > > + d1 = d + 1; > > + p = 0; > > + } else { > > + d1 = 1 + 1; > > + p = d - 1; > > + } > > + m = 1; > > + > > + /* only n, d1 and d2 (other plls) */ > > + } else { > > + t = prate / 4; > > + n = rate / t; > > + if (n < 12) { > > + n *= 4; > > + d1 = d2 = 0 + 1; > > + } else if (n >= 12 * 2 && !(n & 1)) { > > + if (n >= 12 * 4 && !(n % 4)) { > > + n /= 4; > > + d1 = d2 = 0 + 1; > > +
[linux-sunxi] [PATCH 2/5] MAINTAINERS: Add myself as maintainers of sun8i-emac
Signed-off-by: LABBE Corentin--- MAINTAINERS | 6 ++ 1 file changed, 6 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index ed42cb6..d8f5c14 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -581,6 +581,12 @@ S: Maintained F: Documentation/i2c/busses/i2c-ali1563 F: drivers/i2c/busses/i2c-ali1563.c +ALLWINNER SUN8I-EMAC ETHERNET DRIVER +M: Corentin Labbe +L: net...@vger.kernel.org +S: Maintained +F: drivers/net/ethernet/allwinner/sun8i-emac.c + ALLWINNER SECURITY SYSTEM M: Corentin Labbe L: linux-cry...@vger.kernel.org -- 2.7.3 -- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[linux-sunxi] [PATCH 1/5] ethernet: add sun8i-emac driver
This patch add support for sun8i-emac ethernet MAC hardware. It could be found in Allwinner H3/A83T/A64 SoCs. It supports 10/100/1000 Mbit/s speed with half/full duplex. It can use an internal PHY (MII 10/100) or an external PHY via RGMII/RMII. Signed-off-by: LABBE Corentin--- drivers/net/ethernet/allwinner/Kconfig | 13 + drivers/net/ethernet/allwinner/Makefile |1 + drivers/net/ethernet/allwinner/sun8i-emac.c | 1943 +++ 3 files changed, 1957 insertions(+) create mode 100644 drivers/net/ethernet/allwinner/sun8i-emac.c diff --git a/drivers/net/ethernet/allwinner/Kconfig b/drivers/net/ethernet/allwinner/Kconfig index 47da7e7..226499d 100644 --- a/drivers/net/ethernet/allwinner/Kconfig +++ b/drivers/net/ethernet/allwinner/Kconfig @@ -33,4 +33,17 @@ config SUN4I_EMAC To compile this driver as a module, choose M here. The module will be called sun4i-emac. +config SUN8I_EMAC +tristate "Allwinner sun8i EMAC support" + depends on ARCH_SUNXI || COMPILE_TEST + depends on OF + select MII + select PHYLIB +---help--- + This driver support the sun8i EMAC ethernet driver present on + H3/A83T/A64 Allwinner SoCs. + + To compile this driver as a module, choose M here. The module + will be called sun8i-emac. + endif # NET_VENDOR_ALLWINNER diff --git a/drivers/net/ethernet/allwinner/Makefile b/drivers/net/ethernet/allwinner/Makefile index 03129f7..8bd1693c 100644 --- a/drivers/net/ethernet/allwinner/Makefile +++ b/drivers/net/ethernet/allwinner/Makefile @@ -3,3 +3,4 @@ # obj-$(CONFIG_SUN4I_EMAC) += sun4i-emac.o +obj-$(CONFIG_SUN8I_EMAC) += sun8i-emac.o diff --git a/drivers/net/ethernet/allwinner/sun8i-emac.c b/drivers/net/ethernet/allwinner/sun8i-emac.c new file mode 100644 index 000..179aa61 --- /dev/null +++ b/drivers/net/ethernet/allwinner/sun8i-emac.c @@ -0,0 +1,1943 @@ +/* + * sun8i-emac driver + * + * Copyright (C) 2015-2016 Corentin LABBE + * + * This is the driver for Allwinner Ethernet MAC found in H3/A83T/A64 SoC + * + * TODO: + * - NAPI + * - MAC filtering + * - Jumbo frame + * - features rx-all (NETIF_F_RXALL_BIT) + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define SUN8I_EMAC_BASIC_CTL0 0x00 +#define SUN8I_EMAC_BASIC_CTL1 0x04 + +#define SUN8I_EMAC_MDIO_CMD 0x48 +#define SUN8I_EMAC_MDIO_DATA 0x4C + +#define SUN8I_EMAC_RX_CTL0 0x24 +#define SUN8I_EMAC_RX_CTL1 0x28 + +#define SUN8I_EMAC_TX_CTL0 0x10 +#define SUN8I_EMAC_TX_CTL1 0x14 + +#define SUN8I_EMAC_TX_FLOW_CTL 0x1C + +#define SUN8I_EMAC_RX_FRM_FLT 0x38 + +#define SUN8I_EMAC_INT_STA 0x08 +#define SUN8I_EMAC_INT_EN 0x0C +#define SUN8I_EMAC_RGMII_STA 0xD0 + +#define SUN8I_EMAC_TX_DMA_STA 0xB0 +#define SUN8I_EMAC_TX_CUR_DESC 0xB4 +#define SUN8I_EMAC_TX_CUR_BUF 0xB8 +#define SUN8I_EMAC_RX_DMA_STA 0xC0 + +#define MDIO_CMD_MII_BUSY BIT(0) +#define MDIO_CMD_MII_WRITE BIT(1) +#define MDIO_CMD_MII_PHY_REG_ADDR_MASK GENMASK(8, 4) +#define MDIO_CMD_MII_PHY_REG_ADDR_SHIFT4 +#define MDIO_CMD_MII_PHY_ADDR_MASK GENMASK(16, 12) +#define MDIO_CMD_MII_PHY_ADDR_SHIFT12 + +#define SUN8I_EMAC_MACADDR_HI 0x50 +#define SUN8I_EMAC_MACADDR_LO 0x54 + +#define SUN8I_EMAC_RX_DESC_LIST 0x34 +#define SUN8I_EMAC_TX_DESC_LIST 0x20 + +#define SUN8I_EMAC_TX_DO_CRC (BIT(27) | BIT(28)) +#define SUN8I_EMAC_RX_DO_CRC BIT(27) +#define SUN8I_EMAC_RX_STRIP_FCS BIT(28) + +#define SUN8I_COULD_BE_USED_BY_DMA BIT(31) + +#define FLOW_RX 1 +#define FLOW_TX 2 + +/* describe how data from skb are DMA mapped */ +#define MAP_SINGLE 1 +#define MAP_PAGE 2 + +enum emac_variant { + A83T_EMAC, + H3_EMAC, + A64_EMAC, +}; + +struct ethtool_str { + char name[ETH_GSTRING_LEN]; +}; + +static const struct ethtool_str estats_str[] = { + /* errors */ + { "rx_payload_error" }, + { "rx_CRC_error" }, + { "rx_phy_error" }, + { "rx_length_error" }, + { "rx_col_error" }, + { "rx_header_error" }, + { "rx_overflow_error" }, + { "rx_saf_error" }, + { "rx_daf_error" }, + { "rx_buf_error" }, + /* misc infos */ + { "tx_stop_queue" }, + { "rx_dma_ua" }, + { "rx_dma_stop" }, + { "tx_dma_ua" }, + { "tx_dma_stop" }, + { "rx_hw_csum" }, + { "tx_hw_csum" }, + /* interrupts */ + { "rx_early_int" }, + { "tx_early_int" }, + { "tx_underflow_int" }, + /* debug */ + { "tx_used_desc" }, +}; + +struct sun8i_emac_stats { + u64 rx_payload_error; + u64 rx_crc_error; + u64 rx_phy_error; + u64 rx_length_error; + u64 rx_col_error; + u64 rx_header_error; + u64 rx_overflow_error; + u64 rx_saf_fail; + u64
[linux-sunxi] [PATCH 5/5] ARM: dts: sun8i: Enable sun8i-emac on the Orange PI PC
The sun8i-emac hardware is present on the Orange PI PC. It uses the internal PHY. This patch create the needed emac and phy nodes. Signed-off-by: LABBE Corentin--- arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts | 11 +++ 1 file changed, 11 insertions(+) diff --git a/arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts b/arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts index daf50b9a6..b8340f7 100644 --- a/arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts +++ b/arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts @@ -165,3 +165,14 @@ /* USB VBUS is always on */ status = "okay"; }; + + { + phy = <>; + phy-mode = "mii"; + allwinner,use-internal-phy; + allwinner,leds-active-low; + status = "okay"; + phy1: ethernet-phy@1 { + reg = <1>; + }; +}; -- 2.7.3 -- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[linux-sunxi] [PATCH 4/5] ARM: dts: sun8i-h3: add sun8i-emac ethernet driver
The sun8i-emac is an ethernet MAC hardware that support 10/100/1000 speed. This patch enable the sun8i-emac on the Allwinner H3 SoC Device-tree. The SoC H3 have an internal PHY, so optionals syscon and ephy are set. Signed-off-by: LABBE Corentin--- arch/arm/boot/dts/sun8i-h3.dtsi | 14 ++ 1 file changed, 14 insertions(+) diff --git a/arch/arm/boot/dts/sun8i-h3.dtsi b/arch/arm/boot/dts/sun8i-h3.dtsi index 4a4926b..f5a95ff 100644 --- a/arch/arm/boot/dts/sun8i-h3.dtsi +++ b/arch/arm/boot/dts/sun8i-h3.dtsi @@ -626,6 +626,20 @@ status = "disabled"; }; + emac: ethernet@1c3 { + compatible = "allwinner,sun8i-h3-emac"; + reg = <0x01c3 0x104>, <0x01c00030 0x4>; + reg-names = "emac", "syscon"; + interrupts = ; + resets = <_rst 17>, <_rst 66>; + reset-names = "ahb", "ephy"; + clocks = <_gates 17>, <_gates 128>; + clock-names = "ahb", "ephy"; + #address-cells = <1>; + #size-cells = <0>; + status = "disabled"; + }; + gic: interrupt-controller@01c81000 { compatible = "arm,cortex-a7-gic", "arm,cortex-a15-gic"; reg = <0x01c81000 0x1000>, -- 2.7.3 -- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[linux-sunxi] [PATCH 0/5] net-next: ethernet: add sun8i-emac driver
Hello This patch series add the driver for sun8i-emac which handle the Ethernet MAC present on Allwinner H3/A83T/A64 SoCs. It supports 10/100/1000 Mbit/s speed with half/full duplex. It can use an internal PHY (MII 10/100) or an external PHY via RGMII/RMII. This patch series enable the driver only for the H3 SoC since A83T and A64 doesn't have the necessary clocks present in mainline. This patch series enable the driver only for the OrangePiPC board since other board with H3 use external PHY which need optional regulators that will be supported later. The driver have been tested on the following boards: - H3 Orange PI PC, Orange PI Plus, BananaPI-M2+ - A64 Pine64 - A83T BananaPI-M3 I would like to thanks Chen-Yu Tsai for his help on developing this driver. Regards LABBE Corentin (5): ethernet: add sun8i-emac driver MAINTAINERS: Add myself as maintainers of sun8i-emac ARM: sun8i: dt: Add DT bindings documentation for Allwinner sun8i-emac ARM: dts: sun8i-h3: add sun8i-emac ethernet driver ARM: dts: sun8i: Enable sun8i-emac on the Orange PI PC .../bindings/net/allwinner,sun8i-emac.txt | 64 + MAINTAINERS|6 + arch/arm/boot/dts/sun8i-h3-orangepi-pc.dts | 11 + arch/arm/boot/dts/sun8i-h3.dtsi| 14 + drivers/net/ethernet/allwinner/Kconfig | 13 + drivers/net/ethernet/allwinner/Makefile|1 + drivers/net/ethernet/allwinner/sun8i-emac.c| 1943 7 files changed, 2052 insertions(+) create mode 100644 Documentation/devicetree/bindings/net/allwinner,sun8i-emac.txt create mode 100644 drivers/net/ethernet/allwinner/sun8i-emac.c -- 2.7.3 -- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[linux-sunxi] Re: [PATCH RFC 1/2] clk: sunxi-ng: Add the A83T and A80 PLL clocks
Hi, On Tue, May 31, 2016 at 3:26 PM, Jean-Francois Moinewrote: > The A83T and A80 SoCs have unique settings of their PLL clocks. > > Signed-off-by: Jean-Francois Moine > --- > drivers/clk/sunxi-ng/ccu_ndmp.c | 247 > > drivers/clk/sunxi-ng/ccu_ndmp.h | 45 > 2 files changed, 292 insertions(+) > create mode 100644 drivers/clk/sunxi-ng/ccu_ndmp.c > create mode 100644 drivers/clk/sunxi-ng/ccu_ndmp.h > > diff --git a/drivers/clk/sunxi-ng/ccu_ndmp.c b/drivers/clk/sunxi-ng/ccu_ndmp.c > new file mode 100644 > index 000..079b155 > --- /dev/null > +++ b/drivers/clk/sunxi-ng/ccu_ndmp.c > @@ -0,0 +1,247 @@ > +/* > + * PLL clocks of sun8iw6 (A83T) and sun9iw1 (A80) > + * > + * Copyright (c) 2016 Jean-Francois Moine > + * > + * 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. > + * > + * The clock rates are computed as: > + * rate = parent_rate / d1 * n / d2 / m >> p > + */ > + > +#include > +#include > +#include > + > +#include "ccu_gate.h" > +#include "ccu_ndmp.h" > + > +static void ccu_ndmp_disable(struct clk_hw *hw) > +{ > + struct ccu_ndmp *ndmp = hw_to_ccu_ndmp(hw); > + > + return ccu_gate_helper_disable(>common, ndmp->enable); > +} > + > +static int ccu_ndmp_enable(struct clk_hw *hw) > +{ > + struct ccu_ndmp *ndmp = hw_to_ccu_ndmp(hw); > + > + return ccu_gate_helper_enable(>common, ndmp->enable); > +} > + > +static int ccu_ndmp_is_enabled(struct clk_hw *hw) > +{ > + struct ccu_ndmp *ndmp = hw_to_ccu_ndmp(hw); > + > + return ccu_gate_helper_is_enabled(>common, ndmp->enable); > +} > + > +static unsigned long ccu_ndmp_recalc_rate(struct clk_hw *hw, > + unsigned long parent_rate) > +{ > + struct ccu_ndmp *ndmp = hw_to_ccu_ndmp(hw); > + int n, d1, d2, m, p; > + unsigned long rate; > + u32 reg; > + > + reg = readl(ndmp->common.base + ndmp->common.reg); > + > + rate = parent_rate; > + > + if (ndmp->d1.shift) { > + d1 = reg >> ndmp->d1.shift; > + d1 &= (1 << ndmp->d1.width) - 1; > + rate /= (d1 + 1); > + } > + > + n = reg >> ndmp->n.shift; > + n &= (1 << ndmp->n.width) - 1; > + if (!(ndmp->common.features & CCU_FEATURE_N0)) > + n++; > + rate *= n; > + > + if (ndmp->d2.shift) { > + d2 = reg >> ndmp->d2.shift; > + d2 &= (1 << ndmp->d2.width) - 1; > + rate /= (d2 + 1); > + } > + > + if (ndmp->m.shift) { > + m = reg >> ndmp->m.shift; > + m &= (1 << ndmp->m.width) - 1; > + rate /= (m + 1); > + } > + > + if (ndmp->p.shift) { > + p = reg >> ndmp->p.shift; > + p &= (1 << ndmp->p.width) - 1; > + rate >>= p; > + } > + > + return rate; > +} > + > +/* d1 and d2 may be only 1 or 2 */ > +static int ccu_ndmp_get_fact(struct ccu_ndmp *ndmp, > + unsigned long rate, unsigned long prate, > + int *p_n, int *p_d1, int *p_d2, int *p_m, int *p_p) > +{ > + int n, d1, d2, m, p, d; > + unsigned long t; > + > + /* m implies only n, d1, d2 and m (pll-audio) */ > + /* Setting d1=1 and d2=2 keeps n and m small enough > +* with error < 5/1 */ > + /* As only 2 rates are used, this could be simplified: Best not simplify generic code to specific use cases. > +* 22579200Hz => n = 32, m = 17 > +* 24576000Hz => n = 43, m = 21 > +*/ > + if (ndmp->m.shift) { shift could be 0. Testing against width is better. Same for the other functions. > + long unsigned int lun, lum; unsigned long, to match other places. > + > + d1 = 0 + 1; > + d2 = 1 + 1; > + t = prate / 2; > + rational_best_approximation(rate, t, > + 1 << ndmp->n.width, > + 1 << ndmp->m.width, > + , ); > + if (lum == 0) > + return -EINVAL; > + n = lun; > + m = lum; > + p = 0; > + > + /* no d1 implies n alone (pll-cxcpux) */ Pretending these don't have a p factor does not make it disappear. > + } else if (!ndmp->d1.shift) { > + d1 = d2 = 0 + 1; If you say they aren't there, why do you still need to set them. > + n = rate / prate; > + m = 1; > + p = 0; A note about why p isn't used would be nice. Like: P should only be used for