#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 09/21/16 at 08:19:21 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 09/21/16 at 08:21:58 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 09/21/16 at 08:28:57 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 09/21/16 at 22:38:07 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 09/27/16 at 05:36:27 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 05/11/17 at 07:31:02 by Sebastian Huber

Milestone: 4.124.12.0

comment:7 Changed on 11/09/17 at 06:27:14 by Sebastian Huber

Milestone: 4.12.05.1

Milestone renamed

Note: See TracTickets for help on using tickets.