Landfall

Change of pkg/landfall-examples/hw_info/x1600.c

235:438287f28c11
pkg/landfall-examples/hw_info/x1600.c cpm-library-improvements
     1.1 --- a/pkg/landfall-examples/hw_info/x1600.c	Mon Nov 13 01:18:52 2023 +0100
     1.2 +++ b/pkg/landfall-examples/hw_info/x1600.c	Mon Nov 13 01:20:09 2023 +0100
     1.3 @@ -25,7 +25,8 @@
     1.4  #include <l4/devices/gpio-x1600.h>
     1.5  #include <l4/devices/i2c-x1600.h>
     1.6  #include <l4/devices/spi-gpio.h>
     1.7 -// #include <l4/devices/spi-hybrid.h>
     1.8 +#include <l4/devices/spi-hybrid.h>
     1.9 +#include <l4/devices/spi-jz4780.h>
    1.10  #include "common.h"
    1.11  
    1.12  
    1.13 @@ -326,18 +327,15 @@
    1.14  
    1.15  void *spi_init(l4_addr_t spi_start, l4_addr_t start, l4_addr_t end, void *cpm)
    1.16  {
    1.17 -  (void) spi_start; (void) start; (void) end; (void) cpm;
    1.18 -  return NULL;
    1.19 +  return jz4780_spi_init(spi_start, start, end, cpm);
    1.20  }
    1.21  
    1.22  void *spi_get_channel(void *spi, uint8_t num, void *channel, uint64_t frequency,
    1.23                        void *control_chip, int control_pin, int control_alt_func)
    1.24  {
    1.25 -  /* NOTE: Initialisation of a hybrid channel to be supported. */
    1.26 +  void *ch = jz4780_spi_get_channel(spi, num, channel, frequency);
    1.27  
    1.28 -  (void) spi; (void) num; (void) channel; (void) frequency;
    1.29 -  (void) control_chip; (void) control_pin; (void) control_alt_func;
    1.30 -  return NULL;
    1.31 +  return spi_hybrid_get_channel(ch, control_chip, control_pin, control_alt_func);
    1.32  }
    1.33  
    1.34  void *spi_get_channel_gpio(uint64_t frequency,
    1.35 @@ -346,52 +344,44 @@
    1.36                             void *enable_chip, int enable_pin,
    1.37                             void *control_chip, int control_pin)
    1.38  {
    1.39 -  return spi_gpio_get_channel(frequency, clock_chip, clock_pin, data_chip,
    1.40 -                              data_pin, enable_chip, enable_pin, control_chip,
    1.41 -                              control_pin);
    1.42 +  void *ch = spi_gpio_get_channel(frequency, clock_chip, clock_pin, data_chip,
    1.43 +                                  data_pin, enable_chip, enable_pin, control_chip,
    1.44 +                                  control_pin);
    1.45 +
    1.46 +  return spi_hybrid_get_channel(ch, control_chip, control_pin, -1);
    1.47  }
    1.48  
    1.49  void spi_acquire_control(void *channel, int level)
    1.50  {
    1.51 -  /* NOTE: Not yet supported. */
    1.52 -
    1.53 -  (void) channel; (void) level;
    1.54 -  // spi_hybrid_acquire_control(channel, level);
    1.55 +  spi_hybrid_acquire_control(channel, level);
    1.56  }
    1.57  
    1.58  void spi_release_control(void *channel)
    1.59  {
    1.60 -  /* NOTE: Not yet supported. */
    1.61 -
    1.62 -  (void) channel;
    1.63 -  // spi_hybrid_release_control(channel);
    1.64 +  spi_hybrid_release_control(channel);
    1.65  }
    1.66  
    1.67 -void spi_send_gpio(void *channel, uint32_t bytes, const uint8_t data[])
    1.68 +void spi_send(void *channel, uint32_t bytes, const uint8_t data[])
    1.69  {
    1.70 -  spi_gpio_send(channel, bytes, data);
    1.71 +  spi_hybrid_send(channel, bytes, data);
    1.72  }
    1.73  
    1.74  void spi_send_units(void *channel, uint32_t bytes, const uint8_t data[], uint8_t unit_size,
    1.75                      uint8_t char_size)
    1.76  {
    1.77 -  /* NOTE: Not yet supported. */
    1.78 -
    1.79 -  (void) channel; (void) bytes; (void) data; (void) unit_size; (void) char_size;
    1.80 -  // x1600_spi_send_units(channel, bytes, data, unit_size, char_size);
    1.81 +  spi_hybrid_send_units(channel, bytes, data, unit_size, char_size);
    1.82  }
    1.83  
    1.84  uint32_t spi_transfer(void *channel, l4re_dma_space_dma_addr_t paddr,
    1.85                        uint32_t count, uint8_t unit_size, uint8_t char_size,
    1.86                        l4_addr_t desc_vaddr, l4re_dma_space_dma_addr_t desc_paddr)
    1.87  {
    1.88 -  /* NOTE: Not yet supported. */
    1.89 +  /* Transfer is not supported by the common interface. */
    1.90  
    1.91 -  (void) channel; (void) paddr; (void) count; (void) unit_size; (void) char_size;
    1.92 -  (void) desc_vaddr; (void) desc_paddr;
    1.93 -  // return x1600_spi_transfer(channel, paddr, count, unit_size, char_size,
    1.94 -  //                           desc_vaddr, desc_paddr);
    1.95 -  return 0;
    1.96 +  void *ch = spi_hybrid_get_raw_channel(channel);
    1.97 +
    1.98 +  return jz4780_spi_transfer_descriptor(ch, paddr, count, unit_size, char_size,
    1.99 +                                        desc_vaddr, desc_paddr);
   1.100  }
   1.101  
   1.102