Source-Changes-HG archive

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

[src/trunk]: src/sys/arch - Add imxusbphy driver for i.MX6.



details:   https://anonhg.NetBSD.org/src/rev/9f4a4858562c
branches:  trunk
changeset: 357393:9f4a4858562c
user:      hkenken <hkenken%NetBSD.org@localhost>
date:      Thu Nov 09 05:57:23 2017 +0000

description:
- Add imxusbphy driver for i.MX6.
- Clean up CCM (Clock driver).
  Add imx6_ccm_analog_read/write() functions.

diffstat:

 sys/arch/arm/imx/files.imx6               |    7 +-
 sys/arch/arm/imx/imx6_ahcisata.c          |    8 +-
 sys/arch/arm/imx/imx6_axi.c               |    7 +-
 sys/arch/arm/imx/imx6_board.c             |    6 +-
 sys/arch/arm/imx/imx6_ccm.c               |  101 ++++++---
 sys/arch/arm/imx/imx6_ccmreg.h            |  311 ++++++++++++++++-------------
 sys/arch/arm/imx/imx6_ccmvar.h            |   10 +-
 sys/arch/arm/imx/imx6_pcie.c              |    8 +-
 sys/arch/arm/imx/imx6_reg.h               |   10 +-
 sys/arch/arm/imx/imx6_usbphy.c            |  139 +++++++++++++
 sys/arch/arm/imx/imx6_usbphyreg.h         |   64 ++++++
 sys/arch/evbarm/conf/CUBOX-I              |    4 +-
 sys/arch/evbarm/conf/HUMMINGBOARD         |    8 +-
 sys/arch/evbarm/conf/IMX6UL-STARTER       |    4 +-
 sys/arch/evbarm/conf/NITROGEN6X           |    4 +-
 sys/arch/evbarm/nitrogen6/nitrogen6_usb.c |   52 +----
 16 files changed, 500 insertions(+), 243 deletions(-)

diffs (truncated from 1289 to 300 lines):

diff -r 74e5d4f15d85 -r 9f4a4858562c sys/arch/arm/imx/files.imx6
--- a/sys/arch/arm/imx/files.imx6       Thu Nov 09 04:51:07 2017 +0000
+++ b/sys/arch/arm/imx/files.imx6       Thu Nov 09 05:57:23 2017 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: files.imx6,v 1.11 2017/09/08 05:29:12 hkenken Exp $
+#      $NetBSD: files.imx6,v 1.12 2017/11/09 05:57:23 hkenken Exp $
 #
 # Configuration info for the Freescale i.MX6
 #
@@ -90,6 +90,11 @@
 device imxusbc { unit, irq } : bus_dma_generic
 file   arch/arm/imx/imx6_usb.c                 imxusbc
 
+# USB Phy
+device imxusbphy
+attach imxusbphy at axi
+file   arch/arm/imx/imx6_usbphy.c              imxusbphy
+
 attach ehci at imxusbc with imxehci
 file   arch/arm/imx/imxusb.c                   imxehci
 
diff -r 74e5d4f15d85 -r 9f4a4858562c sys/arch/arm/imx/imx6_ahcisata.c
--- a/sys/arch/arm/imx/imx6_ahcisata.c  Thu Nov 09 04:51:07 2017 +0000
+++ b/sys/arch/arm/imx/imx6_ahcisata.c  Thu Nov 09 05:57:23 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: imx6_ahcisata.c,v 1.5 2017/06/09 18:14:59 ryo Exp $    */
+/*     $NetBSD: imx6_ahcisata.c,v 1.6 2017/11/09 05:57:23 hkenken Exp $        */
 
 /*
  * Copyright (c) 2014 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: imx6_ahcisata.c,v 1.5 2017/06/09 18:14:59 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_ahcisata.c,v 1.6 2017/11/09 05:57:23 hkenken Exp $");
 
 #include "locators.h"
 #include "opt_imx.h"
@@ -273,9 +273,9 @@
                    "couldn't enable CCM_ANALOG_PLL_ENET\n");
                return -1;
        }
-       v = imx6_ccm_read(CCM_ANALOG_PLL_ENET);
+       v = imx6_ccm_analog_read(CCM_ANALOG_PLL_ENET);
        v |= CCM_ANALOG_PLL_ENET_ENABLE_100M;
-       imx6_ccm_write(CCM_ANALOG_PLL_ENET, v);
+       imx6_ccm_analog_write(CCM_ANALOG_PLL_ENET, v);
 
        v = iomux_read(IOMUX_GPR13);
        /* clear */
diff -r 74e5d4f15d85 -r 9f4a4858562c sys/arch/arm/imx/imx6_axi.c
--- a/sys/arch/arm/imx/imx6_axi.c       Thu Nov 09 04:51:07 2017 +0000
+++ b/sys/arch/arm/imx/imx6_axi.c       Thu Nov 09 05:57:23 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: imx6_axi.c,v 1.3 2017/08/17 09:11:04 hkenken Exp $     */
+/*     $NetBSD: imx6_axi.c,v 1.4 2017/11/09 05:57:23 hkenken Exp $     */
 
 /*
  * Copyright (c) 2014 Ryo Shimizu <ryo%nerv.org@localhost>
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: imx6_axi.c,v 1.3 2017/08/17 09:11:04 hkenken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_axi.c,v 1.4 2017/11/09 05:57:23 hkenken Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -103,7 +103,8 @@
            (strcmp(cf->cf_name, "imxgpio") != 0) &&
            (strcmp(cf->cf_name, "imxiomux") != 0) &&
            (strcmp(cf->cf_name, "imxocotp") != 0) &&
-           (strcmp(cf->cf_name, "imxuart") != 0))
+           (strcmp(cf->cf_name, "imxuart") != 0) &&
+           (strcmp(cf->cf_name, "imxusbphy") != 0))
                return 0;
 
        aa->aa_name = cf->cf_name;
diff -r 74e5d4f15d85 -r 9f4a4858562c sys/arch/arm/imx/imx6_board.c
--- a/sys/arch/arm/imx/imx6_board.c     Thu Nov 09 04:51:07 2017 +0000
+++ b/sys/arch/arm/imx/imx6_board.c     Thu Nov 09 05:57:23 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: imx6_board.c,v 1.8 2017/06/09 18:14:59 ryo Exp $       */
+/*     $NetBSD: imx6_board.c,v 1.9 2017/11/09 05:57:23 hkenken Exp $   */
 
 /*
  * Copyright (c) 2012  Genetec Corporation.  All rights reserved.
@@ -27,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: imx6_board.c,v 1.8 2017/06/09 18:14:59 ryo Exp $");
+__KERNEL_RCSID(1, "$NetBSD: imx6_board.c,v 1.9 2017/11/09 05:57:23 hkenken Exp $");
 
 #include "opt_imx.h"
 #include "arml2cc.h"
@@ -189,7 +189,7 @@
        uint32_t v;
 
        v = bus_space_read_4(imx6_ioreg_bst, imx6_ioreg_bsh,
-           AIPS1_CCM_BASE + CCM_ANALOG_PLL_ARM);
+           AIPS1_CCM_ANALOG_BASE + CCM_ANALOG_PLL_ARM);
        clk = IMX6_OSC_FREQ * (v & CCM_ANALOG_PLL_ARM_DIV_SELECT) / 2;
        v = bus_space_read_4(imx6_ioreg_bst, imx6_ioreg_bsh,
            AIPS1_CCM_BASE + CCM_CACRR);
diff -r 74e5d4f15d85 -r 9f4a4858562c sys/arch/arm/imx/imx6_ccm.c
--- a/sys/arch/arm/imx/imx6_ccm.c       Thu Nov 09 04:51:07 2017 +0000
+++ b/sys/arch/arm/imx/imx6_ccm.c       Thu Nov 09 05:57:23 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: imx6_ccm.c,v 1.6 2017/06/09 18:14:59 ryo Exp $ */
+/*     $NetBSD: imx6_ccm.c,v 1.7 2017/11/09 05:57:23 hkenken Exp $     */
 
 /*
  * Copyright (c) 2010-2012, 2014  Genetec Corporation.  All rights reserved.
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: imx6_ccm.c,v 1.6 2017/06/09 18:14:59 ryo Exp $");
+__KERNEL_RCSID(0, "$NetBSD: imx6_ccm.c,v 1.7 2017/11/09 05:57:23 hkenken Exp $");
 
 #include "opt_imx.h"
 #include "opt_imx6clk.h"
@@ -63,6 +63,7 @@
        device_t sc_dev;
        bus_space_tag_t sc_iot;
        bus_space_handle_t sc_ioh;
+       bus_space_handle_t sc_ioh_analog;
 
        /* for sysctl */
        struct sysctllog *sc_log;
@@ -118,8 +119,15 @@
        sc->sc_iot = iot;
        sc->sc_log = NULL;
 
-       if (bus_space_map(iot, aa->aa_addr, IMX6_CCM_SIZE, 0, &sc->sc_ioh)) {
-               aprint_error(": can't map registers\n");
+       if (bus_space_map(iot, aa->aa_addr, AIPS1_CCM_SIZE, 0, &sc->sc_ioh)) {
+               aprint_error(": can't map CCM registers\n");
+               return;
+       }
+
+       if (bus_space_map(iot, IMX6_AIPS1_BASE + AIPS1_CCM_ANALOG_BASE,
+           AIPS1_CCM_ANALOG_SIZE, 0, &sc->sc_ioh_analog)) {
+               aprint_error(": can't map CCM_ANALOG registers\n");
+               bus_space_unmap(iot, sc->sc_ioh, AIPS1_CCM_SIZE);
                return;
        }
 
@@ -414,8 +422,29 @@
        bus_space_write_4(ccm_softc->sc_iot, ccm_softc->sc_ioh, reg, val);
 }
 
+
+uint32_t
+imx6_ccm_analog_read(uint32_t reg)
+{
+       if (ccm_softc == NULL)
+               return 0;
+
+       return bus_space_read_4(ccm_softc->sc_iot, ccm_softc->sc_ioh_analog,
+           reg);
+}
+
+void
+imx6_ccm_analog_write(uint32_t reg, uint32_t val)
+{
+       if (ccm_softc == NULL)
+               return;
+
+       bus_space_write_4(ccm_softc->sc_iot, ccm_softc->sc_ioh_analog, reg,
+           val);
+}
+
 int
-imx6_set_clock(enum imx6_clock clk, uint32_t freq)
+imx6_set_clock(enum imx6_clock_id clk, uint32_t freq)
 {
        uint32_t v;
 
@@ -434,11 +463,13 @@
 
                                        v = imx6_ccm_read(CCM_CACRR);
                                        v &= ~CCM_CACRR_ARM_PODF;
-                                       imx6_ccm_write(CCM_CACRR, v | __SHIFTIN(cacrr, CCM_CACRR_ARM_PODF));
+                                       imx6_ccm_write(CCM_CACRR,
+                                           v | __SHIFTIN(cacrr, CCM_CACRR_ARM_PODF));
 
-                                       v = imx6_ccm_read(CCM_ANALOG_PLL_ARM);
+                                       v = imx6_ccm_analog_read(CCM_ANALOG_PLL_ARM);
                                        v &= ~CCM_ANALOG_PLL_ARM_DIV_SELECT;
-                                       imx6_ccm_write(CCM_ANALOG_PLL_ARM, v | __SHIFTIN(pll, CCM_ANALOG_PLL_ARM_DIV_SELECT));
+                                       imx6_ccm_analog_write(CCM_ANALOG_PLL_ARM,
+                                           v | __SHIFTIN(pll, CCM_ANALOG_PLL_ARM_DIV_SELECT));
 
                                        v = imx6_get_clock(IMX6CLK_ARM_ROOT);
                                        cpufreq_set_all(v);
@@ -462,7 +493,7 @@
 }
 
 uint32_t
-imx6_get_clock(enum imx6_clock clk)
+imx6_get_clock(enum imx6_clock_id clk)
 {
        uint32_t d, denom, num, sel, v;
        uint64_t freq;
@@ -473,33 +504,33 @@
        switch (clk) {
        /* CLOCK SWITCHER */
        case IMX6CLK_PLL1:
-               v = imx6_ccm_read(CCM_ANALOG_PLL_ARM);
+               v = imx6_ccm_analog_read(CCM_ANALOG_PLL_ARM);
                freq = IMX6_OSC_FREQ * (v & CCM_ANALOG_PLL_ARM_DIV_SELECT) / 2;
                break;
        case IMX6CLK_PLL2:
-               v = imx6_ccm_read(CCM_ANALOG_PLL_SYS);
+               v = imx6_ccm_analog_read(CCM_ANALOG_PLL_SYS);
                freq = IMX6_OSC_FREQ * ((v & CCM_ANALOG_PLL_SYS_DIV_SELECT) ? 22 : 20);
                break;
        case IMX6CLK_PLL3:
-               v = imx6_ccm_read(CCM_ANALOG_PLL_USB1);
+               v = imx6_ccm_analog_read(CCM_ANALOG_PLL_USB1);
                freq = IMX6_OSC_FREQ * ((v & CCM_ANALOG_PLL_USB1_DIV_SELECT) ? 22 : 20);
                break;
 
        case IMX6CLK_PLL4:
-               v = imx6_ccm_read(CCM_ANALOG_PLL_AUDIO);
+               v = imx6_ccm_analog_read(CCM_ANALOG_PLL_AUDIO);
                d = __SHIFTOUT(v, CCM_ANALOG_PLL_AUDIO_DIV_SELECT);
-               num = imx6_ccm_read(CCM_ANALOG_PLL_AUDIO_NUM);
-               denom = imx6_ccm_read(CCM_ANALOG_PLL_AUDIO_DENOM);
+               num = imx6_ccm_analog_read(CCM_ANALOG_PLL_AUDIO_NUM);
+               denom = imx6_ccm_analog_read(CCM_ANALOG_PLL_AUDIO_DENOM);
                freq = (uint64_t)IMX6_OSC_FREQ * (d + num / denom);
                d = __SHIFTOUT(v, CCM_ANALOG_PLL_AUDIO_POST_DIV_SELECT);
                freq = freq >> (2 - d);
                break;
 
        case IMX6CLK_PLL5:
-               v = imx6_ccm_read(CCM_ANALOG_PLL_VIDEO);
+               v = imx6_ccm_analog_read(CCM_ANALOG_PLL_VIDEO);
                d = __SHIFTOUT(v, CCM_ANALOG_PLL_VIDEO_DIV_SELECT);
-               num = imx6_ccm_read(CCM_ANALOG_PLL_VIDEO_NUM);
-               denom = imx6_ccm_read(CCM_ANALOG_PLL_VIDEO_DENOM);
+               num = imx6_ccm_analog_read(CCM_ANALOG_PLL_VIDEO_NUM);
+               denom = imx6_ccm_analog_read(CCM_ANALOG_PLL_VIDEO_DENOM);
                freq = (uint64_t)IMX6_OSC_FREQ * (d + num / denom);
                d = __SHIFTOUT(v, CCM_ANALOG_PLL_VIDEO_POST_DIV_SELECT);
                freq = freq >> (2 - d);
@@ -507,7 +538,7 @@
 
        case IMX6CLK_PLL6:
                /* XXX: iMX6UL has 2 div. which? */
-               v = imx6_ccm_read(CCM_ANALOG_PLL_ENET);
+               v = imx6_ccm_analog_read(CCM_ANALOG_PLL_ENET);
                switch (v & CCM_ANALOG_PLL_ENET_DIV_SELECT_MASK) {
                case 0:
                        freq = 25 * 1000 * 1000;
@@ -524,8 +555,8 @@
                }
                break;
        case IMX6CLK_PLL7:
-               v = imx6_ccm_read(CCM_ANALOG_PLL_USB2);
-               freq = IMX6_OSC_FREQ * ((v & CCM_ANALOG_PLL_USBn_DIV_SELECT(1)) ? 22 : 20);
+               v = imx6_ccm_analog_read(CCM_ANALOG_PLL_USB2);
+               freq = IMX6_OSC_FREQ * ((v & CCM_ANALOG_PLL_USBn_DIV_SELECT) ? 22 : 20);
                break;
 
 #if 0
@@ -536,37 +567,37 @@
 
        case IMX6CLK_PLL2_PFD0:
                freq = imx6_get_clock(IMX6CLK_PLL2);
-               v = imx6_ccm_read(CCM_ANALOG_PFD_528);
+               v = imx6_ccm_analog_read(CCM_ANALOG_PFD_528);
                freq = freq * 18 / __SHIFTOUT(v, CCM_ANALOG_PFD_528_PFD0_FRAC);
                break;
        case IMX6CLK_PLL2_PFD1:
                freq = imx6_get_clock(IMX6CLK_PLL2);
-               v = imx6_ccm_read(CCM_ANALOG_PFD_528);
+               v = imx6_ccm_analog_read(CCM_ANALOG_PFD_528);
                freq = freq * 18 / __SHIFTOUT(v, CCM_ANALOG_PFD_528_PFD1_FRAC);
                break;
        case IMX6CLK_PLL2_PFD2:
                freq = imx6_get_clock(IMX6CLK_PLL2);
-               v = imx6_ccm_read(CCM_ANALOG_PFD_528);
+               v = imx6_ccm_analog_read(CCM_ANALOG_PFD_528);
                freq = freq * 18 / __SHIFTOUT(v, CCM_ANALOG_PFD_528_PFD2_FRAC);
                break;
        case IMX6CLK_PLL3_PFD3:
                freq = imx6_get_clock(IMX6CLK_PLL3);
-               v = imx6_ccm_read(CCM_ANALOG_PFD_480);
+               v = imx6_ccm_analog_read(CCM_ANALOG_PFD_480);
                freq = freq * 18 / __SHIFTOUT(v, CCM_ANALOG_PFD_480_PFD3_FRAC);
                break;
        case IMX6CLK_PLL3_PFD2:
                freq = imx6_get_clock(IMX6CLK_PLL3);
-               v = imx6_ccm_read(CCM_ANALOG_PFD_480);
+               v = imx6_ccm_analog_read(CCM_ANALOG_PFD_480);



Home | Main Index | Thread Index | Old Index