^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright 2008 Openmoko, Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright 2008 Simtec Electronics
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * http://armlinux.simtec.co.uk/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * Ben Dooks <ben@simtec.co.uk>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Samsung Platform - GPIO pin configuration helper definitions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) /* This is meant for core cpu support, machine or other driver files
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * should not be including this header.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #ifndef __PLAT_GPIO_CFG_HELPERS_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #define __PLAT_GPIO_CFG_HELPERS_H __FILE__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) /* As a note, all gpio configuration functions are entered exclusively, either
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * with the relevant lock held or the system prevented from doing anything else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * by disabling interrupts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) static inline int samsung_gpio_do_setcfg(struct samsung_gpio_chip *chip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) unsigned int off, unsigned int config)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) return (chip->config->set_config)(chip, off, config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) static inline unsigned samsung_gpio_do_getcfg(struct samsung_gpio_chip *chip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) unsigned int off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) return (chip->config->get_config)(chip, off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) static inline int samsung_gpio_do_setpull(struct samsung_gpio_chip *chip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) unsigned int off, samsung_gpio_pull_t pull)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) return (chip->config->set_pull)(chip, off, pull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) static inline samsung_gpio_pull_t samsung_gpio_do_getpull(struct samsung_gpio_chip *chip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) unsigned int off)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) return chip->config->get_pull(chip, off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /* Pull-{up,down} resistor controls.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) * S3C2410,S3C2440 = Pull-UP,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) * S3C2412,S3C2413 = Pull-Down
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) * S3C6400,S3C6410 = Pull-Both [None,Down,Up,Undef]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * S3C2443 = Pull-Both [not same as S3C6400]
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * s3c24xx_gpio_setpull_1up() - Pull configuration for choice of up or none.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) * @chip: The gpio chip that is being configured.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) * @off: The offset for the GPIO being configured.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) * @param: pull: The pull mode being requested.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) * This is a helper function for the case where we have GPIOs with one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) * bit configuring the presence of a pull-up resistor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) extern int s3c24xx_gpio_setpull_1up(struct samsung_gpio_chip *chip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) unsigned int off, samsung_gpio_pull_t pull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) * s3c24xx_gpio_setpull_1down() - Pull configuration for choice of down or none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * @chip: The gpio chip that is being configured
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * @off: The offset for the GPIO being configured
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) * @param: pull: The pull mode being requested
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) * This is a helper function for the case where we have GPIOs with one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * bit configuring the presence of a pull-down resistor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) extern int s3c24xx_gpio_setpull_1down(struct samsung_gpio_chip *chip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) unsigned int off, samsung_gpio_pull_t pull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) * samsung_gpio_setpull_upown() - Pull configuration for choice of up,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) * down or none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) * @chip: The gpio chip that is being configured.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) * @off: The offset for the GPIO being configured.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) * @param: pull: The pull mode being requested.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) * This is a helper function for the case where we have GPIOs with two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) * bits configuring the presence of a pull resistor, in the following
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) * order:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) * 00 = No pull resistor connected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) * 01 = Pull-up resistor connected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) * 10 = Pull-down resistor connected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) extern int samsung_gpio_setpull_updown(struct samsung_gpio_chip *chip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) unsigned int off, samsung_gpio_pull_t pull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) * samsung_gpio_getpull_updown() - Get configuration for choice of up,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) * down or none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) * @chip: The gpio chip that the GPIO pin belongs to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) * @off: The offset to the pin to get the configuration of.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) * This helper function reads the state of the pull-{up,down} resistor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) * for the given GPIO in the same case as samsung_gpio_setpull_upown.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) extern samsung_gpio_pull_t samsung_gpio_getpull_updown(struct samsung_gpio_chip *chip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) unsigned int off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) * s3c24xx_gpio_getpull_1up() - Get configuration for choice of up or none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) * @chip: The gpio chip that the GPIO pin belongs to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) * @off: The offset to the pin to get the configuration of.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) * This helper function reads the state of the pull-up resistor for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) * given GPIO in the same case as s3c24xx_gpio_setpull_1up.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) extern samsung_gpio_pull_t s3c24xx_gpio_getpull_1up(struct samsung_gpio_chip *chip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) unsigned int off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) * s3c24xx_gpio_getpull_1down() - Get configuration for choice of down or none
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) * @chip: The gpio chip that the GPIO pin belongs to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) * @off: The offset to the pin to get the configuration of.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) * This helper function reads the state of the pull-down resistor for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) * given GPIO in the same case as s3c24xx_gpio_setpull_1down.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) extern samsung_gpio_pull_t s3c24xx_gpio_getpull_1down(struct samsung_gpio_chip *chip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) unsigned int off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) * s3c2443_gpio_setpull() - Pull configuration for s3c2443.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) * @chip: The gpio chip that is being configured.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) * @off: The offset for the GPIO being configured.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) * @param: pull: The pull mode being requested.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * This is a helper function for the case where we have GPIOs with two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) * bits configuring the presence of a pull resistor, in the following
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) * order:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) * 00 = Pull-up resistor connected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) * 10 = Pull-down resistor connected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) * x1 = No pull up resistor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) extern int s3c2443_gpio_setpull(struct samsung_gpio_chip *chip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) unsigned int off, samsung_gpio_pull_t pull);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) * s3c2443_gpio_getpull() - Get configuration for s3c2443 pull resistors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) * @chip: The gpio chip that the GPIO pin belongs to.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) * @off: The offset to the pin to get the configuration of.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) * This helper function reads the state of the pull-{up,down} resistor for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) * given GPIO in the same case as samsung_gpio_setpull_upown.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) extern samsung_gpio_pull_t s3c2443_gpio_getpull(struct samsung_gpio_chip *chip,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) unsigned int off);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) #endif /* __PLAT_GPIO_CFG_HELPERS_H */