blob: 759050116a93f8e787058d9dddb4e5e4c869ca81 [file] [log] [blame]
Wolfgang Denk72a087e2006-10-24 14:27:35 +02001/*
2 * Copyright (C) 2005-2006 Atmel Corporation
3 *
4 * See file CREDITS for list of people who contributed to this
5 * project.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
20 * MA 02111-1307 USA
21 */
22#ifndef _ASM_AVR32_ARCH_PM_H
23#define _ASM_AVR32_ARCH_PM_H
24
25#include <config.h>
26
27enum clock_domain_id {
28 CLOCK_CPU,
29 CLOCK_HSB,
30 CLOCK_PBA,
31 CLOCK_PBB,
32 NR_CLOCK_DOMAINS,
33};
34
35enum resource_type {
36 RESOURCE_GPIO,
37 RESOURCE_CLOCK,
38};
39
40enum gpio_func {
41 GPIO_FUNC_GPIO,
42 GPIO_FUNC_A,
43 GPIO_FUNC_B,
44};
45
46enum device_id {
47 DEVICE_HEBI,
48 DEVICE_PBA_BRIDGE,
49 DEVICE_PBB_BRIDGE,
50 DEVICE_HRAMC,
51 /* GPIO controllers must be kept together */
52 DEVICE_PIOA,
53 DEVICE_PIOB,
54 DEVICE_PIOC,
55 DEVICE_PIOD,
56 DEVICE_PIOE,
57 DEVICE_SM,
58 DEVICE_INTC,
59 DEVICE_HMATRIX,
60#if defined(CFG_HPDC)
61 DEVICE_HPDC,
62#endif
63#if defined(CFG_MACB0)
64 DEVICE_MACB0,
65#endif
66#if defined(CFG_MACB1)
67 DEVICE_MACB1,
68#endif
69#if defined(CFG_LCDC)
70 DEVICE_LCDC,
71#endif
72#if defined(CFG_USART0)
73 DEVICE_USART0,
74#endif
75#if defined(CFG_USART1)
76 DEVICE_USART1,
77#endif
78#if defined(CFG_USART2)
79 DEVICE_USART2,
80#endif
81#if defined(CFG_USART3)
82 DEVICE_USART3,
83#endif
84#if defined(CFG_MMCI)
85 DEVICE_MMCI,
86#endif
87#if defined(CFG_DMAC)
88 DEVICE_DMAC,
89#endif
90 NR_DEVICES,
91 NO_DEVICE = -1,
92};
93
94struct resource {
95 enum resource_type type;
96 union {
97 struct {
98 unsigned long base;
99 } iomem;
100 struct {
101 unsigned char nr_pins;
102 enum device_id gpio_dev;
103 enum gpio_func func;
104 unsigned short start;
105 } gpio;
106 struct {
107 enum clock_domain_id id;
108 unsigned char index;
109 } clock;
110 } u;
111};
112
113struct device {
114 void *regs;
115 unsigned int nr_resources;
116 const struct resource *resource;
117};
118
119struct clock_domain {
120 unsigned short reg;
121 enum clock_domain_id id;
122 enum device_id bridge;
123};
124
125extern const struct device chip_device[NR_DEVICES];
126extern const struct clock_domain chip_clock[NR_CLOCK_DOMAINS];
127
128/**
129 * Set up PIO, clock management and I/O memory for a device.
130 */
131const struct device *get_device(enum device_id devid);
132void put_device(const struct device *dev);
133
134int gpio_set_func(enum device_id gpio_devid, unsigned int start,
135 unsigned int nr_pins, enum gpio_func func);
136void gpio_free(enum device_id gpio_devid, unsigned int start,
137 unsigned int nr_pins);
138
139void pm_init(void);
140int pm_enable_clock(enum clock_domain_id id, unsigned int index);
141void pm_disable_clock(enum clock_domain_id id, unsigned int index);
142unsigned long pm_get_clock_freq(enum clock_domain_id domain);
143
144void cpu_enable_sdram(void);
145
146#endif /* _ASM_AVR32_ARCH_PM_H */