summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorPatrick Wildt <patrick@cvs.openbsd.org>2018-04-02 16:03:51 +0000
committerPatrick Wildt <patrick@cvs.openbsd.org>2018-04-02 16:03:51 +0000
commitb954e740f60b47a08429b6a02d11d17f31ebd3cb (patch)
tree5c9759fce7ea9f25fa6d60b2955e04ef5f1112c8 /sys/arch
parent53971b4cdc37f9ac2d565ed5c16c71500b210f04 (diff)
Have imxehci(4) make use of the clock framework by implementing the phy
clock in imxccm(4). ok kettenis@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/armv7/imx/imxccm.c27
-rw-r--r--sys/arch/armv7/imx/imxccm_clocks.h2
-rw-r--r--sys/arch/armv7/imx/imxccmvar.h4
-rw-r--r--sys/arch/armv7/imx/imxehci.c23
4 files changed, 33 insertions, 23 deletions
diff --git a/sys/arch/armv7/imx/imxccm.c b/sys/arch/armv7/imx/imxccm.c
index f75a3a727ed..973089b5259 100644
--- a/sys/arch/armv7/imx/imxccm.c
+++ b/sys/arch/armv7/imx/imxccm.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imxccm.c,v 1.15 2018/04/01 22:19:18 patrick Exp $ */
+/* $OpenBSD: imxccm.c,v 1.16 2018/04/02 16:03:50 patrick Exp $ */
/*
* Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se>
*
@@ -239,8 +239,8 @@ uint32_t imxccm_get_ipg_perclk(struct imxccm_softc *);
uint32_t imxccm_get_uartclk(struct imxccm_softc *);
void imxccm_enable(void *, uint32_t *, int);
uint32_t imxccm_get_frequency(void *, uint32_t *);
-void imxccm_enable_pll_usb1(void);
-void imxccm_enable_pll_usb2(void);
+void imxccm_enable_pll_usb1(struct imxccm_softc *);
+void imxccm_enable_pll_usb2(struct imxccm_softc *);
void imxccm_enable_pll_enet(void);
void imxccm_enable_enet(void);
void imxccm_enable_sata(void);
@@ -483,6 +483,19 @@ imxccm_enable(void *cookie, uint32_t *cells, int on)
if (idx == 0)
return;
+ if (sc->sc_gates == imx6_gates) {
+ switch (idx) {
+ case IMX6_CLK_USBPHY1:
+ imxccm_enable_pll_usb1(sc);
+ return;
+ case IMX6_CLK_USBPHY2:
+ imxccm_enable_pll_usb2(sc);
+ return;
+ default:
+ break;
+ }
+ }
+
if (idx >= sc->sc_ngates || sc->sc_gates[idx].reg == 0) {
printf("%s: 0x%08x\n", __func__, idx);
return;
@@ -591,10 +604,8 @@ imxccm_enable_sata(void)
}
void
-imxccm_enable_pll_usb1(void)
+imxccm_enable_pll_usb1(struct imxccm_softc *sc)
{
- struct imxccm_softc *sc = imxccm_sc;
-
HWRITE4(sc, CCM_ANALOG_PLL_USB1_CLR, CCM_ANALOG_PLL_USB1_BYPASS);
HWRITE4(sc, CCM_ANALOG_PLL_USB1_SET,
@@ -604,10 +615,8 @@ imxccm_enable_pll_usb1(void)
}
void
-imxccm_enable_pll_usb2(void)
+imxccm_enable_pll_usb2(struct imxccm_softc *sc)
{
- struct imxccm_softc *sc = imxccm_sc;
-
HWRITE4(sc, CCM_ANALOG_PLL_USB2_CLR, CCM_ANALOG_PLL_USB2_BYPASS);
HWRITE4(sc, CCM_ANALOG_PLL_USB2_SET,
diff --git a/sys/arch/armv7/imx/imxccm_clocks.h b/sys/arch/armv7/imx/imxccm_clocks.h
index 021dae5965f..d4cd3ed6c06 100644
--- a/sys/arch/armv7/imx/imxccm_clocks.h
+++ b/sys/arch/armv7/imx/imxccm_clocks.h
@@ -19,6 +19,8 @@
#define IMX6_CLK_USDHC2 0xa4
#define IMX6_CLK_USDHC3 0xa5
#define IMX6_CLK_USDHC4 0xa6
+#define IMX6_CLK_USBPHY1 0xb6
+#define IMX6_CLK_USBPHY2 0xb7
struct imxccm_gate imx6_gates[] = {
[IMX6_CLK_ENET] = { CCM_CCGR1, 5, IMX6_CLK_IPG },
diff --git a/sys/arch/armv7/imx/imxccmvar.h b/sys/arch/armv7/imx/imxccmvar.h
index b99f3adfe3e..2ae01097fc1 100644
--- a/sys/arch/armv7/imx/imxccmvar.h
+++ b/sys/arch/armv7/imx/imxccmvar.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: imxccmvar.h,v 1.7 2018/04/01 22:19:18 patrick Exp $ */
+/* $OpenBSD: imxccmvar.h,v 1.8 2018/04/02 16:03:50 patrick Exp $ */
/*
* Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se>
*
@@ -18,8 +18,6 @@
#ifndef IMXCCMVAR_H
#define IMXCCMVAR_H
-void imxccm_enable_pll_usb1(void);
-void imxccm_enable_pll_usb2(void);
void imxccm_enable_enet(void);
void imxccm_enable_sata(void);
diff --git a/sys/arch/armv7/imx/imxehci.c b/sys/arch/armv7/imx/imxehci.c
index 82953699a88..9bd56047c53 100644
--- a/sys/arch/armv7/imx/imxehci.c
+++ b/sys/arch/armv7/imx/imxehci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: imxehci.c,v 1.22 2018/04/01 22:28:54 patrick Exp $ */
+/* $OpenBSD: imxehci.c,v 1.23 2018/04/02 16:03:50 patrick Exp $ */
/*
* Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se>
*
@@ -124,7 +124,8 @@ imxehci_attach(struct device *parent, struct device *self, void *aux)
uint32_t misc_reg[2];
uint32_t anatop[1];
uint32_t vbus;
- int node;
+ int misc_node;
+ int phy_node;
if (faa->fa_nreg < 1)
return;
@@ -137,23 +138,23 @@ imxehci_attach(struct device *parent, struct device *self, void *aux)
misc, sizeof(misc)) != sizeof(misc))
return;
- node = OF_getnodebyphandle(phy[0]);
- if (node == 0)
+ phy_node = OF_getnodebyphandle(phy[0]);
+ if (phy_node == 0)
return;
- if (OF_getpropintarray(node, "reg", phy_reg,
+ if (OF_getpropintarray(phy_node, "reg", phy_reg,
sizeof(phy_reg)) != sizeof(phy_reg))
return;
- if (OF_getpropintarray(node, "fsl,anatop",
+ if (OF_getpropintarray(phy_node, "fsl,anatop",
anatop, sizeof(anatop)) == sizeof(anatop))
rm = regmap_byphandle(anatop[0]);
- node = OF_getnodebyphandle(misc[0]);
- if (node == 0)
+ misc_node = OF_getnodebyphandle(misc[0]);
+ if (misc_node == 0)
return;
- if (OF_getpropintarray(node, "reg", misc_reg,
+ if (OF_getpropintarray(misc_node, "reg", misc_reg,
sizeof(misc_reg)) != sizeof(misc_reg))
return;
@@ -206,7 +207,7 @@ imxehci_attach(struct device *parent, struct device *self, void *aux)
ANALOG_USB1_CHRG_DETECT_EN_B);
/* power host 0 */
- imxccm_enable_pll_usb1();
+ clock_enable(phy_node, NULL);
/* over current and polarity setting */
bus_space_write_4(sc->sc.iot, sc->nc_ioh, USBNC_USB_OTG_CTRL,
@@ -221,7 +222,7 @@ imxehci_attach(struct device *parent, struct device *self, void *aux)
ANALOG_USB2_CHRG_DETECT_EN_B);
/* power host 1 */
- imxccm_enable_pll_usb2();
+ clock_enable(phy_node, NULL);
/* over current and polarity setting */
bus_space_write_4(sc->sc.iot, sc->nc_ioh, USBNC_USB_UH1_CTRL,