123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- /* linux/arch/arm/plat-s3c64xx/clock.c
- *
- * Copyright 2008 Openmoko, Inc.
- * Copyright 2008 Simtec Electronics
- * Ben Dooks <ben@simtec.co.uk>
- * http://armlinux.simtec.co.uk/
- *
- * S3C64XX Base clock support
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
- #include <linux/init.h>
- #include <linux/module.h>
- #include <linux/interrupt.h>
- #include <linux/ioport.h>
- #include <linux/clk.h>
- #include <linux/err.h>
- #include <linux/io.h>
- #include <mach/hardware.h>
- #include <mach/map.h>
- #include <mach/regs-sys.h>
- #include <mach/regs-clock.h>
- #include <plat/cpu.h>
- #include <plat/devs.h>
- #include <plat/cpu-freq.h>
- #include <plat/clock.h>
- #include <plat/clock-clksrc.h>
- #include <plat/pll.h>
- /* fin_apll, fin_mpll and fin_epll are all the same clock, which we call
- * ext_xtal_mux for want of an actual name from the manual.
- */
- static struct clk clk_ext_xtal_mux = {
- .name = "ext_xtal",
- };
- #define clk_fin_apll clk_ext_xtal_mux
- #define clk_fin_mpll clk_ext_xtal_mux
- #define clk_fin_epll clk_ext_xtal_mux
- #define clk_fout_mpll clk_mpll
- #define clk_fout_epll clk_epll
- struct clk clk_h2 = {
- .name = "hclk2",
- .rate = 0,
- };
- struct clk clk_27m = {
- .name = "clk_27m",
- .rate = 27000000,
- };
- static int clk_48m_ctrl(struct clk *clk, int enable)
- {
- unsigned long flags;
- u32 val;
- /* can't rely on clock lock, this register has other usages */
- local_irq_save(flags);
- val = __raw_readl(S3C64XX_OTHERS);
- if (enable)
- val |= S3C64XX_OTHERS_USBMASK;
- else
- val &= ~S3C64XX_OTHERS_USBMASK;
- __raw_writel(val, S3C64XX_OTHERS);
- local_irq_restore(flags);
- return 0;
- }
- struct clk clk_48m = {
- .name = "clk_48m",
- .rate = 48000000,
- .enable = clk_48m_ctrl,
- };
- struct clk clk_xusbxti = {
- .name = "xusbxti",
- .rate = 48000000,
- };
- static int inline s3c64xx_gate(void __iomem *reg,
- struct clk *clk,
- int enable)
- {
- unsigned int ctrlbit = clk->ctrlbit;
- u32 con;
- con = __raw_readl(reg);
- if (enable)
- con |= ctrlbit;
- else
- con &= ~ctrlbit;
- __raw_writel(con, reg);
- return 0;
- }
- static int s3c64xx_pclk_ctrl(struct clk *clk, int enable)
- {
- return s3c64xx_gate(S3C_PCLK_GATE, clk, enable);
- }
- static int s3c64xx_hclk_ctrl(struct clk *clk, int enable)
- {
- return s3c64xx_gate(S3C_HCLK_GATE, clk, enable);
- }
- int s3c64xx_sclk_ctrl(struct clk *clk, int enable)
- {
- return s3c64xx_gate(S3C_SCLK_GATE, clk, enable);
- }
- static struct clk init_clocks_off[] = {
- {
- .name = "nand",
- .parent = &clk_h,
- }, {
- .name = "rtc",
- .parent = &clk_p,
- .enable = s3c64xx_pclk_ctrl,
- .ctrlbit = S3C_CLKCON_PCLK_RTC,
- }, {
- .name = "adc",
- .parent = &clk_p,
- .enable = s3c64xx_pclk_ctrl,
- .ctrlbit = S3C_CLKCON_PCLK_TSADC,
- }, {
- .name = "i2c",
- .devname = "s3c2440-i2c.0",
- .parent = &clk_p,
- .enable = s3c64xx_pclk_ctrl,
- .ctrlbit = S3C_CLKCON_PCLK_IIC,
- }, {
- .name = "i2c",
- .devname = "s3c2440-i2c.1",
- .parent = &clk_p,
- .enable = s3c64xx_pclk_ctrl,
- .ctrlbit = S3C6410_CLKCON_PCLK_I2C1,
- }, {
- .name = "keypad",
- .parent = &clk_p,
- .enable = s3c64xx_pclk_ctrl,
- .ctrlbit = S3C_CLKCON_PCLK_KEYPAD,
- }, {
- .name = "spi",
- .devname = "s3c6410-spi.0",
- .parent = &clk_p,
- .enable = s3c64xx_pclk_ctrl,
- .ctrlbit = S3C_CLKCON_PCLK_SPI0,
- }, {
- .name = "spi",
- .devname = "s3c6410-spi.1",
- .parent = &clk_p,
- .enable = s3c64xx_pclk_ctrl,
- .ctrlbit = S3C_CLKCON_PCLK_SPI1,
- }, {
- .name = "48m",
- .devname = "s3c-sdhci.0",
- .parent = &clk_48m,
- .enable = s3c64xx_sclk_ctrl,
- .ctrlbit = S3C_CLKCON_SCLK_MMC0_48,
- }, {
- .name = "48m",
- .devname = "s3c-sdhci.1",
- .parent = &clk_48m,
- .enable = s3c64xx_sclk_ctrl,
- .ctrlbit = S3C_CLKCON_SCLK_MMC1_48,
- }, {
|