#2788 closed enhancement (wontfix)

RTEMS I2C API only defines Standard-mode (Sm) speed as a default.

Reported by: Chris Johns Owned by: Chris Johns
Priority: normal Milestone: 5.1
Component: score Version: 4.10
Severity: normal Keywords:
Cc: Blocked By:
Blocking:

Description

The RTEMS I2C API as defined in cpukit/dev/include/dev/i2c/i2c.h only defines the bus speed as Standard-mode (Sm) as defined by the I2C standard. This is set as I2C_BUS_CLOCK_DEFAULT. The default speed is defined by the hardware, ie the devices connected, and not this API.

The API should define the speeds as defined in the I2C standard and there should be no default. Drivers like the Cadence driver for the Zynq should be modified to require the bus speed be provided and all future drivers need to provide the speed.

Change History (7)

comment:1 Changed on Sep 21, 2016 at 8:19:21 AM by Sebastian Huber

The cpukit/dev/include/dev/i2c/i2c.h is an I2C bus implementation header file not a part of the user API (<linux/i2c.h> and <linux/i2c-dev.h>. A driver must have an initial speed. The I2C_BUS_CLOCK_DEFAULT is the recommended initial speed.

comment:2 Changed on Sep 21, 2016 at 8:21:58 AM by Chris Johns

A driver's initial speed needs to match the hardware. There is nothing that can be recommended. It requires analysis and a real value.

comment:3 Changed on Sep 21, 2016 at 8:28:57 AM by Sebastian Huber

Ok, the set clock IO control is not part of the Linux user-space API. You can set it via the RTEMS specific I2C_BUS_SET_CLOCK IO control.

It is up to the application/board initialization code to set the right speed for a particular I2C bus. The generic I2C bus driver cannot and should not know this. They have to choose an arbitrary initial value.

comment:4 in reply to:  3 Changed on Sep 21, 2016 at 10:38:07 PM by Chris Johns

Resolution: wontfix
Status: newclosed

Replying to sebastian.huber:

Ok, the set clock IO control is not part of the Linux user-space API. You can set it via the RTEMS specific I2C_BUS_SET_CLOCK IO control.

I did not pick up this interface to control the clock speed.

This approach fits with the Xilinx AXI I2C controller where the bus speed is best handled by the IP integrator placing the IP into the FPGA. There is no point having software control the clock speed, the FPGA needs to do this. In this case setting the clock speed will fail, which is the default.

Thanks.

comment:5 Changed on Sep 27, 2016 at 5:36:27 AM by Sebastian Huber

There is an I2C bus driver handler for the clock setting. You can return an error code, if the user wants an unavailable clock frequency:

  /**
   * @brief Sets the bus clock.
   *
   * @param[in] bus The bus control.
   * @param[in] clock The desired bus clock in Hz.
   *
   * @retval 0 Successful operation.
   * @retval negative Negative error number in case of an error.
   */
  int (*set_clock)(i2c_bus *bus, unsigned long clock);

comment:6 Changed on May 11, 2017 at 7:31:02 AM by Sebastian Huber

Milestone: 4.124.12.0

comment:7 Changed on Nov 9, 2017 at 6:27:14 AM by Sebastian Huber

Milestone: 4.12.05.1

Milestone renamed

Note: See TracTickets for help on using tickets.