diff options
author | Patrick Wildt <patrick@cvs.openbsd.org> | 2018-04-02 16:39:21 +0000 |
---|---|---|
committer | Patrick Wildt <patrick@cvs.openbsd.org> | 2018-04-02 16:39:21 +0000 |
commit | 200d34c83fad73c559f50806b65a9a27a663b5e4 (patch) | |
tree | 97f72cd1bbc2c2cbcfcfbb73ed1084f9343061c7 /sys | |
parent | 47eb16d91ff7bb94103016773ac39953c44eb019 (diff) |
Have fec(4) make use of the clock framework by implementing the enet
ref clock in imxccm(4). We can now also remove the global variable
that stored the pointer to the imxccm(4) softc.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/armv7/imx/if_fec.c | 6 | ||||
-rw-r--r-- | sys/arch/armv7/imx/imxccm.c | 26 | ||||
-rw-r--r-- | sys/arch/armv7/imx/imxccm_clocks.h | 1 | ||||
-rw-r--r-- | sys/arch/armv7/imx/imxccmvar.h | 23 |
4 files changed, 13 insertions, 43 deletions
diff --git a/sys/arch/armv7/imx/if_fec.c b/sys/arch/armv7/imx/if_fec.c index f77eff078ca..e7ae8576f77 100644 --- a/sys/arch/armv7/imx/if_fec.c +++ b/sys/arch/armv7/imx/if_fec.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_fec.c,v 1.24 2018/04/01 18:50:54 patrick Exp $ */ +/* $OpenBSD: if_fec.c,v 1.25 2018/04/02 16:39:20 patrick Exp $ */ /* * Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se> * @@ -44,8 +44,6 @@ #include <dev/mii/miivar.h> #include <dev/mii/miidevs.h> -#include <armv7/imx/imxccmvar.h> - #include <dev/ofw/openfirm.h> #include <dev/ofw/ofw_clock.h> #include <dev/ofw/ofw_gpio.h> @@ -301,7 +299,7 @@ fec_attach(struct device *parent, struct device *self, void *aux) pinctrl_byname(faa->fa_node, "default"); /* power it up */ - imxccm_enable_enet(); + clock_enable_all(faa->fa_node); /* reset PHY */ if (OF_getpropintarray(faa->fa_node, "phy-reset-gpios", phy_reset_gpio, diff --git a/sys/arch/armv7/imx/imxccm.c b/sys/arch/armv7/imx/imxccm.c index edc3f02862b..7f782c2d4c6 100644 --- a/sys/arch/armv7/imx/imxccm.c +++ b/sys/arch/armv7/imx/imxccm.c @@ -1,4 +1,4 @@ -/* $OpenBSD: imxccm.c,v 1.17 2018/04/02 16:18:45 patrick Exp $ */ +/* $OpenBSD: imxccm.c,v 1.18 2018/04/02 16:39:20 patrick Exp $ */ /* * Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se> * @@ -213,8 +213,6 @@ enum clocks { USB1_PLL3_PFD3, /* 454.7 MHz */ }; -struct imxccm_softc *imxccm_sc; - int imxccm_match(struct device *, void *, void *); void imxccm_attach(struct device *parent, struct device *self, void *args); @@ -241,8 +239,8 @@ void imxccm_enable(void *, uint32_t *, int); uint32_t imxccm_get_frequency(void *, uint32_t *); 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_pll_enet(struct imxccm_softc *); +void imxccm_enable_enet(struct imxccm_softc *); void imxccm_enable_sata(struct imxccm_softc *); int @@ -264,7 +262,6 @@ imxccm_attach(struct device *parent, struct device *self, void *aux) KASSERT(faa->fa_nreg >= 1); - imxccm_sc = sc; sc->sc_node = faa->fa_node; sc->sc_iot = faa->fa_iot; if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr, @@ -494,6 +491,9 @@ imxccm_enable(void *cookie, uint32_t *cells, int on) case IMX6_CLK_SATA_REF_100: imxccm_enable_sata(sc); return; + case IMX6_CLK_ENET_REF: + imxccm_enable_enet(sc); + return; default: break; } @@ -568,10 +568,8 @@ imxccm_get_frequency(void *cookie, uint32_t *cells) } void -imxccm_enable_pll_enet(void) +imxccm_enable_pll_enet(struct imxccm_softc *sc) { - struct imxccm_softc *sc = imxccm_sc; - if (HREAD4(sc, CCM_ANALOG_PLL_ENET) & CCM_ANALOG_PLL_ENET_ENABLE) return; @@ -585,20 +583,16 @@ imxccm_enable_pll_enet(void) } void -imxccm_enable_enet(void) +imxccm_enable_enet(struct imxccm_softc *sc) { - struct imxccm_softc *sc = imxccm_sc; - - imxccm_enable_pll_enet(); + imxccm_enable_pll_enet(sc); HWRITE4(sc, CCM_ANALOG_PLL_ENET_SET, CCM_ANALOG_PLL_ENET_DIV_125M); - - HSET4(sc, CCM_CCGR1, CCM_CCGR1_ENET); } void imxccm_enable_sata(struct imxccm_softc *sc) { - imxccm_enable_pll_enet(); + imxccm_enable_pll_enet(sc); HWRITE4(sc, CCM_ANALOG_PLL_ENET_SET, CCM_ANALOG_PLL_ENET_100M_SATA); } diff --git a/sys/arch/armv7/imx/imxccm_clocks.h b/sys/arch/armv7/imx/imxccm_clocks.h index aed158d1524..2bf09ffb954 100644 --- a/sys/arch/armv7/imx/imxccm_clocks.h +++ b/sys/arch/armv7/imx/imxccm_clocks.h @@ -24,6 +24,7 @@ #define IMX6_CLK_USBPHY2 0xb7 #define IMX6_CLK_SATA_REF 0xba #define IMX6_CLK_SATA_REF_100 0xbb +#define IMX6_CLK_ENET_REF 0xbe 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 deleted file mode 100644 index 443ddd63818..00000000000 --- a/sys/arch/armv7/imx/imxccmvar.h +++ /dev/null @@ -1,23 +0,0 @@ -/* $OpenBSD: imxccmvar.h,v 1.9 2018/04/02 16:18:45 patrick Exp $ */ -/* - * Copyright (c) 2012-2013 Patrick Wildt <patrick@blueri.se> - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef IMXCCMVAR_H -#define IMXCCMVAR_H - -void imxccm_enable_enet(void); - -#endif /* IMXCCMVAR_H */ |