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.  Of course, the imx6 ccm code is still more a wish than
reality, so for now its implementations just return hard-coded numbers.
This commit is contained in:
Ian Lepore 2014-04-26 16:48:09 +00:00
parent cf58751a44
commit a7fa939bb3
9 changed files with 122 additions and 51 deletions

View File

@ -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));
}

View File

@ -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
}
// 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_ipg_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 (66000000);
}
uint32_t
imx_ccm_perclk_hz(void)
{
return (66000000);
}
uint32_t
imx_ccm_sdhci_hz(void)
{
return (200000000);
}
uint32_t
imx_ccm_uart_hz(void)
{
return (80000000);
}
static device_method_t ccm_methods[] = {

View File

@ -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>

View File

@ -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

View File

@ -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;

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -60,7 +60,7 @@ __FBSDID("$FreeBSD$");
#include <machine/bus.h>
#include <machine/resource.h>
#include <arm/freescale/imx/imx_machdep.h>
#include <arm/freescale/imx/imx_ccmvar.h>
#include "opt_platform.h"