1.1 --- a/pkg/landfall-examples/hw_info/x1600.c Thu Feb 01 22:41:30 2024 +0100
1.2 +++ b/pkg/landfall-examples/hw_info/x1600.c Thu Feb 01 22:42:56 2024 +0100
1.3 @@ -1,7 +1,7 @@
1.4 /*
1.5 * Access various peripherals on a board using the X1600.
1.6 *
1.7 - * Copyright (C) 2023 Paul Boddie <paul@boddie.org.uk>
1.8 + * Copyright (C) 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 @@ -28,6 +28,7 @@
1.13 #include <l4/devices/spi-gpio.h>
1.14 #include <l4/devices/spi-hybrid.h>
1.15 #include <l4/devices/spi-jz4780.h>
1.16 +#include <l4/devices/tcu-x1600.h>
1.17 #include "common.h"
1.18
1.19
1.20 @@ -448,6 +449,125 @@
1.21
1.22
1.23
1.24 +/* TCU adapter functions. */
1.25 +
1.26 +void *tcu_init(l4_addr_t start, l4_addr_t end)
1.27 +{
1.28 + return x1600_tcu_init(start, end);
1.29 +}
1.30 +
1.31 +void *tcu_get_channel(void *tcu, uint8_t channel, l4_cap_idx_t irq)
1.32 +{
1.33 + return x1600_tcu_get_channel(tcu, channel, irq);
1.34 +}
1.35 +
1.36 +void tcu_disable(void *tcu_channel)
1.37 +{
1.38 + x1600_tcu_disable(tcu_channel);
1.39 +}
1.40 +
1.41 +void tcu_enable(void *tcu_channel)
1.42 +{
1.43 + x1600_tcu_enable(tcu_channel);
1.44 +}
1.45 +
1.46 +int tcu_is_enabled(void *tcu_channel)
1.47 +{
1.48 + return x1600_tcu_is_enabled(tcu_channel);
1.49 +}
1.50 +
1.51 +uint8_t tcu_get_clock(void *tcu_channel)
1.52 +{
1.53 + return x1600_tcu_get_clock(tcu_channel);
1.54 +}
1.55 +
1.56 +void tcu_set_clock(void *tcu_channel, uint8_t clock)
1.57 +{
1.58 + x1600_tcu_set_clock(tcu_channel, clock);
1.59 +}
1.60 +
1.61 +uint32_t tcu_get_prescale(void *tcu_channel)
1.62 +{
1.63 + return x1600_tcu_get_prescale(tcu_channel);
1.64 +}
1.65 +
1.66 +void tcu_set_prescale(void *tcu_channel, uint32_t prescale)
1.67 +{
1.68 + x1600_tcu_set_prescale(tcu_channel, prescale);
1.69 +}
1.70 +
1.71 +uint32_t tcu_get_counter(void *tcu_channel)
1.72 +{
1.73 + return x1600_tcu_get_counter(tcu_channel);
1.74 +}
1.75 +
1.76 +void tcu_set_counter(void *tcu_channel, uint32_t value)
1.77 +{
1.78 + x1600_tcu_set_counter(tcu_channel, value);
1.79 +}
1.80 +
1.81 +uint8_t tcu_get_count_mode(void *tcu_channel)
1.82 +{
1.83 + return x1600_tcu_get_count_mode(tcu_channel);
1.84 +}
1.85 +
1.86 +void tcu_set_count_mode(void *tcu_channel, uint8_t mode)
1.87 +{
1.88 + x1600_tcu_set_count_mode(tcu_channel, mode);
1.89 +}
1.90 +
1.91 +uint32_t tcu_get_full_data_value(void *tcu_channel)
1.92 +{
1.93 + return x1600_tcu_get_full_data_value(tcu_channel);
1.94 +}
1.95 +
1.96 +void tcu_set_full_data_value(void *tcu_channel, uint32_t value)
1.97 +{
1.98 + x1600_tcu_set_full_data_value(tcu_channel, value);
1.99 +}
1.100 +
1.101 +uint32_t tcu_get_half_data_value(void *tcu_channel)
1.102 +{
1.103 + return x1600_tcu_get_half_data_value(tcu_channel);
1.104 +}
1.105 +
1.106 +void tcu_set_half_data_value(void *tcu_channel, uint32_t value)
1.107 +{
1.108 + x1600_tcu_set_half_data_value(tcu_channel, value);
1.109 +}
1.110 +
1.111 +int tcu_get_full_data_mask(void *tcu_channel)
1.112 +{
1.113 + return x1600_tcu_get_full_data_mask(tcu_channel);
1.114 +}
1.115 +
1.116 +void tcu_set_full_data_mask(void *tcu_channel, int masked)
1.117 +{
1.118 + x1600_tcu_set_full_data_mask(tcu_channel, masked);
1.119 +}
1.120 +
1.121 +int tcu_get_half_data_mask(void *tcu_channel)
1.122 +{
1.123 + return x1600_tcu_get_half_data_mask(tcu_channel);
1.124 +}
1.125 +
1.126 +void tcu_set_half_data_mask(void *tcu_channel, int masked)
1.127 +{
1.128 + x1600_tcu_set_half_data_mask(tcu_channel, masked);
1.129 +}
1.130 +
1.131 +int tcu_have_interrupt(void *tcu_channel)
1.132 +{
1.133 + return x1600_tcu_have_interrupt(tcu_channel);
1.134 +}
1.135 +
1.136 +int tcu_wait_for_irq(void *tcu_channel, uint32_t timeout)
1.137 +{
1.138 + return x1600_tcu_wait_for_irq(tcu_channel, timeout);
1.139 +}
1.140 +
1.141 +
1.142 +
1.143 /* Memory regions. */
1.144
1.145 const char *io_memory_regions[] = {
1.146 @@ -458,6 +578,7 @@
1.147 [I2C] = "x1600-i2c",
1.148 [RTC] = "x1600-rtc",
1.149 [SSI] = "x1600-ssi",
1.150 + [TCU] = "x1600-tcu",
1.151 };
1.152
1.153
1.154 @@ -555,3 +676,13 @@
1.155 void *spi_channels[] = {NULL};
1.156
1.157 const unsigned int num_spi_channels = 1;
1.158 +
1.159 +
1.160 +
1.161 +/* TCU definitions. */
1.162 +
1.163 +void *tcu_channels[] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
1.164 +
1.165 +const unsigned int num_tcu_channels = 8;
1.166 +
1.167 +l4_cap_idx_t tcu_irq = L4_INVALID_CAP;