diff options
author | ian <ian@FreeBSD.org> | 2014-05-17 22:29:24 +0000 |
---|---|---|
committer | ian <ian@FreeBSD.org> | 2014-05-17 22:29:24 +0000 |
commit | b256d044788601c05cbc1bef496c805bbc6e510f (patch) | |
tree | 10768a4ade42881ab0e3e02b4461d44026e89ba3 /sys/arm/freescale | |
parent | fd20bf61eac3a3458694db9c476f54abef0077ea (diff) | |
download | FreeBSD-src-b256d044788601c05cbc1bef496c805bbc6e510f.zip FreeBSD-src-b256d044788601c05cbc1bef496c805bbc6e510f.tar.gz |
MFC 264977:
Stop calling imx51_ccm_foo() clock functions from imx6 code. Instead
define a few imx_ccm_foo() functions that are implemented by the imx51
or imx6 ccm code.
Diffstat (limited to 'sys/arm/freescale')
-rw-r--r-- | sys/arm/freescale/imx/imx51_ccm.c | 28 | ||||
-rw-r--r-- | sys/arm/freescale/imx/imx6_ccm.c | 46 | ||||
-rw-r--r-- | sys/arm/freescale/imx/imx6_usbphy.c | 2 | ||||
-rw-r--r-- | sys/arm/freescale/imx/imx_ccmvar.h | 54 | ||||
-rw-r--r-- | sys/arm/freescale/imx/imx_gpt.c | 6 | ||||
-rw-r--r-- | sys/arm/freescale/imx/imx_machdep.h | 16 | ||||
-rw-r--r-- | sys/arm/freescale/imx/imx_nop_usbphy.c | 2 | ||||
-rw-r--r-- | sys/arm/freescale/imx/imx_sdhci.c | 9 |
8 files changed, 117 insertions, 46 deletions
diff --git a/sys/arm/freescale/imx/imx51_ccm.c b/sys/arm/freescale/imx/imx51_ccm.c index 61fdfdc..e004364 100644 --- a/sys/arm/freescale/imx/imx51_ccm.c +++ b/sys/arm/freescale/imx/imx51_ccm.c @@ -83,6 +83,7 @@ __FBSDID("$FreeBSD$"); #include <arm/freescale/imx/imx51_ccmvar.h> #include <arm/freescale/imx/imx51_ccmreg.h> #include <arm/freescale/imx/imx51_dpllreg.h> +#include <arm/freescale/imx/imx_ccmvar.h> #include <arm/freescale/imx/imx_machdep.h> #define IMXCCMDEBUG @@ -552,3 +553,30 @@ imx_ccm_usbphy_enable(device_t dev) } } +uint32_t +imx_ccm_ipg_hz(void) +{ + + return (imx51_get_clock(IMX51CLK_IPG_CLK_ROOT)); +} + +uint32_t +imx_ccm_sdhci_hz(void) +{ + + return (imx51_get_clock(IMX51CLK_ESDHC1_CLK_ROOT)); +} + +uint32_t +imx_ccm_perclk_hz(void) +{ + + return (imx51_get_clock(IMX51CLK_PERCLK_ROOT)); +} + +uint32_t +imx_ccm_uart_hz(void) +{ + + return (imx51_get_clock(IMX51CLK_UART_CLK_ROOT)); +} diff --git a/sys/arm/freescale/imx/imx6_ccm.c b/sys/arm/freescale/imx/imx6_ccm.c index 2ed301f..132c31c 100644 --- a/sys/arm/freescale/imx/imx6_ccm.c +++ b/sys/arm/freescale/imx/imx6_ccm.c @@ -45,13 +45,15 @@ __FBSDID("$FreeBSD$"); #include <arm/freescale/imx/imx6_anatopreg.h> #include <arm/freescale/imx/imx6_anatopvar.h> -#include <arm/freescale/imx/imx_machdep.h> #include <arm/freescale/imx/imx6_ccmreg.h> +#include <arm/freescale/imx/imx_machdep.h> +#include <arm/freescale/imx/imx_ccmvar.h> - -/* XXX temp kludge for imx51_get_clock. */ -#include <arm/freescale/imx/imx51_ccmvar.h> -#include <arm/freescale/imx/imx51_ccmreg.h> +#ifndef CCGR_CLK_MODE_ALWAYS +#define CCGR_CLK_MODE_OFF 0 +#define CCGR_CLK_MODE_RUNMODE 1 +#define CCGR_CLK_MODE_ALWAYS 3 +#endif struct ccm_softc { device_t dev; @@ -208,24 +210,32 @@ imx_ccm_usbphy_enable(device_t _phydev) #endif } +uint32_t +imx_ccm_ipg_hz(void) +{ + + return (66000000); +} + +uint32_t +imx_ccm_perclk_hz(void) +{ + return (66000000); +} +uint32_t +imx_ccm_sdhci_hz(void) +{ + return (200000000); +} -// XXX Fix this. This has to be here for other code to link, -// but it doesn't have to return anything useful for imx6 right now. -u_int -imx51_get_clock(enum imx51_clock clk) +uint32_t +imx_ccm_uart_hz(void) { - switch (clk) - { - case IMX51CLK_IPG_CLK_ROOT: - return 66000000; - default: - printf("imx51_get_clock() on imx6 doesn't know about clock %d\n", clk); - break; - } - return 0; + + return (80000000); } static device_method_t ccm_methods[] = { diff --git a/sys/arm/freescale/imx/imx6_usbphy.c b/sys/arm/freescale/imx/imx6_usbphy.c index 7f3e362..a338737 100644 --- a/sys/arm/freescale/imx/imx6_usbphy.c +++ b/sys/arm/freescale/imx/imx6_usbphy.c @@ -45,7 +45,7 @@ __FBSDID("$FreeBSD$"); #include <machine/bus.h> -#include <arm/freescale/imx/imx_machdep.h> +#include <arm/freescale/imx/imx_ccmvar.h> #include <arm/freescale/imx/imx6_anatopreg.h> #include <arm/freescale/imx/imx6_anatopvar.h> diff --git a/sys/arm/freescale/imx/imx_ccmvar.h b/sys/arm/freescale/imx/imx_ccmvar.h new file mode 100644 index 0000000..bb41a02 --- /dev/null +++ b/sys/arm/freescale/imx/imx_ccmvar.h @@ -0,0 +1,54 @@ +/*- + * Copyright (c) 2014 Ian Lepore <ian@freebsd.org> + * All rights reserved. + * + * 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 AUTHOR 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 AUTHOR 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. + * + * $FreeBSD$ + */ + +#ifndef IMX_CCMVAR_H +#define IMX_CCMVAR_H + +/* + * We need a clock management system that works across unrelated SoCs and + * devices. For now, to keep imx development moving, define some barebones + * functionality that can be shared within the imx family by having each SoC + * implement functions with a common name. + * + * The usb enable functions are best-effort. They turn on the usb otg, host, + * and phy clocks in a SoC-specific manner, but it may take a lot more than that + * to make usb work on a given board. In particular, it can require specific + * pinmux setup of gpio pins connected to external phy parts, voltage regulators + * and overcurrent detectors, and so on. On such boards, u-boot or other early + * board setup code has to handle those things. + */ + +uint32_t imx_ccm_ipg_hz(void); +uint32_t imx_ccm_perclk_hz(void); +uint32_t imx_ccm_sdhci_hz(void); +uint32_t imx_ccm_uart_hz(void); + +void imx_ccm_usb_enable(device_t _usbdev); +void imx_ccm_usbphy_enable(device_t _phydev); + +#endif diff --git a/sys/arm/freescale/imx/imx_gpt.c b/sys/arm/freescale/imx/imx_gpt.c index 73bc8ec..abbb140 100644 --- a/sys/arm/freescale/imx/imx_gpt.c +++ b/sys/arm/freescale/imx/imx_gpt.c @@ -54,7 +54,7 @@ __FBSDID("$FreeBSD$"); #include <arm/freescale/imx/imx_gptreg.h> #include <sys/kdb.h> -#include <arm/freescale/imx/imx51_ccmvar.h> +#include <arm/freescale/imx/imx_ccmvar.h> #define WRITE4(_sc, _r, _v) \ bus_space_write_4((_sc)->sc_iot, (_sc)->sc_ioh, (_r), (_v)) @@ -164,10 +164,10 @@ imx_gpt_attach(device_t dev) basefreq = 32768; break; case GPT_CR_CLKSRC_IPG: - basefreq = imx51_get_clock(IMX51CLK_IPG_CLK_ROOT); + basefreq = imx_ccm_ipg_hz(); break; case GPT_CR_CLKSRC_IPG_HIGH: - basefreq = imx51_get_clock(IMX51CLK_IPG_CLK_ROOT) * 2; + basefreq = imx_ccm_ipg_hz() * 2; break; case GPT_CR_CLKSRC_24M: ctlreg |= GPT_CR_24MEN; diff --git a/sys/arm/freescale/imx/imx_machdep.h b/sys/arm/freescale/imx/imx_machdep.h index b78f0da..6909e51 100644 --- a/sys/arm/freescale/imx/imx_machdep.h +++ b/sys/arm/freescale/imx/imx_machdep.h @@ -56,21 +56,5 @@ void imx_wdog_cpu_reset(vm_offset_t _wdcr_phys) __attribute__((__noreturn__)); u_int imx_soc_type(void); u_int imx_soc_family(void); -/* - * We need a clock management system that works across unrelated SoCs and - * devices. For now, to keep imx development moving, define some barebones - * functionality that can be shared within the imx family by having each SoC - * implement functions with a common name. - * - * The usb enable functions are best-effort. They turn on the usb otg, host, - * and phy clocks in a SoC-specific manner, but it may take a lot more than that - * to make usb work on a given board. In particular, it can require specific - * pinmux setup of gpio pins connected to external phy parts, voltage regulators - * and overcurrent detectors, and so on. On such boards, u-boot or other early - * board setup code has to handle those things. - */ -void imx_ccm_usb_enable(device_t _usbdev); -void imx_ccm_usbphy_enable(device_t _phydev); - #endif diff --git a/sys/arm/freescale/imx/imx_nop_usbphy.c b/sys/arm/freescale/imx/imx_nop_usbphy.c index 38473dd..49bebfc 100644 --- a/sys/arm/freescale/imx/imx_nop_usbphy.c +++ b/sys/arm/freescale/imx/imx_nop_usbphy.c @@ -47,7 +47,7 @@ __FBSDID("$FreeBSD$"); #include <machine/bus.h> -#include <arm/freescale/imx/imx_machdep.h> +#include <arm/freescale/imx/imx_ccmvar.h> /* * Table of supported FDT compat strings. diff --git a/sys/arm/freescale/imx/imx_sdhci.c b/sys/arm/freescale/imx/imx_sdhci.c index 2e3d1a5..a476cb7 100644 --- a/sys/arm/freescale/imx/imx_sdhci.c +++ b/sys/arm/freescale/imx/imx_sdhci.c @@ -52,7 +52,7 @@ __FBSDID("$FreeBSD$"); #include <machine/resource.h> #include <machine/intr.h> -#include <arm/freescale/imx/imx51_ccmvar.h> +#include <arm/freescale/imx/imx_ccmvar.h> #include <dev/ofw/ofw_bus.h> #include <dev/ofw/ofw_bus_subr.h> @@ -723,12 +723,7 @@ imx_sdhci_attach(device_t dev) */ WR4(sc, SDHC_WTMK_LVL, 0x08800880); - /* XXX get imx6 clock frequency from CCM */ - if (sc->hwtype == HWTYPE_USDHC) { - sc->baseclk_hz = 200000000; - } else if (sc->hwtype == HWTYPE_ESDHC) { - sc->baseclk_hz = imx51_get_clock(IMX51CLK_PERCLK_ROOT); - } + sc->baseclk_hz = imx_ccm_sdhci_hz(); /* * If the slot is flagged with the non-removable property, set our flag |