Lines Matching refs:nr
118 static int ichx_write_bit(int reg, unsigned nr, int val, int verify) in ichx_write_bit() argument
122 int reg_nr = nr / 32; in ichx_write_bit()
123 int bit = nr & 0x1f; in ichx_write_bit()
153 static int ichx_read_bit(int reg, unsigned nr) in ichx_read_bit() argument
157 int reg_nr = nr / 32; in ichx_read_bit()
158 int bit = nr & 0x1f; in ichx_read_bit()
173 static bool ichx_gpio_check_available(struct gpio_chip *gpio, unsigned nr) in ichx_gpio_check_available() argument
175 return !!(ichx_priv.use_gpio & BIT(nr / 32)); in ichx_gpio_check_available()
178 static int ichx_gpio_get_direction(struct gpio_chip *gpio, unsigned nr) in ichx_gpio_get_direction() argument
180 return ichx_read_bit(GPIO_IO_SEL, nr); in ichx_gpio_get_direction()
183 static int ichx_gpio_direction_input(struct gpio_chip *gpio, unsigned nr) in ichx_gpio_direction_input() argument
189 if (ichx_write_bit(GPIO_IO_SEL, nr, 1, 1)) in ichx_gpio_direction_input()
195 static int ichx_gpio_direction_output(struct gpio_chip *gpio, unsigned nr, in ichx_gpio_direction_output() argument
199 if (nr < 32 && ichx_priv.desc->have_blink) in ichx_gpio_direction_output()
200 ichx_write_bit(GPO_BLINK, nr, 0, 0); in ichx_gpio_direction_output()
203 ichx_write_bit(GPIO_LVL, nr, val, 0); in ichx_gpio_direction_output()
209 if (ichx_write_bit(GPIO_IO_SEL, nr, 0, 1)) in ichx_gpio_direction_output()
215 static int ichx_gpio_get(struct gpio_chip *chip, unsigned nr) in ichx_gpio_get() argument
217 return ichx_read_bit(GPIO_LVL, nr); in ichx_gpio_get()
220 static int ich6_gpio_get(struct gpio_chip *chip, unsigned nr) in ich6_gpio_get() argument
229 if (nr < 16) { in ich6_gpio_get()
236 ICHX_WRITE(BIT(16 + nr), 0, ichx_priv.pm_base); in ich6_gpio_get()
241 return !!((data >> 16) & BIT(nr)); in ich6_gpio_get()
243 return ichx_gpio_get(chip, nr); in ich6_gpio_get()
247 static int ichx_gpio_request(struct gpio_chip *chip, unsigned nr) in ichx_gpio_request() argument
249 if (!ichx_gpio_check_available(chip, nr)) in ichx_gpio_request()
258 if (ichx_priv.desc->use_sel_ignore[nr / 32] & BIT(nr & 0x1f)) in ichx_gpio_request()
261 return ichx_read_bit(GPIO_USE_SEL, nr) ? 0 : -ENODEV; in ichx_gpio_request()
264 static int ich6_gpio_request(struct gpio_chip *chip, unsigned nr) in ich6_gpio_request() argument
272 if (nr == 16 || nr == 17) in ich6_gpio_request()
273 nr -= 16; in ich6_gpio_request()
275 return ichx_gpio_request(chip, nr); in ich6_gpio_request()
278 static void ichx_gpio_set(struct gpio_chip *chip, unsigned nr, int val) in ichx_gpio_set() argument
280 ichx_write_bit(GPIO_LVL, nr, val, 0); in ichx_gpio_set()