1.1 --- a/pkg/devices/lib/gpio/include/gpio-x1600.h Tue Apr 30 01:31:23 2024 +0200
1.2 +++ b/pkg/devices/lib/gpio/include/gpio-x1600.h Tue Apr 30 01:32:10 2024 +0200
1.3 @@ -30,10 +30,9 @@
1.4
1.5 #pragma once
1.6
1.7 -#include <l4/sys/err.h>
1.8 #include <l4/sys/types.h>
1.9 #include <stdint.h>
1.10 -#include "gpio.h"
1.11 +#include "gpio-generic.h"
1.12
1.13
1.14
1.15 @@ -82,7 +81,6 @@
1.16 Hw::Register_block<32> _regs, _shadow_regs;
1.17
1.18 l4_addr_t _start;
1.19 - unsigned _nr_pins;
1.20 struct gpio_port *_pull_config;
1.21
1.22 // Optional shadow port configuration.
1.23 @@ -91,43 +89,11 @@
1.24 uint8_t _port_number;
1.25 bool _shadow;
1.26
1.27 - // Convenience method for obtaining the bit corresponding to a pin.
1.28 -
1.29 - l4_uint32_t _pin_bit(unsigned pin)
1.30 - { return 1 << (pin & 31); }
1.31 -
1.32 - // Convenience method for obtaining the bit position of a pin.
1.33 -
1.34 - unsigned _pin_shift(unsigned pin)
1.35 - { return pin % 32; }
1.36 -
1.37 - // Permit only "aligned" accesses to registers.
1.38 -
1.39 - unsigned _reg_offset_check(unsigned pin_offset) const
1.40 - {
1.41 - switch (pin_offset)
1.42 - {
1.43 - case 0:
1.44 - return 0;
1.45 -
1.46 - default:
1.47 - throw -L4_EINVAL;
1.48 - }
1.49 - }
1.50 -
1.51 void write_reg_pin(unsigned reg, unsigned pin);
1.52
1.53 public:
1.54 - Gpio_x1600_chip(l4_addr_t start, uint8_t port_number, bool shadow = false);
1.55 -
1.56 - // Obtain the number of pins.
1.57 -
1.58 - unsigned nr_pins() const { return _nr_pins; }
1.59 -
1.60 - // Unnecessary operations.
1.61 -
1.62 - void request(unsigned) {}
1.63 - void free(unsigned) {}
1.64 + explicit Gpio_x1600_chip(l4_addr_t start, uint8_t port_number,
1.65 + bool shadow = false);
1.66
1.67 // Configuration methods.
1.68
1.69 @@ -157,6 +123,9 @@
1.70 void config(unsigned pin, unsigned mode);
1.71 };
1.72
1.73 +Hw::Gpio_chip *x1600_gpio_chip(l4_addr_t start, uint8_t port_number,
1.74 + bool shadow = false);
1.75 +
1.76 #endif /* __cplusplus */
1.77
1.78