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> |
Boris Brezillon | 863a81c | 2014-09-05 09:54:13 +0200 | [diff] [blame^] | 17 | #include <linux/regmap.h> |
Boris BREZILLON | 0ad6125 | 2013-12-02 15:07:02 +0100 | [diff] [blame] | 18 | #include <linux/spinlock.h> |
| 19 | |
| 20 | struct clk_range { |
| 21 | unsigned long min; |
| 22 | unsigned long max; |
| 23 | }; |
| 24 | |
| 25 | #define CLK_RANGE(MIN, MAX) {.min = MIN, .max = MAX,} |
| 26 | |
| 27 | struct at91_pmc_caps { |
| 28 | u32 available_irqs; |
| 29 | }; |
| 30 | |
| 31 | struct at91_pmc { |
Boris Brezillon | 863a81c | 2014-09-05 09:54:13 +0200 | [diff] [blame^] | 32 | struct regmap *regmap; |
Boris BREZILLON | 0ad6125 | 2013-12-02 15:07:02 +0100 | [diff] [blame] | 33 | int virq; |
| 34 | spinlock_t lock; |
| 35 | const struct at91_pmc_caps *caps; |
| 36 | struct irq_domain *irqdomain; |
Boris BREZILLON | 947f5b1 | 2015-03-02 10:18:16 +0100 | [diff] [blame] | 37 | u32 imr; |
Boris BREZILLON | 0ad6125 | 2013-12-02 15:07:02 +0100 | [diff] [blame] | 38 | }; |
| 39 | |
| 40 | static inline void pmc_lock(struct at91_pmc *pmc) |
| 41 | { |
| 42 | spin_lock(&pmc->lock); |
| 43 | } |
| 44 | |
| 45 | static inline void pmc_unlock(struct at91_pmc *pmc) |
| 46 | { |
| 47 | spin_unlock(&pmc->lock); |
| 48 | } |
| 49 | |
| 50 | static inline u32 pmc_read(struct at91_pmc *pmc, int offset) |
| 51 | { |
Boris Brezillon | 863a81c | 2014-09-05 09:54:13 +0200 | [diff] [blame^] | 52 | unsigned int ret = 0; |
| 53 | |
| 54 | regmap_read(pmc->regmap, offset, &ret); |
| 55 | |
| 56 | return ret; |
Boris BREZILLON | 0ad6125 | 2013-12-02 15:07:02 +0100 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | static inline void pmc_write(struct at91_pmc *pmc, int offset, u32 value) |
| 60 | { |
Boris Brezillon | 863a81c | 2014-09-05 09:54:13 +0200 | [diff] [blame^] | 61 | regmap_write(pmc->regmap, offset, value); |
Boris BREZILLON | 0ad6125 | 2013-12-02 15:07:02 +0100 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | int of_at91_get_clk_range(struct device_node *np, const char *propname, |
| 65 | struct clk_range *range); |
| 66 | |
Stephen Boyd | a8a8db4 | 2015-07-06 12:10:51 -0700 | [diff] [blame] | 67 | void of_at91sam9260_clk_slow_setup(struct device_node *np, |
| 68 | struct at91_pmc *pmc); |
Boris BREZILLON | 80eded6 | 2014-05-07 18:02:15 +0200 | [diff] [blame] | 69 | |
Stephen Boyd | a8a8db4 | 2015-07-06 12:10:51 -0700 | [diff] [blame] | 70 | void of_at91rm9200_clk_main_osc_setup(struct device_node *np, |
| 71 | struct at91_pmc *pmc); |
| 72 | void of_at91sam9x5_clk_main_rc_osc_setup(struct device_node *np, |
| 73 | struct at91_pmc *pmc); |
| 74 | void of_at91rm9200_clk_main_setup(struct device_node *np, |
| 75 | struct at91_pmc *pmc); |
| 76 | void of_at91sam9x5_clk_main_setup(struct device_node *np, |
| 77 | struct at91_pmc *pmc); |
Boris BREZILLON | 38d34c3 | 2013-10-11 10:44:49 +0200 | [diff] [blame] | 78 | |
Stephen Boyd | a8a8db4 | 2015-07-06 12:10:51 -0700 | [diff] [blame] | 79 | void of_at91rm9200_clk_pll_setup(struct device_node *np, |
| 80 | struct at91_pmc *pmc); |
| 81 | void of_at91sam9g45_clk_pll_setup(struct device_node *np, |
| 82 | struct at91_pmc *pmc); |
| 83 | void of_at91sam9g20_clk_pllb_setup(struct device_node *np, |
| 84 | struct at91_pmc *pmc); |
| 85 | void of_sama5d3_clk_pll_setup(struct device_node *np, |
| 86 | struct at91_pmc *pmc); |
| 87 | void of_at91sam9x5_clk_plldiv_setup(struct device_node *np, |
| 88 | struct at91_pmc *pmc); |
Boris BREZILLON | 1a748d2 | 2013-10-11 10:48:26 +0200 | [diff] [blame] | 89 | |
Stephen Boyd | a8a8db4 | 2015-07-06 12:10:51 -0700 | [diff] [blame] | 90 | void of_at91rm9200_clk_master_setup(struct device_node *np, |
| 91 | struct at91_pmc *pmc); |
| 92 | void of_at91sam9x5_clk_master_setup(struct device_node *np, |
| 93 | struct at91_pmc *pmc); |
Boris BREZILLON | e442d23 | 2013-10-11 10:51:23 +0200 | [diff] [blame] | 94 | |
Stephen Boyd | a8a8db4 | 2015-07-06 12:10:51 -0700 | [diff] [blame] | 95 | void of_at91rm9200_clk_sys_setup(struct device_node *np, |
| 96 | struct at91_pmc *pmc); |
Boris BREZILLON | 5fba62e | 2013-10-11 11:41:41 +0200 | [diff] [blame] | 97 | |
Stephen Boyd | a8a8db4 | 2015-07-06 12:10:51 -0700 | [diff] [blame] | 98 | void of_at91rm9200_clk_periph_setup(struct device_node *np, |
| 99 | struct at91_pmc *pmc); |
| 100 | void of_at91sam9x5_clk_periph_setup(struct device_node *np, |
| 101 | struct at91_pmc *pmc); |
Boris BREZILLON | 6114067 | 2013-10-11 11:44:36 +0200 | [diff] [blame] | 102 | |
Stephen Boyd | a8a8db4 | 2015-07-06 12:10:51 -0700 | [diff] [blame] | 103 | void of_at91rm9200_clk_prog_setup(struct device_node *np, |
| 104 | struct at91_pmc *pmc); |
| 105 | void of_at91sam9g45_clk_prog_setup(struct device_node *np, |
| 106 | struct at91_pmc *pmc); |
| 107 | void of_at91sam9x5_clk_prog_setup(struct device_node *np, |
| 108 | struct at91_pmc *pmc); |
Boris BREZILLON | 1f22f8b | 2013-10-11 11:57:04 +0200 | [diff] [blame] | 109 | |
Stephen Boyd | a8a8db4 | 2015-07-06 12:10:51 -0700 | [diff] [blame] | 110 | void of_at91sam9x5_clk_utmi_setup(struct device_node *np, |
| 111 | struct at91_pmc *pmc); |
Boris BREZILLON | f090fb3 | 2013-10-11 12:22:06 +0200 | [diff] [blame] | 112 | |
Stephen Boyd | a8a8db4 | 2015-07-06 12:10:51 -0700 | [diff] [blame] | 113 | void of_at91rm9200_clk_usb_setup(struct device_node *np, |
| 114 | struct at91_pmc *pmc); |
| 115 | void of_at91sam9x5_clk_usb_setup(struct device_node *np, |
| 116 | struct at91_pmc *pmc); |
| 117 | void of_at91sam9n12_clk_usb_setup(struct device_node *np, |
| 118 | struct at91_pmc *pmc); |
Boris BREZILLON | c84a61d | 2013-10-17 18:55:41 +0200 | [diff] [blame] | 119 | |
Stephen Boyd | a8a8db4 | 2015-07-06 12:10:51 -0700 | [diff] [blame] | 120 | void of_at91sam9x5_clk_smd_setup(struct device_node *np, |
| 121 | struct at91_pmc *pmc); |
Boris BREZILLON | a9c0688 | 2013-10-11 13:27:06 +0200 | [diff] [blame] | 122 | |
Stephen Boyd | a8a8db4 | 2015-07-06 12:10:51 -0700 | [diff] [blame] | 123 | void of_sama5d4_clk_h32mx_setup(struct device_node *np, |
| 124 | struct at91_pmc *pmc); |
Alexandre Belloni | bcc5fd4 | 2014-09-15 18:15:53 +0200 | [diff] [blame] | 125 | |
Nicolas Ferre | df70aee | 2015-07-31 11:43:12 +0200 | [diff] [blame] | 126 | void of_sama5d2_clk_generated_setup(struct device_node *np, |
| 127 | struct at91_pmc *pmc); |
| 128 | |
Boris BREZILLON | 0ad6125 | 2013-12-02 15:07:02 +0100 | [diff] [blame] | 129 | #endif /* __PMC_H_ */ |