perf, x86: Fix key indexing in Pentium-4 PMU
[linux-2.6-block.git] / arch / arm / plat-s3c / include / plat / gpio-core.h
CommitLineData
7db6c82a
BD
1/* linux/arch/arm/plat-s3c/include/plat/gpio-core.h
2 *
3 * Copyright 2008 Simtec Electronics
4 * http://armlinux.simtec.co.uk/
5 * Ben Dooks <ben@simtec.co.uk>
6 *
7 * S3C Platform - GPIO core
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12*/
13
14/* Define the core gpiolib support functions that the s3c platforms may
15 * need to extend or change depending on the hardware and the s3c chip
16 * selected at build or found at run time.
17 *
18 * These definitions are not intended for driver inclusion, there is
19 * nothing here that should not live outside the platform and core
20 * specific code.
21*/
22
d87964c4
BD
23struct s3c_gpio_chip;
24
25/**
26 * struct s3c_gpio_pm - power management (suspend/resume) information
27 * @save: Routine to save the state of the GPIO block
28 * @resume: Routine to resume the GPIO block.
29 */
30struct s3c_gpio_pm {
31 void (*save)(struct s3c_gpio_chip *chip);
32 void (*resume)(struct s3c_gpio_chip *chip);
33};
34
21b23664
BD
35struct s3c_gpio_cfg;
36
7db6c82a
BD
37/**
38 * struct s3c_gpio_chip - wrapper for specific implementation of gpio
39 * @chip: The chip structure to be exported via gpiolib.
40 * @base: The base pointer to the gpio configuration registers.
21b23664 41 * @config: special function and pull-resistor control information.
d87964c4 42 * @pm_save: Save information for suspend/resume support.
7db6c82a
BD
43 *
44 * This wrapper provides the necessary information for the Samsung
45 * specific gpios being registered with gpiolib.
46 */
47struct s3c_gpio_chip {
48 struct gpio_chip chip;
21b23664 49 struct s3c_gpio_cfg *config;
d87964c4 50 struct s3c_gpio_pm *pm;
7db6c82a 51 void __iomem *base;
d87964c4
BD
52#ifdef CONFIG_PM
53 u32 pm_save[4];
54#endif
7db6c82a
BD
55};
56
57static inline struct s3c_gpio_chip *to_s3c_gpio(struct gpio_chip *gpc)
58{
59 return container_of(gpc, struct s3c_gpio_chip, chip);
60}
61
62/** s3c_gpiolib_add() - add the s3c specific version of a gpio_chip.
63 * @chip: The chip to register
64 *
65 * This is a wrapper to gpiochip_add() that takes our specific gpio chip
66 * information and makes the necessary alterations for the platform and
67 * notes the information for use with the configuration systems and any
68 * other parts of the system.
69 */
70extern void s3c_gpiolib_add(struct s3c_gpio_chip *chip);
8a53bdb9 71
8a53bdb9
BD
72/* CONFIG_S3C_GPIO_TRACK enables the tracking of the s3c specific gpios
73 * for use with the configuration calls, and other parts of the s3c gpiolib
74 * support code.
75 *
76 * Not all s3c support code will need this, as some configurations of cpu
77 * may only support one or two different configuration options and have an
78 * easy gpio to s3c_gpio_chip mapping function. If this is the case, then
79 * the machine support file should provide its own s3c_gpiolib_getchip()
80 * and any other necessary functions.
81 */
82
83#ifdef CONFIG_S3C_GPIO_TRACK
84extern struct s3c_gpio_chip *s3c_gpios[S3C_GPIO_END];
85
86static inline struct s3c_gpio_chip *s3c_gpiolib_getchip(unsigned int chip)
87{
21b23664 88 return (chip < S3C_GPIO_END) ? s3c_gpios[chip] : NULL;
8a53bdb9
BD
89}
90#else
21b23664
BD
91/* machine specific code should provide s3c_gpiolib_getchip */
92
8a53bdb9
BD
93static inline void s3c_gpiolib_track(struct s3c_gpio_chip *chip) { }
94#endif
d87964c4
BD
95
96#ifdef CONFIG_PM
97extern struct s3c_gpio_pm s3c_gpio_pm_1bit;
98extern struct s3c_gpio_pm s3c_gpio_pm_2bit;
99extern struct s3c_gpio_pm s3c_gpio_pm_4bit;
100#define __gpio_pm(x) x
101#else
102#define s3c_gpio_pm_1bit NULL
103#define s3c_gpio_pm_2bit NULL
104#define s3c_gpio_pm_4bit NULL
105#define __gpio_pm(x) NULL
106
107#endif /* CONFIG_PM */