Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src add support for i.MX6UltraLite, and



details:   https://anonhg.NetBSD.org/src/rev/d2eb1bb30897
branches:  trunk
changeset: 354284:d2eb1bb30897
user:      ryo <ryo%NetBSD.org@localhost>
date:      Fri Jun 09 18:14:59 2017 +0000

description:
add support for i.MX6UltraLite, and
ConnectCore for iMX6UL Starter Board.

diffstat:

 etc/etc.evbarm/Makefile.inc                 |    4 +-
 sys/arch/arm/imx/if_enet.c                  |   45 +-
 sys/arch/arm/imx/if_enet_imx6.c             |   54 +++-
 sys/arch/arm/imx/if_enet_imx7.c             |    5 +-
 sys/arch/arm/imx/if_enetreg.h               |    6 +-
 sys/arch/arm/imx/if_enetvar.h               |    3 +-
 sys/arch/arm/imx/imx6_ahcisata.c            |    5 +-
 sys/arch/arm/imx/imx6_board.c               |   13 +-
 sys/arch/arm/imx/imx6_ccm.c                 |   10 +-
 sys/arch/arm/imx/imx6_ccmreg.h              |    9 +-
 sys/arch/arm/imx/imx6_gpio.c                |   10 +-
 sys/arch/arm/imx/imx6_intr.h                |   47 ++-
 sys/arch/arm/imx/imx6_iomuxreg.h            |  451 +++++++++++++++++++++++++++-
 sys/arch/arm/imx/imx6_pcie.c                |    7 +-
 sys/arch/arm/imx/imx6_reg.h                 |   16 +-
 sys/arch/arm/imx/imx6_uart.c                |    7 +-
 sys/arch/arm/imx/imx6_usdhc.c               |   11 +-
 sys/arch/arm/imx/imx6_wdog.c                |   10 +-
 sys/arch/arm/imx/imx6var.h                  |    7 +-
 sys/arch/evbarm/conf/IMX6UL-STARTER         |  434 ++++++++++++++++++++++++++
 sys/arch/evbarm/conf/IMX6UL-STARTER_INSTALL |   10 +
 sys/arch/evbarm/conf/mk.imx6ul              |   33 ++
 sys/arch/evbarm/conf/std.imx6ul             |   35 ++
 sys/arch/evbarm/nitrogen6/nitrogen6_iomux.c |  107 ++++++-
 sys/arch/evbarm/nitrogen6/nitrogen6_start.S |   13 +-
 25 files changed, 1276 insertions(+), 76 deletions(-)

diffs (truncated from 2114 to 300 lines):

diff -r e9bdbb82ce90 -r d2eb1bb30897 etc/etc.evbarm/Makefile.inc
--- a/etc/etc.evbarm/Makefile.inc       Fri Jun 09 18:02:40 2017 +0000
+++ b/etc/etc.evbarm/Makefile.inc       Fri Jun 09 18:14:59 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.inc,v 1.81 2017/01/07 16:29:04 kiyohara Exp $
+#      $NetBSD: Makefile.inc,v 1.82 2017/06/09 18:14:59 ryo Exp $
 #
 #      etc.evbarm/Makefile.inc -- evbarm-specific etc Makefile targets
 #
@@ -105,6 +105,8 @@
 EVBARM_BOARDS.armv7+=          HUMMINGBIRD_A31
 EVBARM_BOARDS.armv7hf+=                HUMMINGBIRD_A31
 #EVBARM_BOARDS.armv7+=         IGEPV2
+EVBARM_BOARDS.armv7+=          IMX6UL-STARTER
+EVBARM_BOARDS.armv7hf+=                IMX6UL-STARTER
 EVBARM_BOARDS.armv7+=          TEGRA
 EVBARM_BOARDS.armv7hf+=                TEGRA
 EVBARM_BOARDS.armv7+=          ARMADILLO-IOT-G3
diff -r e9bdbb82ce90 -r d2eb1bb30897 sys/arch/arm/imx/if_enet.c
--- a/sys/arch/arm/imx/if_enet.c        Fri Jun 09 18:02:40 2017 +0000
+++ b/sys/arch/arm/imx/if_enet.c        Fri Jun 09 18:14:59 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_enet.c,v 1.10 2016/12/15 09:28:02 ozaki-r Exp $     */
+/*     $NetBSD: if_enet.c,v 1.11 2017/06/09 18:14:59 ryo Exp $ */
 
 /*
  * Copyright (c) 2014 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_enet.c,v 1.10 2016/12/15 09:28:02 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_enet.c,v 1.11 2017/06/09 18:14:59 ryo Exp $");
 
 #include "vlan.h"
 
@@ -92,8 +92,10 @@
 
 #define ENET_MAX_PKT_NSEGS     64
 
-#define ENET_TX_NEXTIDX(idx)   (((idx) >= (ENET_TX_RING_CNT - 1)) ? 0 : ((idx) + 1))
-#define ENET_RX_NEXTIDX(idx)   (((idx) >= (ENET_RX_RING_CNT - 1)) ? 0 : ((idx) + 1))
+#define ENET_TX_NEXTIDX(idx)   \
+       (((idx) >= (ENET_TX_RING_CNT - 1)) ? 0 : ((idx) + 1))
+#define ENET_RX_NEXTIDX(idx)   \
+       (((idx) >= (ENET_RX_RING_CNT - 1)) ? 0 : ((idx) + 1))
 
 #define TXDESC_WRITEOUT(idx)                                   \
        bus_dmamap_sync(sc->sc_dmat, sc->sc_txdesc_dmamap,      \
@@ -234,13 +236,15 @@
                /* i.MX7 use 3 interrupts */
                if ((sc->sc_ih2 = intr_establish(irq + 1, IPL_NET,
                    IST_LEVEL, enet_intr, sc)) == NULL) {
-                       aprint_error_dev(self, "unable to establish 2nd interrupt\n");
+                       aprint_error_dev(self,
+                           "unable to establish 2nd interrupt\n");
                        intr_disestablish(sc->sc_ih);
                        goto failure;
                }
                if ((sc->sc_ih3 = intr_establish(irq + 2, IPL_NET,
                    IST_LEVEL, enet_intr, sc)) == NULL) {
-                       aprint_error_dev(self, "unable to establish 3rd interrupt\n");
+                       aprint_error_dev(self,
+                           "unable to establish 3rd interrupt\n");
                        intr_disestablish(sc->sc_ih2);
                        intr_disestablish(sc->sc_ih);
                        goto failure;
@@ -1030,8 +1034,8 @@
                        ENET_REG_WRITE(sc, ENET_FTRL, v);
                        v = ENET_REG_READ(sc, ENET_RCR);
                        v &= ~ENET_RCR_MAX_FL(0x3fff);
-                       v |= ENET_RCR_MAX_FL(ifp->if_mtu +
-                           ETHER_HDR_LEN + ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN);
+                       v |= ENET_RCR_MAX_FL(ifp->if_mtu + ETHER_HDR_LEN +
+                           ETHER_CRC_LEN + ETHER_VLAN_ENCAP_LEN);
                        ENET_REG_WRITE(sc, ENET_RCR, v);
                }
                break;
@@ -1187,6 +1191,7 @@
        case IFM_AUTO:
        case IFM_1000_T:
                ecr |= ENET_ECR_SPEED;          /* 1000Mbps mode */
+               rcr &= ~ENET_RCR_RMII_10T;
                break;
        case IFM_100_TX:
                ecr &= ~ENET_ECR_SPEED;         /* 100Mbps mode */
@@ -1203,6 +1208,9 @@
                break;
        }
 
+       if (sc->sc_rgmii == 0)
+               ecr &= ~ENET_ECR_SPEED;
+
        if (sc->sc_flowflags & IFM_FLOW)
                rcr |= ENET_RCR_FCE;
        else
@@ -1227,7 +1235,7 @@
 
        /* build TX ring */
        for (i = 0; i < ENET_TX_RING_CNT; i++) {
-               sc->sc_txdesc_ring[i].tx_flags1_len = 
+               sc->sc_txdesc_ring[i].tx_flags1_len =
                    ((i == (ENET_TX_RING_CNT - 1)) ? TXFLAGS1_W : 0);
                sc->sc_txdesc_ring[i].tx_databuf = 0;
                sc->sc_txdesc_ring[i].tx_flags2 = TXFLAGS2_INT;
@@ -1298,7 +1306,7 @@
        }
 
        bus_dmamap_sync(sc->sc_dmat, sc->sc_rxsoft[idx].rxs_dmamap, 0,
-           sc->sc_rxsoft[idx].rxs_dmamap->dm_mapsize, 
+           sc->sc_rxsoft[idx].rxs_dmamap->dm_mapsize,
            BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
 
        sc->sc_rxsoft[idx].rxs_mbuf = m;
@@ -1578,7 +1586,8 @@
                                                        ap = mt->m_dat;
                                                }
                                                ap = ALIGN_PTR(ap, ALIGNBYTE);
-                                               memcpy(ap, mt->m_data, mt->m_len);
+                                               memcpy(ap, mt->m_data,
+                                                   mt->m_len);
                                                mt->m_data = ap;
                                        }
 
@@ -1765,7 +1774,7 @@
        struct ifmedia_entry *ife;
        paddr_t paddr;
        uint32_t val;
-       int fulldup, ecr_speed, rcr_speed, flowctrl;
+       int miimode, fulldup, ecr_speed, rcr_speed, flowctrl;
 
        if (init) {
                fulldup = 1;
@@ -1799,6 +1808,9 @@
                flowctrl = sc->sc_flowflags & IFM_FLOW;
        }
 
+       if (sc->sc_rgmii == 0)
+               ecr_speed = 0;
+
        /* reset */
        ENET_REG_WRITE(sc, ENET_ECR, ecr_speed | ENET_ECR_RESET);
 
@@ -1846,9 +1858,14 @@
        /* maximum frame size */
        val = ENET_DEFAULT_PKT_LEN;
        ENET_REG_WRITE(sc, ENET_FTRL, val);     /* Frame Truncation Length */
+
+       if (sc->sc_rgmii == 0)
+               miimode = ENET_RCR_RMII_MODE | ENET_RCR_MII_MODE;
+       else
+               miimode = ENET_RCR_RGMII_EN;
        ENET_REG_WRITE(sc, ENET_RCR,
            ENET_RCR_PADEN |                    /* RX frame padding remove */
-           ENET_RCR_RGMII_EN |                 /* use RGMII */
+           miimode |
            (flowctrl ? ENET_RCR_FCE : 0) |     /* flow control enable */
            rcr_speed |
            (fulldup ? 0 : ENET_RCR_DRT) |
@@ -1880,7 +1897,7 @@
 #if _BYTE_ORDER == _LITTLE_ENDIAN
            ENET_ECR_DBSWP |
 #endif
-           ENET_ECR_SPEED |    /* default 1000Mbps mode */
+           ecr_speed |
            ENET_ECR_EN1588 |   /* use enhanced TX/RX descriptor */
            ENET_ECR_ETHEREN);  /* Ethernet Enable */
 
diff -r e9bdbb82ce90 -r d2eb1bb30897 sys/arch/arm/imx/if_enet_imx6.c
--- a/sys/arch/arm/imx/if_enet_imx6.c   Fri Jun 09 18:02:40 2017 +0000
+++ b/sys/arch/arm/imx/if_enet_imx6.c   Fri Jun 09 18:14:59 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_enet_imx6.c,v 1.2 2016/11/24 03:59:36 hkenken Exp $ */
+/*     $NetBSD: if_enet_imx6.c,v 1.3 2017/06/09 18:14:59 ryo Exp $     */
 
 /*
  * Copyright (c) 2014 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_enet_imx6.c,v 1.2 2016/11/24 03:59:36 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_enet_imx6.c,v 1.3 2017/06/09 18:14:59 ryo Exp $");
 
 #include "locators.h"
 #include "imxccm.h"
@@ -41,6 +41,7 @@
 #include <arm/imx/imx6_reg.h>
 #include <arm/imx/imx6_ccmreg.h>
 #include <arm/imx/imx6_ccmvar.h>
+#include <arm/imx/imx6_iomuxreg.h>
 #include <arm/imx/imx6_ocotpreg.h>
 #include <arm/imx/imx6_ocotpvar.h>
 #include <arm/imx/if_enetreg.h>
@@ -56,6 +57,10 @@
        switch (aa->aa_addr) {
        case (IMX6_AIPS2_BASE + AIPS2_ENET_BASE):
                return 1;
+       case (IMX6_AIPS1_BASE + AIPS1_ENET2_BASE):
+               if (IMX6_CHIPID_MAJOR(imx6_chip_id()) == CHIPID_MAJOR_IMX6UL)
+                       return 1;
+               break;
        }
 
        return 0;
@@ -77,7 +82,19 @@
                aa->aa_size = AIPS_ENET_SIZE;
 
        sc->sc_imxtype = 6;     /* i.MX6 */
-       sc->sc_unit = 0;
+       if (IMX6_CHIPID_MAJOR(imx6_chip_id()) == CHIPID_MAJOR_IMX6UL)
+               sc->sc_rgmii = 0;
+       else
+               sc->sc_rgmii = 1;
+
+       switch (aa->aa_addr) {
+       case (IMX6_AIPS2_BASE + AIPS2_ENET_BASE):
+               sc->sc_unit = 0;
+               break;
+       case (IMX6_AIPS1_BASE + AIPS1_ENET2_BASE):
+               sc->sc_unit = 1;
+               break;
+       }
 
 #if NIMXOCOTP > 0
        /* get mac-address from OCOTP */
@@ -88,18 +105,45 @@
        sc->sc_enaddr[2] = eaddr >> 24;
        sc->sc_enaddr[3] = eaddr >> 16;
        sc->sc_enaddr[4] = eaddr >> 8;
-       sc->sc_enaddr[5] = eaddr;
+       sc->sc_enaddr[5] = eaddr + sc->sc_unit;
 #endif
 
 #if NIMXCCM > 0
        /* PLL power up */
        if (imx6_pll_power(CCM_ANALOG_PLL_ENET, 1,
-               CCM_ANALOG_PLL_ENET_ENABLE) != 0) {
+           CCM_ANALOG_PLL_ENET_ENABLE) != 0) {
                aprint_error_dev(sc->sc_dev,
                    "couldn't enable CCM_ANALOG_PLL_ENET\n");
                return;
        }
 
+       if (IMX6_CHIPID_MAJOR(imx6_chip_id()) == CHIPID_MAJOR_IMX6UL) {
+               uint32_t v;
+
+               /* iMX6UL */
+               if ((imx6_pll_power(CCM_ANALOG_PLL_ENET, 1,
+                   CCM_ANALOG_PLL_ENET_ENET_25M_REF_EN) != 0) ||
+                   (imx6_pll_power(CCM_ANALOG_PLL_ENET, 1,
+                   CCM_ANALOG_PLL_ENET_ENET2_125M_EN) != 0)) {
+                       aprint_error_dev(sc->sc_dev,
+                           "couldn't enable CCM_ANALOG_PLL_ENET\n");
+                       return;
+               }
+
+               v = iomux_read(IMX6UL_IOMUX_GPR1);
+               switch (sc->sc_unit) {
+               case 0:
+                       v |= IMX6UL_IOMUX_GPR1_ENET1_TX_CLK_DIR;
+                       v &= ~IMX6UL_IOMUX_GPR1_ENET1_CLK_SEL;
+                       break;
+               case 1:
+                       v |= IMX6UL_IOMUX_GPR1_ENET2_TX_CLK_DIR;
+                       v &= ~IMX6UL_IOMUX_GPR1_ENET2_CLK_SEL;
+                       break;
+               }
+               iomux_write(IMX6UL_IOMUX_GPR1, v);
+       }
+
        sc->sc_pllclock = imx6_get_clock(IMX6CLK_PLL6);
 #else
        sc->sc_pllclock = 50000000;
diff -r e9bdbb82ce90 -r d2eb1bb30897 sys/arch/arm/imx/if_enet_imx7.c
--- a/sys/arch/arm/imx/if_enet_imx7.c   Fri Jun 09 18:02:40 2017 +0000
+++ b/sys/arch/arm/imx/if_enet_imx7.c   Fri Jun 09 18:14:59 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_enet_imx7.c,v 1.1 2016/05/17 06:44:45 ryo Exp $     */
+/*     $NetBSD: if_enet_imx7.c,v 1.2 2017/06/09 18:14:59 ryo Exp $     */
 
 /*
  * Copyright (c) 2014 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_enet_imx7.c,v 1.1 2016/05/17 06:44:45 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_enet_imx7.c,v 1.2 2017/06/09 18:14:59 ryo Exp $");
 
 #include "locators.h"
 #include "imxccm.h"
@@ -79,6 +79,7 @@
                aa->aa_size = AIPS_ENET_SIZE;
 
        sc->sc_imxtype = 7;     /* i.MX7 */
+       sc->sc_rgmii = 1;
 
 #if NIMXCCM > 0
        /* PLL power up */



Home | Main Index | Thread Index | Old Index