linux/arch/arm/plat-s3c/include/plat/gpio-cfg.h
<<
>>
Prefs
   1/* linux/arch/arm/plat-s3c/include/plat/gpio-cfg.h
   2 *
   3 * Copyright 2008 Openmoko, Inc.
   4 * Copyright 2008 Simtec Electronics
   5 *      http://armlinux.simtec.co.uk/
   6 *      Ben Dooks <ben@simtec.co.uk>
   7 *
   8 * S3C Platform - GPIO pin configuration
   9 *
  10 * This program is free software; you can redistribute it and/or modify
  11 * it under the terms of the GNU General Public License version 2 as
  12 * published by the Free Software Foundation.
  13*/
  14
  15/* This file contains the necessary definitions to get the basic gpio
  16 * pin configuration done such as setting a pin to input or output or
  17 * changing the pull-{up,down} configurations.
  18 */
  19
  20/* Note, this interface is being added to the s3c64xx arch first and will
  21 * be added to the s3c24xx systems later.
  22 */
  23
  24#ifndef __PLAT_GPIO_CFG_H
  25#define __PLAT_GPIO_CFG_H __FILE__
  26
  27typedef unsigned int __bitwise__ s3c_gpio_pull_t;
  28
  29/* forward declaration if gpio-core.h hasn't been included */
  30struct s3c_gpio_chip;
  31
  32/**
  33 * struct s3c_gpio_cfg GPIO configuration
  34 * @cfg_eint: Configuration setting when used for external interrupt source
  35 * @get_pull: Read the current pull configuration for the GPIO
  36 * @set_pull: Set the current pull configuraiton for the GPIO
  37 * @set_config: Set the current configuration for the GPIO
  38 * @get_config: Read the current configuration for the GPIO
  39 *
  40 * Each chip can have more than one type of GPIO bank available and some
  41 * have different capabilites even when they have the same control register
  42 * layouts. Provide an point to vector control routine and provide any
  43 * per-bank configuration information that other systems such as the
  44 * external interrupt code will need.
  45 */
  46struct s3c_gpio_cfg {
  47        unsigned int    cfg_eint;
  48
  49        s3c_gpio_pull_t (*get_pull)(struct s3c_gpio_chip *chip, unsigned offs);
  50        int             (*set_pull)(struct s3c_gpio_chip *chip, unsigned offs,
  51                                    s3c_gpio_pull_t pull);
  52
  53        unsigned (*get_config)(struct s3c_gpio_chip *chip, unsigned offs);
  54        int      (*set_config)(struct s3c_gpio_chip *chip, unsigned offs,
  55                               unsigned config);
  56};
  57
  58#define S3C_GPIO_SPECIAL_MARK   (0xfffffff0)
  59#define S3C_GPIO_SPECIAL(x)     (S3C_GPIO_SPECIAL_MARK | (x))
  60
  61/* Defines for generic pin configurations */
  62#define S3C_GPIO_INPUT  (S3C_GPIO_SPECIAL(0))
  63#define S3C_GPIO_OUTPUT (S3C_GPIO_SPECIAL(1))
  64#define S3C_GPIO_SFN(x) (S3C_GPIO_SPECIAL(x))
  65
  66#define s3c_gpio_is_cfg_special(_cfg) \
  67        (((_cfg) & S3C_GPIO_SPECIAL_MARK) == S3C_GPIO_SPECIAL_MARK)
  68
  69/**
  70 * s3c_gpio_cfgpin() - Change the GPIO function of a pin.
  71 * @pin pin The pin number to configure.
  72 * @pin to The configuration for the pin's function.
  73 *
  74 * Configure which function is actually connected to the external
  75 * pin, such as an gpio input, output or some form of special function
  76 * connected to an internal peripheral block.
  77 */
  78extern int s3c_gpio_cfgpin(unsigned int pin, unsigned int to);
  79
  80/* Define values for the pull-{up,down} available for each gpio pin.
  81 *
  82 * These values control the state of the weak pull-{up,down} resistors
  83 * available on most pins on the S3C series. Not all chips support both
  84 * up or down settings, and it may be dependant on the chip that is being
  85 * used to whether the particular mode is available.
  86 */
  87#define S3C_GPIO_PULL_NONE      ((__force s3c_gpio_pull_t)0x00)
  88#define S3C_GPIO_PULL_DOWN      ((__force s3c_gpio_pull_t)0x01)
  89#define S3C_GPIO_PULL_UP        ((__force s3c_gpio_pull_t)0x02)
  90
  91/**
  92 * s3c_gpio_setpull() - set the state of a gpio pin pull resistor
  93 * @pin: The pin number to configure the pull resistor.
  94 * @pull: The configuration for the pull resistor.
  95 *
  96 * This function sets the state of the pull-{up,down} resistor for the
  97 * specified pin. It will return 0 if successfull, or a negative error
  98 * code if the pin cannot support the requested pull setting.
  99*/
 100extern int s3c_gpio_setpull(unsigned int pin, s3c_gpio_pull_t pull);
 101
 102/**
 103 * s3c_gpio_getpull() - get the pull resistor state of a gpio pin
 104 * @pin: The pin number to get the settings for
 105 *
 106 * Read the pull resistor value for the specified pin.
 107*/
 108extern s3c_gpio_pull_t s3c_gpio_getpull(unsigned int pin);
 109
 110#endif /* __PLAT_GPIO_CFG_H */
 111