Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * Copyright 2008 Openmoko, Inc.
0004  * Copyright 2008 Simtec Electronics
0005  *  http://armlinux.simtec.co.uk/
0006  *  Ben Dooks <ben@simtec.co.uk>
0007  *
0008  * Samsung Platform - GPIO pin configuration helper definitions
0009  */
0010 
0011 /* This is meant for core cpu support, machine or other driver files
0012  * should not be including this header.
0013  */
0014 
0015 #ifndef __PLAT_GPIO_CFG_HELPERS_H
0016 #define __PLAT_GPIO_CFG_HELPERS_H __FILE__
0017 
0018 /* As a note, all gpio configuration functions are entered exclusively, either
0019  * with the relevant lock held or the system prevented from doing anything else
0020  * by disabling interrupts.
0021 */
0022 
0023 static inline int samsung_gpio_do_setcfg(struct samsung_gpio_chip *chip,
0024                      unsigned int off, unsigned int config)
0025 {
0026     return (chip->config->set_config)(chip, off, config);
0027 }
0028 
0029 static inline unsigned samsung_gpio_do_getcfg(struct samsung_gpio_chip *chip,
0030                           unsigned int off)
0031 {
0032     return (chip->config->get_config)(chip, off);
0033 }
0034 
0035 static inline int samsung_gpio_do_setpull(struct samsung_gpio_chip *chip,
0036                       unsigned int off, samsung_gpio_pull_t pull)
0037 {
0038     return (chip->config->set_pull)(chip, off, pull);
0039 }
0040 
0041 static inline samsung_gpio_pull_t samsung_gpio_do_getpull(struct samsung_gpio_chip *chip,
0042                               unsigned int off)
0043 {
0044     return chip->config->get_pull(chip, off);
0045 }
0046 
0047 /* Pull-{up,down} resistor controls.
0048  *
0049  * S3C2410,S3C2440 = Pull-UP,
0050  * S3C2412,S3C2413 = Pull-Down
0051  * S3C6400,S3C6410 = Pull-Both [None,Down,Up,Undef]
0052  * S3C2443 = Pull-Both [not same as S3C6400]
0053  */
0054 
0055 /**
0056  * s3c24xx_gpio_setpull_1up() - Pull configuration for choice of up or none.
0057  * @chip: The gpio chip that is being configured.
0058  * @off: The offset for the GPIO being configured.
0059  * @param: pull: The pull mode being requested.
0060  *
0061  * This is a helper function for the case where we have GPIOs with one
0062  * bit configuring the presence of a pull-up resistor.
0063  */
0064 extern int s3c24xx_gpio_setpull_1up(struct samsung_gpio_chip *chip,
0065                     unsigned int off, samsung_gpio_pull_t pull);
0066 
0067 /**
0068  * s3c24xx_gpio_setpull_1down() - Pull configuration for choice of down or none
0069  * @chip: The gpio chip that is being configured
0070  * @off: The offset for the GPIO being configured
0071  * @param: pull: The pull mode being requested
0072  *
0073  * This is a helper function for the case where we have GPIOs with one
0074  * bit configuring the presence of a pull-down resistor.
0075  */
0076 extern int s3c24xx_gpio_setpull_1down(struct samsung_gpio_chip *chip,
0077                       unsigned int off, samsung_gpio_pull_t pull);
0078 
0079 /**
0080  * samsung_gpio_setpull_upown() - Pull configuration for choice of up,
0081  * down or none
0082  *
0083  * @chip: The gpio chip that is being configured.
0084  * @off: The offset for the GPIO being configured.
0085  * @param: pull: The pull mode being requested.
0086  *
0087  * This is a helper function for the case where we have GPIOs with two
0088  * bits configuring the presence of a pull resistor, in the following
0089  * order:
0090  *  00 = No pull resistor connected
0091  *  01 = Pull-up resistor connected
0092  *  10 = Pull-down resistor connected
0093  */
0094 extern int samsung_gpio_setpull_updown(struct samsung_gpio_chip *chip,
0095                        unsigned int off, samsung_gpio_pull_t pull);
0096 
0097 /**
0098  * samsung_gpio_getpull_updown() - Get configuration for choice of up,
0099  * down or none
0100  *
0101  * @chip: The gpio chip that the GPIO pin belongs to
0102  * @off: The offset to the pin to get the configuration of.
0103  *
0104  * This helper function reads the state of the pull-{up,down} resistor
0105  * for the given GPIO in the same case as samsung_gpio_setpull_upown.
0106 */
0107 extern samsung_gpio_pull_t samsung_gpio_getpull_updown(struct samsung_gpio_chip *chip,
0108                                unsigned int off);
0109 
0110 /**
0111  * s3c24xx_gpio_getpull_1up() - Get configuration for choice of up or none
0112  * @chip: The gpio chip that the GPIO pin belongs to
0113  * @off: The offset to the pin to get the configuration of.
0114  *
0115  * This helper function reads the state of the pull-up resistor for the
0116  * given GPIO in the same case as s3c24xx_gpio_setpull_1up.
0117 */
0118 extern samsung_gpio_pull_t s3c24xx_gpio_getpull_1up(struct samsung_gpio_chip *chip,
0119                             unsigned int off);
0120 
0121 /**
0122  * s3c24xx_gpio_getpull_1down() - Get configuration for choice of down or none
0123  * @chip: The gpio chip that the GPIO pin belongs to
0124  * @off: The offset to the pin to get the configuration of.
0125  *
0126  * This helper function reads the state of the pull-down resistor for the
0127  * given GPIO in the same case as s3c24xx_gpio_setpull_1down.
0128 */
0129 extern samsung_gpio_pull_t s3c24xx_gpio_getpull_1down(struct samsung_gpio_chip *chip,
0130                               unsigned int off);
0131 
0132 /**
0133  * s3c2443_gpio_setpull() - Pull configuration for s3c2443.
0134  * @chip: The gpio chip that is being configured.
0135  * @off: The offset for the GPIO being configured.
0136  * @param: pull: The pull mode being requested.
0137  *
0138  * This is a helper function for the case where we have GPIOs with two
0139  * bits configuring the presence of a pull resistor, in the following
0140  * order:
0141  *  00 = Pull-up resistor connected
0142  *  10 = Pull-down resistor connected
0143  *  x1 = No pull up resistor
0144  */
0145 extern int s3c2443_gpio_setpull(struct samsung_gpio_chip *chip,
0146                 unsigned int off, samsung_gpio_pull_t pull);
0147 
0148 /**
0149  * s3c2443_gpio_getpull() - Get configuration for s3c2443 pull resistors
0150  * @chip: The gpio chip that the GPIO pin belongs to.
0151  * @off: The offset to the pin to get the configuration of.
0152  *
0153  * This helper function reads the state of the pull-{up,down} resistor for the
0154  * given GPIO in the same case as samsung_gpio_setpull_upown.
0155 */
0156 extern samsung_gpio_pull_t s3c2443_gpio_getpull(struct samsung_gpio_chip *chip,
0157                         unsigned int off);
0158 
0159 #endif /* __PLAT_GPIO_CFG_HELPERS_H */