2017-12-25 19:54:35 +00:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
/*
|
2008-10-31 16:14:34 +00:00
|
|
|
* Copyright 2008 Openmoko, Inc.
|
|
|
|
* Copyright 2008 Simtec Electronics
|
|
|
|
* http://armlinux.simtec.co.uk/
|
|
|
|
* Ben Dooks <ben@simtec.co.uk>
|
|
|
|
*
|
2011-08-30 11:47:32 +00:00
|
|
|
* Samsung Platform - GPIO pin configuration helper definitions
|
2017-12-25 19:54:35 +00:00
|
|
|
*/
|
2008-10-31 16:14:34 +00:00
|
|
|
|
|
|
|
/* This is meant for core cpu support, machine or other driver files
|
|
|
|
* should not be including this header.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __PLAT_GPIO_CFG_HELPERS_H
|
|
|
|
#define __PLAT_GPIO_CFG_HELPERS_H __FILE__
|
|
|
|
|
|
|
|
/* As a note, all gpio configuration functions are entered exclusively, either
|
|
|
|
* with the relevant lock held or the system prevented from doing anything else
|
|
|
|
* by disabling interrupts.
|
|
|
|
*/
|
|
|
|
|
2011-08-30 11:47:32 +00:00
|
|
|
static inline int samsung_gpio_do_setcfg(struct samsung_gpio_chip *chip,
|
|
|
|
unsigned int off, unsigned int config)
|
2008-10-31 16:14:34 +00:00
|
|
|
{
|
|
|
|
return (chip->config->set_config)(chip, off, config);
|
|
|
|
}
|
|
|
|
|
2011-08-30 11:47:32 +00:00
|
|
|
static inline unsigned samsung_gpio_do_getcfg(struct samsung_gpio_chip *chip,
|
|
|
|
unsigned int off)
|
2010-05-06 01:50:42 +00:00
|
|
|
{
|
|
|
|
return (chip->config->get_config)(chip, off);
|
|
|
|
}
|
|
|
|
|
2011-08-30 11:47:32 +00:00
|
|
|
static inline int samsung_gpio_do_setpull(struct samsung_gpio_chip *chip,
|
|
|
|
unsigned int off, samsung_gpio_pull_t pull)
|
2008-10-31 16:14:34 +00:00
|
|
|
{
|
|
|
|
return (chip->config->set_pull)(chip, off, pull);
|
|
|
|
}
|
|
|
|
|
2011-08-30 11:47:32 +00:00
|
|
|
static inline samsung_gpio_pull_t samsung_gpio_do_getpull(struct samsung_gpio_chip *chip,
|
|
|
|
unsigned int off)
|
2010-10-25 23:40:08 +00:00
|
|
|
{
|
|
|
|
return chip->config->get_pull(chip, off);
|
|
|
|
}
|
|
|
|
|
2008-10-31 16:14:34 +00:00
|
|
|
/* Pull-{up,down} resistor controls.
|
|
|
|
*
|
2011-07-06 03:44:31 +00:00
|
|
|
* S3C2410,S3C2440 = Pull-UP,
|
2008-10-31 16:14:34 +00:00
|
|
|
* S3C2412,S3C2413 = Pull-Down
|
|
|
|
* S3C6400,S3C6410 = Pull-Both [None,Down,Up,Undef]
|
|
|
|
* S3C2443 = Pull-Both [not same as S3C6400]
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2011-08-30 11:47:32 +00:00
|
|
|
* s3c24xx_gpio_setpull_1up() - Pull configuration for choice of up or none.
|
2008-10-31 16:14:34 +00:00
|
|
|
* @chip: The gpio chip that is being configured.
|
|
|
|
* @off: The offset for the GPIO being configured.
|
|
|
|
* @param: pull: The pull mode being requested.
|
|
|
|
*
|
|
|
|
* This is a helper function for the case where we have GPIOs with one
|
|
|
|
* bit configuring the presence of a pull-up resistor.
|
|
|
|
*/
|
2011-08-30 11:47:32 +00:00
|
|
|
extern int s3c24xx_gpio_setpull_1up(struct samsung_gpio_chip *chip,
|
|
|
|
unsigned int off, samsung_gpio_pull_t pull);
|
2008-10-31 16:14:34 +00:00
|
|
|
|
|
|
|
/**
|
2011-08-30 11:47:32 +00:00
|
|
|
* s3c24xx_gpio_setpull_1down() - Pull configuration for choice of down or none
|
2008-10-31 16:14:34 +00:00
|
|
|
* @chip: The gpio chip that is being configured
|
|
|
|
* @off: The offset for the GPIO being configured
|
|
|
|
* @param: pull: The pull mode being requested
|
|
|
|
*
|
|
|
|
* This is a helper function for the case where we have GPIOs with one
|
|
|
|
* bit configuring the presence of a pull-down resistor.
|
|
|
|
*/
|
2011-08-30 11:47:32 +00:00
|
|
|
extern int s3c24xx_gpio_setpull_1down(struct samsung_gpio_chip *chip,
|
|
|
|
unsigned int off, samsung_gpio_pull_t pull);
|
2008-10-31 16:14:34 +00:00
|
|
|
|
|
|
|
/**
|
2011-08-30 11:47:32 +00:00
|
|
|
* samsung_gpio_setpull_upown() - Pull configuration for choice of up,
|
|
|
|
* down or none
|
|
|
|
*
|
2008-10-31 16:14:34 +00:00
|
|
|
* @chip: The gpio chip that is being configured.
|
|
|
|
* @off: The offset for the GPIO being configured.
|
|
|
|
* @param: pull: The pull mode being requested.
|
|
|
|
*
|
|
|
|
* This is a helper function for the case where we have GPIOs with two
|
|
|
|
* bits configuring the presence of a pull resistor, in the following
|
|
|
|
* order:
|
|
|
|
* 00 = No pull resistor connected
|
|
|
|
* 01 = Pull-up resistor connected
|
|
|
|
* 10 = Pull-down resistor connected
|
|
|
|
*/
|
2011-08-30 11:47:32 +00:00
|
|
|
extern int samsung_gpio_setpull_updown(struct samsung_gpio_chip *chip,
|
|
|
|
unsigned int off, samsung_gpio_pull_t pull);
|
2008-10-31 16:14:34 +00:00
|
|
|
|
|
|
|
/**
|
2011-08-30 11:47:32 +00:00
|
|
|
* samsung_gpio_getpull_updown() - Get configuration for choice of up,
|
|
|
|
* down or none
|
|
|
|
*
|
2008-10-31 16:14:34 +00:00
|
|
|
* @chip: The gpio chip that the GPIO pin belongs to
|
|
|
|
* @off: The offset to the pin to get the configuration of.
|
|
|
|
*
|
2011-08-30 11:47:32 +00:00
|
|
|
* This helper function reads the state of the pull-{up,down} resistor
|
|
|
|
* for the given GPIO in the same case as samsung_gpio_setpull_upown.
|
2008-10-31 16:14:34 +00:00
|
|
|
*/
|
2011-08-30 11:47:32 +00:00
|
|
|
extern samsung_gpio_pull_t samsung_gpio_getpull_updown(struct samsung_gpio_chip *chip,
|
|
|
|
unsigned int off);
|
2008-10-31 16:14:34 +00:00
|
|
|
|
2010-05-03 05:39:45 +00:00
|
|
|
/**
|
2011-08-30 11:47:32 +00:00
|
|
|
* s3c24xx_gpio_getpull_1up() - Get configuration for choice of up or none
|
2010-05-03 05:39:45 +00:00
|
|
|
* @chip: The gpio chip that the GPIO pin belongs to
|
|
|
|
* @off: The offset to the pin to get the configuration of.
|
|
|
|
*
|
|
|
|
* This helper function reads the state of the pull-up resistor for the
|
2011-08-30 11:47:32 +00:00
|
|
|
* given GPIO in the same case as s3c24xx_gpio_setpull_1up.
|
2010-05-03 05:39:45 +00:00
|
|
|
*/
|
2011-08-30 11:47:32 +00:00
|
|
|
extern samsung_gpio_pull_t s3c24xx_gpio_getpull_1up(struct samsung_gpio_chip *chip,
|
|
|
|
unsigned int off);
|
2010-05-03 05:39:45 +00:00
|
|
|
|
2010-12-01 06:29:23 +00:00
|
|
|
/**
|
2011-08-30 11:47:32 +00:00
|
|
|
* s3c24xx_gpio_getpull_1down() - Get configuration for choice of down or none
|
2010-12-01 06:29:23 +00:00
|
|
|
* @chip: The gpio chip that the GPIO pin belongs to
|
|
|
|
* @off: The offset to the pin to get the configuration of.
|
|
|
|
*
|
|
|
|
* This helper function reads the state of the pull-down resistor for the
|
2011-08-30 11:47:32 +00:00
|
|
|
* given GPIO in the same case as s3c24xx_gpio_setpull_1down.
|
2010-12-01 06:29:23 +00:00
|
|
|
*/
|
2011-08-30 11:47:32 +00:00
|
|
|
extern samsung_gpio_pull_t s3c24xx_gpio_getpull_1down(struct samsung_gpio_chip *chip,
|
|
|
|
unsigned int off);
|
2010-12-01 06:29:23 +00:00
|
|
|
|
2008-10-31 16:14:34 +00:00
|
|
|
/**
|
2011-08-30 11:47:32 +00:00
|
|
|
* s3c2443_gpio_setpull() - Pull configuration for s3c2443.
|
2008-10-31 16:14:34 +00:00
|
|
|
* @chip: The gpio chip that is being configured.
|
|
|
|
* @off: The offset for the GPIO being configured.
|
|
|
|
* @param: pull: The pull mode being requested.
|
|
|
|
*
|
|
|
|
* This is a helper function for the case where we have GPIOs with two
|
|
|
|
* bits configuring the presence of a pull resistor, in the following
|
|
|
|
* order:
|
|
|
|
* 00 = Pull-up resistor connected
|
|
|
|
* 10 = Pull-down resistor connected
|
|
|
|
* x1 = No pull up resistor
|
|
|
|
*/
|
2011-08-30 11:47:32 +00:00
|
|
|
extern int s3c2443_gpio_setpull(struct samsung_gpio_chip *chip,
|
|
|
|
unsigned int off, samsung_gpio_pull_t pull);
|
2008-10-31 16:14:34 +00:00
|
|
|
|
|
|
|
/**
|
2011-08-30 11:47:32 +00:00
|
|
|
* s3c2443_gpio_getpull() - Get configuration for s3c2443 pull resistors
|
2008-10-31 16:14:34 +00:00
|
|
|
* @chip: The gpio chip that the GPIO pin belongs to.
|
|
|
|
* @off: The offset to the pin to get the configuration of.
|
|
|
|
*
|
|
|
|
* This helper function reads the state of the pull-{up,down} resistor for the
|
2011-08-30 11:47:32 +00:00
|
|
|
* given GPIO in the same case as samsung_gpio_setpull_upown.
|
2008-10-31 16:14:34 +00:00
|
|
|
*/
|
2011-08-30 11:47:32 +00:00
|
|
|
extern samsung_gpio_pull_t s3c2443_gpio_getpull(struct samsung_gpio_chip *chip,
|
2008-10-31 16:14:34 +00:00
|
|
|
unsigned int off);
|
|
|
|
|
|
|
|
#endif /* __PLAT_GPIO_CFG_HELPERS_H */
|