1.1 --- a/pkg/devices/lib/gpio/include/gpio-jz4740.h Tue Apr 30 01:31:23 2024 +0200
1.2 +++ b/pkg/devices/lib/gpio/include/gpio-jz4740.h Tue Apr 30 01:32:10 2024 +0200
1.3 @@ -2,7 +2,7 @@
1.4 * GPIO driver for Ingenic JZ4740.
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 @@ -30,10 +30,9 @@
1.13
1.14 #pragma once
1.15
1.16 -#include <l4/sys/err.h>
1.17 #include <l4/sys/types.h>
1.18 #include <stdint.h>
1.19 -#include "gpio.h"
1.20 +#include "gpio-generic.h"
1.21
1.22
1.23
1.24 @@ -71,33 +70,8 @@
1.25 Hw::Register_block<32> _regs;
1.26
1.27 l4_addr_t _start;
1.28 - unsigned _nr_pins;
1.29 struct gpio_port *_pull_config;
1.30
1.31 - // Convenience method for obtaining the bit corresponding to a pin.
1.32 -
1.33 - l4_uint32_t _pin_bit(unsigned pin)
1.34 - { return 1 << (pin & 31); }
1.35 -
1.36 - // Convenience method for obtaining the bit position of a pin.
1.37 -
1.38 - unsigned _pin_shift(unsigned pin)
1.39 - { return pin % 32; }
1.40 -
1.41 - // Permit only "aligned" accesses to registers.
1.42 -
1.43 - unsigned _reg_offset_check(unsigned pin_offset) const
1.44 - {
1.45 - switch (pin_offset)
1.46 - {
1.47 - case 0:
1.48 - return 0;
1.49 -
1.50 - default:
1.51 - throw -L4_EINVAL;
1.52 - }
1.53 - }
1.54 -
1.55 // General configuration register updates.
1.56
1.57 void _config(unsigned bitmap, unsigned mode);
1.58 @@ -111,16 +85,7 @@
1.59 void _config_pad(unsigned bitmap, unsigned func, unsigned value);
1.60
1.61 public:
1.62 - Gpio_jz4740_chip(l4_addr_t start, uint8_t port_number);
1.63 -
1.64 - // Obtain the number of pins.
1.65 -
1.66 - unsigned nr_pins() const { return _nr_pins; }
1.67 -
1.68 - // Unnecessary operations.
1.69 -
1.70 - void request(unsigned) {}
1.71 - void free(unsigned) {}
1.72 + explicit Gpio_jz4740_chip(l4_addr_t start, uint8_t port_number);
1.73
1.74 // Configuration methods.
1.75
1.76 @@ -151,6 +116,9 @@
1.77 void config(unsigned pin, unsigned mode);
1.78 };
1.79
1.80 +Hw::Gpio_chip *jz4740_gpio_chip(l4_addr_t start, uint8_t port_number,
1.81 + bool shadow = false);
1.82 +
1.83 #endif /* __cplusplus */
1.84
1.85