Ben Dooks | 952b564 | 2008-10-21 14:06:59 +0100 | [diff] [blame] | 1 | /* arch/arm/plat-s3c64xx/include/plat/pll.h |
| 2 | * |
| 3 | * Copyright 2008 Openmoko, Inc. |
| 4 | * Copyright 2008 Simtec Electronics |
| 5 | * Ben Dooks <ben@simtec.co.uk> |
| 6 | * http://armlinux.simtec.co.uk/ |
| 7 | * |
| 8 | * S3C64XX PLL code |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License version 2 as |
| 12 | * published by the Free Software Foundation. |
| 13 | */ |
| 14 | |
Kyungmin Park | 11e3bd0 | 2008-11-25 17:05:22 +0900 | [diff] [blame] | 15 | #define S3C6400_PLL_MDIV_MASK ((1 << (25-16+1)) - 1) |
| 16 | #define S3C6400_PLL_PDIV_MASK ((1 << (13-8+1)) - 1) |
| 17 | #define S3C6400_PLL_SDIV_MASK ((1 << (2-0+1)) - 1) |
Ben Dooks | 952b564 | 2008-10-21 14:06:59 +0100 | [diff] [blame] | 18 | #define S3C6400_PLL_MDIV_SHIFT (16) |
| 19 | #define S3C6400_PLL_PDIV_SHIFT (8) |
| 20 | #define S3C6400_PLL_SDIV_SHIFT (0) |
| 21 | |
| 22 | #include <asm/div64.h> |
Ben Dooks | e561aac | 2010-04-28 18:10:02 +0900 | [diff] [blame] | 23 | #include <plat/pll6553x.h> |
Ben Dooks | 952b564 | 2008-10-21 14:06:59 +0100 | [diff] [blame] | 24 | |
| 25 | static inline unsigned long s3c6400_get_pll(unsigned long baseclk, |
| 26 | u32 pllcon) |
| 27 | { |
| 28 | u32 mdiv, pdiv, sdiv; |
| 29 | u64 fvco = baseclk; |
| 30 | |
| 31 | mdiv = (pllcon >> S3C6400_PLL_MDIV_SHIFT) & S3C6400_PLL_MDIV_MASK; |
| 32 | pdiv = (pllcon >> S3C6400_PLL_PDIV_SHIFT) & S3C6400_PLL_PDIV_MASK; |
| 33 | sdiv = (pllcon >> S3C6400_PLL_SDIV_SHIFT) & S3C6400_PLL_SDIV_MASK; |
| 34 | |
| 35 | fvco *= mdiv; |
| 36 | do_div(fvco, (pdiv << sdiv)); |
| 37 | |
| 38 | return (unsigned long)fvco; |
| 39 | } |
| 40 | |
Ben Dooks | 952b564 | 2008-10-21 14:06:59 +0100 | [diff] [blame] | 41 | static inline unsigned long s3c6400_get_epll(unsigned long baseclk) |
| 42 | { |
Ben Dooks | e561aac | 2010-04-28 18:10:02 +0900 | [diff] [blame] | 43 | return s3c_get_pll6553x(baseclk, __raw_readl(S3C_EPLL_CON0), |
| 44 | __raw_readl(S3C_EPLL_CON1)); |
Ben Dooks | 952b564 | 2008-10-21 14:06:59 +0100 | [diff] [blame] | 45 | } |