1.1 --- a/pkg/devices/lib/i2c/include/i2c-x1600.h Tue Oct 24 17:20:58 2023 +0200
1.2 +++ b/pkg/devices/lib/i2c/include/i2c-x1600.h Tue Oct 24 17:22:51 2023 +0200
1.3 @@ -51,8 +51,8 @@
1.4 int _stop;
1.5
1.6 public:
1.7 - I2c_x1600_channel(l4_addr_t start, Cpm_x1600_chip *cpm,
1.8 - uint32_t frequency);
1.9 + I2c_x1600_channel(l4_addr_t start, enum Clock_identifiers clock,
1.10 + Cpm_x1600_chip *cpm, uint32_t frequency);
1.11
1.12 uint32_t get_frequency();
1.13 void set_target(uint8_t addr);
1.14 @@ -128,8 +128,6 @@
1.15 void *x1600_i2c_init(l4_addr_t start, l4_addr_t end, void *cpm,
1.16 uint32_t frequency);
1.17
1.18 -void x1600_i2c_disable(void *i2c_channel);
1.19 -
1.20 void *x1600_i2c_get_channel(void *i2c, uint8_t channel);
1.21
1.22 uint32_t x1600_i2c_get_frequency(void *i2c_channel);
1.23 @@ -156,6 +154,4 @@
1.24
1.25 int x1600_i2c_failed(void *i2c_channel);
1.26
1.27 -void x1600_i2c_stop(void *i2c_channel);
1.28 -
1.29 EXTERN_C_END
2.1 --- a/pkg/devices/lib/i2c/src/Makefile Tue Oct 24 17:20:58 2023 +0200
2.2 +++ b/pkg/devices/lib/i2c/src/Makefile Tue Oct 24 17:22:51 2023 +0200
2.3 @@ -8,6 +8,6 @@
2.4
2.5 PRIVATE_INCDIR += $(PKGDIR)/lib/i2c/include
2.6
2.7 -REQUIRES_LIBS := l4re_c l4re_c-util libdrivers-common libdrivers-gpio
2.8 +REQUIRES_LIBS := l4re_c l4re_c-util libdrivers-common libdrivers-cpm libdrivers-gpio
2.9
2.10 include $(L4DIR)/mk/lib.mk
3.1 --- a/pkg/devices/lib/i2c/src/x1600.cc Tue Oct 24 17:20:58 2023 +0200
3.2 +++ b/pkg/devices/lib/i2c/src/x1600.cc Tue Oct 24 17:22:51 2023 +0200
3.3 @@ -166,11 +166,13 @@
3.4 // Initialise a channel.
3.5
3.6 I2c_x1600_channel::I2c_x1600_channel(l4_addr_t start,
3.7 - Cpm_x1600_chip *cpm,
3.8 - uint32_t frequency)
3.9 + enum Clock_identifiers clock,
3.10 + Cpm_x1600_chip *cpm,
3.11 + uint32_t frequency)
3.12 : _cpm(cpm), _frequency(frequency)
3.13 {
3.14 _regs = new Hw::Mmio_register_block<32>(start);
3.15 + _cpm->start_clock(clock);
3.16 }
3.17
3.18 // Enable the channel.
3.19 @@ -687,13 +689,10 @@
3.20 I2c_x1600_chip::get_channel(uint8_t channel)
3.21 {
3.22 l4_addr_t block = _start + channel * I2c_block_offset;
3.23 - enum Clock_identifiers bits[] = {Clock_i2c0, Clock_i2c1};
3.24 + enum Clock_identifiers clocks[] = {Clock_i2c0, Clock_i2c1};
3.25
3.26 if (channel < 2)
3.27 - {
3.28 - _cpm->start_clock(bits[channel]);
3.29 - return new I2c_x1600_channel(block, _cpm, _frequency);
3.30 - }
3.31 + return new I2c_x1600_channel(block, clocks[channel], _cpm, _frequency);
3.32 else
3.33 throw -L4_EINVAL;
3.34 }
3.35 @@ -707,11 +706,6 @@
3.36 return (void *) new I2c_x1600_chip(start, end, static_cast<Cpm_x1600_chip *>(cpm), frequency);
3.37 }
3.38
3.39 -void x1600_i2c_disable(void *i2c_channel)
3.40 -{
3.41 - static_cast<I2c_x1600_channel *>(i2c_channel)->disable();
3.42 -}
3.43 -
3.44 void *x1600_i2c_get_channel(void *i2c, uint8_t channel)
3.45 {
3.46 return static_cast<I2c_x1600_chip *>(i2c)->get_channel(channel);
3.47 @@ -773,8 +767,3 @@
3.48 {
3.49 return static_cast<I2c_x1600_channel *>(i2c_channel)->failed();
3.50 }
3.51 -
3.52 -void x1600_i2c_stop(void *i2c_channel)
3.53 -{
3.54 - static_cast<I2c_x1600_channel *>(i2c_channel)->stop();
3.55 -}