paul@0 | 1 | /* |
paul@0 | 2 | * GPIO driver for Ingenic JZ4780. |
paul@0 | 3 | * (See below for additional copyright and licensing notices.) |
paul@0 | 4 | * |
paul@31 | 5 | * Copyright (C) 2017 Paul Boddie <paul@boddie.org.uk> |
paul@0 | 6 | * |
paul@0 | 7 | * This program is free software; you can redistribute it and/or |
paul@0 | 8 | * modify it under the terms of the GNU General Public License as |
paul@0 | 9 | * published by the Free Software Foundation; either version 2 of |
paul@0 | 10 | * the License, or (at your option) any later version. |
paul@0 | 11 | * |
paul@0 | 12 | * This program is distributed in the hope that it will be useful, |
paul@0 | 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@0 | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@0 | 15 | * GNU General Public License for more details. |
paul@0 | 16 | * |
paul@0 | 17 | * You should have received a copy of the GNU General Public License |
paul@0 | 18 | * along with this program; if not, write to the Free Software |
paul@0 | 19 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@0 | 20 | * Boston, MA 02110-1301, USA |
paul@0 | 21 | * |
paul@0 | 22 | * |
paul@0 | 23 | * Subject to other copyrights, being derived from the bcm2835.cc and |
paul@0 | 24 | * omap.cc GPIO driver implementations. |
paul@0 | 25 | * |
paul@0 | 26 | * This file is part of TUD:OS and distributed under the terms of the |
paul@0 | 27 | * GNU General Public License 2. |
paul@0 | 28 | * Please see the COPYING-GPL-2 file for details. |
paul@0 | 29 | */ |
paul@0 | 30 | |
paul@0 | 31 | #include <l4/sys/icu.h> |
paul@0 | 32 | #include <l4/util/util.h> |
paul@0 | 33 | #include <l4/devices/hw_mmio_register_block.h> |
paul@0 | 34 | |
paul@0 | 35 | #include "gpio-jz4780.h" |
paul@0 | 36 | |
paul@0 | 37 | /* |
paul@0 | 38 | GPIO register offsets (x in A..F). |
paul@0 | 39 | |
paul@0 | 40 | Register summary: |
paul@0 | 41 | |
paul@0 | 42 | PxINT 0 (function/GPIO) 1 (interrupt) |
paul@0 | 43 | PxMSK 0 (function) 1 (GPIO) 0 (IRQ enable)/1 (IRQ disable) |
paul@0 | 44 | PxPAT1 0 (function 0/1) 1 (function 2/3) 0 (output) 1 (input) 0 (level trigger) 1 (edge trigger) |
paul@0 | 45 | PxPAT0 0 (function 0) 0 (function 2) 0 (output value 0) 0 (low level) 0 (falling edge) |
paul@0 | 46 | 1 (function 1) 1 (function 3) 1 (output value 1) 1 (high level) 1 (rising edge) |
paul@0 | 47 | */ |
paul@0 | 48 | |
paul@0 | 49 | enum Regs |
paul@0 | 50 | { |
paul@0 | 51 | Pin_level = 0x000, // PxPIN (read-only) |
paul@0 | 52 | |
paul@0 | 53 | Port_int = 0x010, // PxINT |
paul@0 | 54 | Port_int_set = 0x014, // PxINTS |
paul@0 | 55 | Port_int_clear = 0x018, // PxINTC |
paul@0 | 56 | |
paul@0 | 57 | Irq_mask = 0x020, // PxMSK (for PxINT == 1) |
paul@0 | 58 | Irq_mask_set = 0x024, // PxMSKS |
paul@0 | 59 | Irq_mask_clear = 0x028, // PxMSKC |
paul@0 | 60 | Port_gpio = 0x020, // PxMSK (for PxINT == 0) |
paul@0 | 61 | Port_gpio_set = 0x024, // PxMSKS |
paul@0 | 62 | Port_gpio_clear = 0x028, // PxMSKC |
paul@0 | 63 | |
paul@0 | 64 | Port_trigger = 0x030, // PxPAT1 (for PxINT == 1) |
paul@0 | 65 | Port_trigger_set = 0x034, // PxPAT1S |
paul@0 | 66 | Port_trigger_clear = 0x038, // PxPAT1C |
paul@0 | 67 | Port_dir = 0x030, // PxPAT1 (for PxINT == 0, PxMSK == 1) |
paul@0 | 68 | Port_dir_set = 0x034, // PxPAT1S |
paul@0 | 69 | Port_dir_clear = 0x038, // PxPAT1C |
paul@0 | 70 | Port_group1 = 0x030, // PxPAT1 (for PxINT == 0, PxMSK == 0) |
paul@0 | 71 | Port_group1_set = 0x034, // PxPAT1S |
paul@0 | 72 | Port_group1_clear = 0x038, // PxPAT1C |
paul@0 | 73 | |
paul@0 | 74 | Port_level = 0x040, // PxPAT0 (for PxINT == 1) |
paul@0 | 75 | Port_level_set = 0x044, // PxPAT0S |
paul@0 | 76 | Port_level_clear = 0x048, // PxPAT0C |
paul@0 | 77 | Port_data = 0x040, // PxPAT0 (for PxINT == 0, PxMSK == 1, PxPAT1 == 0) |
paul@0 | 78 | Port_data_set = 0x044, // PxPAT0S |
paul@0 | 79 | Port_data_clear = 0x048, // PxPAT0C |
paul@0 | 80 | Port_group0 = 0x040, // PxPAT0 (for PxINT == 0, PxMSK == 0) |
paul@0 | 81 | Port_group0_set = 0x044, // PxPAT0S |
paul@0 | 82 | Port_group0_clear = 0x048, // PxPAT0C |
paul@0 | 83 | |
paul@0 | 84 | Irq_flag = 0x050, // PxFLG (read-only) |
paul@0 | 85 | Irq_flag_clear = 0x058, // PxFLGC |
paul@0 | 86 | |
paul@0 | 87 | Pull_disable = 0x070, // PxPE |
paul@0 | 88 | Pull_disable_set = 0x074, // PxPES |
paul@0 | 89 | Pull_disable_clear = 0x078, // PxPEC |
paul@0 | 90 | }; |
paul@0 | 91 | |
paul@0 | 92 | |
paul@0 | 93 | |
paul@0 | 94 | // IRQ control for each GPIO pin. |
paul@0 | 95 | |
paul@0 | 96 | Gpio_jz4780_irq_pin::Gpio_jz4780_irq_pin(unsigned pin, Hw::Register_block<32> const ®s) |
paul@0 | 97 | : _pin(pin), _regs(regs) |
paul@0 | 98 | {} |
paul@0 | 99 | |
paul@0 | 100 | void |
paul@0 | 101 | Gpio_jz4780_irq_pin::write_reg_pin(unsigned reg) |
paul@0 | 102 | { |
paul@0 | 103 | // Write the pin bit to the register, setting or clearing the pin |
paul@0 | 104 | // depending on the register chosen. |
paul@0 | 105 | |
paul@0 | 106 | _regs[reg] = _pin_bit(_pin); |
paul@0 | 107 | } |
paul@0 | 108 | |
paul@0 | 109 | void Gpio_jz4780_irq_pin::do_mask() |
paul@0 | 110 | { |
paul@0 | 111 | // Set the interrupt bit in the PxIM register. |
paul@0 | 112 | |
paul@0 | 113 | write_reg_pin(Irq_mask_set); |
paul@0 | 114 | } |
paul@0 | 115 | |
paul@0 | 116 | void Gpio_jz4780_irq_pin::do_unmask() |
paul@0 | 117 | { |
paul@0 | 118 | // Clear the interrupt bit in the PxIM register, first also clearing the |
paul@0 | 119 | // flag bit in the PxFLG register to allow interrupts to be delivered. |
paul@0 | 120 | |
paul@0 | 121 | write_reg_pin(Irq_flag_clear); |
paul@0 | 122 | write_reg_pin(Irq_mask_clear); |
paul@0 | 123 | } |
paul@0 | 124 | |
paul@0 | 125 | bool Gpio_jz4780_irq_pin::do_set_mode(unsigned mode) |
paul@0 | 126 | { |
paul@0 | 127 | // Standard comment found for this method: |
paul@0 | 128 | // this operation touches multiple mmio registers and is thus |
paul@0 | 129 | // not atomic, that's why we first mask the IRQ and if it was |
paul@0 | 130 | // enabled we unmask it after we have changed the mode |
paul@0 | 131 | |
paul@0 | 132 | if (enabled()) |
paul@0 | 133 | do_mask(); |
paul@0 | 134 | |
paul@0 | 135 | // Do the PxINT, PxPAT1 and PxPAT0 configuration. |
paul@0 | 136 | |
paul@0 | 137 | switch(mode) |
paul@0 | 138 | { |
paul@0 | 139 | case L4_IRQ_F_LEVEL_HIGH: |
paul@0 | 140 | write_reg_pin(Port_int_set); |
paul@0 | 141 | write_reg_pin(Port_trigger_clear); |
paul@0 | 142 | write_reg_pin(Port_level_set); |
paul@0 | 143 | break; |
paul@0 | 144 | case L4_IRQ_F_LEVEL_LOW: |
paul@0 | 145 | write_reg_pin(Port_int_set); |
paul@0 | 146 | write_reg_pin(Port_trigger_clear); |
paul@0 | 147 | write_reg_pin(Port_level_clear); |
paul@0 | 148 | break; |
paul@0 | 149 | case L4_IRQ_F_POS_EDGE: |
paul@0 | 150 | write_reg_pin(Port_int_set); |
paul@0 | 151 | write_reg_pin(Port_trigger_set); |
paul@0 | 152 | write_reg_pin(Port_level_set); |
paul@0 | 153 | break; |
paul@0 | 154 | case L4_IRQ_F_NEG_EDGE: |
paul@0 | 155 | write_reg_pin(Port_int_set); |
paul@0 | 156 | write_reg_pin(Port_trigger_set); |
paul@0 | 157 | write_reg_pin(Port_level_clear); |
paul@0 | 158 | break; |
paul@0 | 159 | |
paul@0 | 160 | default: |
paul@0 | 161 | return false; |
paul@0 | 162 | } |
paul@0 | 163 | |
paul@0 | 164 | if (enabled()) |
paul@0 | 165 | do_unmask(); |
paul@0 | 166 | |
paul@0 | 167 | return true; |
paul@0 | 168 | } |
paul@0 | 169 | |
paul@0 | 170 | int Gpio_jz4780_irq_pin::clear() |
paul@0 | 171 | { |
paul@0 | 172 | // Obtain the flag status for the pin, clearing it if set. |
paul@0 | 173 | |
paul@0 | 174 | l4_uint32_t e = _regs[Irq_flag] & (1UL << _pin); |
paul@0 | 175 | if (e) |
paul@0 | 176 | _regs[Irq_flag_clear] = e; |
paul@0 | 177 | |
paul@0 | 178 | return (e >> _pin); |
paul@0 | 179 | } |
paul@0 | 180 | |
paul@0 | 181 | bool Gpio_jz4780_irq_pin::enabled() |
paul@0 | 182 | { |
paul@0 | 183 | return true; |
paul@0 | 184 | } |
paul@0 | 185 | |
paul@0 | 186 | |
paul@0 | 187 | |
paul@0 | 188 | // Initialise the GPIO controller. |
paul@0 | 189 | |
paul@0 | 190 | Gpio_jz4780_chip::Gpio_jz4780_chip(l4_addr_t start, l4_addr_t end, |
paul@0 | 191 | unsigned nr_pins, |
paul@0 | 192 | l4_uint32_t pull_ups, l4_uint32_t pull_downs) |
paul@0 | 193 | : _start(start), _end(end), |
paul@0 | 194 | _nr_pins(nr_pins), |
paul@0 | 195 | _pull_ups(pull_ups), _pull_downs(pull_downs) |
paul@0 | 196 | { |
paul@0 | 197 | _regs = new Hw::Mmio_register_block<32>(_start); |
paul@0 | 198 | } |
paul@0 | 199 | |
paul@0 | 200 | // Return the value of a pin. |
paul@0 | 201 | |
paul@0 | 202 | int |
paul@0 | 203 | Gpio_jz4780_chip::get(unsigned pin) |
paul@0 | 204 | { |
paul@0 | 205 | if (pin >= _nr_pins) |
paul@0 | 206 | throw -L4_EINVAL; |
paul@0 | 207 | |
paul@0 | 208 | l4_uint32_t val = _regs[Pin_level]; |
paul@0 | 209 | return (val >> _pin_shift(pin)) & 1; |
paul@0 | 210 | } |
paul@0 | 211 | |
paul@0 | 212 | // Return multiple pin values. |
paul@0 | 213 | |
paul@0 | 214 | unsigned |
paul@0 | 215 | Gpio_jz4780_chip::multi_get(unsigned offset) |
paul@0 | 216 | { |
paul@0 | 217 | _reg_offset_check(offset); |
paul@0 | 218 | return _regs[Pin_level]; |
paul@0 | 219 | } |
paul@0 | 220 | |
paul@0 | 221 | // Set the value of a pin. |
paul@0 | 222 | |
paul@0 | 223 | void |
paul@0 | 224 | Gpio_jz4780_chip::set(unsigned pin, int value) |
paul@0 | 225 | { |
paul@0 | 226 | if (pin >= _nr_pins) |
paul@0 | 227 | throw -L4_EINVAL; |
paul@0 | 228 | |
paul@0 | 229 | l4_uint32_t reg_set = value ? Port_data_set : Port_data_clear; |
paul@0 | 230 | _regs[reg_set] = _pin_bit(pin); |
paul@0 | 231 | } |
paul@0 | 232 | |
paul@0 | 233 | // Set multiple pin values. |
paul@0 | 234 | |
paul@0 | 235 | void |
paul@0 | 236 | Gpio_jz4780_chip::multi_set(Pin_slice const &mask, unsigned data) |
paul@0 | 237 | { |
paul@0 | 238 | _reg_offset_check(mask.offset); |
paul@0 | 239 | if (mask.mask & data) |
paul@0 | 240 | _regs[Port_data_set] = (mask.mask & data); |
paul@0 | 241 | if (mask.mask & ~data) |
paul@0 | 242 | _regs[Port_data_clear] = (mask.mask & ~data); |
paul@0 | 243 | } |
paul@0 | 244 | |
paul@0 | 245 | // Set a pin up with the given mode and value (if appropriate). |
paul@0 | 246 | |
paul@0 | 247 | void |
paul@0 | 248 | Gpio_jz4780_chip::setup(unsigned pin, unsigned mode, int value) |
paul@0 | 249 | { |
paul@0 | 250 | if (pin >= _nr_pins) |
paul@0 | 251 | throw -L4_EINVAL; |
paul@0 | 252 | |
paul@0 | 253 | config(pin, mode); |
paul@0 | 254 | |
paul@0 | 255 | if (mode == Output) |
paul@0 | 256 | set(pin, value); |
paul@0 | 257 | } |
paul@0 | 258 | |
paul@0 | 259 | // Configuration of a pin using the generic input/output/IRQ mode. |
paul@0 | 260 | |
paul@0 | 261 | void |
paul@0 | 262 | Gpio_jz4780_chip::config(unsigned pin, unsigned mode) |
paul@0 | 263 | { |
paul@0 | 264 | switch (mode) |
paul@0 | 265 | { |
paul@0 | 266 | case Input: |
paul@0 | 267 | _regs[Port_int_clear] = _pin_bit(pin); |
paul@0 | 268 | _regs[Port_gpio_set] = _pin_bit(pin); |
paul@0 | 269 | _regs[Port_dir_set] = _pin_bit(pin); |
paul@0 | 270 | break; |
paul@0 | 271 | case Output: |
paul@0 | 272 | _regs[Port_int_clear] = _pin_bit(pin); |
paul@0 | 273 | _regs[Port_gpio_set] = _pin_bit(pin); |
paul@0 | 274 | _regs[Port_dir_clear] = _pin_bit(pin); |
paul@0 | 275 | break; |
paul@0 | 276 | case Irq: |
paul@0 | 277 | _regs[Port_int_set] = _pin_bit(pin); |
paul@0 | 278 | // Other details depend on the actual trigger mode. |
paul@0 | 279 | break; |
paul@0 | 280 | default: |
paul@0 | 281 | break; |
paul@0 | 282 | } |
paul@0 | 283 | } |
paul@0 | 284 | |
paul@0 | 285 | // Pull-up/down configuration for a pin. |
paul@0 | 286 | |
paul@0 | 287 | void |
paul@0 | 288 | Gpio_jz4780_chip::config_pull(unsigned pin, unsigned mode) |
paul@0 | 289 | { |
paul@0 | 290 | if (pin >= _nr_pins) |
paul@0 | 291 | throw -L4_EINVAL; |
paul@0 | 292 | |
paul@0 | 293 | switch (mode) |
paul@0 | 294 | { |
paul@0 | 295 | case Pull_none: |
paul@0 | 296 | _regs[Pull_disable_set] = _pin_bit(pin); |
paul@0 | 297 | break; |
paul@0 | 298 | case Pull_down: |
paul@0 | 299 | if (_pin_bit(pin) & _pull_downs) |
paul@0 | 300 | _regs[Pull_disable_clear] = _pin_bit(pin); |
paul@0 | 301 | break; |
paul@0 | 302 | case Pull_up: |
paul@0 | 303 | if (_pin_bit(pin) & _pull_ups) |
paul@0 | 304 | _regs[Pull_disable_clear] = _pin_bit(pin); |
paul@0 | 305 | break; |
paul@0 | 306 | default: |
paul@0 | 307 | // Invalid pull-up/down mode for pin. |
paul@0 | 308 | throw -L4_EINVAL; |
paul@0 | 309 | } |
paul@0 | 310 | } |
paul@0 | 311 | |
paul@0 | 312 | // Pin function configuration. |
paul@0 | 313 | |
paul@0 | 314 | void |
paul@0 | 315 | Gpio_jz4780_chip::config_pad(unsigned pin, unsigned func, unsigned value) |
paul@0 | 316 | { |
paul@0 | 317 | if (pin >= _nr_pins) |
paul@0 | 318 | throw -L4_EINVAL; |
paul@0 | 319 | |
paul@0 | 320 | if (value > 1) |
paul@0 | 321 | throw -L4_EINVAL; |
paul@0 | 322 | |
paul@0 | 323 | switch (func) |
paul@0 | 324 | { |
paul@0 | 325 | // Support two different outputs. |
paul@0 | 326 | |
paul@0 | 327 | case Hw::Gpio_chip::Function_gpio: |
paul@0 | 328 | _regs[Port_int_clear] = _pin_bit(pin); |
paul@0 | 329 | _regs[Port_gpio_set] = _pin_bit(pin); |
paul@0 | 330 | _regs[value & 1 ? Port_data_set : Port_data_clear] = _pin_bit(pin); |
paul@0 | 331 | break; |
paul@0 | 332 | |
paul@0 | 333 | // Support four different device functions. |
paul@0 | 334 | |
paul@0 | 335 | case Hw::Gpio_chip::Function_alt: |
paul@0 | 336 | _regs[Port_int_clear] = _pin_bit(pin); |
paul@0 | 337 | _regs[Port_gpio_clear] = _pin_bit(pin); |
paul@0 | 338 | _regs[value & 2 ? Port_group1_set : Port_group1_clear] = _pin_bit(pin); |
paul@0 | 339 | _regs[value & 1 ? Port_group0_set : Port_group0_clear] = _pin_bit(pin); |
paul@0 | 340 | break; |
paul@0 | 341 | default: |
paul@0 | 342 | throw -L4_EINVAL; |
paul@0 | 343 | } |
paul@0 | 344 | } |
paul@0 | 345 | |
paul@0 | 346 | // Obtain a pin's configuration from a register in the supplied value. |
paul@0 | 347 | |
paul@0 | 348 | void |
paul@0 | 349 | Gpio_jz4780_chip::config_get(unsigned pin, unsigned reg, unsigned *value) |
paul@0 | 350 | { |
paul@0 | 351 | if (pin >= _nr_pins) |
paul@0 | 352 | throw -L4_EINVAL; |
paul@0 | 353 | |
paul@0 | 354 | *value = (_regs[reg] >> _pin_shift(pin)) & 1; |
paul@0 | 355 | } |
paul@0 | 356 | |
paul@0 | 357 | // Obtain an IRQ abstraction for a pin. |
paul@0 | 358 | |
paul@0 | 359 | Hw::Gpio_irq_pin * |
paul@0 | 360 | Gpio_jz4780_chip::get_irq(unsigned pin) |
paul@0 | 361 | { |
paul@0 | 362 | if (pin >= _nr_pins) |
paul@0 | 363 | throw -L4_EINVAL; |
paul@0 | 364 | |
paul@0 | 365 | return new Gpio_jz4780_irq_pin(pin, _regs); |
paul@0 | 366 | } |
paul@0 | 367 | |
paul@0 | 368 | // Pin function configuration for multiple pins. |
paul@0 | 369 | |
paul@0 | 370 | void |
paul@0 | 371 | Gpio_jz4780_chip::multi_config_pad(Pin_slice const &mask, unsigned func, unsigned val) |
paul@0 | 372 | { |
paul@0 | 373 | unsigned m = mask.mask; |
paul@0 | 374 | for (unsigned pin = mask.offset; pin < _nr_pins; ++pin, m >>= 1) |
paul@0 | 375 | if (m & 1) |
paul@0 | 376 | config_pad(pin, func, val); |
paul@0 | 377 | } |
paul@0 | 378 | |
paul@0 | 379 | // Set up multiple pins with the given mode. |
paul@0 | 380 | |
paul@0 | 381 | void |
paul@0 | 382 | Gpio_jz4780_chip::multi_setup(Pin_slice const &mask, unsigned mode, unsigned outvalues) |
paul@0 | 383 | { |
paul@0 | 384 | unsigned m = mask.mask; |
paul@0 | 385 | for (unsigned pin = mask.offset; pin < _nr_pins; ++pin, m >>= 1, outvalues >>= 1) |
paul@0 | 386 | if (m & 1) |
paul@0 | 387 | setup(pin, mode, outvalues & 1); |
paul@0 | 388 | } |
paul@0 | 389 | |
paul@0 | 390 | |
paul@0 | 391 | |
paul@0 | 392 | // C language interface functions. |
paul@0 | 393 | |
paul@0 | 394 | void *jz4780_gpio_init(l4_addr_t start, l4_addr_t end, unsigned pins, |
paul@0 | 395 | l4_uint32_t pull_ups, l4_uint32_t pull_downs) |
paul@0 | 396 | { |
paul@0 | 397 | return (void *) new Gpio_jz4780_chip(start, end, pins, pull_ups, pull_downs); |
paul@0 | 398 | } |
paul@0 | 399 | |
paul@0 | 400 | void jz4780_gpio_setup(void *gpio, unsigned pin, unsigned mode, int value) |
paul@0 | 401 | { |
paul@0 | 402 | static_cast<Gpio_jz4780_chip *>(gpio)->setup(pin, mode, value); |
paul@0 | 403 | } |
paul@0 | 404 | |
paul@0 | 405 | void jz4780_gpio_config_pull(void *gpio, unsigned pin, unsigned mode) |
paul@0 | 406 | { |
paul@0 | 407 | static_cast<Gpio_jz4780_chip *>(gpio)->config_pull(pin, mode); |
paul@0 | 408 | } |
paul@0 | 409 | |
paul@0 | 410 | void jz4780_gpio_config_pad(void *gpio, unsigned pin, unsigned func, unsigned value) |
paul@0 | 411 | { |
paul@0 | 412 | static_cast<Gpio_jz4780_chip *>(gpio)->config_pad(pin, func, value); |
paul@0 | 413 | } |
paul@0 | 414 | |
paul@0 | 415 | void jz4780_gpio_config_get(void *gpio, unsigned pin, unsigned reg, unsigned *value) |
paul@0 | 416 | { |
paul@0 | 417 | static_cast<Gpio_jz4780_chip *>(gpio)->config_get(pin, reg, value); |
paul@0 | 418 | } |
paul@0 | 419 | |
paul@0 | 420 | void jz4780_gpio_multi_setup(void *gpio, Pin_slice const *mask, unsigned mode, unsigned outvalues) |
paul@0 | 421 | { |
paul@0 | 422 | static_cast<Gpio_jz4780_chip *>(gpio)->multi_setup(*mask, mode, outvalues); |
paul@0 | 423 | } |
paul@0 | 424 | |
paul@0 | 425 | void jz4780_gpio_multi_config_pad(void *gpio, Pin_slice const *mask, unsigned func, unsigned value) |
paul@0 | 426 | { |
paul@0 | 427 | static_cast<Gpio_jz4780_chip *>(gpio)->multi_config_pad(*mask, func, value); |
paul@0 | 428 | } |
paul@0 | 429 | |
paul@0 | 430 | void jz4780_gpio_multi_set(void *gpio, Pin_slice const *mask, unsigned data) |
paul@0 | 431 | { |
paul@0 | 432 | static_cast<Gpio_jz4780_chip *>(gpio)->multi_set(*mask, data); |
paul@0 | 433 | } |
paul@0 | 434 | |
paul@0 | 435 | unsigned jz4780_gpio_multi_get(void *gpio, unsigned offset) |
paul@0 | 436 | { |
paul@0 | 437 | return static_cast<Gpio_jz4780_chip *>(gpio)->multi_get(offset); |
paul@0 | 438 | } |
paul@0 | 439 | |
paul@0 | 440 | int jz4780_gpio_get(void *gpio, unsigned pin) |
paul@0 | 441 | { |
paul@0 | 442 | return static_cast<Gpio_jz4780_chip *>(gpio)->get(pin); |
paul@0 | 443 | } |
paul@0 | 444 | |
paul@0 | 445 | void jz4780_gpio_set(void *gpio, unsigned pin, int value) |
paul@0 | 446 | { |
paul@0 | 447 | static_cast<Gpio_jz4780_chip *>(gpio)->set(pin, value); |
paul@0 | 448 | } |
paul@0 | 449 | |
paul@0 | 450 | void *jz4780_gpio_get_irq(void *gpio, unsigned pin) |
paul@0 | 451 | { |
paul@0 | 452 | return (void *) static_cast<Gpio_jz4780_chip *>(gpio)->get_irq(pin); |
paul@0 | 453 | } |
paul@0 | 454 | |
paul@0 | 455 | bool jz4780_gpio_irq_set_mode(void *gpio_irq, unsigned mode) |
paul@0 | 456 | { |
paul@0 | 457 | return static_cast<Hw::Gpio_irq_pin *>(gpio_irq)->do_set_mode(mode); |
paul@0 | 458 | } |