Skip to content

Commit

Permalink
ARM: spear: make clock driver independent of headers
Browse files Browse the repository at this point in the history
Device drivers should not access MMIO registers through hardcoded
platform specific address constants. Instead, we can pass the
MMIO token to the spear clock driver in the initialization routine
to contain that knowledge in the platform code itself.

Ideally, the clock driver would use of_iomap() or similar to
get the address, and that can be used later, but for now, this
is the minimal change.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
  • Loading branch information
Arnd Bergmann committed Mar 12, 2013
1 parent 2b9c613 commit d9909eb
Show file tree
Hide file tree
Showing 12 changed files with 143 additions and 142 deletions.
13 changes: 7 additions & 6 deletions arch/arm/mach-spear/generic.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ extern struct dw_dma_slave nand_write_dma_priv;
bool dw_dma_filter(struct dma_chan *chan, void *slave);

void __init spear_setup_of_timer(void);
void __init spear3xx_clk_init(void);
void __init spear3xx_clk_init(void __iomem *misc_base,
void __iomem *soc_config_base);
void __init spear3xx_map_io(void);
void __init spear3xx_dt_init_irq(void);
void __init spear6xx_clk_init(void);
void __init spear6xx_clk_init(void __iomem *misc_base);
void __init spear13xx_map_io(void);
void __init spear13xx_l2x0_init(void);

Expand All @@ -44,15 +45,15 @@ void __cpuinit spear13xx_cpu_die(unsigned int cpu);
extern struct smp_operations spear13xx_smp_ops;

#ifdef CONFIG_MACH_SPEAR1310
void __init spear1310_clk_init(void);
void __init spear1310_clk_init(void __iomem *misc_base, void __iomem *ras_base);
#else
static inline void spear1310_clk_init(void) {}
static inline void spear1310_clk_init(void __iomem *misc_base, void __iomem *ras_base) {}
#endif

#ifdef CONFIG_MACH_SPEAR1340
void __init spear1340_clk_init(void);
void __init spear1340_clk_init(void __iomem *misc_base);
#else
static inline void spear1340_clk_init(void) {}
static inline void spear1340_clk_init(void __iomem *misc_base) {}
#endif

#endif /* __MACH_GENERIC_H */
2 changes: 1 addition & 1 deletion arch/arm/mach-spear/include/mach/misc_regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#include <mach/spear.h>

#define MISC_BASE IOMEM(VA_SPEAR_ICM3_MISC_REG_BASE)
#define MISC_BASE (VA_SPEAR_ICM3_MISC_REG_BASE)
#define DMA_CHN_CFG (MISC_BASE + 0x0A0)

#endif /* __MACH_MISC_REGS_H */
28 changes: 11 additions & 17 deletions arch/arm/mach-spear/include/mach/spear.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@

/* ICM1 - Low speed connection */
#define SPEAR_ICM1_2_BASE UL(0xD0000000)
#define VA_SPEAR_ICM1_2_BASE UL(0xFD000000)
#define VA_SPEAR_ICM1_2_BASE IOMEM(0xFD000000)
#define SPEAR_ICM1_UART_BASE UL(0xD0000000)
#define VA_SPEAR_ICM1_UART_BASE (VA_SPEAR_ICM1_2_BASE | SPEAR_ICM1_UART_BASE)
#define VA_SPEAR_ICM1_UART_BASE (VA_SPEAR_ICM1_2_BASE - SPEAR_ICM1_2_BASE + SPEAR_ICM1_UART_BASE)
#define SPEAR3XX_ICM1_SSP_BASE UL(0xD0100000)

/* ML-1, 2 - Multi Layer CPU Subsystem */
#define SPEAR_ICM3_ML1_2_BASE UL(0xF0000000)
#define VA_SPEAR6XX_ML_CPU_BASE UL(0xF0000000)
#define VA_SPEAR6XX_ML_CPU_BASE IOMEM(0xF0000000)

/* ICM3 - Basic Subsystem */
#define SPEAR_ICM3_SMI_CTRL_BASE UL(0xFC000000)
#define VA_SPEAR_ICM3_SMI_CTRL_BASE UL(0xFC000000)
#define VA_SPEAR_ICM3_SMI_CTRL_BASE IOMEM(0xFC000000)
#define SPEAR_ICM3_DMA_BASE UL(0xFC400000)
#define SPEAR_ICM3_SYS_CTRL_BASE UL(0xFCA00000)
#define VA_SPEAR_ICM3_SYS_CTRL_BASE (VA_SPEAR_ICM3_SMI_CTRL_BASE | SPEAR_ICM3_SYS_CTRL_BASE)
#define VA_SPEAR_ICM3_SYS_CTRL_BASE (VA_SPEAR_ICM3_SMI_CTRL_BASE - SPEAR_ICM3_SMI_CTRL_BASE + SPEAR_ICM3_SYS_CTRL_BASE)
#define SPEAR_ICM3_MISC_REG_BASE UL(0xFCA80000)
#define VA_SPEAR_ICM3_MISC_REG_BASE (VA_SPEAR_ICM3_SMI_CTRL_BASE | SPEAR_ICM3_MISC_REG_BASE)
#define VA_SPEAR_ICM3_MISC_REG_BASE (VA_SPEAR_ICM3_SMI_CTRL_BASE - SPEAR_ICM3_SMI_CTRL_BASE + SPEAR_ICM3_MISC_REG_BASE)

/* Debug uart for linux, will be used for debug and uncompress messages */
#define SPEAR_DBG_UART_BASE SPEAR_ICM1_UART_BASE
Expand All @@ -44,20 +44,11 @@
/* Sysctl base for spear platform */
#define SPEAR_SYS_CTRL_BASE SPEAR_ICM3_SYS_CTRL_BASE
#define VA_SPEAR_SYS_CTRL_BASE VA_SPEAR_ICM3_SYS_CTRL_BASE
#endif /* SPEAR3xx || SPEAR6XX */

/* SPEAr320 Macros */
#define SPEAR320_SOC_CONFIG_BASE UL(0xB3000000)
#define VA_SPEAR320_SOC_CONFIG_BASE UL(0xFE000000)
#define SPEAR320_CONTROL_REG IOMEM(VA_SPEAR320_SOC_CONFIG_BASE)
#define SPEAR320_EXT_CTRL_REG IOMEM(VA_SPEAR320_SOC_CONFIG_BASE + 0x0018)
#define SPEAR320_UARTX_PCLK_MASK 0x1
#define SPEAR320_UART2_PCLK_SHIFT 8
#define SPEAR320_UART3_PCLK_SHIFT 9
#define SPEAR320_UART4_PCLK_SHIFT 10
#define SPEAR320_UART5_PCLK_SHIFT 11
#define SPEAR320_UART6_PCLK_SHIFT 12
#define SPEAR320_RS485_PCLK_SHIFT 13
#endif /* SPEAR3xx || SPEAR6XX */
#define VA_SPEAR320_SOC_CONFIG_BASE IOMEM(0xFE000000)

#ifdef CONFIG_ARCH_SPEAR13XX

Expand All @@ -79,6 +70,9 @@
#define A9SM_AND_MPMC_BASE UL(0xEC000000)
#define VA_A9SM_AND_MPMC_BASE IOMEM(0xFC000000)

#define SPEAR1310_RAS_BASE UL(0xD8400000)
#define VA_SPEAR1310_RAS_BASE IOMEM(UL(0xFA400000))

/* A9SM peripheral offsets */
#define A9SM_PERIP_BASE UL(0xEC800000)
#define VA_A9SM_PERIP_BASE IOMEM(0xFC800000)
Expand Down
2 changes: 0 additions & 2 deletions arch/arm/mach-spear/spear1310.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@

#define SPEAR1310_RAS_GRP1_BASE UL(0xD8000000)
#define VA_SPEAR1310_RAS_GRP1_BASE UL(0xFA000000)
#define SPEAR1310_RAS_BASE UL(0xD8400000)
#define VA_SPEAR1310_RAS_BASE IOMEM(UL(0xFA400000))

static struct arasan_cf_pdata cf_pdata = {
.cf_if_clk = CF_IF_CLK_166M,
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/mach-spear/spear13xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,9 @@ void __init spear13xx_map_io(void)
static void __init spear13xx_clk_init(void)
{
if (of_machine_is_compatible("st,spear1310"))
spear1310_clk_init();
spear1310_clk_init(VA_MISC_BASE, VA_SPEAR1310_RAS_BASE);
else if (of_machine_is_compatible("st,spear1340"))
spear1340_clk_init();
spear1340_clk_init(VA_MISC_BASE);
else
pr_err("%s: Unknown machine\n", __func__);
}
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-spear/spear320.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ static const char * const spear320_dt_board_compat[] = {

struct map_desc spear320_io_desc[] __initdata = {
{
.virtual = VA_SPEAR320_SOC_CONFIG_BASE,
.virtual = (unsigned long)VA_SPEAR320_SOC_CONFIG_BASE,
.pfn = __phys_to_pfn(SPEAR320_SOC_CONFIG_BASE),
.length = SZ_16M,
.type = MT_DEVICE
Expand Down
7 changes: 4 additions & 3 deletions arch/arm/mach-spear/spear3xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "pl080.h"
#include "generic.h"
#include <mach/spear.h>
#include <mach/misc_regs.h>

/* ssp device registration */
struct pl022_ssp_controller pl022_plat_data = {
Expand Down Expand Up @@ -67,12 +68,12 @@ struct pl08x_platform_data pl080_plat_data = {
*/
struct map_desc spear3xx_io_desc[] __initdata = {
{
.virtual = VA_SPEAR_ICM1_2_BASE,
.virtual = (unsigned long)VA_SPEAR_ICM1_2_BASE,
.pfn = __phys_to_pfn(SPEAR_ICM1_2_BASE),
.length = SZ_16M,
.type = MT_DEVICE
}, {
.virtual = VA_SPEAR_ICM3_SMI_CTRL_BASE,
.virtual = (unsigned long)VA_SPEAR_ICM3_SMI_CTRL_BASE,
.pfn = __phys_to_pfn(SPEAR_ICM3_SMI_CTRL_BASE),
.length = SZ_16M,
.type = MT_DEVICE
Expand All @@ -90,7 +91,7 @@ void __init spear3xx_timer_init(void)
char pclk_name[] = "pll3_clk";
struct clk *gpt_clk, *pclk;

spear3xx_clk_init();
spear3xx_clk_init(MISC_BASE, VA_SPEAR320_SOC_CONFIG_BASE);

/* get the system timer clock */
gpt_clk = clk_get_sys("gpt0", NULL);
Expand Down
9 changes: 5 additions & 4 deletions arch/arm/mach-spear/spear6xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "pl080.h"
#include "generic.h"
#include <mach/spear.h>
#include <mach/misc_regs.h>

/* dmac device registration */
static struct pl08x_channel_data spear600_dma_info[] = {
Expand Down Expand Up @@ -350,17 +351,17 @@ struct pl08x_platform_data pl080_plat_data = {
*/
struct map_desc spear6xx_io_desc[] __initdata = {
{
.virtual = VA_SPEAR6XX_ML_CPU_BASE,
.virtual = (unsigned long)VA_SPEAR6XX_ML_CPU_BASE,
.pfn = __phys_to_pfn(SPEAR_ICM3_ML1_2_BASE),
.length = 2 * SZ_16M,
.type = MT_DEVICE
}, {
.virtual = VA_SPEAR_ICM1_2_BASE,
.virtual = (unsigned long)VA_SPEAR_ICM1_2_BASE,
.pfn = __phys_to_pfn(SPEAR_ICM1_2_BASE),
.length = SZ_16M,
.type = MT_DEVICE
}, {
.virtual = VA_SPEAR_ICM3_SMI_CTRL_BASE,
.virtual = (unsigned long)VA_SPEAR_ICM3_SMI_CTRL_BASE,
.pfn = __phys_to_pfn(SPEAR_ICM3_SMI_CTRL_BASE),
.length = SZ_16M,
.type = MT_DEVICE
Expand All @@ -378,7 +379,7 @@ void __init spear6xx_timer_init(void)
char pclk_name[] = "pll3_clk";
struct clk *gpt_clk, *pclk;

spear6xx_clk_init();
spear6xx_clk_init(MISC_BASE);

/* get the system timer clock */
gpt_clk = clk_get_sys("gpt0", NULL);
Expand Down
64 changes: 31 additions & 33 deletions drivers/clk/spear/spear1310_clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
#include <linux/io.h>
#include <linux/of_platform.h>
#include <linux/spinlock_types.h>
#include <mach/spear.h>
#include "clk.h"

#define VA_SPEAR1310_RAS_BASE IOMEM(UL(0xFA400000))
/* PLL related registers and bit values */
#define SPEAR1310_PLL_CFG (VA_MISC_BASE + 0x210)
#define SPEAR1310_PLL_CFG (misc_base + 0x210)
/* PLL_CFG bit values */
#define SPEAR1310_CLCD_SYNT_CLK_MASK 1
#define SPEAR1310_CLCD_SYNT_CLK_SHIFT 31
Expand All @@ -35,15 +33,15 @@
#define SPEAR1310_PLL2_CLK_SHIFT 22
#define SPEAR1310_PLL1_CLK_SHIFT 20

#define SPEAR1310_PLL1_CTR (VA_MISC_BASE + 0x214)
#define SPEAR1310_PLL1_FRQ (VA_MISC_BASE + 0x218)
#define SPEAR1310_PLL2_CTR (VA_MISC_BASE + 0x220)
#define SPEAR1310_PLL2_FRQ (VA_MISC_BASE + 0x224)
#define SPEAR1310_PLL3_CTR (VA_MISC_BASE + 0x22C)
#define SPEAR1310_PLL3_FRQ (VA_MISC_BASE + 0x230)
#define SPEAR1310_PLL4_CTR (VA_MISC_BASE + 0x238)
#define SPEAR1310_PLL4_FRQ (VA_MISC_BASE + 0x23C)
#define SPEAR1310_PERIP_CLK_CFG (VA_MISC_BASE + 0x244)
#define SPEAR1310_PLL1_CTR (misc_base + 0x214)
#define SPEAR1310_PLL1_FRQ (misc_base + 0x218)
#define SPEAR1310_PLL2_CTR (misc_base + 0x220)
#define SPEAR1310_PLL2_FRQ (misc_base + 0x224)
#define SPEAR1310_PLL3_CTR (misc_base + 0x22C)
#define SPEAR1310_PLL3_FRQ (misc_base + 0x230)
#define SPEAR1310_PLL4_CTR (misc_base + 0x238)
#define SPEAR1310_PLL4_FRQ (misc_base + 0x23C)
#define SPEAR1310_PERIP_CLK_CFG (misc_base + 0x244)
/* PERIP_CLK_CFG bit values */
#define SPEAR1310_GPT_OSC24_VAL 0
#define SPEAR1310_GPT_APB_VAL 1
Expand All @@ -65,15 +63,15 @@
#define SPEAR1310_C3_CLK_MASK 1
#define SPEAR1310_C3_CLK_SHIFT 1

#define SPEAR1310_GMAC_CLK_CFG (VA_MISC_BASE + 0x248)
#define SPEAR1310_GMAC_CLK_CFG (misc_base + 0x248)
#define SPEAR1310_GMAC_PHY_IF_SEL_MASK 3
#define SPEAR1310_GMAC_PHY_IF_SEL_SHIFT 4
#define SPEAR1310_GMAC_PHY_CLK_MASK 1
#define SPEAR1310_GMAC_PHY_CLK_SHIFT 3
#define SPEAR1310_GMAC_PHY_INPUT_CLK_MASK 2
#define SPEAR1310_GMAC_PHY_INPUT_CLK_SHIFT 1

#define SPEAR1310_I2S_CLK_CFG (VA_MISC_BASE + 0x24C)
#define SPEAR1310_I2S_CLK_CFG (misc_base + 0x24C)
/* I2S_CLK_CFG register mask */
#define SPEAR1310_I2S_SCLK_X_MASK 0x1F
#define SPEAR1310_I2S_SCLK_X_SHIFT 27
Expand All @@ -91,21 +89,21 @@
#define SPEAR1310_I2S_SRC_CLK_MASK 2
#define SPEAR1310_I2S_SRC_CLK_SHIFT 0

#define SPEAR1310_C3_CLK_SYNT (VA_MISC_BASE + 0x250)
#define SPEAR1310_UART_CLK_SYNT (VA_MISC_BASE + 0x254)
#define SPEAR1310_GMAC_CLK_SYNT (VA_MISC_BASE + 0x258)
#define SPEAR1310_SDHCI_CLK_SYNT (VA_MISC_BASE + 0x25C)
#define SPEAR1310_CFXD_CLK_SYNT (VA_MISC_BASE + 0x260)
#define SPEAR1310_ADC_CLK_SYNT (VA_MISC_BASE + 0x264)
#define SPEAR1310_AMBA_CLK_SYNT (VA_MISC_BASE + 0x268)
#define SPEAR1310_CLCD_CLK_SYNT (VA_MISC_BASE + 0x270)
#define SPEAR1310_RAS_CLK_SYNT0 (VA_MISC_BASE + 0x280)
#define SPEAR1310_RAS_CLK_SYNT1 (VA_MISC_BASE + 0x288)
#define SPEAR1310_RAS_CLK_SYNT2 (VA_MISC_BASE + 0x290)
#define SPEAR1310_RAS_CLK_SYNT3 (VA_MISC_BASE + 0x298)
#define SPEAR1310_C3_CLK_SYNT (misc_base + 0x250)
#define SPEAR1310_UART_CLK_SYNT (misc_base + 0x254)
#define SPEAR1310_GMAC_CLK_SYNT (misc_base + 0x258)
#define SPEAR1310_SDHCI_CLK_SYNT (misc_base + 0x25C)
#define SPEAR1310_CFXD_CLK_SYNT (misc_base + 0x260)
#define SPEAR1310_ADC_CLK_SYNT (misc_base + 0x264)
#define SPEAR1310_AMBA_CLK_SYNT (misc_base + 0x268)
#define SPEAR1310_CLCD_CLK_SYNT (misc_base + 0x270)
#define SPEAR1310_RAS_CLK_SYNT0 (misc_base + 0x280)
#define SPEAR1310_RAS_CLK_SYNT1 (misc_base + 0x288)
#define SPEAR1310_RAS_CLK_SYNT2 (misc_base + 0x290)
#define SPEAR1310_RAS_CLK_SYNT3 (misc_base + 0x298)
/* Check Fractional synthesizer reg masks */

#define SPEAR1310_PERIP1_CLK_ENB (VA_MISC_BASE + 0x300)
#define SPEAR1310_PERIP1_CLK_ENB (misc_base + 0x300)
/* PERIP1_CLK_ENB register masks */
#define SPEAR1310_RTC_CLK_ENB 31
#define SPEAR1310_ADC_CLK_ENB 30
Expand Down Expand Up @@ -138,7 +136,7 @@
#define SPEAR1310_SYSROM_CLK_ENB 1
#define SPEAR1310_BUS_CLK_ENB 0

#define SPEAR1310_PERIP2_CLK_ENB (VA_MISC_BASE + 0x304)
#define SPEAR1310_PERIP2_CLK_ENB (misc_base + 0x304)
/* PERIP2_CLK_ENB register masks */
#define SPEAR1310_THSENS_CLK_ENB 8
#define SPEAR1310_I2S_REF_PAD_CLK_ENB 7
Expand All @@ -150,7 +148,7 @@
#define SPEAR1310_DDR_CORE_CLK_ENB 1
#define SPEAR1310_DDR_CTRL_CLK_ENB 0

#define SPEAR1310_RAS_CLK_ENB (VA_MISC_BASE + 0x310)
#define SPEAR1310_RAS_CLK_ENB (misc_base + 0x310)
/* RAS_CLK_ENB register masks */
#define SPEAR1310_SYNT3_CLK_ENB 17
#define SPEAR1310_SYNT2_CLK_ENB 16
Expand All @@ -172,7 +170,7 @@
#define SPEAR1310_ACLK_CLK_ENB 0

/* RAS Area Control Register */
#define SPEAR1310_RAS_CTRL_REG0 (VA_SPEAR1310_RAS_BASE + 0x000)
#define SPEAR1310_RAS_CTRL_REG0 (ras_base + 0x000)
#define SPEAR1310_SSP1_CLK_MASK 3
#define SPEAR1310_SSP1_CLK_SHIFT 26
#define SPEAR1310_TDM_CLK_MASK 1
Expand All @@ -197,12 +195,12 @@
#define SPEAR1310_PCI_CLK_MASK 1
#define SPEAR1310_PCI_CLK_SHIFT 0

#define SPEAR1310_RAS_CTRL_REG1 (VA_SPEAR1310_RAS_BASE + 0x004)
#define SPEAR1310_RAS_CTRL_REG1 (ras_base + 0x004)
#define SPEAR1310_PHY_CLK_MASK 0x3
#define SPEAR1310_RMII_PHY_CLK_SHIFT 0
#define SPEAR1310_SMII_RGMII_PHY_CLK_SHIFT 2

#define SPEAR1310_RAS_SW_CLK_CTRL (VA_SPEAR1310_RAS_BASE + 0x0148)
#define SPEAR1310_RAS_SW_CLK_CTRL (ras_base + 0x0148)
#define SPEAR1310_CAN1_CLK_ENB 25
#define SPEAR1310_CAN0_CLK_ENB 24
#define SPEAR1310_GPT64_CLK_ENB 23
Expand Down Expand Up @@ -385,7 +383,7 @@ static const char *ssp1_parents[] = { "ras_apb_clk", "gen_syn1_clk",
static const char *pci_parents[] = { "ras_pll3_clk", "gen_syn2_clk", };
static const char *tdm_parents[] = { "ras_pll3_clk", "gen_syn1_clk", };

void __init spear1310_clk_init(void)
void __init spear1310_clk_init(void __iomem *misc_base, void __iomem *ras_base)
{
struct clk *clk, *clk1;

Expand Down
Loading

0 comments on commit d9909eb

Please sign in to comment.