1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/conf/landfall-examples/mips-ci20-spi-spectrum.cfg Fri Apr 19 16:27:55 2024 +0200 1.3 @@ -0,0 +1,62 @@ 1.4 +-- vim: ft=lua ts=2 et sw=2 1.5 + 1.6 +-- Start Mag to multiplex the framebuffer showing only a single program. 1.7 +-- This example shows an animation showing off a spectrum of colours. 1.8 +-- The target platform is the MIPS Creator CI20. 1.9 + 1.10 +local L4 = require("L4"); 1.11 + 1.12 +local l = L4.default_loader; 1.13 + 1.14 +-- Define general access to peripherals. 1.15 + 1.16 +local io_buses = { 1.17 + common = l:new_channel(); 1.18 + }; 1.19 + 1.20 +l:start({ 1.21 + caps = { 1.22 + common = io_buses.common:svr(), 1.23 + icu = L4.Env.icu, 1.24 + sigma0 = L4.cast(L4.Proto.Factory, L4.Env.sigma0):create(L4.Proto.Sigma0), 1.25 + }, 1.26 + }, 1.27 + "rom/io rom/hw_devices.io rom/mips-ci20-common.io"); 1.28 + 1.29 +-- Expose a framebuffer device. 1.30 + 1.31 +local fbdrv_fb = l:new_channel(); 1.32 + 1.33 +l:start({ 1.34 + caps = { 1.35 + vbus = io_buses.common, 1.36 + fb = fbdrv_fb:svr(), 1.37 + }, 1.38 + }, 1.39 + "rom/fb-drv"); 1.40 + 1.41 +-- Multiplex the framebuffer. 1.42 + 1.43 +local mag_caps = { 1.44 + mag = l:new_channel(), 1.45 + svc = l:new_channel(), 1.46 + }; 1.47 + 1.48 +l:start({ 1.49 + caps = { 1.50 + vbus = io_buses.common, -- needed by input driver 1.51 + fb = fbdrv_fb, 1.52 + mag = mag_caps.mag:svr(), 1.53 + svc = mag_caps.svc:svr(), 1.54 + }, 1.55 + }, 1.56 + "rom/mag"); 1.57 + 1.58 +-- Show the spectrum example. 1.59 + 1.60 +l:start({ 1.61 + caps = { 1.62 + fb = mag_caps.svc:create(L4.Proto.Goos, "g=240x240+0+0", "barheight=10"), 1.63 + }, 1.64 + }, 1.65 + "rom/ex_fb_spectrum_cc");
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/conf/landfall-examples/mips-ci20-spi-spectrum.list Fri Apr 19 16:27:55 2024 +0200 2.3 @@ -0,0 +1,16 @@ 2.4 + 2.5 +modaddr 0x1100000 2.6 + 2.7 +entry mips-ci20-spi-spectrum-example 2.8 +bootstrap bootstrap -serial 2.9 +kernel fiasco -serial_esc 2.10 +roottask moe rom/mips-ci20-spi-spectrum.cfg 2.11 +module mips-ci20-spi-spectrum.cfg 2.12 +module mips-ci20-common.io 2.13 +module plat-ingenic-jz4780/hw_devices.io 2.14 +module l4re 2.15 +module io 2.16 +module ned 2.17 +module fb-drv 2.18 +module mag 2.19 +module ex_fb_spectrum_cc
3.1 --- a/pkg/devices/Control Fri Apr 19 16:25:48 2024 +0200 3.2 +++ b/pkg/devices/Control Fri Apr 19 16:27:55 2024 +0200 3.3 @@ -20,6 +20,7 @@ 3.4 provides: libdevice-keypad-server 3.5 provides: libdevice-lcd 3.6 provides: libdevice-lcd-jz4740 3.7 +provides: libdevice-lcd-jz4780-spi 3.8 provides: libdevice-util 3.9 provides: libdrivers-aic 3.10 provides: libdrivers-common
4.1 --- a/pkg/devices/lcd/include/lcd-device.h Fri Apr 19 16:25:48 2024 +0200 4.2 +++ b/pkg/devices/lcd/include/lcd-device.h Fri Apr 19 16:27:55 2024 +0200 4.3 @@ -38,10 +38,6 @@ 4.4 class Lcd_device 4.5 { 4.6 protected: 4.7 - /* LCD peripheral abstraction. */ 4.8 - 4.9 - Lcd_chip *_chip; 4.10 - 4.11 /* Display server abstraction. */ 4.12 4.13 Activation *_display; 4.14 @@ -59,8 +55,8 @@ 4.15 public: 4.16 /* Initialise a device with a controller and display object reference. */ 4.17 4.18 - Lcd_device(Lcd_chip *chip, Activation *display) 4.19 - : _chip(chip), _display(display) 4.20 + Lcd_device(Activation *display) 4.21 + : _display(display) 4.22 { 4.23 /* Subclasses must set up any memory. */ 4.24
5.1 --- a/pkg/devices/lcd/include/lcd-jz4740-device.h Fri Apr 19 16:25:48 2024 +0200 5.2 +++ b/pkg/devices/lcd/include/lcd-jz4740-device.h Fri Apr 19 16:27:55 2024 +0200 5.3 @@ -42,6 +42,10 @@ 5.4 5.5 struct dma_region _desc_region; 5.6 5.7 + /* LCD peripheral abstraction. */ 5.8 + 5.9 + Lcd_chip *_chip; 5.10 + 5.11 protected: 5.12 /* Device-specific memory allocation. */ 5.13 5.14 @@ -51,7 +55,7 @@ 5.15 /* Inherit constructor. */ 5.16 5.17 Lcd_jz4740_device(Lcd_chip *chip, Activation *display) 5.18 - : Lcd_device(chip, display) 5.19 + : Lcd_device(display), _chip(chip) 5.20 { 5.21 _setup_memory(); 5.22 }
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 6.2 +++ b/pkg/devices/lcd/include/lcd-jz4780-spi-device.h Fri Apr 19 16:27:55 2024 +0200 6.3 @@ -0,0 +1,71 @@ 6.4 +/* 6.5 + * LCD device support for the JZ4740 and related SoCs. 6.6 + * 6.7 + * Copyright (C) 2018, 2023 Paul Boddie <paul@boddie.org.uk> 6.8 + * 6.9 + * This program is free software; you can redistribute it and/or 6.10 + * modify it under the terms of the GNU General Public License as 6.11 + * published by the Free Software Foundation; either version 2 of 6.12 + * the License, or (at your option) any later version. 6.13 + * 6.14 + * This program is distributed in the hope that it will be useful, 6.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 6.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 6.17 + * GNU General Public License for more details. 6.18 + * 6.19 + * You should have received a copy of the GNU General Public License 6.20 + * along with this program; if not, write to the Free Software 6.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, 6.22 + * Boston, MA 02110-1301, USA 6.23 + */ 6.24 + 6.25 +#pragma once 6.26 + 6.27 +#include <l4/devices/lcd.h> 6.28 +#include <l4/devices/lcd-device.h> 6.29 + 6.30 +#include <l4/re/c/dma_space.h> 6.31 +#include <l4/re/c/video/view.h> 6.32 +#include <l4/sys/types.h> 6.33 + 6.34 + 6.35 + 6.36 +/* C++ language interface. */ 6.37 + 6.38 +#ifdef __cplusplus 6.39 + 6.40 +/* Support for specific JZ4780-based devices. */ 6.41 + 6.42 +class Lcd_jz4780_spi_device : public Lcd_device 6.43 +{ 6.44 + /* DMA region providing the DMA descriptor virtual and physical addresses. */ 6.45 + 6.46 + struct dma_region _desc_region; 6.47 + 6.48 +protected: 6.49 + /* Device-specific memory allocation. */ 6.50 + 6.51 + int _setup_memory(); 6.52 + 6.53 +public: 6.54 + Lcd_jz4780_spi_device(Activation *display) 6.55 + : Lcd_device(display) 6.56 + { 6.57 + _setup_memory(); 6.58 + } 6.59 + 6.60 + /* Device operations. */ 6.61 + 6.62 + void disable(); 6.63 + void enable(); 6.64 + 6.65 + l4_size_t get_framebuffer_size(); 6.66 + 6.67 + void get_view_info(l4re_video_view_info_t *view_info); 6.68 + 6.69 + /* Common device instance. */ 6.70 + 6.71 + static Lcd_jz4780_spi_device *device; 6.72 +}; 6.73 + 6.74 +#endif
7.1 --- a/pkg/devices/lcd/src/Makefile Fri Apr 19 16:25:48 2024 +0200 7.2 +++ b/pkg/devices/lcd/src/Makefile Fri Apr 19 16:27:55 2024 +0200 7.3 @@ -1,8 +1,9 @@ 7.4 PKGDIR ?= ../.. 7.5 L4DIR ?= $(PKGDIR)/../.. 7.6 7.7 -TARGET := common jz4740 7.8 +TARGET := common jz4740 jz4780 7.9 7.10 include $(L4DIR)/mk/subdir.mk 7.11 7.12 jz4740: common 7.13 +jz4780: common
8.1 --- a/pkg/devices/lcd/src/common/lcd-device.cc Fri Apr 19 16:25:48 2024 +0200 8.2 +++ b/pkg/devices/lcd/src/common/lcd-device.cc Fri Apr 19 16:27:55 2024 +0200 8.3 @@ -27,12 +27,14 @@ 8.4 8.5 void Lcd_device::disable_display() 8.6 { 8.7 - _display->disable(); 8.8 + if (_display != NULL) 8.9 + _display->disable(); 8.10 } 8.11 8.12 void Lcd_device::enable_display() 8.13 { 8.14 - _display->enable(); 8.15 + if (_display != NULL) 8.16 + _display->enable(); 8.17 } 8.18 8.19
9.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 9.2 +++ b/pkg/devices/lcd/src/jz4780/Makefile Fri Apr 19 16:27:55 2024 +0200 9.3 @@ -0,0 +1,41 @@ 9.4 +PKGDIR ?= ../../.. 9.5 +L4DIR ?= $(PKGDIR)/../.. 9.6 + 9.7 +TARGET = liblcd_dev_jz4780.o.a liblcd_dev_jz4780.o.so 9.8 +PC_FILENAME = libdevice-lcd-jz4780-spi 9.9 + 9.10 +# Locations for interface input and generated output. 9.11 + 9.12 +IDL_DIR = $(PKGDIR)/idl 9.13 +IDL_MK_DIR = $(L4DIR)/idl4re/mk 9.14 +IDL_BUILD_DIR = . 9.15 +IDL_EXPORT_DIR = $(OBJ_BASE)/include/l4/devices/lcd 9.16 + 9.17 +include $(IDL_MK_DIR)/idl.mk 9.18 + 9.19 +# Individual interfaces. 9.20 + 9.21 +CLIENT_INTERFACES_CC = activation 9.22 + 9.23 +# Generated and plain source files. 9.24 + 9.25 +CLIENT_INTERFACES_SRC_CC = $(call interfaces_to_client_cc,$(CLIENT_INTERFACES_CC)) 9.26 + 9.27 +PLAIN_SRC_CC = lcd-jz4780-spi-device.cc 9.28 + 9.29 +# Normal definitions. 9.30 + 9.31 +SRC_CC = $(CLIENT_INTERFACES_SRC_CC) $(PLAIN_SRC_CC) 9.32 + 9.33 +REQUIRES_LIBS = \ 9.34 + l4re_c l4re_c-util \ 9.35 + libdevice-lcd \ 9.36 + libdrivers-cpm libdrivers-dma libdrivers-gpio libdrivers-spi \ 9.37 + libdevice-util 9.38 + 9.39 +PRIVATE_INCDIR = $(PKGDIR)/lcd/include $(IDL_BUILD_DIR) $(IDL_EXPORT_DIR) 9.40 + 9.41 +include $(L4DIR)/mk/lib.mk 9.42 +include $(IDL_MK_DIR)/interface_rules.mk 9.43 + 9.44 +$(PLAIN_SRC_CC): $(CLIENT_INTERFACES_SRC_CC)
10.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 10.2 +++ b/pkg/devices/lcd/src/jz4780/lcd-jz4780-spi-device.cc Fri Apr 19 16:27:55 2024 +0200 10.3 @@ -0,0 +1,275 @@ 10.4 +/* 10.5 + * Common SPI-based screen support for the JZ4780 and related SoCs. 10.6 + * 10.7 + * Copyright (C) 2018, 2020, 2021, 2023, 2024 Paul Boddie <paul@boddie.org.uk> 10.8 + * 10.9 + * This program is free software; you can redistribute it and/or 10.10 + * modify it under the terms of the GNU General Public License as 10.11 + * published by the Free Software Foundation; either version 2 of 10.12 + * the License, or (at your option) any later version. 10.13 + * 10.14 + * This program is distributed in the hope that it will be useful, 10.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of 10.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10.17 + * GNU General Public License for more details. 10.18 + * 10.19 + * You should have received a copy of the GNU General Public License 10.20 + * along with this program; if not, write to the Free Software 10.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, 10.22 + * Boston, MA 02110-1301, USA 10.23 + */ 10.24 + 10.25 +#include <l4/devices/cpm-jz4780.h> 10.26 +#include <l4/devices/dma-jz4780.h> 10.27 +#include <l4/devices/gpio-jz4780.h> 10.28 +#include <l4/devices/spi-hybrid.h> 10.29 +#include <l4/devices/spi-jz4780.h> 10.30 + 10.31 +#include <l4/devices/dma.h> 10.32 +#include <l4/devices/memory.h> 10.33 +#include "lcd-jz4780-spi-device.h" 10.34 + 10.35 +#include <l4/re/c/dataspace.h> 10.36 +#include <l4/re/env.h> 10.37 +#include <l4/sys/cache.h> 10.38 +#include <l4/sys/types.h> 10.39 + 10.40 +#include <ipc/cap_alloc.h> 10.41 +#include <ipc/mem_ipc.h> 10.42 + 10.43 +#include <stdio.h> 10.44 +#include <unistd.h> 10.45 + 10.46 + 10.47 + 10.48 +/* Virtual addresses for the CPM, DMA, GPIO and SSI/SPI register blocks. 10.49 + 10.50 + NOTE: Should be able to use component abstractions for some of these 10.51 + eventually. */ 10.52 + 10.53 +static l4_addr_t cpm_virt_base = 0, cpm_virt_base_end = 0; 10.54 +static l4_addr_t dma_virt_base = 0, dma_virt_base_end = 0; 10.55 +static l4_addr_t gpio_virt_base = 0, gpio_virt_base_end = 0; 10.56 +static l4_addr_t spi_virt_base = 0, spi_virt_base_end = 0; 10.57 +static l4_addr_t spi_phys_base = 0, spi_phys_base_end = 0; 10.58 + 10.59 +static l4_uint32_t dma_irq_start = 0, dma_irq_end = 0; 10.60 + 10.61 +// CPM, DMA, GPIO, SSI/SPI and display device abstractions. 10.62 + 10.63 +static Cpm_jz4780_chip *cpm_chip; 10.64 +static Dma_jz4780_chip *dma_chip; 10.65 +static Gpio_jz4780_chip *gpio_chip; 10.66 +static Spi_jz4780_chip *spi_chip; 10.67 + 10.68 +static Dma_jz4780_channel *dma_channel; 10.69 +static Spi_hybrid *spi_channel; 10.70 +static Spi_jz4780_channel *spi_jz4780_channel; 10.71 + 10.72 +struct gpio_port 10.73 +{ 10.74 + uint32_t pull_ups, pull_downs; 10.75 +}; 10.76 + 10.77 +static struct gpio_port gpio_ports[] = { 10.78 + {0x3fff00ff, 0x00000000}, 10.79 + {0xfff0f3fc, 0x000f0c03}, 10.80 + {0x0fffffff, 0x00000000}, 10.81 + {0xffff4fff, 0x0000b000}, 10.82 + {0xf0fff37c, 0x00000483}, 10.83 + {0x7fa7f00f, 0x00580ff0}, 10.84 +}; 10.85 + 10.86 + 10.87 + 10.88 +// Disable the display. 10.89 + 10.90 +void 10.91 +Lcd_jz4780_spi_device::disable() 10.92 +{ 10.93 + // NOTE: Need to support cancelling the transfer or disabling the peripheral. 10.94 + 10.95 + //disable_display(); 10.96 +} 10.97 + 10.98 +// Configure the peripheral and enable the display. 10.99 + 10.100 +void 10.101 +Lcd_jz4780_spi_device::enable() 10.102 +{ 10.103 + // Set up the GPIO pins for the peripheral. 10.104 + // NOTE: Hard-coded pin usage! 10.105 + 10.106 + gpio_chip->setup(20, Hw::Gpio_chip::Output, 1); // backlight 10.107 + gpio_chip->config_pad(21, Hw::Gpio_chip::Function_alt, 2); // CE1 10.108 + gpio_chip->config_pad(28, Hw::Gpio_chip::Function_alt, 2); // SCLK 10.109 + gpio_chip->config_pad(29, Hw::Gpio_chip::Function_alt, 2); // MOSI 10.110 + gpio_chip->config_pad(30, Hw::Gpio_chip::Function_alt, 2); // GPC 10.111 + 10.112 + // Initialise the screen. 10.113 + // NOTE: Specific to the ST7789. 10.114 + 10.115 + spi_channel->send_units(2, (const uint8_t []) {0x00, 0x01}, 2, 8); 10.116 + usleep(120000); 10.117 + spi_channel->send_units(2, (const uint8_t []) {0x00, 0x11}, 2, 8); 10.118 + usleep(5000); 10.119 + spi_channel->send_units(4, (const uint8_t []) {0x00, 0x36, 0x01, 0x00}, 2, 8); 10.120 + usleep(5000); 10.121 + spi_channel->send_units(10, (const uint8_t []) {0x00, 0x3a, 0x01, 0x05, 0x00, 0x13, 0x00, 0x29, 0x00, 0x21}, 2, 8); 10.122 + usleep(5000); 10.123 + spi_channel->send_units(22, (const uint8_t []) {0x00, 0x2a, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0xef, 10.124 + 0x00, 0x2b, 0x01, 0x00, 0x01, 0x00, 0x01, 0x00, 0x01, 0xef, 10.125 + 0x00, 0x2c}, 2, 8); 10.126 + usleep(5000); 10.127 + 10.128 + for (l4_addr_t addr = get_framebuffer(); addr < get_framebuffer() + get_framebuffer_size(); addr += sizeof(uint32_t)) 10.129 + *((uint32_t *) addr) = 0; 10.130 + 10.131 + l4_cache_clean_data(get_framebuffer(), get_framebuffer() + get_framebuffer_size()); 10.132 + 10.133 + // Initialise the display transfer. 10.134 + // NOTE: Asserting the data signal. 10.135 + 10.136 + spi_channel->acquire_control(true); 10.137 + 10.138 + spi_jz4780_channel->transfer(_fb_region.vaddr, _fb_region.paddr, 10.139 + get_framebuffer_size(), 2, 16, 10.140 + _desc_region.vaddr, _desc_region.paddr); 10.141 + 10.142 + //enable_display(); 10.143 +} 10.144 + 10.145 +// Set up memory addresses for the peripheral, initialising the framebuffer and 10.146 +// descriptor members. 10.147 + 10.148 +int 10.149 +Lcd_jz4780_spi_device::_setup_memory() 10.150 +{ 10.151 + // Test for existing setup. 10.152 + 10.153 + if (_fb_region.vaddr) 10.154 + return 0; 10.155 + 10.156 + // Framebuffer and descriptor sizes. 10.157 + 10.158 + unsigned long fb_size = get_framebuffer_size(), desc_size = 32; 10.159 + 10.160 + // Allocate memory for the framebuffer and descriptors with 2**5 = 32 byte == 10.161 + // 8 word alignment, sufficient for the descriptors. 10.162 + 10.163 + long err = get_dma_region(fb_size, 5, &_fb_region); 10.164 + 10.165 + if (err) 10.166 + return 1; 10.167 + 10.168 + err = get_dma_region(desc_size, 5, &_desc_region); 10.169 + 10.170 + if (err) 10.171 + return 1; 10.172 + 10.173 + return 0; 10.174 +} 10.175 + 10.176 +l4_size_t Lcd_jz4780_spi_device::get_framebuffer_size() 10.177 +{ 10.178 + // NOTE: Hard-coded size. 10.179 + 10.180 + return 240 * 240 * 2; 10.181 +} 10.182 + 10.183 +// Populate a view information structure. 10.184 + 10.185 +void Lcd_jz4780_spi_device::get_view_info(l4re_video_view_info_t *view_info) 10.186 +{ 10.187 + // NOTE: Hard-coded properties. 10.188 + 10.189 + view_info->width = 240; 10.190 + view_info->height = 240; 10.191 + view_info->pixel_info.bytes_per_pixel = 2; 10.192 + view_info->bytes_per_line = 480; 10.193 + 10.194 + view_info->pixel_info.r.shift = 11; view_info->pixel_info.r.size = 5; 10.195 + view_info->pixel_info.g.shift = 5; view_info->pixel_info.g.size = 6; 10.196 + view_info->pixel_info.b.shift = 0; view_info->pixel_info.b.size = 5; 10.197 + 10.198 + view_info->pixel_info.a.shift = 0; 10.199 + view_info->pixel_info.a.size = 0; 10.200 +} 10.201 + 10.202 +// Access to peripheral memory. 10.203 + 10.204 +static int setup_memory() 10.205 +{ 10.206 + if (get_memory("jz4780-cpm", &cpm_virt_base, &cpm_virt_base_end)) 10.207 + return 1; 10.208 + 10.209 + if (get_memory("jz4780-dma", &dma_virt_base, &dma_virt_base_end)) 10.210 + return 1; 10.211 + 10.212 + if (get_irq("jz4780-dma", &dma_irq_start, &dma_irq_end) < 0) 10.213 + return 1; 10.214 + 10.215 + if (get_memory("jz4780-gpio", &gpio_virt_base, &gpio_virt_base_end)) 10.216 + return 1; 10.217 + 10.218 + if (get_memory_complete("jz4780-ssi", &spi_virt_base, &spi_virt_base_end, 10.219 + &spi_phys_base, &spi_phys_base_end)) 10.220 + return 1; 10.221 + 10.222 + // Initialise the abstractions. 10.223 + // NOTE: Using a preset GPIO configuration. 10.224 + 10.225 + int gpio_port = 1; 10.226 + 10.227 + cpm_chip = new Cpm_jz4780_chip(cpm_virt_base); 10.228 + 10.229 + dma_chip = new Dma_jz4780_chip(dma_virt_base, dma_virt_base_end, cpm_chip); 10.230 + 10.231 + dma_chip->enable(); 10.232 + 10.233 + gpio_chip = new Gpio_jz4780_chip(gpio_virt_base + gpio_port * 0x100, 10.234 + gpio_virt_base + (gpio_port + 1) * 0x100, 10.235 + 32, gpio_ports[gpio_port].pull_ups, 10.236 + gpio_ports[gpio_port].pull_downs); 10.237 + 10.238 + // Initialise the clocks for the SPI peripheral before obtaining the 10.239 + // peripheral abstraction. 10.240 + 10.241 + /* NOTE: Set a suitably high but arbitrary frequency to support the SPI bit 10.242 + clock. */ 10.243 + 10.244 + cpm_chip->set_frequency(Clock_ssi, 100000000); 10.245 + 10.246 + spi_chip = new Spi_jz4780_chip(spi_phys_base, spi_virt_base, 10.247 + spi_virt_base_end, cpm_chip); 10.248 + 10.249 + // Obtain a DMA channel and an SPI channel for updating the display. 10.250 + // NOTE: Using preset channels, frequency and pin configuration. 10.251 + 10.252 + dma_channel = dma_chip->get_channel(12); 10.253 + 10.254 + spi_jz4780_channel = spi_chip->get_channel(1, dma_channel, 25000000); 10.255 + 10.256 + spi_channel = new Spi_hybrid(spi_jz4780_channel, gpio_chip, 30, 2); 10.257 + 10.258 + return 0; 10.259 +} 10.260 + 10.261 +// Device initialisation. 10.262 + 10.263 +Lcd_jz4780_spi_device *Lcd_jz4780_spi_device::device = 0; 10.264 + 10.265 +Lcd_device *Lcd_device::get_device() 10.266 +{ 10.267 + if (Lcd_jz4780_spi_device::device) 10.268 + return Lcd_jz4780_spi_device::device; 10.269 + 10.270 + if (setup_memory()) 10.271 + return 0; 10.272 + 10.273 + // Initialise the common device. 10.274 + 10.275 + Lcd_jz4780_spi_device::device = new Lcd_jz4780_spi_device(NULL /* display_device */); 10.276 + 10.277 + return Lcd_jz4780_spi_device::device; 10.278 +}
11.1 --- a/pkg/devices/lib/spi/include/spi-hybrid.h Fri Apr 19 16:25:48 2024 +0200 11.2 +++ b/pkg/devices/lib/spi/include/spi-hybrid.h Fri Apr 19 16:27:55 2024 +0200 11.3 @@ -2,7 +2,7 @@ 11.4 * Perform SPI communication using a suitable abstraction augmented with 11.5 * explicit manipulation of a control signal. 11.6 * 11.7 - * Copyright (C) 2023 Paul Boddie <paul@boddie.org.uk> 11.8 + * Copyright (C) 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 @@ -55,10 +55,11 @@ 11.13 uint32_t send(uint32_t bytes, const uint8_t data[]); 11.14 11.15 uint32_t send_dc(uint32_t bytes, const uint8_t data[], const int dc[], 11.16 - uint8_t char_size, bool big_endian); 11.17 + uint8_t char_size, bool big_endian = true); 11.18 11.19 uint32_t send_units(uint32_t bytes, const uint8_t data[], 11.20 - uint8_t unit_size, uint8_t char_size, bool big_endian); 11.21 + uint8_t unit_size, uint8_t char_size, 11.22 + bool big_endian = true); 11.23 11.24 uint32_t transfer(l4_addr_t vaddr, l4re_dma_space_dma_addr_t paddr, 11.25 uint32_t count, uint8_t unit_size, uint8_t char_size,
12.1 --- a/pkg/devices/lib/spi/include/spi-jz4780.h Fri Apr 19 16:25:48 2024 +0200 12.2 +++ b/pkg/devices/lib/spi/include/spi-jz4780.h Fri Apr 19 16:27:55 2024 +0200 12.3 @@ -1,7 +1,7 @@ 12.4 /* 12.5 * Perform SPI communication using the JZ4780 SPI peripheral. 12.6 * 12.7 - * Copyright (C) 2023 Paul Boddie <paul@boddie.org.uk> 12.8 + * Copyright (C) 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 @@ -68,10 +68,10 @@ 12.13 virtual uint32_t send(uint32_t bytes, const uint8_t data[]); 12.14 12.15 virtual uint32_t send_dc(uint32_t bytes, const uint8_t data[], const int dc[], 12.16 - uint8_t char_size, bool big_endian); 12.17 + uint8_t char_size, bool big_endian = true); 12.18 12.19 uint32_t send_units(uint32_t bytes, const uint8_t data[], uint8_t unit_size, 12.20 - uint8_t char_size, bool big_endian); 12.21 + uint8_t char_size, bool big_endian = true); 12.22 12.23 /* DMA operations. */ 12.24