# HG changeset patch # User Paul Boddie # Date 1698160971 -7200 # Node ID 1d4ce68b74f1d41bf1e9111954ab4d1934a62ab1 # Parent 0221ee7cf79a7aea203a5adb950be52af3e8d6f4 Removed superfluous functions and tidied up initialisation slightly. diff -r 0221ee7cf79a -r 1d4ce68b74f1 pkg/devices/lib/i2c/include/i2c-x1600.h --- a/pkg/devices/lib/i2c/include/i2c-x1600.h Tue Oct 24 17:20:58 2023 +0200 +++ b/pkg/devices/lib/i2c/include/i2c-x1600.h Tue Oct 24 17:22:51 2023 +0200 @@ -51,8 +51,8 @@ int _stop; public: - I2c_x1600_channel(l4_addr_t start, Cpm_x1600_chip *cpm, - uint32_t frequency); + I2c_x1600_channel(l4_addr_t start, enum Clock_identifiers clock, + Cpm_x1600_chip *cpm, uint32_t frequency); uint32_t get_frequency(); void set_target(uint8_t addr); @@ -128,8 +128,6 @@ void *x1600_i2c_init(l4_addr_t start, l4_addr_t end, void *cpm, uint32_t frequency); -void x1600_i2c_disable(void *i2c_channel); - void *x1600_i2c_get_channel(void *i2c, uint8_t channel); uint32_t x1600_i2c_get_frequency(void *i2c_channel); @@ -156,6 +154,4 @@ int x1600_i2c_failed(void *i2c_channel); -void x1600_i2c_stop(void *i2c_channel); - EXTERN_C_END diff -r 0221ee7cf79a -r 1d4ce68b74f1 pkg/devices/lib/i2c/src/Makefile --- a/pkg/devices/lib/i2c/src/Makefile Tue Oct 24 17:20:58 2023 +0200 +++ b/pkg/devices/lib/i2c/src/Makefile Tue Oct 24 17:22:51 2023 +0200 @@ -8,6 +8,6 @@ PRIVATE_INCDIR += $(PKGDIR)/lib/i2c/include -REQUIRES_LIBS := l4re_c l4re_c-util libdrivers-common libdrivers-gpio +REQUIRES_LIBS := l4re_c l4re_c-util libdrivers-common libdrivers-cpm libdrivers-gpio include $(L4DIR)/mk/lib.mk diff -r 0221ee7cf79a -r 1d4ce68b74f1 pkg/devices/lib/i2c/src/x1600.cc --- a/pkg/devices/lib/i2c/src/x1600.cc Tue Oct 24 17:20:58 2023 +0200 +++ b/pkg/devices/lib/i2c/src/x1600.cc Tue Oct 24 17:22:51 2023 +0200 @@ -166,11 +166,13 @@ // Initialise a channel. I2c_x1600_channel::I2c_x1600_channel(l4_addr_t start, - Cpm_x1600_chip *cpm, - uint32_t frequency) + enum Clock_identifiers clock, + Cpm_x1600_chip *cpm, + uint32_t frequency) : _cpm(cpm), _frequency(frequency) { _regs = new Hw::Mmio_register_block<32>(start); + _cpm->start_clock(clock); } // Enable the channel. @@ -687,13 +689,10 @@ I2c_x1600_chip::get_channel(uint8_t channel) { l4_addr_t block = _start + channel * I2c_block_offset; - enum Clock_identifiers bits[] = {Clock_i2c0, Clock_i2c1}; + enum Clock_identifiers clocks[] = {Clock_i2c0, Clock_i2c1}; if (channel < 2) - { - _cpm->start_clock(bits[channel]); - return new I2c_x1600_channel(block, _cpm, _frequency); - } + return new I2c_x1600_channel(block, clocks[channel], _cpm, _frequency); else throw -L4_EINVAL; } @@ -707,11 +706,6 @@ return (void *) new I2c_x1600_chip(start, end, static_cast(cpm), frequency); } -void x1600_i2c_disable(void *i2c_channel) -{ - static_cast(i2c_channel)->disable(); -} - void *x1600_i2c_get_channel(void *i2c, uint8_t channel) { return static_cast(i2c)->get_channel(channel); @@ -773,8 +767,3 @@ { return static_cast(i2c_channel)->failed(); } - -void x1600_i2c_stop(void *i2c_channel) -{ - static_cast(i2c_channel)->stop(); -}