Stelian Pop | fa506a9 | 2008-01-31 21:15:53 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2007 |
Stelian Pop | c9e798d | 2011-11-01 00:00:39 +0100 | [diff] [blame] | 3 | * Stelian Pop <stelian@popies.net> |
Stelian Pop | fa506a9 | 2008-01-31 21:15:53 +0000 | [diff] [blame] | 4 | * Lead Tech Design <www.leadtechdesign.com> |
Jean-Christophe PLAGNIOL-VILLARD | dc39ae9 | 2009-04-16 21:30:44 +0200 | [diff] [blame] | 5 | * Copyright (C) 2009 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> |
Stelian Pop | fa506a9 | 2008-01-31 21:15:53 +0000 | [diff] [blame] | 6 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 7 | * SPDX-License-Identifier: GPL-2.0+ |
Stelian Pop | fa506a9 | 2008-01-31 21:15:53 +0000 | [diff] [blame] | 8 | */ |
| 9 | #ifndef __ASM_ARM_ARCH_CLK_H__ |
| 10 | #define __ASM_ARM_ARCH_CLK_H__ |
| 11 | |
| 12 | #include <asm/arch/hardware.h> |
Andreas Bießmann | c3a383f | 2011-06-12 01:49:11 +0000 | [diff] [blame] | 13 | #include <asm/global_data.h> |
Stelian Pop | fa506a9 | 2008-01-31 21:15:53 +0000 | [diff] [blame] | 14 | |
Andreas Bießmann | c3a383f | 2011-06-12 01:49:11 +0000 | [diff] [blame] | 15 | static inline unsigned long get_cpu_clk_rate(void) |
| 16 | { |
| 17 | DECLARE_GLOBAL_DATA_PTR; |
Simon Glass | f47e6ec | 2012-12-13 20:48:31 +0000 | [diff] [blame] | 18 | return gd->arch.cpu_clk_rate_hz; |
Andreas Bießmann | c3a383f | 2011-06-12 01:49:11 +0000 | [diff] [blame] | 19 | } |
| 20 | |
| 21 | static inline unsigned long get_main_clk_rate(void) |
| 22 | { |
| 23 | DECLARE_GLOBAL_DATA_PTR; |
Simon Glass | f47e6ec | 2012-12-13 20:48:31 +0000 | [diff] [blame] | 24 | return gd->arch.main_clk_rate_hz; |
Andreas Bießmann | c3a383f | 2011-06-12 01:49:11 +0000 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | static inline unsigned long get_mck_clk_rate(void) |
| 28 | { |
| 29 | DECLARE_GLOBAL_DATA_PTR; |
Simon Glass | f47e6ec | 2012-12-13 20:48:31 +0000 | [diff] [blame] | 30 | return gd->arch.mck_rate_hz; |
Andreas Bießmann | c3a383f | 2011-06-12 01:49:11 +0000 | [diff] [blame] | 31 | } |
| 32 | |
| 33 | static inline unsigned long get_plla_clk_rate(void) |
| 34 | { |
| 35 | DECLARE_GLOBAL_DATA_PTR; |
Simon Glass | f47e6ec | 2012-12-13 20:48:31 +0000 | [diff] [blame] | 36 | return gd->arch.plla_rate_hz; |
Andreas Bießmann | c3a383f | 2011-06-12 01:49:11 +0000 | [diff] [blame] | 37 | } |
| 38 | |
| 39 | static inline unsigned long get_pllb_clk_rate(void) |
| 40 | { |
| 41 | DECLARE_GLOBAL_DATA_PTR; |
Simon Glass | f47e6ec | 2012-12-13 20:48:31 +0000 | [diff] [blame] | 42 | return gd->arch.pllb_rate_hz; |
Andreas Bießmann | c3a383f | 2011-06-12 01:49:11 +0000 | [diff] [blame] | 43 | } |
| 44 | |
| 45 | static inline u32 get_pllb_init(void) |
| 46 | { |
| 47 | DECLARE_GLOBAL_DATA_PTR; |
Simon Glass | f47e6ec | 2012-12-13 20:48:31 +0000 | [diff] [blame] | 48 | return gd->arch.at91_pllb_usb_init; |
Andreas Bießmann | c3a383f | 2011-06-12 01:49:11 +0000 | [diff] [blame] | 49 | } |
Jean-Christophe PLAGNIOL-VILLARD | dc39ae9 | 2009-04-16 21:30:44 +0200 | [diff] [blame] | 50 | |
Stelian Pop | fa506a9 | 2008-01-31 21:15:53 +0000 | [diff] [blame] | 51 | static inline unsigned long get_macb_pclk_rate(unsigned int dev_id) |
| 52 | { |
Jean-Christophe PLAGNIOL-VILLARD | dc39ae9 | 2009-04-16 21:30:44 +0200 | [diff] [blame] | 53 | return get_mck_clk_rate(); |
Stelian Pop | fa506a9 | 2008-01-31 21:15:53 +0000 | [diff] [blame] | 54 | } |
| 55 | |
| 56 | static inline unsigned long get_usart_clk_rate(unsigned int dev_id) |
| 57 | { |
Jean-Christophe PLAGNIOL-VILLARD | dc39ae9 | 2009-04-16 21:30:44 +0200 | [diff] [blame] | 58 | return get_mck_clk_rate(); |
Stelian Pop | fa506a9 | 2008-01-31 21:15:53 +0000 | [diff] [blame] | 59 | } |
| 60 | |
Stelian Pop | 39cf480 | 2008-05-09 21:57:18 +0200 | [diff] [blame] | 61 | static inline unsigned long get_lcdc_clk_rate(unsigned int dev_id) |
| 62 | { |
Jean-Christophe PLAGNIOL-VILLARD | dc39ae9 | 2009-04-16 21:30:44 +0200 | [diff] [blame] | 63 | return get_mck_clk_rate(); |
Stelian Pop | 39cf480 | 2008-05-09 21:57:18 +0200 | [diff] [blame] | 64 | } |
| 65 | |
Sedji Gaouaou | 22ee647 | 2009-07-09 10:16:29 +0200 | [diff] [blame] | 66 | static inline unsigned long get_spi_clk_rate(unsigned int dev_id) |
| 67 | { |
| 68 | return get_mck_clk_rate(); |
| 69 | } |
| 70 | |
Jean-Christophe PLAGNIOL-VILLARD | dc39ae9 | 2009-04-16 21:30:44 +0200 | [diff] [blame] | 71 | static inline unsigned long get_twi_clk_rate(unsigned int dev_id) |
| 72 | { |
| 73 | return get_mck_clk_rate(); |
| 74 | } |
Stelian Pop | 39cf480 | 2008-05-09 21:57:18 +0200 | [diff] [blame] | 75 | |
Reinhard Meyer | 1592ef8 | 2010-08-13 10:31:06 +0200 | [diff] [blame] | 76 | static inline unsigned long get_mci_clk_rate(void) |
| 77 | { |
| 78 | return get_mck_clk_rate(); |
| 79 | } |
| 80 | |
Jean-Christophe PLAGNIOL-VILLARD | dc39ae9 | 2009-04-16 21:30:44 +0200 | [diff] [blame] | 81 | int at91_clock_init(unsigned long main_clock); |
Bo Shen | 3225f34 | 2013-05-12 22:40:54 +0000 | [diff] [blame] | 82 | void at91_periph_clk_enable(int id); |
Stelian Pop | fa506a9 | 2008-01-31 21:15:53 +0000 | [diff] [blame] | 83 | #endif /* __ASM_ARM_ARCH_CLK_H__ */ |