Skip to content

Commit

Permalink
Add Chris Boot's i2c driver
Browse files Browse the repository at this point in the history
i2c-bcm2708: fixed baudrate

Fixed issue where the wrong CDIV value was set for baudrates below 3815 Hz (for 250MHz bus clock).
In that case the computed CDIV value was more than 0xffff. However the CDIV register width is only 16 bits.
This resulted in incorrect setting of CDIV and higher baudrate than intended.
Example: 3500Hz -> CDIV=0x11704 -> CDIV(16bit)=0x1704 -> 42430Hz
After correction: 3500Hz -> CDIV=0x11704 -> CDIV(16bit)=0xffff -> 3815Hz
The correct baudrate is shown in the log after the cdiv > 0xffff correction.

Perform I2C combined transactions when possible

Perform I2C combined transactions whenever possible, within the
restrictions of the Broadcomm Serial Controller.

Disable DONE interrupt during TA poll

Prevent interrupt from being triggered if poll is missed and transfer
starts and finishes.

i2c: Make combined transactions optional and disabled by default

i2c: bcm2708: add device tree support

Add DT support to driver and add to .dtsi file.
Setup pins in .dts file.
i2c is disabled by default.

Signed-off-by: Noralf Tronnes <notro@tronnes.org>

bcm2708: don't register i2c controllers when using DT

The devices for the i2c controllers are in the Device Tree.
Only register devices when not using DT.

Signed-off-by: Noralf Tronnes <notro@tronnes.org>

I2C: Only register the I2C device for the current board revision

i2c_bcm2708: Fix clock reference counting

Fix grabbing lock from atomic context in i2c driver

2 main changes:
- check for timeouts in the bcm2708_bsc_setup function as indicated by this comment:
      /* poll for transfer start bit (should only take 1-20 polls) */
  This implies that the setup function can now fail so account for this everywhere it's called
- Removed the clk_get_rate call from inside the setup function as it locks a mutex and that's not ok since we call it from under a spin lock.

i2c-bcm2708: When using DT, leave the GPIO setup to pinctrl

i2c-bcm2708: Increase timeouts to allow larger transfers

Use the timeout value provided by the I2C_TIMEOUT ioctl when waiting
for completion. The default timeout is 1 second.

See: #260

i2c-bcm2708/BCM270X_DT: Add support for I2C2

The third I2C bus (I2C2) is normally reserved for HDMI use. Careless
use of this bus can break an attached display - use with caution.

It is recommended to disable accesses by VideoCore by setting
hdmi_ignore_edid=1 or hdmi_edid_file=1 in config.txt.

The interface is disabled by default - enable using the
i2c2_iknowwhatimdoing DT parameter.

bcm2708-spi: Don't use static pin configuration with DT

Also remove superfluous error checking - the SPI framework ensures the
validity of the chip_select value.

i2c-bcm2708: Remove non-DT support

Signed-off-by: Noralf Trønnes <noralf@tronnes.org>

Set the BSC_CLKT clock streching timeout to 35ms as per SMBus specs.

Fixes i2c_bcm2708: Write to FIFO correctly - v2 (#1574)

* i2c: fix i2c_bcm2708: Clear FIFO before sending data

Make sure FIFO gets cleared before trying to send
data in case of a repeated start (COMBINED=Y).

* i2c: fix i2c_bcm2708: Only write to FIFO when not full

Check if FIFO can accept data before writing.
To avoid a peripheral read on the last iteration of a loop,
both bcm2708_bsc_fifo_fill and ~drain are changed as well.
  • Loading branch information
popcornmix committed Feb 19, 2024
1 parent b5ec35a commit 4b496d1
Show file tree
Hide file tree
Showing 3 changed files with 533 additions and 0 deletions.
19 changes: 19 additions & 0 deletions drivers/i2c/busses/Kconfig
Expand Up @@ -16,6 +16,25 @@ config I2C_CCGX_UCSI
for Cypress CCGx Type-C controller. Individual bus drivers
need to select this one on demand.

config I2C_BCM2708
tristate "BCM2708 BSC"
depends on ARCH_BCM2835
help
Enabling this option will add BSC (Broadcom Serial Controller)
support for the BCM2708. BSC is a Broadcom proprietary bus compatible
with I2C/TWI/SMBus.

config I2C_BCM2708_BAUDRATE
prompt "BCM2708 I2C baudrate"
depends on I2C_BCM2708
int
default 100000
help
Set the I2C baudrate. This will alter the default value. A
different baudrate can be set by using a module parameter as well. If
no parameter is provided when loading, this is the value that will be
used.

config I2C_ALI1535
tristate "ALI 1535"
depends on PCI
Expand Down
2 changes: 2 additions & 0 deletions drivers/i2c/busses/Makefile
Expand Up @@ -3,6 +3,8 @@
# Makefile for the i2c bus drivers.
#

obj-$(CONFIG_I2C_BCM2708) += i2c-bcm2708.o

# ACPI drivers
obj-$(CONFIG_I2C_SCMI) += i2c-scmi.o

Expand Down

0 comments on commit 4b496d1

Please sign in to comment.