From 41475be3f91b47a1b743388c2a791b4ac006ec54 Mon Sep 17 00:00:00 2001 From: andrew Date: Sun, 25 May 2014 10:49:07 +0000 Subject: [PATCH] Allow the OMAP4 and AM335x prcm drivers to be compiled in the same kernel by renaming the structures used. --- sys/arm/ti/am335x/am335x_prcm.c | 2 +- sys/arm/ti/omap4/omap4_prcm_clks.c | 2 +- sys/arm/ti/ti_prcm.c | 22 +++++++++++++++++++--- 3 files changed, 21 insertions(+), 5 deletions(-) diff --git a/sys/arm/ti/am335x/am335x_prcm.c b/sys/arm/ti/am335x/am335x_prcm.c index 325a83885f2e..7537a33fc47c 100644 --- a/sys/arm/ti/am335x/am335x_prcm.c +++ b/sys/arm/ti/am335x/am335x_prcm.c @@ -190,7 +190,7 @@ static int am335x_clk_pruss_activate(struct ti_clock_dev *clkdev); .clk_get_source_freq = am335x_clk_hsmmc_get_source_freq \ } -struct ti_clock_dev ti_clk_devmap[] = { +struct ti_clock_dev ti_am335x_clk_devmap[] = { /* System clocks */ { .id = SYS_CLK, .clk_activate = NULL, diff --git a/sys/arm/ti/omap4/omap4_prcm_clks.c b/sys/arm/ti/omap4/omap4_prcm_clks.c index 7fa59b3c8bf0..589f15696e2f 100644 --- a/sys/arm/ti/omap4/omap4_prcm_clks.c +++ b/sys/arm/ti/omap4/omap4_prcm_clks.c @@ -256,7 +256,7 @@ static int omap4_clk_get_arm_fclk_freq(struct ti_clock_dev *clkdev, unsigned int } -struct ti_clock_dev ti_clk_devmap[] = { +struct ti_clock_dev ti_omap4_clk_devmap[] = { /* System clocks */ { .id = SYS_CLK, diff --git a/sys/arm/ti/ti_prcm.c b/sys/arm/ti/ti_prcm.c index 89a23772711e..3c073f995a69 100644 --- a/sys/arm/ti/ti_prcm.c +++ b/sys/arm/ti/ti_prcm.c @@ -57,16 +57,18 @@ __FBSDID("$FreeBSD$"); #include #include +#include #include /** - * ti_clk_devmap - Array of clock devices, should be defined one per SoC + * ti_*_clk_devmap - Array of clock devices, should be defined one per SoC * * This array is typically defined in one of the targeted *_prcm_clk.c * files and is specific to the given SoC platform. Each entry in the array * corresponds to an individual clock device. */ -extern struct ti_clock_dev ti_clk_devmap[]; +extern struct ti_clock_dev ti_omap4_clk_devmap[]; +extern struct ti_clock_dev ti_am335x_clk_devmap[]; /** * ti_prcm_clk_dev - returns a pointer to the clock device with given id @@ -90,7 +92,21 @@ ti_prcm_clk_dev(clk_ident_t clk) * loop for this, but this function should only called when a driver is * being activated so IMHO not a big issue. */ - clk_dev = &(ti_clk_devmap[0]); + clk_dev = NULL; + switch(ti_chip()) { +#ifdef SOC_OMAP4 + case CHIP_OMAP_4: + clk_dev = &(ti_omap4_clk_devmap[0]); + break; +#endif +#ifdef SOC_TI_AM335X + case CHIP_AM335X: + clk_dev = &(ti_am335x_clk_devmap[0]); + break; +#endif + } + if (clk_dev == NULL) + panic("No clock devmap found"); while (clk_dev->id != INVALID_CLK_IDENT) { if (clk_dev->id == clk) { return (clk_dev);