1 /* linux/arch/arm/plat-s3c/include/plat/gpio-core.h
3 * Copyright 2008 Simtec Electronics
4 * http://armlinux.simtec.co.uk/
5 * Ben Dooks <ben@simtec.co.uk>
7 * S3C Platform - GPIO core
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.
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.
18 * These definitions are not intended for driver inclusion, there is
19 * nothing here that should not live outside the platform and core
26 * struct s3c_gpio_chip - wrapper for specific implementation of gpio
27 * @chip: The chip structure to be exported via gpiolib.
28 * @base: The base pointer to the gpio configuration registers.
29 * @config: special function and pull-resistor control information.
31 * This wrapper provides the necessary information for the Samsung
32 * specific gpios being registered with gpiolib.
34 struct s3c_gpio_chip {
35 struct gpio_chip chip;
36 struct s3c_gpio_cfg *config;
40 static inline struct s3c_gpio_chip *to_s3c_gpio(struct gpio_chip *gpc)
42 return container_of(gpc, struct s3c_gpio_chip, chip);
45 /** s3c_gpiolib_add() - add the s3c specific version of a gpio_chip.
46 * @chip: The chip to register
48 * This is a wrapper to gpiochip_add() that takes our specific gpio chip
49 * information and makes the necessary alterations for the platform and
50 * notes the information for use with the configuration systems and any
51 * other parts of the system.
53 extern void s3c_gpiolib_add(struct s3c_gpio_chip *chip);
55 /* CONFIG_S3C_GPIO_TRACK enables the tracking of the s3c specific gpios
56 * for use with the configuration calls, and other parts of the s3c gpiolib
59 * Not all s3c support code will need this, as some configurations of cpu
60 * may only support one or two different configuration options and have an
61 * easy gpio to s3c_gpio_chip mapping function. If this is the case, then
62 * the machine support file should provide its own s3c_gpiolib_getchip()
63 * and any other necessary functions.
66 #ifdef CONFIG_S3C_GPIO_TRACK
67 extern struct s3c_gpio_chip *s3c_gpios[S3C_GPIO_END];
69 static inline struct s3c_gpio_chip *s3c_gpiolib_getchip(unsigned int chip)
71 return (chip < S3C_GPIO_END) ? s3c_gpios[chip] : NULL;
74 /* machine specific code should provide s3c_gpiolib_getchip */
76 static inline void s3c_gpiolib_track(struct s3c_gpio_chip *chip) { }