1.1 --- a/pkg/devices/lib/gpio/include/gpio-x1600.h Fri Feb 23 22:53:30 2024 +0100
1.2 +++ b/pkg/devices/lib/gpio/include/gpio-x1600.h Mon Feb 26 16:18:13 2024 +0100
1.3 @@ -2,7 +2,7 @@
1.4 * GPIO driver for Ingenic X1600.
1.5 * (See below for additional copyright and licensing notices.)
1.6 *
1.7 - * Copyright (C) 2017, 2018, 2023 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 2017, 2018, 2023, 2024 Paul Boddie <paul@boddie.org.uk>
1.9 *
1.10 * This program is free software; you can redistribute it and/or
1.11 * modify it under the terms of the GNU General Public License as
1.12 @@ -46,7 +46,12 @@
1.13 class Gpio_x1600_irq_pin : public Hw::Gpio_irq_pin
1.14 {
1.15 unsigned _pin;
1.16 - Hw::Register_block<32> _regs;
1.17 +
1.18 + // Register blocks for the conventional and optional shadow registers.
1.19 +
1.20 + Hw::Register_block<32> _regs, _shadow_regs;
1.21 + uint8_t _port_number;
1.22 + bool _shadow;
1.23
1.24 // Convenience method for obtaining the bit corresponding to a pin.
1.25
1.26 @@ -56,6 +61,10 @@
1.27 void write_reg_pin(unsigned reg);
1.28
1.29 public:
1.30 + Gpio_x1600_irq_pin(unsigned pin, Hw::Register_block<32> const ®s,
1.31 + Hw::Register_block<32> const &shadow_regs,
1.32 + uint8_t port_number);
1.33 +
1.34 Gpio_x1600_irq_pin(unsigned pin, Hw::Register_block<32> const ®s);
1.35
1.36 void do_mask();
1.37 @@ -68,12 +77,20 @@
1.38 class Gpio_x1600_chip : public Hw::Gpio_chip
1.39 {
1.40 private:
1.41 - Hw::Register_block<32> _regs;
1.42 + // Register blocks for the conventional and optional shadow registers.
1.43 +
1.44 + Hw::Register_block<32> _regs, _shadow_regs;
1.45
1.46 l4_addr_t _start, _end;
1.47 unsigned _nr_pins;
1.48 l4_uint32_t _pull_ups, _pull_downs;
1.49
1.50 + // Optional shadow port configuration.
1.51 +
1.52 + l4_addr_t _shadow_start, _shadow_end;
1.53 + uint8_t _port_number;
1.54 + bool _shadow;
1.55 +
1.56 // Convenience method for obtaining the bit corresponding to a pin.
1.57
1.58 l4_uint32_t _pin_bit(unsigned pin)
1.59 @@ -98,10 +115,14 @@
1.60 }
1.61 }
1.62
1.63 + void write_reg_pin(unsigned reg, unsigned pin);
1.64 +
1.65 public:
1.66 Gpio_x1600_chip(l4_addr_t start, l4_addr_t end,
1.67 - unsigned nr_pins,
1.68 - l4_uint32_t pull_ups, l4_uint32_t pull_downs);
1.69 + unsigned nr_pins,
1.70 + l4_uint32_t pull_ups, l4_uint32_t pull_downs,
1.71 + l4_addr_t shadow_start = 0, l4_addr_t shadow_end = 0,
1.72 + uint8_t port_number = 0);
1.73
1.74 // Obtain the number of pins.
1.75
1.76 @@ -149,7 +170,12 @@
1.77 EXTERN_C_BEGIN
1.78
1.79 void *x1600_gpio_init(l4_addr_t start, l4_addr_t end, unsigned pins,
1.80 - l4_uint32_t pull_ups, l4_uint32_t pull_downs);
1.81 + l4_uint32_t pull_ups, l4_uint32_t pull_downs);
1.82 +
1.83 +void *x1600_gpio_init_shadow(l4_addr_t start, l4_addr_t end, unsigned pins,
1.84 + l4_uint32_t pull_ups, l4_uint32_t pull_downs,
1.85 + l4_addr_t shadow_start, l4_addr_t shadow_end,
1.86 + uint8_t port_number);
1.87
1.88 void x1600_gpio_setup(void *gpio, unsigned pin, unsigned mode, int value);
1.89 void x1600_gpio_config_pull(void *gpio, unsigned pin, unsigned mode);