Boris BREZILLON | 0ad6125 | 2013-12-02 15:07:02 +0100 | [diff] [blame] | 1 | /* |
| 2 | * drivers/clk/at91/pmc.h |
| 3 | * |
| 4 | * Copyright (C) 2013 Boris BREZILLON <b.brezillon@overkiz.com> |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | */ |
| 11 | |
| 12 | #ifndef __PMC_H_ |
| 13 | #define __PMC_H_ |
| 14 | |
| 15 | #include <linux/io.h> |
| 16 | #include <linux/irqdomain.h> |
| 17 | #include <linux/spinlock.h> |
| 18 | |
| 19 | struct clk_range { |
| 20 | unsigned long min; |
| 21 | unsigned long max; |
| 22 | }; |
| 23 | |
| 24 | #define CLK_RANGE(MIN, MAX) {.min = MIN, .max = MAX,} |
| 25 | |
| 26 | struct at91_pmc_caps { |
| 27 | u32 available_irqs; |
| 28 | }; |
| 29 | |
| 30 | struct at91_pmc { |
| 31 | void __iomem *regbase; |
| 32 | int virq; |
| 33 | spinlock_t lock; |
| 34 | const struct at91_pmc_caps *caps; |
| 35 | struct irq_domain *irqdomain; |
| 36 | }; |
| 37 | |
| 38 | static inline void pmc_lock(struct at91_pmc *pmc) |
| 39 | { |
| 40 | spin_lock(&pmc->lock); |
| 41 | } |
| 42 | |
| 43 | static inline void pmc_unlock(struct at91_pmc *pmc) |
| 44 | { |
| 45 | spin_unlock(&pmc->lock); |
| 46 | } |
| 47 | |
| 48 | static inline u32 pmc_read(struct at91_pmc *pmc, int offset) |
| 49 | { |
| 50 | return readl(pmc->regbase + offset); |
| 51 | } |
| 52 | |
| 53 | static inline void pmc_write(struct at91_pmc *pmc, int offset, u32 value) |
| 54 | { |
| 55 | writel(value, pmc->regbase + offset); |
| 56 | } |
| 57 | |
| 58 | int of_at91_get_clk_range(struct device_node *np, const char *propname, |
| 59 | struct clk_range *range); |
| 60 | |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame^] | 61 | extern void __init of_at91rm9200_clk_main_osc_setup(struct device_node *np, |
| 62 | struct at91_pmc *pmc); |
| 63 | extern void __init of_at91sam9x5_clk_main_rc_osc_setup(struct device_node *np, |
| 64 | struct at91_pmc *pmc); |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 65 | extern void __init of_at91rm9200_clk_main_setup(struct device_node *np, |
| 66 | struct at91_pmc *pmc); |
Boris BREZILLON | 27cb1c2 | 2014-05-07 18:00:08 +0200 | [diff] [blame^] | 67 | extern void __init of_at91sam9x5_clk_main_setup(struct device_node *np, |
| 68 | struct at91_pmc *pmc); |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 69 | |
Boris BREZILLON | 1a748d2 | 2013-10-11 10:48:26 +0200 | [diff] [blame] | 70 | extern void __init of_at91rm9200_clk_pll_setup(struct device_node *np, |
| 71 | struct at91_pmc *pmc); |
| 72 | extern void __init of_at91sam9g45_clk_pll_setup(struct device_node *np, |
| 73 | struct at91_pmc *pmc); |
| 74 | extern void __init of_at91sam9g20_clk_pllb_setup(struct device_node *np, |
| 75 | struct at91_pmc *pmc); |
| 76 | extern void __init of_sama5d3_clk_pll_setup(struct device_node *np, |
| 77 | struct at91_pmc *pmc); |
| 78 | extern void __init of_at91sam9x5_clk_plldiv_setup(struct device_node *np, |
| 79 | struct at91_pmc *pmc); |
| 80 | |
Boris BREZILLON | e442d23 | 2013-10-11 10:51:23 +0200 | [diff] [blame] | 81 | extern void __init of_at91rm9200_clk_master_setup(struct device_node *np, |
| 82 | struct at91_pmc *pmc); |
| 83 | extern void __init of_at91sam9x5_clk_master_setup(struct device_node *np, |
| 84 | struct at91_pmc *pmc); |
| 85 | |
Boris BREZILLON | 5fba62e | 2013-10-11 11:41:41 +0200 | [diff] [blame] | 86 | extern void __init of_at91rm9200_clk_sys_setup(struct device_node *np, |
| 87 | struct at91_pmc *pmc); |
| 88 | |
Boris BREZILLON | 6114067 | 2013-10-11 11:44:36 +0200 | [diff] [blame] | 89 | extern void __init of_at91rm9200_clk_periph_setup(struct device_node *np, |
| 90 | struct at91_pmc *pmc); |
| 91 | extern void __init of_at91sam9x5_clk_periph_setup(struct device_node *np, |
| 92 | struct at91_pmc *pmc); |
| 93 | |
Boris BREZILLON | 1f22f8b | 2013-10-11 11:57:04 +0200 | [diff] [blame] | 94 | extern void __init of_at91rm9200_clk_prog_setup(struct device_node *np, |
| 95 | struct at91_pmc *pmc); |
| 96 | extern void __init of_at91sam9g45_clk_prog_setup(struct device_node *np, |
| 97 | struct at91_pmc *pmc); |
| 98 | extern void __init of_at91sam9x5_clk_prog_setup(struct device_node *np, |
| 99 | struct at91_pmc *pmc); |
Boris BREZILLON | 1f22f8b | 2013-10-11 11:57:04 +0200 | [diff] [blame] | 100 | |
Boris BREZILLON | f090fb3 | 2013-10-11 12:22:06 +0200 | [diff] [blame] | 101 | #if defined(CONFIG_HAVE_AT91_UTMI) |
| 102 | extern void __init of_at91sam9x5_clk_utmi_setup(struct device_node *np, |
| 103 | struct at91_pmc *pmc); |
| 104 | #endif |
| 105 | |
Boris BREZILLON | c84a61d | 2013-10-17 18:55:41 +0200 | [diff] [blame] | 106 | #if defined(CONFIG_HAVE_AT91_USB_CLK) |
| 107 | extern void __init of_at91rm9200_clk_usb_setup(struct device_node *np, |
| 108 | struct at91_pmc *pmc); |
| 109 | extern void __init of_at91sam9x5_clk_usb_setup(struct device_node *np, |
| 110 | struct at91_pmc *pmc); |
| 111 | extern void __init of_at91sam9n12_clk_usb_setup(struct device_node *np, |
| 112 | struct at91_pmc *pmc); |
| 113 | #endif |
| 114 | |
Boris BREZILLON | a9c0688 | 2013-10-11 13:27:06 +0200 | [diff] [blame] | 115 | #if defined(CONFIG_HAVE_AT91_SMD) |
| 116 | extern void __init of_at91sam9x5_clk_smd_setup(struct device_node *np, |
| 117 | struct at91_pmc *pmc); |
| 118 | #endif |
| 119 | |
Boris BREZILLON | 0ad6125 | 2013-12-02 15:07:02 +0100 | [diff] [blame] | 120 | #endif /* __PMC_H_ */ |