1.1 --- a/pkg/devices/lib/i2c/include/i2c-x1600.h Sat Oct 28 01:15:45 2023 +0200
1.2 +++ b/pkg/devices/lib/i2c/include/i2c-x1600.h Sun Oct 29 16:14:38 2023 +0100
1.3 @@ -28,93 +28,28 @@
1.4
1.5 #ifdef __cplusplus
1.6
1.7 -#include <l4/devices/cpm-x1600.h>
1.8 -#include <l4/devices/hw_mmio_register_block.h>
1.9 +#include <l4/devices/i2c-common.h>
1.10
1.11 // I2C channel.
1.12
1.13 -class I2c_x1600_channel
1.14 +class I2c_x1600_channel : public I2c_channel
1.15 {
1.16 -private:
1.17 - Hw::Register_block<32> _regs;
1.18 - Cpm_x1600_chip *_cpm;
1.19 - uint32_t _frequency;
1.20 -
1.21 - // Buffer management.
1.22 -
1.23 - unsigned int _pos, _reqpos, _total;
1.24 - uint8_t *_buf;
1.25 -
1.26 - // Status conditions.
1.27 -
1.28 - int _fail;
1.29 - int _stop;
1.30 -
1.31 public:
1.32 - I2c_x1600_channel(l4_addr_t start, enum Clock_identifiers clock,
1.33 - Cpm_x1600_chip *cpm, uint32_t frequency);
1.34 -
1.35 - uint32_t get_frequency();
1.36 - void set_target(uint8_t addr);
1.37 -
1.38 - // Reading initiation and execution.
1.39 -
1.40 - void start_read(uint8_t buf[], unsigned int total, int stop = 0);
1.41 - void read();
1.42 -
1.43 - // Writing initiation and execution.
1.44 -
1.45 - void start_write(uint8_t buf[], unsigned int total, int stop = 0);
1.46 - void write();
1.47 -
1.48 - // Transaction control.
1.49 -
1.50 - void stop();
1.51 - void disable();
1.52 -
1.53 - // Specific status conditions.
1.54 -
1.55 - unsigned int have_read();
1.56 - unsigned int have_written();
1.57 - int read_done();
1.58 - int write_done();
1.59 -
1.60 - int failed();
1.61 - int read_failed();
1.62 - int write_failed();
1.63 -
1.64 -private:
1.65 - void enable();
1.66 -
1.67 - int active();
1.68 - int have_input();
1.69 - int have_output();
1.70 - int can_send();
1.71 -
1.72 - void reset_flags();
1.73 - void init_parameters();
1.74 - void set_frequency();
1.75 -
1.76 - void set_read_threshold();
1.77 - void queue_reads();
1.78 - void queue_writes();
1.79 - void store_reads();
1.80 + explicit I2c_x1600_channel(l4_addr_t start, enum Clock_identifiers clock,
1.81 + Cpm_chip *cpm, uint32_t frequency);
1.82 };
1.83
1.84 // I2C device control.
1.85
1.86 -class I2c_x1600_chip
1.87 +class I2c_x1600_chip : public I2c_chip
1.88 {
1.89 -private:
1.90 - l4_addr_t _start, _end;
1.91 - Cpm_x1600_chip *_cpm;
1.92 - uint32_t _frequency;
1.93 +protected:
1.94 + unsigned int num_channels()
1.95 + { return 2; }
1.96
1.97 public:
1.98 - I2c_x1600_chip(l4_addr_t start, l4_addr_t end, Cpm_x1600_chip *cpm,
1.99 - uint32_t frequency);
1.100 -
1.101 - I2c_x1600_channel *get_channel(uint8_t channel);
1.102 + explicit I2c_x1600_chip(l4_addr_t start, l4_addr_t end, Cpm_chip *cpm,
1.103 + uint32_t frequency);
1.104 };
1.105
1.106 #endif /* __cplusplus */