pll6553x.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* arch/arm/plat-samsung/include/plat/pll6553x.h
  2. * partially from arch/arm/mach-s3c64xx/include/mach/pll.h
  3. *
  4. * Copyright 2008 Openmoko, Inc.
  5. * Copyright 2008 Simtec Electronics
  6. * Ben Dooks <ben@simtec.co.uk>
  7. * http://armlinux.simtec.co.uk/
  8. *
  9. * Samsung PLL6553x PLL code
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. */
  15. /* S3C6400 and compatible (S3C2416, etc.) EPLL code */
  16. #define PLL6553X_MDIV_MASK ((1 << (23-16)) - 1)
  17. #define PLL6553X_PDIV_MASK ((1 << (13-8)) - 1)
  18. #define PLL6553X_SDIV_MASK ((1 << (2-0)) - 1)
  19. #define PLL6553X_MDIV_SHIFT (16)
  20. #define PLL6553X_PDIV_SHIFT (8)
  21. #define PLL6553X_SDIV_SHIFT (0)
  22. #define PLL6553X_KDIV_MASK (0xffff)
  23. static inline unsigned long s3c_get_pll6553x(unsigned long baseclk,
  24. u32 pll0, u32 pll1)
  25. {
  26. unsigned long result;
  27. u32 mdiv, pdiv, sdiv, kdiv;
  28. u64 tmp;
  29. mdiv = (pll0 >> PLL6553X_MDIV_SHIFT) & PLL6553X_MDIV_MASK;
  30. pdiv = (pll0 >> PLL6553X_PDIV_SHIFT) & PLL6553X_PDIV_MASK;
  31. sdiv = (pll0 >> PLL6553X_SDIV_SHIFT) & PLL6553X_SDIV_MASK;
  32. kdiv = pll1 & PLL6553X_KDIV_MASK;
  33. /* We need to multiple baseclk by mdiv (the integer part) and kdiv
  34. * which is in 2^16ths, so shift mdiv up (does not overflow) and
  35. * add kdiv before multiplying. The use of tmp is to avoid any
  36. * overflows before shifting bac down into result when multipling
  37. * by the mdiv and kdiv pair.
  38. */
  39. tmp = baseclk;
  40. tmp *= (mdiv << 16) + kdiv;
  41. do_div(tmp, (pdiv << sdiv));
  42. result = tmp >> 16;
  43. return result;
  44. }