paul@218 | 1 | /* |
paul@218 | 2 | * Access various peripherals on a board using the X1600. |
paul@218 | 3 | * |
paul@253 | 4 | * Copyright (C) 2023, 2024 Paul Boddie <paul@boddie.org.uk> |
paul@218 | 5 | * |
paul@218 | 6 | * This program is free software; you can redistribute it and/or |
paul@218 | 7 | * modify it under the terms of the GNU General Public License as |
paul@218 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@218 | 9 | * the License, or (at your option) any later version. |
paul@218 | 10 | * |
paul@218 | 11 | * This program is distributed in the hope that it will be useful, |
paul@218 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@218 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@218 | 14 | * GNU General Public License for more details. |
paul@218 | 15 | * |
paul@218 | 16 | * You should have received a copy of the GNU General Public License |
paul@218 | 17 | * along with this program; if not, write to the Free Software |
paul@218 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@218 | 19 | * Boston, MA 02110-1301, USA |
paul@218 | 20 | */ |
paul@218 | 21 | |
paul@218 | 22 | #include <l4/devices/aic-x1600.h> |
paul@218 | 23 | #include <l4/devices/cpm-x1600.h> |
paul@218 | 24 | #include <l4/devices/dma-x1600.h> |
paul@218 | 25 | #include <l4/devices/gpio-x1600.h> |
paul@218 | 26 | #include <l4/devices/i2c-x1600.h> |
paul@237 | 27 | #include <l4/devices/rtc-x1600.h> |
paul@218 | 28 | #include <l4/devices/spi-gpio.h> |
paul@235 | 29 | #include <l4/devices/spi-hybrid.h> |
paul@235 | 30 | #include <l4/devices/spi-jz4780.h> |
paul@253 | 31 | #include <l4/devices/tcu-x1600.h> |
paul@218 | 32 | #include "common.h" |
paul@218 | 33 | |
paul@218 | 34 | |
paul@218 | 35 | |
paul@218 | 36 | /* AIC adapter functions. */ |
paul@218 | 37 | |
paul@218 | 38 | void *aic_init(l4_addr_t aic_start, l4_addr_t start, l4_addr_t end, void *cpm) |
paul@218 | 39 | { |
paul@218 | 40 | return x1600_aic_init(aic_start, start, end, cpm); |
paul@218 | 41 | } |
paul@218 | 42 | |
paul@218 | 43 | void *aic_get_channel(void *aic, int num, void *channel) |
paul@218 | 44 | { |
paul@218 | 45 | return x1600_aic_get_channel(aic, num, channel); |
paul@218 | 46 | } |
paul@218 | 47 | |
paul@221 | 48 | unsigned int aic_transfer(void *channel, l4re_dma_space_dma_addr_t paddr, |
paul@221 | 49 | uint32_t count, uint32_t sample_rate, |
paul@221 | 50 | uint8_t sample_size) |
paul@218 | 51 | { |
paul@221 | 52 | return x1600_aic_transfer(channel, paddr, count, sample_rate, sample_size); |
paul@218 | 53 | } |
paul@218 | 54 | |
paul@218 | 55 | |
paul@218 | 56 | |
paul@218 | 57 | /* CPM adapter functions. */ |
paul@218 | 58 | |
paul@218 | 59 | void *cpm_init(l4_addr_t cpm_base) |
paul@218 | 60 | { |
paul@218 | 61 | return x1600_cpm_init(cpm_base); |
paul@218 | 62 | } |
paul@218 | 63 | |
paul@218 | 64 | const char *cpm_clock_type(void *cpm, enum Clock_identifiers clock) |
paul@218 | 65 | { |
paul@218 | 66 | return x1600_cpm_clock_type(cpm, clock); |
paul@218 | 67 | } |
paul@218 | 68 | |
paul@218 | 69 | int cpm_have_clock(void *cpm, enum Clock_identifiers clock) |
paul@218 | 70 | { |
paul@218 | 71 | return x1600_cpm_have_clock(cpm, clock); |
paul@218 | 72 | } |
paul@218 | 73 | |
paul@218 | 74 | void cpm_start_clock(void *cpm, enum Clock_identifiers clock) |
paul@218 | 75 | { |
paul@218 | 76 | x1600_cpm_start_clock(cpm, clock); |
paul@218 | 77 | } |
paul@218 | 78 | |
paul@218 | 79 | void cpm_stop_clock(void *cpm, enum Clock_identifiers clock) |
paul@218 | 80 | { |
paul@218 | 81 | x1600_cpm_stop_clock(cpm, clock); |
paul@218 | 82 | } |
paul@218 | 83 | |
paul@218 | 84 | int cpm_get_parameters(void *cpm, enum Clock_identifiers clock, |
paul@218 | 85 | uint32_t parameters[]) |
paul@218 | 86 | { |
paul@218 | 87 | return x1600_cpm_get_parameters(cpm, clock, parameters); |
paul@218 | 88 | } |
paul@218 | 89 | |
paul@218 | 90 | int cpm_set_parameters(void *cpm, enum Clock_identifiers clock, |
paul@218 | 91 | int num_parameters, uint32_t parameters[]) |
paul@218 | 92 | { |
paul@218 | 93 | return x1600_cpm_set_parameters(cpm, clock, num_parameters, parameters); |
paul@218 | 94 | } |
paul@218 | 95 | |
paul@218 | 96 | uint8_t cpm_get_source(void *cpm, enum Clock_identifiers clock) |
paul@218 | 97 | { |
paul@218 | 98 | return x1600_cpm_get_source(cpm, clock); |
paul@218 | 99 | } |
paul@218 | 100 | |
paul@218 | 101 | void cpm_set_source(void *cpm, enum Clock_identifiers clock, uint8_t source) |
paul@218 | 102 | { |
paul@218 | 103 | x1600_cpm_set_source(cpm, clock, source); |
paul@218 | 104 | } |
paul@218 | 105 | |
paul@218 | 106 | enum Clock_identifiers cpm_get_source_clock(void *cpm, enum Clock_identifiers clock) |
paul@218 | 107 | { |
paul@218 | 108 | return x1600_cpm_get_source_clock(cpm, clock); |
paul@218 | 109 | } |
paul@218 | 110 | |
paul@218 | 111 | void cpm_set_source_clock(void *cpm, enum Clock_identifiers clock, enum Clock_identifiers source) |
paul@218 | 112 | { |
paul@218 | 113 | x1600_cpm_set_source_clock(cpm, clock, source); |
paul@218 | 114 | } |
paul@218 | 115 | |
paul@218 | 116 | uint64_t cpm_get_source_frequency(void *cpm, enum Clock_identifiers clock) |
paul@218 | 117 | { |
paul@218 | 118 | return x1600_cpm_get_source_frequency(cpm, clock); |
paul@218 | 119 | } |
paul@218 | 120 | |
paul@218 | 121 | uint64_t cpm_get_frequency(void *cpm, enum Clock_identifiers clock) |
paul@218 | 122 | { |
paul@218 | 123 | return x1600_cpm_get_frequency(cpm, clock); |
paul@218 | 124 | } |
paul@218 | 125 | |
paul@218 | 126 | int cpm_set_frequency(void *cpm, enum Clock_identifiers clock, uint64_t frequency) |
paul@218 | 127 | { |
paul@218 | 128 | return x1600_cpm_set_frequency(cpm, clock, frequency); |
paul@218 | 129 | } |
paul@218 | 130 | |
paul@218 | 131 | |
paul@218 | 132 | |
paul@218 | 133 | /* DMA adapter functions. */ |
paul@218 | 134 | |
paul@218 | 135 | void *dma_init(l4_addr_t start, l4_addr_t end, void *cpm) |
paul@218 | 136 | { |
paul@218 | 137 | return x1600_dma_init(start, end, cpm); |
paul@218 | 138 | } |
paul@218 | 139 | |
paul@218 | 140 | void dma_disable(void *dma_chip) |
paul@218 | 141 | { |
paul@218 | 142 | x1600_dma_disable(dma_chip); |
paul@218 | 143 | } |
paul@218 | 144 | |
paul@218 | 145 | void dma_enable(void *dma_chip) |
paul@218 | 146 | { |
paul@218 | 147 | x1600_dma_enable(dma_chip); |
paul@218 | 148 | } |
paul@218 | 149 | |
paul@218 | 150 | void *dma_get_channel(void *dma, uint8_t channel, l4_cap_idx_t irq) |
paul@218 | 151 | { |
paul@218 | 152 | return x1600_dma_get_channel(dma, channel, irq); |
paul@218 | 153 | } |
paul@218 | 154 | |
paul@218 | 155 | unsigned int dma_transfer(void *dma_channel, |
paul@218 | 156 | uint32_t source, uint32_t destination, |
paul@218 | 157 | unsigned int count, |
paul@218 | 158 | int source_increment, int destination_increment, |
paul@218 | 159 | uint8_t source_width, uint8_t destination_width, |
paul@218 | 160 | uint8_t transfer_unit_size, |
paul@218 | 161 | int type) |
paul@218 | 162 | { |
paul@218 | 163 | return x1600_dma_transfer(dma_channel, source, destination, count, |
paul@218 | 164 | source_increment, destination_increment, |
paul@218 | 165 | source_width, destination_width, |
paul@218 | 166 | transfer_unit_size, type); |
paul@218 | 167 | } |
paul@218 | 168 | |
paul@218 | 169 | unsigned int dma_wait(void *dma_channel) |
paul@218 | 170 | { |
paul@218 | 171 | return x1600_dma_wait(dma_channel); |
paul@218 | 172 | } |
paul@218 | 173 | |
paul@218 | 174 | |
paul@218 | 175 | |
paul@218 | 176 | /* GPIO adapter functions. */ |
paul@218 | 177 | |
paul@218 | 178 | void *gpio_init(l4_addr_t start, l4_addr_t end, unsigned pins, |
paul@218 | 179 | l4_uint32_t pull_ups, l4_uint32_t pull_downs) |
paul@218 | 180 | { |
paul@218 | 181 | return x1600_gpio_init(start, end, pins, pull_ups, pull_downs); |
paul@218 | 182 | } |
paul@218 | 183 | |
paul@218 | 184 | void gpio_setup(void *gpio, unsigned pin, unsigned mode, int value) |
paul@218 | 185 | { |
paul@218 | 186 | x1600_gpio_setup(gpio, pin, mode, value); |
paul@218 | 187 | } |
paul@218 | 188 | |
paul@218 | 189 | void gpio_config_pull(void *gpio, unsigned pin, unsigned mode) |
paul@218 | 190 | { |
paul@218 | 191 | x1600_gpio_config_pull(gpio, pin, mode); |
paul@218 | 192 | } |
paul@218 | 193 | |
paul@218 | 194 | void gpio_config_pad(void *gpio, unsigned pin, unsigned func, unsigned value) |
paul@218 | 195 | { |
paul@218 | 196 | x1600_gpio_config_pad(gpio, pin, func, value); |
paul@218 | 197 | } |
paul@218 | 198 | |
paul@218 | 199 | void gpio_config_get(void *gpio, unsigned pin, unsigned reg, unsigned *value) |
paul@218 | 200 | { |
paul@218 | 201 | x1600_gpio_config_get(gpio, pin, reg, value); |
paul@218 | 202 | } |
paul@218 | 203 | |
paul@218 | 204 | void gpio_config_pad_get(void *gpio, unsigned pin, unsigned *func, unsigned *value) |
paul@218 | 205 | { |
paul@218 | 206 | x1600_gpio_config_pad_get(gpio, pin, func, value); |
paul@218 | 207 | } |
paul@218 | 208 | |
paul@218 | 209 | void gpio_multi_setup(void *gpio, Pin_slice const *mask, unsigned mode, unsigned outvalues) |
paul@218 | 210 | { |
paul@218 | 211 | x1600_gpio_multi_setup(gpio, mask, mode, outvalues); |
paul@218 | 212 | } |
paul@218 | 213 | |
paul@218 | 214 | void gpio_multi_config_pad(void *gpio, Pin_slice const *mask, unsigned func, unsigned value) |
paul@218 | 215 | { |
paul@218 | 216 | x1600_gpio_multi_config_pad(gpio, mask, func, value); |
paul@218 | 217 | } |
paul@218 | 218 | |
paul@218 | 219 | void gpio_multi_set(void *gpio, Pin_slice const *mask, unsigned data) |
paul@218 | 220 | { |
paul@218 | 221 | x1600_gpio_multi_set(gpio, mask, data); |
paul@218 | 222 | } |
paul@218 | 223 | |
paul@218 | 224 | unsigned gpio_multi_get(void *gpio, unsigned offset) |
paul@218 | 225 | { |
paul@218 | 226 | return x1600_gpio_multi_get(gpio, offset); |
paul@218 | 227 | } |
paul@218 | 228 | |
paul@218 | 229 | int gpio_get(void *gpio, unsigned pin) |
paul@218 | 230 | { |
paul@218 | 231 | return x1600_gpio_get(gpio, pin); |
paul@218 | 232 | } |
paul@218 | 233 | |
paul@218 | 234 | void gpio_set(void *gpio, unsigned pin, int value) |
paul@218 | 235 | { |
paul@218 | 236 | x1600_gpio_set(gpio, pin, value); |
paul@218 | 237 | } |
paul@218 | 238 | |
paul@218 | 239 | void *gpio_get_irq(void *gpio, unsigned pin) |
paul@218 | 240 | { |
paul@218 | 241 | return x1600_gpio_get_irq(gpio, pin); |
paul@218 | 242 | } |
paul@218 | 243 | |
paul@218 | 244 | bool gpio_irq_set_mode(void *gpio_irq, unsigned mode) |
paul@218 | 245 | { |
paul@218 | 246 | return x1600_gpio_irq_set_mode(gpio_irq, mode); |
paul@218 | 247 | } |
paul@218 | 248 | |
paul@218 | 249 | |
paul@218 | 250 | |
paul@218 | 251 | /* I2C adapter functions. */ |
paul@218 | 252 | |
paul@218 | 253 | void *i2c_init(l4_addr_t start, l4_addr_t end, void *cpm, |
paul@218 | 254 | uint32_t frequency) |
paul@218 | 255 | { |
paul@218 | 256 | return x1600_i2c_init(start, end, cpm, frequency); |
paul@218 | 257 | } |
paul@218 | 258 | |
paul@218 | 259 | void *i2c_get_channel(void *i2c, uint8_t channel) |
paul@218 | 260 | { |
paul@218 | 261 | return x1600_i2c_get_channel(i2c, channel); |
paul@218 | 262 | } |
paul@218 | 263 | |
paul@218 | 264 | uint32_t i2c_get_frequency(void *i2c_channel) |
paul@218 | 265 | { |
paul@218 | 266 | return x1600_i2c_get_frequency(i2c_channel); |
paul@218 | 267 | } |
paul@218 | 268 | |
paul@218 | 269 | void i2c_set_target(void *i2c_channel, uint8_t addr) |
paul@218 | 270 | { |
paul@218 | 271 | return x1600_i2c_set_target(i2c_channel, addr); |
paul@218 | 272 | } |
paul@218 | 273 | |
paul@218 | 274 | void i2c_start_read(void *i2c_channel, uint8_t buf[], unsigned int total, |
paul@218 | 275 | int stop) |
paul@218 | 276 | { |
paul@218 | 277 | x1600_i2c_start_read(i2c_channel, buf, total, stop); |
paul@218 | 278 | } |
paul@218 | 279 | |
paul@218 | 280 | void i2c_read(void *i2c_channel) |
paul@218 | 281 | { |
paul@218 | 282 | x1600_i2c_read(i2c_channel); |
paul@218 | 283 | } |
paul@218 | 284 | |
paul@218 | 285 | void i2c_start_write(void *i2c_channel, uint8_t buf[], unsigned int total, |
paul@218 | 286 | int stop) |
paul@218 | 287 | { |
paul@218 | 288 | x1600_i2c_start_write(i2c_channel, buf, total, stop); |
paul@218 | 289 | } |
paul@218 | 290 | |
paul@218 | 291 | void i2c_write(void *i2c_channel) |
paul@218 | 292 | { |
paul@218 | 293 | x1600_i2c_write(i2c_channel); |
paul@218 | 294 | } |
paul@218 | 295 | |
paul@218 | 296 | int i2c_read_done(void *i2c_channel) |
paul@218 | 297 | { |
paul@218 | 298 | return x1600_i2c_read_done(i2c_channel); |
paul@218 | 299 | } |
paul@218 | 300 | |
paul@218 | 301 | int i2c_write_done(void *i2c_channel) |
paul@218 | 302 | { |
paul@218 | 303 | return x1600_i2c_write_done(i2c_channel); |
paul@218 | 304 | } |
paul@218 | 305 | |
paul@218 | 306 | unsigned int i2c_have_read(void *i2c_channel) |
paul@218 | 307 | { |
paul@218 | 308 | return x1600_i2c_have_read(i2c_channel); |
paul@218 | 309 | } |
paul@218 | 310 | |
paul@218 | 311 | unsigned int i2c_have_written(void *i2c_channel) |
paul@218 | 312 | { |
paul@218 | 313 | return x1600_i2c_have_written(i2c_channel); |
paul@218 | 314 | } |
paul@218 | 315 | |
paul@218 | 316 | int i2c_failed(void *i2c_channel) |
paul@218 | 317 | { |
paul@218 | 318 | return x1600_i2c_failed(i2c_channel); |
paul@218 | 319 | } |
paul@218 | 320 | |
paul@218 | 321 | void i2c_stop(void *i2c_channel) |
paul@218 | 322 | { |
paul@218 | 323 | x1600_i2c_stop(i2c_channel); |
paul@218 | 324 | } |
paul@218 | 325 | |
paul@218 | 326 | |
paul@218 | 327 | |
paul@237 | 328 | /* RTC adapter functions. */ |
paul@237 | 329 | |
paul@240 | 330 | void *rtc_init(l4_addr_t start, void *cpm) |
paul@237 | 331 | { |
paul@240 | 332 | return x1600_rtc_init(start, cpm); |
paul@237 | 333 | } |
paul@237 | 334 | |
paul@237 | 335 | void rtc_disable(void *rtc) |
paul@237 | 336 | { |
paul@237 | 337 | x1600_rtc_disable(rtc); |
paul@237 | 338 | } |
paul@237 | 339 | |
paul@237 | 340 | void rtc_enable(void *rtc) |
paul@237 | 341 | { |
paul@237 | 342 | x1600_rtc_enable(rtc); |
paul@237 | 343 | } |
paul@237 | 344 | |
paul@239 | 345 | void rtc_alarm_disable(void *rtc) |
paul@239 | 346 | { |
paul@239 | 347 | x1600_rtc_alarm_disable(rtc); |
paul@239 | 348 | } |
paul@239 | 349 | |
paul@239 | 350 | void rtc_alarm_enable(void *rtc) |
paul@239 | 351 | { |
paul@239 | 352 | x1600_rtc_alarm_enable(rtc); |
paul@239 | 353 | } |
paul@239 | 354 | |
paul@237 | 355 | uint32_t rtc_get_seconds(void *rtc) |
paul@237 | 356 | { |
paul@237 | 357 | return x1600_rtc_get_seconds(rtc); |
paul@237 | 358 | } |
paul@237 | 359 | |
paul@237 | 360 | void rtc_set_seconds(void *rtc, uint32_t seconds) |
paul@237 | 361 | { |
paul@237 | 362 | x1600_rtc_set_seconds(rtc, seconds); |
paul@237 | 363 | } |
paul@237 | 364 | |
paul@237 | 365 | uint32_t rtc_get_alarm_seconds(void *rtc) |
paul@237 | 366 | { |
paul@237 | 367 | return x1600_rtc_get_alarm_seconds(rtc); |
paul@237 | 368 | } |
paul@237 | 369 | |
paul@237 | 370 | void rtc_set_alarm_seconds(void *rtc, uint32_t seconds) |
paul@237 | 371 | { |
paul@237 | 372 | x1600_rtc_set_alarm_seconds(rtc, seconds); |
paul@237 | 373 | } |
paul@237 | 374 | |
paul@238 | 375 | void rtc_hibernate(void *rtc) |
paul@238 | 376 | { |
paul@238 | 377 | x1600_rtc_hibernate(rtc); |
paul@238 | 378 | } |
paul@238 | 379 | |
paul@237 | 380 | void rtc_power_down(void *rtc) |
paul@237 | 381 | { |
paul@237 | 382 | x1600_rtc_power_down(rtc); |
paul@237 | 383 | } |
paul@237 | 384 | |
paul@237 | 385 | void rtc_set_regulator(void *rtc, uint32_t base, uint32_t adjustment) |
paul@237 | 386 | { |
paul@237 | 387 | x1600_rtc_set_regulator(rtc, base, adjustment); |
paul@237 | 388 | } |
paul@237 | 389 | |
paul@237 | 390 | |
paul@237 | 391 | |
paul@218 | 392 | /* SPI adapter functions. */ |
paul@218 | 393 | |
paul@221 | 394 | void *spi_init(l4_addr_t spi_start, l4_addr_t start, l4_addr_t end, void *cpm) |
paul@221 | 395 | { |
paul@235 | 396 | return jz4780_spi_init(spi_start, start, end, cpm); |
paul@221 | 397 | } |
paul@221 | 398 | |
paul@222 | 399 | void *spi_get_channel(void *spi, uint8_t num, void *channel, uint64_t frequency, |
paul@222 | 400 | void *control_chip, int control_pin, int control_alt_func) |
paul@221 | 401 | { |
paul@235 | 402 | void *ch = jz4780_spi_get_channel(spi, num, channel, frequency); |
paul@222 | 403 | |
paul@235 | 404 | return spi_hybrid_get_channel(ch, control_chip, control_pin, control_alt_func); |
paul@221 | 405 | } |
paul@221 | 406 | |
paul@222 | 407 | void *spi_get_channel_gpio(uint64_t frequency, |
paul@222 | 408 | void *clock_chip, int clock_pin, |
paul@221 | 409 | void *data_chip, int data_pin, |
paul@221 | 410 | void *enable_chip, int enable_pin, |
paul@222 | 411 | void *control_chip, int control_pin) |
paul@218 | 412 | { |
paul@235 | 413 | void *ch = spi_gpio_get_channel(frequency, clock_chip, clock_pin, data_chip, |
paul@235 | 414 | data_pin, enable_chip, enable_pin, control_chip, |
paul@235 | 415 | control_pin); |
paul@235 | 416 | |
paul@235 | 417 | return spi_hybrid_get_channel(ch, control_chip, control_pin, -1); |
paul@222 | 418 | } |
paul@222 | 419 | |
paul@222 | 420 | void spi_acquire_control(void *channel, int level) |
paul@222 | 421 | { |
paul@235 | 422 | spi_hybrid_acquire_control(channel, level); |
paul@218 | 423 | } |
paul@218 | 424 | |
paul@222 | 425 | void spi_release_control(void *channel) |
paul@222 | 426 | { |
paul@235 | 427 | spi_hybrid_release_control(channel); |
paul@222 | 428 | } |
paul@222 | 429 | |
paul@235 | 430 | void spi_send(void *channel, uint32_t bytes, const uint8_t data[]) |
paul@222 | 431 | { |
paul@235 | 432 | spi_hybrid_send(channel, bytes, data); |
paul@222 | 433 | } |
paul@222 | 434 | |
paul@222 | 435 | void spi_send_units(void *channel, uint32_t bytes, const uint8_t data[], uint8_t unit_size, |
paul@236 | 436 | uint8_t char_size, int big_endian) |
paul@221 | 437 | { |
paul@236 | 438 | spi_hybrid_send_units(channel, bytes, data, unit_size, char_size, big_endian); |
paul@218 | 439 | } |
paul@218 | 440 | |
paul@236 | 441 | uint32_t spi_transfer(void *channel, l4_addr_t vaddr, |
paul@236 | 442 | l4re_dma_space_dma_addr_t paddr, uint32_t count, |
paul@236 | 443 | uint8_t unit_size, uint8_t char_size, |
paul@223 | 444 | l4_addr_t desc_vaddr, l4re_dma_space_dma_addr_t desc_paddr) |
paul@221 | 445 | { |
paul@236 | 446 | return spi_hybrid_transfer_descriptor(channel, vaddr, paddr, count, unit_size, |
paul@236 | 447 | char_size, desc_vaddr, desc_paddr); |
paul@221 | 448 | } |
paul@221 | 449 | |
paul@218 | 450 | |
paul@218 | 451 | |
paul@253 | 452 | /* TCU adapter functions. */ |
paul@253 | 453 | |
paul@253 | 454 | void *tcu_init(l4_addr_t start, l4_addr_t end) |
paul@253 | 455 | { |
paul@253 | 456 | return x1600_tcu_init(start, end); |
paul@253 | 457 | } |
paul@253 | 458 | |
paul@253 | 459 | void *tcu_get_channel(void *tcu, uint8_t channel, l4_cap_idx_t irq) |
paul@253 | 460 | { |
paul@253 | 461 | return x1600_tcu_get_channel(tcu, channel, irq); |
paul@253 | 462 | } |
paul@253 | 463 | |
paul@253 | 464 | void tcu_disable(void *tcu_channel) |
paul@253 | 465 | { |
paul@253 | 466 | x1600_tcu_disable(tcu_channel); |
paul@253 | 467 | } |
paul@253 | 468 | |
paul@253 | 469 | void tcu_enable(void *tcu_channel) |
paul@253 | 470 | { |
paul@253 | 471 | x1600_tcu_enable(tcu_channel); |
paul@253 | 472 | } |
paul@253 | 473 | |
paul@253 | 474 | int tcu_is_enabled(void *tcu_channel) |
paul@253 | 475 | { |
paul@253 | 476 | return x1600_tcu_is_enabled(tcu_channel); |
paul@253 | 477 | } |
paul@253 | 478 | |
paul@253 | 479 | uint8_t tcu_get_clock(void *tcu_channel) |
paul@253 | 480 | { |
paul@253 | 481 | return x1600_tcu_get_clock(tcu_channel); |
paul@253 | 482 | } |
paul@253 | 483 | |
paul@253 | 484 | void tcu_set_clock(void *tcu_channel, uint8_t clock) |
paul@253 | 485 | { |
paul@253 | 486 | x1600_tcu_set_clock(tcu_channel, clock); |
paul@253 | 487 | } |
paul@253 | 488 | |
paul@253 | 489 | uint32_t tcu_get_prescale(void *tcu_channel) |
paul@253 | 490 | { |
paul@253 | 491 | return x1600_tcu_get_prescale(tcu_channel); |
paul@253 | 492 | } |
paul@253 | 493 | |
paul@253 | 494 | void tcu_set_prescale(void *tcu_channel, uint32_t prescale) |
paul@253 | 495 | { |
paul@253 | 496 | x1600_tcu_set_prescale(tcu_channel, prescale); |
paul@253 | 497 | } |
paul@253 | 498 | |
paul@253 | 499 | uint32_t tcu_get_counter(void *tcu_channel) |
paul@253 | 500 | { |
paul@253 | 501 | return x1600_tcu_get_counter(tcu_channel); |
paul@253 | 502 | } |
paul@253 | 503 | |
paul@253 | 504 | void tcu_set_counter(void *tcu_channel, uint32_t value) |
paul@253 | 505 | { |
paul@253 | 506 | x1600_tcu_set_counter(tcu_channel, value); |
paul@253 | 507 | } |
paul@253 | 508 | |
paul@253 | 509 | uint8_t tcu_get_count_mode(void *tcu_channel) |
paul@253 | 510 | { |
paul@253 | 511 | return x1600_tcu_get_count_mode(tcu_channel); |
paul@253 | 512 | } |
paul@253 | 513 | |
paul@253 | 514 | void tcu_set_count_mode(void *tcu_channel, uint8_t mode) |
paul@253 | 515 | { |
paul@253 | 516 | x1600_tcu_set_count_mode(tcu_channel, mode); |
paul@253 | 517 | } |
paul@253 | 518 | |
paul@253 | 519 | uint32_t tcu_get_full_data_value(void *tcu_channel) |
paul@253 | 520 | { |
paul@253 | 521 | return x1600_tcu_get_full_data_value(tcu_channel); |
paul@253 | 522 | } |
paul@253 | 523 | |
paul@253 | 524 | void tcu_set_full_data_value(void *tcu_channel, uint32_t value) |
paul@253 | 525 | { |
paul@253 | 526 | x1600_tcu_set_full_data_value(tcu_channel, value); |
paul@253 | 527 | } |
paul@253 | 528 | |
paul@253 | 529 | uint32_t tcu_get_half_data_value(void *tcu_channel) |
paul@253 | 530 | { |
paul@253 | 531 | return x1600_tcu_get_half_data_value(tcu_channel); |
paul@253 | 532 | } |
paul@253 | 533 | |
paul@253 | 534 | void tcu_set_half_data_value(void *tcu_channel, uint32_t value) |
paul@253 | 535 | { |
paul@253 | 536 | x1600_tcu_set_half_data_value(tcu_channel, value); |
paul@253 | 537 | } |
paul@253 | 538 | |
paul@253 | 539 | int tcu_get_full_data_mask(void *tcu_channel) |
paul@253 | 540 | { |
paul@253 | 541 | return x1600_tcu_get_full_data_mask(tcu_channel); |
paul@253 | 542 | } |
paul@253 | 543 | |
paul@253 | 544 | void tcu_set_full_data_mask(void *tcu_channel, int masked) |
paul@253 | 545 | { |
paul@253 | 546 | x1600_tcu_set_full_data_mask(tcu_channel, masked); |
paul@253 | 547 | } |
paul@253 | 548 | |
paul@253 | 549 | int tcu_get_half_data_mask(void *tcu_channel) |
paul@253 | 550 | { |
paul@253 | 551 | return x1600_tcu_get_half_data_mask(tcu_channel); |
paul@253 | 552 | } |
paul@253 | 553 | |
paul@253 | 554 | void tcu_set_half_data_mask(void *tcu_channel, int masked) |
paul@253 | 555 | { |
paul@253 | 556 | x1600_tcu_set_half_data_mask(tcu_channel, masked); |
paul@253 | 557 | } |
paul@253 | 558 | |
paul@253 | 559 | int tcu_have_interrupt(void *tcu_channel) |
paul@253 | 560 | { |
paul@253 | 561 | return x1600_tcu_have_interrupt(tcu_channel); |
paul@253 | 562 | } |
paul@253 | 563 | |
paul@253 | 564 | int tcu_wait_for_irq(void *tcu_channel, uint32_t timeout) |
paul@253 | 565 | { |
paul@253 | 566 | return x1600_tcu_wait_for_irq(tcu_channel, timeout); |
paul@253 | 567 | } |
paul@253 | 568 | |
paul@253 | 569 | |
paul@253 | 570 | |
paul@218 | 571 | /* Memory regions. */ |
paul@218 | 572 | |
paul@236 | 573 | const char *io_memory_regions[] = { |
paul@218 | 574 | [AIC] = "x1600-aic", |
paul@218 | 575 | [CPM] = "x1600-cpm", |
paul@218 | 576 | [DMA] = "x1600-dma", |
paul@218 | 577 | [GPIO] = "x1600-gpio", |
paul@218 | 578 | [I2C] = "x1600-i2c", |
paul@237 | 579 | [RTC] = "x1600-rtc", |
paul@221 | 580 | [SSI] = "x1600-ssi", |
paul@253 | 581 | [TCU] = "x1600-tcu", |
paul@218 | 582 | }; |
paul@218 | 583 | |
paul@218 | 584 | |
paul@218 | 585 | |
paul@218 | 586 | /* AIC definitions. */ |
paul@218 | 587 | |
paul@218 | 588 | void *aic_channels[] = {NULL}; |
paul@218 | 589 | |
paul@218 | 590 | const unsigned int num_aic_channels = 1; |
paul@218 | 591 | |
paul@218 | 592 | l4_cap_idx_t aic_irqs[] = {L4_INVALID_CAP}; |
paul@218 | 593 | |
paul@218 | 594 | |
paul@218 | 595 | |
paul@218 | 596 | /* CPM definitions. */ |
paul@218 | 597 | |
paul@218 | 598 | struct clock_info clocks[] = { |
paul@239 | 599 | {"ext", Clock_external, "EXCLK"}, |
paul@239 | 600 | {"ext_512", Clock_external_div_512, "EXCLK/512"}, |
paul@239 | 601 | {"rtc_ext", Clock_rtc_external, "RTCLK"}, |
paul@239 | 602 | {"plla", Clock_pll_A, "PLL A"}, |
paul@239 | 603 | {"plle", Clock_pll_E, "PLL E"}, |
paul@239 | 604 | {"pllm", Clock_pll_M, "PLL M"}, |
paul@239 | 605 | {"main", Clock_main, "Main (SCLK_A)"}, |
paul@239 | 606 | {"cpu", Clock_cpu, "CPU"}, |
paul@240 | 607 | {"l2c", Clock_l2cache, "L2 cache"}, |
paul@239 | 608 | {"ahb0", Clock_hclock0, "AHB0"}, |
paul@239 | 609 | {"ahb2", Clock_hclock2, "AHB2"}, |
paul@239 | 610 | {"apb", Clock_pclock, "APB"}, |
paul@239 | 611 | {"aic", Clock_aic, "AIC"}, |
paul@239 | 612 | {"dma", Clock_dma, "DMA"}, |
paul@239 | 613 | {"lcd0", Clock_lcd_pixel0, "LCD pixel"}, |
paul@239 | 614 | {"msc0", Clock_msc0, "MSC0"}, |
paul@239 | 615 | {"msc1", Clock_msc1, "MSC1"}, |
paul@239 | 616 | {"otg", Clock_otg0, "USB OTG"}, |
paul@239 | 617 | {"i2c0", Clock_i2c0, "I2C0"}, |
paul@239 | 618 | {"i2c1", Clock_i2c1, "I2C1"}, |
paul@239 | 619 | {"i2s0", Clock_i2s0, "I2S0"}, |
paul@239 | 620 | {"i2s1", Clock_i2s1, "I2S1"}, |
paul@239 | 621 | {"i2s0r", Clock_i2s0_rx, "I2S0 RX"}, |
paul@239 | 622 | {"i2s0t", Clock_i2s0_tx, "I2S0 TX"}, |
paul@239 | 623 | {"rtc", Clock_rtc, "RTC"}, |
paul@239 | 624 | {"ssi0", Clock_ssi0, "SSI"}, |
paul@239 | 625 | {"uart0", Clock_uart0, "UART0"}, |
paul@239 | 626 | {"uart1", Clock_uart1, "UART1"}, |
paul@239 | 627 | {"uart2", Clock_uart2, "UART2"}, |
paul@239 | 628 | {"uart3", Clock_uart3, "UART3"}, |
paul@243 | 629 | {"usbphy", Clock_usb_phy, "USB PHY"}, |
paul@243 | 630 | {NULL, Clock_none, NULL}, |
paul@218 | 631 | }; |
paul@218 | 632 | |
paul@218 | 633 | |
paul@218 | 634 | |
paul@218 | 635 | /* DMA definitions. */ |
paul@218 | 636 | |
paul@218 | 637 | void *dma_channels[32] = {NULL}; |
paul@218 | 638 | |
paul@218 | 639 | const unsigned int num_dma_channels = 32; |
paul@218 | 640 | |
paul@221 | 641 | struct dma_region dma_regions[8]; |
paul@218 | 642 | |
paul@221 | 643 | const unsigned int num_dma_regions = 8; |
paul@218 | 644 | |
paul@218 | 645 | l4_cap_idx_t dma_irq = L4_INVALID_CAP; |
paul@218 | 646 | |
paul@218 | 647 | |
paul@218 | 648 | |
paul@218 | 649 | /* GPIO definitions. */ |
paul@218 | 650 | |
paul@218 | 651 | struct gpio_port gpio_ports[] = { |
paul@218 | 652 | {0xffffffff, 0x00000000}, |
paul@218 | 653 | {0xdffbf7bf, 0x00000000}, |
paul@218 | 654 | {0x987e0000, 0x07000007}, |
paul@218 | 655 | {0x0000003f, 0x00000000} |
paul@218 | 656 | }; |
paul@218 | 657 | |
paul@218 | 658 | const unsigned int num_gpio_ports = 4; |
paul@218 | 659 | |
paul@218 | 660 | const char gpio_port_labels[] = "ABCD"; |
paul@218 | 661 | |
paul@218 | 662 | |
paul@218 | 663 | |
paul@218 | 664 | /* I2C definitions. */ |
paul@218 | 665 | |
paul@218 | 666 | void *i2c_channels[] = {NULL, NULL}; |
paul@218 | 667 | |
paul@218 | 668 | const unsigned int num_i2c_channels = 2; |
paul@218 | 669 | |
paul@218 | 670 | l4_cap_idx_t i2c_irqs[] = {L4_INVALID_CAP, L4_INVALID_CAP}; |
paul@218 | 671 | |
paul@218 | 672 | |
paul@218 | 673 | |
paul@218 | 674 | /* SPI definitions. */ |
paul@218 | 675 | |
paul@218 | 676 | void *spi_channels[] = {NULL}; |
paul@218 | 677 | |
paul@218 | 678 | const unsigned int num_spi_channels = 1; |
paul@253 | 679 | |
paul@253 | 680 | |
paul@253 | 681 | |
paul@253 | 682 | /* TCU definitions. */ |
paul@253 | 683 | |
paul@253 | 684 | void *tcu_channels[] = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; |
paul@253 | 685 | |
paul@253 | 686 | const unsigned int num_tcu_channels = 8; |
paul@253 | 687 | |
paul@253 | 688 | l4_cap_idx_t tcu_irq = L4_INVALID_CAP; |