1.1 --- a/pkg/devices/display/src/letux400/display-letux400.cc Sat Apr 27 23:46:28 2024 +0200 1.2 +++ b/pkg/devices/display/src/letux400/display-letux400.cc Sun Apr 28 18:37:08 2024 +0200 1.3 @@ -1,7 +1,7 @@ 1.4 /* 1.5 * Export Letux 400 display operations as a server. 1.6 * 1.7 - * Copyright (C) 2018, 2020, 2023 Paul Boddie <paul@boddie.org.uk> 1.8 + * Copyright (C) 2018, 2020, 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 @@ -119,8 +119,8 @@ 1.13 1.14 /* Initialise the GPIO abstractions. */ 1.15 1.16 - Gpio_jz4730_chip gpb(gpio_virt_base + (1 * 0x30), gpio_virt_base + (2 * 0x30), 32); 1.17 - Gpio_jz4730_chip gpc(gpio_virt_base + (2 * 0x30), gpio_virt_base + (3 * 0x30), 32); 1.18 + Gpio_jz4730_chip gpb(gpio_virt_base, 1); 1.19 + Gpio_jz4730_chip gpc(gpio_virt_base, 2); 1.20 1.21 gpio_port_b = &gpb; 1.22 gpio_port_c = &gpc;
2.1 --- a/pkg/devices/display/src/qi_lb60/display-qi_lb60.cc Sat Apr 27 23:46:28 2024 +0200 2.2 +++ b/pkg/devices/display/src/qi_lb60/display-qi_lb60.cc Sun Apr 28 18:37:08 2024 +0200 2.3 @@ -1,7 +1,7 @@ 2.4 /* 2.5 * Export Ben NanoNote display operations as a server. 2.6 * 2.7 - * Copyright (C) 2018, 2020, 2023 Paul Boddie <paul@boddie.org.uk> 2.8 + * Copyright (C) 2018, 2020, 2023, 2024 Paul Boddie <paul@boddie.org.uk> 2.9 * 2.10 * This program is free software; you can redistribute it and/or 2.11 * modify it under the terms of the GNU General Public License as 2.12 @@ -116,7 +116,7 @@ 2.13 2.14 /* Initialise the GPIO abstraction. */ 2.15 2.16 - Gpio_jz4740_chip gpio_port(gpio_virt_base + 0x200, gpio_virt_base + 0x300, 32); 2.17 + Gpio_jz4740_chip gpio_port(gpio_virt_base, 2); 2.18 2.19 gpio_port_c = &gpio_port; 2.20
3.1 --- a/pkg/devices/keypad/src/letux400/keypad-letux400.cc Sat Apr 27 23:46:28 2024 +0200 3.2 +++ b/pkg/devices/keypad/src/letux400/keypad-letux400.cc Sun Apr 28 18:37:08 2024 +0200 3.3 @@ -2,7 +2,7 @@ 3.4 * Export the keypad GPIOs on the Letux 400 as a data space accessible via the 3.5 * "keypad" capability. 3.6 * 3.7 - * Copyright (C) 2018, 2023 Paul Boddie <paul@boddie.org.uk> 3.8 + * Copyright (C) 2018, 2023, 2024 Paul Boddie <paul@boddie.org.uk> 3.9 * 3.10 * This program is free software; you can redistribute it and/or 3.11 * modify it under the terms of the GNU General Public License as 3.12 @@ -83,8 +83,8 @@ 3.13 if (get_memory("jz4730-gpio", &gpio_virt_base, &gpio_virt_base_end) < 0) 3.14 return 1; 3.15 3.16 - gpio_port_a = jz4730_gpio_init(gpio_virt_base, gpio_virt_base + 0x30, 32); 3.17 - gpio_port_d = jz4730_gpio_init(gpio_virt_base + 0x90, gpio_virt_base + 0xc0, 32); 3.18 + gpio_port_a = jz4730_gpio_init(gpio_virt_base, 0); 3.19 + gpio_port_d = jz4730_gpio_init(gpio_virt_base, 3); 3.20 3.21 return 0; 3.22 }
4.1 --- a/pkg/devices/keypad/src/qi_lb60/keypad-qi_lb60.cc Sat Apr 27 23:46:28 2024 +0200 4.2 +++ b/pkg/devices/keypad/src/qi_lb60/keypad-qi_lb60.cc Sun Apr 28 18:37:08 2024 +0200 4.3 @@ -2,7 +2,7 @@ 4.4 * Export the keypad GPIOs on the Ben NanoNote as a data space accessible via 4.5 * the "keypad" capability. 4.6 * 4.7 - * Copyright (C) 2018, 2023 Paul Boddie <paul@boddie.org.uk> 4.8 + * Copyright (C) 2018, 2023, 2024 Paul Boddie <paul@boddie.org.uk> 4.9 * 4.10 * This program is free software; you can redistribute it and/or 4.11 * modify it under the terms of the GNU General Public License as 4.12 @@ -81,8 +81,8 @@ 4.13 if (get_memory("jz4740-gpio", &gpio_virt_base, &gpio_virt_base_end) < 0) 4.14 return 1; 4.15 4.16 - gpio_port_c = jz4740_gpio_init(gpio_virt_base + 0x200, gpio_virt_base + 0x300, 32); 4.17 - gpio_port_d = jz4740_gpio_init(gpio_virt_base + 0x300, gpio_virt_base + 0x400, 32); 4.18 + gpio_port_c = jz4740_gpio_init(gpio_virt_base, 2); 4.19 + gpio_port_d = jz4740_gpio_init(gpio_virt_base, 3); 4.20 4.21 return 0; 4.22 }
5.1 --- a/pkg/devices/lcd/src/jz4780/lcd-jz4780-spi-device.cc Sat Apr 27 23:46:28 2024 +0200 5.2 +++ b/pkg/devices/lcd/src/jz4780/lcd-jz4780-spi-device.cc Sun Apr 28 18:37:08 2024 +0200 5.3 @@ -66,20 +66,6 @@ 5.4 static Spi_hybrid *spi_channel; 5.5 static Spi_jz4780_channel *spi_jz4780_channel; 5.6 5.7 -struct gpio_port 5.8 -{ 5.9 - uint32_t pull_ups, pull_downs; 5.10 -}; 5.11 - 5.12 -static struct gpio_port gpio_ports[] = { 5.13 - {0x3fff00ff, 0x00000000}, 5.14 - {0xfff0f3fc, 0x000f0c03}, 5.15 - {0x0fffffff, 0x00000000}, 5.16 - {0xffff4fff, 0x0000b000}, 5.17 - {0xf0fff37c, 0x00000483}, 5.18 - {0x7fa7f00f, 0x00580ff0}, 5.19 -}; 5.20 - 5.21 5.22 5.23 // Disable the display. 5.24 @@ -227,10 +213,7 @@ 5.25 5.26 dma_chip->enable(); 5.27 5.28 - gpio_chip = new Gpio_jz4780_chip(gpio_virt_base + gpio_port * 0x100, 5.29 - gpio_virt_base + (gpio_port + 1) * 0x100, 5.30 - 32, gpio_ports[gpio_port].pull_ups, 5.31 - gpio_ports[gpio_port].pull_downs); 5.32 + gpio_chip = new Gpio_jz4780_chip(gpio_virt_base, gpio_port); 5.33 5.34 // Initialise the clocks for the SPI peripheral before obtaining the 5.35 // peripheral abstraction.
6.1 --- a/pkg/devices/lib/gpio/include/gpio-jz4730.h Sat Apr 27 23:46:28 2024 +0200 6.2 +++ b/pkg/devices/lib/gpio/include/gpio-jz4730.h Sun Apr 28 18:37:08 2024 +0200 6.3 @@ -2,7 +2,7 @@ 6.4 * GPIO driver for Ingenic JZ4730. 6.5 * (See below for additional copyright and licensing notices.) 6.6 * 6.7 - * Copyright (C) 2017, 2018, 2023 Paul Boddie <paul@boddie.org.uk> 6.8 + * Copyright (C) 2017, 2018, 2023, 2024 Paul Boddie <paul@boddie.org.uk> 6.9 * 6.10 * This program is free software; you can redistribute it and/or 6.11 * modify it under the terms of the GNU General Public License as 6.12 @@ -78,8 +78,9 @@ 6.13 private: 6.14 Hw::Register_block<32> _regs; 6.15 6.16 - l4_addr_t _start, _end; 6.17 + l4_addr_t _start; 6.18 unsigned _nr_pins; 6.19 + struct gpio_port *_pull_config; 6.20 6.21 // Convenience method for obtaining the bit corresponding to a pin. 6.22 6.23 @@ -123,8 +124,7 @@ 6.24 unsigned *value); 6.25 6.26 public: 6.27 - Gpio_jz4730_chip(l4_addr_t start, l4_addr_t end, 6.28 - unsigned nr_pins); 6.29 + Gpio_jz4730_chip(l4_addr_t start, uint8_t port_number); 6.30 6.31 // Obtain the number of pins. 6.32 6.33 @@ -172,7 +172,7 @@ 6.34 6.35 EXTERN_C_BEGIN 6.36 6.37 -void *jz4730_gpio_init(l4_addr_t start, l4_addr_t end, unsigned pins); 6.38 +void *jz4730_gpio_init(l4_addr_t start, uint8_t port_number); 6.39 6.40 void jz4730_gpio_setup(void *gpio, unsigned pin, unsigned mode, int value); 6.41 void jz4730_gpio_config_pull(void *gpio, unsigned pin, unsigned mode);
7.1 --- a/pkg/devices/lib/gpio/include/gpio-jz4740.h Sat Apr 27 23:46:28 2024 +0200 7.2 +++ b/pkg/devices/lib/gpio/include/gpio-jz4740.h Sun Apr 28 18:37:08 2024 +0200 7.3 @@ -70,8 +70,9 @@ 7.4 private: 7.5 Hw::Register_block<32> _regs; 7.6 7.7 - l4_addr_t _start, _end; 7.8 + l4_addr_t _start; 7.9 unsigned _nr_pins; 7.10 + struct gpio_port *_pull_config; 7.11 7.12 // Convenience method for obtaining the bit corresponding to a pin. 7.13 7.14 @@ -110,8 +111,7 @@ 7.15 void _config_pad(unsigned bitmap, unsigned func, unsigned value); 7.16 7.17 public: 7.18 - Gpio_jz4740_chip(l4_addr_t start, l4_addr_t end, 7.19 - unsigned nr_pins); 7.20 + Gpio_jz4740_chip(l4_addr_t start, uint8_t port_number); 7.21 7.22 // Obtain the number of pins. 7.23 7.24 @@ -159,7 +159,7 @@ 7.25 7.26 EXTERN_C_BEGIN 7.27 7.28 -void *jz4740_gpio_init(l4_addr_t start, l4_addr_t end, unsigned pins); 7.29 +void *jz4740_gpio_init(l4_addr_t start, uint8_t port_number); 7.30 7.31 void jz4740_gpio_setup(void *gpio, unsigned pin, unsigned mode, int value); 7.32 void jz4740_gpio_config_pull(void *gpio, unsigned pin, unsigned mode);
8.1 --- a/pkg/devices/lib/gpio/include/gpio-jz4780.h Sat Apr 27 23:46:28 2024 +0200 8.2 +++ b/pkg/devices/lib/gpio/include/gpio-jz4780.h Sun Apr 28 18:37:08 2024 +0200 8.3 @@ -70,9 +70,9 @@ 8.4 private: 8.5 Hw::Register_block<32> _regs; 8.6 8.7 - l4_addr_t _start, _end; 8.8 + l4_addr_t _start; 8.9 unsigned _nr_pins; 8.10 - l4_uint32_t _pull_ups, _pull_downs; 8.11 + struct gpio_port *_pull_config; 8.12 8.13 // Convenience method for obtaining the bit corresponding to a pin. 8.14 8.15 @@ -99,9 +99,7 @@ 8.16 } 8.17 8.18 public: 8.19 - Gpio_jz4780_chip(l4_addr_t start, l4_addr_t end, 8.20 - unsigned nr_pins, 8.21 - l4_uint32_t pull_ups, l4_uint32_t pull_downs); 8.22 + Gpio_jz4780_chip(l4_addr_t start, uint8_t port_number); 8.23 8.24 // Obtain the number of pins. 8.25 8.26 @@ -148,8 +146,7 @@ 8.27 8.28 EXTERN_C_BEGIN 8.29 8.30 -void *jz4780_gpio_init(l4_addr_t start, l4_addr_t end, unsigned pins, 8.31 - l4_uint32_t pull_ups, l4_uint32_t pull_downs); 8.32 +void *jz4780_gpio_init(l4_addr_t start, uint8_t port_number); 8.33 8.34 void jz4780_gpio_setup(void *gpio, unsigned pin, unsigned mode, int value); 8.35 void jz4780_gpio_config_pull(void *gpio, unsigned pin, unsigned mode);
9.1 --- a/pkg/devices/lib/gpio/include/gpio-x1600.h Sat Apr 27 23:46:28 2024 +0200 9.2 +++ b/pkg/devices/lib/gpio/include/gpio-x1600.h Sun Apr 28 18:37:08 2024 +0200 9.3 @@ -81,13 +81,13 @@ 9.4 9.5 Hw::Register_block<32> _regs, _shadow_regs; 9.6 9.7 - l4_addr_t _start, _end; 9.8 + l4_addr_t _start; 9.9 unsigned _nr_pins; 9.10 - l4_uint32_t _pull_ups, _pull_downs; 9.11 + struct gpio_port *_pull_config; 9.12 9.13 // Optional shadow port configuration. 9.14 9.15 - l4_addr_t _shadow_start, _shadow_end; 9.16 + l4_addr_t _shadow_start; 9.17 uint8_t _port_number; 9.18 bool _shadow; 9.19 9.20 @@ -118,11 +118,7 @@ 9.21 void write_reg_pin(unsigned reg, unsigned pin); 9.22 9.23 public: 9.24 - Gpio_x1600_chip(l4_addr_t start, l4_addr_t end, 9.25 - unsigned nr_pins, 9.26 - l4_uint32_t pull_ups, l4_uint32_t pull_downs, 9.27 - l4_addr_t shadow_start = 0, l4_addr_t shadow_end = 0, 9.28 - uint8_t port_number = 0); 9.29 + Gpio_x1600_chip(l4_addr_t start, uint8_t port_number, bool shadow = false); 9.30 9.31 // Obtain the number of pins. 9.32 9.33 @@ -169,13 +165,9 @@ 9.34 9.35 EXTERN_C_BEGIN 9.36 9.37 -void *x1600_gpio_init(l4_addr_t start, l4_addr_t end, unsigned pins, 9.38 - l4_uint32_t pull_ups, l4_uint32_t pull_downs); 9.39 +void *x1600_gpio_init(l4_addr_t start, uint8_t port_number); 9.40 9.41 -void *x1600_gpio_init_shadow(l4_addr_t start, l4_addr_t end, unsigned pins, 9.42 - l4_uint32_t pull_ups, l4_uint32_t pull_downs, 9.43 - l4_addr_t shadow_start, l4_addr_t shadow_end, 9.44 - uint8_t port_number); 9.45 +void *x1600_gpio_init_shadow(l4_addr_t start, uint8_t port_number); 9.46 9.47 void x1600_gpio_setup(void *gpio, unsigned pin, unsigned mode, int value); 9.48 void x1600_gpio_config_pull(void *gpio, unsigned pin, unsigned mode);
10.1 --- a/pkg/devices/lib/gpio/include/gpio.h Sat Apr 27 23:46:28 2024 +0200 10.2 +++ b/pkg/devices/lib/gpio/include/gpio.h Sun Apr 28 18:37:08 2024 +0200 10.3 @@ -2,7 +2,7 @@ 10.4 * GPIO driver definitions. 10.5 * (See below for additional copyright and licensing notices.) 10.6 * 10.7 - * Copyright (C) 2017, 2018, 2023 Paul Boddie <paul@boddie.org.uk> 10.8 + * Copyright (C) 2017, 2018, 2023, 2024 Paul Boddie <paul@boddie.org.uk> 10.9 * 10.10 * This program is free software; you can redistribute it and/or 10.11 * modify it under the terms of the GNU General Public License as 10.12 @@ -31,6 +31,12 @@ 10.13 #pragma once 10.14 10.15 #include <l4/vbus/vbus_gpio.h> 10.16 +#include <stdint.h> 10.17 + 10.18 +struct gpio_port 10.19 +{ 10.20 + uint32_t pull_ups, pull_downs; 10.21 +}; 10.22 10.23 typedef struct Pin_slice 10.24 {
11.1 --- a/pkg/devices/lib/gpio/src/jz4730.cc Sat Apr 27 23:46:28 2024 +0200 11.2 +++ b/pkg/devices/lib/gpio/src/jz4730.cc Sun Apr 28 18:37:08 2024 +0200 11.3 @@ -2,7 +2,7 @@ 11.4 * GPIO driver for Ingenic JZ4730. 11.5 * (See below for additional copyright and licensing notices.) 11.6 * 11.7 - * Copyright (C) 2017, 2018, 2023 Paul Boddie <paul@boddie.org.uk> 11.8 + * Copyright (C) 2017, 2018, 2023, 2024 Paul Boddie <paul@boddie.org.uk> 11.9 * 11.10 * This program is free software; you can redistribute it and/or 11.11 * modify it under the terms of the GNU General Public License as 11.12 @@ -52,6 +52,17 @@ 11.13 11.14 11.15 11.16 +// JZ4730 pull-up/down configuration. 11.17 + 11.18 +static struct gpio_port gpio_ports[] = { 11.19 + {0x3fa32e0f, 0x000001f0}, 11.20 + {0xf2000fff, 0x0dfff000}, 11.21 + {0xffffffff, 0x00000000}, 11.22 + {0xffffffff, 0x00000000}, 11.23 +}; 11.24 + 11.25 + 11.26 + 11.27 // Select the appropriate register and pin where two bits are assigned per pin, 11.28 // thus requiring two 32-bit registers to hold the configuration of 32 pins. 11.29 11.30 @@ -233,12 +244,12 @@ 11.31 11.32 // Initialise the GPIO controller. 11.33 11.34 -Gpio_jz4730_chip::Gpio_jz4730_chip(l4_addr_t start, l4_addr_t end, 11.35 - unsigned nr_pins) 11.36 -: _start(start), _end(end), 11.37 - _nr_pins(nr_pins) 11.38 +Gpio_jz4730_chip::Gpio_jz4730_chip(l4_addr_t start, uint8_t port_number) 11.39 +: _nr_pins(32) 11.40 { 11.41 + _start = start + port_number * 0x30; 11.42 _regs = new Hw::Mmio_register_block<32>(_start); 11.43 + _pull_config = &gpio_ports[port_number]; 11.44 } 11.45 11.46 // Return the value of a pin. 11.47 @@ -359,8 +370,11 @@ 11.48 case Pull_none: 11.49 _regs[Pull_enable] = _regs[Pull_enable] & ~bitmap; 11.50 break; 11.51 + case Pull_down: 11.52 + _regs[Pull_enable] = _regs[Pull_enable] | (bitmap & _pull_config->pull_downs); 11.53 + break; 11.54 case Pull_up: 11.55 - _regs[Pull_enable] = _regs[Pull_enable] | bitmap; 11.56 + _regs[Pull_enable] = _regs[Pull_enable] | (bitmap & _pull_config->pull_ups); 11.57 break; 11.58 default: 11.59 // Invalid pull-up/down mode for pin. 11.60 @@ -516,9 +530,9 @@ 11.61 11.62 // C language interface functions. 11.63 11.64 -void *jz4730_gpio_init(l4_addr_t start, l4_addr_t end, unsigned pins) 11.65 +void *jz4730_gpio_init(l4_addr_t start, uint8_t port_number) 11.66 { 11.67 - return (void *) new Gpio_jz4730_chip(start, end, pins); 11.68 + return (void *) new Gpio_jz4730_chip(start, port_number); 11.69 } 11.70 11.71 void jz4730_gpio_setup(void *gpio, unsigned pin, unsigned mode, int value)
12.1 --- a/pkg/devices/lib/gpio/src/jz4740.cc Sat Apr 27 23:46:28 2024 +0200 12.2 +++ b/pkg/devices/lib/gpio/src/jz4740.cc Sun Apr 28 18:37:08 2024 +0200 12.3 @@ -2,7 +2,7 @@ 12.4 * GPIO driver for Ingenic JZ4740. 12.5 * (See below for additional copyright and licensing notices.) 12.6 * 12.7 - * Copyright (C) 2017, 2018, 2023 Paul Boddie <paul@boddie.org.uk> 12.8 + * Copyright (C) 2017, 2018, 2023, 2024 Paul Boddie <paul@boddie.org.uk> 12.9 * 12.10 * This program is free software; you can redistribute it and/or 12.11 * modify it under the terms of the GNU General Public License as 12.12 @@ -66,6 +66,17 @@ 12.13 12.14 12.15 12.16 +// JZ4740 pull-up/down configuration. 12.17 + 12.18 +static struct gpio_port gpio_ports[] = { 12.19 + {0xffffffff, 0x00000000}, 12.20 + {0xffffffff, 0x00000000}, 12.21 + {0x7fffffff, 0x00000000}, 12.22 + {0xdeffffff, 0x00000000}, 12.23 +}; 12.24 + 12.25 + 12.26 + 12.27 // IRQ control for each GPIO pin. 12.28 12.29 Gpio_jz4740_irq_pin::Gpio_jz4740_irq_pin(unsigned pin, Hw::Register_block<32> const ®s) 12.30 @@ -166,12 +177,12 @@ 12.31 12.32 // Initialise the GPIO controller. 12.33 12.34 -Gpio_jz4740_chip::Gpio_jz4740_chip(l4_addr_t start, l4_addr_t end, 12.35 - unsigned nr_pins) 12.36 -: _start(start), _end(end), 12.37 - _nr_pins(nr_pins) 12.38 +Gpio_jz4740_chip::Gpio_jz4740_chip(l4_addr_t start, uint8_t port_number) 12.39 +: _nr_pins(32) 12.40 { 12.41 + _start = start + port_number * 0x100; 12.42 _regs = new Hw::Mmio_register_block<32>(_start); 12.43 + _pull_config = &gpio_ports[port_number]; 12.44 } 12.45 12.46 // Return the value of a pin. 12.47 @@ -285,8 +296,11 @@ 12.48 case Pull_none: 12.49 _regs[Pull_disable_set] = bitmap; 12.50 break; 12.51 + case Pull_down: 12.52 + _regs[Pull_disable_clear] = (bitmap & _pull_config->pull_downs); 12.53 + break; 12.54 case Pull_up: 12.55 - _regs[Pull_disable_clear] = bitmap; 12.56 + _regs[Pull_disable_clear] = (bitmap & _pull_config->pull_ups); 12.57 break; 12.58 default: 12.59 // Invalid pull-up/down mode for pin. 12.60 @@ -413,9 +427,9 @@ 12.61 12.62 // C language interface functions. 12.63 12.64 -void *jz4740_gpio_init(l4_addr_t start, l4_addr_t end, unsigned pins) 12.65 +void *jz4740_gpio_init(l4_addr_t start, uint8_t port_number) 12.66 { 12.67 - return (void *) new Gpio_jz4740_chip(start, end, pins); 12.68 + return (void *) new Gpio_jz4740_chip(start, port_number); 12.69 } 12.70 12.71 void jz4740_gpio_setup(void *gpio, unsigned pin, unsigned mode, int value)
13.1 --- a/pkg/devices/lib/gpio/src/jz4780.cc Sat Apr 27 23:46:28 2024 +0200 13.2 +++ b/pkg/devices/lib/gpio/src/jz4780.cc Sun Apr 28 18:37:08 2024 +0200 13.3 @@ -91,6 +91,19 @@ 13.4 13.5 13.6 13.7 +// JZ4780 pull-up/down configuration. 13.8 + 13.9 +static struct gpio_port gpio_ports[] = { 13.10 + {0x3fff00ff, 0x00000000}, 13.11 + {0xfff0f3fc, 0x000f0c03}, 13.12 + {0x0fffffff, 0x00000000}, 13.13 + {0xffff4fff, 0x0000b000}, 13.14 + {0xf0fff37c, 0x00000483}, 13.15 + {0x7fa7f00f, 0x00580ff0}, 13.16 +}; 13.17 + 13.18 + 13.19 + 13.20 // IRQ control for each GPIO pin. 13.21 13.22 Gpio_jz4780_irq_pin::Gpio_jz4780_irq_pin(unsigned pin, Hw::Register_block<32> const ®s) 13.23 @@ -187,14 +200,12 @@ 13.24 13.25 // Initialise the GPIO controller. 13.26 13.27 -Gpio_jz4780_chip::Gpio_jz4780_chip(l4_addr_t start, l4_addr_t end, 13.28 - unsigned nr_pins, 13.29 - l4_uint32_t pull_ups, l4_uint32_t pull_downs) 13.30 -: _start(start), _end(end), 13.31 - _nr_pins(nr_pins), 13.32 - _pull_ups(pull_ups), _pull_downs(pull_downs) 13.33 +Gpio_jz4780_chip::Gpio_jz4780_chip(l4_addr_t start, uint8_t port_number) 13.34 +: _nr_pins(32) 13.35 { 13.36 + _start = start + port_number * 0x100; 13.37 _regs = new Hw::Mmio_register_block<32>(_start); 13.38 + _pull_config = &gpio_ports[port_number]; 13.39 } 13.40 13.41 // Return the value of a pin. 13.42 @@ -296,12 +307,12 @@ 13.43 _regs[Pull_disable_set] = _pin_bit(pin); 13.44 break; 13.45 case Pull_down: 13.46 - if (_pin_bit(pin) & _pull_downs) 13.47 + if (_pin_bit(pin) & _pull_config->pull_downs) 13.48 _regs[Pull_disable_clear] = _pin_bit(pin); 13.49 break; 13.50 case Pull_up: 13.51 - if (_pin_bit(pin) & _pull_ups) 13.52 - _regs[Pull_disable_clear] = _pin_bit(pin); 13.53 + if (_pin_bit(pin) & _pull_config->pull_ups) 13.54 + _regs[Pull_disable_clear] = _pin_bit(pin); 13.55 break; 13.56 default: 13.57 // Invalid pull-up/down mode for pin. 13.58 @@ -430,10 +441,9 @@ 13.59 13.60 // C language interface functions. 13.61 13.62 -void *jz4780_gpio_init(l4_addr_t start, l4_addr_t end, unsigned pins, 13.63 - l4_uint32_t pull_ups, l4_uint32_t pull_downs) 13.64 +void *jz4780_gpio_init(l4_addr_t start, uint8_t port_number) 13.65 { 13.66 - return (void *) new Gpio_jz4780_chip(start, end, pins, pull_ups, pull_downs); 13.67 + return (void *) new Gpio_jz4780_chip(start, port_number); 13.68 } 13.69 13.70 void jz4780_gpio_setup(void *gpio, unsigned pin, unsigned mode, int value)
14.1 --- a/pkg/devices/lib/gpio/src/x1600.cc Sat Apr 27 23:46:28 2024 +0200 14.2 +++ b/pkg/devices/lib/gpio/src/x1600.cc Sun Apr 28 18:37:08 2024 +0200 14.3 @@ -104,6 +104,17 @@ 14.4 14.5 14.6 14.7 +// X1600 pull-up/down configuration. 14.8 + 14.9 +struct gpio_port gpio_ports[] = { 14.10 + {0xffffffff, 0x00000000}, 14.11 + {0xdffbf7bf, 0x00000000}, 14.12 + {0x987e0000, 0x07000007}, 14.13 + {0x0000003f, 0x00000000} 14.14 +}; 14.15 + 14.16 + 14.17 + 14.18 // IRQ control for each GPIO pin. 14.19 14.20 Gpio_x1600_irq_pin::Gpio_x1600_irq_pin(unsigned pin, Hw::Register_block<32> const ®s, 14.21 @@ -215,23 +226,18 @@ 14.22 14.23 // Initialise the GPIO controller. 14.24 14.25 -Gpio_x1600_chip::Gpio_x1600_chip(l4_addr_t start, l4_addr_t end, 14.26 - unsigned nr_pins, 14.27 - l4_uint32_t pull_ups, l4_uint32_t pull_downs, 14.28 - l4_addr_t shadow_start, l4_addr_t shadow_end, 14.29 - uint8_t port_number) 14.30 -: _start(start), _end(end), 14.31 - _nr_pins(nr_pins), 14.32 - _pull_ups(pull_ups), _pull_downs(pull_downs), 14.33 - _shadow_start(shadow_start), _shadow_end(shadow_end), 14.34 - _port_number(port_number) 14.35 +Gpio_x1600_chip::Gpio_x1600_chip(l4_addr_t start, uint8_t port_number, 14.36 + bool shadow) 14.37 +: _nr_pins(32), _port_number(port_number), _shadow(shadow) 14.38 { 14.39 + _start = start + port_number * 0x100; 14.40 _regs = new Hw::Mmio_register_block<32>(_start); 14.41 + _pull_config = &gpio_ports[port_number]; 14.42 14.43 - if (_shadow_start) 14.44 + if (_shadow) 14.45 { 14.46 + _shadow_start = start + 0x700; 14.47 _shadow_regs = new Hw::Mmio_register_block<32>(_shadow_start); 14.48 - _shadow = true; 14.49 } 14.50 else 14.51 _shadow = false; 14.52 @@ -351,11 +357,11 @@ 14.53 _regs[Pull_enable_clear] = _pin_bit(pin); 14.54 break; 14.55 case Pull_down: 14.56 - if (_pin_bit(pin) & _pull_downs) 14.57 + if (_pin_bit(pin) & _pull_config->pull_downs) 14.58 _regs[Pull_enable_set] = _pin_bit(pin); 14.59 break; 14.60 case Pull_up: 14.61 - if (_pin_bit(pin) & _pull_ups) 14.62 + if (_pin_bit(pin) & _pull_config->pull_ups) 14.63 _regs[Pull_enable_set] = _pin_bit(pin); 14.64 break; 14.65 default: 14.66 @@ -491,19 +497,14 @@ 14.67 14.68 // C language interface functions. 14.69 14.70 -void *x1600_gpio_init(l4_addr_t start, l4_addr_t end, unsigned pins, 14.71 - l4_uint32_t pull_ups, l4_uint32_t pull_downs) 14.72 +void *x1600_gpio_init(l4_addr_t start, uint8_t port_number) 14.73 { 14.74 - return (void *) new Gpio_x1600_chip(start, end, pins, pull_ups, pull_downs); 14.75 + return (void *) new Gpio_x1600_chip(start, port_number, false); 14.76 } 14.77 14.78 -void *x1600_gpio_init_shadow(l4_addr_t start, l4_addr_t end, unsigned pins, 14.79 - l4_uint32_t pull_ups, l4_uint32_t pull_downs, 14.80 - l4_addr_t shadow_start, l4_addr_t shadow_end, 14.81 - uint8_t port_number) 14.82 +void *x1600_gpio_init_shadow(l4_addr_t start, uint8_t port_number) 14.83 { 14.84 - return (void *) new Gpio_x1600_chip(start, end, pins, pull_ups, pull_downs, 14.85 - shadow_start, shadow_end, port_number); 14.86 + return (void *) new Gpio_x1600_chip(start, port_number, true); 14.87 } 14.88 14.89 void x1600_gpio_setup(void *gpio, unsigned pin, unsigned mode, int value)
15.1 --- a/pkg/devices/pwm/src/jz4730/pwm-jz4730.cc Sat Apr 27 23:46:28 2024 +0200 15.2 +++ b/pkg/devices/pwm/src/jz4730/pwm-jz4730.cc Sun Apr 28 18:37:08 2024 +0200 15.3 @@ -1,7 +1,7 @@ 15.4 /* 15.5 * Export a JZ4730 PWM peripheral as a server. 15.6 * 15.7 - * Copyright (C) 2018, 2020, 2023 Paul Boddie <paul@boddie.org.uk> 15.8 + * Copyright (C) 2018, 2020, 2023, 2024 Paul Boddie <paul@boddie.org.uk> 15.9 * 15.10 * This program is free software; you can redistribute it and/or 15.11 * modify it under the terms of the GNU General Public License as 15.12 @@ -124,8 +124,7 @@ 15.13 Pwm_jz4730_chip pwm_device(pwm_virt_base + number * 0x1000, 15.14 pwm_virt_base + (number + 1) * 0x1000); 15.15 15.16 - Gpio_jz4730_chip gpio_port_c(gpio_virt_base + 2 * 0x30, 15.17 - gpio_virt_base + 3 * 0x30, 32); 15.18 + Gpio_jz4730_chip gpio_port_c(gpio_virt_base, 2); 15.19 15.20 /* Enable the PWM output for PC30 or PC31. */ 15.21
16.1 --- a/pkg/devices/spi/src/jz4740/spi-jz4740.cc Sat Apr 27 23:46:28 2024 +0200 16.2 +++ b/pkg/devices/spi/src/jz4740/spi-jz4740.cc Sun Apr 28 18:37:08 2024 +0200 16.3 @@ -1,7 +1,7 @@ 16.4 /* 16.5 * Export JZ4740 GPIO pins as a SPI server. 16.6 * 16.7 - * Copyright (C) 2018, 2020, 2023 Paul Boddie <paul@boddie.org.uk> 16.8 + * Copyright (C) 2018, 2020, 2023, 2024 Paul Boddie <paul@boddie.org.uk> 16.9 * 16.10 * This program is free software; you can redistribute it and/or 16.11 * modify it under the terms of the GNU General Public License as 16.12 @@ -141,22 +141,19 @@ 16.13 16.14 /* Configure the clock pin. */ 16.15 16.16 - Gpio_jz4740_chip gpio_port_clock(gpio_virt_base + clock_port * 0x100, 16.17 - gpio_virt_base + (clock_port + 1) * 0x100, 32); 16.18 + Gpio_jz4740_chip gpio_port_clock(gpio_virt_base, clock_port); 16.19 16.20 gpio_port_clock.setup(clock_pin, Hw::Gpio_chip::Output, 0); 16.21 16.22 /* Configure the data pin. */ 16.23 16.24 - Gpio_jz4740_chip gpio_port_data(gpio_virt_base + data_port * 0x100, 16.25 - gpio_virt_base + (data_port + 1) * 0x100, 32); 16.26 + Gpio_jz4740_chip gpio_port_data(gpio_virt_base, data_port); 16.27 16.28 gpio_port_data.setup(data_pin, Hw::Gpio_chip::Output, 0); 16.29 16.30 /* Configure the enable pin. */ 16.31 16.32 - Gpio_jz4740_chip gpio_port_enable(gpio_virt_base + enable_port * 0x100, 16.33 - gpio_virt_base + (enable_port + 1) * 0x100, 32); 16.34 + Gpio_jz4740_chip gpio_port_enable(gpio_virt_base, enable_port); 16.35 16.36 gpio_port_enable.setup(enable_pin, Hw::Gpio_chip::Output, 0); 16.37
17.1 --- a/pkg/landfall-examples/ci20_hdmi_i2c/ci20_hdmi_i2c.c Sat Apr 27 23:46:28 2024 +0200 17.2 +++ b/pkg/landfall-examples/ci20_hdmi_i2c/ci20_hdmi_i2c.c Sun Apr 28 18:37:08 2024 +0200 17.3 @@ -1,7 +1,7 @@ 17.4 /* 17.5 * Access the HDMI I2C peripheral on the MIPS Creator CI20 board. 17.6 * 17.7 - * Copyright (C) 2020, 2021, 2023 Paul Boddie <paul@boddie.org.uk> 17.8 + * Copyright (C) 2020, 2021, 2023, 2024 Paul Boddie <paul@boddie.org.uk> 17.9 * 17.10 * This program is free software; you can redistribute it and/or 17.11 * modify it under the terms of the GNU General Public License as 17.12 @@ -138,7 +138,6 @@ 17.13 l4_addr_t gpio_base = 0, gpio_base_end = 0; 17.14 l4_addr_t hdmi_base = 0, hdmi_base_end = 0; 17.15 l4_addr_t lcd_base = 0, lcd_base_end = 0; 17.16 - l4_addr_t port_f, port_f_end; 17.17 17.18 /* Peripheral abstractions. */ 17.19 17.20 @@ -284,12 +283,9 @@ 17.21 17.22 /* Configure pins. */ 17.23 17.24 - port_f = gpio_base + 0x500; 17.25 - port_f_end = port_f + 0x100; 17.26 + printf("PORTF at 0x%lx...0x%lx.\n", gpio_base + 0x500, gpio_base + 0x600); 17.27 17.28 - printf("PORTF at 0x%lx...0x%lx.\n", port_f, port_f_end); 17.29 - 17.30 - gpio_port_f = jz4780_gpio_init(port_f, port_f_end, 32, 0x7fa7f00f, 0x00580ff0); 17.31 + gpio_port_f = jz4780_gpio_init(gpio_base, 5); 17.32 17.33 printf("Set up GPIO pins...\n"); 17.34
18.1 --- a/pkg/landfall-examples/ci20_i2c/ci20_i2c.c Sat Apr 27 23:46:28 2024 +0200 18.2 +++ b/pkg/landfall-examples/ci20_i2c/ci20_i2c.c Sun Apr 28 18:37:08 2024 +0200 18.3 @@ -1,7 +1,8 @@ 18.4 /* 18.5 * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de> 18.6 * economic rights: Technische Universität Dresden (Germany) 18.7 - * Copyright (C) 2017, 2018, 2019, 2020, 2023 Paul Boddie <paul@boddie.org.uk> 18.8 + * Copyright (C) 2017, 2018, 2019, 2020, 2023, 18.9 + * 2024 Paul Boddie <paul@boddie.org.uk> 18.10 * 18.11 * This file is part of TUD:OS and distributed under the terms of the 18.12 * GNU General Public License 2. 18.13 @@ -264,8 +265,6 @@ 18.14 l4_addr_t i2c_base = 0, i2c_base_end = 0; 18.15 l4_addr_t cpm_base = 0, cpm_base_end = 0; 18.16 l4_addr_t rtc_base = 0, rtc_base_end = 0; 18.17 - l4_addr_t port_d, port_d_end; 18.18 - l4_addr_t port_e, port_e_end; 18.19 18.20 /* Peripheral abstractions. */ 18.21 18.22 @@ -379,16 +378,11 @@ 18.23 18.24 /* Configure pins. */ 18.25 18.26 - port_d = gpio_base + 0x300; 18.27 - port_d_end = port_d + 0x100; 18.28 - port_e = gpio_base + 0x400; 18.29 - port_e_end = port_e + 0x100; 18.30 + printf("PORTD at 0x%lx...0x%lx.\n", gpio_base + 0x300, gpio_base + 0x400); 18.31 + printf("PORTE at 0x%lx...0x%lx.\n", gpio_base + 0x400, gpio_base + 0x500); 18.32 18.33 - printf("PORTD at 0x%lx...0x%lx.\n", port_d, port_d_end); 18.34 - printf("PORTE at 0x%lx...0x%lx.\n", port_e, port_e_end); 18.35 - 18.36 - gpio_port_d = jz4780_gpio_init(port_d, port_d_end, 32, 0xffff4fff, 0x0000b000); 18.37 - gpio_port_e = jz4780_gpio_init(port_e, port_e_end, 32, 0xfffff37c, 0x00000483); 18.38 + gpio_port_d = jz4780_gpio_init(gpio_base, 3); 18.39 + gpio_port_e = jz4780_gpio_init(gpio_base, 4); 18.40 18.41 printf("Set up GPIO pins...\n"); 18.42
19.1 --- a/pkg/landfall-examples/ci20_leds/ci20_leds.c Sat Apr 27 23:46:28 2024 +0200 19.2 +++ b/pkg/landfall-examples/ci20_leds/ci20_leds.c Sun Apr 28 18:37:08 2024 +0200 19.3 @@ -1,7 +1,7 @@ 19.4 /* 19.5 * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de> 19.6 * economic rights: Technische Universität Dresden (Germany) 19.7 - * Copyright (C) 2017, 2018, 2023 Paul Boddie <paul@boddie.org.uk> 19.8 + * Copyright (C) 2017, 2018, 2023, 2024 Paul Boddie <paul@boddie.org.uk> 19.9 * 19.10 * This file is part of TUD:OS and distributed under the terms of the 19.11 * GNU General Public License 2. 19.12 @@ -153,7 +153,7 @@ 19.13 19.14 int main(void) 19.15 { 19.16 - l4_addr_t gpio_base = 0, gpio_base_end = 0, port_d, port_d_end, port_f, port_f_end; 19.17 + l4_addr_t gpio_base = 0, gpio_base_end = 0; 19.18 l4_uint32_t gpio_irq_start = 0, gpio_irq_end = 0, gpio_irq; 19.19 l4_cap_idx_t irqcap, icucap; 19.20 l4_msgtag_t tag; 19.21 @@ -195,17 +195,12 @@ 19.22 if ((result = gpio_get_memory("jz4780-gpio", &gpio_base, &gpio_base_end)) < 0) 19.23 return 1; 19.24 19.25 - port_d = gpio_base + 0x300; 19.26 - port_d_end = port_d + 0x100; 19.27 - port_f = gpio_base + 0x500; 19.28 - port_f_end = port_f + 0x100; 19.29 + printf("GPIO at 0x%lx...0x%lx.\n", gpio_base, gpio_base_end); 19.30 + printf("PORTD at 0x%lx...0x%lx.\n", gpio_base + 0x300, gpio_base + 0x400); 19.31 + printf("PORTF at 0x%lx...0x%lx.\n", gpio_base + 0x500, gpio_base + 0x600); 19.32 19.33 - printf("GPIO at 0x%lx...0x%lx.\n", gpio_base, gpio_base_end); 19.34 - printf("PORTD at 0x%lx...0x%lx.\n", port_d, port_d_end); 19.35 - printf("PORTF at 0x%lx...0x%lx.\n", port_f, port_f_end); 19.36 - 19.37 - gpio_port_d = jz4780_gpio_init(port_d, port_d_end, 32, 0xffff4fff, 0x0000b000); 19.38 - gpio_port_f = jz4780_gpio_init(port_f, port_f_end, 32, 0xffa7f00f, 0x00580ff0); 19.39 + gpio_port_d = jz4780_gpio_init(gpio_base, 3); 19.40 + gpio_port_f = jz4780_gpio_init(gpio_base, 5); 19.41 19.42 /* Create an interrupt object. */ 19.43
20.1 --- a/pkg/landfall-examples/hw_info/common.h Sat Apr 27 23:46:28 2024 +0200 20.2 +++ b/pkg/landfall-examples/hw_info/common.h Sun Apr 28 18:37:08 2024 +0200 20.3 @@ -101,13 +101,9 @@ 20.4 20.5 /* GPIO adapter functions. */ 20.6 20.7 -void *gpio_init(l4_addr_t start, l4_addr_t end, unsigned pins, 20.8 - l4_uint32_t pull_ups, l4_uint32_t pull_downs); 20.9 +void *gpio_init(l4_addr_t start, uint8_t port_number); 20.10 20.11 -void *gpio_init_shadow(l4_addr_t start, l4_addr_t end, unsigned pins, 20.12 - l4_uint32_t pull_ups, l4_uint32_t pull_downs, 20.13 - l4_addr_t shadow_start, l4_addr_t shadow_end, 20.14 - uint8_t port_number); 20.15 +void *gpio_init_shadow(l4_addr_t start, uint8_t port_number); 20.16 20.17 void gpio_setup(void *gpio, unsigned pin, unsigned mode, int value); 20.18 20.19 @@ -316,15 +312,6 @@ 20.20 20.21 20.22 20.23 -/* GPIO definitions. */ 20.24 - 20.25 -struct gpio_port 20.26 -{ 20.27 - const uint32_t pull_ups, pull_downs; 20.28 -}; 20.29 - 20.30 - 20.31 - 20.32 /* Memory definitions. */ 20.33 20.34 struct memory_region
21.1 --- a/pkg/landfall-examples/hw_info/defs.h Sat Apr 27 23:46:28 2024 +0200 21.2 +++ b/pkg/landfall-examples/hw_info/defs.h Sun Apr 28 18:37:08 2024 +0200 21.3 @@ -65,8 +65,6 @@ 21.4 21.5 extern const unsigned int num_gpio_ports; 21.6 21.7 -extern struct gpio_port gpio_ports[]; 21.8 - 21.9 extern const char gpio_port_labels[]; 21.10 21.11
22.1 --- a/pkg/landfall-examples/hw_info/hw_info.c Sat Apr 27 23:46:28 2024 +0200 22.2 +++ b/pkg/landfall-examples/hw_info/hw_info.c Sun Apr 28 18:37:08 2024 +0200 22.3 @@ -2006,11 +2006,7 @@ 22.4 printf("GPIO at 0x%lx...0x%lx.\n", gpio_base, gpio_base_end); 22.5 22.6 for (port = 0; port < num_gpio_ports; port++) 22.7 - gpio[port] = gpio_init_shadow(gpio_base + port * 0x100, gpio_base + (port + 1) * 0x100, 22.8 - 32, 22.9 - gpio_ports[port].pull_ups, gpio_ports[port].pull_downs, 22.10 - gpio_base + 0x700, gpio_base + 0x800, 22.11 - port); 22.12 + gpio[port] = gpio_init_shadow(gpio_base, port); 22.13 22.14 printf("Access I2C...\n"); 22.15
23.1 --- a/pkg/landfall-examples/hw_info/jz4780.c Sat Apr 27 23:46:28 2024 +0200 23.2 +++ b/pkg/landfall-examples/hw_info/jz4780.c Sun Apr 28 18:37:08 2024 +0200 23.3 @@ -187,19 +187,14 @@ 23.4 23.5 /* GPIO adapter functions. */ 23.6 23.7 -void *gpio_init(l4_addr_t start, l4_addr_t end, unsigned pins, 23.8 - l4_uint32_t pull_ups, l4_uint32_t pull_downs) 23.9 +void *gpio_init(l4_addr_t start, uint8_t port_number) 23.10 { 23.11 - return jz4780_gpio_init(start, end, pins, pull_ups, pull_downs); 23.12 + return jz4780_gpio_init(start, port_number); 23.13 } 23.14 23.15 -void *gpio_init_shadow(l4_addr_t start, l4_addr_t end, unsigned pins, 23.16 - l4_uint32_t pull_ups, l4_uint32_t pull_downs, 23.17 - l4_addr_t shadow_start, l4_addr_t shadow_end, 23.18 - uint8_t port_number) 23.19 +void *gpio_init_shadow(l4_addr_t start, uint8_t port_number) 23.20 { 23.21 - (void) shadow_start; (void) shadow_end; (void) port_number; 23.22 - return jz4780_gpio_init(start, end, pins, pull_ups, pull_downs); 23.23 + return jz4780_gpio_init(start, port_number); 23.24 } 23.25 23.26 void gpio_setup(void *gpio, unsigned pin, unsigned mode, int value) 23.27 @@ -722,15 +717,6 @@ 23.28 23.29 /* GPIO definitions. */ 23.30 23.31 -struct gpio_port gpio_ports[] = { 23.32 - {0x3fff00ff, 0x00000000}, 23.33 - {0xfff0f3fc, 0x000f0c03}, 23.34 - {0x0fffffff, 0x00000000}, 23.35 - {0xffff4fff, 0x0000b000}, 23.36 - {0xf0fff37c, 0x00000483}, 23.37 - {0x7fa7f00f, 0x00580ff0}, 23.38 -}; 23.39 - 23.40 const unsigned int num_gpio_ports = 6; 23.41 23.42 const char gpio_port_labels[] = "ABCDEF";
24.1 --- a/pkg/landfall-examples/hw_info/x1600.c Sat Apr 27 23:46:28 2024 +0200 24.2 +++ b/pkg/landfall-examples/hw_info/x1600.c Sun Apr 28 18:37:08 2024 +0200 24.3 @@ -176,19 +176,14 @@ 24.4 24.5 /* GPIO adapter functions. */ 24.6 24.7 -void *gpio_init(l4_addr_t start, l4_addr_t end, unsigned pins, 24.8 - l4_uint32_t pull_ups, l4_uint32_t pull_downs) 24.9 +void *gpio_init(l4_addr_t start, uint8_t port_number) 24.10 { 24.11 - return x1600_gpio_init(start, end, pins, pull_ups, pull_downs); 24.12 + return x1600_gpio_init(start, port_number); 24.13 } 24.14 24.15 -void *gpio_init_shadow(l4_addr_t start, l4_addr_t end, unsigned pins, 24.16 - l4_uint32_t pull_ups, l4_uint32_t pull_downs, 24.17 - l4_addr_t shadow_start, l4_addr_t shadow_end, 24.18 - uint8_t port_number) 24.19 +void *gpio_init_shadow(l4_addr_t start, uint8_t port_number) 24.20 { 24.21 - return x1600_gpio_init_shadow(start, end, pins, pull_ups, pull_downs, 24.22 - shadow_start, shadow_end, port_number); 24.23 + return x1600_gpio_init_shadow(start, port_number); 24.24 } 24.25 24.26 void gpio_setup(void *gpio, unsigned pin, unsigned mode, int value) 24.27 @@ -696,13 +691,6 @@ 24.28 24.29 /* GPIO definitions. */ 24.30 24.31 -struct gpio_port gpio_ports[] = { 24.32 - {0xffffffff, 0x00000000}, 24.33 - {0xdffbf7bf, 0x00000000}, 24.34 - {0x987e0000, 0x07000007}, 24.35 - {0x0000003f, 0x00000000} 24.36 -}; 24.37 - 24.38 const unsigned int num_gpio_ports = 4; 24.39 24.40 const char gpio_port_labels[] = "ABCD";
25.1 --- a/pkg/landfall-examples/letux400_keypad/letux400_keypad.c Sat Apr 27 23:46:28 2024 +0200 25.2 +++ b/pkg/landfall-examples/letux400_keypad/letux400_keypad.c Sun Apr 28 18:37:08 2024 +0200 25.3 @@ -1,7 +1,7 @@ 25.4 /* 25.5 * Access the keypad GPIOs on the Letux 400 notebook computer. 25.6 * 25.7 - * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 25.8 + * Copyright (C) 2018, 2024 Paul Boddie <paul@boddie.org.uk> 25.9 * 25.10 * This program is free software; you can redistribute it and/or 25.11 * modify it under the terms of the GNU General Public License as 25.12 @@ -190,8 +190,8 @@ 25.13 if (!(fb = l4re_util_video_goos_fb_attach_buffer(&gfb))) 25.14 return 1; 25.15 25.16 - gpio_port_a = jz4730_gpio_init(gpio_virt_base, gpio_virt_base + 0x30, 32); 25.17 - gpio_port_d = jz4730_gpio_init(gpio_virt_base + 0x90, gpio_virt_base + 0xc0, 32); 25.18 + gpio_port_a = jz4730_gpio_init(gpio_virt_base, 0); 25.19 + gpio_port_d = jz4730_gpio_init(gpio_virt_base, 3); 25.20 25.21 init_keyscan(); 25.22
26.1 --- a/pkg/landfall-examples/letux400_leds/letux400_leds.c Sat Apr 27 23:46:28 2024 +0200 26.2 +++ b/pkg/landfall-examples/letux400_leds/letux400_leds.c Sun Apr 28 18:37:08 2024 +0200 26.3 @@ -6,7 +6,7 @@ 26.4 * PC22 - Num Lock 26.5 * PC30 - PWM backlight 26.6 * 26.7 - * Copyright (C) 2017, 2018 Paul Boddie <paul@boddie.org.uk> 26.8 + * Copyright (C) 2017, 2018, 2024 Paul Boddie <paul@boddie.org.uk> 26.9 * 26.10 * This program is free software; you can redistribute it and/or 26.11 * modify it under the terms of the GNU General Public License as 26.12 @@ -133,7 +133,7 @@ 26.13 26.14 int main(void) 26.15 { 26.16 - l4_addr_t gpio_base = 0, gpio_base_end = 0, port_a, port_a_end, port_c, port_c_end; 26.17 + l4_addr_t gpio_base = 0, gpio_base_end = 0; 26.18 l4_addr_t pwm_base = 0, pwm_base_end = 0; 26.19 void *gpio_port_a, *gpio_port_c, *pwm0_device; 26.20 int result = 0; 26.21 @@ -146,17 +146,12 @@ 26.22 if ((result = get_memory("jz4730-gpio", &gpio_base, &gpio_base_end)) < 0) 26.23 return 1; 26.24 26.25 - port_a = gpio_base; 26.26 - port_a_end = port_a + 0x30; 26.27 - port_c = gpio_base + 0x60; 26.28 - port_c_end = port_c + 0x30; 26.29 + printf("GPIO at 0x%lx...0x%lx.\n", gpio_base, gpio_base_end); 26.30 + printf("PORTA at 0x%lx...0x%lx.\n", gpio_base, gpio_base + 0x30); 26.31 + printf("PORTC at 0x%lx...0x%lx.\n", gpio_base + 0x60, gpio_base + 0x90); 26.32 26.33 - printf("GPIO at 0x%lx...0x%lx.\n", gpio_base, gpio_base_end); 26.34 - printf("PORTA at 0x%lx...0x%lx.\n", port_a, port_a_end); 26.35 - printf("PORTC at 0x%lx...0x%lx.\n", port_c, port_c_end); 26.36 - 26.37 - gpio_port_a = jz4730_gpio_init(port_a, port_a_end, 32); 26.38 - gpio_port_c = jz4730_gpio_init(port_c, port_c_end, 32); 26.39 + gpio_port_a = jz4730_gpio_init(gpio_base, 0); 26.40 + gpio_port_c = jz4730_gpio_init(gpio_base, 2); 26.41 26.42 printf("Access PWM...\n"); 26.43
27.1 --- a/pkg/landfall-examples/qi_lb60_keypad/qi_lb60_keypad.c Sat Apr 27 23:46:28 2024 +0200 27.2 +++ b/pkg/landfall-examples/qi_lb60_keypad/qi_lb60_keypad.c Sun Apr 28 18:37:08 2024 +0200 27.3 @@ -1,7 +1,7 @@ 27.4 /* 27.5 * Access the keypad GPIOs on the Ben NanoNote. 27.6 * 27.7 - * Copyright (C) 2018 Paul Boddie <paul@boddie.org.uk> 27.8 + * Copyright (C) 2018, 2024 Paul Boddie <paul@boddie.org.uk> 27.9 * 27.10 * This program is free software; you can redistribute it and/or 27.11 * modify it under the terms of the GNU General Public License as 27.12 @@ -187,8 +187,8 @@ 27.13 if (!(fb = l4re_util_video_goos_fb_attach_buffer(&gfb))) 27.14 return 1; 27.15 27.16 - gpio_port_c = jz4740_gpio_init(gpio_virt_base + 0x200, gpio_virt_base + 0x300, 32); 27.17 - gpio_port_d = jz4740_gpio_init(gpio_virt_base + 0x300, gpio_virt_base + 0x400, 32); 27.18 + gpio_port_c = jz4740_gpio_init(gpio_virt_base, 2); 27.19 + gpio_port_d = jz4740_gpio_init(gpio_virt_base, 3); 27.20 27.21 init_keyscan(); 27.22