2008-10-31 10:14:34 -06:00
|
|
|
/* linux/arch/arm/plat-s3c/include/plat/gpio-cfg.h
|
|
|
|
*
|
|
|
|
* Copyright 2008 Openmoko, Inc.
|
|
|
|
* Copyright 2008 Simtec Electronics
|
|
|
|
* http://armlinux.simtec.co.uk/
|
|
|
|
* Ben Dooks <ben@simtec.co.uk>
|
|
|
|
*
|
|
|
|
* S3C Platform - GPIO pin configuration
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* This file contains the necessary definitions to get the basic gpio
|
|
|
|
* pin configuration done such as setting a pin to input or output or
|
|
|
|
* changing the pull-{up,down} configurations.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Note, this interface is being added to the s3c64xx arch first and will
|
|
|
|
* be added to the s3c24xx systems later.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __PLAT_GPIO_CFG_H
|
|
|
|
#define __PLAT_GPIO_CFG_H __FILE__
|
|
|
|
|
2012-06-06 06:17:46 -06:00
|
|
|
#include <linux/types.h>
|
ARM: SAMSUNG: include linux/types.h at gpio-cfg.h
Include linux/types.h to fix below build error:
CC drivers/power/max8903_charger.o
In file included from arch/arm/plat-samsung/include/plat/gpio-fns.h:27,
from arch/arm/mach-s3c2410/include/mach/gpio-fns.h:1,
from arch/arm/mach-s3c2410/include/mach/gpio.h:27,
from /home/axel/repos/git/linux-2.6/arch/arm/include/asm/gpio.h:5,
from include/linux/gpio.h:30,
from drivers/power/max8903_charger.c:23:
arch/arm/plat-samsung/include/plat/gpio-cfg.h:27: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'samsung_gpio_pull_t'
arch/arm/plat-samsung/include/plat/gpio-cfg.h:28: error: expected '=', ',', ';', 'asm' or '__attribute__' before 's5p_gpio_drvstr_t'
arch/arm/plat-samsung/include/plat/gpio-cfg.h:55: error: expected specifier-qualifier-list before 'samsung_gpio_pull_t'
arch/arm/plat-samsung/include/plat/gpio-cfg.h:146: error: expected declaration specifiers or '...' before 'samsung_gpio_pull_t'
arch/arm/plat-samsung/include/plat/gpio-cfg.h:154: error: expected '=', ',', ';', 'asm' or '__attribute__' before 's3c_gpio_getpull'
arch/arm/plat-samsung/include/plat/gpio-cfg.h:173: error: expected declaration specifiers or '...' before 'samsung_gpio_pull_t'
arch/arm/plat-samsung/include/plat/gpio-cfg.h: In function 's3c_gpio_cfgrange_nopull':
arch/arm/plat-samsung/include/plat/gpio-cfg.h:178: error: '__force' undeclared (first use in this function)
arch/arm/plat-samsung/include/plat/gpio-cfg.h:178: error: (Each undeclared identifier is reported only once
arch/arm/plat-samsung/include/plat/gpio-cfg.h:178: error: for each function it appears in.)
arch/arm/plat-samsung/include/plat/gpio-cfg.h:178: error: expected ')' before 'samsung_gpio_pull_t'
arch/arm/plat-samsung/include/plat/gpio-cfg.h:178: error: expected ')' before numeric constant
arch/arm/plat-samsung/include/plat/gpio-cfg.h:178: error: too many arguments to function 's3c_gpio_cfgall_range'
arch/arm/plat-samsung/include/plat/gpio-cfg.h: At top level:
arch/arm/plat-samsung/include/plat/gpio-cfg.h:197: error: expected '=', ',', ';', 'asm' or '__attribute__' before 's5p_gpio_get_drvstr'
arch/arm/plat-samsung/include/plat/gpio-cfg.h:208: error: expected declaration specifiers or '...' before 's5p_gpio_drvstr_t'
make[2]: *** [drivers/power/max8903_charger.o] Error 1
make[1]: *** [drivers/power] Error 2
make: *** [drivers] Error 2
Signed-off-by: Axel Lin <axel.lin@gmail.com>
Cc: stable@kernel.org
Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
2011-11-16 09:17:18 -07:00
|
|
|
|
2011-08-30 05:47:32 -06:00
|
|
|
typedef unsigned int __bitwise__ samsung_gpio_pull_t;
|
2010-05-18 04:23:36 -06:00
|
|
|
typedef unsigned int __bitwise__ s5p_gpio_drvstr_t;
|
2008-10-31 10:14:34 -06:00
|
|
|
|
|
|
|
/* forward declaration if gpio-core.h hasn't been included */
|
2011-08-30 05:47:32 -06:00
|
|
|
struct samsung_gpio_chip;
|
2008-10-31 10:14:34 -06:00
|
|
|
|
|
|
|
/**
|
2011-08-30 05:47:32 -06:00
|
|
|
* struct samsung_gpio_cfg GPIO configuration
|
2008-10-31 10:14:34 -06:00
|
|
|
* @cfg_eint: Configuration setting when used for external interrupt source
|
|
|
|
* @get_pull: Read the current pull configuration for the GPIO
|
|
|
|
* @set_pull: Set the current pull configuraiton for the GPIO
|
|
|
|
* @set_config: Set the current configuration for the GPIO
|
|
|
|
* @get_config: Read the current configuration for the GPIO
|
|
|
|
*
|
|
|
|
* Each chip can have more than one type of GPIO bank available and some
|
|
|
|
* have different capabilites even when they have the same control register
|
|
|
|
* layouts. Provide an point to vector control routine and provide any
|
|
|
|
* per-bank configuration information that other systems such as the
|
|
|
|
* external interrupt code will need.
|
2010-05-23 21:21:40 -06:00
|
|
|
*
|
2011-08-30 05:47:32 -06:00
|
|
|
* @sa samsung_gpio_cfgpin
|
2010-05-23 21:21:40 -06:00
|
|
|
* @sa s3c_gpio_getcfg
|
|
|
|
* @sa s3c_gpio_setpull
|
|
|
|
* @sa s3c_gpio_getpull
|
2008-10-31 10:14:34 -06:00
|
|
|
*/
|
2011-08-30 05:47:32 -06:00
|
|
|
struct samsung_gpio_cfg {
|
2008-10-31 10:14:34 -06:00
|
|
|
unsigned int cfg_eint;
|
|
|
|
|
2011-08-30 05:47:32 -06:00
|
|
|
samsung_gpio_pull_t (*get_pull)(struct samsung_gpio_chip *chip, unsigned offs);
|
|
|
|
int (*set_pull)(struct samsung_gpio_chip *chip, unsigned offs,
|
|
|
|
samsung_gpio_pull_t pull);
|
2008-10-31 10:14:34 -06:00
|
|
|
|
2011-08-30 05:47:32 -06:00
|
|
|
unsigned (*get_config)(struct samsung_gpio_chip *chip, unsigned offs);
|
|
|
|
int (*set_config)(struct samsung_gpio_chip *chip, unsigned offs,
|
2008-10-31 10:14:34 -06:00
|
|
|
unsigned config);
|
|
|
|
};
|
|
|
|
|
|
|
|
#define S3C_GPIO_SPECIAL_MARK (0xfffffff0)
|
|
|
|
#define S3C_GPIO_SPECIAL(x) (S3C_GPIO_SPECIAL_MARK | (x))
|
|
|
|
|
|
|
|
/* Defines for generic pin configurations */
|
|
|
|
#define S3C_GPIO_INPUT (S3C_GPIO_SPECIAL(0))
|
|
|
|
#define S3C_GPIO_OUTPUT (S3C_GPIO_SPECIAL(1))
|
|
|
|
#define S3C_GPIO_SFN(x) (S3C_GPIO_SPECIAL(x))
|
|
|
|
|
2011-08-30 05:47:32 -06:00
|
|
|
#define samsung_gpio_is_cfg_special(_cfg) \
|
2008-10-31 10:14:34 -06:00
|
|
|
(((_cfg) & S3C_GPIO_SPECIAL_MARK) == S3C_GPIO_SPECIAL_MARK)
|
|
|
|
|
|
|
|
/**
|
|
|
|
* s3c_gpio_cfgpin() - Change the GPIO function of a pin.
|
|
|
|
* @pin pin The pin number to configure.
|
2010-05-23 21:11:43 -06:00
|
|
|
* @to to The configuration for the pin's function.
|
2008-10-31 10:14:34 -06:00
|
|
|
*
|
|
|
|
* Configure which function is actually connected to the external
|
|
|
|
* pin, such as an gpio input, output or some form of special function
|
|
|
|
* connected to an internal peripheral block.
|
2010-05-23 21:21:40 -06:00
|
|
|
*
|
|
|
|
* The @to parameter can be one of the generic S3C_GPIO_INPUT, S3C_GPIO_OUTPUT
|
|
|
|
* or S3C_GPIO_SFN() to indicate one of the possible values that the helper
|
|
|
|
* will then generate the correct bit mask and shift for the configuration.
|
|
|
|
*
|
|
|
|
* If a bank of GPIOs all needs to be set to special-function 2, then
|
|
|
|
* the following code will work:
|
|
|
|
*
|
|
|
|
* for (gpio = start; gpio < end; gpio++)
|
|
|
|
* s3c_gpio_cfgpin(gpio, S3C_GPIO_SFN(2));
|
|
|
|
*
|
|
|
|
* The @to parameter can also be a specific value already shifted to the
|
|
|
|
* correct position in the control register, although these are discouraged
|
|
|
|
* in newer kernels and are only being kept for compatibility.
|
2008-10-31 10:14:34 -06:00
|
|
|
*/
|
|
|
|
extern int s3c_gpio_cfgpin(unsigned int pin, unsigned int to);
|
|
|
|
|
2010-05-05 19:50:42 -06:00
|
|
|
/**
|
|
|
|
* s3c_gpio_getcfg - Read the current function for a GPIO pin
|
|
|
|
* @pin: The pin to read the configuration value for.
|
|
|
|
*
|
|
|
|
* Read the configuration state of the given @pin, returning a value that
|
|
|
|
* could be passed back to s3c_gpio_cfgpin().
|
|
|
|
*
|
|
|
|
* @sa s3c_gpio_cfgpin
|
|
|
|
*/
|
|
|
|
extern unsigned s3c_gpio_getcfg(unsigned int pin);
|
|
|
|
|
2010-09-30 22:37:13 -06:00
|
|
|
/**
|
|
|
|
* s3c_gpio_cfgpin_range() - Change the GPIO function for configuring pin range
|
|
|
|
* @start: The pin number to start at
|
|
|
|
* @nr: The number of pins to configure from @start.
|
|
|
|
* @cfg: The configuration for the pin's function
|
|
|
|
*
|
|
|
|
* Call s3c_gpio_cfgpin() for the @nr pins starting at @start.
|
|
|
|
*
|
|
|
|
* @sa s3c_gpio_cfgpin.
|
|
|
|
*/
|
|
|
|
extern int s3c_gpio_cfgpin_range(unsigned int start, unsigned int nr,
|
|
|
|
unsigned int cfg);
|
|
|
|
|
2008-10-31 10:14:34 -06:00
|
|
|
/* Define values for the pull-{up,down} available for each gpio pin.
|
|
|
|
*
|
|
|
|
* These values control the state of the weak pull-{up,down} resistors
|
|
|
|
* available on most pins on the S3C series. Not all chips support both
|
2011-03-30 19:57:33 -06:00
|
|
|
* up or down settings, and it may be dependent on the chip that is being
|
2008-10-31 10:14:34 -06:00
|
|
|
* used to whether the particular mode is available.
|
|
|
|
*/
|
2011-08-30 05:47:32 -06:00
|
|
|
#define S3C_GPIO_PULL_NONE ((__force samsung_gpio_pull_t)0x00)
|
|
|
|
#define S3C_GPIO_PULL_DOWN ((__force samsung_gpio_pull_t)0x01)
|
|
|
|
#define S3C_GPIO_PULL_UP ((__force samsung_gpio_pull_t)0x02)
|
2008-10-31 10:14:34 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* s3c_gpio_setpull() - set the state of a gpio pin pull resistor
|
|
|
|
* @pin: The pin number to configure the pull resistor.
|
|
|
|
* @pull: The configuration for the pull resistor.
|
|
|
|
*
|
|
|
|
* This function sets the state of the pull-{up,down} resistor for the
|
2011-03-30 19:57:33 -06:00
|
|
|
* specified pin. It will return 0 if successful, or a negative error
|
2008-10-31 10:14:34 -06:00
|
|
|
* code if the pin cannot support the requested pull setting.
|
2010-05-23 21:21:40 -06:00
|
|
|
*
|
|
|
|
* @pull is one of S3C_GPIO_PULL_NONE, S3C_GPIO_PULL_DOWN or S3C_GPIO_PULL_UP.
|
2008-10-31 10:14:34 -06:00
|
|
|
*/
|
2011-08-30 05:47:32 -06:00
|
|
|
extern int s3c_gpio_setpull(unsigned int pin, samsung_gpio_pull_t pull);
|
2008-10-31 10:14:34 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* s3c_gpio_getpull() - get the pull resistor state of a gpio pin
|
|
|
|
* @pin: The pin number to get the settings for
|
|
|
|
*
|
|
|
|
* Read the pull resistor value for the specified pin.
|
|
|
|
*/
|
2011-08-30 05:47:32 -06:00
|
|
|
extern samsung_gpio_pull_t s3c_gpio_getpull(unsigned int pin);
|
2008-10-31 10:14:34 -06:00
|
|
|
|
2010-10-01 01:34:34 -06:00
|
|
|
/* configure `all` aspects of an gpio */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* s3c_gpio_cfgall_range() - configure range of gpio functtion and pull.
|
|
|
|
* @start: The gpio number to start at.
|
|
|
|
* @nr: The number of gpio to configure from @start.
|
|
|
|
* @cfg: The configuration to use
|
|
|
|
* @pull: The pull setting to use.
|
|
|
|
*
|
|
|
|
* Run s3c_gpio_cfgpin() and s3c_gpio_setpull() over the gpio range starting
|
|
|
|
* @gpio and running for @size.
|
|
|
|
*
|
|
|
|
* @sa s3c_gpio_cfgpin
|
|
|
|
* @sa s3c_gpio_setpull
|
|
|
|
* @sa s3c_gpio_cfgpin_range
|
|
|
|
*/
|
|
|
|
extern int s3c_gpio_cfgall_range(unsigned int start, unsigned int nr,
|
2011-08-30 05:47:32 -06:00
|
|
|
unsigned int cfg, samsung_gpio_pull_t pull);
|
2010-10-01 01:34:34 -06:00
|
|
|
|
2010-10-01 04:07:28 -06:00
|
|
|
static inline int s3c_gpio_cfgrange_nopull(unsigned int pin, unsigned int size,
|
|
|
|
unsigned int cfg)
|
|
|
|
{
|
|
|
|
return s3c_gpio_cfgall_range(pin, size, cfg, S3C_GPIO_PULL_NONE);
|
|
|
|
}
|
|
|
|
|
2010-05-18 04:23:36 -06:00
|
|
|
/* Define values for the drvstr available for each gpio pin.
|
|
|
|
*
|
|
|
|
* These values control the value of the output signal driver strength,
|
2010-08-29 19:45:54 -06:00
|
|
|
* configurable on most pins on the S5P series.
|
2010-05-18 04:23:36 -06:00
|
|
|
*/
|
2010-08-29 19:45:54 -06:00
|
|
|
#define S5P_GPIO_DRVSTR_LV1 ((__force s5p_gpio_drvstr_t)0x0)
|
|
|
|
#define S5P_GPIO_DRVSTR_LV2 ((__force s5p_gpio_drvstr_t)0x2)
|
|
|
|
#define S5P_GPIO_DRVSTR_LV3 ((__force s5p_gpio_drvstr_t)0x1)
|
|
|
|
#define S5P_GPIO_DRVSTR_LV4 ((__force s5p_gpio_drvstr_t)0x3)
|
2010-05-18 04:23:36 -06:00
|
|
|
|
|
|
|
/**
|
|
|
|
* s5c_gpio_get_drvstr() - get the driver streght value of a gpio pin
|
|
|
|
* @pin: The pin number to get the settings for
|
|
|
|
*
|
|
|
|
* Read the driver streght value for the specified pin.
|
|
|
|
*/
|
|
|
|
extern s5p_gpio_drvstr_t s5p_gpio_get_drvstr(unsigned int pin);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* s3c_gpio_set_drvstr() - set the driver streght value of a gpio pin
|
|
|
|
* @pin: The pin number to configure the driver streght value
|
|
|
|
* @drvstr: The new value of the driver strength
|
|
|
|
*
|
|
|
|
* This function sets the driver strength value for the specified pin.
|
2011-03-30 19:57:33 -06:00
|
|
|
* It will return 0 if successful, or a negative error code if the pin
|
2010-05-18 04:23:36 -06:00
|
|
|
* cannot support the requested setting.
|
|
|
|
*/
|
|
|
|
extern int s5p_gpio_set_drvstr(unsigned int pin, s5p_gpio_drvstr_t drvstr);
|
|
|
|
|
2010-09-30 19:40:37 -06:00
|
|
|
/**
|
|
|
|
* s5p_register_gpio_interrupt() - register interrupt support for a gpio group
|
|
|
|
* @pin: The pin number from the group to be registered
|
|
|
|
*
|
|
|
|
* This function registers gpio interrupt support for the group that the
|
|
|
|
* specified pin belongs to.
|
|
|
|
*
|
|
|
|
* The total number of gpio pins is quite large ob s5p series. Registering
|
|
|
|
* irq support for all of them would be a resource waste. Because of that the
|
|
|
|
* interrupt support for standard gpio pins is registered dynamically.
|
|
|
|
*
|
|
|
|
* It will return the irq number of the interrupt that has been registered
|
|
|
|
* or -ENOMEM if no more gpio interrupts can be registered. It is allowed
|
|
|
|
* to call this function more than once for the same gpio group (the group
|
|
|
|
* will be registered only once).
|
|
|
|
*/
|
|
|
|
extern int s5p_register_gpio_interrupt(int pin);
|
|
|
|
|
2011-03-15 06:17:43 -06:00
|
|
|
/** s5p_register_gpioint_bank() - add gpio bank for further gpio interrupt
|
|
|
|
* registration (see s5p_register_gpio_interrupt function)
|
|
|
|
* @chain_irq: chained irq number for the gpio int handler for this bank
|
|
|
|
* @start: start gpio group number of this bank
|
|
|
|
* @nr_groups: number of gpio groups handled by this bank
|
|
|
|
*
|
|
|
|
* This functions registers initial information about gpio banks that
|
|
|
|
* can be later used by the s5p_register_gpio_interrupt() function to
|
|
|
|
* enable support for gpio interrupt for particular gpio group.
|
|
|
|
*/
|
|
|
|
#ifdef CONFIG_S5P_GPIO_INT
|
|
|
|
extern int s5p_register_gpioint_bank(int chain_irq, int start, int nr_groups);
|
|
|
|
#else
|
|
|
|
#define s5p_register_gpioint_bank(chain_irq, start, nr_groups) do { } while (0)
|
|
|
|
#endif
|
|
|
|
|
2008-10-31 10:14:34 -06:00
|
|
|
#endif /* __PLAT_GPIO_CFG_H */
|