CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: thorpej Date: Wed Jan 27 02:03:10 UTC 2021 Modified Files: src/sys/arch/arm/sociox: if_ave.c Log Message: Use DEVICE_COMPAT_EOL. To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/sociox/if_ave.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_ave.c diff -u src/sys/arch/arm/sociox/if_ave.c:1.19 src/sys/arch/arm/sociox/if_ave.c:1.20 --- src/sys/arch/arm/sociox/if_ave.c:1.19 Mon Jan 25 14:20:38 2021 +++ src/sys/arch/arm/sociox/if_ave.c Wed Jan 27 02:03:10 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ave.c,v 1.19 2021/01/25 14:20:38 thorpej Exp $ */ +/* $NetBSD: if_ave.c,v 1.20 2021/01/27 02:03:10 thorpej Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.19 2021/01/25 14:20:38 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.20 2021/01/27 02:03:10 thorpej Exp $"); #include #include @@ -327,7 +327,7 @@ static const struct device_compatible_en { .compat = "socionext,unifier-pxs2-ave4", .value = 32 }, { .compat = "socionext,unifier-ld11-ave4", .value = 32 }, { .compat = "socionext,unifier-pxs3-ave4", .value = 32 }, - { } + DEVICE_COMPAT_EOL }; static int
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Sat Oct 10 03:29:48 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_scx.c Log Message: reorder functions for better relevance To generate a diff of this commit: cvs rdiff -u -r1.22 -r1.23 src/sys/arch/arm/sociox/if_scx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_scx.c diff -u src/sys/arch/arm/sociox/if_scx.c:1.22 src/sys/arch/arm/sociox/if_scx.c:1.23 --- src/sys/arch/arm/sociox/if_scx.c:1.22 Sat Mar 28 13:15:24 2020 +++ src/sys/arch/arm/sociox/if_scx.c Sat Oct 10 03:29:48 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_scx.c,v 1.22 2020/03/28 13:15:24 nisimura Exp $ */ +/* $NetBSD: if_scx.c,v 1.23 2020/10/10 03:29:48 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -29,35 +29,24 @@ * POSSIBILITY OF SUCH DAMAGE. */ -#define NOT_MP_SAFE 0 /* * Socionext SC2A11 SynQuacer NetSec GbE driver * - * (possibly incorrect notes to be removed eventually) - * - 32 byte descriptor for 64 bit paddr design. - * - multiple rings seems available. There are special descriptor fields - * to designify ring number from which to arrive or to which go. - * - memory mapped EEPROM to hold MAC address. The rest of the area is - * occupied by a set of ucode for two DMA engines and one packet engine. - * - The size of frame address filter is 16 plus 16. - * - The first slot is my own station address. Always enabled to perform - * to identify oneself. - * - 1~15 are for supplimental MAC addresses. Independently enabled for - * use. Good to catch multicast. Byte-wise selective match available. - * Use the mask to catch { 0x01, 0x00, 0x00 } and/or { 0x33, 0x33 }. - * - 16~32 might be exact match without byte-mask. - * - The size of multicast hash filter store is 64 bit. - * - Socionext/Linaro "NetSec" code contains some constants left unexplained. - * Fortunately, Intel/Altera CycloneV PDFs describe every detail of - * "such the instance of" DW EMAC IP and most of them are likely applicable - * to SC2A11 GbE. - * - not known "NetSec" instanciates DW timestamp or builds its own. - * - DW EMAC implmentation (0x20) is known 0x10.36 + * Multiple Tx and Rx queues exist inside and dedicated descriptor + * fields specifies which queue is to use. Three internal micro-processors + * to handle incoming frames, outgoing frames and packet data crypto + * processing. uP programs are stored in an external flash memory and + * have to be loaded by device driver. + * NetSec uses Synopsys DesignWare Core EMAC. DWC implmentation + * regiter (0x20) is known to have 0x10.36 and feature register (0x1058) + * to report XX.XX. */ +#define NOT_MP_SAFE 0 + #include -__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.22 2020/03/28 13:15:24 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.23 2020/10/10 03:29:48 nisimura Exp $"); #include #include @@ -84,8 +73,47 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #include #include +/* Socionext SC2A11 descriptor format */ +struct tdes { + uint32_t t0, t1, t2, t3; +}; + +struct rdes { + uint32_t r0, r1, r2, r3; +}; + +#define T0_OWN (1U<<31) /* desc is ready to Tx */ +#define T0_EOD (1U<<30) /* end of descriptor array */ +#define T0_DRID (24) /* 29:24 D-RID */ +#define T0_PT (1U<<21) /* 23:21 PT */ +#define T0_TRID (16) /* 20:16 T-RID */ +#define T0_FS (1U<<9) /* first segment of frame */ +#define T0_LS (1U<<8) /* last segment of frame */ +#define T0_CSUM (1U<<7) /* enable check sum offload */ +#define T0_SGOL (1U<<6) /* enable TCP segment offload */ +#define T0_TRS (1U<<4) /* 5:4 TRS */ +#define T0_IOC (0) /* XXX TBD interrupt when completed */ +/* T1 segment address 63:32 */ +/* T2 segment address 31:0 */ +/* T3 31:16 TCP segment length, 15:0 segment length to transmit */ + +#define R0_OWN (1U<<31) /* desc is empty */ +#define R0_EOD (1U<<30) /* end of descriptor array */ +#define R0_SRID (24) /* 29:24 S-RID */ +#define R0_FR (1U<<23) /* FR */ +#define R0_ER (1U<<21) /* Rx error indication */ +#define R0_ERR (3U<<16) /* 18:16 receive error code */ +#define R0_TDRID (14) /* 15:14 TD-RID */ +#define R0_FS (1U<<9) /* first segment of frame */ +#define R0_LS (1U<<8) /* last segment of frame */ +#define R0_CSUM (3U<<6) /* 7:6 checksum status */ +#define R0_CERR (2U<<6) /* 0 (undone), 1 (found ok), 2 (bad) */ +/* R1 frame address 63:32 */ +/* R2 frame address 31:0 */ +/* R3 31:16 received frame length, 15:0 buffer length to receive */ + /* - * SC2A11 register block 0x100-0x1204? + * SC2A11 NetSec registers. 0x100 - 1204 */ #define SWRESET 0x104 #define COMINIT 0x120 @@ -98,7 +126,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define xINTBEN 0x23c /* INT_B enable */ #define xINTB_SET 0x240 /* bit to set */ #define xINTB_CLR 0x244 /* bit to clr */ -/* 0x00c-048 */ /* pkt,tls,s0,s1 SR/IE/SET/CLR */ +/* 0x00c - 048
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Wed Sep 23 23:38:24 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_ave.c Log Message: note more about AVE EMAC design To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/sociox/if_ave.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_ave.c diff -u src/sys/arch/arm/sociox/if_ave.c:1.16 src/sys/arch/arm/sociox/if_ave.c:1.17 --- src/sys/arch/arm/sociox/if_ave.c:1.16 Fri Mar 27 13:00:22 2020 +++ src/sys/arch/arm/sociox/if_ave.c Wed Sep 23 23:38:24 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ave.c,v 1.16 2020/03/27 13:00:22 nisimura Exp $ */ +/* $NetBSD: if_ave.c,v 1.17 2020/09/23 23:38:24 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.16 2020/03/27 13:00:22 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.17 2020/09/23 23:38:24 nisimura Exp $"); #include #include @@ -63,6 +63,41 @@ __KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1 #define NOT_MP_SAFE (0) +/* + * AVE has two different, rather obscure, descriptor formats. 32-bit + * paddr descriptor layout occupies 8 bytes while 64-bit paddr descriptor + * does 12 bytes. AVE is a derivative of Synopsys DesignWare Core + * EMAC. + */ +struct tdes { + uint32_t t0, t1, t2; +}; + +struct rdes { + uint32_t r0, r1, r2; +}; + +struct tdes32 { uint32_t t0, t1; }; +struct rdes32 { uint32_t r0, r1; }; + +#define T0_OWN (1U<<31) /* desc is ready to Tx */ +#define T0_IOC (1U<<29) /* post interrupt on Tx completes */ +#define T0_NOCSUM (1U<<28) /* inhibit checksum operation */ +#define T0_DONEOK (1U<<27) /* status - Tx completed ok */ +#define T0_FS (1U<<26) /* first segment of frame */ +#define T0_LS (1U<<25) /* last segment of frame */ +#define T0_OWC (1U<<21) /* status - out of win. late coll. */ +#define T0_ECOL (1U<<20) /* status - excess collision */ +#define T0_TBS_MASK 0x /* T0 segment length 15:0 */ +/* T1 segment address 31:0 */ +/* T2 segment address 63:32 */ +#define R0_OWN (1U<<31) /* desc is empty */ +#define R0_CSUM (1U<<21) /* receive checksum done */ +#define R0_CERR (1U<<20) /* csum found negative */ +#define R0_FL_MASK 0x07ff /* R0 frame length 10:0 */ +/* R1 frame address 31:0 */ +/* R2 frame address 63:32 */ + #define AVEID 0x000 /* hardware ID */ #define AVEHWVER 0x004 /* hardware version */ #define AVEGR 0x008 /* chip global control */ @@ -107,17 +142,14 @@ __KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1 #define DESCC_RD0 (1U<<3) /* activate Rx0 descriptor to run */ #define DESCC_RSTP (1U<<2) /* pause Rx descriptor */ #define DESCC_TD (1U<<0) /* activate Tx descriptor to run */ - /* 31:16 status report to read */ +/* 31:16 status report to read */ #define AVETXDES 0x304 /* Tx descriptor control */ - /* 27:16 Tx descriptor byte count - * 11:0 start address offset */ +/* 27:16 Tx descriptor byte count, 11:0 start address offset */ #define AVERXDES0 0x308 /* Rx0 descriptor control */ - /* 30:16 Rx descriptor byte count - * 14:0 start address offset */ +/* 30:16 Rx descriptor byte count, 14:0 start address offset */ #define AVEITIRQC 0x34c /* interval IRQ control */ #define ITIRQC_R0E (1U<<27) /* enable Rx0 interval timer */ -#define INTMVAL (20<<16) /* INTM value */ - /* 15:0 interval timer count */ +#define INTMVAL (20<<16) /* 15:0 interval timer count */ #define AVEAFB 0x0800 /* address filter base */ #define AVEAFMSKB 0x0d00 /* byte mask base */ @@ -128,47 +160,21 @@ __KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1 #define AVEAFRING 0x0f00 /* entry ring number selector */ #define AVEAFEN 0x0ffc /* entry enable bit vector */ -#define AVETDB 0x1000 /* 64bit Tx descriptor store, upto 256 */ -#define AVERDB 0x1c00 /* 64bit Rx descriptor store, upto 2048 */ -#define AVE32TDB 0x1000 /* 32bit Tx store base, upto 256 */ -#define AVE32RDB 0x1800 /* 32bit Rx store base, upto 2048 */ +/* AVE has internal cache coherent memory tol hold descriptor arrays. */ +#define AVETDB 0x1000 /* 64-bit Tx desc store, upto 256 */ +#define AVERDB 0x1c00 /* 64-bit Rx desc store, upto 2048 */ +#define AVE32TDB 0x1000 /* 32-bit Tx store base, upto 256 */ +#define AVE32RDB 0x1800 /* 32-bit Rx store base, upto 2048 */ #define AVERMIIC 0x8028 /* RMII control */ #define RMIIC_RST (1U<<16) /* reset operation */ #define AVELINKSEL 0x8034 /* RMII speed selection */ #define LINKSEL_SPD100 (1U<<0) /* use 100Mbps */ -/* - * descriptor size is 12 bytes when 64bit paddr design, 8 bytes otherwise. - */ -struct tdes { - uint32_t t0, t1, t2; -}; - -struct rdes { - uint32_t r0, r1, r2; -}; - -struct tdes32 { uint32_t t0, t1; }; -struct rdes32 { uint32_t r0, r1; }; - -#define T0_OWN (1U<<31) /* desc is ready to Tx */ -#define T0_IOC (1U<<29) /* post interrupt on Tx completes */
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: thorpej Date: Mon Jun 1 00:00:37 UTC 2020 Modified Files: src/sys/arch/arm/sociox: sni_i2c.c Log Message: Oops, missed a line in the last change. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sociox/sni_i2c.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/sni_i2c.c diff -u src/sys/arch/arm/sociox/sni_i2c.c:1.7 src/sys/arch/arm/sociox/sni_i2c.c:1.8 --- src/sys/arch/arm/sociox/sni_i2c.c:1.7 Sun May 31 23:55:18 2020 +++ src/sys/arch/arm/sociox/sni_i2c.c Mon Jun 1 00:00:37 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sni_i2c.c,v 1.7 2020/05/31 23:55:18 thorpej Exp $ */ +/* $NetBSD: sni_i2c.c,v 1.8 2020/06/01 00:00:37 thorpej Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sni_i2c.c,v 1.7 2020/05/31 23:55:18 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sni_i2c.c,v 1.8 2020/06/01 00:00:37 thorpej Exp $"); #include #include @@ -117,7 +117,6 @@ sniiic_fdt_attach(device_t parent, devic { struct sniiic_softc * const sc = device_private(self); struct fdt_attach_args * const faa = aux; - prop_dictionary_t dict = device_properties(self); const int phandle = faa->faa_phandle; bus_space_handle_t ioh; bus_addr_t addr;
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: thorpej Date: Sun May 31 23:55:18 UTC 2020 Modified Files: src/sys/arch/arm/sociox: sni_emmc.c sni_exiu.c sni_gpio.c sni_i2c.c Log Message: Remove superfluous checking for a "disable" property in the device_t properties dictionary. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sociox/sni_emmc.c \ src/sys/arch/arm/sociox/sni_i2c.c cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sociox/sni_exiu.c cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sociox/sni_gpio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/sni_emmc.c diff -u src/sys/arch/arm/sociox/sni_emmc.c:1.6 src/sys/arch/arm/sociox/sni_emmc.c:1.7 --- src/sys/arch/arm/sociox/sni_emmc.c:1.6 Wed Mar 25 23:20:38 2020 +++ src/sys/arch/arm/sociox/sni_emmc.c Sun May 31 23:55:18 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sni_emmc.c,v 1.6 2020/03/25 23:20:38 nisimura Exp $ */ +/* $NetBSD: sni_emmc.c,v 1.7 2020/05/31 23:55:18 thorpej Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sni_emmc.c,v 1.6 2020/03/25 23:20:38 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sni_emmc.c,v 1.7 2020/05/31 23:55:18 thorpej Exp $"); #include #include @@ -100,20 +100,12 @@ sniemmc_fdt_attach(device_t parent, devi { struct sniemmc_softc * const sc = device_private(self); struct fdt_attach_args * const faa = aux; - prop_dictionary_t dict = device_properties(self); const int phandle = faa->faa_phandle; bus_space_handle_t ioh; bus_addr_t addr; bus_size_t size; char intrstr[128]; - _Bool disable; - prop_dictionary_get_bool(dict, "disable", ); - if (disable) { - aprint_naive(": disabled\n"); - aprint_normal(": disabled\n"); - return; - } if (fdtbus_get_reg(phandle, 0, , ) != 0 || bus_space_map(faa->faa_bst, addr, size, 0, ) != 0) { aprint_error(": unable to map device\n"); Index: src/sys/arch/arm/sociox/sni_i2c.c diff -u src/sys/arch/arm/sociox/sni_i2c.c:1.6 src/sys/arch/arm/sociox/sni_i2c.c:1.7 --- src/sys/arch/arm/sociox/sni_i2c.c:1.6 Wed Mar 25 23:20:38 2020 +++ src/sys/arch/arm/sociox/sni_i2c.c Sun May 31 23:55:18 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sni_i2c.c,v 1.6 2020/03/25 23:20:38 nisimura Exp $ */ +/* $NetBSD: sni_i2c.c,v 1.7 2020/05/31 23:55:18 thorpej Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sni_i2c.c,v 1.6 2020/03/25 23:20:38 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sni_i2c.c,v 1.7 2020/05/31 23:55:18 thorpej Exp $"); #include #include @@ -123,14 +123,7 @@ sniiic_fdt_attach(device_t parent, devic bus_addr_t addr; bus_size_t size; char intrstr[128]; - _Bool disable; - prop_dictionary_get_bool(dict, "disable", ); - if (disable) { - aprint_naive(": disabled\n"); - aprint_normal(": disabled\n"); - return; - } if (fdtbus_get_reg(phandle, 0, , ) != 0 || bus_space_map(faa->faa_bst, addr, size, 0, ) != 0) { aprint_error(": unable to map device\n"); Index: src/sys/arch/arm/sociox/sni_exiu.c diff -u src/sys/arch/arm/sociox/sni_exiu.c:1.3 src/sys/arch/arm/sociox/sni_exiu.c:1.4 --- src/sys/arch/arm/sociox/sni_exiu.c:1.3 Wed Mar 25 23:29:39 2020 +++ src/sys/arch/arm/sociox/sni_exiu.c Sun May 31 23:55:18 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sni_exiu.c,v 1.3 2020/03/25 23:29:39 nisimura Exp $ */ +/* $NetBSD: sni_exiu.c,v 1.4 2020/05/31 23:55:18 thorpej Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sni_exiu.c,v 1.3 2020/03/25 23:29:39 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sni_exiu.c,v 1.4 2020/05/31 23:55:18 thorpej Exp $"); #include #include @@ -91,20 +91,12 @@ sniexiu_fdt_attach(device_t parent, devi { struct sniexiu_softc * const sc = device_private(self); struct fdt_attach_args * const faa = aux; - prop_dictionary_t dict = device_properties(self); const int phandle = faa->faa_phandle; bus_space_handle_t ioh; bus_addr_t addr; bus_size_t size; char intrstr[128]; - _Bool disable; - prop_dictionary_get_bool(dict, "disable", ); - if (disable) { - aprint_naive(": disabled\n"); - aprint_normal(": disabled\n"); - return; - } if (fdtbus_get_reg(phandle, 0, , ) != 0 || bus_space_map(faa->faa_bst, addr, size, 0, ) != 0) { aprint_error(": unable to map device\n"); Index: src/sys/arch/arm/sociox/sni_gpio.c diff -u src/sys/arch/arm/sociox/sni_gpio.c:1.7 src/sys/arch/arm/sociox/sni_gpio.c:1.8 --- src/sys/arch/arm/sociox/sni_gpio.c:1.7 Wed Mar 25 23:31:19 2020 +++ src/sys/arch/arm/sociox/sni_gpio.c Sun May 31 23:55:18 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sni_gpio.c,v 1.7 2020/03/25 23:31:19 nisimura Exp $ */ +/* $NetBSD: sni_gpio.c,v 1.8 2020/05/31 23:55:18 thorpej Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Sat Mar 28 13:15:24 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_scx.c Log Message: - comb down rcvfilt() filter adjustment logic. - some mii_statchg() can be written in simpler form. To generate a diff of this commit: cvs rdiff -u -r1.21 -r1.22 src/sys/arch/arm/sociox/if_scx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_scx.c diff -u src/sys/arch/arm/sociox/if_scx.c:1.21 src/sys/arch/arm/sociox/if_scx.c:1.22 --- src/sys/arch/arm/sociox/if_scx.c:1.21 Fri Mar 27 13:00:13 2020 +++ src/sys/arch/arm/sociox/if_scx.c Sat Mar 28 13:15:24 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_scx.c,v 1.21 2020/03/27 13:00:13 nisimura Exp $ */ +/* $NetBSD: if_scx.c,v 1.22 2020/03/28 13:15:24 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.21 2020/03/27 13:00:13 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.22 2020/03/28 13:15:24 nisimura Exp $"); #include #include @@ -673,7 +673,12 @@ scx_attach_i(struct scx_softc *sc) int i, nseg, error = 0; hwver = CSR_READ(sc, HWVER); /* Socionext HW */ - /* stored in big endian order */ + dwimp = mac_read(sc, GMACIMPL); /* DW EMAC XX.YY */ + aprint_normal_dev(sc->sc_dev, + "Socionext NetSec GbE hw %d.%d impl 0x%x\n", + hwver >> 16, hwver & 0x, dwimp); + + /* fetch MAC address in flash. stored in big endian order */ csr = bus_space_read_4(sc->sc_st, sc->sc_eesh, 0); enaddr[0] = csr >> 24; enaddr[1] = csr >> 16; @@ -682,11 +687,6 @@ scx_attach_i(struct scx_softc *sc) csr = bus_space_read_4(sc->sc_st, sc->sc_eesh, 4); enaddr[4] = csr >> 24; enaddr[5] = csr >> 16; - dwimp = mac_read(sc, GMACIMPL); /* DW EMAC XX.YY */ - - aprint_normal_dev(sc->sc_dev, - "Socionext NetSec GbE hw %d.%d impl 0x%x\n", - hwver >> 16, hwver & 0x, dwimp); aprint_normal_dev(sc->sc_dev, "Ethernet address %s\n", ether_sprintf(enaddr)); @@ -1024,20 +1024,21 @@ scx_set_rcvfilt(struct scx_softc *sc) csr &= ~(AFR_PR | AFR_PM | AFR_MHTE | AFR_HPF); mac_write(sc, GMACAFR, csr); + /* clear 15 entry supplimental perfect match filter */ + for (i = 1; i < 16; i++) + mac_write(sc, GMACMAH(i), 0); + /* build 64 bit multicast hash filter */ + crc = mchash[1] = mchash[0] = 0; + ETHER_LOCK(ec); if (ifp->if_flags & IFF_PROMISC) { ec->ec_flags |= ETHER_F_ALLMULTI; ETHER_UNLOCK(ec); + /* run promisc. mode */ + csr |= AFR_PR; goto update; } ec->ec_flags &= ~ETHER_F_ALLMULTI; - - /* clear 15 entry supplimental perfect match filter */ - for (i = 1; i < 16; i++) - mac_write(sc, GMACMAH(i), 0); - /* build 64 bit multicast hash filter */ - crc = mchash[1] = mchash[0] = 0; - ETHER_FIRST_MULTI(step, ec, enm); i = 1; /* slot 0 is occupied */ while (enm != NULL) { @@ -1052,6 +1053,8 @@ scx_set_rcvfilt(struct scx_softc *sc) */ ec->ec_flags |= ETHER_F_ALLMULTI; ETHER_UNLOCK(ec); + /* accept all multi */ + csr |= AFR_PM; goto update; } printf("[%d] %s\n", i, ether_sprintf(enm->enm_addrlo)); @@ -1080,15 +1083,8 @@ printf("[%d] %s\n", i, ether_sprintf(enm csr |= AFR_HPF; /* use hash+perfect */ mac_write(sc, GMACMHTH, mchash[1]); mac_write(sc, GMACMHTL, mchash[0]); - mac_write(sc, GMACAFR, csr); - return; - update: /* With PR or PM, MHTE/MHTL/MHTH are never consulted. really? */ - if (ifp->if_flags & IFF_PROMISC) - csr |= AFR_PR; /* run promisc. mode */ - else - csr |= AFR_PM; /* accept all multicast */ mac_write(sc, GMACAFR, csr); return; } @@ -1110,18 +1106,19 @@ mii_statchg(struct ifnet *ifp) { struct scx_softc *sc = ifp->if_softc; struct mii_data *mii = >sc_mii; - struct ifmedia * ifm = >mii_media; - uint32_t mcr, fcr; + const int Mbps[4] = { 10, 100, 1000, 0 }; + uint32_t miisr, mcr, fcr; + int spd; -#if 1 /* decode MIISR register value */ - uint32_t miisr = mac_read(sc, GMACMIISR); - int spd = (miisr >> 1) & 03; + miisr = mac_read(sc, GMACMIISR); + spd = Mbps[(miisr >> 1) & 03]; +#if 1 printf("MII link status (0x%x) %s", miisr, (miisr & 8) ? "up" : "down"); if (miisr & 8) { - printf(" spd%d", (spd == 2) ? 1000 : (spd == 1) ? 100 : 10); - if (miisr & 1) + printf(" spd%d", spd); + if (miisr & 01) printf(",full-duplex"); } printf("\n"); @@ -1133,11 +1130,10 @@ mii_statchg(struct ifnet *ifp) /* Adjust speed 1000/100/10. */ mcr = mac_read(sc, GMACMCR); - if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_1000_T) + if (spd == 1000) mcr &= ~MCR_USEMII; /* RGMII+SPD1000 */ else { - if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_100_TX - && sc->sc_100mii) + if (spd == 100 && sc->sc_100mii) mcr |= MCR_SPD100; mcr |= MCR_USEMII; } @@ -1148,12 +1144,12 @@ mii_statchg(struct ifnet *ifp) /* Adjust duplexity and PAUSE flow control. */ mcr &= ~MCR_USEFDX; fcr
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Fri Mar 27 13:00:13 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_scx.c Log Message: extend mii_statchg() to use ether_mediachange(). care about hash filter selection. To generate a diff of this commit: cvs rdiff -u -r1.20 -r1.21 src/sys/arch/arm/sociox/if_scx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_scx.c diff -u src/sys/arch/arm/sociox/if_scx.c:1.20 src/sys/arch/arm/sociox/if_scx.c:1.21 --- src/sys/arch/arm/sociox/if_scx.c:1.20 Fri Mar 27 09:19:33 2020 +++ src/sys/arch/arm/sociox/if_scx.c Fri Mar 27 13:00:13 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_scx.c,v 1.20 2020/03/27 09:19:33 nisimura Exp $ */ +/* $NetBSD: if_scx.c,v 1.21 2020/03/27 13:00:13 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.20 2020/03/27 09:19:33 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.21 2020/03/27 13:00:13 nisimura Exp $"); #include #include @@ -224,8 +224,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define GMACEVCTL 0x0100 /* event counter control */ #define GMACEVCNT(i) ((i)*4+0x114) /* event counter 0x114~284 */ -#define GMACMHT0 0x0500 /* 256bit multicast hash table 0 - 7 */ -#define GMACMHT(i) ((i)*4+0x500) +#define GMACMHT(i) ((i)*4+0x500) /* 256bit multicast hash table 0 - 7 */ #define GMACVHT 0x0588 /* VLAN tag hash */ /* 0x0700-0734 ??? */ @@ -452,7 +451,6 @@ static void scx_stop(struct ifnet *, int static void scx_watchdog(struct ifnet *); static int scx_ioctl(struct ifnet *, u_long, void *); static void scx_set_rcvfilt(struct scx_softc *); -static int scx_ifmedia_upd(struct ifnet *); static void scx_ifmedia_sts(struct ifnet *, struct ifmediareq *); static void mii_statchg(struct ifnet *); static void phy_tick(void *); @@ -709,7 +707,7 @@ sc->sc_mdclk <<= 2; mii->mii_statchg = mii_statchg; sc->sc_ethercom.ec_mii = mii; - ifmedia_init(ifm, 0, scx_ifmedia_upd, scx_ifmedia_sts); + ifmedia_init(ifm, 0, ether_mediachange, scx_ifmedia_sts); mii_attach(sc->sc_dev, mii, 0x, sc->sc_phy_id, MII_OFFSET_ANY, MIIF_DOPAUSE); if (LIST_FIRST(>mii_phys) == NULL) { @@ -881,7 +879,7 @@ scx_init(struct ifnet *ifp) /* accept multicast frame or run promisc mode */ scx_set_rcvfilt(sc); - (void)scx_ifmedia_upd(ifp); + (void)ether_mediachange(ifp); /* build sane Tx */ memset(sc->sc_txdescs, 0, sizeof(struct tdes) * MD_NTXDESC); @@ -1077,16 +1075,16 @@ printf("[%d] %s\n", i, ether_sprintf(enm i++; } ETHER_UNLOCK(ec); - if (crc) - csr |= AFR_MHTE | AFR_HPF; /* use hash+perfect */ + csr |= AFR_MHTE; + csr |= AFR_HPF; /* use hash+perfect */ mac_write(sc, GMACMHTH, mchash[1]); mac_write(sc, GMACMHTL, mchash[0]); mac_write(sc, GMACAFR, csr); return; update: - /* With PM or AM, MHTE/MHT0-7 are never consulted. really? */ + /* With PR or PM, MHTE/MHTL/MHTH are never consulted. really? */ if (ifp->if_flags & IFF_PROMISC) csr |= AFR_PR; /* run promisc. mode */ else @@ -1095,39 +1093,6 @@ printf("[%d] %s\n", i, ether_sprintf(enm return; } -static int -scx_ifmedia_upd(struct ifnet *ifp) -{ - struct scx_softc *sc = ifp->if_softc; - struct ifmedia *ifm = >sc_mii.mii_media; - - if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_AUTO) { - ; /* restart AN */ - ; /* enable AN */ - ; /* advertise flow control pause */ - ; /* adv. 1000FDX,100FDX,100HDX,10FDX,10HDX */ - } else { -#if 1 /* XXX not sure to belong here XXX */ - uint32_t mcr = mac_read(sc, GMACMCR); - if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_1000_T) - mcr &= ~MCR_USEMII; /* RGMII+SPD1000 */ - else { - if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_100_TX - && sc->sc_100mii) -mcr |= MCR_SPD100; - mcr |= MCR_USEMII; - } - if (ifm->ifm_cur->ifm_media & IFM_FDX) - mcr |= MCR_USEFDX; - mcr |= MCR_CST | MCR_JE; - if (sc->sc_100mii == 0) - mcr |= MCR_IBN; - mac_write(sc, GMACMCR, mcr); -#endif - } - return 0; -} - static void scx_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr) { @@ -1145,7 +1110,8 @@ mii_statchg(struct ifnet *ifp) { struct scx_softc *sc = ifp->if_softc; struct mii_data *mii = >sc_mii; - uint32_t fcr; + struct ifmedia * ifm = >mii_media; + uint32_t mcr, fcr; #if 1 /* decode MIISR register value */ @@ -1165,14 +1131,31 @@ mii_statchg(struct ifnet *ifp) (mii->mii_media_active & IFM_ETH_FMASK) != sc->sc_flowflags) sc->sc_flowflags = mii->mii_media_active & IFM_ETH_FMASK; - /* Adjust PAUSE flow control. */ + /* Adjust speed 1000/100/10. */ + mcr = mac_read(sc, GMACMCR); + if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_1000_T) + mcr &= ~MCR_USEMII; /* RGMII+SPD1000 */ + else { + if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_100_TX + && sc->sc_100mii) + mcr |= MCR_SPD100; + mcr |= MCR_USEMII; + } + mcr
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Fri Mar 27 13:00:22 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_ave.c Log Message: extend mii_statchg() to use ether_mediachange(). care about hash filter selection. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/sociox/if_ave.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_ave.c diff -u src/sys/arch/arm/sociox/if_ave.c:1.15 src/sys/arch/arm/sociox/if_ave.c:1.16 --- src/sys/arch/arm/sociox/if_ave.c:1.15 Tue Mar 24 03:08:02 2020 +++ src/sys/arch/arm/sociox/if_ave.c Fri Mar 27 13:00:22 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ave.c,v 1.15 2020/03/24 03:08:02 nisimura Exp $ */ +/* $NetBSD: if_ave.c,v 1.16 2020/03/27 13:00:22 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -36,15 +36,16 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.15 2020/03/24 03:08:02 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.16 2020/03/27 13:00:22 nisimura Exp $"); #include #include #include #include #include -#include +#include #include +#include #include #include #include @@ -249,7 +250,6 @@ static void ave_watchdog(struct ifnet *) static int ave_ioctl(struct ifnet *, u_long, void *); static void ave_set_rcvfilt(struct ave_softc *); static void ave_write_filt(struct ave_softc *, int, const uint8_t *); -static int ave_ifmedia_upd(struct ifnet *); static void ave_ifmedia_sts(struct ifnet *, struct ifmediareq *); static void mii_statchg(struct ifnet *); static void lnkchg(struct ave_softc *); @@ -384,19 +384,17 @@ ave_fdt_attach(device_t parent, device_t sc->sc_model = of_search_compatible(phandle, compat_data)->data; phy_mode = fdtbus_get_string(phandle, "phy-mode"); - if (phy_mode == NULL) { + if (phy_mode == NULL) aprint_error(": missing 'phy-mode' property\n"); - phy_mode = "rgmii"; - } aprint_naive("\n"); aprint_normal(": Gigabit Ethernet Controller\n"); - aprint_normal_dev(self, "UniPhier %c%c%c%c AVE%d GbE (%d.%d) %s\n", + aprint_normal_dev(self, "UniPhier %c%c%c%c AVE%d GbE (%d.%d)\n", hwimp >> 24, hwimp >> 16, hwimp >> 8, hwimp, - sc->sc_model, hwver >> 8, hwver & 0xff, phy_mode); + sc->sc_model, hwver >> 8, hwver & 0xff); aprint_normal_dev(self, "interrupt on %s\n", intrstr); - sc->sc_100mii = (strcmp(phy_mode, "rgmii") != 0); + sc->sc_100mii = (phy_mode && strcmp(phy_mode, "rgmii") != 0); sc->sc_desops = (sc->sc_model == 64) ? : CSR_WRITE(sc, AVEGR, GR_GRST | GR_PHYRST); @@ -429,7 +427,7 @@ ave_fdt_attach(device_t parent, device_t sc->sc_phy_id = MII_PHY_ANY; sc->sc_ethercom.ec_mii = mii; - ifmedia_init(ifm, 0, ave_ifmedia_upd, ave_ifmedia_sts); + ifmedia_init(ifm, 0, ether_mediachange, ave_ifmedia_sts); mii_attach(sc->sc_dev, mii, 0x, sc->sc_phy_id, MII_OFFSET_ANY, MIIF_DOPAUSE); if (LIST_FIRST(>mii_phys) == NULL) { @@ -586,7 +584,7 @@ ave_init(struct ifnet *ifp) /* accept multicast frame or run promisc mode */ ave_set_rcvfilt(sc); - (void)ave_ifmedia_upd(ifp); + (void)ether_mediachange(ifp); csr = CSR_READ(sc, AVECFG); if (ifp->if_capenable & IFCAP_CSUM_IPv4_Tx) { @@ -636,49 +634,6 @@ ave_stop(struct ifnet *ifp, int disable) ifp->if_timer = 0; } -static int -ave_ifmedia_upd(struct ifnet *ifp) -{ - struct ave_softc *sc = ifp->if_softc; - struct ifmedia *ifm = >sc_mii.mii_media; - uint32_t txcr, rxcr, csr; - - txcr = CSR_READ(sc, AVETXC); - rxcr = CSR_READ(sc, AVERXC); - CSR_WRITE(sc, AVERXC, rxcr &~ RXC_EN); /* stop Rx first */ - - if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_AUTO) { - ; /* restart AN */ - ; /* enable AN */ - ; /* advertise flow control pause */ - ; /* adv. 1000FDX,100FDX,100HDX,10FDX,10HDX */ - } else { -#if 1 /* XXX not sure to belong here XXX */ - txcr &= ~(TXC_SPD1000 | TXC_SPD100); - rxcr &= ~RXC_USEFDX; - if ((sc->sc_100mii == 0) /* RGMII model */ - && IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_1000_T) - txcr |= TXC_SPD1000; - else if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_100_TX) - txcr |= TXC_SPD100; - if (ifm->ifm_media & IFM_FDX) - rxcr |= RXC_USEFDX; - - /* adjust LINKSEL when RMII/MII too */ - if (sc->sc_100mii) { - csr = CSR_READ(sc, AVELINKSEL) &~ LINKSEL_SPD100; - if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_100_TX) -csr |= LINKSEL_SPD100; - CSR_WRITE(sc, AVELINKSEL, csr); - } -#endif - } - sc->sc_rxc = rxcr; - CSR_WRITE(sc, AVETXC, txcr); - CSR_WRITE(sc, AVERXC, rxcr | RXC_EN); - return 0; -} - static void ave_ifmedia_sts(struct ifnet *ifp, struct ifmediareq *ifmr) { @@ -696,7 +651,8 @@ mii_statchg(struct ifnet *ifp) { struct ave_softc *sc = ifp->if_softc; struct mii_data *mii = >sc_mii; - uint32_t txcr, rxcr; + struct ifmedia *ifm = >mii_media; + uint32_t txcr, rxcr, lsel; /* Get flow control negotiation result. */ if
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Fri Mar 27 09:19:33 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_scx.c Log Message: try to be better register descriptions To generate a diff of this commit: cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/sociox/if_scx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_scx.c diff -u src/sys/arch/arm/sociox/if_scx.c:1.19 src/sys/arch/arm/sociox/if_scx.c:1.20 --- src/sys/arch/arm/sociox/if_scx.c:1.19 Fri Mar 27 07:59:50 2020 +++ src/sys/arch/arm/sociox/if_scx.c Fri Mar 27 09:19:33 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_scx.c,v 1.19 2020/03/27 07:59:50 nisimura Exp $ */ +/* $NetBSD: if_scx.c,v 1.20 2020/03/27 09:19:33 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -40,24 +40,24 @@ * to designify ring number from which to arrive or to which go. * - memory mapped EEPROM to hold MAC address. The rest of the area is * occupied by a set of ucode for two DMA engines and one packet engine. - * - The size of frame address filter is 16 plus 32. + * - The size of frame address filter is 16 plus 16. * - The first slot is my own station address. Always enabled to perform * to identify oneself. - * - 1~16 are for supplimental MAC addresses. Independently enabled for + * - 1~15 are for supplimental MAC addresses. Independently enabled for * use. Good to catch multicast. Byte-wise selective match available. * Use the mask to catch { 0x01, 0x00, 0x00 } and/or { 0x33, 0x33 }. * - 16~32 might be exact match without byte-mask. * - The size of multicast hash filter store is 64 bit. - * - Socionext/Linaro "NetSec" code makes many cut shorts. Some constants - * are left unexplained. The values should be handled via external - * controls like FDT descriptions. Fortunately, Intel/Altera CycloneV PDFs - * describe every detail of "such the instance of" DW EMAC IP and - * most of them are likely applicable to SC2A11 GbE. - * - DW EMAC implmentation (0x20) is 0x10.0x36 + * - Socionext/Linaro "NetSec" code contains some constants left unexplained. + * Fortunately, Intel/Altera CycloneV PDFs describe every detail of + * "such the instance of" DW EMAC IP and most of them are likely applicable + * to SC2A11 GbE. + * - not known "NetSec" instanciates DW timestamp or builds its own. + * - DW EMAC implmentation (0x20) is known 0x10.36 */ #include -__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.19 2020/03/27 07:59:50 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.20 2020/03/27 09:19:33 nisimura Exp $"); #include #include @@ -212,7 +212,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define GMACMAH0 0x0040 /* MAC address 0 47:32 */ #define GMACMAL0 0x0044 /* MAC address 0 31:0 */ #define GMACMAH(i) ((i)*8+0x40) /* supplimental MAC addr 1 - 15 */ -#define GMACMAL(i) ((i)*8+0x44) +#define GMACMAL(i) ((i)*8+0x44) /* bit 31 to use, 30 SA, + * 29:24 byte-wise don'care */ #define GMACMIISR 0x00d8 /* resolved xMII link status */ /* 3 link up detected * 2:1 resovled speed @@ -227,12 +228,12 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define GMACMHT(i) ((i)*4+0x500) #define GMACVHT 0x0588 /* VLAN tag hash */ -/* 0x0700-0734 */ +/* 0x0700-0734 ??? */ #define GMACAMAH(i) ((i)*8+0x800) /* supplimental MAC addr 16-31 */ -#define GMACAMAL(i) ((i)*8+0x804) +#define GMACAMAL(i) ((i)*8+0x804) /* bit 31 to use */ #define GMACBMR 0x1000 /* DMA bus mode control - * 244PBL 8? + * 244PBL 8??? * 23USP * 22:17 RPBL * 16fixed burst, or undefined b. @@ -841,12 +842,11 @@ scx_reset(struct scx_softc *sc) int loop = 0, busy; mac_write(sc, GMACOMR, 0); - mac_write(sc, GMACBMR, BMR_RST); /* may take for a while */ + mac_write(sc, GMACBMR, BMR_RST); do { DELAY(1); busy = mac_read(sc, GMACBMR) & BMR_RST; } while (++loop < 3000 && busy); -printf("BMR reset done with %d loop\n", loop); mac_write(sc, GMACBMR, _BMR); mac_write(sc, GMACAFR, 0);
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Fri Mar 27 07:59:50 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_scx.c Log Message: more register mashup work To generate a diff of this commit: cvs rdiff -u -r1.18 -r1.19 src/sys/arch/arm/sociox/if_scx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_scx.c diff -u src/sys/arch/arm/sociox/if_scx.c:1.18 src/sys/arch/arm/sociox/if_scx.c:1.19 --- src/sys/arch/arm/sociox/if_scx.c:1.18 Fri Mar 27 06:32:49 2020 +++ src/sys/arch/arm/sociox/if_scx.c Fri Mar 27 07:59:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_scx.c,v 1.18 2020/03/27 06:32:49 nisimura Exp $ */ +/* $NetBSD: if_scx.c,v 1.19 2020/03/27 07:59:50 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.18 2020/03/27 06:32:49 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.19 2020/03/27 07:59:50 nisimura Exp $"); #include #include @@ -84,7 +84,9 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #include #include -/* SC2A11 register block 0x100-0x1204? */ +/* + * SC2A11 register block 0x100-0x1204? + */ #define SWRESET 0x104 #define COMINIT 0x120 #define xINTSR 0x200 /* aggregated interrupt status report */ @@ -96,7 +98,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define xINTBEN 0x23c /* INT_B enable */ #define xINTB_SET 0x240 /* bit to set */ #define xINTB_CLR 0x244 /* bit to clr */ -/* 0x0c-48 *//* pkt,tls,s0,s1 SR/IE/SET/CLR */ +/* 0x00c-048 */ /* pkt,tls,s0,s1 SR/IE/SET/CLR */ #define TXISR 0x400 #define TXIEN 0x404 #define TXI_SET 0x428 @@ -127,6 +129,17 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define MCVER 0x22c /* micro controller version */ #define HWVER 0x230 /* hardware version */ +/* 0x800 */ /* dec Tx SR/EN/SET/CLR */ +/* 0x840 */ /* enc Rx SR/EN/SET/CLR */ +/* 0x880 */ /* enc TLS Tx SR/IE/SET/CLR */ +/* 0x8c0 */ /* dec TLS Tx SR/IE/SET/CLR */ +/* 0x900 */ /* enc TLS Rx SR/IE/SET/CLR */ +/* 0x940 */ /* dec TLS Rx SR/IE/SET/CLR */ +/* 0x980 */ /* enc RAW Tx SR/IE/SET/CLR */ +/* 0x9c0 */ /* dec RAW Tx SR/IE/SET/CLR */ +/* 0xA00 */ /* enc RAW Rx SR/IE/SET/CLR */ +/* 0xA40 */ /* dec RAW Rx SR/IE/SET/CLR */ + #define MACCMD 0x11c4 /* gmac operation */ #define CMD_IOWR (1U<<28) /* write op */ #define CMD_BUSY (1U<<31) /* busy bit */ @@ -136,23 +149,30 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define DESC_INIT 0x11fc /* desc engine init */ #define DESC_SRST 0x1204 /* desc engine sw reset */ -/* GMAC register block. use mac_write()/mac_read() to handle */ +/* + * GMAC register block. use mac_write()/mac_read() to handle + */ #define GMACMCR 0x /* MAC configuration */ -#define MCR_IBN (1U<<30) /* */ +#define MCR_IBN (1U<<30) /* ??? */ #define MCR_CST (1U<<25) /* strip CRC */ #define MCR_TC (1U<<24) /* keep RGMII PHY notified */ #define MCR_JE (1U<<20) /* ignore oversized >9018 condition */ +#define MCR_IFG (7U<<17) /* 19:17 IFG value 0~7 */ +#define MCR_DRCS (1U<<16) /* ignore (G)MII HDX Tx error */ #define MCR_USEMII (1U<<15) /* 1: RMII/MII, 0: RGMII (_PS) */ #define MCR_SPD100 (1U<<14) /* force speed 100 (_FES) */ +#define MCR_DO (1U<<13) /* */ +#define MCR_LOOP (1U<<12) /* */ #define MCR_USEFDX (1U<<11) /* force full duplex */ -#define MCR_IPCKEN (1U<<10) /* handle checksum */ +#define MCR_IPCEN (1U<<10) /* handle checksum */ #define MCR_ACS (1U<<7) /* auto pad strip CRC */ -#define MCR_TXE (1U<<3) /* start Tx DMA engine */ -#define MCR_RXE (1U<<2) /* start Rx DMA engine */ +#define MCR_TE (1U<<3) /* run Tx MAC engine, 0 to stop */ +#define MCR_RE (1U<<2) /* run Rx MAC engine, 0 to stop */ +#define MCR_PREA (3U) /* 1:0 preamble len. 0~2 */ #define _MCR_FDX 0x280c /* XXX TBD */ #define _MCR_HDX 0x0001a00c /* XXX TBD */ #define GMACAFR 0x0004 /* frame DA/SA address filter */ -#define AFR_RA (1U<<31) /* receive block all on */ +#define AFR_RA (1U<<31) /* accept all irrecspective of filt. */ #define AFR_HPF (1U<<10) /* hash+perfect filter, or hash only */ #define AFR_SAF (1U<<9) /* source address filter */ #define AFR_SAIF (1U<<8) /* SA inverse filtering */ @@ -161,9 +181,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define AFR_PM (1U<<4) /* accept all multicast frame */ #define AFR_DAIF (1U<<3) /* DA inverse filtering */ #define AFR_MHTE (1U<<2) /* use multicast hash table */ -#define AFR_UHTE (1U<<1) /* use additional MAC addresses */ +#define AFR_UHTE (1U<<1) /* use hash table for unicast */ #define AFR_PR (1U<<0) /* run promisc mode */ -#define _AFR 0x8001 /* XXX TBD */ #define GMACMHTH 0x0008 /* 64bit multicast hash table 63:32 */ #define GMACMHTL 0x000c /* 64bit multicast hash table 31:0 */ #define GMACGAR 0x0010 /* MDIO operation */ @@ -184,6 +203,12 @@ __KERNEL_RCSID(0,
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Fri Mar 27 06:32:49 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_scx.c Log Message: register definition mashed. from UEFI and CycloneV PDF To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/sociox/if_scx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_scx.c diff -u src/sys/arch/arm/sociox/if_scx.c:1.17 src/sys/arch/arm/sociox/if_scx.c:1.18 --- src/sys/arch/arm/sociox/if_scx.c:1.17 Thu Mar 26 10:38:16 2020 +++ src/sys/arch/arm/sociox/if_scx.c Fri Mar 27 06:32:49 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_scx.c,v 1.17 2020/03/26 10:38:16 nisimura Exp $ */ +/* $NetBSD: if_scx.c,v 1.18 2020/03/27 06:32:49 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.17 2020/03/26 10:38:16 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.18 2020/03/27 06:32:49 nisimura Exp $"); #include #include @@ -84,29 +84,31 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #include #include -/* SC2A11 register block */ +/* SC2A11 register block 0x100-0x1204? */ #define SWRESET 0x104 -#define MACADRH 0x10c -#define MACADRL 0x110 #define COMINIT 0x120 -#define INTRST 0x200 -#define IRQ_RX (1U<<1) -#define IRQ_TX (1U<<0) -#define INTREN 0x204 -#define INTR_SET 0x234 -#define INTR_CLR 0x238 -#define TXINTST 0x400 -#define TXINTEN 0x404 -#define TXINT_SET 0x428 -#define TXINT_CLR 0x42c +#define xINTSR 0x200 /* aggregated interrupt status report */ +#define IRQ_RX (1U<<1) /* top level Rx interrupt */ +#define IRQ_TX (1U<<0) /* top level Rx interrupt */ +#define xINTAEN 0x204 /* INT_A enable */ +#define xINTA_SET 0x234 /* bit to set */ +#define xINTA_CLR 0x238 /* bit to clr */ +#define xINTBEN 0x23c /* INT_B enable */ +#define xINTB_SET 0x240 /* bit to set */ +#define xINTB_CLR 0x244 /* bit to clr */ +/* 0x0c-48 *//* pkt,tls,s0,s1 SR/IE/SET/CLR */ +#define TXISR 0x400 +#define TXIEN 0x404 +#define TXI_SET 0x428 +#define TXI_CLR 0x42c #define TXI_NTOWNR (1U<<17) #define TXI_TR_ERR (1U<<16) #define TXI_TXDONE (1U<<15) #define TXI_TMREXP (1U<<14) -#define RXINTST 0x440 -#define RXINTEN 0x444 -#define RXINT_SET 0x468 -#define RXINT_CLR 0x46c +#define RXISR 0x440 +#define RXIEN 0x444 +#define RXI_SET 0x468 +#define RXI_CLR 0x46c #define RXI_RC_ERR (1U<<16) #define RXI_PKTCNT (1U<<15) #define RXI_TMREXP (1U<<14) @@ -117,16 +119,22 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define H2MENG 0x210 /* DMAC host2media ucode port */ #define M2HENG 0x21c /* DMAC media2host ucode port */ #define PKTENG 0x0d0 /* packet engine ucode port */ +#define CLKEN 0x100 /* clock distribution enable */ +#define CLK_G (1U<<5) +#define CLK_ALL 0x24 +#define MACADRH 0x10c /* ??? */ +#define MACADRL 0x110 /* ??? */ #define MCVER 0x22c /* micro controller version */ #define HWVER 0x230 /* hardware version */ -#define MACSTAT 0x1024 /* gmac status */ -#define MACDATA 0x11c0 /* gmac rd/wr data */ #define MACCMD 0x11c4 /* gmac operation */ #define CMD_IOWR (1U<<28) /* write op */ #define CMD_BUSY (1U<<31) /* busy bit */ -#define DESCENG_INIT 0x11fc -#define DESCENG_SRST 0x1204 +#define MACSTAT 0x1024 /* gmac status */ +#define MACDATA 0x11c0 /* gmac rd/wr data */ +#define MACINTE 0x1028 /* interrupt enable */ +#define DESC_INIT 0x11fc /* desc engine init */ +#define DESC_SRST 0x1204 /* desc engine sw reset */ /* GMAC register block. use mac_write()/mac_read() to handle */ #define GMACMCR 0x /* MAC configuration */ @@ -134,8 +142,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define MCR_CST (1U<<25) /* strip CRC */ #define MCR_TC (1U<<24) /* keep RGMII PHY notified */ #define MCR_JE (1U<<20) /* ignore oversized >9018 condition */ -#define MCR_USEMII (1U<<15) /* 1: RMII/MII, 0: RGMII */ -#define MCR_SPD100 (1U<<14) /* force speed 100 */ +#define MCR_USEMII (1U<<15) /* 1: RMII/MII, 0: RGMII (_PS) */ +#define MCR_SPD100 (1U<<14) /* force speed 100 (_FES) */ #define MCR_USEFDX (1U<<11) /* force full duplex */ #define MCR_IPCKEN (1U<<10) /* handle checksum */ #define MCR_ACS (1U<<7) /* auto pad strip CRC */ @@ -145,19 +153,19 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define _MCR_HDX 0x0001a00c /* XXX TBD */ #define GMACAFR 0x0004 /* frame DA/SA address filter */ #define AFR_RA (1U<<31) /* receive block all on */ -#define AFR_HPF (1U<<10) /* activate hash or perfect filter */ +#define AFR_HPF (1U<<10) /* hash+perfect filter, or hash only */ #define AFR_SAF (1U<<9) /* source address filter */ #define AFR_SAIF (1U<<8) /* SA inverse filtering */ -#define AFR_PCF (3U<<6) /* */ -#define AFR_RB (1U<<5) /* reject broadcast frame */ -#define AFR_AM (1U<<4) /* accept all multicast frame */ +#define
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Thu Mar 26 10:38:16 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_scx.c Log Message: update register definition. from UEFI source code. To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/sociox/if_scx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_scx.c diff -u src/sys/arch/arm/sociox/if_scx.c:1.16 src/sys/arch/arm/sociox/if_scx.c:1.17 --- src/sys/arch/arm/sociox/if_scx.c:1.16 Thu Mar 26 08:28:50 2020 +++ src/sys/arch/arm/sociox/if_scx.c Thu Mar 26 10:38:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_scx.c,v 1.16 2020/03/26 08:28:50 nisimura Exp $ */ +/* $NetBSD: if_scx.c,v 1.17 2020/03/26 10:38:16 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -40,14 +40,14 @@ * to designify ring number from which to arrive or to which go. * - memory mapped EEPROM to hold MAC address. The rest of the area is * occupied by a set of ucode for two DMA engines and one packet engine. - * - The size of frame address filter is unknown. Might be 16 or even 128. + * - The size of frame address filter is 16 plus 32. * - The first slot is my own station address. Always enabled to perform * to identify oneself. * - 1~16 are for supplimental MAC addresses. Independently enabled for * use. Good to catch multicast. Byte-wise selective match available. * Use the mask to catch { 0x01, 0x00, 0x00 } and/or { 0x33, 0x33 }. - * - 16~128 might be exact match without byte-mask. - * - The size of multicast hash filter store is unknown. Might be 256 bit. + * - 16~32 might be exact match without byte-mask. + * - The size of multicast hash filter store is 64 bit. * - Socionext/Linaro "NetSec" code makes many cut shorts. Some constants * are left unexplained. The values should be handled via external * controls like FDT descriptions. Fortunately, Intel/Altera CycloneV PDFs @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.16 2020/03/26 08:28:50 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.17 2020/03/26 10:38:16 nisimura Exp $"); #include #include @@ -86,6 +86,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 /* SC2A11 register block */ #define SWRESET 0x104 +#define MACADRH 0x10c +#define MACADRL 0x110 #define COMINIT 0x120 #define INTRST 0x200 #define IRQ_RX (1U<<1) @@ -115,8 +117,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define H2MENG 0x210 /* DMAC host2media ucode port */ #define M2HENG 0x21c /* DMAC media2host ucode port */ #define PKTENG 0x0d0 /* packet engine ucode port */ -#define HWVER0 0x22c -#define HWVER1 0x230 +#define MCVER 0x22c /* micro controller version */ +#define HWVER 0x230 /* hardware version */ #define MACSTAT 0x1024 /* gmac status */ #define MACDATA 0x11c0 /* gmac rd/wr data */ @@ -154,8 +156,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define AFR_UHTE (1U<<1) /* use additional MAC addresses */ #define AFR_PM (1U<<0) /* run promisc mode */ #define _AFR 0x8001 /* XXX TBD */ -#define GMACMHTH 0x0008 /* XXX multicast hash table 63:32 */ -#define GMACMHTL 0x000c /* XXX multicast hash table 31:0 */ +#define GMACMHTH 0x0008 /* multicast hash table 63:32 */ +#define GMACMHTL 0x000c /* multicast hash table 31:0 */ #define GMACGAR 0x0010 /* MDIO operation */ #define GAR_PHY (11) /* mii phy 15:11 */ #define GAR_REG (6) /* mii reg 10:6 */ @@ -180,13 +182,13 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 * 2 125Mhz (1000Mbps) * 1 full duplex detected */ -#define GMACMHT0 0x0500 /* multicast hash table 0 - 7 */ +#define GMACMHT0 0x0500 /* XXX multicast hash table 0 - 7 */ #define GMACMHT(i) ((i)*4+0x500) #define GMACVHT 0x0588 /* VLAN tag hash */ -#define GMACAMAH(i) ((i)*8+0x800) /* supplimental MAC addr 16-127 */ +#define GMACAMAH(i) ((i)*8+0x800) /* supplimental MAC addr 16-31 */ #define GMACAMAL(i) ((i)*8+0x804) +#define GMACEVCTL 0x0100 /* event counter control */ #define GMACEVCNT(i) ((i)*4+0x114) /* event counter 0x114~284 */ -#define GMACEVCTL 0x0100 /* clear event counter registers */ #define GMACBMR 0x1000 /* DMA bus mode control * 244PBL @@ -613,7 +615,7 @@ scx_attach_i(struct scx_softc *sc) uint32_t csr; int i, nseg, error = 0; - hwver = CSR_READ(sc, HWVER1); /* Socionext HW */ + hwver = CSR_READ(sc, HWVER); /* Socionext HW */ /* stored in big endian order */ csr = bus_space_read_4(sc->sc_st, sc->sc_eesh, 0); enaddr[0] = csr >> 24; @@ -953,7 +955,7 @@ scx_set_rcvfilt(struct scx_softc *sc) struct ifnet * const ifp = >ec_if; struct ether_multistep step; struct ether_multi *enm; - uint32_t mchash[8]; /* 8x 32 = 256 bit */ + uint32_t mchash[2]; /* 2x 32 = 64 bit */ uint32_t csr, crc; int i; @@ -972,9 +974,8 @@ scx_set_rcvfilt(struct scx_softc *sc) /* clear 15 entry
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Thu Mar 26 08:28:50 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_scx.c Log Message: correct global reset logic. still remains MII speed trouble. To generate a diff of this commit: cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/sociox/if_scx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_scx.c diff -u src/sys/arch/arm/sociox/if_scx.c:1.15 src/sys/arch/arm/sociox/if_scx.c:1.16 --- src/sys/arch/arm/sociox/if_scx.c:1.15 Thu Mar 26 01:05:26 2020 +++ src/sys/arch/arm/sociox/if_scx.c Thu Mar 26 08:28:50 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_scx.c,v 1.15 2020/03/26 01:05:26 nisimura Exp $ */ +/* $NetBSD: if_scx.c,v 1.16 2020/03/26 08:28:50 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.15 2020/03/26 01:05:26 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.16 2020/03/26 08:28:50 nisimura Exp $"); #include #include @@ -202,7 +202,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 */ #define _BMR 0x00412080 /* XXX TBD */ #define _BMR0 0x00020181 /* XXX TBD */ -#define BMR_RST (1U<<0) /* reset op. self clear when done */ +#define BMR_RST (1) /* reset op. self clear when done */ #define GMACTDS 0x1004 /* write any to resume tdes */ #define GMACRDS 0x1008 /* write any to resume rdes */ #define GMACRDLAR 0x100c /* rdes base address 32bit paddr */ @@ -585,6 +585,8 @@ aprint_normal_dev(self, sc->sc_100mii = (phy_mode && strcmp(phy_mode, "rgmii") != 0); sc->sc_phy_id = (int)acpi_phy; sc->sc_freq = acpi_freq; +aprint_normal_dev(self, +"GMACGAR %08x\n", mac_read(sc, GMACGAR)); scx_attach_i(sc); @@ -631,7 +633,7 @@ scx_attach_i(struct scx_softc *sc) sc->sc_phy_id = MII_PHY_ANY; sc->sc_mdclk = get_mdioclk(sc->sc_freq); /* 5:2 clk control */ -sc->sc_mdclk = 5; /* XXX */ +sc->sc_mdclk = 0; /* XXX */ aprint_normal_dev(sc->sc_dev, "using %d for mdclk\n", sc->sc_mdclk); sc->sc_mdclk <<= 2; @@ -776,16 +778,18 @@ aprint_normal_dev(sc->sc_dev, "descripto static void scx_reset(struct scx_softc *sc) { + int loop = 0, busy; - mac_write(sc, GMACBMR, BMR_RST); /* may take for a while */ - (void)spin_waitfor(sc, GMACBMR, BMR_RST); + mac_write(sc, GMACBMR, _BMR0); /* may take for a while */ + do { + DELAY(10); + busy = mac_read(sc, GMACBMR) & BMR_RST; + } while (++loop < 3000 && busy); +printf("reset done with %d loop\n", loop); CSR_WRITE(sc, DESCENG_SRST, 1); CSR_WRITE(sc, DESCENG_INIT, 1); mac_write(sc, GMACBMR, _BMR); - mac_write(sc, GMACRDLAR, _RDLAR); - mac_write(sc, GMACTDLAR, _TDLAR); - mac_write(sc, GMACAFR, _AFR); mac_write(sc, GMACEVCTL, 1); } @@ -1444,16 +1448,16 @@ add_rxbuf(struct scx_softc *sc, int i) static int spin_waitfor(struct scx_softc *sc, int reg, int exist) { - int val, loop; + int busy, loop; - val = CSR_READ(sc, reg); - if ((val & exist) == 0) + busy = CSR_READ(sc, reg) & exist; + if (busy == 0) return 0; loop = 3000; do { DELAY(10); - val = CSR_READ(sc, reg); - } while (--loop > 0 && (val & exist)); + busy = CSR_READ(sc, reg) & exist; + } while (--loop > 0 && busy); return (loop > 0) ? 0 : ETIMEDOUT; }
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Thu Mar 26 01:05:26 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_scx.c Log Message: adjust minor comments To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/sociox/if_scx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_scx.c diff -u src/sys/arch/arm/sociox/if_scx.c:1.14 src/sys/arch/arm/sociox/if_scx.c:1.15 --- src/sys/arch/arm/sociox/if_scx.c:1.14 Wed Mar 25 20:19:46 2020 +++ src/sys/arch/arm/sociox/if_scx.c Thu Mar 26 01:05:26 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_scx.c,v 1.14 2020/03/25 20:19:46 nisimura Exp $ */ +/* $NetBSD: if_scx.c,v 1.15 2020/03/26 01:05:26 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -57,7 +57,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.14 2020/03/25 20:19:46 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.15 2020/03/26 01:05:26 nisimura Exp $"); #include #include @@ -176,7 +176,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 /* 3 link up detected * 2:1 resovled speed * 0 2.5Mhz (10Mbps) - * 1 25Mhz (100bps) + * 1 25Mhz (100Mbps) * 2 125Mhz (1000Mbps) * 1 full duplex detected */ @@ -463,7 +463,6 @@ scx_fdt_attach(device_t parent, device_t goto fail; } - aprint_naive("\n"); /* aprint_normal(": Gigabit Ethernet Controller\n"); */ aprint_normal_dev(self, "interrupt on %s\n", intrstr); @@ -475,6 +474,7 @@ scx_fdt_attach(device_t parent, device_t sc->sc_eesh = eebsh; sc->sc_eesz = size[1]; sc->sc_dmat = faa->faa_dmat; + sc->sc_dmat32 = faa->faa_dmat; /* XXX */ sc->sc_phandle = phandle; phy_mode = fdtbus_get_string(phandle, "phy-mode"); @@ -583,8 +583,8 @@ scx_acpi_attach(device_t parent, device_ aprint_normal_dev(self, "phy mode %s, phy id %d, freq %ld\n", phy_mode, (int)acpi_phy, acpi_freq); sc->sc_100mii = (phy_mode && strcmp(phy_mode, "rgmii") != 0); - sc->sc_freq = acpi_freq; sc->sc_phy_id = (int)acpi_phy; + sc->sc_freq = acpi_freq; scx_attach_i(sc); @@ -605,13 +605,14 @@ scx_attach_i(struct scx_softc *sc) struct ifnet * const ifp = >sc_ethercom.ec_if; struct mii_data * const mii = >sc_mii; struct ifmedia * const ifm = >mii_media; - uint32_t hwver; + uint32_t hwver, dwimp; uint8_t enaddr[ETHER_ADDR_LEN]; bus_dma_segment_t seg; uint32_t csr; int i, nseg, error = 0; - hwver = CSR_READ(sc, HWVER1); + hwver = CSR_READ(sc, HWVER1); /* Socionext HW */ + /* stored in big endian order */ csr = bus_space_read_4(sc->sc_st, sc->sc_eesh, 0); enaddr[0] = csr >> 24; enaddr[1] = csr >> 16; @@ -620,15 +621,15 @@ scx_attach_i(struct scx_softc *sc) csr = bus_space_read_4(sc->sc_st, sc->sc_eesh, 4); enaddr[4] = csr >> 24; enaddr[5] = csr >> 16; - csr = mac_read(sc, GMACIMPL); + dwimp = mac_read(sc, GMACIMPL); /* DW EMAC XX.YY */ aprint_normal_dev(sc->sc_dev, "Socionext NetSec GbE hw %d.%d impl 0x%x\n", - hwver >> 16, hwver & 0x, csr); + hwver >> 16, hwver & 0x, dwimp); aprint_normal_dev(sc->sc_dev, "Ethernet address %s\n", ether_sprintf(enaddr)); - sc->sc_phy_id = MII_PHY_ANY; +sc->sc_phy_id = MII_PHY_ANY; sc->sc_mdclk = get_mdioclk(sc->sc_freq); /* 5:2 clk control */ sc->sc_mdclk = 5; /* XXX */ aprint_normal_dev(sc->sc_dev, "using %d for mdclk\n", sc->sc_mdclk); @@ -802,7 +803,7 @@ scx_init(struct ifnet *ifp) /* Reset the chip to a known state. */ scx_reset(sc); - /* set my address in perfect match slot 0 */ + /* set my address in perfect match slot 0. little endin order */ csr = (ea[3] << 24) | (ea[2] << 16) | (ea[1] << 8) | ea[0]; mac_write(sc, GMACMAL0, csr); csr = (ea[5] << 8) | ea[4]; @@ -1077,6 +1078,7 @@ mii_statchg(struct ifnet *ifp) struct scx_softc *sc = ifp->if_softc; struct mii_data *mii = >sc_mii; uint32_t fcr; + #if 1 /* decode MIISR register value */ uint32_t miisr = mac_read(sc, GMACMIISR);
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Wed Mar 25 23:31:19 UTC 2020 Modified Files: src/sys/arch/arm/sociox: sni_gpio.c Log Message: try to DRT about config messages, redo ... To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sociox/sni_gpio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/sni_gpio.c diff -u src/sys/arch/arm/sociox/sni_gpio.c:1.6 src/sys/arch/arm/sociox/sni_gpio.c:1.7 --- src/sys/arch/arm/sociox/sni_gpio.c:1.6 Wed Mar 25 23:29:39 2020 +++ src/sys/arch/arm/sociox/sni_gpio.c Wed Mar 25 23:31:19 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sni_gpio.c,v 1.6 2020/03/25 23:29:39 nisimura Exp $ */ +/* $NetBSD: sni_gpio.c,v 1.7 2020/03/25 23:31:19 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sni_gpio.c,v 1.6 2020/03/25 23:29:39 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sni_gpio.c,v 1.7 2020/03/25 23:31:19 nisimura Exp $"); #include #include @@ -151,7 +151,7 @@ snigpio_fdt_attach(device_t parent, devi } aprint_naive("\n"); - aprint_normal_dev("Socionext GPIO controller\n"); + aprint_normal_dev(self, "Socionext GPIO controller\n"); aprint_normal_dev(self, "interrupting on %s\n", intrstr); list = fdtbus_get_string(phandle, "gpio-line-names"); if (list)
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Wed Mar 25 23:29:39 UTC 2020 Modified Files: src/sys/arch/arm/sociox: sni_exiu.c sni_gpio.c Log Message: try to DRT about config messages To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sociox/sni_exiu.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sociox/sni_gpio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/sni_exiu.c diff -u src/sys/arch/arm/sociox/sni_exiu.c:1.2 src/sys/arch/arm/sociox/sni_exiu.c:1.3 --- src/sys/arch/arm/sociox/sni_exiu.c:1.2 Thu Mar 19 22:17:45 2020 +++ src/sys/arch/arm/sociox/sni_exiu.c Wed Mar 25 23:29:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sni_exiu.c,v 1.2 2020/03/19 22:17:45 nisimura Exp $ */ +/* $NetBSD: sni_exiu.c,v 1.3 2020/03/25 23:29:39 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sni_exiu.c,v 1.2 2020/03/19 22:17:45 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sni_exiu.c,v 1.3 2020/03/25 23:29:39 nisimura Exp $"); #include #include @@ -60,8 +60,8 @@ struct sniexiu_softc { bus_space_handle_t sc_ioh; bus_addr_t sc_iob; bus_size_t sc_ios; - kmutex_t sc_lock; void *sc_ih; + kmutex_t sc_lock; int sc_phandle; }; @@ -98,7 +98,6 @@ sniexiu_fdt_attach(device_t parent, devi bus_size_t size; char intrstr[128]; _Bool disable; - int error; prop_dictionary_get_bool(dict, "disable", ); if (disable) { @@ -106,22 +105,25 @@ sniexiu_fdt_attach(device_t parent, devi aprint_normal(": disabled\n"); return; } - error = fdtbus_get_reg(phandle, 0, , ); - if (error) { - aprint_error(": couldn't get registers\n"); - return; - } - error = bus_space_map(faa->faa_bst, addr, size, 0, ); - if (error) { + if (fdtbus_get_reg(phandle, 0, , ) != 0 + || bus_space_map(faa->faa_bst, addr, size, 0, ) != 0) { aprint_error(": unable to map device\n"); return; } - error = fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr)); - if (error) { + if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) { aprint_error(": failed to decode interrupt\n"); - return; + goto fail; + } + sc->sc_ih = fdtbus_intr_establish(phandle, + 0, IPL_NET, 0, sniexiu_intr, sc); + if (sc->sc_ih == NULL) { + aprint_error_dev(self, "couldn't establish interrupt\n"); + goto fail; } + aprint_naive("\n"); + aprint_normal_dev(self, "interrupting on %s\n", intrstr); + sc->sc_dev = self; sc->sc_phandle = phandle; sc->sc_iot = faa->faa_bst; @@ -130,13 +132,6 @@ sniexiu_fdt_attach(device_t parent, devi sc->sc_ios = size; mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_NONE); - sc->sc_ih = fdtbus_intr_establish(phandle, - 0, IPL_NET, 0, sniexiu_intr, sc); - if (sc->sc_ih == NULL) { - aprint_error_dev(self, "couldn't establish interrupt\n"); - goto fail; - } - sniexiu_attach_i(sc); return; fail: @@ -173,30 +168,17 @@ sniexiu_acpi_attach(device_t parent, dev , _resource_parse_ops_default); if (ACPI_FAILURE(rv)) return; - mem = acpi_res_mem(, 0); irq = acpi_res_irq(, 0); - if (mem == NULL || irq == NULL) { + if (mem == NULL || irq == NULL || mem->ar_length) { aprint_error(": incomplete resources\n"); return; } - if (mem->ar_length == 0) { - aprint_error(": zero length memory resource\n"); - return; - } if (bus_space_map(aa->aa_memt, mem->ar_base, mem->ar_length, 0, )) { aprint_error(": couldn't map registers\n"); return; } - - sc->sc_dev = self; - sc->sc_iot = aa->aa_memt; - sc->sc_ioh = ioh; - sc->sc_iob = mem->ar_base; - sc->sc_ios = mem->ar_length; - mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_NONE); - sc->sc_ih = acpi_intr_establish(self, (uint64_t)(uintptr_t)aa->aa_node->ad_handle, IPL_BIO, false, sniexiu_intr, sc, device_xname(self)); @@ -205,20 +187,31 @@ sniexiu_acpi_attach(device_t parent, dev goto fail; } + aprint_naive("\n"); + + sc->sc_dev = self; + sc->sc_iot = aa->aa_memt; + sc->sc_ioh = ioh; + sc->sc_iob = mem->ar_base; + sc->sc_ios = mem->ar_length; + mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_NONE); + sniexiu_attach_i(sc); + + acpi_resource_cleanup(); + return; fail: + bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_ios); acpi_resource_cleanup(); + return; } static void sniexiu_attach_i(struct sniexiu_softc *sc) { - - aprint_naive(": External IRQ controller\n"); - aprint_normal(": External IRQ controller\n"); - + + aprint_normal_dev(sc->sc_dev, "Socionext External IRQ controller\n"); /* AAA */ - return; } Index: src/sys/arch/arm/sociox/sni_gpio.c diff -u src/sys/arch/arm/sociox/sni_gpio.c:1.5 src/sys/arch/arm/sociox/sni_gpio.c:1.6 --- src/sys/arch/arm/sociox/sni_gpio.c:1.5 Wed Mar 25 19:03:44 2020 +++ src/sys/arch/arm/sociox/sni_gpio.c Wed Mar 25 23:29:39 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sni_gpio.c,v 1.5 2020/03/25 19:03:44 nisimura Exp $ */ +/* $NetBSD: sni_gpio.c,v
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Wed Mar 25 23:20:38 UTC 2020 Modified Files: src/sys/arch/arm/sociox: sni_emmc.c sni_i2c.c Log Message: DRT about config messages To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sociox/sni_emmc.c \ src/sys/arch/arm/sociox/sni_i2c.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/sni_emmc.c diff -u src/sys/arch/arm/sociox/sni_emmc.c:1.5 src/sys/arch/arm/sociox/sni_emmc.c:1.6 --- src/sys/arch/arm/sociox/sni_emmc.c:1.5 Wed Mar 25 22:15:53 2020 +++ src/sys/arch/arm/sociox/sni_emmc.c Wed Mar 25 23:20:38 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sni_emmc.c,v 1.5 2020/03/25 22:15:53 nisimura Exp $ */ +/* $NetBSD: sni_emmc.c,v 1.6 2020/03/25 23:20:38 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sni_emmc.c,v 1.5 2020/03/25 22:15:53 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sni_emmc.c,v 1.6 2020/03/25 23:20:38 nisimura Exp $"); #include #include @@ -132,6 +132,7 @@ sniemmc_fdt_attach(device_t parent, devi } aprint_naive("\n"); + aprint_normal_dev(self, "Socionext eMMC controller\n"); aprint_normal_dev(self, "interrupting on %s\n", intrstr); sc->sc.sc_dev = self; @@ -199,6 +200,7 @@ sniemmc_acpi_attach(device_t parent, dev } aprint_naive("\n"); + aprint_normal_dev(self, "Socionext eMMC controller\n"); sc->sc.sc_dev = self; sc->sc.sc_dmat = aa->aa_dmat; @@ -227,7 +229,7 @@ sniemmc_attach_i(device_t self) sc->sc.sc_flags |= SDHC_FLAG_32BIT_ACCESS; sc->sc.sc_clkbase = 5; /* Default to 50MHz */ - aprint_normal_dev(sc->sc.sc_dev, "Socionext eMMC controller\n"); + aprint_normal_dev(sc->sc.sc_dev, "doing sdhc_host() ...\n"); #if 0 error = sdhc_host_found(>sc, sc->sc_iot, sc->sc_ioh, sc->sc_ios); #endif Index: src/sys/arch/arm/sociox/sni_i2c.c diff -u src/sys/arch/arm/sociox/sni_i2c.c:1.5 src/sys/arch/arm/sociox/sni_i2c.c:1.6 --- src/sys/arch/arm/sociox/sni_i2c.c:1.5 Wed Mar 25 22:15:53 2020 +++ src/sys/arch/arm/sociox/sni_i2c.c Wed Mar 25 23:20:38 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sni_i2c.c,v 1.5 2020/03/25 22:15:53 nisimura Exp $ */ +/* $NetBSD: sni_i2c.c,v 1.6 2020/03/25 23:20:38 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sni_i2c.c,v 1.5 2020/03/25 22:15:53 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sni_i2c.c,v 1.6 2020/03/25 23:20:38 nisimura Exp $"); #include #include @@ -61,7 +61,6 @@ static void sniiic_acpi_attach(device_t, struct sniiic_softc { device_t sc_dev; struct i2c_controller sc_ic; - device_t sc_i2cdev; bus_space_tag_t sc_iot; bus_space_handle_t sc_ioh; bus_addr_t sc_iob; @@ -70,8 +69,7 @@ struct sniiic_softc { kmutex_t sc_lock; kmutex_t sc_mtx; kcondvar_t sc_cv; - int sc_opflags; - bool sc_busy; + volatile bool sc_busy; int sc_phandle; }; @@ -81,6 +79,8 @@ CFATTACH_DECL_NEW(sniiic_fdt, sizeof(str CFATTACH_DECL_NEW(sniiic_acpi, sizeof(struct sniiic_softc), sniiic_acpi_match, sniiic_acpi_attach, NULL, NULL); +void sni_i2c_common_i(struct sniiic_softc *); + static int sni_i2c_acquire_bus(void *, int); static void sni_i2c_release_bus(void *, int); static int sni_i2c_exec(void *, i2c_op_t, i2c_addr_t, const void *, @@ -148,7 +148,6 @@ sniiic_fdt_attach(device_t parent, devic } aprint_naive("\n"); - aprint_normal_dev(self, "Socionext I2C controller\n"); aprint_normal_dev(self, "interrupting on %s\n", intrstr); sc->sc_dev = self; @@ -156,15 +155,8 @@ sniiic_fdt_attach(device_t parent, devic sc->sc_ioh = ioh; sc->sc_iob = addr; sc->sc_ios = size; - mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_NONE); - mutex_init(>sc_mtx, MUTEX_DEFAULT, IPL_BIO); - cv_init(>sc_cv, device_xname(self)); - iic_tag_init(>sc_ic); - sc->sc_ic.ic_cookie = sc; - sc->sc_ic.ic_acquire_bus = sni_i2c_acquire_bus; - sc->sc_ic.ic_release_bus = sni_i2c_release_bus; - sc->sc_ic.ic_exec = sni_i2c_exec; + sni_i2c_common_i(sc); fdtbus_register_i2c_controller(self, phandle, _i2c_funcs); #if 0 @@ -226,22 +218,14 @@ sniiic_acpi_attach(device_t parent, devi } aprint_naive("\n"); - aprint_normal_dev(self, "Socionext I2C controller\n"); sc->sc_dev = self; sc->sc_iot = aa->aa_memt; sc->sc_ioh = ioh; sc->sc_iob = mem->ar_base; sc->sc_ios = mem->ar_length; - mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_NONE); - mutex_init(>sc_mtx, MUTEX_DEFAULT, IPL_NET); - cv_init(>sc_cv, device_xname(self)); - iic_tag_init(>sc_ic); - sc->sc_ic.ic_cookie = sc; - sc->sc_ic.ic_acquire_bus = sni_i2c_acquire_bus; - sc->sc_ic.ic_release_bus = sni_i2c_release_bus; - sc->sc_ic.ic_exec = sni_i2c_exec; + sni_i2c_common_i(sc); memset(, 0, sizeof(iba)); iba.iba_tag = >sc_ic; @@ -258,6 +242,24 @@ sniiic_acpi_attach(device_t parent, devi
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Wed Mar 25 22:15:53 UTC 2020 Modified Files: src/sys/arch/arm/sociox: sni_emmc.c sni_i2c.c Log Message: better boot messaging, redo To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/sociox/sni_emmc.c \ src/sys/arch/arm/sociox/sni_i2c.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/sni_emmc.c diff -u src/sys/arch/arm/sociox/sni_emmc.c:1.4 src/sys/arch/arm/sociox/sni_emmc.c:1.5 --- src/sys/arch/arm/sociox/sni_emmc.c:1.4 Wed Mar 25 22:11:00 2020 +++ src/sys/arch/arm/sociox/sni_emmc.c Wed Mar 25 22:15:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sni_emmc.c,v 1.4 2020/03/25 22:11:00 nisimura Exp $ */ +/* $NetBSD: sni_emmc.c,v 1.5 2020/03/25 22:15:53 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sni_emmc.c,v 1.4 2020/03/25 22:11:00 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sni_emmc.c,v 1.5 2020/03/25 22:15:53 nisimura Exp $"); #include #include @@ -132,7 +132,7 @@ sniemmc_fdt_attach(device_t parent, devi } aprint_naive("\n"); - aprint_normal_dev(self, ": interrupting on %s\n", intrstr); + aprint_normal_dev(self, "interrupting on %s\n", intrstr); sc->sc.sc_dev = self; sc->sc.sc_dmat = faa->faa_dmat; Index: src/sys/arch/arm/sociox/sni_i2c.c diff -u src/sys/arch/arm/sociox/sni_i2c.c:1.4 src/sys/arch/arm/sociox/sni_i2c.c:1.5 --- src/sys/arch/arm/sociox/sni_i2c.c:1.4 Wed Mar 25 22:11:00 2020 +++ src/sys/arch/arm/sociox/sni_i2c.c Wed Mar 25 22:15:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sni_i2c.c,v 1.4 2020/03/25 22:11:00 nisimura Exp $ */ +/* $NetBSD: sni_i2c.c,v 1.5 2020/03/25 22:15:53 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sni_i2c.c,v 1.4 2020/03/25 22:11:00 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sni_i2c.c,v 1.5 2020/03/25 22:15:53 nisimura Exp $"); #include #include @@ -148,8 +148,8 @@ sniiic_fdt_attach(device_t parent, devic } aprint_naive("\n"); - aprint_normal_dev(self, ": Socionext I2C controller\n"); - aprint_normal_dev(self, ": interrupting on %s\n", intrstr); + aprint_normal_dev(self, "Socionext I2C controller\n"); + aprint_normal_dev(self, "interrupting on %s\n", intrstr); sc->sc_dev = self; sc->sc_iot = faa->faa_bst; @@ -226,7 +226,7 @@ sniiic_acpi_attach(device_t parent, devi } aprint_naive("\n"); - aprint_normal_dev(self, ": Socionext I2C controller\n"); + aprint_normal_dev(self, "Socionext I2C controller\n"); sc->sc_dev = self; sc->sc_iot = aa->aa_memt;
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Wed Mar 25 22:11:00 UTC 2020 Modified Files: src/sys/arch/arm/sociox: sni_emmc.c sni_i2c.c Log Message: better boot messaging To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sociox/sni_emmc.c \ src/sys/arch/arm/sociox/sni_i2c.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/sni_emmc.c diff -u src/sys/arch/arm/sociox/sni_emmc.c:1.3 src/sys/arch/arm/sociox/sni_emmc.c:1.4 --- src/sys/arch/arm/sociox/sni_emmc.c:1.3 Wed Mar 18 10:05:24 2020 +++ src/sys/arch/arm/sociox/sni_emmc.c Wed Mar 25 22:11:00 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sni_emmc.c,v 1.3 2020/03/18 10:05:24 nisimura Exp $ */ +/* $NetBSD: sni_emmc.c,v 1.4 2020/03/25 22:11:00 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sni_emmc.c,v 1.3 2020/03/18 10:05:24 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sni_emmc.c,v 1.4 2020/03/25 22:11:00 nisimura Exp $"); #include #include @@ -66,12 +66,12 @@ struct sniemmc_softc { bus_space_handle_t sc_ioh; bus_addr_t sc_iob; bus_size_t sc_ios; - struct sdhc_host *sc_hosts[1]; void *sc_ih; - int sc_phandle; + struct sdhc_host *sc_hosts[1]; bus_dmamap_t sc_dmamap; bus_dma_segment_t sc_segs[1]; kcondvar_t sc_cv; + int sc_phandle; }; CFATTACH_DECL_NEW(sniemmc_fdt, sizeof(struct sniemmc_softc), @@ -105,10 +105,8 @@ sniemmc_fdt_attach(device_t parent, devi bus_space_handle_t ioh; bus_addr_t addr; bus_size_t size; - void *ih; char intrstr[128]; _Bool disable; - int error; prop_dictionary_get_bool(dict, "disable", ); if (disable) { @@ -116,24 +114,25 @@ sniemmc_fdt_attach(device_t parent, devi aprint_normal(": disabled\n"); return; } - error = fdtbus_get_reg(phandle, 0, , ); - if (error) { - aprint_error(": couldn't get registers\n"); - return; - } - error = bus_space_map(faa->faa_bst, addr, size, 0, ); - if (error) { + if (fdtbus_get_reg(phandle, 0, , ) != 0 + || bus_space_map(faa->faa_bst, addr, size, 0, ) != 0) { aprint_error(": unable to map device\n"); return; } - error = fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr)); - if (error) { + if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) { aprint_error(": failed to decode interrupt\n"); - return; + goto fail; + } + sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_SDMMC, 0, + sdhc_intr, >sc); + if (sc->sc_ih == NULL) { + aprint_error_dev(self, "couldn't establish interrupt on %s\n", + intrstr); + goto fail; } - aprint_naive(": SDHC controller\n"); - aprint_normal(": SDHC controller\n"); + aprint_naive("\n"); + aprint_normal_dev(self, ": interrupting on %s\n", intrstr); sc->sc.sc_dev = self; sc->sc.sc_dmat = faa->faa_dmat; @@ -144,18 +143,7 @@ sniemmc_fdt_attach(device_t parent, devi sc->sc_iob = addr; sc->sc_ios = size; - ih = fdtbus_intr_establish(phandle, 0, IPL_SDMMC, 0, - sdhc_intr, >sc); - if (ih == NULL) { - aprint_error_dev(self, "couldn't establish interrupt on %s\n", - intrstr); - goto fail; - } - aprint_normal_dev(self, "interrupting on %s\n", intrstr); - sc->sc_ih = ih; - config_defer(self, sniemmc_attach_i); - return; fail: bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_ios); @@ -186,31 +174,31 @@ sniemmc_acpi_attach(device_t parent, dev struct acpi_mem *mem; struct acpi_irq *irq; ACPI_STATUS rv; - void *ih; rv = acpi_resource_parse(self, aa->aa_node->ad_handle, "_CRS", , _resource_parse_ops_default); if (ACPI_FAILURE(rv)) return; - mem = acpi_res_mem(, 0); irq = acpi_res_irq(, 0); - if (mem == NULL || irq == NULL) { + if (mem == NULL || irq == NULL || mem->ar_length == 0) { aprint_error(": incomplete resources\n"); return; } - if (mem->ar_length == 0) { - aprint_error(": zero length memory resource\n"); - return; - } if (bus_space_map(aa->aa_memt, mem->ar_base, mem->ar_length, 0, )) { aprint_error(": couldn't map registers\n"); return; } + sc->sc_ih = acpi_intr_establish(self, + (uint64_t)(uintptr_t)aa->aa_node->ad_handle, + IPL_BIO, false, sdhc_intr, >sc, device_xname(self)); + if (sc->sc_ih == NULL) { + aprint_error_dev(self, "couldn't establish interrupt\n"); + goto fail; + } - aprint_naive(": SDHC controller\n"); - aprint_normal(": SDHC controller\n"); + aprint_naive("\n"); sc->sc.sc_dev = self; sc->sc.sc_dmat = aa->aa_dmat; @@ -219,20 +207,10 @@ sniemmc_acpi_attach(device_t parent, dev sc->sc_ioh = ioh; sc->sc_ios = mem->ar_length; - ih = acpi_intr_establish(self, - (uint64_t)(uintptr_t)aa->aa_node->ad_handle, - IPL_BIO, false, sdhc_intr, >sc, device_xname(self)); - if (ih == NULL) { - aprint_error_dev(self, "couldn't establish interrupt\n"); - goto fail; - } - sc->sc_ih = ih; - config_defer(self, sniemmc_attach_i);
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Wed Mar 25 20:19:46 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_scx.c Log Message: use dma32 for descriptor store. likely still missing freq designation(s) To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/sociox/if_scx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_scx.c diff -u src/sys/arch/arm/sociox/if_scx.c:1.13 src/sys/arch/arm/sociox/if_scx.c:1.14 --- src/sys/arch/arm/sociox/if_scx.c:1.13 Wed Mar 25 01:39:49 2020 +++ src/sys/arch/arm/sociox/if_scx.c Wed Mar 25 20:19:46 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_scx.c,v 1.13 2020/03/25 01:39:49 nisimura Exp $ */ +/* $NetBSD: if_scx.c,v 1.14 2020/03/25 20:19:46 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -53,10 +53,11 @@ * controls like FDT descriptions. Fortunately, Intel/Altera CycloneV PDFs * describe every detail of "such the instance of" DW EMAC IP and * most of them are likely applicable to SC2A11 GbE. + * - DW EMAC implmentation (0x20) is 0x10.0x36 */ #include -__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.13 2020/03/25 01:39:49 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.14 2020/03/25 20:19:46 nisimura Exp $"); #include #include @@ -166,7 +167,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define FCR_RFE (1U<<2) /* accept PAUSE to throttle Tx */ #define FCR_TFE (1U<<1) /* generate PAUSE to moderate Rx lvl */ #define GMACVTAG 0x001c /* VLAN tag control */ -#define GMACIMPL 0x0020 /* implementation number . */ +#define GMACIMPL 0x0020 /* implementation number XX.YY */ #define GMACMAH0 0x0040 /* MAC address 0 47:32 */ #define GMACMAL0 0x0044 /* MAC address 0 31:0 */ #define GMACMAH(i) ((i)*8+0x40) /* supplimental MAC addr 1 - 15 */ @@ -174,7 +175,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define GMACMIISR 0x00d8 /* resolved xMII link status */ /* 3 link up detected * 2:1 resovled speed - * 0 2.5Mhz (10Mbps) + * 0 2.5Mhz (10Mbps) * 1 25Mhz (100bps) * 2 125Mhz (1000Mbps) * 1 full duplex detected */ @@ -306,6 +307,7 @@ struct scx_softc { bus_space_handle_t sc_eesh; /* eeprom section handle */ bus_size_t sc_eesz; /* eeprom map size */ bus_dma_tag_t sc_dmat; /* bus DMA tag */ + bus_dma_tag_t sc_dmat32; struct ethercom sc_ethercom; /* Ethernet common data */ struct mii_data sc_mii; /* MII */ callout_t sc_tick_ch; /* PHY monitor callout */ @@ -319,6 +321,7 @@ struct scx_softc { int sc_ucodeloaded; /* ucode for H2M/M2H/PKT */ int sc_100mii; /* 1 for RMII/MII, 0 for RGMII */ int sc_phandle; /* fdt phandle */ + uint64_t sc_freq; bus_dmamap_t sc_cddmamap; /* control data DMA map */ #define sc_cddma sc_cddmamap->dm_segs[0].ds_addr @@ -399,12 +402,12 @@ static void txreap(struct scx_softc *); static void rxintr(struct scx_softc *); static int add_rxbuf(struct scx_softc *, int); -static int get_mdioclk(uint32_t); static int spin_waitfor(struct scx_softc *, int, int); static int mac_read(struct scx_softc *, int); static void mac_write(struct scx_softc *, int, int); static void loaducode(struct scx_softc *); static void injectucode(struct scx_softc *, int, bus_addr_t, bus_size_t); +static int get_mdioclk(uint32_t); #define CSR_READ(sc,off) \ bus_space_read_4((sc)->sc_st, (sc)->sc_sh, (off)) @@ -460,14 +463,9 @@ scx_fdt_attach(device_t parent, device_t goto fail; } - phy_mode = fdtbus_get_string(phandle, "phy-mode"); - if (phy_mode == NULL) { - aprint_error(": missing 'phy-mode' property\n"); - phy_mode = "rgmii"; - } aprint_naive("\n"); - aprint_normal(": Gigabit Ethernet Controller\n"); + /* aprint_normal(": Gigabit Ethernet Controller\n"); */ aprint_normal_dev(self, "interrupt on %s\n", intrstr); sc->sc_dev = self; @@ -478,7 +476,15 @@ scx_fdt_attach(device_t parent, device_t sc->sc_eesz = size[1]; sc->sc_dmat = faa->faa_dmat; sc->sc_phandle = phandle; - sc->sc_100mii = (strcmp(phy_mode, "rgmii") != 0); + + phy_mode = fdtbus_get_string(phandle, "phy-mode"); + if (phy_mode == NULL) + aprint_error(": missing 'phy-mode' property\n"); + sc->sc_100mii = (phy_mode != NULL && strcmp(phy_mode, "rgmii") != 0); +sc->sc_phy_id = 7; /* XXX */ +sc->sc_freq = 250 * 1000 * 1000; /* XXX */ +aprint_normal_dev(self, +"phy mode %s, phy id %d, freq %ld\n", phy_mode, sc->sc_phy_id, sc->sc_freq); scx_attach_i(sc); return; @@ -515,13 +521,14 @@ scx_acpi_attach(device_t parent, device_ struct acpi_resources res; struct acpi_mem *mem; struct acpi_irq *irq; + char *phy_mode; + ACPI_INTEGER acpi_phy, acpi_freq; ACPI_STATUS rv; rv = acpi_resource_parse(self, handle, "_CRS", , _resource_parse_ops_default); if (ACPI_FAILURE(rv)) return; -acpi_resource_print(self, ); mem = acpi_res_mem(, 0); irq =
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Wed Mar 25 19:03:44 UTC 2020 Modified Files: src/sys/arch/arm/sociox: sni_gpio.c Log Message: describe DeveloperBox pin assignment correctly To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/sociox/sni_gpio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/sni_gpio.c diff -u src/sys/arch/arm/sociox/sni_gpio.c:1.4 src/sys/arch/arm/sociox/sni_gpio.c:1.5 --- src/sys/arch/arm/sociox/sni_gpio.c:1.4 Wed Mar 25 18:42:16 2020 +++ src/sys/arch/arm/sociox/sni_gpio.c Wed Mar 25 19:03:44 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sni_gpio.c,v 1.4 2020/03/25 18:42:16 nisimura Exp $ */ +/* $NetBSD: sni_gpio.c,v 1.5 2020/03/25 19:03:44 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sni_gpio.c,v 1.4 2020/03/25 18:42:16 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sni_gpio.c,v 1.5 2020/03/25 19:03:44 nisimura Exp $"); #include #include @@ -82,21 +82,21 @@ CFATTACH_DECL_NEW(snigpio_acpi, sizeof(s * "DevelopmentBox" implementation *DSW3-PIN1, DSW3-PIN2, DSW3-PIN3,DSW3-PIN4, *DSW3-PIN5, DSW3-PIN6, DSW3-PIN7,DSW3-PIN8, - *PEC-PD8,PEC-PD9,PEC-PD10, PEC-PD11, - *NC, NC, PCIE1EXTINT, PCIE0EXTINT, - *PHY_P2_2, PHY_P1_2, NC, NC, - *NC, NC, NC, NC, - *NC, NC, PEC-PD26, PEC-PD27, - *PEC-PD28, PEC-PD29, PEC-PD30, PEC-PD31; + *PSIN#, PWROFF#,GPIO-A, GPIO-B, + *GPIO-C, GPIO-D, PCIE1EXTINT, PCIE0EXTINT, + *PHY2-INT#, PHY1-INT#, GPIO-E, GPIO-F, + *GPIO-G, GPIO-H, GPIO-I, GPIO-J, + *GPIO-K, GPIO-L, PEC-PD26, PEC-PD27, + *PEC-PD28, PEC-PD29, PEC-PD30, PEC-PD31 * - *PD/PC/PB/PA 0-7 in this order. *DSW3-PIN1 -- what's "varstore" really this *DSW3-PIN3 -- tweek PCIe bus implementation error toggle + *PowerButton (PWROFF#) can be detectable. * * 96board mezzanine *i2c "/i2c@51221000" *spi "/spi@5481" - *gpio "/gpio@5100" pinA-L (10-25) level? sensitive + *gpio "/gpio@5100" pinA-L (10-25) down edge sensitive */ static void snigpio_attach_i(struct snigpio_softc *); static int snigpio_intr(void *); @@ -225,15 +225,13 @@ snigpio_acpi_attach(device_t parent, dev sc->sc_ioh = ioh; sc->sc_ios = mem->ar_length; + snigpio_attach_i(sc); + /* dig _DSD property to show 32 of GPIO line usage */ rv = acpi_dsd_string(handle, "gpio-line-names", ); - if (ACPI_FAILURE(rv)) - list = NULL; - else + if (ACPI_SUCCESS(rv)) aprint_normal_dev(self, "%s\n", list); - snigpio_attach_i(sc); - acpi_resource_cleanup(); return; fail:
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Wed Mar 25 18:42:17 UTC 2020 Modified Files: src/sys/arch/arm/sociox: sni_gpio.c Log Message: try to decode _DSD ACPI resource To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sociox/sni_gpio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/sni_gpio.c diff -u src/sys/arch/arm/sociox/sni_gpio.c:1.3 src/sys/arch/arm/sociox/sni_gpio.c:1.4 --- src/sys/arch/arm/sociox/sni_gpio.c:1.3 Tue Mar 24 11:40:08 2020 +++ src/sys/arch/arm/sociox/sni_gpio.c Wed Mar 25 18:42:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sni_gpio.c,v 1.3 2020/03/24 11:40:08 nisimura Exp $ */ +/* $NetBSD: sni_gpio.c,v 1.4 2020/03/25 18:42:16 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sni_gpio.c,v 1.3 2020/03/24 11:40:08 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sni_gpio.c,v 1.4 2020/03/25 18:42:16 nisimura Exp $"); #include #include @@ -88,6 +88,15 @@ CFATTACH_DECL_NEW(snigpio_acpi, sizeof(s *NC, NC, NC, NC, *NC, NC, PEC-PD26, PEC-PD27, *PEC-PD28, PEC-PD29, PEC-PD30, PEC-PD31; + * + *PD/PC/PB/PA 0-7 in this order. + *DSW3-PIN1 -- what's "varstore" really this + *DSW3-PIN3 -- tweek PCIe bus implementation error toggle + * + * 96board mezzanine + *i2c "/i2c@51221000" + *spi "/spi@5481" + *gpio "/gpio@5100" pinA-L (10-25) level? sensitive */ static void snigpio_attach_i(struct snigpio_softc *); static int snigpio_intr(void *); @@ -154,7 +163,6 @@ snigpio_fdt_attach(device_t parent, devi snigpio_attach_i(sc); /* dig FDT description to show 32 of GPIO line usage */ -/* DIPSW3 1-8 usage remain unclear */ return; fail: @@ -181,11 +189,13 @@ snigpio_acpi_attach(device_t parent, dev { struct snigpio_softc * const sc = device_private(self); struct acpi_attach_args *aa = aux; + ACPI_HANDLE handle = aa->aa_node->ad_handle; bus_space_handle_t ioh; struct acpi_resources res; struct acpi_mem *mem; struct acpi_irq *irq; ACPI_STATUS rv; + char *list; rv = acpi_resource_parse(self, aa->aa_node->ad_handle, "_CRS", , _resource_parse_ops_default); @@ -215,10 +225,14 @@ snigpio_acpi_attach(device_t parent, dev sc->sc_ioh = ioh; sc->sc_ios = mem->ar_length; - snigpio_attach_i(sc); + /* dig _DSD property to show 32 of GPIO line usage */ + rv = acpi_dsd_string(handle, "gpio-line-names", ); + if (ACPI_FAILURE(rv)) + list = NULL; + else + aprint_normal_dev(self, "%s\n", list); -/* dig _DSD property to show 32 of GPIO line usage */ -/* DIPSW3 1-8 usage remain unclear */ + snigpio_attach_i(sc); acpi_resource_cleanup(); return;
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Wed Mar 25 01:39:50 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_scx.c Log Message: make sure to use mac_write() for GMACxxx registers. try to decode xMII link status report To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/sociox/if_scx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_scx.c diff -u src/sys/arch/arm/sociox/if_scx.c:1.12 src/sys/arch/arm/sociox/if_scx.c:1.13 --- src/sys/arch/arm/sociox/if_scx.c:1.12 Tue Mar 24 13:44:21 2020 +++ src/sys/arch/arm/sociox/if_scx.c Wed Mar 25 01:39:49 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_scx.c,v 1.12 2020/03/24 13:44:21 nisimura Exp $ */ +/* $NetBSD: if_scx.c,v 1.13 2020/03/25 01:39:49 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -56,7 +56,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.12 2020/03/24 13:44:21 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.13 2020/03/25 01:39:49 nisimura Exp $"); #include #include @@ -83,6 +83,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #include #include +/* SC2A11 register block */ #define SWRESET 0x104 #define COMINIT 0x120 #define INTRST 0x200 @@ -124,6 +125,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define DESCENG_INIT 0x11fc #define DESCENG_SRST 0x1204 +/* GMAC register block. use mac_write()/mac_read() to handle */ #define GMACMCR 0x /* MAC configuration */ #define MCR_IBN (1U<<30) /* */ #define MCR_CST (1U<<25) /* strip CRC */ @@ -169,13 +171,21 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define GMACMAL0 0x0044 /* MAC address 0 31:0 */ #define GMACMAH(i) ((i)*8+0x40) /* supplimental MAC addr 1 - 15 */ #define GMACMAL(i) ((i)*8+0x44) -#define GMACMDSR 0x00d8 /* GMII/RGMII/MII command/status */ +#define GMACMIISR 0x00d8 /* resolved xMII link status */ + /* 3 link up detected + * 2:1 resovled speed + * 0 2.5Mhz (10Mbps) + * 1 25Mhz (100bps) + * 2 125Mhz (1000Mbps) + * 1 full duplex detected */ + #define GMACMHT0 0x0500 /* multicast hash table 0 - 7 */ #define GMACMHT(i) ((i)*4+0x500) #define GMACVHT 0x0588 /* VLAN tag hash */ #define GMACAMAH(i) ((i)*8+0x800) /* supplimental MAC addr 16-127 */ #define GMACAMAL(i) ((i)*8+0x804) #define GMACEVCNT(i) ((i)*4+0x114) /* event counter 0x114~284 */ +#define GMACEVCTL 0x0100 /* clear event counter registers */ #define GMACBMR 0x1000 /* DMA bus mode control * 244PBL @@ -202,8 +212,6 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define OMR_TXE (1U<<13) /* start Tx DMA engine, 0 to stop */ #define OMR_RXE (1U<<1) /* start Rx DMA engine, 0 to stop */ -static int get_mdioclk(uint32_t); - /* descriptor format definition */ struct tdes { uint32_t t0, t1, t2, t3; @@ -390,6 +398,8 @@ static int scx_intr(void *); static void txreap(struct scx_softc *); static void rxintr(struct scx_softc *); static int add_rxbuf(struct scx_softc *, int); + +static int get_mdioclk(uint32_t); static int spin_waitfor(struct scx_softc *, int, int); static int mac_read(struct scx_softc *, int); static void mac_write(struct scx_softc *, int, int); @@ -585,7 +595,7 @@ scx_attach_i(struct scx_softc *sc) csr = bus_space_read_4(sc->sc_st, sc->sc_eesh, 4); enaddr[4] = csr >> 24; enaddr[5] = csr >> 16; - csr = CSR_READ(sc, GMACIMPL); + csr = mac_read(sc, GMACIMPL); aprint_normal_dev(sc->sc_dev, "NetSec GbE (%d.%d) impl (%x.%x)\n", hwver >> 16, hwver & 0x, csr >> 16, csr & 0x); @@ -747,6 +757,7 @@ scx_reset(struct scx_softc *sc) mac_write(sc, GMACRDLAR, _RDLAR); mac_write(sc, GMACTDLAR, _TDLAR); mac_write(sc, GMACAFR, _AFR); + mac_write(sc, GMACEVCTL, 1); } static int @@ -763,28 +774,43 @@ scx_init(struct ifnet *ifp) /* Reset the chip to a known state. */ scx_reset(sc); - /* build sane Tx and load Rx descriptors with mbuf */ - for (i = 0; i < MD_NTXDESC; i++) - sc->sc_txdescs[i].t0 = T0_OWN; - sc->sc_txdescs[MD_NTXDESC - 1].t0 |= T0_EOD; /* tie off the ring */ - for (i = 0; i < MD_NRXDESC; i++) - (void)add_rxbuf(sc, i); - /* set my address in perfect match slot 0 */ csr = (ea[3] << 24) | (ea[2] << 16) | (ea[1] << 8) | ea[0]; - CSR_WRITE(sc, GMACMAL0, csr); + mac_write(sc, GMACMAL0, csr); csr = (ea[5] << 8) | ea[4]; - CSR_WRITE(sc, GMACMAH0, csr | 1U<<31); /* always valid? */ + mac_write(sc, GMACMAH0, csr | 1U<<31); /* always valid? */ /* accept multicast frame or run promisc mode */ scx_set_rcvfilt(sc); (void)scx_ifmedia_upd(ifp); + /* build sane Tx */ + memset(sc->sc_txdescs, 0, sizeof(struct tdes) * MD_NTXDESC); + sc->sc_txdescs[MD_NTXDESC - 1].t0 |= T0_EOD; /* tie off the ring */ + SCX_CDTXSYNC(sc, 0, MD_NTXDESC, + BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); + sc->sc_txfree = MD_NTXDESC; + sc->sc_txnext = 0; + for (i = 0; i <
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Tue Mar 24 13:44:21 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_scx.c Log Message: add more register description To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/sociox/if_scx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_scx.c diff -u src/sys/arch/arm/sociox/if_scx.c:1.11 src/sys/arch/arm/sociox/if_scx.c:1.12 --- src/sys/arch/arm/sociox/if_scx.c:1.11 Tue Mar 24 13:07:46 2020 +++ src/sys/arch/arm/sociox/if_scx.c Tue Mar 24 13:44:21 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_scx.c,v 1.11 2020/03/24 13:07:46 nisimura Exp $ */ +/* $NetBSD: if_scx.c,v 1.12 2020/03/24 13:44:21 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -56,7 +56,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.11 2020/03/24 13:07:46 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.12 2020/03/24 13:44:21 nisimura Exp $"); #include #include @@ -169,11 +169,13 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define GMACMAL0 0x0044 /* MAC address 0 31:0 */ #define GMACMAH(i) ((i)*8+0x40) /* supplimental MAC addr 1 - 15 */ #define GMACMAL(i) ((i)*8+0x44) +#define GMACMDSR 0x00d8 /* GMII/RGMII/MII command/status */ #define GMACMHT0 0x0500 /* multicast hash table 0 - 7 */ #define GMACMHT(i) ((i)*4+0x500) #define GMACVHT 0x0588 /* VLAN tag hash */ #define GMACAMAH(i) ((i)*8+0x800) /* supplimental MAC addr 16-127 */ #define GMACAMAL(i) ((i)*8+0x804) +#define GMACEVCNT(i) ((i)*4+0x114) /* event counter 0x114~284 */ #define GMACBMR 0x1000 /* DMA bus mode control * 244PBL @@ -185,15 +187,17 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 * 1rxtx ratio 21 * 0rxtx ratio 11 * 13:8 PBL possible DMA burst len - * 0 reset op. self clear + * 0reset op. self clear */ #define _BMR 0x00412080 /* XXX TBD */ #define _BMR0 0x00020181 /* XXX TBD */ #define BMR_RST (1U<<0) /* reset op. self clear when done */ -#define GMACRDLAR 0x100c /* */ -#define _RDLAR 0x18000 /* XXX TBD */ -#define GMACTDLAR 0x1010 /* */ -#define _TDLAR 0x1c000 /* XXX TBD */ +#define GMACTDS 0x1004 /* write any to resume tdes */ +#define GMACRDS 0x1008 /* write any to resume rdes */ +#define GMACRDLAR 0x100c /* rdes base address 32bit paddr */ +#define _RDLAR 0x18000 /* XXX TBD system SRAM with CC ? */ +#define GMACTDLAR 0x1010 /* tdes base address 32bit paddr */ +#define _TDLAR 0x1c000 /* XXX TBD system SRAM with CC ? */ #define GMACOMR 0x1018 /* DMA operation */ #define OMR_TXE (1U<<13) /* start Tx DMA engine, 0 to stop */ #define OMR_RXE (1U<<1) /* start Rx DMA engine, 0 to stop */ @@ -1203,7 +1207,7 @@ scx_start(struct ifnet *ifp) BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE); /* Tell DMA start transmit */ - /* CSR_WRITE(sc, MDTSC, 1); */ + /* CSR_WRITE(sc, GMACTDS, 1); */ txs->txs_mbuf = m0; txs->txs_firstdesc = sc->sc_txnext;
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Tue Mar 24 13:07:46 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_scx.c Log Message: add more registers supposed to exist To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/sociox/if_scx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_scx.c diff -u src/sys/arch/arm/sociox/if_scx.c:1.10 src/sys/arch/arm/sociox/if_scx.c:1.11 --- src/sys/arch/arm/sociox/if_scx.c:1.10 Tue Mar 24 11:26:21 2020 +++ src/sys/arch/arm/sociox/if_scx.c Tue Mar 24 13:07:46 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_scx.c,v 1.10 2020/03/24 11:26:21 nisimura Exp $ */ +/* $NetBSD: if_scx.c,v 1.11 2020/03/24 13:07:46 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -56,7 +56,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.10 2020/03/24 11:26:21 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.11 2020/03/24 13:07:46 nisimura Exp $"); #include #include @@ -170,17 +170,20 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define GMACMAH(i) ((i)*8+0x40) /* supplimental MAC addr 1 - 15 */ #define GMACMAL(i) ((i)*8+0x44) #define GMACMHT0 0x0500 /* multicast hash table 0 - 7 */ -#define GMACMHT(i) ((i)*4+0500) +#define GMACMHT(i) ((i)*4+0x500) +#define GMACVHT 0x0588 /* VLAN tag hash */ +#define GMACAMAH(i) ((i)*8+0x800) /* supplimental MAC addr 16-127 */ +#define GMACAMAL(i) ((i)*8+0x804) #define GMACBMR 0x1000 /* DMA bus mode control * 244PBL * 22:17 RPBL * 16fix burst * 15:14 priority between Rx and Tx - * 3rxtx41 - * 2rxtx31 - * 1rxtx21 - * 0rxtx11 + * 3rxtx ratio 41 + * 2rxtx ratio 31 + * 1rxtx ratio 21 + * 0rxtx ratio 11 * 13:8 PBL possible DMA burst len * 0 reset op. self clear */
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Tue Mar 24 11:40:08 UTC 2020 Modified Files: src/sys/arch/arm/sociox: sni_gpio.c Log Message: try to show 32 GPIO line usage To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sociox/sni_gpio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/sni_gpio.c diff -u src/sys/arch/arm/sociox/sni_gpio.c:1.2 src/sys/arch/arm/sociox/sni_gpio.c:1.3 --- src/sys/arch/arm/sociox/sni_gpio.c:1.2 Thu Mar 19 20:53:53 2020 +++ src/sys/arch/arm/sociox/sni_gpio.c Tue Mar 24 11:40:08 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sni_gpio.c,v 1.2 2020/03/19 20:53:53 nisimura Exp $ */ +/* $NetBSD: sni_gpio.c,v 1.3 2020/03/24 11:40:08 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sni_gpio.c,v 1.2 2020/03/19 20:53:53 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sni_gpio.c,v 1.3 2020/03/24 11:40:08 nisimura Exp $"); #include #include @@ -64,6 +64,7 @@ struct snigpio_softc { bus_space_handle_t sc_ioh; bus_addr_t sc_iob; bus_size_t sc_ios; + void *sc_ih; kmutex_t sc_lock; struct gpio_chipset_tag sc_gpio_gc; gpio_pin_t sc_gpio_pins[32]; @@ -77,7 +78,19 @@ CFATTACH_DECL_NEW(snigpio_fdt, sizeof(st CFATTACH_DECL_NEW(snigpio_acpi, sizeof(struct snigpio_softc), snigpio_acpi_match, snigpio_acpi_attach, NULL, NULL); +/* + * "DevelopmentBox" implementation + *DSW3-PIN1, DSW3-PIN2, DSW3-PIN3,DSW3-PIN4, + *DSW3-PIN5, DSW3-PIN6, DSW3-PIN7,DSW3-PIN8, + *PEC-PD8,PEC-PD9,PEC-PD10, PEC-PD11, + *NC, NC, PCIE1EXTINT, PCIE0EXTINT, + *PHY_P2_2, PHY_P1_2, NC, NC, + *NC, NC, NC, NC, + *NC, NC, PEC-PD26, PEC-PD27, + *PEC-PD28, PEC-PD29, PEC-PD30, PEC-PD31; + */ static void snigpio_attach_i(struct snigpio_softc *); +static int snigpio_intr(void *); static int snigpio_fdt_match(device_t parent, struct cfdata *match, void *aux) @@ -102,8 +115,8 @@ snigpio_fdt_attach(device_t parent, devi bus_space_handle_t ioh; bus_addr_t addr; bus_size_t size; + char intrstr[128]; _Bool disable; - int error; prop_dictionary_get_bool(dict, "disable", ); if (disable) { @@ -111,16 +124,25 @@ snigpio_fdt_attach(device_t parent, devi aprint_normal(": disabled\n"); return; } - error = fdtbus_get_reg(phandle, 0, , ); - if (error) { - aprint_error(": couldn't get registers\n"); - return; - } - error = bus_space_map(faa->faa_bst, addr, size, 0, ); - if (error) { + if (fdtbus_get_reg(phandle, 0, , ) != 0 + || bus_space_map(faa->faa_bst, addr, size, 0, ) != 0) { aprint_error(": unable to map device\n"); return; } + if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) { + aprint_error(": failed to decode interrupt\n"); + goto fail; + } + sc->sc_ih = fdtbus_intr_establish(phandle, + 0, IPL_VM, 0, snigpio_intr, sc); + if (sc->sc_ih == NULL) { + aprint_error_dev(self, "couldn't establish interrupt\n"); + goto fail; + } + + aprint_naive("\n"); + aprint_normal(": GPIO controller\n"); + aprint_normal_dev(self, "interrupting on %s\n", intrstr); sc->sc_dev = self; sc->sc_phandle = phandle; @@ -131,7 +153,13 @@ snigpio_fdt_attach(device_t parent, devi snigpio_attach_i(sc); +/* dig FDT description to show 32 of GPIO line usage */ +/* DIPSW3 1-8 usage remain unclear */ + return; + fail: + bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_ios); + return; } static int @@ -163,22 +191,24 @@ snigpio_acpi_attach(device_t parent, dev , _resource_parse_ops_default); if (ACPI_FAILURE(rv)) return; - mem = acpi_res_mem(, 0); irq = acpi_res_irq(, 0); - if (mem == NULL || irq == NULL) { + if (mem == NULL || irq == NULL || mem->ar_length == 0) { aprint_error(": incomplete resources\n"); return; } - if (mem->ar_length == 0) { - aprint_error(": zero length memory resource\n"); - return; - } if (bus_space_map(aa->aa_memt, mem->ar_base, mem->ar_length, 0, )) { aprint_error(": couldn't map registers\n"); return; } + sc->sc_ih = acpi_intr_establish(self, + (uint64_t)(uintptr_t)aa->aa_node->ad_handle, + IPL_VM, false, snigpio_intr, sc, device_xname(self)); + if (sc->sc_ih == NULL) { + aprint_error_dev(self, "couldn't establish interrupt\n"); + goto fail; + } sc->sc_dev = self; sc->sc_iot = aa->aa_memt; @@ -186,31 +216,46 @@ snigpio_acpi_attach(device_t parent, dev sc->sc_ios = mem->ar_length; snigpio_attach_i(sc); + +/* dig _DSD property to show 32 of GPIO line usage */ +/* DIPSW3 1-8 usage remain unclear */ + + acpi_resource_cleanup(); + return; + fail: + acpi_resource_cleanup(); + bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_ios); + return; } static void snigpio_attach_i(struct snigpio_softc *sc) { + struct
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Tue Mar 24 11:26:21 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_scx.c Log Message: fix FDT 2nd addr to map EEPROM store. mention ACPI _DSD contains FDT equiv parameters. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/sociox/if_scx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_scx.c diff -u src/sys/arch/arm/sociox/if_scx.c:1.9 src/sys/arch/arm/sociox/if_scx.c:1.10 --- src/sys/arch/arm/sociox/if_scx.c:1.9 Tue Mar 24 10:47:03 2020 +++ src/sys/arch/arm/sociox/if_scx.c Tue Mar 24 11:26:21 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_scx.c,v 1.9 2020/03/24 10:47:03 nisimura Exp $ */ +/* $NetBSD: if_scx.c,v 1.10 2020/03/24 11:26:21 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -56,7 +56,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.9 2020/03/24 10:47:03 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.10 2020/03/24 11:26:21 nisimura Exp $"); #include #include @@ -438,7 +438,7 @@ scx_fdt_attach(device_t parent, device_t goto fail; } if (fdtbus_get_reg(phandle, 1, addr+1, size+1) != 0 - || bus_space_map(faa->faa_bst, addr[0], size[1], 0, ) != 0) { + || bus_space_map(faa->faa_bst, addr[1], size[1], 0, ) != 0) { aprint_error(": unable to map device eeprom\n"); goto fail; } @@ -504,6 +504,7 @@ scx_acpi_attach(device_t parent, device_ , _resource_parse_ops_default); if (ACPI_FAILURE(rv)) return; +acpi_resource_print(self, ); mem = acpi_res_mem(, 0); irq = acpi_res_irq(, 0); if (mem == NULL || irq == NULL || mem->ar_length == 0) { @@ -541,6 +542,8 @@ scx_acpi_attach(device_t parent, device_ sc->sc_eesh = eebsh; sc->sc_dmat = aa->aa_dmat64; +/* dig _DSD to see parameters. safe to assume RGMII/spd1000 though */ + scx_attach_i(sc); acpi_resource_cleanup();
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Tue Mar 24 10:47:03 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_scx.c Log Message: try to be consistent for the number of address match filter. tentative util the reality. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/sociox/if_scx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_scx.c diff -u src/sys/arch/arm/sociox/if_scx.c:1.8 src/sys/arch/arm/sociox/if_scx.c:1.9 --- src/sys/arch/arm/sociox/if_scx.c:1.8 Tue Mar 24 10:31:52 2020 +++ src/sys/arch/arm/sociox/if_scx.c Tue Mar 24 10:47:03 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_scx.c,v 1.8 2020/03/24 10:31:52 nisimura Exp $ */ +/* $NetBSD: if_scx.c,v 1.9 2020/03/24 10:47:03 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -40,12 +40,13 @@ * to designify ring number from which to arrive or to which go. * - memory mapped EEPROM to hold MAC address. The rest of the area is * occupied by a set of ucode for two DMA engines and one packet engine. - * - The size of frame address filter is unknown. Might be 32 + * - The size of frame address filter is unknown. Might be 16 or even 128. * - The first slot is my own station address. Always enabled to perform * to identify oneself. - * - 1~31 are for supplimental MAC addresses. Independently enabled - * for use. Good to catch multicast. Byte-wise selective match available. - * Use to catch { 0x01, 0x00, 0x00 } and/or { 0x33, 0x33 }. + * - 1~16 are for supplimental MAC addresses. Independently enabled for + * use. Good to catch multicast. Byte-wise selective match available. + * Use the mask to catch { 0x01, 0x00, 0x00 } and/or { 0x33, 0x33 }. + * - 16~128 might be exact match without byte-mask. * - The size of multicast hash filter store is unknown. Might be 256 bit. * - Socionext/Linaro "NetSec" code makes many cut shorts. Some constants * are left unexplained. The values should be handled via external @@ -55,7 +56,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.8 2020/03/24 10:31:52 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.9 2020/03/24 10:47:03 nisimura Exp $"); #include #include @@ -924,7 +925,7 @@ scx_set_rcvfilt(struct scx_softc *sc) } printf("[%d] %s\n", i, ether_sprintf(enm->enm_addrlo)); if (i < 16) { - /* use 31 entry perfect match filter */ + /* use 15 entry perfect match filter */ uint32_t addr; uint8_t *ep = enm->enm_addrlo; addr = (ep[3] << 24) | (ep[2] << 16)
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Tue Mar 24 10:31:52 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_scx.c Log Message: small knit about multicast hash table handling. use sc_100mii as bool To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sociox/if_scx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_scx.c diff -u src/sys/arch/arm/sociox/if_scx.c:1.7 src/sys/arch/arm/sociox/if_scx.c:1.8 --- src/sys/arch/arm/sociox/if_scx.c:1.7 Tue Mar 24 02:31:59 2020 +++ src/sys/arch/arm/sociox/if_scx.c Tue Mar 24 10:31:52 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_scx.c,v 1.7 2020/03/24 02:31:59 nisimura Exp $ */ +/* $NetBSD: if_scx.c,v 1.8 2020/03/24 10:31:52 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -55,7 +55,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.7 2020/03/24 02:31:59 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.8 2020/03/24 10:31:52 nisimura Exp $"); #include #include @@ -162,13 +162,14 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define GMACFCR 0x0018 /* 802.3x flowcontrol */ #define FCR_RFE (1U<<2) /* accept PAUSE to throttle Tx */ #define FCR_TFE (1U<<1) /* generate PAUSE to moderate Rx lvl */ -#define GMACIMPL 0x0020 /* implementation number . */ #define GMACVTAG 0x001c /* VLAN tag control */ +#define GMACIMPL 0x0020 /* implementation number . */ #define GMACMAH0 0x0040 /* MAC address 0 47:32 */ #define GMACMAL0 0x0044 /* MAC address 0 31:0 */ #define GMACMAH(i) ((i)*8+0x40) /* supplimental MAC addr 1 - 15 */ #define GMACMAL(i) ((i)*8+0x44) -#define GMACMHT0 0x0500 /* multicast hash table 0 - 8*/ +#define GMACMHT0 0x0500 /* multicast hash table 0 - 7 */ +#define GMACMHT(i) ((i)*4+0500) #define GMACBMR 0x1000 /* DMA bus mode control * 244PBL @@ -300,7 +301,7 @@ struct scx_softc { uint32_t sc_mdclk; /* GAR 5:2 clock selection */ uint32_t sc_t0coso; /* T0_CSUM | T0_SGOL to run */ int sc_ucodeloaded; /* ucode for H2M/M2H/PKT */ - int sc_100mii; /* 1<<15 RMII/MII, 0 for RGMII */ + int sc_100mii; /* 1 for RMII/MII, 0 for RGMII */ int sc_phandle; /* fdt phandle */ bus_dmamap_t sc_cddmamap; /* control data DMA map */ @@ -459,7 +460,7 @@ scx_fdt_attach(device_t parent, device_t sc->sc_eesz = size[1]; sc->sc_dmat = faa->faa_dmat; sc->sc_phandle = phandle; - sc->sc_100mii = (strcmp(phy_mode, "rgmii") != 0) ? MCR_USEMII : 0; + sc->sc_100mii = (strcmp(phy_mode, "rgmii") != 0); scx_attach_i(sc); return; @@ -945,13 +946,13 @@ printf("[%d] %s\n", i, ether_sprintf(enm if (crc) csr |= AFR_MHTE; - for (i = 0; i < 8; i++) - CSR_WRITE(sc, GMACMHT0 + i * 4, mchash[i]); + for (i = 0; i < __arraycount(mchash); i++) + CSR_WRITE(sc, GMACMHT(i), mchash[i]); CSR_WRITE(sc, GMACAFR, csr); return; update: - /* With PM or AM, MHTE/MHTL/MHTH are never consulted. really? */ + /* With PM or AM, MHTE/MHT0-7 are never consulted. really? */ if (ifp->if_flags & IFF_PROMISC) csr |= AFR_PM; /* run promisc. mode */ else
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Tue Mar 24 03:08:02 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_ave.c Log Message: correct inverted logic to determine RMII/MII To generate a diff of this commit: cvs rdiff -u -r1.14 -r1.15 src/sys/arch/arm/sociox/if_ave.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_ave.c diff -u src/sys/arch/arm/sociox/if_ave.c:1.14 src/sys/arch/arm/sociox/if_ave.c:1.15 --- src/sys/arch/arm/sociox/if_ave.c:1.14 Mon Mar 23 10:26:07 2020 +++ src/sys/arch/arm/sociox/if_ave.c Tue Mar 24 03:08:02 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ave.c,v 1.14 2020/03/23 10:26:07 nisimura Exp $ */ +/* $NetBSD: if_ave.c,v 1.15 2020/03/24 03:08:02 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.14 2020/03/23 10:26:07 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.15 2020/03/24 03:08:02 nisimura Exp $"); #include #include @@ -396,7 +396,7 @@ ave_fdt_attach(device_t parent, device_t sc->sc_model, hwver >> 8, hwver & 0xff, phy_mode); aprint_normal_dev(self, "interrupt on %s\n", intrstr); - sc->sc_100mii = (strcmp(phy_mode, "rgmii") == 0) ? CFG_MII : 0; + sc->sc_100mii = (strcmp(phy_mode, "rgmii") != 0); sc->sc_desops = (sc->sc_model == 64) ? : CSR_WRITE(sc, AVEGR, GR_GRST | GR_PHYRST); @@ -522,7 +522,7 @@ ave_reset(struct ave_softc *sc) CSR_WRITE(sc, AVERXC, 0); /* stop Rx first */ CSR_WRITE(sc, AVEDESCC, 0); /* stop Tx/Rx descriptor engine */ - if (sc->sc_100mii & CFG_MII) { + if (sc->sc_100mii) { csr = CSR_READ(sc, AVERMIIC); CSR_WRITE(sc, AVERMIIC, csr &~ RMIIC_RST); DELAY(10);
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Tue Mar 24 02:31:59 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_scx.c Log Message: add some more findings about SC2A11 GbE. do some code steamline practice. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sociox/if_scx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_scx.c diff -u src/sys/arch/arm/sociox/if_scx.c:1.6 src/sys/arch/arm/sociox/if_scx.c:1.7 --- src/sys/arch/arm/sociox/if_scx.c:1.6 Mon Mar 23 07:42:00 2020 +++ src/sys/arch/arm/sociox/if_scx.c Tue Mar 24 02:31:59 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_scx.c,v 1.6 2020/03/23 07:42:00 nisimura Exp $ */ +/* $NetBSD: if_scx.c,v 1.7 2020/03/24 02:31:59 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -47,10 +47,15 @@ * for use. Good to catch multicast. Byte-wise selective match available. * Use to catch { 0x01, 0x00, 0x00 } and/or { 0x33, 0x33 }. * - The size of multicast hash filter store is unknown. Might be 256 bit. + * - Socionext/Linaro "NetSec" code makes many cut shorts. Some constants + * are left unexplained. The values should be handled via external + * controls like FDT descriptions. Fortunately, Intel/Altera CycloneV PDFs + * describe every detail of "such the instance of" DW EMAC IP and + * most of them are likely applicable to SC2A11 GbE. */ #include -__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.6 2020/03/23 07:42:00 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.7 2020/03/24 02:31:59 nisimura Exp $"); #include #include @@ -188,7 +193,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define OMR_TXE (1U<<13) /* start Tx DMA engine, 0 to stop */ #define OMR_RXE (1U<<1) /* start Rx DMA engine, 0 to stop */ -static int get_garclk(uint32_t); +static int get_mdioclk(uint32_t); /* descriptor format definition */ struct tdes { @@ -292,7 +297,7 @@ struct scx_softc { void *sc_ih; /* interrupt cookie */ int sc_phy_id; /* PHY address */ int sc_flowflags; /* 802.3x PAUSE flow control */ - uint32_t sc_gar; /* GAR 5:2 clock selection */ + uint32_t sc_mdclk; /* GAR 5:2 clock selection */ uint32_t sc_t0coso; /* T0_CSUM | T0_SGOL to run */ int sc_ucodeloaded; /* ucode for H2M/M2H/PKT */ int sc_100mii; /* 1<<15 RMII/MII, 0 for RGMII */ @@ -577,7 +582,7 @@ scx_attach_i(struct scx_softc *sc) phyfreq = 0; sc->sc_phy_id = MII_PHY_ANY; - sc->sc_gar = get_garclk(phyfreq) << GAR_CTL; /* 5:2 gar control */ + sc->sc_mdclk = get_mdioclk(phyfreq); /* 5:2 clk control */ sc->sc_flowflags = 0; @@ -1044,11 +1049,11 @@ static int mii_readreg(device_t self, int phy, int reg, uint16_t *val) { struct scx_softc *sc = device_private(self); - uint32_t gar; + uint32_t miia; int error; - gar = (phy << GAR_PHY) | (reg << GAR_REG) | sc->sc_gar; - mac_write(sc, GMACGAR, gar | GAR_BUSY); + miia = (phy << GAR_PHY) | (reg << GAR_REG) | sc->sc_mdclk; + mac_write(sc, GMACGAR, miia | GAR_BUSY); error = spin_waitfor(sc, GMACGAR, GAR_BUSY); if (error) return error; @@ -1060,13 +1065,13 @@ static int mii_writereg(device_t self, int phy, int reg, uint16_t val) { struct scx_softc *sc = device_private(self); - uint32_t gar; + uint32_t miia; uint16_t dummy; int error; - gar = (phy << GAR_PHY) | (reg << GAR_REG) | sc->sc_gar; + miia = (phy << GAR_PHY) | (reg << GAR_REG) | sc->sc_mdclk; mac_write(sc, GMACGDR, val); - mac_write(sc, GMACGAR, gar | GAR_IOWR | GAR_BUSY); + mac_write(sc, GMACGAR, miia | GAR_IOWR | GAR_BUSY); error = spin_waitfor(sc, GMACGAR, GAR_BUSY); if (error) return error; @@ -1390,12 +1395,12 @@ mac_write(struct scx_softc *sc, int reg, } static int -get_garclk(uint32_t freq) +get_mdioclk(uint32_t freq) { const struct { uint16_t freq, bit; /* GAR 5:2 MDIO frequency selection */ - } garclk[] = { + } mdioclk[] = { { 35, 2 }, /* 25-35 MHz */ { 60, 3 }, /* 35-60 MHz */ { 100, 0 }, /* 60-100 MHz */ @@ -1406,13 +1411,13 @@ get_garclk(uint32_t freq) int i; /* convert MDIO clk to a divisor value */ - if (freq < garclk[0].freq) - return garclk[0].bit; - for (i = 1; i < __arraycount(garclk); i++) { - if (freq < garclk[i].freq) - return garclk[i-1].bit; + if (freq < mdioclk[0].freq) + return mdioclk[0].bit; + for (i = 1; i < __arraycount(mdioclk); i++) { + if (freq < mdioclk[i].freq) + return mdioclk[i-1].bit; } - return garclk[__arraycount(garclk) - 1].bit; + return mdioclk[__arraycount(mdioclk) - 1].bit << GAR_CTL; } static void
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Mon Mar 23 10:26:07 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_ave.c Log Message: adapt dual descriptor design both for AVE64 and AVE32 To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/sys/arch/arm/sociox/if_ave.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_ave.c diff -u src/sys/arch/arm/sociox/if_ave.c:1.13 src/sys/arch/arm/sociox/if_ave.c:1.14 --- src/sys/arch/arm/sociox/if_ave.c:1.13 Mon Mar 23 07:42:00 2020 +++ src/sys/arch/arm/sociox/if_ave.c Mon Mar 23 10:26:07 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ave.c,v 1.13 2020/03/23 07:42:00 nisimura Exp $ */ +/* $NetBSD: if_ave.c,v 1.14 2020/03/23 10:26:07 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.13 2020/03/23 07:42:00 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.14 2020/03/23 10:26:07 nisimura Exp $"); #include #include @@ -182,29 +182,6 @@ struct rdes32 { uint32_t r0, r1; }; #define MD_NRXDESC_MASK (MD_NRXDESC - 1) #define MD_NEXTRX(x) (((x) + 1) & MD_NRXDESC_MASK) -#define AVE_INIT_RXDESC(sc, x) \ -do { \ - struct ave_rxsoft *__rxs = &(sc)->sc_rxsoft[(x)]; \ - struct rdes *__rxd = &(sc)->sc_rxdescs[(x)]; \ - struct mbuf *__m = __rxs->rxs_mbuf;\ - bus_addr_t __paddr =__rxs->rxs_dmamap->dm_segs[0].ds_addr; \ - __m->m_data = __m->m_ext.ext_buf;\ - __rxd->r2 = htole32(BUS_ADDR_HI32(__paddr)); \ - __rxd->r1 = htole32(BUS_ADDR_LO32(__paddr)); \ - __rxd->r0 = R0_OWN | R0_FL_MASK;\ -} while (/*CONSTCOND*/0) - -#define AVE32_INIT_RXDESC(sc, x) \ -do { \ - struct ave_rxsoft *__rxs = &(sc)->sc_rxsoft[(x)]; \ - struct rdes32 *__rxd = &(sc)->sc_rxd32[(x)]; \ - struct mbuf *__m = __rxs->rxs_mbuf;\ - bus_addr_t __paddr =__rxs->rxs_dmamap->dm_segs[0].ds_addr; \ - __m->m_data = __m->m_ext.ext_buf;\ - __rxd->r1 = htole32(__paddr); \ - __rxd->r0 = R0_OWN | R0_FL_MASK;\ -} while (/*CONSTCOND*/0) - struct ave_txsoft { struct mbuf *txs_mbuf; /* head of our mbuf chain */ bus_dmamap_t txs_dmamap; /* our DMA map */ @@ -218,6 +195,8 @@ struct ave_rxsoft { bus_dmamap_t rxs_dmamap; /* our DMA map */ }; +struct desops; + struct ave_softc { device_t sc_dev; /* generic device information */ bus_space_tag_t sc_st; /* bus space tag */ @@ -241,6 +220,7 @@ struct ave_softc { struct rdes *sc_rxdescs; /* PTR to rdes [NRXDESC] store */ struct tdes32 *sc_txd32; struct rdes32 *sc_rxd32; + struct desops *sc_desops; /* descriptor management */ struct ave_txsoft sc_txsoft[MD_TXQUEUELEN]; struct ave_rxsoft sc_rxsoft[MD_NRXDESC]; @@ -286,8 +266,62 @@ static int add_rxbuf(struct ave_softc *, #define CSR_WRITE(sc, off, val) \ bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (off), (val)) +struct desops { + void (*make_tdes)(void *, int, int, int); + void (*mark_txfs)(void *, int); + void (*mark_txls)(void *, int); + void (*mark_txic)(void *, int); + int (*read_tdes0)(void *, int); + int (*read_rdes0)(void *, int); + int (*read_rlen)(void *, int); + void (*init_rdes)(void *, int); +}; +#define MAKE_TDES(sc,x,s,o) (*(sc)->sc_desops->make_tdes)((sc),(x),(s),(o)) +#define MARK_TXFS(sc,x) (*(sc)->sc_desops->mark_txfs)((sc),(x)) +#define MARK_TXLS(sc,x) (*(sc)->sc_desops->mark_txls)((sc),(x)) +#define MARK_TXIC(sc,x) (*(sc)->sc_desops->mark_txic)((sc),(x)) +#define READ_TDES0(sc,x) (*(sc)->sc_desops->read_tdes0)((sc),(x)) +#define READ_RDES0(sc,x) (*(sc)->sc_desops->read_rdes0)((sc),(x)) +#define INIT_RDES(sc,x) (*(sc)->sc_desops->init_rdes)((sc),(x)) +/* received frame length is stored in RDES0 10:0 */ + +static void make_tdes(void *, int, int, int); +static void mark_txfs(void *, int); +static void mark_txls(void *, int); +static void mark_txic(void *, int); +static int read_tdes0(void *, int); +static int read_rdes0(void *, int); +static void init_rdes(void *, int); +struct desops ave64ops = { + make_tdes, + mark_txfs, + mark_txls, + mark_txic, + read_tdes0, + read_rdes0, + NULL, + init_rdes, +}; +static void omake_tdes(void *, int, int, int); +static void omark_txfs(void *, int); +static void omark_txls(void *, int); +static void omark_txic(void *, int); +static int oread_tdes0(void *, int); +static int oread_rdes0(void *, int); +static void oinit_rdes(void *, int); +struct desops ave32ops = { + omake_tdes, + omark_txfs, + omark_txls, + omark_txic, + oread_tdes0, + oread_rdes0, + NULL, + oinit_rdes, +}; + static const struct of_compat_data compat_data[] = { - { "socionext,unifier-ld20-ave4", 64 }, /* XXX only this for now */ + { "socionext,unifier-ld20-ave4", 64 }, { "socionext,unifier-pro4-ave4", 32 }, { "socionext,unifier-pxs2-ave4", 32 }, { "socionext,unifier-ld11-ave4", 32 }, @@ -357,12 +391,13 @@ ave_fdt_attach(device_t parent, device_t
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Mon Mar 23 07:42:00 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_ave.c if_scx.c Log Message: replace some macro names for descriptor management To generate a diff of this commit: cvs rdiff -u -r1.12 -r1.13 src/sys/arch/arm/sociox/if_ave.c cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sociox/if_scx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_ave.c diff -u src/sys/arch/arm/sociox/if_ave.c:1.12 src/sys/arch/arm/sociox/if_ave.c:1.13 --- src/sys/arch/arm/sociox/if_ave.c:1.12 Mon Mar 23 05:24:28 2020 +++ src/sys/arch/arm/sociox/if_ave.c Mon Mar 23 07:42:00 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ave.c,v 1.12 2020/03/23 05:24:28 nisimura Exp $ */ +/* $NetBSD: if_ave.c,v 1.13 2020/03/23 07:42:00 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.12 2020/03/23 05:24:28 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.13 2020/03/23 07:42:00 nisimura Exp $"); #include #include @@ -169,18 +169,18 @@ struct rdes32 { uint32_t r0, r1; }; /* R1 frame address 31:0 */ /* R2 frame address 63:32 */ -#define AVE_NTXSEGS 16 -#define AVE_TXQUEUELEN (AVE_NTXDESC / AVE_NTXSEGS) -#define AVE_TXQUEUELEN_MASK (AVE_TXQUEUELEN - 1) -#define AVE_TXQUEUE_GC (AVE_TXQUEUELEN / 4) -#define AVE_NTXDESC 256 /* HW limit */ -#define AVE_NTXDESC_MASK (AVE_NTXDESC - 1) -#define AVE_NEXTTX(x) (((x) + 1) & AVE_NTXDESC_MASK) -#define AVE_NEXTTXS(x) (((x) + 1) & AVE_TXQUEUELEN_MASK) - -#define AVE_NRXDESC 256 -#define AVE_NRXDESC_MASK (AVE_NRXDESC - 1) -#define AVE_NEXTRX(x) (((x) + 1) & AVE_NRXDESC_MASK) +#define MD_NTXSEGS 16 /* fixed */ +#define MD_TXQUEUELEN (MD_NTXDESC / MD_NTXSEGS) +#define MD_TXQUEUELEN_MASK (MD_TXQUEUELEN - 1) +#define MD_TXQUEUE_GC (MD_TXQUEUELEN / 4) +#define MD_NTXDESC 256 /* this is max HW limit */ +#define MD_NTXDESC_MASK (MD_NTXDESC - 1) +#define MD_NEXTTX(x) (((x) + 1) & MD_NTXDESC_MASK) +#define MD_NEXTTXS(x) (((x) + 1) & MD_TXQUEUELEN_MASK) + +#define MD_NRXDESC 256 /* tunable */ +#define MD_NRXDESC_MASK (MD_NRXDESC - 1) +#define MD_NEXTRX(x) (((x) + 1) & MD_NRXDESC_MASK) #define AVE_INIT_RXDESC(sc, x) \ do { \ @@ -242,8 +242,8 @@ struct ave_softc { struct tdes32 *sc_txd32; struct rdes32 *sc_rxd32; - struct ave_txsoft sc_txsoft[AVE_TXQUEUELEN]; - struct ave_rxsoft sc_rxsoft[AVE_NRXDESC]; + struct ave_txsoft sc_txsoft[MD_TXQUEUELEN]; + struct ave_rxsoft sc_rxsoft[MD_NRXDESC]; int sc_txfree; /* number of free Tx descriptors */ int sc_txnext; /* next ready Tx descriptor */ int sc_txsfree; /* number of free Tx jobs */ @@ -429,9 +429,9 @@ ave_fdt_attach(device_t parent, device_t * so no need to build Tx/Rx descriptor control_data. * go straight to make dmamap to hold Tx segments and Rx frames. */ - for (i = 0; i < AVE_TXQUEUELEN; i++) { + for (i = 0; i < MD_TXQUEUELEN; i++) { if ((error = bus_dmamap_create(sc->sc_dmat, MCLBYTES, - AVE_NTXSEGS, MCLBYTES, 0, 0, + MD_NTXSEGS, MCLBYTES, 0, 0, >sc_txsoft[i].txs_dmamap)) != 0) { aprint_error_dev(self, "unable to create tx DMA map %d, error = %d\n", @@ -439,7 +439,7 @@ ave_fdt_attach(device_t parent, device_t goto fail_4; } } - for (i = 0; i < AVE_NRXDESC; i++) { + for (i = 0; i < MD_NRXDESC; i++) { if ((error = bus_dmamap_create(sc->sc_dmat, MCLBYTES, 1, MCLBYTES, 0, 0, >sc_rxsoft[i].rxs_dmamap)) != 0) { aprint_error_dev(self, @@ -462,13 +462,13 @@ ave_fdt_attach(device_t parent, device_t return; fail_5: - for (i = 0; i < AVE_NRXDESC; i++) { + for (i = 0; i < MD_NRXDESC; i++) { if (sc->sc_rxsoft[i].rxs_dmamap != NULL) bus_dmamap_destroy(sc->sc_dmat, sc->sc_rxsoft[i].rxs_dmamap); } fail_4: - for (i = 0; i < AVE_TXQUEUELEN; i++) { + for (i = 0; i < MD_TXQUEUELEN; i++) { if (sc->sc_txsoft[i].txs_dmamap != NULL) bus_dmamap_destroy(sc->sc_dmat, sc->sc_txsoft[i].txs_dmamap); @@ -519,8 +519,8 @@ ave_init(struct ifnet *ifp) CSR_WRITE(sc, AVECFG, CFG_FLE | sc->sc_100mii); /* set Tx/Rx descriptor ring base addr offset and total size */ - CSR_WRITE(sc, AVETXDES, 0U|(sizeof(struct tdes)*AVE_NTXDESC) << 16); - CSR_WRITE(sc, AVERXDES0, 0U|(sizeof(struct rdes)*AVE_NRXDESC) << 16); + CSR_WRITE(sc, AVETXDES, 0U|(sizeof(struct tdes)*MD_NTXDESC) << 16); + CSR_WRITE(sc, AVERXDES0, 0U|(sizeof(struct rdes)*MD_NRXDESC) << 16); /* set ptr to Tx/Rx descriptor store */ sc->sc_txdescs = (void *)((uintptr_t)sc->sc_sh + AVETDB); @@ -529,12 +529,12 @@ ave_init(struct ifnet *ifp) sc->sc_rxd32 = (void *)((uintptr_t)sc->sc_sh + AVE32RDB); /* build sane Tx and load Rx descriptors with mbuf */ - for (i = 0; i < AVE_NTXDESC; i++) { + for (i = 0; i < MD_NTXDESC; i++) { struct tdes *tdes = >sc_txdescs[i]; tdes->t2
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Mon Mar 23 05:49:57 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_scx.c Log Message: do better work in ifmedia_upd. fix ucode injection. To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/sociox/if_scx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_scx.c diff -u src/sys/arch/arm/sociox/if_scx.c:1.4 src/sys/arch/arm/sociox/if_scx.c:1.5 --- src/sys/arch/arm/sociox/if_scx.c:1.4 Mon Mar 23 05:27:41 2020 +++ src/sys/arch/arm/sociox/if_scx.c Mon Mar 23 05:49:57 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_scx.c,v 1.4 2020/03/23 05:27:41 nisimura Exp $ */ +/* $NetBSD: if_scx.c,v 1.5 2020/03/23 05:49:57 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -50,7 +50,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.4 2020/03/23 05:27:41 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.5 2020/03/23 05:49:57 nisimura Exp $"); #include #include @@ -127,7 +127,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define MCR_SPD100 (1U<<14) /* force speed 100 */ #define MCR_USEFDX (1U<<11) /* force full duplex */ #define MCR_IPCKEN (1U<<10) /* handle checksum */ -#define MCR_ACS (1U<<7) /* auto pad CRC strip */ +#define MCR_ACS (1U<<7) /* auto pad strip CRC */ #define MCR_TXE (1U<<3) /* start Tx DMA engine */ #define MCR_RXE (1U<<2) /* start Rx DMA engine */ #define _MCR_FDX 0x280c /* XXX TBD */ @@ -967,19 +967,21 @@ scx_ifmedia_upd(struct ifnet *ifp) ; /* advertise flow control pause */ ; /* adv. 100FDX,100HDX,10FDX,10HDX */ } else { -#if 1 +#if 1 /* XXX not sure to belong here XXX */ uint32_t mcr = mac_read(sc, GMACMCR); if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_1000_T) mcr &= ~MCR_USEMII; /* RGMII+SPD1000 */ else { - mcr |= MCR_USEMII; /* RMII/MII */ - if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_100_TX) + if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_100_TX + && sc->sc_100mii) mcr |= MCR_SPD100; + mcr |= MCR_USEMII; } if (ifm->ifm_cur->ifm_media & IFM_FDX) mcr |= MCR_USEFDX; mcr |= MCR_CST | MCR_JE; - mcr |= MCR_IBN; + if (sc->sc_100mii == 0) + mcr |= MCR_IBN; mac_write(sc, GMACMCR, mcr); #endif } @@ -1365,7 +1367,7 @@ spin_waitfor(struct scx_softc *sc, int r do { DELAY(10); val = CSR_READ(sc, reg); - } while (--loop > 0 && (val & exist) != 0); + } while (--loop > 0 && (val & exist)); return (loop > 0) ? 0 : ETIMEDOUT; } @@ -1451,18 +1453,15 @@ injectucode(struct scx_softc *sc, int po bus_space_handle_t bsh; bus_size_t off; uint32_t ucode; - int i; if (!bus_space_map(sc->sc_st, addr, size, 0, ) != 0) { aprint_error_dev(sc->sc_dev, "eeprom map failure for ucode port 0x%x\n", port); return; } - off = 0; - for (i = 0; i < size; i++) { + for (off = 0; off < size; off += 4) { ucode = bus_space_read_4(sc->sc_st, bsh, off); CSR_WRITE(sc, port, ucode); - off += 4; } bus_space_unmap(sc->sc_st, bsh, size); }
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Mon Mar 23 05:27:42 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_scx.c Log Message: try to catch RMII/MII phy condition. fix divisor cal. nuke &= 03 error To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sociox/if_scx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_scx.c diff -u src/sys/arch/arm/sociox/if_scx.c:1.3 src/sys/arch/arm/sociox/if_scx.c:1.4 --- src/sys/arch/arm/sociox/if_scx.c:1.3 Mon Mar 23 04:34:16 2020 +++ src/sys/arch/arm/sociox/if_scx.c Mon Mar 23 05:27:41 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_scx.c,v 1.3 2020/03/23 04:34:16 nisimura Exp $ */ +/* $NetBSD: if_scx.c,v 1.4 2020/03/23 05:27:41 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -50,7 +50,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.3 2020/03/23 04:34:16 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.4 2020/03/23 05:27:41 nisimura Exp $"); #include #include @@ -188,17 +188,6 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define OMR_TXE (1U<<13) /* start Tx DMA engine, 0 to stop */ #define OMR_RXE (1U<<1) /* start Rx DMA engine, 0 to stop */ -const struct { - uint16_t freq, bit; /* GAR 5:2 MDIO frequency selection */ -} garclk[] = { - { 35, 2 }, /* 25-35 MHz */ - { 60, 3 }, /* 35-60 MHz */ - { 100, 0 }, /* 60-100 MHz */ - { 150, 1 }, /* 100-150 MHz */ - { 250, 4 }, /* 150-250 MHz */ - { 300, 5 }, /* 250-300 MHz */ - { 0 }, -}; static int get_garclk(uint32_t); /* descriptor format definition */ @@ -306,6 +295,7 @@ struct scx_softc { uint32_t sc_gar; /* GAR 5:2 clock selection */ uint32_t sc_t0coso; /* T0_CSUM | T0_SGOL to run */ int sc_ucodeloaded; /* ucode for H2M/M2H/PKT */ + int sc_100mii; /* 1<<15 RMII/MII, 0 for RGMII */ int sc_phandle; /* fdt phandle */ bus_dmamap_t sc_cddmamap; /* control data DMA map */ @@ -423,6 +413,7 @@ scx_fdt_attach(device_t parent, device_t bus_addr_t addr[2]; bus_size_t size[2]; char intrstr[128]; + const char *phy_mode; if (fdtbus_get_reg(phandle, 0, addr+0, size+0) != 0 || bus_space_map(faa->faa_bst, addr[0], size[0], 0, ) != 0) { @@ -445,6 +436,12 @@ scx_fdt_attach(device_t parent, device_t goto fail; } + phy_mode = fdtbus_get_string(phandle, "phy-mode"); + if (phy_mode == NULL) { + aprint_error(": missing 'phy-mode' property\n"); + phy_mode = "rgmii"; + } + aprint_naive("\n"); aprint_normal(": Gigabit Ethernet Controller\n"); aprint_normal_dev(self, "interrupt on %s\n", intrstr); @@ -457,6 +454,7 @@ scx_fdt_attach(device_t parent, device_t sc->sc_eesz = size[1]; sc->sc_dmat = faa->faa_dmat; sc->sc_phandle = phandle; + sc->sc_100mii = (strcmp(phy_mode, "rgmii") != 0) ? MCR_USEMII : 0; scx_attach_i(sc); return; @@ -1392,13 +1390,27 @@ mac_write(struct scx_softc *sc, int reg, static int get_garclk(uint32_t freq) { + + const struct { + uint16_t freq, bit; /* GAR 5:2 MDIO frequency selection */ + } garclk[] = { + { 35, 2 }, /* 25-35 MHz */ + { 60, 3 }, /* 35-60 MHz */ + { 100, 0 }, /* 60-100 MHz */ + { 150, 1 }, /* 100-150 MHz */ + { 250, 4 }, /* 150-250 MHz */ + { 300, 5 }, /* 250-300 MHz */ + }; int i; - for (i = 0; garclk[i].freq != 0; i++) { + /* convert MDIO clk to a divisor value */ + if (freq < garclk[0].freq) + return garclk[0].bit; + for (i = 1; i < __arraycount(garclk); i++) { if (freq < garclk[i].freq) - return garclk[i].bit; + return garclk[i-1].bit; } - return garclk[i - 1].bit; + return garclk[__arraycount(garclk) - 1].bit; } static void @@ -1441,7 +1453,6 @@ injectucode(struct scx_softc *sc, int po uint32_t ucode; int i; - port &= 03; if (!bus_space_map(sc->sc_st, addr, size, 0, ) != 0) { aprint_error_dev(sc->sc_dev, "eeprom map failure for ucode port 0x%x\n", port);
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Mon Mar 23 05:24:28 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_ave.c Log Message: use sc_100mii variable name for RMII/MII To generate a diff of this commit: cvs rdiff -u -r1.11 -r1.12 src/sys/arch/arm/sociox/if_ave.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_ave.c diff -u src/sys/arch/arm/sociox/if_ave.c:1.11 src/sys/arch/arm/sociox/if_ave.c:1.12 --- src/sys/arch/arm/sociox/if_ave.c:1.11 Mon Mar 23 03:21:31 2020 +++ src/sys/arch/arm/sociox/if_ave.c Mon Mar 23 05:24:28 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ave.c,v 1.11 2020/03/23 03:21:31 nisimura Exp $ */ +/* $NetBSD: if_ave.c,v 1.12 2020/03/23 05:24:28 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.11 2020/03/23 03:21:31 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.12 2020/03/23 05:24:28 nisimura Exp $"); #include #include @@ -230,7 +230,7 @@ struct ave_softc { int sc_flowflags; /* 802.3x PAUSE flow control */ void *sc_ih; /* interrupt cookie */ int sc_phy_id; /* PHY address */ - uint32_t sc_phymode; /* 1<<27: MII/RMII, 0: RGMII */ + uint32_t sc_100mii; /* 1<<27: RMII/MII, 0: RGMII */ uint32_t sc_rxc; /* software copy of AVERXC */ int sc_model; /* 64 paddr model or otherwise 32 */ @@ -362,10 +362,7 @@ ave_fdt_attach(device_t parent, device_t sc->sc_model, hwver >> 8, hwver & 0xff, phy_mode); aprint_normal_dev(self, "interrupt on %s\n", intrstr); - if (strcmp(phy_mode, "rgmii") == 0) - sc->sc_phymode = 0; /* RGMII */ - else - sc->sc_phymode = CFG_MII; /* MII|RMII */ + sc->sc_100mii = (strcmp(phy_mode, "rgmii") == 0) ? CFG_MII : 0; CSR_WRITE(sc, AVEGR, GR_GRST | GR_PHYRST); DELAY(20); @@ -490,7 +487,7 @@ ave_reset(struct ave_softc *sc) CSR_WRITE(sc, AVERXC, 0); /* stop Rx first */ CSR_WRITE(sc, AVEDESCC, 0); /* stop Tx/Rx descriptor engine */ - if (sc->sc_phymode & CFG_MII) { + if (sc->sc_100mii & CFG_MII) { csr = CSR_READ(sc, AVERMIIC); CSR_WRITE(sc, AVERMIIC, csr &~ RMIIC_RST); DELAY(10); @@ -519,7 +516,7 @@ ave_init(struct ifnet *ifp) /* make sure Rx circuit sane & stable state */ ave_reset(sc); - CSR_WRITE(sc, AVECFG, CFG_FLE | sc->sc_phymode); + CSR_WRITE(sc, AVECFG, CFG_FLE | sc->sc_100mii); /* set Tx/Rx descriptor ring base addr offset and total size */ CSR_WRITE(sc, AVETXDES, 0U|(sizeof(struct tdes)*AVE_NTXDESC) << 16); @@ -624,7 +621,7 @@ ave_ifmedia_upd(struct ifnet *ifp) #if 1 /* XXX not sure to belong here XXX */ txcr &= ~(TXC_SPD1000 | TXC_SPD100); rxcr &= ~RXC_USEFDX; - if ((sc->sc_phymode & CFG_MII) == 0 /* RGMII model */ + if ((sc->sc_100mii == 0) /* RGMII model */ && IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_1000_T) txcr |= TXC_SPD1000; else if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_100_TX) @@ -632,9 +629,9 @@ ave_ifmedia_upd(struct ifnet *ifp) if (ifm->ifm_media & IFM_FDX) rxcr |= RXC_USEFDX; - /* adjust LINKSEL when MII/RMII too */ - if (sc->sc_phymode & CFG_MII) { - csr = CSR_READ(sc, AVELINKSEL) &~ LINKSEL_SPD100;; + /* adjust LINKSEL when RMII/MII too */ + if (sc->sc_100mii) { + csr = CSR_READ(sc, AVELINKSEL) &~ LINKSEL_SPD100; if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_100_TX) csr |= LINKSEL_SPD100; CSR_WRITE(sc, AVELINKSEL, csr);
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Mon Mar 23 04:34:16 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_scx.c Log Message: improve comment descriptions. DRT for ucode load To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sociox/if_scx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_scx.c diff -u src/sys/arch/arm/sociox/if_scx.c:1.2 src/sys/arch/arm/sociox/if_scx.c:1.3 --- src/sys/arch/arm/sociox/if_scx.c:1.2 Mon Mar 23 03:55:49 2020 +++ src/sys/arch/arm/sociox/if_scx.c Mon Mar 23 04:34:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_scx.c,v 1.2 2020/03/23 03:55:49 nisimura Exp $ */ +/* $NetBSD: if_scx.c,v 1.3 2020/03/23 04:34:16 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -50,7 +50,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.2 2020/03/23 03:55:49 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.3 2020/03/23 04:34:16 nisimura Exp $"); #include #include @@ -104,8 +104,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define RXTIMER 0x45c #define TXCOUNT 0x410 #define RXCOUNT 0x454 -#define DMACH2M 0x210 /* DMAC host2media ucode port */ -#define DMACM2H 0x21c /* DMAC media2host ucode port */ +#define H2MENG 0x210 /* DMAC host2media ucode port */ +#define M2HENG 0x21c /* DMAC media2host ucode port */ #define PKTENG 0x0d0 /* packet engine ucode port */ #define HWVER0 0x22c #define HWVER1 0x230 @@ -122,7 +122,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define MCR_IBN (1U<<30) /* */ #define MCR_CST (1U<<25) /* strip CRC */ #define MCR_TC (1U<<24) /* keep RGMII PHY notified */ -#define MCR_JE (1U<<20) /* ignore oversized >9018 frame */ +#define MCR_JE (1U<<20) /* ignore oversized >9018 condition */ #define MCR_USEMII (1U<<15) /* 1: RMII/MII, 0: RGMII */ #define MCR_SPD100 (1U<<14) /* force speed 100 */ #define MCR_USEFDX (1U<<11) /* force full duplex */ @@ -157,7 +157,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define GMACFCR 0x0018 /* 802.3x flowcontrol */ #define FCR_RFE (1U<<2) /* accept PAUSE to throttle Tx */ #define FCR_TFE (1U<<1) /* generate PAUSE to moderate Rx lvl */ -#define GMACIMPL 0x0020 /* (dig this number .) */ +#define GMACIMPL 0x0020 /* implementation number . */ #define GMACVTAG 0x001c /* VLAN tag control */ #define GMACMAH0 0x0040 /* MAC address 0 47:32 */ #define GMACMAL0 0x0044 /* MAC address 0 31:0 */ @@ -165,7 +165,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define GMACMAL(i) ((i)*8+0x44) #define GMACMHT0 0x0500 /* multicast hash table 0 - 8*/ -#define GMACBMR 0x1000 /* DMA bus mode +#define GMACBMR 0x1000 /* DMA bus mode control * 244PBL * 22:17 RPBL * 16fix burst @@ -185,8 +185,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define GMACTDLAR 0x1010 /* */ #define _TDLAR 0x1c000 /* XXX TBD */ #define GMACOMR 0x1018 /* DMA operation */ -#define OMR_TXE (1U<<13) /* start Tx DMA engine */ -#define OMR_RXE (1U<<1) /* start Rx DMA engine */ +#define OMR_TXE (1U<<13) /* start Tx DMA engine, 0 to stop */ +#define OMR_RXE (1U<<1) /* start Rx DMA engine, 0 to stop */ const struct { uint16_t freq, bit; /* GAR 5:2 MDIO frequency selection */ @@ -298,14 +298,15 @@ struct scx_softc { struct ethercom sc_ethercom; /* Ethernet common data */ struct mii_data sc_mii; /* MII */ callout_t sc_tick_ch; /* PHY monitor callout */ - int sc_flowflags; /* 802.3x PAUSE flow control */ - void *sc_ih; /* interrupt cookie */ bus_dma_segment_t sc_seg; /* descriptor store seg */ int sc_nseg; /* descriptor store nseg */ + void *sc_ih; /* interrupt cookie */ int sc_phy_id; /* PHY address */ + int sc_flowflags; /* 802.3x PAUSE flow control */ uint32_t sc_gar; /* GAR 5:2 clock selection */ - int sc_phandle; /* fdt phandle */ uint32_t sc_t0coso; /* T0_CSUM | T0_SGOL to run */ + int sc_ucodeloaded; /* ucode for H2M/M2H/PKT */ + int sc_phandle; /* fdt phandle */ bus_dmamap_t sc_cddmamap; /* control data DMA map */ #define sc_cddma sc_cddmamap->dm_segs[0].ds_addr @@ -569,9 +570,10 @@ scx_attach_i(struct scx_softc *sc) csr = bus_space_read_4(sc->sc_st, sc->sc_eesh, 4); enaddr[4] = csr >> 24; enaddr[5] = csr >> 16; + csr = CSR_READ(sc, GMACIMPL); - aprint_normal_dev(sc->sc_dev, "NetSec GbE (%d.%d)\n", - hwver >> 16, hwver & 0x); + aprint_normal_dev(sc->sc_dev, "NetSec GbE (%d.%d) impl (%x.%x)\n", + hwver >> 16, hwver & 0x, csr >> 16, csr & 0x); aprint_normal_dev(sc->sc_dev, "Ethernet address %s\n", ether_sprintf(enaddr)); @@ -581,7 +583,7 @@ scx_attach_i(struct scx_softc *sc) sc->sc_flowflags = 0; - if (0/*CONSTCOND*/) + if (sc->sc_ucodeloaded == 0) loaducode(sc); mii->mii_ifp = ifp; @@ -1220,7 +1222,7 @@ scx_intr(void *arg) { struct scx_softc *sc = arg;
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Mon Mar 23 03:55:49 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_scx.c Log Message: try to DRT about EEPROM ucode To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sociox/if_scx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_scx.c diff -u src/sys/arch/arm/sociox/if_scx.c:1.1 src/sys/arch/arm/sociox/if_scx.c:1.2 --- src/sys/arch/arm/sociox/if_scx.c:1.1 Mon Mar 23 03:25:06 2020 +++ src/sys/arch/arm/sociox/if_scx.c Mon Mar 23 03:55:49 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_scx.c,v 1.1 2020/03/23 03:25:06 nisimura Exp $ */ +/* $NetBSD: if_scx.c,v 1.2 2020/03/23 03:55:49 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -50,7 +50,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.1 2020/03/23 03:25:06 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.2 2020/03/23 03:55:49 nisimura Exp $"); #include #include @@ -133,7 +133,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define _MCR_FDX 0x280c /* XXX TBD */ #define _MCR_HDX 0x0001a00c /* XXX TBD */ #define GMACAFR 0x0004 /* frame DA/SA address filter */ -#define AFR_RA (1U<<31) /* receive all on */ +#define AFR_RA (1U<<31) /* receive block all on */ #define AFR_HPF (1U<<10) /* activate hash or perfect filter */ #define AFR_SAF (1U<<9) /* source address filter */ #define AFR_SAIF (1U<<8) /* SA inverse filtering */ @@ -161,9 +161,10 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1 #define GMACVTAG 0x001c /* VLAN tag control */ #define GMACMAH0 0x0040 /* MAC address 0 47:32 */ #define GMACMAL0 0x0044 /* MAC address 0 31:0 */ -#define GMACMAH(i) ((i)*8+0x40) /* 0 - 15 */ +#define GMACMAH(i) ((i)*8+0x40) /* supplimental MAC addr 1 - 15 */ #define GMACMAL(i) ((i)*8+0x44) -#define GMACMHT0 0x0500 /* multcast hash table 0 - 8*/ +#define GMACMHT0 0x0500 /* multicast hash table 0 - 8*/ + #define GMACBMR 0x1000 /* DMA bus mode * 244PBL * 22:17 RPBL @@ -304,7 +305,7 @@ struct scx_softc { int sc_phy_id; /* PHY address */ uint32_t sc_gar; /* GAR 5:2 clock selection */ int sc_phandle; /* fdt phandle */ - uint32_t sc_t0coso; /* T0_CSUM | T0_SGOL */ + uint32_t sc_t0coso; /* T0_CSUM | T0_SGOL to run */ bus_dmamap_t sc_cddmamap; /* control data DMA map */ #define sc_cddma sc_cddmamap->dm_segs[0].ds_addr @@ -388,7 +389,7 @@ static int spin_waitfor(struct scx_softc static int mac_read(struct scx_softc *, int); static void mac_write(struct scx_softc *, int, int); static void loaducode(struct scx_softc *); -static void injectucode(struct scx_softc *, int, uint64_t, uint32_t); +static void injectucode(struct scx_softc *, int, bus_addr_t, bus_size_t); #define CSR_READ(sc,off) \ bus_space_read_4((sc)->sc_st, (sc)->sc_sh, (off)) @@ -418,16 +419,15 @@ scx_fdt_attach(device_t parent, device_t bus_space_tag_t bst = faa->faa_bst; bus_space_handle_t bsh; bus_space_handle_t eebsh; - bus_addr_t addr; - bus_size_t size; + bus_addr_t addr[2]; + bus_size_t size[2]; char intrstr[128]; - if (fdtbus_get_reg(phandle, 0, , ) != 0 - || bus_space_map(faa->faa_bst, addr, size, 0, ) != 0) { + if (fdtbus_get_reg(phandle, 0, addr+0, size+0) != 0 + || bus_space_map(faa->faa_bst, addr[0], size[0], 0, ) != 0) { aprint_error(": unable to map device csr\n"); return; } - sc->sc_sz = size; if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) { aprint_error(": failed to decode interrupt\n"); goto fail; @@ -438,12 +438,11 @@ scx_fdt_attach(device_t parent, device_t aprint_error_dev(self, "couldn't establish interrupt\n"); goto fail; } - if (fdtbus_get_reg(phandle, 1, , ) != 0 - || bus_space_map(faa->faa_bst, addr, size, 0, ) != 0) { + if (fdtbus_get_reg(phandle, 1, addr+1, size+1) != 0 + || bus_space_map(faa->faa_bst, addr[0], size[1], 0, ) != 0) { aprint_error(": unable to map device eeprom\n"); goto fail; } - sc->sc_eesz = size; aprint_naive("\n"); aprint_normal(": Gigabit Ethernet Controller\n"); @@ -452,7 +451,9 @@ scx_fdt_attach(device_t parent, device_t sc->sc_dev = self; sc->sc_st = bst; sc->sc_sh = bsh; + sc->sc_sz = size[0]; sc->sc_eesh = eebsh; + sc->sc_eesz = size[1]; sc->sc_dmat = faa->faa_dmat; sc->sc_phandle = phandle; @@ -945,7 +946,7 @@ printf("[%d] %s\n", i, ether_sprintf(enm return; update: - /* With PM or AM, MHTE/MTL/MTH are never consulted. really? */ + /* With PM or AM, MHTE/MHTL/MHTH are never consulted. really? */ if (ifp->if_flags & IFF_PROMISC) csr |= AFR_PM; /* run promisc. mode */ else @@ -1407,38 +1408,48 @@ loaducode(struct scx_softc *sc) up = EE_READ(sc, 0x08); /* H->M ucode addr high */ lo = EE_READ(sc, 0x0c); /* H->M ucode addr low */ sz = EE_READ(sc, 0x10); /* H->M ucode size */ + sz *= 4; addr = ((uint64_t)up << 32) | lo;
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Mon Mar 23 03:25:06 UTC 2020 Added Files: src/sys/arch/arm/sociox: if_scx.c Log Message: Socionext "NetSec" GbE driver To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/sociox/if_scx.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/sys/arch/arm/sociox/if_scx.c diff -u /dev/null src/sys/arch/arm/sociox/if_scx.c:1.1 --- /dev/null Mon Mar 23 03:25:06 2020 +++ src/sys/arch/arm/sociox/if_scx.c Mon Mar 23 03:25:06 2020 @@ -0,0 +1,1444 @@ +/* $NetBSD: if_scx.c,v 1.1 2020/03/23 03:25:06 nisimura Exp $ */ + +/*- + * Copyright (c) 2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Tohru Nishimura. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#define NOT_MP_SAFE 0 + +/* + * Socionext SC2A11 SynQuacer NetSec GbE driver + * + * (possibly incorrect notes to be removed eventually) + * - 32 byte descriptor for 64 bit paddr design. + * - multiple rings seems available. There are special descriptor fields + * to designify ring number from which to arrive or to which go. + * - memory mapped EEPROM to hold MAC address. The rest of the area is + * occupied by a set of ucode for two DMA engines and one packet engine. + * - The size of frame address filter is unknown. Might be 32 + * - The first slot is my own station address. Always enabled to perform + * to identify oneself. + * - 1~31 are for supplimental MAC addresses. Independently enabled + * for use. Good to catch multicast. Byte-wise selective match available. + * Use to catch { 0x01, 0x00, 0x00 } and/or { 0x33, 0x33 }. + * - The size of multicast hash filter store is unknown. Might be 256 bit. + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.1 2020/03/23 03:25:06 nisimura Exp $"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#define SWRESET 0x104 +#define COMINIT 0x120 +#define INTRST 0x200 +#define IRQ_RX (1U<<1) +#define IRQ_TX (1U<<0) +#define INTREN 0x204 +#define INTR_SET 0x234 +#define INTR_CLR 0x238 +#define TXINTST 0x400 +#define TXINTEN 0x404 +#define TXINT_SET 0x428 +#define TXINT_CLR 0x42c +#define TXI_NTOWNR (1U<<17) +#define TXI_TR_ERR (1U<<16) +#define TXI_TXDONE (1U<<15) +#define TXI_TMREXP (1U<<14) +#define RXINTST 0x440 +#define RXINTEN 0x444 +#define RXINT_SET 0x468 +#define RXINT_CLR 0x46c +#define RXI_RC_ERR (1U<<16) +#define RXI_PKTCNT (1U<<15) +#define RXI_TMREXP (1U<<14) +#define TXTIMER 0x41c +#define RXTIMER 0x45c +#define TXCOUNT 0x410 +#define RXCOUNT 0x454 +#define DMACH2M 0x210 /* DMAC host2media ucode port */ +#define DMACM2H 0x21c /* DMAC media2host ucode port */ +#define PKTENG 0x0d0 /* packet engine ucode port */ +#define HWVER0 0x22c +#define HWVER1 0x230 + +#define MACSTAT 0x1024 /* gmac status */ +#define MACDATA 0x11c0 /* gmac rd/wr data */ +#define MACCMD 0x11c4 /* gmac operation */ +#define CMD_IOWR (1U<<28) /* write op */ +#define CMD_BUSY (1U<<31) /* busy bit */ +#define DESCENG_INIT 0x11fc +#define DESCENG_SRST 0x1204 + +#define GMACMCR 0x /* MAC configuration */ +#define MCR_IBN (1U<<30) /* */ +#define MCR_CST (1U<<25) /* strip CRC */ +#define MCR_TC (1U<<24) /* keep RGMII PHY notified */ +#define MCR_JE (1U<<20) /* ignore oversized >9018 frame */ +#define MCR_USEMII (1U<<15) /* 1: RMII/MII, 0: RGMII */
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Mon Mar 23 03:21:31 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_ave.c Log Message: manifest non-MP_SAFE To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sys/arch/arm/sociox/if_ave.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_ave.c diff -u src/sys/arch/arm/sociox/if_ave.c:1.10 src/sys/arch/arm/sociox/if_ave.c:1.11 --- src/sys/arch/arm/sociox/if_ave.c:1.10 Sun Mar 22 00:14:16 2020 +++ src/sys/arch/arm/sociox/if_ave.c Mon Mar 23 03:21:31 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ave.c,v 1.10 2020/03/22 00:14:16 nisimura Exp $ */ +/* $NetBSD: if_ave.c,v 1.11 2020/03/23 03:21:31 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.10 2020/03/22 00:14:16 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.11 2020/03/23 03:21:31 nisimura Exp $"); #include #include @@ -60,7 +60,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1 #include -#define FDT_INTR_FLAGS (0) /* !MP_SAFE */ +#define NOT_MP_SAFE (0) #define AVEID 0x000 /* hardware ID */ #define AVEHWVER 0x004 /* hardware version */ @@ -71,7 +71,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1 #define AVECFG 0x00c /* hw configuration */ #define CFG_FLE (1U<<31) /* filter function enable */ #define CFG_CKE (1U<<30) /* checksum enable */ -#define CFG_MII (1U<<27) /* 1: MII/RMII, 0: RGMII */ +#define CFG_MII (1U<<27) /* 1: RMII/MII, 0: RGMII */ #define CFG_IPFCKE (1U<<24) /* IP framgment csum enable */ #define AVEGIMR 0x100 /* global interrupt mask */ #define AVEGISR 0x104 /* global interrupt status */ @@ -331,7 +331,7 @@ ave_fdt_attach(device_t parent, device_t aprint_error(": failed to decode interrupt\n"); return; } - sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_NET, 0, + sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_NET, NOT_MP_SAFE, ave_intr, sc); if (sc->sc_ih == NULL) { aprint_error_dev(self, "couldn't establish interrupt on %s\n", @@ -513,7 +513,7 @@ ave_init(struct ifnet *ifp) CSR_WRITE(sc, AVEGIMR, 0); - /* cancel pending I/O */ + /* Cancel pending I/O. */ ave_stop(ifp, 0); /* make sure Rx circuit sane & stable state */ @@ -531,7 +531,7 @@ ave_init(struct ifnet *ifp) sc->sc_txd32 = (void *)((uintptr_t)sc->sc_sh + AVE32TDB); sc->sc_rxd32 = (void *)((uintptr_t)sc->sc_sh + AVE32RDB); - /* build sane Tx and loaded Rx descriptors */ + /* build sane Tx and load Rx descriptors with mbuf */ for (i = 0; i < AVE_NTXDESC; i++) { struct tdes *tdes = >sc_txdescs[i]; tdes->t2 = tdes->t1 = 0;
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Sun Mar 22 00:14:16 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_ave.c Log Message: improve comments To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/arm/sociox/if_ave.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_ave.c diff -u src/sys/arch/arm/sociox/if_ave.c:1.9 src/sys/arch/arm/sociox/if_ave.c:1.10 --- src/sys/arch/arm/sociox/if_ave.c:1.9 Sun Mar 22 00:05:17 2020 +++ src/sys/arch/arm/sociox/if_ave.c Sun Mar 22 00:14:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ave.c,v 1.9 2020/03/22 00:05:17 nisimura Exp $ */ +/* $NetBSD: if_ave.c,v 1.10 2020/03/22 00:14:16 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.9 2020/03/22 00:05:17 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.10 2020/03/22 00:14:16 nisimura Exp $"); #include #include @@ -82,13 +82,13 @@ __KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1 #define GISR_RXDROP (1U<<6) /* PAUSE frame has been dropped */ #define GISR_RXIT (1U<<5) /* receive itimer notify */ #define AVETXC 0x200 /* transmit control */ -#define TXC_FCE (1U<<18) /* enable Tx flow control */ +#define TXC_FCE (1U<<18) /* generate PAUSE to moderate Rx lvl */ #define TXC_SPD1000 (1U<<17) /* use 1000Mbps */ #define TXC_SPD100 (1U<<16) /* use 100Mbps */ #define AVERXC 0x204 /* receive control */ #define RXC_EN (1U<<30) /* enable receive circuit */ #define RXC_USEFDX (1U<<22) /* use full-duplex */ -#define RXC_FCE (1U<<21) /* enable Rx flow control */ +#define RXC_FCE (1U<<21) /* accept PAUSE to throttle Tx */ #define RXC_AFE (1U<<19) /* use address filter (!promisc) */ #define RXC_DRPEN (1U<<18) /* drop receiving PAUSE frames */ /* RXC 15:0 max frame length to accept */ @@ -287,7 +287,7 @@ static int add_rxbuf(struct ave_softc *, bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (off), (val)) static const struct of_compat_data compat_data[] = { - { "socionext,unifier-ld20-ave4", 64 }, + { "socionext,unifier-ld20-ave4", 64 }, /* XXX only this for now */ { "socionext,unifier-pro4-ave4", 32 }, { "socionext,unifier-pxs2-ave4", 32 }, { "socionext,unifier-ld11-ave4", 32 },
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Sun Mar 22 00:05:17 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_ave.c Log Message: - move sc_flowflags = 0 line at earlier place. - handle a set of speed selection operations. To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/sociox/if_ave.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_ave.c diff -u src/sys/arch/arm/sociox/if_ave.c:1.8 src/sys/arch/arm/sociox/if_ave.c:1.9 --- src/sys/arch/arm/sociox/if_ave.c:1.8 Sat Mar 21 11:46:36 2020 +++ src/sys/arch/arm/sociox/if_ave.c Sun Mar 22 00:05:17 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ave.c,v 1.8 2020/03/21 11:46:36 nisimura Exp $ */ +/* $NetBSD: if_ave.c,v 1.9 2020/03/22 00:05:17 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.8 2020/03/21 11:46:36 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.9 2020/03/22 00:05:17 nisimura Exp $"); #include #include @@ -387,6 +387,9 @@ ave_fdt_attach(device_t parent, device_t aprint_normal_dev(self, "Ethernet address %s\n", ether_sprintf(enaddr)); + sc->sc_flowflags = 0; + sc->sc_rxc = 0; + mii->mii_ifp = ifp; mii->mii_readreg = mii_readreg; mii->mii_writereg = mii_writereg; @@ -414,9 +417,6 @@ ave_fdt_attach(device_t parent, device_t ifp->if_stop = ave_stop; IFQ_SET_READY(>if_snd); - sc->sc_flowflags = 0; - sc->sc_rxc = 0; - sc->sc_ethercom.ec_capabilities = ETHERCAP_VLAN_MTU; ifp->if_capabilities = IFCAP_CSUM_IPv4_Tx | IFCAP_CSUM_IPv4_Rx; @@ -531,8 +531,12 @@ ave_init(struct ifnet *ifp) sc->sc_txd32 = (void *)((uintptr_t)sc->sc_sh + AVE32TDB); sc->sc_rxd32 = (void *)((uintptr_t)sc->sc_sh + AVE32RDB); - /* build sane and loaded Tx/Rx descriptors */ - memset(sc->sc_txdescs, 0, sizeof(struct tdes)*AVE_NTXDESC); + /* build sane Tx and loaded Rx descriptors */ + for (i = 0; i < AVE_NTXDESC; i++) { + struct tdes *tdes = >sc_txdescs[i]; + tdes->t2 = tdes->t1 = 0; + tdes->t0 = T0_OWN; + } for (i = 0; i < AVE_NRXDESC; i++) (void)add_rxbuf(sc, i); @@ -550,6 +554,8 @@ ave_init(struct ifnet *ifp) /* accept multicast frame or run promisc mode */ ave_set_rcvfilt(sc); + (void)ave_ifmedia_upd(ifp); + csr = CSR_READ(sc, AVECFG); if (ifp->if_capenable & IFCAP_CSUM_IPv4_Tx) { sc->sc_t0csum = 0; @@ -603,7 +609,7 @@ ave_ifmedia_upd(struct ifnet *ifp) { struct ave_softc *sc = ifp->if_softc; struct ifmedia *ifm = >sc_mii.mii_media; - uint32_t txcr, rxcr; + uint32_t txcr, rxcr, csr; txcr = CSR_READ(sc, AVETXC); rxcr = CSR_READ(sc, AVERXC); @@ -615,14 +621,25 @@ ave_ifmedia_upd(struct ifnet *ifp) ; /* advertise flow control pause */ ; /* adv. 1000FDX,100FDX,100HDX,10FDX,10HDX */ } else { +#if 1 /* XXX not sure to belong here XXX */ txcr &= ~(TXC_SPD1000 | TXC_SPD100); rxcr &= ~RXC_USEFDX; - if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_1000_T) + if ((sc->sc_phymode & CFG_MII) == 0 /* RGMII model */ + && IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_1000_T) txcr |= TXC_SPD1000; else if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_100_TX) txcr |= TXC_SPD100; if (ifm->ifm_media & IFM_FDX) - rxcr |= RXC_USEFDX; + rxcr |= RXC_USEFDX; + + /* adjust LINKSEL when MII/RMII too */ + if (sc->sc_phymode & CFG_MII) { + csr = CSR_READ(sc, AVELINKSEL) &~ LINKSEL_SPD100;; + if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_100_TX) +csr |= LINKSEL_SPD100; + CSR_WRITE(sc, AVELINKSEL, csr); + } +#endif } sc->sc_rxc = rxcr; CSR_WRITE(sc, AVETXC, txcr); @@ -647,10 +664,9 @@ mii_statchg(struct ifnet *ifp) { struct ave_softc *sc = ifp->if_softc; struct mii_data *mii = >sc_mii; - struct ifmedia * const ifm = >mii_media; - uint32_t txcr, rxcr, csr; + uint32_t txcr, rxcr; - /* get flow control negotiation result */ + /* Get flow control negotiation result. */ if (IFM_SUBTYPE(mii->mii_media.ifm_cur->ifm_media) == IFM_AUTO && (mii->mii_media_active & IFM_ETH_FMASK) != sc->sc_flowflags) sc->sc_flowflags = mii->mii_media_active & IFM_ETH_FMASK; @@ -659,32 +675,14 @@ mii_statchg(struct ifnet *ifp) rxcr = CSR_READ(sc, AVERXC); CSR_WRITE(sc, AVERXC, rxcr &~ RXC_EN); /* stop Rx first */ - /* adjust 802.3x PAUSE flow control */ - if ((mii->mii_media_active & IFM_FDX) - && (sc->sc_flowflags & IFM_ETH_TXPAUSE)) - txcr |= TXC_FCE; - else - txcr &= ~TXC_FCE; - if ((mii->mii_media_active & IFM_FDX) - && (sc->sc_flowflags & IFM_ETH_RXPAUSE)) - rxcr |= RXC_FCE; - else - rxcr &= ~RXC_FCE; - - /* HW does not handle automatic speed adjustment */ - txcr &= ~(TXC_SPD1000 | TXC_SPD100); - if ((sc->sc_phymode & CFG_MII) == 0 /* RGMII model */ - && IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_1000_T) - txcr |= TXC_SPD1000; - else if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) ==
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Sat Mar 21 11:46:36 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_ave.c Log Message: - handle register adjustment when link speed change. - make some more care on reset operation. To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sociox/if_ave.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_ave.c diff -u src/sys/arch/arm/sociox/if_ave.c:1.7 src/sys/arch/arm/sociox/if_ave.c:1.8 --- src/sys/arch/arm/sociox/if_ave.c:1.7 Sat Mar 21 08:16:19 2020 +++ src/sys/arch/arm/sociox/if_ave.c Sat Mar 21 11:46:36 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ave.c,v 1.7 2020/03/21 08:16:19 nisimura Exp $ */ +/* $NetBSD: if_ave.c,v 1.8 2020/03/21 11:46:36 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.7 2020/03/21 08:16:19 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.8 2020/03/21 11:46:36 nisimura Exp $"); #include #include @@ -77,9 +77,9 @@ __KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1 #define AVEGISR 0x104 /* global interrupt status */ #define GISR_PHY (1U<<24) /* PHY status change detected */ #define GISR_TXCI (1U<<16) /* transmission completed */ -#define GISR_RXERR (1U<<8) /* Rx frame error detected */ -#define GISR_RXOVF (1U<<7) /* Rx oveflow detected */ -#define GISR_RXDROP (1U<<6) /* Rx has been dropped */ +#define GISR_RXF2L (1U<<8) /* Rx frame length beyond limit */ +#define GISR_RXOVF (1U<<7) /* RxFIFO oveflow detected */ +#define GISR_RXDROP (1U<<6) /* PAUSE frame has been dropped */ #define GISR_RXIT (1U<<5) /* receive itimer notify */ #define AVETXC 0x200 /* transmit control */ #define TXC_FCE (1U<<18) /* enable Tx flow control */ @@ -133,9 +133,9 @@ __KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1 #define AVE32RDB 0x1800 /* 32bit Rx store base, upto 2048 */ #define AVERMIIC 0x8028 /* RMII control */ -#define RMIIC_RST (1U<<16) /* reset */ -#define AVELINKSEL 0x8034 /* link speed selection */ -#define LINKSEL_SPD100 (1U<<0) /* RMII speed 100Mbps */ +#define RMIIC_RST (1U<<16) /* reset operation */ +#define AVELINKSEL 0x8034 /* RMII speed selection */ +#define LINKSEL_SPD100 (1U<<0) /* use 100Mbps */ /* * descriptor size is 12 bytes when 64bit paddr design, 8 bytes otherwise. @@ -486,12 +486,19 @@ ave_fdt_attach(device_t parent, device_t static void ave_reset(struct ave_softc *sc) { + uint32_t csr; CSR_WRITE(sc, AVERXC, 0); /* stop Rx first */ CSR_WRITE(sc, AVEDESCC, 0); /* stop Tx/Rx descriptor engine */ + if (sc->sc_phymode & CFG_MII) { + csr = CSR_READ(sc, AVERMIIC); + CSR_WRITE(sc, AVERMIIC, csr &~ RMIIC_RST); + DELAY(10); + CSR_WRITE(sc , AVERMIIC, csr); + } CSR_WRITE(sc, AVEGR, GR_RXRST); /* assert RxFIFO reset operation */ DELAY(50); - CSR_WRITE(sc, AVEGR, 0); /* negate reset */ + CSR_WRITE(sc, AVEGR, 0); CSR_WRITE(sc, AVEGISR, GISR_RXOVF); /* clear OVF condition */ } @@ -564,7 +571,7 @@ ave_init(struct ifnet *ifp) CSR_WRITE(sc, AVEITIRQC, csr | ITIRQC_R0E | INTMVAL); CSR_WRITE(sc, AVEGIMR, /* PHY interrupt is not maskable */ - GISR_TXCI | GISR_RXIT | GISR_RXDROP | GISR_RXOVF | GISR_RXERR); + GISR_TXCI | GISR_RXIT | GISR_RXDROP | GISR_RXOVF | GISR_RXF2L); ifp->if_flags |= IFF_RUNNING; ifp->if_flags &= ~IFF_OACTIVE; @@ -664,21 +671,19 @@ mii_statchg(struct ifnet *ifp) else rxcr &= ~RXC_FCE; - /* HW does not handle auto speed adjustment */ + /* HW does not handle automatic speed adjustment */ txcr &= ~(TXC_SPD1000 | TXC_SPD100); if ((sc->sc_phymode & CFG_MII) == 0 /* RGMII model */ - && IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_100_TX) + && IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_1000_T) txcr |= TXC_SPD1000; else if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_100_TX) txcr |= TXC_SPD100; /* adjust LINKSEL when MII/RMII too */ if (sc->sc_phymode & CFG_MII) { - csr = CSR_READ(sc, AVELINKSEL); + csr = CSR_READ(sc, AVELINKSEL) &~ LINKSEL_SPD100;; if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_100_TX) csr |= LINKSEL_SPD100; - else - csr &= ~LINKSEL_SPD100; CSR_WRITE(sc, AVELINKSEL, csr); } @@ -804,15 +809,15 @@ ave_write_filt(struct ave_softc *sc, int { uint32_t macl, mach, n, mskbyte0; - macl = mach = 0; - macl |= (en[3]<<24) | (en[2]<<16)| (en[1]<<8) | en[0]; - mach |= (en[5]<<8) | en[4]; /* pick v4mcast or v6mcast length */ n = (en[0] == 0x01) ? 3 : (en[0] == 0x33) ? 2 : ETHER_ADDR_LEN; /* entry 0 is reserved for promisc mode */ mskbyte0 = (i > 0) ? genmask0(n) : MSKBYTE0; /* set frame address first */ + macl = mach = 0; + macl |= (en[3]<<24) | (en[2]<<16)| (en[1]<<8) | en[0]; + mach |= (en[5]<<8) | en[4]; CSR_WRITE(sc, AVEAFB + (i * 0x40) + 0, macl); CSR_WRITE(sc, AVEAFB + (i * 0x40) + 4, mach); /* set byte
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Sat Mar 21 08:16:19 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_ave.c Log Message: - add one more missing RXC_EN. - handle link speed change. - fix genmask0() bit mask generation error. To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sociox/if_ave.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_ave.c diff -u src/sys/arch/arm/sociox/if_ave.c:1.6 src/sys/arch/arm/sociox/if_ave.c:1.7 --- src/sys/arch/arm/sociox/if_ave.c:1.6 Sat Mar 21 07:16:16 2020 +++ src/sys/arch/arm/sociox/if_ave.c Sat Mar 21 08:16:19 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ave.c,v 1.6 2020/03/21 07:16:16 nisimura Exp $ */ +/* $NetBSD: if_ave.c,v 1.7 2020/03/21 08:16:19 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -36,7 +36,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.6 2020/03/21 07:16:16 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.7 2020/03/21 08:16:19 nisimura Exp $"); #include #include @@ -122,7 +122,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1 #define AVEAFMSKB 0x0d00 /* byte mask base */ #define MSKBYTE0 0xfff3f /* zeros in 7:6 */ #define MSKBYTE1 0x003ff /* ones in 25:0 */ -#define genmask0(x) (MSKBYTE0 & (~0U << (32-(x +#define genmask0(x) (MSKBYTE0 & (~0U << (x))) #define AVEAFMSKV 0x0e00 /* bit mask base */ #define AVEAFRING 0x0f00 /* entry ring number selector */ #define AVEAFEN 0x0ffc /* entry enable bit vector */ @@ -132,6 +132,11 @@ __KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1 #define AVE32TDB 0x1000 /* 32bit Tx store base, upto 256 */ #define AVE32RDB 0x1800 /* 32bit Rx store base, upto 2048 */ +#define AVERMIIC 0x8028 /* RMII control */ +#define RMIIC_RST (1U<<16) /* reset */ +#define AVELINKSEL 0x8034 /* link speed selection */ +#define LINKSEL_SPD100 (1U<<0) /* RMII speed 100Mbps */ + /* * descriptor size is 12 bytes when 64bit paddr design, 8 bytes otherwise. */ @@ -635,17 +640,19 @@ mii_statchg(struct ifnet *ifp) { struct ave_softc *sc = ifp->if_softc; struct mii_data *mii = >sc_mii; - uint32_t txcr, rxcr; + struct ifmedia * const ifm = >mii_media; + uint32_t txcr, rxcr, csr; - /* Get flow control negotiation result. */ + /* get flow control negotiation result */ if (IFM_SUBTYPE(mii->mii_media.ifm_cur->ifm_media) == IFM_AUTO && (mii->mii_media_active & IFM_ETH_FMASK) != sc->sc_flowflags) sc->sc_flowflags = mii->mii_media_active & IFM_ETH_FMASK; - /* Adjust PAUSE flow control. */ txcr = CSR_READ(sc, AVETXC); rxcr = CSR_READ(sc, AVERXC); CSR_WRITE(sc, AVERXC, rxcr &~ RXC_EN); /* stop Rx first */ + + /* adjust 802.3x PAUSE flow control */ if ((mii->mii_media_active & IFM_FDX) && (sc->sc_flowflags & IFM_ETH_TXPAUSE)) txcr |= TXC_FCE; @@ -656,9 +663,28 @@ mii_statchg(struct ifnet *ifp) rxcr |= RXC_FCE; else rxcr &= ~RXC_FCE; + + /* HW does not handle auto speed adjustment */ + txcr &= ~(TXC_SPD1000 | TXC_SPD100); + if ((sc->sc_phymode & CFG_MII) == 0 /* RGMII model */ + && IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_100_TX) + txcr |= TXC_SPD1000; + else if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_100_TX) + txcr |= TXC_SPD100; + + /* adjust LINKSEL when MII/RMII too */ + if (sc->sc_phymode & CFG_MII) { + csr = CSR_READ(sc, AVELINKSEL); + if (IFM_SUBTYPE(ifm->ifm_cur->ifm_media) == IFM_100_TX) + csr |= LINKSEL_SPD100; + else + csr &= ~LINKSEL_SPD100; + CSR_WRITE(sc, AVELINKSEL, csr); + } + sc->sc_rxc = rxcr; CSR_WRITE(sc, AVETXC, txcr); - CSR_WRITE(sc, AVERXC, rxcr); + CSR_WRITE(sc, AVERXC, rxcr | RXC_EN); printf("%ctxfe, %crxfe\n", (txcr & TXC_FCE) ? '+' : '-', (rxcr & RXC_FCE) ? '+' : '-'); @@ -776,22 +802,25 @@ ave_ioctl(struct ifnet *ifp, u_long cmd, static void ave_write_filt(struct ave_softc *sc, int i, const uint8_t *en) { - uint32_t n, macl, mach; + uint32_t macl, mach, n, mskbyte0; - /* pick v4mcast or v6mcast length */ - n = (en[0] == 0x01) ? 3 : (en[0] == 0x33) ? 2 : ETHER_ADDR_LEN; macl = mach = 0; macl |= (en[3]<<24) | (en[2]<<16)| (en[1]<<8) | en[0]; mach |= (en[5]<<8) | en[4]; + /* pick v4mcast or v6mcast length */ + n = (en[0] == 0x01) ? 3 : (en[0] == 0x33) ? 2 : ETHER_ADDR_LEN; + /* entry 0 is reserved for promisc mode */ + mskbyte0 = (i > 0) ? genmask0(n) : MSKBYTE0; + /* set frame address first */ CSR_WRITE(sc, AVEAFB + (i * 0x40) + 0, macl); CSR_WRITE(sc, AVEAFB + (i * 0x40) + 4, mach); /* set byte mask according to mask length, any of 6, 3, or 2 */ - CSR_WRITE(sc, AVEAFMSKB + (i * 8) + 0, genmask0(n)); + CSR_WRITE(sc, AVEAFMSKB + (i * 8) + 0, mskbyte0); CSR_WRITE(sc, AVEAFMSKB + (i * 8) + 4, MSKBYTE1); /* set bit vector mask */ CSR_WRITE(sc, AVEAFMSKV + (i * 4), 0x); - /* use Rx ring 0 for any entry */ + /* use Rx ring 0 anyway */ CSR_WRITE(sc, AVEAFRING + (i * 4), 0);
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Sat Mar 21 07:16:16 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_ave.c Log Message: make comments about descriptor storage design detail To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sociox/if_ave.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_ave.c diff -u src/sys/arch/arm/sociox/if_ave.c:1.5 src/sys/arch/arm/sociox/if_ave.c:1.6 --- src/sys/arch/arm/sociox/if_ave.c:1.5 Sat Mar 21 04:35:20 2020 +++ src/sys/arch/arm/sociox/if_ave.c Sat Mar 21 07:16:16 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ave.c,v 1.5 2020/03/21 04:35:20 nisimura Exp $ */ +/* $NetBSD: if_ave.c,v 1.6 2020/03/21 07:16:16 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -30,11 +30,13 @@ */ /* - * Socionext Uniphier AVE GbE driver + * Socionext UniPhier AVE GbE driver + * + * There are two groups for 64bit paddr model and 32bit paddr. */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.5 2020/03/21 04:35:20 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.6 2020/03/21 07:16:16 nisimura Exp $"); #include #include @@ -125,15 +127,13 @@ __KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1 #define AVEAFRING 0x0f00 /* entry ring number selector */ #define AVEAFEN 0x0ffc /* entry enable bit vector */ -#define AVETDB 0x1000 /* 64bit Tx descriptor storage base */ -#define AVERDB 0x1c00 /* 64bit Rx descriptor storage base */ -#define AVE32TDB 0x1000 /* 32bit Tx descriptor storage base */ -#define AVE32RDB 0x1800 /* 32bit Rx descriptor storage base */ +#define AVETDB 0x1000 /* 64bit Tx descriptor store, upto 256 */ +#define AVERDB 0x1c00 /* 64bit Rx descriptor store, upto 2048 */ +#define AVE32TDB 0x1000 /* 32bit Tx store base, upto 256 */ +#define AVE32RDB 0x1800 /* 32bit Rx store base, upto 2048 */ /* * descriptor size is 12 bytes when 64bit paddr design, 8 bytes otherwise. - * 3KB/24KB split or 64bit paddr Tx/Rx descriptor storage. - * 2KB/16KB split or 32bit paddr Tx/Rx descriptor storage. */ struct tdes { uint32_t t0, t1, t2; @@ -165,10 +165,10 @@ struct rdes32 { uint32_t r0, r1; }; /* R2 frame address 63:32 */ #define AVE_NTXSEGS 16 -#define AVE_TXQUEUELEN 8 +#define AVE_TXQUEUELEN (AVE_NTXDESC / AVE_NTXSEGS) #define AVE_TXQUEUELEN_MASK (AVE_TXQUEUELEN - 1) #define AVE_TXQUEUE_GC (AVE_TXQUEUELEN / 4) -#define AVE_NTXDESC (AVE_TXQUEUELEN * AVE_NTXSEGS) +#define AVE_NTXDESC 256 /* HW limit */ #define AVE_NTXDESC_MASK (AVE_NTXDESC - 1) #define AVE_NEXTTX(x) (((x) + 1) & AVE_NTXDESC_MASK) #define AVE_NEXTTXS(x) (((x) + 1) & AVE_TXQUEUELEN_MASK) @@ -232,8 +232,8 @@ struct ave_softc { bus_dmamap_t sc_cddmamap; /* control data DMA map */ #define sc_cddma sc_cddmamap->dm_segs[0].ds_addr - struct tdes *sc_txdescs; /* PTR to tdes [NTXDESC] array */ - struct rdes *sc_rxdescs; /* PTR to rdes [NRXDESC] array */ + struct tdes *sc_txdescs; /* PTR to tdes [NTXDESC] store */ + struct rdes *sc_rxdescs; /* PTR to rdes [NRXDESC] store */ struct tdes32 *sc_txd32; struct rdes32 *sc_rxd32; @@ -344,19 +344,19 @@ ave_fdt_attach(device_t parent, device_t hwver = CSR_READ(sc, AVEHWVER); sc->sc_model = of_search_compatible(phandle, compat_data)->data; - aprint_naive("\n"); - aprint_normal(": Gigabit Ethernet Controller\n"); - aprint_normal_dev(self, "UniPhier %c%c%c%c AVE %d GbE (%d.%d)\n", - hwimp >> 24, hwimp >> 16, hwimp >> 8, hwimp, - sc->sc_model, - hwver >> 8, hwver & 0xff); - aprint_normal_dev(self, "interrupt on %s\n", intrstr); - phy_mode = fdtbus_get_string(phandle, "phy-mode"); if (phy_mode == NULL) { aprint_error(": missing 'phy-mode' property\n"); phy_mode = "rgmii"; } + + aprint_naive("\n"); + aprint_normal(": Gigabit Ethernet Controller\n"); + aprint_normal_dev(self, "UniPhier %c%c%c%c AVE %d GbE (%d.%d) %s\n", + hwimp >> 24, hwimp >> 16, hwimp >> 8, hwimp, + sc->sc_model, hwver >> 8, hwver & 0xff, phy_mode); + aprint_normal_dev(self, "interrupt on %s\n", intrstr); + if (strcmp(phy_mode, "rgmii") == 0) sc->sc_phymode = 0; /* RGMII */ else @@ -423,14 +423,15 @@ ave_fdt_attach(device_t parent, device_t callout_setfunc(>sc_tick_ch, phy_tick, sc); /* - * no need to build Tx/Rx descriptor control_data. - * go straight to make dmamap to hold Tx segments/Rx frames. + * HW has a dedicated store to hold Tx/Rx descriptor arrays. + * so no need to build Tx/Rx descriptor control_data. + * go straight to make dmamap to hold Tx segments and Rx frames. */ for (i = 0; i < AVE_TXQUEUELEN; i++) { if ((error = bus_dmamap_create(sc->sc_dmat, MCLBYTES, AVE_NTXSEGS, MCLBYTES, 0, 0, >sc_txsoft[i].txs_dmamap)) != 0) { - aprint_error_dev(sc->sc_dev, + aprint_error_dev(self, "unable to create tx DMA map %d, error = %d\n", i, error); goto fail_4; @@ -439,7
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Sat Mar 21 04:35:20 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_ave.c Log Message: more on toward dual descriptor design To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/sociox/if_ave.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_ave.c diff -u src/sys/arch/arm/sociox/if_ave.c:1.4 src/sys/arch/arm/sociox/if_ave.c:1.5 --- src/sys/arch/arm/sociox/if_ave.c:1.4 Sat Mar 21 01:17:51 2020 +++ src/sys/arch/arm/sociox/if_ave.c Sat Mar 21 04:35:20 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ave.c,v 1.4 2020/03/21 01:17:51 nisimura Exp $ */ +/* $NetBSD: if_ave.c,v 1.5 2020/03/21 04:35:20 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.4 2020/03/21 01:17:51 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.5 2020/03/21 04:35:20 nisimura Exp $"); #include #include @@ -125,16 +125,13 @@ __KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1 #define AVEAFRING 0x0f00 /* entry ring number selector */ #define AVEAFEN 0x0ffc /* entry enable bit vector */ -#ifdef _LP64 #define AVETDB 0x1000 /* 64bit Tx descriptor storage base */ #define AVERDB 0x1c00 /* 64bit Rx descriptor storage base */ -#else -#define AVETDB 0x1000 /* 32bit Tx descriptor storage base */ -#define AVERDB 0x1800 /* 32bit Rx descriptor storage base */ -#endif +#define AVE32TDB 0x1000 /* 32bit Tx descriptor storage base */ +#define AVE32RDB 0x1800 /* 32bit Rx descriptor storage base */ /* - * descriptor size is 12 bytes when _LP64, 8 bytes otherwise. + * descriptor size is 12 bytes when 64bit paddr design, 8 bytes otherwise. * 3KB/24KB split or 64bit paddr Tx/Rx descriptor storage. * 2KB/16KB split or 32bit paddr Tx/Rx descriptor storage. */ @@ -146,6 +143,9 @@ struct rdes { uint32_t r0, r1, r2; }; +struct tdes32 { uint32_t t0, t1; }; +struct rdes32 { uint32_t r0, r1; }; + #define T0_OWN (1U<<31) /* desc is ready to Tx */ #define T0_IOC (1U<<29) /* post interrupt on Tx completes */ #define T0_NOCSUM (1U<<28) /* inhibit checksum operation */ @@ -177,7 +177,6 @@ struct rdes { #define AVE_NRXDESC_MASK (AVE_NRXDESC - 1) #define AVE_NEXTRX(x) (((x) + 1) & AVE_NRXDESC_MASK) -#ifdef _LP64 #define AVE_INIT_RXDESC(sc, x) \ do { \ struct ave_rxsoft *__rxs = &(sc)->sc_rxsoft[(x)]; \ @@ -189,18 +188,17 @@ do { \ __rxd->r1 = htole32(BUS_ADDR_LO32(__paddr)); \ __rxd->r0 = R0_OWN | R0_FL_MASK;\ } while (/*CONSTCOND*/0) -#else -#define AVE_INIT_RXDESC(sc, x) \ + +#define AVE32_INIT_RXDESC(sc, x) \ do { \ struct ave_rxsoft *__rxs = &(sc)->sc_rxsoft[(x)]; \ - struct rdes *__rxd = &(sc)->sc_rxdescs[(x)]; \ + struct rdes32 *__rxd = &(sc)->sc_rxd32[(x)]; \ struct mbuf *__m = __rxs->rxs_mbuf;\ bus_addr_t __paddr =__rxs->rxs_dmamap->dm_segs[0].ds_addr; \ __m->m_data = __m->m_ext.ext_buf;\ __rxd->r1 = htole32(__paddr); \ __rxd->r0 = R0_OWN | R0_FL_MASK;\ } while (/*CONSTCOND*/0) -#endif struct ave_txsoft { struct mbuf *txs_mbuf; /* head of our mbuf chain */ @@ -236,6 +234,8 @@ struct ave_softc { struct tdes *sc_txdescs; /* PTR to tdes [NTXDESC] array */ struct rdes *sc_rxdescs; /* PTR to rdes [NRXDESC] array */ + struct tdes32 *sc_txd32; + struct rdes32 *sc_rxd32; struct ave_txsoft sc_txsoft[AVE_TXQUEUELEN]; struct ave_rxsoft sc_rxsoft[AVE_NRXDESC]; @@ -515,6 +515,8 @@ ave_init(struct ifnet *ifp) /* set ptr to Tx/Rx descriptor store */ sc->sc_txdescs = (void *)((uintptr_t)sc->sc_sh + AVETDB); sc->sc_rxdescs = (void *)((uintptr_t)sc->sc_sh + AVERDB); + sc->sc_txd32 = (void *)((uintptr_t)sc->sc_sh + AVE32TDB); + sc->sc_rxd32 = (void *)((uintptr_t)sc->sc_sh + AVE32RDB); /* build sane and loaded Tx/Rx descriptors */ memset(sc->sc_txdescs, 0, sizeof(struct tdes)*AVE_NTXDESC); @@ -969,12 +971,8 @@ ave_start(struct ifnet *ifp) * yet. That could cause a race condition. * We'll do it below. */ -#ifdef _LP64 tdes->t2 = htole32(BUS_ADDR_HI32(paddr)); tdes->t1 = htole32(BUS_ADDR_LO32(paddr)); -#else - tdes->t1 = htole32(paddr); -#endif tdes->t0 = tdes0 | sc->sc_t0csum | (dmamap->dm_segs[seg].ds_len & T0_TBS_MASK); tdes0 = T0_OWN; /* 2nd and other segments */
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Sat Mar 21 01:17:51 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_ave.c Log Message: - add missing RXC_EN bit to resume receiving. - an inch forward to absorb incompatible descriptor designs. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sociox/if_ave.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_ave.c diff -u src/sys/arch/arm/sociox/if_ave.c:1.3 src/sys/arch/arm/sociox/if_ave.c:1.4 --- src/sys/arch/arm/sociox/if_ave.c:1.3 Fri Mar 20 12:29:09 2020 +++ src/sys/arch/arm/sociox/if_ave.c Sat Mar 21 01:17:51 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ave.c,v 1.3 2020/03/20 12:29:09 nisimura Exp $ */ +/* $NetBSD: if_ave.c,v 1.4 2020/03/21 01:17:51 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.3 2020/03/20 12:29:09 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.4 2020/03/21 01:17:51 nisimura Exp $"); #include #include @@ -139,17 +139,11 @@ __KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1 * 2KB/16KB split or 32bit paddr Tx/Rx descriptor storage. */ struct tdes { - uint32_t t0, t1; -#ifdef _LP64 - uint32_t t2; -#endif + uint32_t t0, t1, t2; }; struct rdes { - uint32_t r0, r1; -#ifdef _LP64 - uint32_t r2; -#endif + uint32_t r0, r1, r2; }; #define T0_OWN (1U<<31) /* desc is ready to Tx */ @@ -235,6 +229,7 @@ struct ave_softc { int sc_phy_id; /* PHY address */ uint32_t sc_phymode; /* 1<<27: MII/RMII, 0: RGMII */ uint32_t sc_rxc; /* software copy of AVERXC */ + int sc_model; /* 64 paddr model or otherwise 32 */ bus_dmamap_t sc_cddmamap; /* control data DMA map */ #define sc_cddma sc_cddmamap->dm_segs[0].ds_addr @@ -286,20 +281,21 @@ static int add_rxbuf(struct ave_softc *, #define CSR_WRITE(sc, off, val) \ bus_space_write_4((sc)->sc_st, (sc)->sc_sh, (off), (val)) +static const struct of_compat_data compat_data[] = { + { "socionext,unifier-ld20-ave4", 64 }, + { "socionext,unifier-pro4-ave4", 32 }, + { "socionext,unifier-pxs2-ave4", 32 }, + { "socionext,unifier-ld11-ave4", 32 }, + { "socionext,unifier-pxs3-ave4", 32 }, + { NULL } +}; + static int ave_fdt_match(device_t parent, cfdata_t cf, void *aux) { - static const char * compatible[] = { - "socionext,unifier-ld20-ave4", - "socionext,unifier-pro4-ave4", - "socionext,unifier-pxs2-ave4", - "socionext,unifier-ld11-ave4", - "socionext,unifier-pxs3-ave4", - NULL - }; struct fdt_attach_args * const faa = aux; - return of_match_compatible(faa->faa_phandle, compatible); + return of_match_compat_data(faa->faa_phandle, compat_data); } static void @@ -346,11 +342,13 @@ ave_fdt_attach(device_t parent, device_t hwimp = CSR_READ(sc, AVEID); hwver = CSR_READ(sc, AVEHWVER); + sc->sc_model = of_search_compatible(phandle, compat_data)->data; aprint_naive("\n"); aprint_normal(": Gigabit Ethernet Controller\n"); - aprint_normal_dev(self, "UniPhier %c%c%c%c AVE GbE (%d.%d)\n", + aprint_normal_dev(self, "UniPhier %c%c%c%c AVE %d GbE (%d.%d)\n", hwimp >> 24, hwimp >> 16, hwimp >> 8, hwimp, + sc->sc_model, hwver >> 8, hwver & 0xff); aprint_normal_dev(self, "interrupt on %s\n", intrstr); @@ -613,7 +611,7 @@ ave_ifmedia_upd(struct ifnet *ifp) } sc->sc_rxc = rxcr; CSR_WRITE(sc, AVETXC, txcr); - CSR_WRITE(sc, AVERXC, rxcr); + CSR_WRITE(sc, AVERXC, rxcr | RXC_EN); return 0; }
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Fri Mar 20 12:29:09 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_ave.c Log Message: use correct product name. still unfinished To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sociox/if_ave.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_ave.c diff -u src/sys/arch/arm/sociox/if_ave.c:1.2 src/sys/arch/arm/sociox/if_ave.c:1.3 --- src/sys/arch/arm/sociox/if_ave.c:1.2 Fri Mar 20 09:41:24 2020 +++ src/sys/arch/arm/sociox/if_ave.c Fri Mar 20 12:29:09 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ave.c,v 1.2 2020/03/20 09:41:24 nisimura Exp $ */ +/* $NetBSD: if_ave.c,v 1.3 2020/03/20 12:29:09 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.2 2020/03/20 09:41:24 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.3 2020/03/20 12:29:09 nisimura Exp $"); #include #include @@ -321,19 +321,22 @@ ave_fdt_attach(device_t parent, device_t uint8_t enaddr[ETHER_ADDR_LEN]; int i, error = 0; - if (fdtbus_get_reg(phandle, 0, , ) != 0) { - aprint_error(": couldn't get registers\n"); - return; - } - error = bus_space_map(bst, addr, size, 0, ); - if (error) { - aprint_error(": couldn't map registers: %d\n", error); + if (fdtbus_get_reg(phandle, 0, , ) != 0 + || bus_space_map(faa->faa_bst, addr, size, 0, ) != 0) { + aprint_error(": unable to map device\n"); return; } if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) { aprint_error(": failed to decode interrupt\n"); return; } + sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_NET, 0, + ave_intr, sc); + if (sc->sc_ih == NULL) { + aprint_error_dev(self, "couldn't establish interrupt on %s\n", + intrstr); + goto fail; + } sc->sc_dev = self; sc->sc_st = bst; @@ -341,25 +344,20 @@ ave_fdt_attach(device_t parent, device_t sc->sc_mapsize = size; sc->sc_dmat = faa->faa_dmat; - aprint_naive("\n"); - aprint_normal(": Gigabit Ethernet Controller\n"); - hwimp = CSR_READ(sc, AVEID); hwver = CSR_READ(sc, AVEHWVER); - aprint_normal_dev(self, "Unifier %c%c%c%c GbE (%d.%d)\n", + + aprint_naive("\n"); + aprint_normal(": Gigabit Ethernet Controller\n"); + aprint_normal_dev(self, "UniPhier %c%c%c%c AVE GbE (%d.%d)\n", hwimp >> 24, hwimp >> 16, hwimp >> 8, hwimp, hwver >> 8, hwver & 0xff); - - sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_NET, - FDT_INTR_FLAGS, ave_intr, sc); - if (sc->sc_ih == NULL) - goto fail; aprint_normal_dev(self, "interrupt on %s\n", intrstr); phy_mode = fdtbus_get_string(phandle, "phy-mode"); if (phy_mode == NULL) { aprint_error(": missing 'phy-mode' property\n"); - return; + phy_mode = "rgmii"; } if (strcmp(phy_mode, "rgmii") == 0) sc->sc_phymode = 0; /* RGMII */
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Fri Mar 20 09:41:24 UTC 2020 Modified Files: src/sys/arch/arm/sociox: if_ave.c Log Message: remove #ifdef _LP64 as jmcneil@ suggested To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sociox/if_ave.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/if_ave.c diff -u src/sys/arch/arm/sociox/if_ave.c:1.1 src/sys/arch/arm/sociox/if_ave.c:1.2 --- src/sys/arch/arm/sociox/if_ave.c:1.1 Fri Mar 20 00:27:58 2020 +++ src/sys/arch/arm/sociox/if_ave.c Fri Mar 20 09:41:24 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: if_ave.c,v 1.1 2020/03/20 00:27:58 nisimura Exp $ */ +/* $NetBSD: if_ave.c,v 1.2 2020/03/20 09:41:24 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.1 2020/03/20 00:27:58 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.2 2020/03/20 09:41:24 nisimura Exp $"); #include #include @@ -290,14 +290,11 @@ static int ave_fdt_match(device_t parent, cfdata_t cf, void *aux) { static const char * compatible[] = { -#ifdef _LP64 "socionext,unifier-ld20-ave4", -#else "socionext,unifier-pro4-ave4", "socionext,unifier-pxs2-ave4", "socionext,unifier-ld11-ave4", "socionext,unifier-pxs3-ave4", -#endif NULL }; struct fdt_attach_args * const faa = aux;
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Fri Mar 20 00:27:58 UTC 2020 Added Files: src/sys/arch/arm/sociox: if_ave.c Log Message: Socionext AVE GbE driver for UniPhier SoC family. To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/sociox/if_ave.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/sys/arch/arm/sociox/if_ave.c diff -u /dev/null src/sys/arch/arm/sociox/if_ave.c:1.1 --- /dev/null Fri Mar 20 00:27:58 2020 +++ src/sys/arch/arm/sociox/if_ave.c Fri Mar 20 00:27:58 2020 @@ -0,0 +1,1205 @@ +/* $NetBSD: if_ave.c,v 1.1 2020/03/20 00:27:58 nisimura Exp $ */ + +/*- + * Copyright (c) 2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Tohru Nishimura. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Socionext Uniphier AVE GbE driver + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: if_ave.c,v 1.1 2020/03/20 00:27:58 nisimura Exp $"); + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include + +#define FDT_INTR_FLAGS (0) /* !MP_SAFE */ + +#define AVEID 0x000 /* hardware ID */ +#define AVEHWVER 0x004 /* hardware version */ +#define AVEGR 0x008 /* chip global control */ +#define GR_RXRST (1U<<5) /* RxFIFO reset */ +#define GR_PHYRST (1U<<4) /* external PHY reset */ +#define GR_GRST (1U<<0) /* full chip reset */ +#define AVECFG 0x00c /* hw configuration */ +#define CFG_FLE (1U<<31) /* filter function enable */ +#define CFG_CKE (1U<<30) /* checksum enable */ +#define CFG_MII (1U<<27) /* 1: MII/RMII, 0: RGMII */ +#define CFG_IPFCKE (1U<<24) /* IP framgment csum enable */ +#define AVEGIMR 0x100 /* global interrupt mask */ +#define AVEGISR 0x104 /* global interrupt status */ +#define GISR_PHY (1U<<24) /* PHY status change detected */ +#define GISR_TXCI (1U<<16) /* transmission completed */ +#define GISR_RXERR (1U<<8) /* Rx frame error detected */ +#define GISR_RXOVF (1U<<7) /* Rx oveflow detected */ +#define GISR_RXDROP (1U<<6) /* Rx has been dropped */ +#define GISR_RXIT (1U<<5) /* receive itimer notify */ +#define AVETXC 0x200 /* transmit control */ +#define TXC_FCE (1U<<18) /* enable Tx flow control */ +#define TXC_SPD1000 (1U<<17) /* use 1000Mbps */ +#define TXC_SPD100 (1U<<16) /* use 100Mbps */ +#define AVERXC 0x204 /* receive control */ +#define RXC_EN (1U<<30) /* enable receive circuit */ +#define RXC_USEFDX (1U<<22) /* use full-duplex */ +#define RXC_FCE (1U<<21) /* enable Rx flow control */ +#define RXC_AFE (1U<<19) /* use address filter (!promisc) */ +#define RXC_DRPEN (1U<<18) /* drop receiving PAUSE frames */ +/* RXC 15:0 max frame length to accept */ +#define AVEMACL 0x208 /* MAC address lower */ +#define AVEMACH 0x20c /* MAC address upper */ +#define AVEMDIOC 0x214 /* MDIO control */ +#define MDIOC_RD (1U<<3) /* read op */ +#define MDIOC_WR (1U<<2) /* write op */ +#define AVEMDADR 0x218 /* MDIO address -- 13:8 phy id */ +#define AVEMDWRD 0x21c /* MDIO write data - 15:0 */ +#define AVEMDIOS 0x220 /* MDIO status */ +#define MDIOS_BUSY (1U<<0) /* MDIO in progress */ +#define AVEMDRDD 0x224 /* MDIO read data */ +#define AVEDESCC 0x300 /* descriptor control */ +#define DESCC_RD0 (1U<<3) /* activate Rx0 descriptor to run */ +#define DESCC_RSTP (1U<<2) /* pause Rx descriptor */ +#define DESCC_TD (1U<<0) /* activate Tx descriptor to run */ + /* 31:16 status report to read */ +#define
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Thu Mar 19 22:17:45 UTC 2020 Modified Files: src/sys/arch/arm/sociox: files.sociox sni_exiu.c Log Message: make sni_exiu.c fdt/ACPI dual attach device To generate a diff of this commit: cvs rdiff -u -r1.8 -r1.9 src/sys/arch/arm/sociox/files.sociox cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sociox/sni_exiu.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/files.sociox diff -u src/sys/arch/arm/sociox/files.sociox:1.8 src/sys/arch/arm/sociox/files.sociox:1.9 --- src/sys/arch/arm/sociox/files.sociox:1.8 Thu Mar 19 20:53:53 2020 +++ src/sys/arch/arm/sociox/files.sociox Thu Mar 19 22:17:45 2020 @@ -1,4 +1,4 @@ -# $NetBSD: files.sociox,v 1.8 2020/03/19 20:53:53 nisimura Exp $ +# $NetBSD: files.sociox,v 1.9 2020/03/19 22:17:45 nisimura Exp $ # # Configuration info for Socionext Unifier/SC2A11 # @@ -35,5 +35,6 @@ file arch/arm/sociox/sni_gpio.c snigpio # Socionext EXIU external interrupt controller unit device sniexiu -attach sniexiu at fdt +attach sniexiu at acpinodebus with sniexitu_acpi +attach sniexiu at fdt with sniexiu_fdt file arch/arm/sociox/sni_exiu.c sniexiu Index: src/sys/arch/arm/sociox/sni_exiu.c diff -u src/sys/arch/arm/sociox/sni_exiu.c:1.1 src/sys/arch/arm/sociox/sni_exiu.c:1.2 --- src/sys/arch/arm/sociox/sni_exiu.c:1.1 Wed Mar 18 08:51:08 2020 +++ src/sys/arch/arm/sociox/sni_exiu.c Thu Mar 19 22:17:45 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sni_exiu.c,v 1.1 2020/03/18 08:51:08 nisimura Exp $ */ +/* $NetBSD: sni_exiu.c,v 1.2 2020/03/19 22:17:45 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sni_exiu.c,v 1.1 2020/03/18 08:51:08 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sni_exiu.c,v 1.2 2020/03/19 22:17:45 nisimura Exp $"); #include #include @@ -45,9 +45,14 @@ __KERNEL_RCSID(0, "$NetBSD: sni_exiu.c,v #include #include - -static int sniexiu_match(device_t, struct cfdata *, void *); -static void sniexiu_attach(device_t, device_t, void *); +#include +#include +#include + +static int sniexiu_fdt_match(device_t, struct cfdata *, void *); +static void sniexiu_fdt_attach(device_t, device_t, void *); +static int sniexiu_acpi_match(device_t, struct cfdata *, void *); +static void sniexiu_acpi_attach(device_t, device_t, void *); struct sniexiu_softc { device_t sc_dev; @@ -55,15 +60,22 @@ struct sniexiu_softc { bus_space_handle_t sc_ioh; bus_addr_t sc_iob; bus_size_t sc_ios; + kmutex_t sc_lock; + void *sc_ih; int sc_phandle; }; -CFATTACH_DECL_NEW(sniexiu, sizeof(struct sniexiu_softc), -sniexiu_match, sniexiu_attach, NULL, NULL); +CFATTACH_DECL_NEW(sniexiu_fdt, sizeof(struct sniexiu_softc), +sniexiu_fdt_match, sniexiu_fdt_attach, NULL, NULL); + +CFATTACH_DECL_NEW(sniexiu_acpi, sizeof(struct sniexiu_softc), +sniexiu_acpi_match, sniexiu_acpi_attach, NULL, NULL); + +static void sniexiu_attach_i(struct sniexiu_softc *); +static int sniexiu_intr(void *); -/* ARGSUSED */ static int -sniexiu_match(device_t parent, struct cfdata *match, void *aux) +sniexiu_fdt_match(device_t parent, struct cfdata *match, void *aux) { static const char * compatible[] = { "socionext,synquacer-exiu", @@ -74,9 +86,8 @@ sniexiu_match(device_t parent, struct cf return of_match_compatible(faa->faa_phandle, compatible); } -/* ARGSUSED */ static void -sniexiu_attach(device_t parent, device_t self, void *aux) +sniexiu_fdt_attach(device_t parent, device_t self, void *aux) { struct sniexiu_softc * const sc = device_private(self); struct fdt_attach_args * const faa = aux; @@ -111,15 +122,111 @@ sniexiu_attach(device_t parent, device_t return; } - aprint_naive(": External IRQ controller\n"); - aprint_normal(": External IRQ controller\n"); - sc->sc_dev = self; sc->sc_phandle = phandle; sc->sc_iot = faa->faa_bst; sc->sc_ioh = ioh; sc->sc_iob = addr; sc->sc_ios = size; + mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_NONE); + sc->sc_ih = fdtbus_intr_establish(phandle, + 0, IPL_NET, 0, sniexiu_intr, sc); + if (sc->sc_ih == NULL) { + aprint_error_dev(self, "couldn't establish interrupt\n"); + goto fail; + } + + sniexiu_attach_i(sc); + return; + fail: + bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_ios); return; } + +static int +sniexiu_acpi_match(device_t parent, struct cfdata *match, void *aux) +{ + static const char * compatible[] = { + "SCX0008", + NULL + }; + struct acpi_attach_args *aa = aux; + + if (aa->aa_node->ad_type != ACPI_TYPE_DEVICE) + return 0; + return acpi_match_hid(aa->aa_node->ad_devinfo, compatible); +} + +static void +sniexiu_acpi_attach(device_t parent, device_t self, void *aux) +{ + struct sniexiu_softc * const sc = device_private(self); + struct acpi_attach_args *aa = aux; + bus_space_handle_t ioh; + struct acpi_resources res; + struct acpi_mem *mem; +
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Thu Mar 19 20:53:53 UTC 2020 Modified Files: src/sys/arch/arm/sociox: files.sociox sni_gpio.c Log Message: make sni_gpio.c fdt/ACPI dual attach device To generate a diff of this commit: cvs rdiff -u -r1.7 -r1.8 src/sys/arch/arm/sociox/files.sociox cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sociox/sni_gpio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/files.sociox diff -u src/sys/arch/arm/sociox/files.sociox:1.7 src/sys/arch/arm/sociox/files.sociox:1.8 --- src/sys/arch/arm/sociox/files.sociox:1.7 Wed Mar 18 08:49:51 2020 +++ src/sys/arch/arm/sociox/files.sociox Thu Mar 19 20:53:53 2020 @@ -1,4 +1,4 @@ -# $NetBSD: files.sociox,v 1.7 2020/03/18 08:49:51 nisimura Exp $ +# $NetBSD: files.sociox,v 1.8 2020/03/19 20:53:53 nisimura Exp $ # # Configuration info for Socionext Unifier/SC2A11 # @@ -6,31 +6,31 @@ # SC2A11 SynQuacer NetSec GbE device scx: ether, ifnet, arp, mii, bus_dma_generic -attach scx at fdt with scx_fdt attach scx at acpinodebus with scx_acpi +attach scx at fdt with scx_fdt file arch/arm/sociox/if_scx.c scx # Unifier AVE GbE device ave: ether, ifnet, arp, mii, bus_dma_generic attach ave at fdt with ave_fdt -attach ave at acpinodebus with ave_acpi file arch/arm/sociox/if_ave.c ave # Socionext eMMC device sniemmc: sdmmcbus -attach sniemmc at fdt with sniemmc_fdt attach sniemmc at acpinodebus with sniemmc_acpi +attach sniemmc at fdt with sniemmc_fdt file arch/arm/sociox/sni_emmc.c sniemmc # Socionext I2C device sniiic: i2cbus -attach sniiic at fdt with sniiic_fdt attach sniiic at acpinodebus with sniiic_acpi +attach sniiic at fdt with sniiic_fdt file arch/arm/sociox/sni_i2c.c sniiic needs-flag # Socionext GPIO device snigpio: gpiobus -attach snigpio at fdt +attach snigpio at acpinodebus with snigpio_acpi +attach snigpio at fdt with snigpio_fdt file arch/arm/sociox/sni_gpio.c snigpio # Socionext EXIU external interrupt controller unit Index: src/sys/arch/arm/sociox/sni_gpio.c diff -u src/sys/arch/arm/sociox/sni_gpio.c:1.1 src/sys/arch/arm/sociox/sni_gpio.c:1.2 --- src/sys/arch/arm/sociox/sni_gpio.c:1.1 Wed Mar 18 08:51:08 2020 +++ src/sys/arch/arm/sociox/sni_gpio.c Thu Mar 19 20:53:53 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sni_gpio.c,v 1.1 2020/03/18 08:51:08 nisimura Exp $ */ +/* $NetBSD: sni_gpio.c,v 1.2 2020/03/19 20:53:53 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sni_gpio.c,v 1.1 2020/03/18 08:51:08 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sni_gpio.c,v 1.2 2020/03/19 20:53:53 nisimura Exp $"); #include #include @@ -49,9 +49,14 @@ __KERNEL_RCSID(0, "$NetBSD: sni_gpio.c,v #include #include - -static int snigpio_match(device_t, struct cfdata *, void *); -static void snigpio_attach(device_t, device_t, void *); +#include +#include +#include + +static int snigpio_fdt_match(device_t, struct cfdata *, void *); +static void snigpio_fdt_attach(device_t, device_t, void *); +static int snigpio_acpi_match(device_t, struct cfdata *, void *); +static void snigpio_acpi_attach(device_t, device_t, void *); struct snigpio_softc { device_t sc_dev; @@ -66,11 +71,16 @@ struct snigpio_softc { int sc_phandle; }; -CFATTACH_DECL_NEW(snigpio, sizeof(struct snigpio_softc), -snigpio_match, snigpio_attach, NULL, NULL); +CFATTACH_DECL_NEW(snigpio_fdt, sizeof(struct snigpio_softc), +snigpio_fdt_match, snigpio_fdt_attach, NULL, NULL); + +CFATTACH_DECL_NEW(snigpio_acpi, sizeof(struct snigpio_softc), +snigpio_acpi_match, snigpio_acpi_attach, NULL, NULL); + +static void snigpio_attach_i(struct snigpio_softc *); static int -snigpio_match(device_t parent, struct cfdata *match, void *aux) +snigpio_fdt_match(device_t parent, struct cfdata *match, void *aux) { static const char * compatible[] = { "socionext,synquacer-gpio", @@ -83,13 +93,12 @@ snigpio_match(device_t parent, struct cf } static void -snigpio_attach(device_t parent, device_t self, void *aux) +snigpio_fdt_attach(device_t parent, device_t self, void *aux) { struct snigpio_softc * const sc = device_private(self); struct fdt_attach_args * const faa = aux; prop_dictionary_t dict = device_properties(self); const int phandle = faa->faa_phandle; - struct gpiobus_attach_args gba; bus_space_handle_t ioh; bus_addr_t addr; bus_size_t size; @@ -113,15 +122,80 @@ snigpio_attach(device_t parent, device_t return; } - aprint_naive(": GPIO controller\n"); - aprint_normal(": GPIO controller\n"); - sc->sc_dev = self; sc->sc_phandle = phandle; sc->sc_iot = faa->faa_bst; sc->sc_ioh = ioh; sc->sc_iob = addr; sc->sc_ios = size; + + snigpio_attach_i(sc); + + return; +} + +static int +snigpio_acpi_match(device_t parent, struct cfdata *match, void *aux) +{ + static const char * compatible[]
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Wed Mar 18 10:05:25 UTC 2020 Modified Files: src/sys/arch/arm/sociox: sni_emmc.c Log Message: attempt graceful failure To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sociox/sni_emmc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/sni_emmc.c diff -u src/sys/arch/arm/sociox/sni_emmc.c:1.2 src/sys/arch/arm/sociox/sni_emmc.c:1.3 --- src/sys/arch/arm/sociox/sni_emmc.c:1.2 Wed Mar 18 06:44:57 2020 +++ src/sys/arch/arm/sociox/sni_emmc.c Wed Mar 18 10:05:24 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sni_emmc.c,v 1.2 2020/03/18 06:44:57 nisimura Exp $ */ +/* $NetBSD: sni_emmc.c,v 1.3 2020/03/18 10:05:24 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sni_emmc.c,v 1.2 2020/03/18 06:44:57 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sni_emmc.c,v 1.3 2020/03/18 10:05:24 nisimura Exp $"); #include #include @@ -256,8 +256,10 @@ sniemmc_attach_i(device_t self) } return; fail: - fdtbus_intr_disestablish(sc->sc_phandle, sc->sc_ih); - acpi_intr_disestablish(sc->sc_ih); + if (sc->sc_phandle) + fdtbus_intr_disestablish(sc->sc_phandle, sc->sc_ih); + else + acpi_intr_disestablish(sc->sc_ih); sc->sc_ih = NULL; bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_ios); return;
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Wed Mar 18 08:51:08 UTC 2020 Added Files: src/sys/arch/arm/sociox: sni_exiu.c sni_gpio.c Log Message: add skelton external IRQ unit driver and GPIO driver. To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/sociox/sni_exiu.c \ src/sys/arch/arm/sociox/sni_gpio.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/sys/arch/arm/sociox/sni_exiu.c diff -u /dev/null src/sys/arch/arm/sociox/sni_exiu.c:1.1 --- /dev/null Wed Mar 18 08:51:08 2020 +++ src/sys/arch/arm/sociox/sni_exiu.c Wed Mar 18 08:51:08 2020 @@ -0,0 +1,125 @@ +/* $NetBSD: sni_exiu.c,v 1.1 2020/03/18 08:51:08 nisimura Exp $ */ + +/*- + * Copyright (c) 2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Tohru Nishimura. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Socionext SC2A11 SynQuacer EXIU external interrupt controller driver + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: sni_exiu.c,v 1.1 2020/03/18 08:51:08 nisimura Exp $"); + +#include +#include +#include +#include +#include +#include +#include + +#include + +static int sniexiu_match(device_t, struct cfdata *, void *); +static void sniexiu_attach(device_t, device_t, void *); + +struct sniexiu_softc { + device_t sc_dev; + bus_space_tag_t sc_iot; + bus_space_handle_t sc_ioh; + bus_addr_t sc_iob; + bus_size_t sc_ios; + int sc_phandle; +}; + +CFATTACH_DECL_NEW(sniexiu, sizeof(struct sniexiu_softc), +sniexiu_match, sniexiu_attach, NULL, NULL); + +/* ARGSUSED */ +static int +sniexiu_match(device_t parent, struct cfdata *match, void *aux) +{ + static const char * compatible[] = { + "socionext,synquacer-exiu", + NULL + }; + struct fdt_attach_args * const faa = aux; + + return of_match_compatible(faa->faa_phandle, compatible); +} + +/* ARGSUSED */ +static void +sniexiu_attach(device_t parent, device_t self, void *aux) +{ + struct sniexiu_softc * const sc = device_private(self); + struct fdt_attach_args * const faa = aux; + prop_dictionary_t dict = device_properties(self); + const int phandle = faa->faa_phandle; + bus_space_handle_t ioh; + bus_addr_t addr; + bus_size_t size; + char intrstr[128]; + _Bool disable; + int error; + + prop_dictionary_get_bool(dict, "disable", ); + if (disable) { + aprint_naive(": disabled\n"); + aprint_normal(": disabled\n"); + return; + } + error = fdtbus_get_reg(phandle, 0, , ); + if (error) { + aprint_error(": couldn't get registers\n"); + return; + } + error = bus_space_map(faa->faa_bst, addr, size, 0, ); + if (error) { + aprint_error(": unable to map device\n"); + return; + } + error = fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr)); + if (error) { + aprint_error(": failed to decode interrupt\n"); + return; + } + + aprint_naive(": External IRQ controller\n"); + aprint_normal(": External IRQ controller\n"); + + sc->sc_dev = self; + sc->sc_phandle = phandle; + sc->sc_iot = faa->faa_bst; + sc->sc_ioh = ioh; + sc->sc_iob = addr; + sc->sc_ios = size; + + return; +} Index: src/sys/arch/arm/sociox/sni_gpio.c diff -u /dev/null src/sys/arch/arm/sociox/sni_gpio.c:1.1 --- /dev/null Wed Mar 18 08:51:08 2020 +++ src/sys/arch/arm/sociox/sni_gpio.c Wed Mar 18 08:51:08 2020 @@ -0,0 +1,143 @@ +/* $NetBSD: sni_gpio.c,v 1.1 2020/03/18 08:51:08 nisimura Exp $ */ + +/*- + * Copyright (c) 2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Tohru Nishimura. + * + * Redistribution and use in source and binary forms,
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Wed Mar 18 08:49:51 UTC 2020 Modified Files: src/sys/arch/arm/sociox: files.sociox Log Message: add SynQuacer EXIU external IRQ unit driver desciption To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/sys/arch/arm/sociox/files.sociox Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/files.sociox diff -u src/sys/arch/arm/sociox/files.sociox:1.6 src/sys/arch/arm/sociox/files.sociox:1.7 --- src/sys/arch/arm/sociox/files.sociox:1.6 Wed Mar 18 03:49:17 2020 +++ src/sys/arch/arm/sociox/files.sociox Wed Mar 18 08:49:51 2020 @@ -1,4 +1,4 @@ -# $NetBSD: files.sociox,v 1.6 2020/03/18 03:49:17 nisimura Exp $ +# $NetBSD: files.sociox,v 1.7 2020/03/18 08:49:51 nisimura Exp $ # # Configuration info for Socionext Unifier/SC2A11 # @@ -32,3 +32,8 @@ file arch/arm/sociox/sni_i2c.c sniiic n device snigpio: gpiobus attach snigpio at fdt file arch/arm/sociox/sni_gpio.c snigpio + +# Socionext EXIU external interrupt controller unit +device sniexiu +attach sniexiu at fdt +file arch/arm/sociox/sni_exiu.c sniexiu
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Wed Mar 18 07:49:01 UTC 2020 Modified Files: src/sys/arch/arm/sociox: sni_i2c.c Log Message: enrich I2C driver realities to work a bit To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sociox/sni_i2c.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/sni_i2c.c diff -u src/sys/arch/arm/sociox/sni_i2c.c:1.2 src/sys/arch/arm/sociox/sni_i2c.c:1.3 --- src/sys/arch/arm/sociox/sni_i2c.c:1.2 Wed Mar 18 05:02:48 2020 +++ src/sys/arch/arm/sociox/sni_i2c.c Wed Mar 18 07:49:01 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sni_i2c.c,v 1.2 2020/03/18 05:02:48 nisimura Exp $ */ +/* $NetBSD: sni_i2c.c,v 1.3 2020/03/18 07:49:01 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -34,21 +34,30 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sni_i2c.c,v 1.2 2020/03/18 05:02:48 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sni_i2c.c,v 1.3 2020/03/18 07:49:01 nisimura Exp $"); + +#ifdef I2CDEBUG +#define DPRINTF(args) printf args +#else +#define DPRINTF(args) +#endif #include #include #include #include +#include +#include #include #include #include -#include +#include #include #include #include +#include static int sniiic_fdt_match(device_t, struct cfdata *, void *); static void sniiic_fdt_attach(device_t, device_t, void *); @@ -56,7 +65,19 @@ static int sniiic_acpi_match(device_t, s static void sniiic_acpi_attach(device_t, device_t, void *); struct sniiic_softc { - device_t sc_dev; + device_t sc_dev; + struct i2c_controller sc_ic; + device_t sc_i2cdev; + bus_space_tag_t sc_iot; + bus_space_handle_t sc_ioh; + bus_addr_t sc_iob; + bus_size_t sc_ios; + void *sc_ih; + kmutex_t sc_lock; + kmutex_t sc_mtx; + kcondvar_t sc_cv; + int sc_opflags; + bool sc_busy; }; CFATTACH_DECL_NEW(sniiic_fdt, sizeof(struct sniiic_softc), @@ -65,7 +86,19 @@ CFATTACH_DECL_NEW(sniiic_fdt, sizeof(str CFATTACH_DECL_NEW(sniiic_acpi, sizeof(struct sniiic_softc), sniiic_acpi_match, sniiic_acpi_attach, NULL, NULL); -static int sniiic_attach_i(struct sniiic_softc *); +static int sniiic_acquire_bus(void *, int); +static void sniiic_release_bus(void *, int); +static int sniiic_exec(void *, i2c_op_t, i2c_addr_t, const void *, + size_t, void *, size_t, int); + +static int sniiic_intr(void *); +static void sniiic_reset(struct sniiic_softc *); +static void sniiic_flush(struct sniiic_softc *); + +static i2c_tag_t sniiic_get_tag(device_t); +static const struct fdtbus_i2c_controller_func sniiic_funcs = { + .get_tag = sniiic_get_tag, +}; static int sniiic_fdt_match(device_t parent, struct cfdata *match, void *aux) @@ -83,10 +116,69 @@ static void sniiic_fdt_attach(device_t parent, device_t self, void *aux) { struct sniiic_softc * const sc = device_private(self); + struct fdt_attach_args * const faa = aux; + prop_dictionary_t dict = device_properties(self); + const int phandle = faa->faa_phandle; + bus_space_handle_t ioh; + bus_addr_t addr; + bus_size_t size; + void *ih; + char intrstr[128]; + _Bool disable; int error; - error = sniiic_attach_i(sc); - (void)error; + prop_dictionary_get_bool(dict, "disable", ); + if (disable) { + aprint_naive(": disabled\n"); + aprint_normal(": disabled\n"); + return; + } + error = fdtbus_get_reg(phandle, 0, , ); + if (error) { + aprint_error(": couldn't get registers\n"); + return; + } + error = bus_space_map(faa->faa_bst, addr, size, 0, ); + if (error) { + aprint_error(": unable to map device\n"); + return; + } + error = fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr)); + if (error) { + aprint_error(": failed to decode interrupt\n"); + return; + } + + aprint_naive(": I2C controller\n"); + aprint_normal(": I2C controller\n"); + + sc->sc_dev = self; + sc->sc_iot = faa->faa_bst; + sc->sc_ioh = ioh; + sc->sc_iob = addr; + sc->sc_ios = size; + mutex_init(>sc_lock, MUTEX_DEFAULT, IPL_NONE); + mutex_init(>sc_mtx, MUTEX_DEFAULT, IPL_NET); + cv_init(>sc_cv, "sniiic"); + sc->sc_ic.ic_cookie = sc; + sc->sc_ic.ic_acquire_bus = sniiic_acquire_bus; + sc->sc_ic.ic_release_bus = sniiic_release_bus; + sc->sc_ic.ic_exec = sniiic_exec; + + ih = fdtbus_intr_establish(phandle, 0, IPL_NET, 0, sniiic_intr, sc); + if (ih == NULL) { + aprint_error_dev(self, "couldn't establish interrupt\n"); + goto fail; + } + sc->sc_ih = ih; + + fdtbus_register_i2c_controller(self, phandle, _funcs); + fdtbus_attach_i2cbus(self, phandle, >sc_ic, iicbus_print); + + return; + fail: + bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_ios); + return; } static int @@ -107,14 +199,148 @@ static void sniiic_acpi_attach(device_t parent, device_t self, void *aux) { struct sniiic_softc * const sc = device_private(self); - int error; - - error = sniiic_attach_i(sc); - (void)error; + struct acpi_attach_args *aa = aux; + bus_space_handle_t ioh; + struct
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Wed Mar 18 06:44:57 UTC 2020 Modified Files: src/sys/arch/arm/sociox: sni_emmc.c Log Message: enrich eMMC driver realities to work a bit To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sociox/sni_emmc.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/sni_emmc.c diff -u src/sys/arch/arm/sociox/sni_emmc.c:1.1 src/sys/arch/arm/sociox/sni_emmc.c:1.2 --- src/sys/arch/arm/sociox/sni_emmc.c:1.1 Wed Mar 18 03:33:49 2020 +++ src/sys/arch/arm/sociox/sni_emmc.c Wed Mar 18 06:44:57 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sni_emmc.c,v 1.1 2020/03/18 03:33:49 nisimura Exp $ */ +/* $NetBSD: sni_emmc.c,v 1.2 2020/03/18 06:44:57 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sni_emmc.c,v 1.1 2020/03/18 03:33:49 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sni_emmc.c,v 1.2 2020/03/18 06:44:57 nisimura Exp $"); #include #include @@ -46,9 +46,14 @@ __KERNEL_RCSID(0, "$NetBSD: sni_emmc.c,v #include +#include +#include +#include + #include #include #include +#include static int sniemmc_fdt_match(device_t, struct cfdata *, void *); static void sniemmc_fdt_attach(device_t, device_t, void *); @@ -56,7 +61,17 @@ static int sniemmc_acpi_match(device_t, static void sniemmc_acpi_attach(device_t, device_t, void *); struct sniemmc_softc { - device_t sc_dev; + struct sdhc_softc sc; + bus_space_tag_t sc_iot; + bus_space_handle_t sc_ioh; + bus_addr_t sc_iob; + bus_size_t sc_ios; + struct sdhc_host *sc_hosts[1]; + void *sc_ih; + int sc_phandle; + bus_dmamap_t sc_dmamap; + bus_dma_segment_t sc_segs[1]; + kcondvar_t sc_cv; }; CFATTACH_DECL_NEW(sniemmc_fdt, sizeof(struct sniemmc_softc), @@ -65,7 +80,7 @@ CFATTACH_DECL_NEW(sniemmc_fdt, sizeof(st CFATTACH_DECL_NEW(sniemmc_acpi, sizeof(struct sniemmc_softc), sniemmc_acpi_match, sniemmc_acpi_attach, NULL, NULL); -static int sniemmc_attach_i(struct sniemmc_softc *); +static void sniemmc_attach_i(device_t); static int sniemmc_fdt_match(device_t parent, struct cfdata *match, void *aux) @@ -84,10 +99,67 @@ static void sniemmc_fdt_attach(device_t parent, device_t self, void *aux) { struct sniemmc_softc * const sc = device_private(self); + struct fdt_attach_args * const faa = aux; + prop_dictionary_t dict = device_properties(self); + const int phandle = faa->faa_phandle; + bus_space_handle_t ioh; + bus_addr_t addr; + bus_size_t size; + void *ih; + char intrstr[128]; + _Bool disable; int error; - error = sniemmc_attach_i(sc); - (void)error; + prop_dictionary_get_bool(dict, "disable", ); + if (disable) { + aprint_naive(": disabled\n"); + aprint_normal(": disabled\n"); + return; + } + error = fdtbus_get_reg(phandle, 0, , ); + if (error) { + aprint_error(": couldn't get registers\n"); + return; + } + error = bus_space_map(faa->faa_bst, addr, size, 0, ); + if (error) { + aprint_error(": unable to map device\n"); + return; + } + error = fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr)); + if (error) { + aprint_error(": failed to decode interrupt\n"); + return; + } + + aprint_naive(": SDHC controller\n"); + aprint_normal(": SDHC controller\n"); + + sc->sc.sc_dev = self; + sc->sc.sc_dmat = faa->faa_dmat; + sc->sc.sc_host = sc->sc_hosts; + sc->sc_phandle = phandle; + sc->sc_iot = faa->faa_bst; + sc->sc_ioh = ioh; + sc->sc_iob = addr; + sc->sc_ios = size; + + ih = fdtbus_intr_establish(phandle, 0, IPL_SDMMC, 0, + sdhc_intr, >sc); + if (ih == NULL) { + aprint_error_dev(self, "couldn't establish interrupt on %s\n", + intrstr); + goto fail; + } + aprint_normal_dev(self, "interrupting on %s\n", intrstr); + sc->sc_ih = ih; + + config_defer(self, sniemmc_attach_i); + + return; + fail: + bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_ios); + return; } static int @@ -108,14 +180,85 @@ static void sniemmc_acpi_attach(device_t parent, device_t self, void *aux) { struct sniemmc_softc * const sc = device_private(self); - int error; - - error = sniemmc_attach_i(sc); - (void)error; + struct acpi_attach_args *aa = aux; + bus_space_handle_t ioh; + struct acpi_resources res; + struct acpi_mem *mem; + struct acpi_irq *irq; + ACPI_STATUS rv; + void *ih; + + rv = acpi_resource_parse(self, aa->aa_node->ad_handle, "_CRS", + , _resource_parse_ops_default); + if (ACPI_FAILURE(rv)) + return; + + mem = acpi_res_mem(, 0); + irq = acpi_res_irq(, 0); + if (mem == NULL || irq == NULL) { + aprint_error(": incomplete resources\n"); + return; + } + if (mem->ar_length == 0) { + aprint_error(": zero length memory resource\n"); + return; + } + if (bus_space_map(aa->aa_memt, mem->ar_base, mem->ar_length, 0, + )) { + aprint_error(": couldn't map registers\n"); + return; + } + + aprint_naive(": SDHC controller\n"); + aprint_normal(": SDHC
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Wed Mar 18 05:02:49 UTC 2020 Modified Files: src/sys/arch/arm/sociox: sni_i2c.c Log Message: use correct compatible designation To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sociox/sni_i2c.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/sni_i2c.c diff -u src/sys/arch/arm/sociox/sni_i2c.c:1.1 src/sys/arch/arm/sociox/sni_i2c.c:1.2 --- src/sys/arch/arm/sociox/sni_i2c.c:1.1 Wed Mar 18 03:33:49 2020 +++ src/sys/arch/arm/sociox/sni_i2c.c Wed Mar 18 05:02:48 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: sni_i2c.c,v 1.1 2020/03/18 03:33:49 nisimura Exp $ */ +/* $NetBSD: sni_i2c.c,v 1.2 2020/03/18 05:02:48 nisimura Exp $ */ /*- * Copyright (c) 2020 The NetBSD Foundation, Inc. @@ -34,7 +34,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: sni_i2c.c,v 1.1 2020/03/18 03:33:49 nisimura Exp $"); +__KERNEL_RCSID(0, "$NetBSD: sni_i2c.c,v 1.2 2020/03/18 05:02:48 nisimura Exp $"); #include #include @@ -71,8 +71,7 @@ static int sniiic_fdt_match(device_t parent, struct cfdata *match, void *aux) { static const char * compatible[] = { - "socionext,synquacer-sdhci", - "fujitsu,mb86s70-sdhci-3.0", + "socionext,synquacer-i2c", NULL }; struct fdt_attach_args * const faa = aux;
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Wed Mar 18 03:49:17 UTC 2020 Modified Files: src/sys/arch/arm/sociox: files.sociox Log Message: uncomment sniemmc and sniiic devices To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sociox/files.sociox Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/files.sociox diff -u src/sys/arch/arm/sociox/files.sociox:1.5 src/sys/arch/arm/sociox/files.sociox:1.6 --- src/sys/arch/arm/sociox/files.sociox:1.5 Wed Mar 18 02:36:53 2020 +++ src/sys/arch/arm/sociox/files.sociox Wed Mar 18 03:49:17 2020 @@ -1,4 +1,4 @@ -# $NetBSD: files.sociox,v 1.5 2020/03/18 02:36:53 nisimura Exp $ +# $NetBSD: files.sociox,v 1.6 2020/03/18 03:49:17 nisimura Exp $ # # Configuration info for Socionext Unifier/SC2A11 # @@ -18,14 +18,14 @@ file arch/arm/sociox/if_ave.c ave # Socionext eMMC device sniemmc: sdmmcbus -#attach sdhc at fdt with sniemmc_fdt -#attach sdhc at acpinodebus with sniemmc_acpi +attach sniemmc at fdt with sniemmc_fdt +attach sniemmc at acpinodebus with sniemmc_acpi file arch/arm/sociox/sni_emmc.c sniemmc # Socionext I2C device sniiic: i2cbus -#attach sniiic at fdt with sniiic_fdt -#attach sniiic at acpinodebus with sniiic_acpi +attach sniiic at fdt with sniiic_fdt +attach sniiic at acpinodebus with sniiic_acpi file arch/arm/sociox/sni_i2c.c sniiic needs-flag # Socionext GPIO
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Wed Mar 18 03:33:50 UTC 2020 Added Files: src/sys/arch/arm/sociox: sni_emmc.c sni_i2c.c Log Message: new skelton files for SC2A11 eMMC and I2C To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/sociox/sni_emmc.c \ src/sys/arch/arm/sociox/sni_i2c.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/sys/arch/arm/sociox/sni_emmc.c diff -u /dev/null src/sys/arch/arm/sociox/sni_emmc.c:1.1 --- /dev/null Wed Mar 18 03:33:50 2020 +++ src/sys/arch/arm/sociox/sni_emmc.c Wed Mar 18 03:33:49 2020 @@ -0,0 +1,121 @@ +/* $NetBSD: sni_emmc.c,v 1.1 2020/03/18 03:33:49 nisimura Exp $ */ + +/*- + * Copyright (c) 2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Tohru Nishimura. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + *notice, this list of conditions and the following disclaimer in the + *documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * Socionext SC2A11 SynQuacer eMMC driver + */ + +#include +__KERNEL_RCSID(0, "$NetBSD: sni_emmc.c,v 1.1 2020/03/18 03:33:49 nisimura Exp $"); + +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +static int sniemmc_fdt_match(device_t, struct cfdata *, void *); +static void sniemmc_fdt_attach(device_t, device_t, void *); +static int sniemmc_acpi_match(device_t, struct cfdata *, void *); +static void sniemmc_acpi_attach(device_t, device_t, void *); + +struct sniemmc_softc { + device_t sc_dev; +}; + +CFATTACH_DECL_NEW(sniemmc_fdt, sizeof(struct sniemmc_softc), +sniemmc_fdt_match, sniemmc_fdt_attach, NULL, NULL); + +CFATTACH_DECL_NEW(sniemmc_acpi, sizeof(struct sniemmc_softc), +sniemmc_acpi_match, sniemmc_acpi_attach, NULL, NULL); + +static int sniemmc_attach_i(struct sniemmc_softc *); + +static int +sniemmc_fdt_match(device_t parent, struct cfdata *match, void *aux) +{ + static const char * compatible[] = { + "socionext,synquacer-sdhci", + "fujitsu,mb86s70-sdhci-3.0", + NULL + }; + struct fdt_attach_args * const faa = aux; + + return of_match_compatible(faa->faa_phandle, compatible); +} + +static void +sniemmc_fdt_attach(device_t parent, device_t self, void *aux) +{ + struct sniemmc_softc * const sc = device_private(self); + int error; + + error = sniemmc_attach_i(sc); + (void)error; +} + +static int +sniemmc_acpi_match(device_t parent, struct cfdata *match, void *aux) +{ + static const char * compatible[] = { + "SCX0002", + NULL + }; + struct acpi_attach_args *aa = aux; + + if (aa->aa_node->ad_type != ACPI_TYPE_DEVICE) + return 0; + return acpi_match_hid(aa->aa_node->ad_devinfo, compatible); +} + +static void +sniemmc_acpi_attach(device_t parent, device_t self, void *aux) +{ + struct sniemmc_softc * const sc = device_private(self); + int error; + + error = sniemmc_attach_i(sc); + (void)error; +} + +static int +sniemmc_attach_i(struct sniemmc_softc *sc) +{ + return 0; +} Index: src/sys/arch/arm/sociox/sni_i2c.c diff -u /dev/null src/sys/arch/arm/sociox/sni_i2c.c:1.1 --- /dev/null Wed Mar 18 03:33:50 2020 +++ src/sys/arch/arm/sociox/sni_i2c.c Wed Mar 18 03:33:49 2020 @@ -0,0 +1,121 @@ +/* $NetBSD: sni_i2c.c,v 1.1 2020/03/18 03:33:49 nisimura Exp $ */ + +/*- + * Copyright (c) 2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Tohru Nishimura. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + *
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Wed Mar 18 02:36:53 UTC 2020 Modified Files: src/sys/arch/arm/sociox: files.sociox Log Message: more fdt/ACPI dual attach glue. SCX0002 and SCX0003 respectively To generate a diff of this commit: cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/sociox/files.sociox Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/files.sociox diff -u src/sys/arch/arm/sociox/files.sociox:1.4 src/sys/arch/arm/sociox/files.sociox:1.5 --- src/sys/arch/arm/sociox/files.sociox:1.4 Wed Mar 18 01:40:56 2020 +++ src/sys/arch/arm/sociox/files.sociox Wed Mar 18 02:36:53 2020 @@ -1,4 +1,4 @@ -# $NetBSD: files.sociox,v 1.4 2020/03/18 01:40:56 nisimura Exp $ +# $NetBSD: files.sociox,v 1.5 2020/03/18 02:36:53 nisimura Exp $ # # Configuration info for Socionext Unifier/SC2A11 # @@ -18,12 +18,14 @@ file arch/arm/sociox/if_ave.c ave # Socionext eMMC device sniemmc: sdmmcbus -attach sdhc at fdt with sniemmc +#attach sdhc at fdt with sniemmc_fdt +#attach sdhc at acpinodebus with sniemmc_acpi file arch/arm/sociox/sni_emmc.c sniemmc # Socionext I2C device sniiic: i2cbus -attach sniiic at fdt +#attach sniiic at fdt with sniiic_fdt +#attach sniiic at acpinodebus with sniiic_acpi file arch/arm/sociox/sni_i2c.c sniiic needs-flag # Socionext GPIO
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Wed Mar 18 01:40:56 UTC 2020 Modified Files: src/sys/arch/arm/sociox: files.sociox Log Message: add ACPI attachment glue. SynQuacer/SC2A11 has UEFI/tainocore firmware which is able to select either FDT format or ACPI format for device description. To generate a diff of this commit: cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/sociox/files.sociox Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/files.sociox diff -u src/sys/arch/arm/sociox/files.sociox:1.3 src/sys/arch/arm/sociox/files.sociox:1.4 --- src/sys/arch/arm/sociox/files.sociox:1.3 Tue Mar 17 23:01:15 2020 +++ src/sys/arch/arm/sociox/files.sociox Wed Mar 18 01:40:56 2020 @@ -1,4 +1,4 @@ -# $NetBSD: files.sociox,v 1.3 2020/03/17 23:01:15 nisimura Exp $ +# $NetBSD: files.sociox,v 1.4 2020/03/18 01:40:56 nisimura Exp $ # # Configuration info for Socionext Unifier/SC2A11 # @@ -7,11 +7,13 @@ # SC2A11 SynQuacer NetSec GbE device scx: ether, ifnet, arp, mii, bus_dma_generic attach scx at fdt with scx_fdt +attach scx at acpinodebus with scx_acpi file arch/arm/sociox/if_scx.c scx # Unifier AVE GbE device ave: ether, ifnet, arp, mii, bus_dma_generic attach ave at fdt with ave_fdt +attach ave at acpinodebus with ave_acpi file arch/arm/sociox/if_ave.c ave # Socionext eMMC
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Tue Mar 17 23:01:15 UTC 2020 Modified Files: src/sys/arch/arm/sociox: files.sociox Log Message: step forward to fdt/ACPI dual attach device To generate a diff of this commit: cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/sociox/files.sociox Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/files.sociox diff -u src/sys/arch/arm/sociox/files.sociox:1.2 src/sys/arch/arm/sociox/files.sociox:1.3 --- src/sys/arch/arm/sociox/files.sociox:1.2 Mon Mar 16 08:10:20 2020 +++ src/sys/arch/arm/sociox/files.sociox Tue Mar 17 23:01:15 2020 @@ -1,4 +1,4 @@ -# $NetBSD: files.sociox,v 1.2 2020/03/16 08:10:20 nisimura Exp $ +# $NetBSD: files.sociox,v 1.3 2020/03/17 23:01:15 nisimura Exp $ # # Configuration info for Socionext Unifier/SC2A11 # @@ -6,12 +6,12 @@ # SC2A11 SynQuacer NetSec GbE device scx: ether, ifnet, arp, mii, bus_dma_generic -attach scx at fdt +attach scx at fdt with scx_fdt file arch/arm/sociox/if_scx.c scx # Unifier AVE GbE device ave: ether, ifnet, arp, mii, bus_dma_generic -attach ave at fdt +attach ave at fdt with ave_fdt file arch/arm/sociox/if_ave.c ave # Socionext eMMC
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Mon Mar 16 08:10:20 UTC 2020 Modified Files: src/sys/arch/arm/sociox: files.sociox Log Message: add a missing line To generate a diff of this commit: cvs rdiff -u -r1.1 -r1.2 src/sys/arch/arm/sociox/files.sociox Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Modified files: Index: src/sys/arch/arm/sociox/files.sociox diff -u src/sys/arch/arm/sociox/files.sociox:1.1 src/sys/arch/arm/sociox/files.sociox:1.2 --- src/sys/arch/arm/sociox/files.sociox:1.1 Sun Mar 15 12:01:41 2020 +++ src/sys/arch/arm/sociox/files.sociox Mon Mar 16 08:10:20 2020 @@ -1,4 +1,4 @@ -# $NetBSD: files.sociox,v 1.1 2020/03/15 12:01:41 nisimura Exp $ +# $NetBSD: files.sociox,v 1.2 2020/03/16 08:10:20 nisimura Exp $ # # Configuration info for Socionext Unifier/SC2A11 # @@ -15,6 +15,7 @@ attach ave at fdt file arch/arm/sociox/if_ave.c ave # Socionext eMMC +device sniemmc: sdmmcbus attach sdhc at fdt with sniemmc file arch/arm/sociox/sni_emmc.c sniemmc
CVS commit: src/sys/arch/arm/sociox
Module Name:src Committed By: nisimura Date: Sun Mar 15 12:01:41 UTC 2020 Added Files: src/sys/arch/arm/sociox: files.sociox Log Message: driver description file for Socionext products To generate a diff of this commit: cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/sociox/files.sociox Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. Added files: Index: src/sys/arch/arm/sociox/files.sociox diff -u /dev/null src/sys/arch/arm/sociox/files.sociox:1.1 --- /dev/null Sun Mar 15 12:01:41 2020 +++ src/sys/arch/arm/sociox/files.sociox Sun Mar 15 12:01:41 2020 @@ -0,0 +1,29 @@ +# $NetBSD: files.sociox,v 1.1 2020/03/15 12:01:41 nisimura Exp $ +# +# Configuration info for Socionext Unifier/SC2A11 +# +# + +# SC2A11 SynQuacer NetSec GbE +device scx: ether, ifnet, arp, mii, bus_dma_generic +attach scx at fdt +file arch/arm/sociox/if_scx.c scx + +# Unifier AVE GbE +device ave: ether, ifnet, arp, mii, bus_dma_generic +attach ave at fdt +file arch/arm/sociox/if_ave.c ave + +# Socionext eMMC +attach sdhc at fdt with sniemmc +file arch/arm/sociox/sni_emmc.c sniemmc + +# Socionext I2C +device sniiic: i2cbus +attach sniiic at fdt +file arch/arm/sociox/sni_i2c.c sniiic needs-flag + +# Socionext GPIO +device snigpio: gpiobus +attach snigpio at fdt +file arch/arm/sociox/sni_gpio.c snigpio